Joao Eriberto Mota Filho wrote:
> When I make chmod (2xxx|4xxx|6xxx) over a directory, I can set SUID
> and SGID bits. However, if I use 0xxx, the SUID and SGID bits aren't
> removed. But it can be removed if using u-s and/or g-s. So I think
> it is a chmod bug and not a kernel bug.

This is intentional behavior.  This behavior was changed in 2006.  The
goal was to make working with setgid directories easier.  In that
effort I think it is a good thing.  But personally I would rather have
seen this keep the numeric modes literal and only affect the symbolic
modes.  But it didn't work out that way.

As one of the dissenting votes I will direct you to the archive around
the time that this was implemented for the entire discussion.

  http://lists.gnu.org/archive/html/bug-coreutils/2006-07/msg00124.html

In the NEWS file you will find this entry:

* Major changes in release 6.0 (2006-08-15) [unstable]

** Changes in behavior

  chmod, install, and mkdir now preserve a directory's set-user-ID and
  set-group-ID bits unless you explicitly request otherwise.  E.g.,
  `chmod 755 DIR' and `chmod u=rwx,go=rx DIR' now preserve DIR's
  set-user-ID and set-group-ID bits instead of clearing them, and
  similarly for `mkdir -m 755 DIR' and `mkdir -m u=rwx,go=rx DIR'.  To
  clear the bits, mention them explicitly in a symbolic mode, e.g.,
  `mkdir -m u=rwx,go=rx,-s DIR'.  To set them, mention them explicitly
  in either a symbolic or a numeric mode, e.g., `mkdir -m 2755 DIR',
  `mkdir -m u=rwx,go=rx,g+s' DIR.  This change is for convenience on
  systems where these bits inherit from parents.  Unfortunately other
  operating systems are not consistent here, and portable scripts
  cannot assume the bits are set, cleared, or preserved, even when the
  bits are explicitly mentioned.  For example, OpenBSD 3.9 `mkdir -m
  777 D' preserves D's setgid bit but `chmod 777 D' clears it.
  Conversely, Solaris 10 `mkdir -m 777 D', `mkdir -m g-s D', and
  `chmod 0777 D' all preserve D's setgid bit, and you must use
  something like `chmod g-s D' to clear it.

Bob



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to