#include <afsconfig.h>
#include <afs/param.h>
+#include <afs/stds.h>
#include <roken.h>
-#include <afs/stds.h>
-#include <sys/types.h>
-#include <stdio.h>
-#ifdef AFS_NT40_ENV
-#include <winsock2.h>
-#else
-#include <netinet/in.h>
-#endif
-#include <string.h>
#include <lock.h>
#include <ubik.h>
#include <rx/xdr.h>
#include <afs/com_err.h>
#include <afs/cellconfig.h>
+
#include "ptserver.h"
#include "pterror.h"
#include "ptprototypes.h"
-#include <stdlib.h>
/* Foreign cells are represented by the group system:authuser@cell*/
#define AUTHUSER_GROUP "system:authuser"
newEntry = AllocBlock(at);
if (!newEntry)
return PRDBFAIL;
-#ifdef PR_REMEMBER_TIMES
tentry.createTime = time(0);
-#endif
if (flag & PRGRP) {
tentry.flags = PRGRP;
/* To create the user <name>@<cell> the group AUTHUSER_GROUP@<cell>
* must exist.
*/
- cellGroup =
- (char *)malloc(strlen(AUTHUSER_GROUP) + strlen(atsign) + 1);
- strcpy(cellGroup, AUTHUSER_GROUP);
- strcat(cellGroup, atsign);
+ asprintf(&cellGroup, "%s%s", AUTHUSER_GROUP, atsign);
pos = FindByName(at, cellGroup, ¢ry);
free(cellGroup);
if (!pos)
/* write updated entry for group */
code = pr_Write(at, 0, pos, ¢ry, sizeof(centry));
+ if (code)
+ return PRDBFAIL;
/* Now add the new user entry to the database */
tentry.creator = creator;
code = pr_ReadEntry(at, 0, temp, &tentry);
if (code != 0)
return code;
-#ifdef PR_REMEMBER_TIMES
tentry.removeTime = time(0);
-#endif
for (i = 0; i < PRSIZE; i++) {
if (tentry.entries[i] == aid) {
tentry.entries[i] = PRBADID;
code = pr_ReadEntry(at, 0, temp, &tentry);
if (code != 0)
return code;
-#ifdef PR_REMEMBER_TIMES
tentry.removeTime = time(NULL);
-#endif
tentryg = (struct prentryg *)&tentry;
for (i = 0; i < SGSIZE; i++) {
if (tentryg->supergroup[i] == aid) {
if (entry->id == aid)
return PRINCONSISTENT;
-#ifdef PR_REMEMBER_TIMES
entry->addTime = time(0);
-#endif
for (i = 0; i < PRSIZE; i++) {
if (entry->entries[i] == aid)
return PRIDEXIST;
if (entry->id == aid)
return PRINCONSISTENT;
-#ifdef PR_REMEMBER_TIMES
entry->addTime = time(NULL);
-#endif
entryg = (struct prentryg *)entry;
for (i = 0; i < SGSIZE; i++) {
if (entryg->supergroup[i] == aid)
afs_int32
AddToPRList(prlist *alist, int *sizeP, afs_int32 id)
{
- char *tmp;
+ afs_int32 *tmp;
int count;
if (alist->prlist_len >= *sizeP) {
count = alist->prlist_len + 100;
if (alist->prlist_val) {
- tmp =
- (char *)realloc(alist->prlist_val, count * sizeof(afs_int32));
+ tmp = realloc(alist->prlist_val, count * sizeof(afs_int32));
} else {
- tmp = (char *)malloc(count * sizeof(afs_int32));
+ tmp = malloc(count * sizeof(afs_int32));
}
if (!tmp)
return (PRNOMEM);
- alist->prlist_val = (afs_int32 *) tmp;
+ alist->prlist_val = tmp;
*sizeP = count;
}
alist->prlist_val[alist->prlist_len++] = id;
}
if (build) {
- /* Only rebuild database if the db was deleted (the header is zero) and we
- * are running noAuth. */
+ /* Only rebuild database if the db was deleted (the header is zero) */
char *bp = (char *)&cheader;
int i;
for (i = 0; i < sizeof(cheader); i++) {
break;
}
}
- if (!pr_noAuth) {
- code = PRDBBAD;
- afs_com_err(whoami, code,
- "Can't rebuild database because not running NoAuth");
- }
}
if (code) {
if (tentry.owner != cid && !IsAMemberOf(at, cid, SYSADMINID)
&& !IsAMemberOf(at, cid, tentry.owner) && !pr_noAuth)
return PRPERM;
-#ifdef PR_REMEMBER_TIMES
tentry.changeTime = time(0);
-#endif
/* we're actually trying to change the id */
if (newid && (newid != aid)) {