3

Bach states the following:

mkdir is a typical setuid program. Only a process with Effective UID root can create a folder. (Section 7.6, Page 229)


I checked the permissions on it on Ubuntu 12.04, the setuid bit isn't set.

-rwxr-xr-x 1 root root 42624 Oct  2 08:55 mkdir
   ^??

Then I checked other programs which are supposed to have this set, like ping and su and they have it set.

-rwsr-xr-x 1 root root 34740 Nov  8  2011 ping
   ^---there it is 

So, how does mkdir work? Have things changed since Bach wrote that?

3 Answers3

5

The mkdir() call has been around since BSD 4.2. It was later added to SYSV 3.0. See: http://pubs.opengroup.org/onlinepubs/9699919799/functions/mkdir.html

BSD 4.2 came out in 1984: http://www.unix.org/what_is_unix/history_timeline.html

If access to a kernel mode entry point in UNIX via a syscall is permitted from user mode without restriction, what duskwuff indicates, then setuid is not required.

3

It's no longer necessary to have root privileges to create a folder. There's now instead a mkdir() system call which any process can use to create a directory.

1

Have things changed since Bach wrote that?

Exactly. The permission to create a directory is nowadays based on the write permission to the parent directory or the t bit (for /tmp-like directories where everybody can create a directory but you can only delete files owned by you).

Jens
  • 629