why root? (was Re: How does 'mv' rename directories?)
Randal Schwartz
merlyn at iwarp.intel.com
Wed Sep 20 23:19:40 AEST 1989
In article <4195 at buengc.BU.EDU>, bph at buengc (Blair P. Houghton) writes:
[...much much gibberish deleted...]
| Moving from one partition to the next requires a copy-then-unlink,
| whereas moving within a partition only requires a link-then-unlink.
[...]
| But, basically, there's no need to become uid 0 when you're just moving
| files around in a partition.
>From link(2)[sunos3.2]:
"With hard links, both files must be on the same file system. Unless
the caller is the super-user, the file named by [the first parameter]
must not be a directory...."
I cannot, as J. Random Luser, write a program that renames a directory
because I cannot do the link/unlink pair that you mention ....unless I
have the rename(2) system call, in which case mv(1) is indeed not
setuid root, because it can be done in simple user code. The original
question was probably regarding a system that hasn't incorporated the
rename(2) system call (originally in 4.0BSD, I think), and *requires*
root privs to rename a directory.
Enough bogosity. Think of all the things mv does.
Just another UNIX hacker,
--
/== Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ====\
| on contract to Intel, Hillsboro, Oregon, USA |
| merlyn at iwarp.intel.com ...!uunet!iwarp.intel.com!merlyn |
\== Cute Quote: "Welcome to Oregon... Home of the California Raisins!" ==/
More information about the Comp.unix.wizards
mailing list