bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fwd: Re: error.c: "Unknown system error" should report errno value


From: Jim Meyering
Subject: Re: Fwd: Re: error.c: "Unknown system error" should report errno value
Date: Wed, 03 Oct 2007 19:17:52 +0200

Martin Koeppe <address@hidden> wrote:

> On Wed, 3 Oct 2007, Jim Meyering wrote:
>> Martin Koeppe <address@hidden> wrote:
>>> A question arises: How should one portably test for "root"? Neither
>>> "root" nor uid 0 seem to be a POSIX requirement. I found one solution
>>> so far, but I'm not sure how good it really is:
>>>
>>> For shell scripts run:
>>> $ /usr/sbin/chroot / /bin/true
>>> If successful, you have root rights.
>>
>> I'm leery of this.
>> What if chroot works for non-privileged users on some type of system?
>>
>> Since Interix is the problem here, how about adding
>> a test that'd be run solely on that system?
>
> Yes, no problem with that.  I only thought there might be a
> possibility to check the root-ness without an explicit comparison of
> uid or username.  This need not necessarily be the chroot() function.
> But I don't know the POSIX standard in that detail.
>
> If you want an explicit check, then for Interix 3 different users/uids
> must be checked:  System (uid ???), Domain Administrator (uid 1049076)
> and local Administrator (uid 197108). All of these have "root" rights.
> See: http://www.interopcommunity.com/faqs.aspx#307

But those are all legitimate, non-root IDs on other systems,
so a test based solely on that would risk false positives.
There has to be something else (interix-specific) that will
ensure that part of the test is run only on Interix.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]