]> andersk Git - moira.git/blob - afssync/ptprocs.c
Initial revision
[moira.git] / afssync / ptprocs.c
1 /* $Header$ */
2 /* $Source$ */
3
4
5 /*
6  * P_R_P_Q_# (C) COPYRIGHT IBM CORPORATION 1988
7  * LICENSED MATERIALS - PROPERTY OF IBM
8  * REFER TO COPYRIGHT INSTRUCTIONS FORM NUMBER G120-2083
9  */
10
11 /*      
12        Sherri Nichols
13        Information Technology Center
14        November, 1988
15 */
16
17
18 #include <ctype.h>
19 #include <stdio.h>
20 #include <strings.h>
21 #include <lock.h>
22 #include <ubik.h>
23 #include <rx/xdr.h>
24 #include <rx/rx.h>
25 #include "print.h"
26 #include "prserver.h"
27 #include "prerror.h"
28
29 extern struct ubik_dbase *dbase;
30 extern struct afsconf_dir *prdir;
31 extern long Initdb();
32
33 PR_INewEntry(call,aname,aid,oid)
34 struct rx_call *call;
35 char aname[PR_MAXNAMELEN];
36 long aid;
37 long oid;
38 {
39     /* used primarily for conversion - not intended to be used as usual means of entering people into the database. */
40     struct ubik_trans *tt;
41     register long code;
42     long temp = 0;
43     long gflag = 0;
44     long cid;
45     long noAuth;
46     char *check;
47     long tid;
48     char oname[PR_MAXNAMELEN];
49     
50     stolower(aname);
51     code = Initdb();
52     if (code != PRSUCCESS) return code;
53     noAuth =afsconf_GetNoAuthFlag(prdir);
54     code = ubik_BeginTrans(dbase,UBIK_WRITETRANS, &tt);
55     if (code) return code;
56     code = ubik_SetLock(tt, 1,1,LOCKWRITE);
57     if (code) {
58         ubik_AbortTrans(tt);
59         return code;
60     }
61     code = WhoIsThis(call,tt,&cid);
62     if (code && !noAuth) {
63         ubik_AbortTrans(tt);
64         return PRPERM;
65     }
66     if (aid == 0) {
67         ubik_AbortTrans(tt);
68         return PRPERM;
69     }
70     if (aid < 0) gflag |= PRGRP;
71
72     if (!noAuth) {
73         if (gflag & PRGRP) {
74             if (oid != cid && !IsAMemberOf(tt,cid,SYSADMINID)) {
75                 ubik_AbortTrans(tt);
76                 return PRPERM;
77             }
78         }
79         else {
80             if (!IsAMemberOf(tt,cid,SYSADMINID)) {
81                 ubik_AbortTrans(tt);
82                 return PRPERM;
83             }
84         }
85     }
86
87     /* is this guy already in the database? */
88     temp = FindByID(tt,aid);
89     if (temp) {
90         ubik_AbortTrans(tt);
91         return PRIDEXIST;
92     }
93     if (gflag & PRGRP) {
94         if (cid == ANONYMOUSID) {
95             ubik_AbortTrans(tt);
96             return PRPERM;
97         }
98         if ((check = index(aname,':')) == 0) {
99             /* groups should have owner's name prepended */
100             ubik_AbortTrans(tt);
101             return PRBADNAM;
102         }
103         if (oid) {
104             if (!IsAMemberOf(tt,cid,SYSADMINID) && !IsOwnerOf(tt,cid,oid)) {
105                 /* must be a sysadmin to specify another owner, unless other owner is group owned by you */
106                 ubik_AbortTrans(tt);
107                 return PRPERM;
108             }
109         }
110         else oid = cid;
111         bzero(oname,PR_MAXNAMELEN);
112         /* check prepended part */
113         strncpy(oname,aname,check-aname);
114         if (!strcmp(oname,"system")) {
115             /* groups with system: at beginning are owned by SYSADMIN */
116             tid = SYSADMINID;
117         }
118         else {
119             code = NameToID(tt,oname,&tid);
120             if (code || tid == ANONYMOUSID) {
121                 /* owner doesn't exist */
122                 ubik_AbortTrans(tt);
123                 return PRNOENT;
124             }
125         }
126         if (oid > 0) {
127             /* owner's name should be prepended */
128             if (tid != oid) {
129                 ubik_AbortTrans(tt);
130                 return PRBADNAM;
131             }
132         }
133         else {
134             /* if owner is a group, group owner's name should be prepended. */
135             if (tid != OwnerOf(tt,oid)) {
136                 ubik_AbortTrans(tt);
137                 return PRPERM;
138             }
139         }
140     }
141     temp = FindByName(tt,aname);
142     if (temp) {
143         ubik_AbortTrans(tt);
144         return PREXIST;
145     }
146     code = CreateEntry(tt,aname,&aid,1,gflag,oid,cid);
147     if (code != PRSUCCESS) {
148         ubik_AbortTrans(tt);
149         return code;
150     }
151     /* finally, commit transaction */
152     code = ubik_EndTrans(tt);
153     if (code) return code;
154     return PRSUCCESS;
155 }
156
157
158 PR_NewEntry(call,aname,flag,oid,aid)
159 struct rx_call *call;
160 char aname[PR_MAXNAMELEN];
161 long flag;
162 long oid;
163 long *aid;
164 {
165     register long code;
166     struct ubik_trans *tt;
167     long temp;
168     long cid;
169     char oname[PR_MAXNAMELEN];
170     long noAuth;
171     char *check;
172     long tid;
173
174     stolower(aname);
175     code = Initdb();
176     noAuth = afsconf_GetNoAuthFlag(prdir);
177     if (code != PRSUCCESS) return code;
178     code = ubik_BeginTrans(dbase,UBIK_WRITETRANS,&tt);
179     if (code) return code;
180     code = ubik_SetLock(tt,1,1,LOCKWRITE);
181     if (code) {
182         ubik_AbortTrans(tt);
183         return code;
184     }
185     code = WhoIsThis(call,tt,&cid);
186     if (code && !noAuth) {
187         ubik_AbortTrans(tt);
188         return PRPERM;
189     }
190     if (flag & PRGRP) {
191         if (cid == ANONYMOUSID) {
192             ubik_AbortTrans(tt);
193             return PRPERM;
194         }
195         if ((check = index(aname,':')) == 0) {
196             /* groups should have owner's name prepended */
197             ubik_AbortTrans(tt);
198             return PRBADNAM;
199         }
200         if (oid) {
201             if (!IsAMemberOf(tt,cid,SYSADMINID) && !IsOwnerOf(tt,cid,oid)) {
202                 /* must be a sysadmin to specify another owner, unless other owner is group owned by you */
203                 ubik_AbortTrans(tt);
204                 return PRPERM;
205             }
206         }
207         else oid = cid;
208         bzero(oname,PR_MAXNAMELEN);
209         /* check prepended part */
210         strncpy(oname,aname,check-aname);
211         if (!strcmp(oname,"system")) {
212             /* groups with system: at beginning are owned by SYSADMIN */
213             tid = SYSADMINID;
214         }
215         else {
216             code = NameToID(tt,oname,&tid);
217             if (code || tid == ANONYMOUSID) {
218                 /* owner doesn't exist */
219                 ubik_AbortTrans(tt);
220                 return PRNOENT;
221             }
222         }
223         if (oid > 0) {
224             /* owner's name should be prepended */
225             if (tid != oid) {
226                 ubik_AbortTrans(tt);
227                 return PRBADNAM;
228             }
229         }
230         else {
231             /* if owner is a group, prepend group owner's name. */
232             if (tid != OwnerOf(tt,oid)) {
233                 ubik_AbortTrans(tt);
234                 return PRPERM;
235             }
236         }
237         temp = FindByName(tt,aname);
238         if (temp) {
239             ubik_AbortTrans(tt);
240             return PREXIST;
241         }
242         code = CreateEntry(tt,aname,aid,0,flag,oid,cid);
243         if (code != PRSUCCESS) {
244             ubik_AbortTrans(tt);
245             return code;
246         }
247     }
248     else {
249         if (!(flag & PRFOREIGN)) {
250             if (!IsAMemberOf(tt,cid,SYSADMINID) && !noAuth) {
251                 ubik_AbortTrans(tt);
252                 return PRPERM;
253             }
254             if (oid != SYSADMINID) oid = SYSADMINID;
255         }
256         temp = FindByName(tt,aname);
257         if (temp) {
258             ubik_AbortTrans(tt);
259             return PREXIST;
260         }
261         code = CreateEntry(tt,aname,aid,0,flag,oid,cid);
262         if (code != PRSUCCESS) {
263             ubik_AbortTrans(tt);
264             return code;
265         }
266     }
267     code = ubik_EndTrans(tt);
268     if (code) return code;
269     return PRSUCCESS;
270 }
271
272
273
274 PR_WhereIsIt(call,aid,apos)
275 struct rx_call *call;
276 long aid;
277 long *apos;
278 {
279     register long code;
280     struct ubik_trans *tt;
281     long temp;
282
283     code = Initdb();
284     if (code != PRSUCCESS) return code;
285     code = ubik_BeginTrans(dbase,UBIK_READTRANS,&tt);
286     if (code) return code;
287     code = ubik_SetLock(tt,1,1,LOCKREAD);
288     if (code) {
289         ubik_AbortTrans(tt);
290         return code;
291     }
292     temp = FindByID(tt,aid);
293     if (!temp) {
294         ubik_AbortTrans(tt);
295         return PRNOENT;
296     }
297     *apos = temp;
298     code = ubik_EndTrans(tt);
299     if (code) return code;
300     return PRSUCCESS;
301 }
302
303
304 PR_DumpEntry(call,apos, aentry)
305 struct rx_call *call;
306 long apos;
307 struct prdebugentry *aentry;
308 {
309     register long code;
310     struct ubik_trans *tt;
311
312     code = Initdb();
313     if (code != PRSUCCESS) return code;
314     code = ubik_BeginTrans(dbase,UBIK_READTRANS,&tt);
315     if (code) return code;
316     code = ubik_SetLock(tt,1,1,LOCKREAD);
317     if (code) {
318         ubik_AbortTrans(tt);
319         return code;
320     }
321     code = pr_ReadEntry(tt, 0, apos, aentry);
322     if (code != 0) {
323         ubik_AbortTrans(tt);
324         return code;
325     }
326     code = ubik_EndTrans(tt);
327     if (code) return code;
328     return PRSUCCESS;
329 }
330
331 PR_AddToGroup(call,aid,gid)
332 struct rx_call *call;
333 long aid;
334 long gid;
335 {
336     register long code;
337     struct ubik_trans *tt;
338     long tempu;
339     long tempg;
340     struct prentry tentry;
341     struct prentry uentry;
342     long len;
343     long cid;
344     long noAuth;
345
346     code = Initdb();
347     if (code != PRSUCCESS) return code;
348     if (gid == ANYUSERID || gid == AUTHUSERID) return PRPERM;
349     if (aid == ANONYMOUSID) return PRPERM;
350     noAuth = afsconf_GetNoAuthFlag(prdir);
351     code = ubik_BeginTrans(dbase,UBIK_WRITETRANS,&tt);
352     if (code) return code;
353     code = ubik_SetLock(tt,1,1,LOCKWRITE);
354     if (code) {
355         ubik_AbortTrans(tt);
356         return code;
357     }
358     code = WhoIsThis(call, tt, &cid);
359     if (code && !noAuth) {
360         ubik_AbortTrans(tt);
361         return PRPERM;
362     }
363     tempu = FindByID(tt,aid);
364     if (!tempu) { 
365         ubik_AbortTrans(tt);
366         return PRNOENT;
367     }
368     bzero(&uentry,sizeof(uentry));
369     code = pr_ReadEntry(tt,0,tempu,&uentry);
370     if (code != 0)  {
371         ubik_AbortTrans(tt);
372         return code;
373     }
374     /* we don't allow groups as members of groups at present */
375     if (uentry.flags & PRGRP) {
376         ubik_AbortTrans(tt);
377         return PRNOTUSER;
378     }
379     tempg = FindByID(tt,gid);
380     if (!tempg) {
381         ubik_AbortTrans(tt);
382         return PRNOENT;
383     }
384     code = pr_ReadEntry(tt,0,tempg,&tentry);
385     if (code != 0) {
386         ubik_AbortTrans(tt);
387         return code;
388     }
389     /* make sure that this is a group */
390     if (!(tentry.flags & PRGRP)) {
391         ubik_AbortTrans(tt);
392         return PRNOTGROUP;
393     }
394     if (tentry.owner != cid && !IsAMemberOf(tt,cid,SYSADMINID) && !IsAMemberOf(tt,cid,tentry.owner) && !noAuth) {
395         ubik_AbortTrans(tt);
396         return PRPERM;
397     }
398
399     
400     code = AddToEntry(tt,tentry,tempg,aid);
401     if (code != PRSUCCESS) {
402         ubik_AbortTrans(tt);
403         return code;
404     }
405     /* now, modify the user's entry as well */
406     code = AddToEntry(tt,uentry,tempu,gid);
407     if (code != PRSUCCESS) {
408         ubik_AbortTrans(tt);
409         return code;
410     }
411     code = ubik_EndTrans(tt);
412     if (code) return code;
413     return PRSUCCESS;
414 }
415
416 PR_NameToID(call,aname,aid)
417 struct rx_call *call;
418 namelist *aname;
419 idlist *aid;
420 {
421     register long code;
422     struct ubik_trans *tt;
423     long i;
424
425     /* must do this first for RPC stub to work */
426     aid->idlist_val = (long *)malloc(PR_MAXLIST*sizeof(long));
427     aid->idlist_len = 0;
428
429     code = Initdb();
430     if (code != PRSUCCESS) return code;
431     code = ubik_BeginTrans(dbase,UBIK_READTRANS,&tt);
432     if (code) return code;
433     code = ubik_SetLock(tt,1,1,LOCKREAD);
434     if (code) {
435         ubik_AbortTrans(tt);
436         return code;
437     }
438     for (i=0;i<aname->namelist_len;i++) {
439         code = NameToID(tt,aname->namelist_val[i],&aid->idlist_val[i]);
440         if (code != PRSUCCESS) aid->idlist_val[i] = ANONYMOUSID;
441         aid->idlist_len++;
442     }
443     code = ubik_EndTrans(tt);
444     if (code)return code;
445     return PRSUCCESS;
446 }
447
448 PR_IDToName(call,aid,aname)
449 struct rx_call *call;
450 idlist *aid;
451 namelist *aname;
452 {
453     register long code;
454     struct ubik_trans *tt;
455     long i;
456
457     /* leave this first for rpc stub */
458     aname->namelist_len = 0;
459     aname->namelist_val = (prname *)malloc(PR_MAXLIST*PR_MAXNAMELEN);
460
461     code = Initdb();
462     if (code != PRSUCCESS) return code;
463     code = ubik_BeginTrans(dbase,UBIK_READTRANS,&tt);
464     if (code) return code;
465     code = ubik_SetLock(tt,1,1,LOCKREAD);
466     if (code) {
467         ubik_AbortTrans(tt);
468         return code;
469     }
470     for (i=0;i<aid->idlist_len;i++) {
471         /* interface won't allow more than PR_MAXLIST to be sent in */
472         code = IDToName(tt,aid->idlist_val[i],aname->namelist_val[i]);
473         if (code != PRSUCCESS)
474             sprintf(aname->namelist_val[i],"%d",aid->idlist_val[i]);
475         aname->namelist_len++;
476     }
477     code = ubik_EndTrans(tt);
478     if (code) return code;
479     return PRSUCCESS;
480 }
481
482 PR_Delete(call,aid)
483 struct rx_call *call;
484 long aid;
485 {
486     register long code;
487     struct ubik_trans *tt;
488     long cid;
489     long noAuth;
490
491     code = Initdb();
492     noAuth = afsconf_GetNoAuthFlag(prdir);
493     if (code != PRSUCCESS) return code;
494     if (aid == SYSADMINID || aid == ANYUSERID || aid == AUTHUSERID || aid == ANONYMOUSID) return PRPERM;
495     code = ubik_BeginTrans(dbase,UBIK_WRITETRANS,&tt);
496     if (code) return code;
497     code = ubik_SetLock(tt,1,1,LOCKWRITE);
498     if (code) {
499         ubik_AbortTrans(tt);
500         return code;
501     }
502     code = WhoIsThis(call,tt,&cid);
503     if (code && !noAuth) {
504         ubik_AbortTrans(tt);
505         return PRPERM;
506     }
507     /*protection check will occur in DeleteEntry - sigh. */
508     code = DeleteEntry(tt,aid,cid);
509     if (code != PRSUCCESS) {
510         ubik_AbortTrans(tt);
511         return code;
512     }
513     code = ubik_EndTrans(tt);
514     if (code) return code;
515     return PRSUCCESS;
516 }
517
518 PR_RemoveFromGroup(call,aid,gid)
519 struct rx_call *call;
520 long aid;
521 long gid;
522 {
523     register long code;
524     struct ubik_trans *tt;
525     long tempu;
526     long tempg;
527     struct prentry uentry;
528     struct prentry gentry;
529     long cid;
530     long noAuth;
531
532     code = Initdb();
533     if (code != PRSUCCESS) return code;
534     noAuth = afsconf_GetNoAuthFlag(prdir);
535     code = ubik_BeginTrans(dbase,UBIK_WRITETRANS,&tt);
536     if (code) return code;
537     code = ubik_SetLock(tt,1,1,LOCKWRITE);
538     if (code) {
539         ubik_AbortTrans(tt);
540         return code;
541     }
542     code = WhoIsThis(call,tt,&cid);
543     if (code && !noAuth) {
544         ubik_AbortTrans(tt);
545         return PRPERM;
546     }
547     tempu = FindByID(tt,aid);
548     if (!tempu) { 
549         ubik_AbortTrans(tt);
550         return PRNOENT;
551     }
552     tempg = FindByID(tt,gid);
553     if (!tempg) {
554         ubik_AbortTrans(tt);
555         return PRNOENT;
556     }
557     bzero(&uentry,sizeof(uentry));
558     bzero(&gentry,sizeof(gentry));
559     code = pr_ReadEntry(tt,0,tempu,&uentry);
560     if (code != 0) {
561         ubik_AbortTrans(tt);
562         return code;
563     }
564     code = pr_ReadEntry(tt,0,tempg,&gentry);
565     if (code != 0) {
566         ubik_AbortTrans(tt);
567         return code;
568     }
569     if (!(gentry.flags & PRGRP)) {
570         ubik_AbortTrans(tt);
571         return PRNOTGROUP;
572     }
573     if (uentry.flags & PRGRP) {
574         ubik_AbortTrans(tt);
575         return PRNOTUSER;
576     }
577     if (gentry.owner != cid && !IsAMemberOf(tt,cid,SYSADMINID) && !IsAMemberOf(tt,cid,gentry.owner) && !noAuth) {
578         ubik_AbortTrans(tt);
579         return PRPERM;
580     }
581     code = RemoveFromEntry(tt,aid,gid);
582     if (code != PRSUCCESS) {
583         ubik_AbortTrans(tt);
584         return code;
585     }
586     code = RemoveFromEntry(tt,gid,aid);
587     if (code != PRSUCCESS) {
588         ubik_AbortTrans(tt);
589         return code;
590     }
591     code = ubik_EndTrans(tt);
592     if (code) return code;
593     return PRSUCCESS;
594 }
595
596 PR_GetCPS(call,aid,alist,over)
597 struct rx_call *call;
598 long aid;
599 prlist *alist;
600 long *over;
601 {
602     register long code;
603     struct ubik_trans *tt;
604
605     alist->prlist_len = 0;
606     alist->prlist_val = (long *) 0;
607     code = Initdb();
608     if (code != PRSUCCESS) goto done;
609     code = ubik_BeginTrans(dbase,UBIK_READTRANS,&tt);
610     if (code) goto done;
611     code = ubik_SetLock(tt,1,1,LOCKREAD);
612     if (code) {
613         ubik_AbortTrans(tt);
614         goto done;
615     }
616     *over = 0;
617     code = GetList(tt,aid,alist,1);
618     if (code != PRSUCCESS) {
619         ubik_AbortTrans(tt);
620         goto done;
621     }
622     if (alist->prlist_len > PR_MAXGROUPS) *over = alist->prlist_len - PR_MAXGROUPS;
623     code = ubik_EndTrans(tt);
624
625 done:
626     /* return code, making sure that prlist_val points to malloc'd memory */
627     if (!alist->prlist_val)
628         alist->prlist_val = (long *) malloc(0); /* make xdr stub happy */
629     return code;
630 }
631
632 PR_ListMax(call,uid,gid)
633 struct rx_call *call;
634 long *uid;
635 long *gid;
636 {
637     register long code;
638     struct ubik_trans *tt;
639
640     code = Initdb();
641     if (code != PRSUCCESS) return code;
642     code = ubik_BeginTrans(dbase,UBIK_READTRANS,&tt);
643     if (code) return code;
644     code = ubik_SetLock(tt,1,1,LOCKREAD);
645     if (code) {
646         ubik_AbortTrans(tt);
647         return code;
648     }
649     code = GetMax(tt,uid,gid);
650     if (code != PRSUCCESS) {
651         ubik_AbortTrans(tt);
652         return code;
653     }
654     code = ubik_EndTrans(tt);
655     if (code) return code;
656     return PRSUCCESS;
657 }
658
659 PR_SetMax(call,aid,gflag)
660 struct rx_call *call;
661 long aid;
662 long gflag;
663 {
664     register long code;
665     struct ubik_trans *tt;
666     long cid;
667     long noAuth;
668
669     code = Initdb();
670     if (code != PRSUCCESS) return code;
671     noAuth = afsconf_GetNoAuthFlag(prdir);
672     code = ubik_BeginTrans(dbase,UBIK_WRITETRANS,&tt);
673     if (code) return code;
674     code = ubik_SetLock(tt,1,1,LOCKWRITE);
675     if (code) {
676         ubik_AbortTrans(tt);
677         return code;
678     }
679     code = WhoIsThis(call,tt,&cid);
680     if (code && !noAuth) {
681         ubik_AbortTrans(tt);
682         return PRPERM;
683     }
684     if (!IsAMemberOf(tt, cid,SYSADMINID) && !noAuth) {
685         ubik_AbortTrans(tt);
686         return PRPERM;
687     }
688     code = SetMax(tt,aid,gflag);
689     if (code != PRSUCCESS) {
690         ubik_AbortTrans(tt);
691         return code;
692     }
693     code = ubik_EndTrans(tt);
694     if (code) return code;
695     return PRSUCCESS;
696 }
697
698 PR_ListEntry(call,aid,aentry)
699 struct rx_call *call;
700 long aid;
701 struct prcheckentry *aentry;
702 {
703     register long code;
704     struct ubik_trans *tt;
705     long temp;
706     struct prentry tentry;
707
708     code = Initdb();
709     if (code != PRSUCCESS) return code;
710     code = ubik_BeginTrans(dbase,UBIK_READTRANS,&tt);
711     if (code) return code;
712     code = ubik_SetLock(tt,1,1,LOCKREAD);
713     if (code) {
714         ubik_AbortTrans(tt);
715         return code;
716     }
717     temp = FindByID(tt,aid);
718     if (!temp) { 
719         ubik_AbortTrans(tt);
720         return PRNOENT;
721     }
722     code = pr_ReadEntry(tt, 0, temp, &tentry);
723     if (code != 0) {
724         ubik_AbortTrans(tt);
725         return code;
726     } 
727     aentry->owner = tentry.owner;
728     aentry->id = tentry.id;
729     strncpy(aentry->name,tentry.name,PR_MAXNAMELEN);
730     aentry->creator = tentry.creator;
731     aentry->ngroups = tentry.ngroups;
732     aentry->nusers = tentry.nusers;
733     aentry->count = aentry->count;
734     code = ubik_EndTrans(tt);
735     if (code) return code;
736     return PRSUCCESS;
737 }
738
739 PR_ChangeEntry(call,aid,name,oid,newid)
740 struct rx_call *call;
741 long aid;
742 char *name;
743 long oid;
744 long newid;
745 {
746     register long code;
747     struct ubik_trans *tt;
748     long pos;
749     long cid;
750     long noAuth;
751
752     stolower(name);
753     code = Initdb();
754     if (aid == ANYUSERID || aid == AUTHUSERID || aid == ANONYMOUSID || aid == SYSADMINID) return PRPERM;
755     noAuth = afsconf_GetNoAuthFlag(prdir);
756     if (code != PRSUCCESS) return code;
757     code = ubik_BeginTrans(dbase,UBIK_WRITETRANS,&tt);
758     if (code) return code;
759     code = ubik_SetLock(tt,1,1,LOCKWRITE);
760     if (code) {
761         ubik_AbortTrans(tt);
762         return code;
763     }
764     code = WhoIsThis(call,tt,&cid);
765     if (code && !noAuth) {
766         ubik_AbortTrans(tt);
767         return PRPERM;
768     }
769     pos = FindByID(tt,aid);
770     if (!pos) { 
771         ubik_AbortTrans(tt);
772         return PRNOENT;
773     }
774     /* protection check in changeentry */
775     code = ChangeEntry(tt,aid,cid,name,oid,newid);
776     if (code != PRSUCCESS) {
777         ubik_AbortTrans(tt);
778         return code;
779     }
780     code = ubik_EndTrans(tt);
781     return code;
782 }
783
784 PR_ListElements(call,aid,alist,over)
785 struct rx_call *call;
786 long aid;
787 prlist *alist;
788 long *over;
789 {
790     register long code;
791     struct ubik_trans *tt;
792
793     alist->prlist_len = 0;
794     alist->prlist_val = (long *) 0;
795
796     code = Initdb();
797     if (code != PRSUCCESS) goto done;
798     code = ubik_BeginTrans(dbase,UBIK_READTRANS,&tt);
799     if (code) goto done;
800     code = ubik_SetLock(tt,1,1,LOCKREAD);
801     if (code) {
802         ubik_AbortTrans(tt);
803         goto done;
804     }
805     code = GetList(tt,aid,alist,0);
806     if (code != PRSUCCESS) {
807         ubik_AbortTrans(tt);
808         goto done;
809     }
810     if (alist->prlist_len > PR_MAXGROUPS) *over = alist->prlist_len - PR_MAXGROUPS;
811     code = ubik_EndTrans(tt);
812
813 done:
814     if (!alist->prlist_val)
815         alist->prlist_val = (long *) malloc(0); /* make calling stub happy */
816     return code;
817 }
818
819 static stolower(s)
820 register char *s;
821 {
822     register int tc;
823     while (tc = *s) {
824         if (isupper(tc)) *s = tolower(tc);
825         s++;
826     }
827 }
This page took 0.13266 seconds and 5 git commands to generate.