From owner-freebsd-bugs Fri Apr 25 09:27:03 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id JAA25123 for bugs-outgoing; Fri, 25 Apr 1997 09:27:03 -0700 (PDT) Received: from godzilla.zeta.org.au (godzilla.zeta.org.au [203.2.228.19]) by hub.freebsd.org (8.8.5/8.8.5) with ESMTP id JAA25090 for ; Fri, 25 Apr 1997 09:26:51 -0700 (PDT) Received: (from bde@localhost) by godzilla.zeta.org.au (8.8.5/8.6.9) id CAA03538; Sat, 26 Apr 1997 02:22:45 +1000 Date: Sat, 26 Apr 1997 02:22:45 +1000 From: Bruce Evans Message-Id: <199704251622.CAA03538@godzilla.zeta.org.au> To: bde@zeta.org.au, bugs@freebsd.org, jc@netview.net Subject: Re: owner sticky and mv Sender: owner-bugs@freebsd.org X-Loop: FreeBSD.org Precedence: bulk >NOTE: To demonstrate this bug, you have to be moving a subdirectory across >file systems. This assumes that '/root' and '/var' are on different >filesystems. > >mkdir /var/d1 >mkdir /var/d1/test >touch /var/d1/test/f1_rw >touch /var/d1/test/f2_rw >touch /var/d1/test/f1_nn >touch /var/d1/test/f2_nn >chown root.wheel /var/d1/test/f1_rw >chown root.wheel /var/d1/test/f2_rw >chown nobody.nogroup /var/d1/test/f1_nn >chown nobody.nogroup /var/d1/test/f2_nn >chmod 4555 /var/d1/test/f1_rw >chmod 555 /var/d1/test/f2_rw >chmod 4555 /var/d1/test/f1_nn >chmod 555 /var/d1/test/f2_nn >ls -al /var/d1/test >... >mv /var/test /root >ls -al /root/test > >we see that any files owned by the mover get stripped: > >drwx------ 2 root wheel 512 Apr 25 10:32 ./ >drwxr-x--- 9 root wheel 512 Apr 25 10:32 ../ >-r-sr-xr-x 1 nobody nogroup 0 Apr 25 10:27 f1_nn* >-r-s------ 1 root wheel 0 Apr 25 10:27 f1_rw* >-r-xr-xr-x 1 nobody nogroup 0 Apr 25 10:27 f2_nn* >-r-xr-xr-x 1 root wheel 0 Apr 25 10:27 f2_rw* > >I am using umask 077, although it should not affect an 'mv' process. This works here. I seem to already have a fix for it. The bug is in `cp -p' (mv across file systems uses cp -pRP). diff -c2 cp/utils.c~ cp/utils.c *** cp/utils.c~ Sun Feb 23 12:34:58 1997 --- cp/utils.c Sun Feb 23 12:35:00 1997 *************** *** 160,165 **** */ ! if (pflag && setfile(fs, to_fd)) ! rval = 1; /* * If the source was setuid or setgid, lose the bits unless the --- 160,165 ---- */ ! if (pflag) ! rval = setfile(fs, to_fd); /* * If the source was setuid or setgid, lose the bits unless the Bruce