]> andersk Git - moira.git/blob - afssync/prnewlist.c
Initial revision
[moira.git] / afssync / prnewlist.c
1 /* $Header$ */
2
3 #include <stdio.h>
4 #include <sys/file.h>
5 #include <rx/xdr.h>
6 #include "print.h"
7 #include "prserver.h"
8 #include "prerror.h"
9
10 int dbase_fd;
11 extern struct prheader cheader;
12
13 main(argc, argv)
14 int argc;
15 char **argv;
16 {
17     char *name, *msg;
18     long id, status;
19
20     if (argc != 3) {
21         fprintf(stderr, "usage: %s listname gid\n", argv[0]);
22         exit(1);
23     }
24     name = argv[1];
25     id = atoi(argv[2]);
26
27     dbase_fd = open("/usr/afs/db/xprdb.DB0", O_RDWR|O_CREAT, 0660);
28
29     status = PR_INewEntry(NULL, name, -id, SYSADMINID);
30     if (status != 0) {
31         switch (status) {
32         case PREXIST:
33             msg = "name already exists";
34             break;
35         case PRIDEXIST:
36             msg = "ID already exists";
37             break;
38         case PRNOIDS:
39             msg = "no IDs available";
40             break;
41         case PRDBFAIL:
42             msg = "database failed";
43             break;
44         case PRNOENT:
45             msg = "no space left in database";
46             break;
47         case PRPERM:
48             msg = "permission denied";
49             break;
50         case PRNOTGROUP:
51             msg = "not a group";
52             break;
53         case PRNOTUSER:
54             msg = "not a user";
55             break;
56         case PRBADNAM:
57             msg = "bad name";
58             break;
59         default:
60             msg = "unknown code";
61             break;
62         }
63         fprintf(stderr, "Failed: %s (%d)\n", msg, status);
64     }
65     exit(status);
66 }
This page took 0.059392 seconds and 5 git commands to generate.