Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 182136 - sys-apps/coreutils-7.1 with USE=acl and ext3 mounted with -o acl: cp -pr does not reset the setgid bit when appropriate
Summary: sys-apps/coreutils-7.1 with USE=acl and ext3 mounted with -o acl: cp -pr does...
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Gentoo's Team for Core System packages
Depends on:
Reported: 2007-06-15 13:45 UTC by David Leverton
Modified: 2021-01-03 18:15 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---

strace output (cp.trace,8.05 KB, text/plain)
2007-06-16 12:35 UTC, David Leverton

Note You need to log in before you can comment on or make changes to this bug.
Description David Leverton 2007-06-15 13:45:00 UTC
When copying a non-setgid directory into a setgid directory with cp -pr, the copy has its setgid bit set inappropriately.  This only happens with the acl USE-flag.  More precisely:

$ cd /tmp
$ mkdir foo
$ chmod g+s foo
$ cd foo
$ mkdir bar
$ chmod g-s bar
$ cp -pr bar baz
$ ls -l
total 8.0K
drwxr-xr-x 2 dleverton users 4.0K 2007-06-15 14:36 bar/
drwxr-sr-x 2 dleverton users 4.0K 2007-06-15 14:36 baz/

With USE=-acl, baz has mode drwxr-xr-x.
Comment 1 SpanKY gentoo-dev 2007-06-16 12:03:48 UTC
it's working for me

$ cd /tmp/
$ rm -rf foo/
$ mkdir foo
$ chmod g+s foo
$ cd foo
$ mkdir bar
$ chmod g-s bar
$ cp -pr bar baz
$ ls -l
total 8
drwxr-xr-x 2 root root 4096 2007-06-16 08:02 bar
drwxr-xr-x 2 root root 4096 2007-06-16 08:02 baz

you forgot `emerge info` ... also it'd be helpful if you ran it through `strace` and posted the output as an attachment (use the -o option)
Comment 2 David Leverton 2007-06-16 12:34:29 UTC
I'm using Paludis, but the problem also occurs with coreutils built using Portage.

# emerge --info
Portage (default-linux/amd64/2006.1, gcc-4.1.2, glibc-2.5-r3, 2.6.20-gentoo-r8 x86_64)
System uname: 2.6.20-gentoo-r8 x86_64 AMD Turion(tm) 64 X2 Mobile Technology TL-50
Gentoo Base System release 1.12.9
Timestamp of tree: Fri, 15 Jun 2007 12:30:01 +0000
ccache version 2.4 [enabled]
dev-java/java-config: 1.3.7, 2.0.32
dev-lang/python:     2.4.4-r4
dev-python/pycrypto: 2.0.1-r5
dev-util/ccache:     2.4-r7
!!! Invalid db entry: /var/db/pkg/sys-apps/paludis-scm
sys-apps/sandbox:    1.2.17
sys-devel/autoconf:  2.13, 2.61
sys-devel/automake:  1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2, 1.10
sys-devel/binutils:  2.16.1-r3
sys-devel/gcc-config: 1.3.16
sys-devel/libtool:   1.5.22
virtual/os-headers:  2.6.17-r2
CFLAGS="-march=athlon64 -msse3 -pipe -fomit-frame-pointer -O2"
CONFIG_PROTECT="/etc /usr/kde/3.5/env /usr/kde/3.5/share/config /usr/kde/3.5/shutdown /usr/share/X11/xkb /usr/share/config /usr/share/games/angband/apex /usr/share/games/angband/lib/apex /var/games"
CONFIG_PROTECT_MASK="/etc/env.d /etc/env.d/java/ /etc/gconf /etc/java-config/vms/ /etc/php/apache1-php5/ext-active/ /etc/php/apache2-php5/ext-active/ /etc/php/cgi-php5/ext-active/ /etc/php/cli-php5/ext-active/ /etc/revdep-rebuild /etc/splash /etc/terminfo /etc/texmf/web2c"
CXXFLAGS="-march=athlon64 -msse3 -pipe -fomit-frame-pointer -O2"
FEATURES="candy ccache collision-protect distlocks sandbox sfperms strict"
LINGUAS="en_GB en"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --delete-after --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --filter=H_**/files/digest-*"
PORTDIR_OVERLAY="/var/paludis/repositories/local /var/paludis/repositories/emacs /var/paludis/repositories/enlightenment /var/paludis/repositories/gentoo-haskell /var/paludis/repositories/java-experimental /var/paludis/repositories/java-overlay"
USE="X aac aalib acl acpi alsa amd64 apache2 audiofile bash-completion bzip2 cairo cdr curl dbus dri dvd dvdr emacs fam ftp gif gmp gstreamer hal iconv id3 jack jpeg kde kdehiddenvisibility lcms libcaca logrotate mad mbox midi mng mp3 mpeg ncurses nls nptl nvidia ogg opengl pam png quicktime readline samba speex ssl svg test theora timidity truetype unicode utempter vorbis xattr xml xpm xv xvid xvmc zlib" ALSA_CARDS="hda-intel" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mulaw multi null plug rate route share shm softvol" ELIBC="glibc" INPUT_DEVICES="keyboard mouse synaptics" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LINGUAS="en_GB en" USERLAND="GNU" VIDEO_CARDS="nvidia nv"

# emerge -pv sys-apps/attr sys-apps/acl sys-apps/coreutils --nodeps

These are the packages that would be merged, in order:

[ebuild   R   ] sys-apps/attr-2.4.32  USE="nls" 0 kB
[ebuild   R   ] sys-apps/acl-2.2.39-r1  USE="nls -nfs" 0 kB
[ebuild   R   ] sys-apps/coreutils-6.9-r1  USE="acl nls xattr (-selinux) -static" 0 kB

Total: 3 packages (3 reinstalls), Size of downloads: 0 kB

Comment 3 David Leverton 2007-06-16 12:35:00 UTC
Created attachment 122225 [details]
strace output
Comment 4 David Leverton 2007-06-16 19:59:54 UTC
I just found out that the bug only occurs if the filesystem is mounted with the acl option (and presumably has ACL support compiled in, but I didn't check).
Comment 5 Arfrever Frehtes Taifersar Arahesis (RETIRED) gentoo-dev 2007-06-16 21:23:20 UTC
I can confirm this bug.

drwxr-xr-x 2 0 0 4,0K 2007-06-16 23:14 bar/
drwxr-sr-x 2 0 0 4,0K 2007-06-16 23:14 baz/
Comment 6 SpanKY gentoo-dev 2008-02-23 03:40:38 UTC
ive revalidated things with up-to-date versions:

can be replicated with just making a local fs:
dd if=/dev/zero of=fs.img count=512
mke2fs -j fs.img
mkdir fs
mount -o loop,acl fs.img fs
cd fs
mkdir dir
chmod g+s dir
cd dir
mkdir src
chmod g-s src
cp -pr src dst
<dst now wrongly has +s bit>

repeat the steps w/out "acl" to the mount and it works

moved to coreutils list for feedback
Comment 7 SpanKY gentoo-dev 2009-02-22 00:14:13 UTC
rested and bug still exists :/

linux-2.6.28 / coreutils-7.1