On Sun, Feb 18, 2018 at 09:19:12PM +0530, Neeraj Pal wrote:
> yeah, but I am asking about pledge_xbit (pledge value of any process
> in hex). See output:
>
> process name: pltestnopledge(no pledge) ps_flags:
> 101007 kern_exec: 100000 pid: 66364 pledge_xbit: 8009588f
>
> process name: pltest(with pledge("stdio",NULL)) ps_flags: 101007
> kern_exec: 100000 pid: 74005 pledge_xbit: 8
>
> Now, 2nd line is correct, because of pledge "stdio" and PLEDGE_STDIO
> is 0x0000000000000008, but I am confused with 1st line. How it becomes
> even this, 0x8009588f value without pledge.
>
> Sorry, but I think either I am not getting you or you didn't get my question.
>
> I don't know why you are telling me about PS_PLEDGE because I know
> that when PS_PLEDGE is set, then it means the process has called
> pledge.
>
> We can do this to check whether any process has called pledged or not:
>
> if ((p->p_p->ps_pledge & PS_PLEDGE) > 0) {
>
> /* pledged process */
> }
> else {
>
> /* unpledged process */
> }
No, that is not correct. ps_pledge is only valid if PS_PLEDGE is set
in ps_flags. Something like:
pledge_bits = (p->p_p->ps_flags & PS_PLEDGE) ? p->p_p->ps_pledge : 0
-Otto