Disallow creating users with ANONYMOUSID
[openafs.git] / src / ptserver / ptubik.c
1 /* $Id$ */
2
3 #include <afsconfig.h>
4 #include <afs/param.h>
5 #include <afs/stds.h>
6
7 #include <roken.h>
8
9 #include <lock.h>
10 #include <afs/cellconfig.h>
11 #define UBIK_INTERNALS
12 #include <ubik.h>
13 #include <rx/xdr.h>
14
15 #include "ptint.h"
16 #include "ptserver.h"
17
18 extern int dbase_fd;
19 struct ubik_dbase *dbase;
20
21 int
22 ubik_ServerInit(afs_uint32 myHost, short myPort, afs_uint32 serverList[],
23                 const char *pathName, struct ubik_dbase **dbase)
24 {
25     return (0);
26 }
27
28 int
29 ubik_BeginTrans(struct ubik_dbase *dbase, afs_int32 transMode,
30                 struct ubik_trans **transPtr)
31 {
32     static int init = 0;
33     struct ubik_hdr thdr;
34
35     if (!init) {
36         memset(&thdr, 0, sizeof(thdr));
37         thdr.version.epoch = htonl(2);
38         thdr.version.counter = htonl(0);
39         thdr.magic = htonl(UBIK_MAGIC);
40         thdr.size = htons(HDRSIZE);
41         lseek(dbase_fd, 0, 0);
42         write(dbase_fd, &thdr, sizeof(thdr));
43         fsync(dbase_fd);
44         init = 1;
45     }
46     return (0);
47 }
48
49 int
50 ubik_BeginTransReadAny(struct ubik_dbase *dbase, afs_int32 transMode,
51                        struct ubik_trans **transPtr)
52 {
53     return (0);
54 }
55
56 int
57 ubik_AbortTrans(struct ubik_trans *transPtr)
58 {
59     return (0);
60 }
61
62 int
63 ubik_EndTrans(struct ubik_trans *transPtr)
64 {
65     return (0);
66 }
67
68 int
69 ubik_Tell(struct ubik_trans *transPtr, afs_int32 * fileid,
70           afs_int32 * position)
71 {
72     return (0);
73 }
74
75 int
76 ubik_Truncate(struct ubik_trans *transPtr, afs_int32 length)
77 {
78     return (0);
79 }
80
81 int
82 ubik_SetLock(struct ubik_trans *atrans, afs_int32 apos, afs_int32 alen,
83              int atype)
84 {
85     return (0);
86 }
87
88 int
89 ubik_WaitVersion(struct ubik_dbase *adatabase,
90                  struct ubik_version *aversion)
91 {
92     return (0);
93 }
94
95 int
96 ubik_CheckCache(struct ubik_trans *atrans, ubik_updatecache_func cbf, void *rock)
97 {
98     return (*cbf)(atrans, rock);
99 }
100
101 void
102 panic(char *format, ...)
103 {
104     va_list ap;
105
106     va_start(ap, format);
107     vprintf(format, ap);
108     va_end(ap);
109
110     abort();
111     printf("BACK FROM ABORT\n");        /* shouldn't come back from floating pt exception */
112     exit(1);                    /* never know, though */
113 }
114
115 int
116 ubik_GetVersion(struct ubik_trans *dummy, struct ubik_version *ver)
117 {
118     memset(ver, 0, sizeof(struct ubik_version));
119     return (0);
120 }
121
122
123 int
124 ubik_Seek(struct ubik_trans *tt, afs_int32 afd, afs_int32 pos)
125 {
126     if (lseek(dbase_fd, pos + HDRSIZE, 0) < 0) {
127         perror("ubik_Seek");
128         return (-1);
129     }
130     return (0);
131 }
132
133 int
134 ubik_Write(struct ubik_trans *tt, void *buf, afs_int32 len)
135 {
136     int status;
137
138     status = write(dbase_fd, buf, len);
139     if (status < len) {
140         perror("ubik_Write");
141         return (1);
142     }
143     return (0);
144 }
145
146 int
147 ubik_Read(struct ubik_trans *tt, void *buf, afs_int32 len)
148 {
149     int status;
150
151     status = read(dbase_fd, buf, len);
152     if (status < 0) {
153         perror("ubik_Read");
154         return (1);
155     }
156     if (status < len)
157         memset((char *)buf + status, 0, len - status);
158     return (0);
159 }
160
161
162 /* Global declarations from ubik.c */
163 afs_int32 ubik_quorum = 0;
164 struct ubik_dbase *ubik_dbase = 0;
165 struct ubik_stats ubik_stats;
166 afs_uint32 ubik_host[UBIK_MAX_INTERFACE_ADDR];
167 afs_int32 ubik_epochTime = 0;
168 afs_int32 urecovery_state = 0;
169
170 struct rx_securityClass *ubik_sc[3];
171
172
173 /* Other declarations */
174
175 int
176 afsconf_GetNoAuthFlag(struct afsconf_dir *adir)
177 {
178     return (1);
179 }
180
181
182 char *prdir = "/dev/null";
183 struct prheader cheader;