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

Re: [K12OSN] Checking for Group Membership



On Thu, 30 Jan 2003, Steve Wright wrote:
>Eric Harrison wrote:
<snip>
>>	if (groups $user | grep $group) >>/dev/null ; then
>>
>>
>>These days you can't make the assumption that there is a complete
>>/etc/groups, /etc/passwd, etc ;-)
>>
>>If you use the "id" command ("groups" is just a wrapper around "id"),
>>it will work with accounts stored in LDAP, NT domains, etc.
>>
>
>well, live and learn I allus say..  thanks for that.

You wouldn't believe how many scripts I have written that parse
/etc/passwd & /etc/group ;-)   The *really* hard one to learn not to do
is expect all of the home directories to be listed in /etc/password.
I still have not found a good, cross-platform way of getting a list
of home directories ;-(

Off list I was reminded that I forgot to mention the reason why I used
the "groups" wrapper script rather than running "id -Gn" explicitly
was that the "groups" command is common between most unicies. It works
the same on the Linux, HP-UX, and Solaris I have access to, where "id -Gn"
only works on Linux. (except on the HP-UX/Solaris boxes that have all
the GNU tools installed ;-)

-Eric





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