git.samba.org
/
tridge
/
junkcode.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
perl version of histogram prog
[tridge/junkcode.git]
/
id_mkdir.c
1
#include <sys/types.h>
2
#include <sys/stat.h>
3
#include <fcntl.h>
4
#include <errno.h>
5
#include <stdio.h>
6
#include <stdlib.h>
7
#include <unistd.h>
8
9
int main(int argc, const char *argv[])
10
{
11
const char *name;
12
uid_t id;
13
int fd;
14
15
if (argc < 3) {
16
printf("id_create <name> <uid>\n");
17
exit(1);
18
}
19
20
name = argv[1];
21
id = atoi(argv[2]);
22
23
if (seteuid(id) != 0) {
24
perror("seteuid");
25
return -1;
26
}
27
28
unlink(name);
29
fd = open(name, O_CREAT|O_EXCL|O_RDWR, 0644);
30
if (fd == -1) {
31
perror("open");
32
return -1;
33
}
34
35
close(fd);
36
return 0;
37
}
38