cpcahil@virtech.uucp (Conor P. Cahill) (05/29/90)
In article <009375FC.8A3B0AC0@rigel.efd.lth.se> e89hse@rigel.efd.lth.se writes: > > I'd like to know if there is any way for a C-program to create a directory. >The mkdir(2) call doesn't exist on the machine I'm using. It is possible to >create a directory with the mknod(2) call, but then you have to have >effective-user-id 0 (super user). Of course one could set the substitute user >flag, but isn't there a more elegant way to do it. With no mkdir() system call, the best way for a standard user level program to make a directory is to fork/exec the mkdir program. Making your program setuid to root in order to be able to create a directory can expose you to all kinds of security problems. BTW - when you ask a question like this it is best to include the exact version of the OS that you are using. Just saying that there is no mkdir() and that mknod() requires root is not enough because it is possible that you are not reading the documentation right, or that your version of the OS has some special user_can_make_a_dir() system call that will do the required job, etc. -- Conor P. Cahill (703)430-9247 Virtual Technologies, Inc., uunet!virtech!cpcahil 46030 Manekin Plaza, Suite 160 Sterling, VA 22170
e89hse@rigel.efd.lth.se (05/29/90)
I'd like to know if there is any way for a C-program to create a directory. The mkdir(2) call doesn't exist on the machine I'm using. It is possible to create a directory with the mknod(2) call, but then you have to have effective-user-id 0 (super user). Of course one could set the substitute user flag, but isn't there a more elegant way to do it. Henrik Sandell
gwyn@smoke.BRL.MIL (Doug Gwyn) (05/29/90)
In article <009375FC.8A3B0AC0@rigel.efd.lth.se> e89hse@rigel.efd.lth.se writes: > I'd like to know if there is any way for a C-program to create a directory. >The mkdir(2) call doesn't exist on the machine I'm using. It is possible to >create a directory with the mknod(2) call, but then you have to have >effective-user-id 0 (super user). Of course one could set the substitute user >flag, but isn't there a more elegant way to do it. The reason mknod() is protected even for making directory inodes is that you need to also plant the . and .. links, or havoc will ensue. The simplest solution is to invoke the privileged system utility: system("mkdir whatever");
coxr@ecn.purdue.edu (Richard L Cox) (05/30/90)
Try system("mkdir dirname"); to make a directory. The system call can be used to make many system calls. -Rich -- |\/\/\/| ------------------------------------------------------ | | |"Every silver lining's got a |coxr@en.ecn.purdue.edu | | | | touch of grey..." | | | (o)(o) |-(Jerry Garcia,Robert Hunter)|Online America: RichKid |