/*
* Copyright 2000, International Business Machines Corporation and others.
* All Rights Reserved.
- *
+ *
* This software has been released under the terms of the IBM Public
* License. For details, see the LICENSE file in the top-level source
* directory or online at http://www.openafs.org/dl/license10.html
*/
-/*
+/*
* (5) Add functions to process supergroups:
* ChangeIDEntry(), RemoveFromSGEntry(),
* AddToSGEntry(), GetListSG2().
#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"
* just after ubik_ServerInit.
*/
-void
+void
pt_hook_write(void)
{
extern struct ubik_dbase *ubik_dbase;
#endif /* SUPERGROUPS */
/* CorrectUserName - Check to make sure a user name is OK. It must not include
- * either a colon (or it would look like a group) or an atsign (or it would
- * look like a foreign user). The length is checked as well to make sure
- * that the user name, an atsign, and the local cell name will fit in
- * PR_MAXNAMELEN. This is so this user can fit in another cells database as
- * a foreign user with our cell name tacked on. This is a predicate, so it
- * return one if name is OK and zero if name is bogus. */
+ * either a colon (or it would look like a group) or a newline (which can
+ * confuse some ptdb code, depending on the format we're reading from).
+ * This is a predicate, so it return one if name is OK and zero if name is
+ * bogus. */
static int
CorrectUserName(char *name)
{
- extern int pr_realmNameLen;
-
/* We accept foreign names, so we will deal with '@' later */
if (strchr(name, ':') || strchr(name, '\n'))
return 0;
- if (strlen(name) >= PR_MAXNAMELEN - pr_realmNameLen - 1)
+ if (strlen(name) >= PR_MAXNAMELEN)
return 0;
return 1;
}
newEntry = AllocBlock(at);
if (!newEntry)
return PRDBFAIL;
-#ifdef PR_REMEMBER_TIMES
tentry.createTime = time(0);
-#endif
if (flag & PRGRP) {
tentry.flags = PRGRP;
}
} else {
/* A foreign user: <name>@<cell>. The foreign user is added to
- * its representing group. It is
+ * its representing group. It is
*/
char *cellGroup;
afs_int32 pos, n;
return PRBADARG;
tentry.id = *aid;
} else {
- /* Allocate an ID special for this foreign user. It is based
+ /* Allocate an ID special for this foreign user. It is based
* on the representing group's id and nusers count.
*/
tentry.id = allocNextId(at, ¢ry);
}
/* Admins don't get charged for creating a group.
- * If in noAuth mode, you get changed for it but you
+ * If in noAuth mode, you get changed for it but you
* are still allowed to create as many groups as you want.
*/
admin = ((creator == SYSADMINID)
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;
* entry if appropriate */
afs_int32
-ChangeIDEntry(register struct ubik_trans *at, register afs_int32 aid, afs_int32 newid, register afs_int32 bid)
+ChangeIDEntry(struct ubik_trans *at, afs_int32 aid, afs_int32 newid, afs_int32 bid)
{
- register afs_int32 code;
+ afs_int32 code;
struct prentry tentry;
struct contentry centry;
afs_int32 temp;
* continuation entry if appropriate */
afs_int32
-RemoveFromSGEntry(register struct ubik_trans *at, register afs_int32 aid, register afs_int32 bid)
+RemoveFromSGEntry(struct ubik_trans *at, afs_int32 aid, afs_int32 bid)
{
- register afs_int32 code;
+ afs_int32 code;
struct prentry tentry;
struct prentryg *tentryg;
struct contentry centry;
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;
afs_int32
AddToSGEntry(struct ubik_trans *tt, struct prentry *entry, afs_int32 loc, afs_int32 aid)
{
- register afs_int32 code;
+ afs_int32 code;
afs_int32 i;
struct contentry nentry;
struct contentry aentry;
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
GetListSG2(struct ubik_trans *at, afs_int32 gid, prlist *alist, afs_int32 *sizeP, afs_int32 depth)
{
- register afs_int32 code;
+ afs_int32 code;
struct prentry tentry;
struct prentryg *tentryg = (struct prentryg *)&tentry;
afs_int32 i;
afs_int32
GetSGList(struct ubik_trans *at, struct prentry *tentry, prlist *alist)
{
- register afs_int32 code;
+ afs_int32 code;
afs_int32 i;
struct contentry centry;
struct prentryg *tentryg;
}
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) {
code = pr_ReadEntry(at, 0, loc, &tentry);
if (code)
return PRDBFAIL;
- if (restricted && !IsAMemberOf(at, cid, SYSADMINID))
+ if (restricted && !IsAMemberOf(at, cid, SYSADMINID))
return PRPERM;
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)) {
return code;
}
/* Look through cont entries too. This needs to be broken into
- * seperate transaction so that no one transaction becomes too
+ * seperate transaction so that no one transaction becomes too
* large to complete.
*/
for (nptr = tentry.next; nptr; nptr = centry.next) {
}
cellEntry->nusers = htonl(id);
- /* use the field nusers to keep
+ /* use the field nusers to keep
* the next available id in that
* foreign cell's group. Note :
* It would seem more appropriate
* to use ngroup for that and nusers
* to enforce the quota, however pts
- * does not have an option to change
+ * does not have an option to change
* foreign users quota yet */
id = (id << 16) | cellid;
/*
* The only thing that we want to make sure here is that
* the id is in the legal range of this group. If it is
- * a duplicate we don't care since it will get caught
+ * a duplicate we don't care since it will get caught
* in a different check.
*/
if (cellid != groupid)
return 0; /* not in range */
- /*
+ /*
* if we got here we're ok but we need to update the nusers
- * field in order to get the id correct the next time that
+ * field in order to get the id correct the next time that
* we try to allocate it automatically
*/