[Top][All Lists]

[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: Martin Koeppe
Subject: Re: Fwd: Re: error.c: "Unknown system error" should report errno value
Date: Wed, 3 Oct 2007 17:22:03 +0200 (CEST)

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


reply via email to

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