Unable to unset setguid bit

Bug #927218 reported by Lars Noodén
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
coreutils (Ubuntu)
Invalid
Undecided
Unassigned

Bug Description

In Precise, it is possible to set the guid bit for a directory but not to unset it.

$ chmod g=rwxs Y
foo@precise:/tmp/X$ ls -l
total 4
drwxrwsr-x 2 foo adm 4096 Feb 5 18:48 Y

foo@precise:/tmp/X$ chmod g= Y
foo@precise:/tmp/X$ ls -l
total 4
drwx--Sr-x 2 maintenance adm 4096 Feb 5 18:48 Y
foo@precise:/tmp/X$ chmod g=rwx Y
maintenance@precise:/tmp/X$ ls -l
total 4
drwxrwsr-x 2 foo adm 4096 Feb 5 18:48 Y

foo@precise:/tmp/X$ chmod 0775 Y
foo@precise:/tmp/X$ ls -l
total 4
drwxrwsr-x 2 foo adm 4096 Feb 5 18:48 Y

ProblemType: Bug
DistroRelease: Ubuntu 12.04
Package: bash 4.2-1ubuntu1
ProcVersionSignature: Ubuntu 3.2.0-14.23-generic-pae 3.2.3
Uname: Linux 3.2.0-14-generic-pae i686
ApportVersion: 1.91-0ubuntu1
Architecture: i386
Date: Sun Feb 5 18:52:29 2012
InstallationMedia: Ubuntu-Server 12.04 LTS "Precise Pangolin" - Alpha i386 (20111129)
ProcEnviron:
 LANGUAGE=en_US:en
 PATH=(custom, no user)
 LANG=en_US.UTF-8
 SHELL=/bin/bash
SourcePackage: bash
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
Lars Noodén (larsnooden) wrote :
Revision history for this message
Andrew McCarthy (andrewmccarthy) wrote :

Thanks for taking the time to report this. The behaviour you describe may seem surprising (and it was to me, too!), but is actually what the man page describes:

       chmod preserves a directory's set-user-ID and set-group-ID bits unless
       you explicitly specify otherwise. You can set or clear the bits with
       symbolic modes like u+s and g-s, and you can set (but not clear) the
       bits with a numeric mode.

So, you can clear the setgid bit on the directory in your example with "chmod g-s Y", but not with "chmod 0775 Y". Since this is the defined behaviour that others may have come to expect for both interactive use and in long-established scripts, it's unlikely to be changed now.

affects: bash (Ubuntu) → coreutils (Ubuntu)
Changed in coreutils (Ubuntu):
status: New → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.