This is the mail archive of the
cygwin-apps@cygwin.com
mailing list for the Cygwin project.
Re: /etc/profile, mk[passwd|group|group_l_d] messages
- From: Igor Pechtchanski <pechtcha at cs dot nyu dot edu>
- To: "Pierre A. Humblet" <Pierre dot Humblet at ieee dot org>
- Cc: "Morrison, John" <John dot Morrison at uk dot experian dot com>, cygwin-apps at cygwin dot com
- Date: Thu, 28 Aug 2003 12:39:26 -0400 (EDT)
- Subject: Re: /etc/profile, mk[passwd|group|group_l_d] messages
- References: <CCD084B0E779D411A70300508B66222605A32FE5@exchukahis02.experian.co.uk><3F4E1F33.E84C0271@ieee.org>
- Reply-to: cygwin-apps at cygwin dot com
On Thu, 28 Aug 2003, Pierre A. Humblet wrote:
> > Hows this...? (edit inline)
> >
> > oops, corrected some typos.
>
> Instead of running `id -ng` several times you can hard code the values
> (see XXX below)
>
> > case "`id -ng`" in
> > mkpasswd )
> > echo "Your group is currently \"`id -ng`\". This indicates that"
> XXX echo "Your group is currently \"mkpasswd\". This indicates that"
> > echo "the /etc/passwd (and possibly /etc/group) files should be rebuilt."
> > echo "See the man pages for mkpasswd and mkgroup then, for example, run"
> > echo "mkpasswd -l [-d] > /etc/passwd"
> > echo "mkgroup -l [-d] > /etc/group"
> > echo "as appropriate. Note that the -d switch is necessary for"
> > echo "domain users." ;;
> > mkgroup )
> > echo "Your group is currently \"`id -ng`\". This indicates that"
> XXX ditto
> > echo "the /etc/group (and possibly /etc/passwd) files should be rebuilt."
> > echo "See the man pages for mkpasswd and mkgroup then, for example, run"
> > echo "mkpasswd -l [-d] > /etc/passwd"
> > echo "mkgroup -l [-d] > /etc/group"
> > echo "as appropriate. Note that the -d switch is necessary for"
> > echo "domain users." ;;
> > mkgroup_l_d )
> > echo "The /etc/group file doesn't contain the domain groups."
> > echo "See the man page for mkgroup and then, for example, run"
> > echo "mkgroup -l -d > /etc/group"
> > echo "as appropriate."
> XXX echo "Your group name is currently \"mkpasswd_l_d\". This indicates that not all"
> XXX echo "domain users and groups are listed in the "/etc/passwd and /etc/group files."
> XXX echo "See the man pages for mkpasswd and mkgroup then, for example, run"
> XXX echo "mkpasswd -l [-d] > /etc/passwd"
> XXX echo "mkgroup -l [-d] > /etc/group"
Umm, Pierre, don't you *need* to add "-d" to mkpasswd and mkgroup
invocations to get the domain users into /etc/{passwd,group}?
Furthermore, what if you only want the *current* domain user to be
recognized? Perhaps the above should be
XXXXX echo "See the man pages for mkpasswd and mkgroup then, for example, run"
XXXXX echo "mkpasswd -l -d [-u yourUser] >> /etc/passwd"
XXXXX echo "mkgroup -l -d > /etc/group"
> > echo
> > echo "You can safely ignore this message"
> XXX echo "This message is only displayed once and can be safely ignored."
> > # only display the above once
> > cat /etc/group | sed -e 's/mkgroup_l_d/mkgroup-l-d/g' >
> > /etc/group.new mv /etc/group /etc/group.mkgroup_l_d
> > mv /etc/group.new /etc/group
>
> Let's make it fail safe, avoid invoking cat and set the mode
> sed -e 's/mkgroup_l_d/mkgroup-l-d/' /etc/group > /etc/group.new \
> && mv /etc/group /etc/group.mkgroup_l_d
> && (mv /etc/group.new /etc/group || mv /etc/group.mkgroup_l_d /etc/group ; )
> chmod a+r /etc/group
> rm -f /etc/group.mkgroup_l_d
>
> Pierre
Better yet, create temporary files in the current directory, allow writes
to /etc/group, and restore the owner/mode afterwards, i.e.,
cp -p /etc/group group.mkgroup_l_d \
&& chmod a+w /etc/group \
&& sed -e 's/^mkgroup_l_d/mkgroup-l-d/' group.mkgroup_l_d > /etc/group \
&& chmod --reference=group.mkgroup_l_d /etc/group \
&& chown --reference=group.mkgroup_l_d /etc/group
rm -f group.mkgroup_l_d
This should work even if /etc is not writeable.
Igor
--
http://cs.nyu.edu/~pechtcha/
|\ _,,,---,,_ pechtcha@cs.nyu.edu
ZZZzz /,`.-'`' -. ;-;;,_ igor@watson.ibm.com
|,4- ) )-,_. ,\ ( `'-' Igor Pechtchanski, Ph.D.
'---''(_/--' `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-. Meow!
"I have since come to realize that being between your mentor and his route
to the bathroom is a major career booster." -- Patrick Naughton