Hi misc, First of all sorry for my crappy english, i'm trying my best:
I found a posible issue with cp(1) when the source file and target file match with the process uid and gid and source file have S_ISUID or S_ISGID active. It overrides the target file permission mode with the source file mode. This issue also involves the '-p' behaviour. Before filling a bugreport I would like to discuss this in misc@ In the form 'cp src dst', src and dst are existing regular files with same uid and gid with the calling process (i.e. user 'foo' copies in a file in his home), the mode of 'dst' will be the mode of 'src' with ~umask and RETAINBITS. the manpage says that a existing file will preserve mode and if source file have set-user id bit or set-group id bit actives and both source file and target file share uid and gid with the calling process S_ISUID or S_ISGID bits will be preserved. assuming user umask 0000 if file 'src' exists with mode 4666 (rwSrw-rw-) and 'dst' exist with mode 0600 (rw-------) the result of 'cp src dst' (if the process uid and gid is the same as the src and dst files) will be dst with 4666 instead 4600 as expected. In case of 'dst' beign an existing file it should preserve his original mode (0600) and add the S_ISUID or S_ISGID from the source file (4000) resulting in (4600), not (4666) as result. I wrote a dirty diff for src/bin/cp/util.c to illustrate the possible patch. to reproduce the issue: umask 000 mkdir tmp cd tmp touch src touch dst chmod 4666 src cp src dst ls -l --- dst have 4666 mode (rwSrw-rw-) --- Thanks for your time. -Jesus [demime 1.01d removed an attachment of type application/octet-stream which had a name of 20110613_bin_cp_util_c.diff]