delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2001/05/13/08:52:16

Sender: rich AT phekda DOT freeserve DOT co DOT uk
Message-ID: <3AFE8350.71B1B4F1@phekda.freeserve.co.uk>
Date: Sun, 13 May 2001 13:51:28 +0100
From: Richard Dawe <rich AT phekda DOT freeserve DOT co DOT uk>
X-Mailer: Mozilla 4.77 [en] (X11; U; Linux 2.2.17 i586)
X-Accept-Language: de,fr
MIME-Version: 1.0
To: djgpp-workers AT delorie DOT com
Subject: Re: ANNOUNCE: Fileutils 4.0 beta 2
References: <Pine DOT SUN DOT 3 DOT 91 DOT 1010513135605 DOT 14539A AT is>
Reply-To: djgpp-workers AT delorie DOT com

Hello.

Eli Zaretskii wrote:
> 
> On Sun, 13 May 2001, Richard Dawe wrote:
>
> > Eli Zaretskii wrote:
> >
> > > The trick to set GROUP etc. was meant to avoid patching chgrp's and
> > > chown's code where they set the owner and the group.  I do think it
> > > is better to say the ownership was changed, not that it was
> > > retained. Perhaps removing GROUP from the environment right after
> > > the call to chgrp library function will do that?
> >
> > The code in chown, chgrp uses uids and gids, to determine whether the
> > file ownership has changed. Beta 2 would set the user and group names
> > in advance, so that all users and groups would appear to have the same
> > uids, gids. So modifying the environment after calling chown() would
> > not have helped, since the uid, gid would always be the same.
> 
> Sorry, I'm not following: are you describing changes in the mainline
> Fileutils code (probably not) or your modifications?  Also, when you say
> ``Beta 2 would set etc.'', do you mean those are changes that you
> introduced now and which were not in the beta for which I reported the
> problem, or do you mean these changes are already in the beta I've seen?

I was describing the behaviour of the mainline code. It extracts the uid
and/or gid from a string (e.g. user.group or user:group or group) and then
passes the uid & gid around.

For DJGPP lib/userspec.c in mainline Fileutils 4.0 actually switches the
user and group to whatever is parsed by parse_user_spec(), so that
getpwnam(), etc. succeed. It does not restore the user and group, once
parse_user_spec() has finished, which is arguably a bug. parse_user_spec()
is used by chown to parse the user.group string.

In beta 2 of the port (and previous betas) I modified lib/userspec.c to
restore the user and group to whatever was set before. I also modified
src/chgrp.c to set the group prior to parsing the group specification &
restore it afterwards, to work like chown.

In beta 2, because the user & group were set in advance in
parse_user_spec() and chgrp.c, the uid & gid returned were the same as the
ones returned by stat(). Hence, chown and chgrp (in verbose mode) would
always give you the 'user.group retained as owner of ...' message,
whatever user & group you gave it.

Up to this point I have been describing the beta that you tested with -
beta 2.

Now these changes make 4.0's chown and chgrp behave differently than
3.16's. Hence, I backed out the changes and made the ones described below.
I have not released a version with these fixes yet.

> > Anyway, I have fixed it: chown, chgrp now work like they did in
> > Fileutils 3.16. Things were complicated by the fact Fileutils 4.0 did
> > have some DJGPP-specific code in lib/*.c. It just seems to do the
> > wrong thing for Fileutils. I removed that code and my patches to
> > src/chown.c, src/chgrp.c. I reinstated some of your fixes to
> > lib/userspec.c - the ones that return the uid, gid as 2*current uid,
> > gid when parsing the user specification. src/chgrp.c needed an
> > additional patch.

"Things were complicated by the fact Fileutils 4.0 did
have some DJGPP-specific code in lib/*.c." does refer to mainline
Fileutils 4.0.

> I'm not sure this is the best plan.  The files in lib/ are used by other
> GNU packages, so any changes to them might break something else.

I agree - I realise lib/ is used also by Textutils. Are there any other
packages - Shellutils perhaps?

But from the point of view of having a working Fileutils 4.0, I think they
are OK.

> So I suggest to discuss the details: what exactly do you think is
> wrong in lib/, and why?

In parse_user_spec() lib/userspec.c sets the user and group based on the
specification, so that getpwnam(), etc. will return valid results. The
point of parse_user_spec() is to return the uid and gid of a user
name/number and group name/number. 

I can see two problems with the fixes for DJGPP:

* It does not save and restore the current user and group in the
environment. This could cause unexpected side-effects.

* It makes all user & group names map to the same uid & gid respectively.
This may be what you want in some cases. But there is no way to
distinguish between current user & group and every other user & group. In
chown and chgrp you want the second behaviour.

Eli, in the 3.16 port you added a change (for MSDOS) to set uid and gid to
2*getuid() or 2*getgid() respectively, when the user and group name
lookups failed. This allows distinction between current user & group and
other user & groups.

I'm sorry I wasn't clearer the first time. I hope this makes more sense.

Thanks, bye, Rich =]

-- 
Richard Dawe
http://www.phekda.freeserve.co.uk/richdawe/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019