Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 26 Apr 1997 02:22:45 +1000
From:      Bruce Evans <bde@zeta.org.au>
To:        bde@zeta.org.au, bugs@freebsd.org, jc@netview.net
Subject:   Re: owner sticky and mv
Message-ID:  <199704251622.CAA03538@godzilla.zeta.org.au>

next in thread | raw e-mail | index | archive | help
>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



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