|
|
1.1 root 1: /* mkdir.c
2: Create a directory. We must go through a subsidiary program to
3: force our real uid to be the uucp owner before invoking the setuid
4: /bin/mkdir program. */
5:
6: #include "uucp.h"
7:
8: #include "sysdep.h"
9:
10: #include <errno.h>
11:
12: int
13: mkdir (zdir, imode)
14: const char *zdir;
15: int imode;
16: {
17: struct stat s;
18: const char *azargs[3];
19: int aidescs[3];
20: pid_t ipid;
21:
22: /* Make sure the directory does not exist, since we will otherwise
23: get the wrong errno value. */
24: if (stat (zdir, &s) == 0)
25: {
26: errno = EEXIST;
27: return -1;
28: }
29:
30: /* /bin/mkdir will create the directory with mode 777, so we set our
31: umask to get the mode we want. */
32: (void) umask ((~ imode) & (S_IRWXU | S_IRWXG | S_IRWXO));
33:
34: azargs[0] = UUDIR_PROGRAM;
35: azargs[1] = zdir;
36: azargs[2] = NULL;
37: aidescs[0] = SPAWN_NULL;
38: aidescs[1] = SPAWN_NULL;
39: aidescs[2] = SPAWN_NULL;
40:
41: ipid = ixsspawn (azargs, aidescs, FALSE, FALSE, (const char *) NULL,
42: TRUE, FALSE, (const char *) NULL,
43: (const char *) NULL, (const char *) NULL);
44:
45: (void) umask (0);
46:
47: if (ipid < 0)
48: return -1;
49:
50: if (ixswait ((unsigned long) ipid, (const char *) NULL) != 0)
51: {
52: /* Make up an errno value. */
53: errno = EACCES;
54: return -1;
55: }
56:
57: return 0;
58: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.