Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 14 Aug 1995 00:04:26 +1000
From:      Bruce Evans <bde@zeta.org.au>
To:        roberto@blaise.ibp.fr, wosch@cs.tu-berlin.de
Cc:        current@FreeBSD.org, davidg@FreeBSD.org
Subject:   Re: kern/679: chown(2) ignores set-user-id and set-group-id bits for root
Message-ID:  <199508131404.AAA29370@godzilla.zeta.org.au>

next in thread | raw e-mail | index | archive | help
>> That's all right and should not been changed. Unfortunately chown
>> does not clear set-user-id and set-group-id bits if you are root.

The POSIX behaviour is: set*id bits shall be cleared for non-root; it
is implementation-defined whether they are cleared for root.

I think 4.4lite doesn't clear them for root because this is the traditional
behaviour.

>I suggest the following patch (please review it David):

This isn't quite right.

1. It changes the mode(s) when the ownership change(s) are null.  (This
   is actually a bug fix.  ufs_chown() optimizes null changes to have no
   visible effect, but POSIX requires clearing the mode bits whenever
   chown() is successful (for non-root of course; we can implement TRT
   for root).  Urk.  There are a lot of bugs here.  POSIX also requires
   marking the ctime for update whenever chmod() is successful.)

2. It might change the mode when the chown() fails.  (Actually it
   probably wouldn't, because ufs_setattr() happens to check for
   ownership changes before it checks for permissions changes.
   ufs_setattr() normally only changes a single attribute.)

Anyway, it would be easier to remove the (cred->cr_*id != 0) checks
from the end of xxfs_chown() for each xxfs that supports POSIX
chown() and attributes - currently only ufs (?).

Bruce



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199508131404.AAA29370>