#include <afsconfig.h>
#include <afs/param.h>
-RCSID("$Header$");
#include <stdio.h>
+#include <ctype.h>
#include <afs/stds.h>
+#include <rx/rx.h>
+#include <rx/rxstat.h>
#include "afs_ptsAdmin.h"
#include "../adminutil/afs_AdminInternal.h"
#include <afs/afs_AdminErrors.h>
#include <afs/ptserver.h>
/*
- * The list of external functions that aren't prototyped anywhere
- */
-
-extern int PR_NameToID();
-extern int PR_AddToGroup();
-extern int PR_ChangeEntry();
-extern int PR_RemoveFromGroup();
-extern int PR_INewEntry();
-extern int PR_NewEntry();
-extern int PR_Delete();
-extern int PR_IDToName();
-extern int PR_ListEntry();
-extern int PR_SetMax();
-extern int PR_ListElements();
-extern int PR_SetFieldsEntry();
-extern int PR_IsAMemberOf();
-extern int PR_ListMax();
-extern int PR_ListOwned();
-
-/*
* IsValidCellHandle - validate the cell handle for making pts
* requests.
*
*
*/
-static int IsValidCellHandle(
- const afs_cell_handle_p c_handle,
- afs_status_p st)
+static int
+IsValidCellHandle(const afs_cell_handle_p c_handle, afs_status_p st)
{
int rc = 0;
afs_status_t tst = 0;
- if (!CellHandleIsValid((void *) c_handle, &tst)) {
+ if (!CellHandleIsValid((void *)c_handle, &tst)) {
goto fail_IsValidCellHandle;
}
-
+
if (c_handle->pts_valid == 0) {
tst = ADMCLIENTCELLPTSINVALID;
goto fail_IsValidCellHandle;
rc = 1;
-fail_IsValidCellHandle:
+ fail_IsValidCellHandle:
if (st != NULL) {
- *st = tst;
+ *st = tst;
}
return rc;
}
*
*/
-static int TranslatePTSNames(
- const afs_cell_handle_p cellHandle,
- namelist *names,
- idlist *ids,
- afs_status_p st)
+static int
+TranslatePTSNames(const afs_cell_handle_p cellHandle, namelist * names,
+ idlist * ids, afs_status_p st)
{
int rc = 0;
afs_status_t tst = 0;
* Lowercase the names to translate
*/
- for(i=0;i<names->namelist_len;i++) {
+ for (i = 0; i < names->namelist_len; i++) {
p = names->namelist_val[i];
while (*p) {
*p = tolower(*p);
}
}
- tst = ubik_Call(PR_NameToID, cellHandle->pts, 0, names, ids);
+ tst = ubik_PR_NameToID(cellHandle->pts, 0, names, ids);
if (tst) {
goto fail_TranslatePTSNames;
* Check to see if the lookup failed
*/
- for(i=0;i<ids->idlist_len;i++) {
+ for (i = 0; i < ids->idlist_len; i++) {
if (ids->idlist_val[i] == ANONYMOUSID) {
tst = ADMPTSFAILEDNAMETRANSLATE;
goto fail_TranslatePTSNames;
}
rc = 1;
-fail_TranslatePTSNames:
+ fail_TranslatePTSNames:
if (st != NULL) {
- *st = tst;
+ *st = tst;
}
return rc;
}
*
*/
-static int TranslateTwoNames(
- const afs_cell_handle_p c_handle,
- const char *id1,
- afs_status_t error1,
- const char *id2,
- afs_status_t error2,
- idlist *ids,
- afs_status_p st)
+static int
+TranslateTwoNames(const afs_cell_handle_p c_handle, const char *id1,
+ afs_status_t error1, const char *id2, afs_status_t error2,
+ idlist * ids, afs_status_p st)
{
int rc = 0;
afs_status_t tst = 0;
namelist names;
- char tmp_array[2*PTS_MAX_NAME_LEN];
-
+ char tmp_array[2 * PTS_MAX_NAME_LEN];
+
/*
* Copy the group and user names in order to translate them
*/
names.namelist_len = 2;
- names.namelist_val = (prname *) &tmp_array[0];
+ names.namelist_val = (prname *) & tmp_array[0];
- strncpy(names.namelist_val[0],id1,PTS_MAX_NAME_LEN);
- strncpy(names.namelist_val[1],id2,PTS_MAX_NAME_LEN);
+ strncpy(names.namelist_val[0], id1, PTS_MAX_NAME_LEN);
+ names.namelist_val[0][PTS_MAX_NAME_LEN - 1] = '\0';
+ strncpy(names.namelist_val[1], id2, PTS_MAX_NAME_LEN);
+ names.namelist_val[1][PTS_MAX_NAME_LEN - 1] = '\0';
ids->idlist_val = 0;
ids->idlist_len = 0;
* This is a cheaper check than calling strlen
*/
- if (names.namelist_val[0][PTS_MAX_NAME_LEN-1] != 0) {
+ if (names.namelist_val[0][PTS_MAX_NAME_LEN - 1] != 0) {
tst = error1;
goto fail_TranslateTwoNames;
}
- if (names.namelist_val[0][PTS_MAX_NAME_LEN-1] != 0) {
+ if (names.namelist_val[0][PTS_MAX_NAME_LEN - 1] != 0) {
tst = error2;
goto fail_TranslateTwoNames;
}
* Translate user and group into pts ID's
*/
- if(TranslatePTSNames(c_handle, &names, ids, &tst) == 0) {
+ if (TranslatePTSNames(c_handle, &names, ids, &tst) == 0) {
goto fail_TranslateTwoNames;
}
rc = 1;
-fail_TranslateTwoNames:
+ fail_TranslateTwoNames:
if (st != NULL) {
- *st = tst;
+ *st = tst;
}
return rc;
}
*
*/
-static int TranslateOneName(
- const afs_cell_handle_p c_handle,
- const char *ptsName,
- afs_status_t tooLongError,
- afs_int32 *ptsId,
- afs_status_p st)
+static int
+TranslateOneName(const afs_cell_handle_p c_handle, const char *ptsName,
+ afs_status_t tooLongError, afs_int32 * ptsId,
+ afs_status_p st)
{
int rc = 0;
afs_status_t tst = 0;
namelist names[1];
char tmp_array[PTS_MAX_NAME_LEN];
idlist ids;
-
+
/*
* Copy the name in order to translate it
*/
names[0].namelist_len = 1;
- names[0].namelist_val = (prname *) &tmp_array[0];
+ names[0].namelist_val = (prname *) & tmp_array[0];
- strncpy(names[0].namelist_val,ptsName,PTS_MAX_NAME_LEN);
+ strncpy((char *)names[0].namelist_val, ptsName, PTS_MAX_NAME_LEN);
+ ((char *)names[0].namelist_val)[PTS_MAX_NAME_LEN - 1] = '\0';
ids.idlist_val = 0;
ids.idlist_len = 0;
* This is a cheaper check than calling strlen
*/
- if (names[0].namelist_val[0][PTS_MAX_NAME_LEN-1] != 0) {
+ if (names[0].namelist_val[0][PTS_MAX_NAME_LEN - 1] != 0) {
tst = tooLongError;
goto fail_TranslateOneName;
}
* Translate user into pts ID
*/
- if(TranslatePTSNames(c_handle, names, &ids, &tst) == 0) {
+ if (TranslatePTSNames(c_handle, names, &ids, &tst) == 0) {
goto fail_TranslateOneName;
} else {
if (ids.idlist_val != NULL) {
rc = 1;
-fail_TranslateOneName:
+ fail_TranslateOneName:
if (st != NULL) {
- *st = tst;
+ *st = tst;
}
return rc;
}
*
*/
-static int TranslatePTSIds(
- const afs_cell_handle_p cellHandle,
- namelist *names,
- idlist *ids,
- afs_status_p st)
+static int
+TranslatePTSIds(const afs_cell_handle_p cellHandle, namelist * names,
+ idlist * ids, afs_status_p st)
{
int rc = 0;
afs_status_t tst = 0;
- tst = ubik_Call(PR_IDToName, cellHandle->pts, 0, ids, names);
+ tst = ubik_PR_IDToName(cellHandle->pts, 0, ids, names);
if (tst) {
goto fail_TranslatePTSIds;
}
rc = 1;
-fail_TranslatePTSIds:
+ fail_TranslatePTSIds:
if (st != NULL) {
- *st = tst;
+ *st = tst;
}
return rc;
}
*
*/
-int ADMINAPI pts_GroupMemberAdd(
- const void *cellHandle,
- const char *userName,
- const char *groupName,
- afs_status_p st)
+int ADMINAPI
+pts_GroupMemberAdd(const void *cellHandle, const char *userName,
+ const char *groupName, afs_status_p st)
{
int rc = 0;
afs_status_t tst = 0;
afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
- idlist ids;
-
+ idlist ids = {0,0};
+
/*
* Validate arguments
*/
goto fail_pts_GroupMemberAdd;
}
- if (!TranslateTwoNames(c_handle, userName, ADMPTSUSERNAMETOOLONG, groupName,
- ADMPTSGROUPNAMETOOLONG, &ids, &tst)) {
+ if (!TranslateTwoNames
+ (c_handle, userName, ADMPTSUSERNAMETOOLONG, groupName,
+ ADMPTSGROUPNAMETOOLONG, &ids, &tst)) {
goto fail_pts_GroupMemberAdd;
}
* Make the rpc
*/
- tst = ubik_Call(PR_AddToGroup, c_handle->pts, 0, ids.idlist_val[0],
- ids.idlist_val[1]);
+ tst =
+ ubik_PR_AddToGroup(c_handle->pts, 0, ids.idlist_val[0],
+ ids.idlist_val[1]);
if (tst != 0) {
goto fail_pts_GroupMemberAdd;
}
rc = 1;
-fail_pts_GroupMemberAdd:
+ fail_pts_GroupMemberAdd:
if (ids.idlist_val != 0) {
free(ids.idlist_val);
}
if (st != NULL) {
- *st = tst;
+ *st = tst;
}
return rc;
}
*
*/
-int ADMINAPI pts_GroupOwnerChange(
- const void *cellHandle,
- const char *targetGroup,
- const char *newOwner,
- afs_status_p st)
+int ADMINAPI
+pts_GroupOwnerChange(const void *cellHandle, const char *targetGroup,
+ const char *newOwner, afs_status_p st)
{
int rc = 0;
afs_status_t tst = 0;
afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
idlist ids;
-
+
/*
* Validate arguments
*/
goto fail_pts_GroupOwnerChange;
}
- if (!TranslateTwoNames(c_handle, newOwner, ADMPTSNEWOWNERTOOLONG,
- targetGroup, ADMPTSTARGETGROUPTOOLONG, &ids, &tst)) {
+ if (!TranslateTwoNames
+ (c_handle, newOwner, ADMPTSNEWOWNERTOOLONG, targetGroup,
+ ADMPTSTARGETGROUPTOOLONG, &ids, &tst)) {
goto fail_pts_GroupOwnerChange;
}
* Make the rpc
*/
- tst = ubik_Call(PR_ChangeEntry, c_handle->pts, 0, ids.idlist_val[1],
- "", ids.idlist_val[0], 0);
+ tst =
+ ubik_PR_ChangeEntry(c_handle->pts, 0, ids.idlist_val[1], "",
+ ids.idlist_val[0], 0);
if (tst != 0) {
goto fail_pts_GroupOwnerChange;
}
rc = 1;
-fail_pts_GroupOwnerChange:
+ fail_pts_GroupOwnerChange:
if (ids.idlist_val != 0) {
free(ids.idlist_val);
}
if (st != NULL) {
- *st = tst;
+ *st = tst;
}
return rc;
}
*
*/
-int ADMINAPI pts_GroupCreate(
- const void *cellHandle,
- const char *newGroup,
- const char *newOwner,
- int *newGroupId,
- afs_status_p st)
+int ADMINAPI
+pts_GroupCreate(const void *cellHandle, char *newGroup,
+ char *newOwner, int *newGroupId, afs_status_p st)
{
int rc = 0;
afs_status_t tst = 0;
afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
afs_int32 newOwnerId = 0;
-
+
/*
* Validate arguments
*/
*/
if (newOwner != NULL) {
- if (!TranslateOneName(c_handle, newOwner, ADMPTSNEWOWNERTOOLONG,
- &newOwnerId, &tst)) {
+ if (!TranslateOneName
+ (c_handle, newOwner, ADMPTSNEWOWNERTOOLONG, &newOwnerId, &tst)) {
goto fail_pts_GroupCreate;
}
}
*/
if (*newGroupId != 0) {
- tst = ubik_Call(PR_INewEntry, c_handle->pts, 0, newGroup, *newGroupId,
- newOwnerId);
+ tst =
+ ubik_PR_INewEntry(c_handle->pts, 0, newGroup, *newGroupId,
+ newOwnerId);
} else {
- tst = ubik_Call(PR_NewEntry, c_handle->pts, 0, newGroup, PRGRP,
- newOwnerId, newGroupId);
+ tst =
+ ubik_PR_NewEntry(c_handle->pts, 0, newGroup, PRGRP,
+ newOwnerId, newGroupId);
}
if (tst != 0) {
}
rc = 1;
-fail_pts_GroupCreate:
+ fail_pts_GroupCreate:
if (st != NULL) {
- *st = tst;
+ *st = tst;
}
return rc;
}
*
*/
-static void GetGroupAccess(
- pts_groupAccess_p access,
- afs_int32 flag)
+static void
+GetGroupAccess(pts_groupAccess_p access, afs_int32 flag)
{
*access = PTS_GROUP_OWNER_ACCESS;
*access = PTS_GROUP_ANYUSER_ACCESS;
}
}
-
+
/*
* pts_GroupGet - retrieve information about a particular group.
*
*/
-int ADMINAPI pts_GroupGet(
- const void *cellHandle,
- const char *groupName,
- pts_GroupEntry_p groupP,
- afs_status_p st)
+int ADMINAPI
+pts_GroupGet(const void *cellHandle, const char *groupName,
+ pts_GroupEntry_p groupP, afs_status_p st)
{
int rc = 0;
afs_status_t tst = 0;
* Translate the group name into an id.
*/
- if (!TranslateOneName(c_handle, groupName, ADMPTSGROUPNAMETOOLONG,
- &groupId, &tst)) {
+ if (!TranslateOneName
+ (c_handle, groupName, ADMPTSGROUPNAMETOOLONG, &groupId, &tst)) {
goto fail_pts_GroupGet;
}
* Retrieve information about the group
*/
- tst = ubik_Call(PR_ListEntry, c_handle->pts, 0, groupId, &groupEntry);
+ tst = ubik_PR_ListEntry(c_handle->pts, 0, groupId, &groupEntry);
if (tst != 0) {
goto fail_pts_GroupGet;
groupP->nameUid = groupEntry.id;
groupP->ownerUid = groupEntry.owner;
groupP->creatorUid = groupEntry.creator;
- strcpy(groupP->name, groupEntry.name);
+ strncpy(groupP->name, groupEntry.name, PTS_MAX_NAME_LEN);
+ groupP->name[PTS_MAX_NAME_LEN - 1] = '\0';
/*
* Set the access rights based upon the value of the flags member
* of the groupEntry struct.
twobit = flags & 3;
GetGroupAccess(&groupP->listMembership, twobit);
-
+
flags = flags >> 2;
if (flags & 1) {
ptsids[1] = groupEntry.creator;
names.namelist_len = 0;
names.namelist_val = 0;
-
+
if (!TranslatePTSIds(c_handle, &names, &ids, &tst)) {
goto fail_pts_GroupGet;
}
- strcpy(groupP->owner, names.namelist_val[0]);
- strcpy(groupP->creator, names.namelist_val[1]);
+ strncpy(groupP->owner, names.namelist_val[0], PTS_MAX_NAME_LEN);
+ groupP->owner[PTS_MAX_NAME_LEN - 1] = '\0';
+ strncpy(groupP->creator, names.namelist_val[1], PTS_MAX_NAME_LEN);
+ groupP->creator[PTS_MAX_NAME_LEN - 1] = '\0';
free(names.namelist_val);
rc = 1;
-fail_pts_GroupGet:
+ fail_pts_GroupGet:
if (st != NULL) {
- *st = tst;
+ *st = tst;
}
return rc;
}
*
*/
-static int EntryDelete(
- const void *cellHandle,
- const char *entryName,
- afs_status_t error1,
- afs_status_t error2,
- afs_status_p st)
+static int
+EntryDelete(const void *cellHandle, const char *entryName,
+ afs_status_t error1, afs_status_t error2, afs_status_p st)
{
int rc = 0;
afs_status_t tst = 0;
afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
afs_int32 entryId = 0;
-
+
/*
* Validate arguments
*/
* Translate the entry name into an id.
*/
- if (!TranslateOneName(c_handle, entryName, error2,
- &entryId, &tst)) {
+ if (!TranslateOneName(c_handle, entryName, error2, &entryId, &tst)) {
goto fail_EntryDelete;
}
* Make the rpc
*/
- tst = ubik_Call(PR_Delete, c_handle->pts, 0, entryId);
+ tst = ubik_PR_Delete(c_handle->pts, 0, entryId);
if (tst != 0) {
goto fail_EntryDelete;
}
rc = 1;
-fail_EntryDelete:
+ fail_EntryDelete:
if (st != NULL) {
- *st = tst;
+ *st = tst;
}
return rc;
}
*
*/
-int ADMINAPI pts_GroupDelete(
- const void *cellHandle,
- const char *groupName,
- afs_status_p st)
+int ADMINAPI
+pts_GroupDelete(const void *cellHandle, const char *groupName,
+ afs_status_p st)
{
return EntryDelete(cellHandle, groupName, ADMPTSGROUPNAMENULL,
*
*/
-int ADMINAPI pts_GroupMaxGet(
- const void *cellHandle,
- int *maxGroupId,
- afs_status_p st)
+int ADMINAPI
+pts_GroupMaxGet(const void *cellHandle, int *maxGroupId, afs_status_p st)
{
int rc = 0;
afs_status_t tst = 0;
afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
afs_int32 maxUserId = 0;
-
+
/*
* Validate arguments
*/
goto fail_pts_GroupMaxGet;
}
- tst = ubik_Call(PR_ListMax, c_handle->pts, 0, &maxUserId, maxGroupId);
+ tst = ubik_PR_ListMax(c_handle->pts, 0, &maxUserId, maxGroupId);
if (tst != 0) {
goto fail_pts_GroupMaxGet;
}
rc = 1;
-fail_pts_GroupMaxGet:
+ fail_pts_GroupMaxGet:
if (st != NULL) {
- *st = tst;
+ *st = tst;
}
return rc;
}
*
*/
-int ADMINAPI pts_GroupMaxSet(
- const void *cellHandle,
- int maxGroupId,
- afs_status_p st)
+int ADMINAPI
+pts_GroupMaxSet(const void *cellHandle, int maxGroupId, afs_status_p st)
{
int rc = 0;
afs_status_t tst = 0;
afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
-
+
/*
* Validate arguments
*/
goto fail_pts_GroupMaxSet;
}
- tst = ubik_Call(PR_SetMax, c_handle->pts, 0, maxGroupId, PRGRP);
+ tst = ubik_PR_SetMax(c_handle->pts, 0, maxGroupId, PRGRP);
if (tst != 0) {
goto fail_pts_GroupMaxSet;
}
rc = 1;
-fail_pts_GroupMaxSet:
+ fail_pts_GroupMaxSet:
if (st != NULL) {
- *st = tst;
+ *st = tst;
}
return rc;
}
typedef struct pts_group_member_list_iterator {
int begin_magic;
int is_valid;
- pthread_mutex_t mutex; /* hold to manipulate this structure */
+ pthread_mutex_t mutex; /* hold to manipulate this structure */
prlist ids;
namelist names;
int index;
*
*/
-static int IsValidPtsGroupMemberListIterator(
- pts_group_member_list_iterator_p iter,
- afs_status_p st)
+static int
+IsValidPtsGroupMemberListIterator(pts_group_member_list_iterator_p iter,
+ afs_status_p st)
{
int rc = 0;
afs_status_t tst = 0;
if (iter == NULL) {
- tst = ADMITERATORNULL;
- goto fail_IsValidPtsGroupMemberListIterator;
+ tst = ADMITERATORNULL;
+ goto fail_IsValidPtsGroupMemberListIterator;
}
-
- if ((iter->begin_magic != BEGIN_MAGIC) ||
- (iter->end_magic != END_MAGIC)) {
- tst = ADMITERATORBADMAGICNULL;
- goto fail_IsValidPtsGroupMemberListIterator;
+
+ if ((iter->begin_magic != BEGIN_MAGIC) || (iter->end_magic != END_MAGIC)) {
+ tst = ADMITERATORBADMAGICNULL;
+ goto fail_IsValidPtsGroupMemberListIterator;
}
-
+
if (iter->is_valid == 0) {
- tst = ADMITERATORINVALID;
- goto fail_IsValidPtsGroupMemberListIterator;
+ tst = ADMITERATORINVALID;
+ goto fail_IsValidPtsGroupMemberListIterator;
}
rc = 1;
-fail_IsValidPtsGroupMemberListIterator:
+ fail_IsValidPtsGroupMemberListIterator:
if (st != NULL) {
- *st = tst;
+ *st = tst;
}
return rc;
}
+
/*
* MemberListBegin - an internal function which is used to get both
* the list of members in a group and the list of groups a user belongs
*
*/
-static int MemberListBegin(
- const void *cellHandle,
- const char *name,
- afs_status_t error1,
- afs_status_t error2,
- void **iterationIdP,
- afs_status_p st)
+static int
+MemberListBegin(const void *cellHandle, const char *name, afs_status_t error1,
+ afs_status_t error2, void **iterationIdP, afs_status_p st)
{
int rc = 0;
afs_status_t tst = 0;
afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
afs_int32 groupId = 0;
afs_int32 exceeded = 0;
- pts_group_member_list_iterator_p iter = (pts_group_member_list_iterator_p) malloc(sizeof(pts_group_member_list_iterator_t));
+ pts_group_member_list_iterator_p iter = (pts_group_member_list_iterator_p)
+ malloc(sizeof(pts_group_member_list_iterator_t));
int iter_allocated = 0;
int ids_allocated = 0;
int names_allocated = 0;
int mutex_inited = 0;
-
+
/*
* Validate arguments
*/
* Translate the name into an id.
*/
- if (!TranslateOneName(c_handle, name, ADMPTSGROUPNAMETOOLONG,
- &groupId, &tst)) {
+ if (!TranslateOneName
+ (c_handle, name, ADMPTSGROUPNAMETOOLONG, &groupId, &tst)) {
goto fail_MemberListBegin;
}
iter->ids.prlist_len = 0;
iter->ids.prlist_val = 0;
- tst = ubik_Call(PR_ListElements, c_handle->pts, 0, groupId, &iter->ids,
- &exceeded);
+ tst =
+ ubik_PR_ListElements(c_handle->pts, 0, groupId, &iter->ids,
+ &exceeded);
if (tst != 0) {
goto fail_MemberListBegin;
iter->names.namelist_len = 0;
iter->names.namelist_val = 0;
- if (!TranslatePTSIds(c_handle, &iter->names, (idlist *) &iter->ids, &tst)) {
+ if (!TranslatePTSIds
+ (c_handle, &iter->names, (idlist *) & iter->ids, &tst)) {
goto fail_MemberListBegin;
}
iter->index = 0;
iter->is_valid = 1;
- *iterationIdP = (void *) iter;
+ *iterationIdP = (void *)iter;
rc = 1;
-fail_MemberListBegin:
+ fail_MemberListBegin:
if (ids_allocated) {
free(iter->ids.prlist_val);
}
}
if (st != NULL) {
- *st = tst;
+ *st = tst;
}
return rc;
}
*
*/
-int ADMINAPI pts_GroupMemberListBegin(
- const void *cellHandle,
- const char *groupName,
- void **iterationIdP,
- afs_status_p st)
+int ADMINAPI
+pts_GroupMemberListBegin(const void *cellHandle, const char *groupName,
+ void **iterationIdP, afs_status_p st)
{
return MemberListBegin(cellHandle, groupName, ADMPTSGROUPNAMENULL,
ADMPTSGROUPNAMETOOLONG, iterationIdP, st);
*
*/
-int ADMINAPI pts_GroupMemberListNext(
- const void *iterationId,
- char *memberName,
- afs_status_p st)
+int ADMINAPI
+pts_GroupMemberListNext(const void *iterationId, char *memberName,
+ afs_status_p st)
{
int rc = 0;
afs_status_t tst = 0;
- pts_group_member_list_iterator_p iter = (pts_group_member_list_iterator_p) iterationId;
+ pts_group_member_list_iterator_p iter =
+ (pts_group_member_list_iterator_p) iterationId;
int mutex_locked = 0;
-
+
/*
* Validate arguments
*/
tst = ADMITERATORDONE;
goto fail_pts_GroupMemberListNext;
} else {
- strcpy(memberName,iter->names.namelist_val[iter->index]);
+ strcpy(memberName, iter->names.namelist_val[iter->index]);
iter->index++;
}
rc = 1;
-fail_pts_GroupMemberListNext:
+ fail_pts_GroupMemberListNext:
if (mutex_locked) {
pthread_mutex_unlock(&iter->mutex);
}
if (st != NULL) {
- *st = tst;
+ *st = tst;
}
return rc;
}
* is called only once for each iterator.
*/
-int ADMINAPI pts_GroupMemberListDone(
- const void *iterationId,
- afs_status_p st)
+int ADMINAPI
+pts_GroupMemberListDone(const void *iterationId, afs_status_p st)
{
int rc = 0;
afs_status_t tst = 0;
- pts_group_member_list_iterator_p iter = (pts_group_member_list_iterator_p) iterationId;
+ pts_group_member_list_iterator_p iter =
+ (pts_group_member_list_iterator_p) iterationId;
int mutex_locked = 0;
-
+
/*
* Validate arguments
*/
mutex_locked = 1;
- if (!IsValidPtsGroupMemberListIterator(iter,&tst)) {
+ if (!IsValidPtsGroupMemberListIterator(iter, &tst)) {
goto fail_pts_GroupMemberListDone;
}
free(iter);
rc = 1;
-fail_pts_GroupMemberListDone:
+ fail_pts_GroupMemberListDone:
if (mutex_locked) {
pthread_mutex_unlock(&iter->mutex);
}
-
+
if (st != NULL) {
- *st = tst;
+ *st = tst;
}
return rc;
}
*
*/
-int ADMINAPI pts_GroupMemberRemove(
- const void *cellHandle,
- const char *userName,
- const char *groupName,
- afs_status_p st)
+int ADMINAPI
+pts_GroupMemberRemove(const void *cellHandle, const char *userName,
+ const char *groupName, afs_status_p st)
{
int rc = 0;
afs_status_t tst = 0;
afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
idlist ids;
-
+
+ ids.idlist_val = NULL;
+
/*
* Validate arguments
*/
goto fail_pts_GroupMemberRemove;
}
- if (!TranslateTwoNames(c_handle, userName, ADMPTSUSERNAMETOOLONG, groupName,
- ADMPTSGROUPNAMETOOLONG, &ids, &tst)) {
+ if (!TranslateTwoNames
+ (c_handle, userName, ADMPTSUSERNAMETOOLONG, groupName,
+ ADMPTSGROUPNAMETOOLONG, &ids, &tst)) {
goto fail_pts_GroupMemberRemove;
}
* Make the rpc
*/
- tst = ubik_Call(PR_RemoveFromGroup, c_handle->pts, 0, ids.idlist_val[0],
- ids.idlist_val[1]);
+ tst =
+ ubik_PR_RemoveFromGroup(c_handle->pts, 0, ids.idlist_val[0],
+ ids.idlist_val[1]);
if (tst != 0) {
goto fail_pts_GroupMemberRemove;
}
rc = 1;
-fail_pts_GroupMemberRemove:
+ fail_pts_GroupMemberRemove:
if (ids.idlist_val != 0) {
free(ids.idlist_val);
}
if (st != NULL) {
- *st = tst;
+ *st = tst;
}
return rc;
}
*
*/
-int ADMINAPI pts_GroupRename(
- const void *cellHandle,
- const char *oldName,
- const char *newName,
- afs_status_p st)
+int ADMINAPI
+pts_GroupRename(const void *cellHandle, const char *oldName,
+ char *newName, afs_status_p st)
{
int rc = 0;
afs_status_t tst = 0;
afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
afs_int32 groupId = 0;
-
+
/*
* Validate arguments
*/
* Translate the group name into an id.
*/
- if (!TranslateOneName(c_handle, oldName, ADMPTSOLDNAMETOOLONG,
- &groupId, &tst)) {
+ if (!TranslateOneName
+ (c_handle, oldName, ADMPTSOLDNAMETOOLONG, &groupId, &tst)) {
goto fail_pts_GroupRename;
}
* Make the rpc
*/
- tst = ubik_Call(PR_ChangeEntry, c_handle->pts, 0, groupId, newName, 0, 0);
+ tst = ubik_PR_ChangeEntry(c_handle->pts, 0, groupId, newName, 0, 0);
if (tst != 0) {
goto fail_pts_GroupRename;
}
rc = 1;
-fail_pts_GroupRename:
+ fail_pts_GroupRename:
if (st != NULL) {
- *st = tst;
+ *st = tst;
}
return rc;
}
*
*/
-static int SetGroupAccess(
- const pts_GroupUpdateEntry_p rights,
- afs_int32 *flags,
- afs_status_p st)
+static int
+SetGroupAccess(const pts_GroupUpdateEntry_p rights, afs_int32 * flags,
+ afs_status_p st)
{
int rc = 0;
afs_status_t tst = 0;
}
rc = 1;
-fail_SetGroupAccess:
+ fail_SetGroupAccess:
if (st != NULL) {
- *st = tst;
+ *st = tst;
}
return rc;
}
*
*/
-int ADMINAPI pts_GroupModify(
- const void *cellHandle,
- const char *groupName,
- const pts_GroupUpdateEntry_p newEntryP,
- afs_status_p st)
+int ADMINAPI
+pts_GroupModify(const void *cellHandle, const char *groupName,
+ const pts_GroupUpdateEntry_p newEntryP, afs_status_p st)
{
int rc = 0;
afs_status_t tst = 0;
afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
afs_int32 groupId = 0;
afs_int32 flags = 0;
-
+
/*
* Validate arguments
*/
* Translate the group name into an id.
*/
- if (!TranslateOneName(c_handle, groupName, ADMPTSGROUPNAMETOOLONG,
- &groupId, &tst)) {
+ if (!TranslateOneName
+ (c_handle, groupName, ADMPTSGROUPNAMETOOLONG, &groupId, &tst)) {
goto fail_pts_GroupModify;
}
/*
* Make the rpc
*/
-
- tst = ubik_Call(PR_SetFieldsEntry, c_handle->pts, 0, groupId,
- PR_SF_ALLBITS, flags, 0, 0, 0, 0);
+
+ tst =
+ ubik_PR_SetFieldsEntry(c_handle->pts, 0, groupId, PR_SF_ALLBITS,
+ flags, 0, 0, 0, 0);
if (tst != 0) {
goto fail_pts_GroupModify;
}
rc = 1;
-fail_pts_GroupModify:
+ fail_pts_GroupModify:
if (st != NULL) {
- *st = tst;
+ *st = tst;
}
return rc;
}
*
*/
-int ADMINAPI pts_UserCreate(
- const void *cellHandle,
- const char *userName,
- int *newUserId,
- afs_status_p st)
+int ADMINAPI
+pts_UserCreate(const void *cellHandle, char *userName, int *newUserId,
+ afs_status_p st)
{
int rc = 0;
afs_status_t tst = 0;
afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
- afs_int32 userId = 0;
-
+
/*
* Validate arguments
*/
*/
if (*newUserId != 0) {
- tst = ubik_Call(PR_INewEntry, c_handle->pts, 0, userName, *newUserId,
- 0);
+ tst =
+ ubik_PR_INewEntry(c_handle->pts, 0, userName, *newUserId,
+ 0);
} else {
- tst = ubik_Call(PR_NewEntry, c_handle->pts, 0, userName, 0,
- 0, newUserId);
+ tst =
+ ubik_PR_NewEntry(c_handle->pts, 0, userName, 0, 0,
+ newUserId);
}
if (tst != 0) {
}
rc = 1;
-fail_pts_UserCreate:
+ fail_pts_UserCreate:
if (st != NULL) {
- *st = tst;
+ *st = tst;
}
return rc;
}
*
*/
-int ADMINAPI pts_UserDelete(
- const void *cellHandle,
- const char *userName,
- afs_status_p st)
+int ADMINAPI
+pts_UserDelete(const void *cellHandle, const char *userName, afs_status_p st)
{
return EntryDelete(cellHandle, userName, ADMPTSUSERNAMENULL,
ADMPTSUSERNAMETOOLONG, st);
*
*/
-static void GetUserAccess(
- pts_userAccess_p access,
- afs_int32 flag)
+static void
+GetUserAccess(pts_userAccess_p access, afs_int32 flag)
{
*access = PTS_USER_OWNER_ACCESS;
*access = PTS_USER_ANYUSER_ACCESS;
}
}
-
+
/*
* IsAdministrator - determine if a user is an administrator.
*
*
*/
-static int IsAdministrator(
- const afs_cell_handle_p c_handle,
- afs_int32 userId,
- int *admin,
- afs_status_p st)
+static int
+IsAdministrator(const afs_cell_handle_p c_handle, afs_int32 userId,
+ int *admin, afs_status_p st)
{
int rc = 0;
afs_status_t tst = 0;
if (userId == SYSADMINID) {
*admin = 1;
} else {
- if (!TranslateOneName(c_handle, "system:administrators",
- ADMPTSGROUPNAMETOOLONG, &adminId, &tst)) {
+ if (!TranslateOneName
+ (c_handle, "system:administrators", ADMPTSGROUPNAMETOOLONG,
+ &adminId, &tst)) {
goto fail_IsAdministrator;
}
- tst = ubik_Call(PR_IsAMemberOf, c_handle->pts, 0, userId, adminId, &isAdmin);
+ tst =
+ ubik_PR_IsAMemberOf(c_handle->pts, 0, userId, adminId,
+ &isAdmin);
if (tst != 0) {
goto fail_IsAdministrator;
}
}
rc = 1;
-fail_IsAdministrator:
+ fail_IsAdministrator:
if (st != NULL) {
- *st = tst;
+ *st = tst;
}
return rc;
}
*
*/
-int ADMINAPI pts_UserGet(
- const void *cellHandle,
- const char *userName,
- pts_UserEntry_p userP,
- afs_status_p st)
+int ADMINAPI
+pts_UserGet(const void *cellHandle, const char *userName,
+ pts_UserEntry_p userP, afs_status_p st)
{
int rc = 0;
afs_status_t tst = 0;
namelist names;
int admin = 0;
-
+
/*
* Validate arguments
*/
* Translate the group name into an id.
*/
- if (!TranslateOneName(c_handle, userName, ADMPTSUSERNAMETOOLONG,
- &userId, &tst)) {
+ if (!TranslateOneName
+ (c_handle, userName, ADMPTSUSERNAMETOOLONG, &userId, &tst)) {
goto fail_pts_UserGet;
}
* Retrieve information about the group
*/
- tst = ubik_Call(PR_ListEntry, c_handle->pts, 0, userId, &userEntry);
+ tst = ubik_PR_ListEntry(c_handle->pts, 0, userId, &userEntry);
if (tst != 0) {
goto fail_pts_UserGet;
* has unlimited group creation quota. Denote this by setting
* quota to -1.
*/
-
+
if (!IsAdministrator(c_handle, userEntry.id, &admin, &tst)) {
goto fail_pts_UserGet;
}
userP->nameUid = userEntry.id;
userP->ownerUid = userEntry.owner;
userP->creatorUid = userEntry.creator;
- strcpy(userP->name, userEntry.name);
+ strncpy(userP->name, userEntry.name, PTS_MAX_NAME_LEN);
+ userP->name[PTS_MAX_NAME_LEN - 1] = '\0';
/*
* The permission bits are described in the GroupGet function above.
twobit = flags & 3;
GetUserAccess(&userP->listMembership, twobit);
-
+
flags = flags >> 2;
if (flags & 1) {
ptsids[1] = userEntry.creator;
names.namelist_len = 0;
names.namelist_val = 0;
-
+
if (!TranslatePTSIds(c_handle, &names, &ids, &tst)) {
goto fail_pts_UserGet;
}
- strcpy(userP->owner, names.namelist_val[0]);
- strcpy(userP->creator, names.namelist_val[1]);
+ strncpy(userP->owner, names.namelist_val[0], PTS_MAX_NAME_LEN);
+ userP->owner[PTS_MAX_NAME_LEN - 1] ='\0';
+ strncpy(userP->creator, names.namelist_val[1], PTS_MAX_NAME_LEN);
+ userP->creator[PTS_MAX_NAME_LEN - 1] = '\0';
free(names.namelist_val);
rc = 1;
-fail_pts_UserGet:
+ fail_pts_UserGet:
if (st != NULL) {
- *st = tst;
+ *st = tst;
}
return rc;
}
*
*/
-int ADMINAPI pts_UserRename(
- const void *cellHandle,
- const char *oldName,
- const char *newName,
- afs_status_p st)
+int ADMINAPI
+pts_UserRename(const void *cellHandle, const char *oldName,
+ char *newName, afs_status_p st)
{
int rc = 0;
afs_status_t tst = 0;
afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
afs_int32 userId = 0;
-
+
/*
* Validate arguments
*/
* Translate the user name into an id.
*/
- if (!TranslateOneName(c_handle, oldName, ADMPTSOLDNAMETOOLONG,
- &userId, &tst)) {
+ if (!TranslateOneName
+ (c_handle, oldName, ADMPTSOLDNAMETOOLONG, &userId, &tst)) {
goto fail_pts_UserRename;
}
* Make the rpc
*/
- tst = ubik_Call(PR_ChangeEntry, c_handle->pts, 0, userId, newName, 0, 0);
+ tst = ubik_PR_ChangeEntry(c_handle->pts, 0, userId, newName, 0, 0);
if (tst != 0) {
goto fail_pts_UserRename;
}
rc = 1;
-fail_pts_UserRename:
+ fail_pts_UserRename:
if (st != NULL) {
- *st = tst;
+ *st = tst;
}
return rc;
}
*
*/
-static int SetUserAccess(
- const pts_UserUpdateEntry_p userP,
- afs_int32 *flags,
- afs_status_p st)
+static int
+SetUserAccess(const pts_UserUpdateEntry_p userP, afs_int32 * flags,
+ afs_status_p st)
{
int rc = 0;
afs_status_t tst = 0;
}
rc = 1;
-fail_SetUserAccess:
-
if (st != NULL) {
- *st = tst;
+ *st = tst;
}
return rc;
}
*
*/
-int ADMINAPI pts_UserModify(
- const void *cellHandle,
- const char *userName,
- const pts_UserUpdateEntry_p newEntryP,
- afs_status_p st)
+int ADMINAPI
+pts_UserModify(const void *cellHandle, const char *userName,
+ const pts_UserUpdateEntry_p newEntryP, afs_status_p st)
{
int rc = 0;
afs_status_t tst = 0;
afs_int32 newQuota = 0;
afs_int32 mask = 0;
afs_int32 flags = 0;
-
+
/*
* Validate arguments
*/
* Translate the user name into an id.
*/
- if (!TranslateOneName(c_handle, userName, ADMPTSUSERNAMETOOLONG,
- &userId, &tst)) {
+ if (!TranslateOneName
+ (c_handle, userName, ADMPTSUSERNAMETOOLONG, &userId, &tst)) {
goto fail_pts_UserModify;
}
* Make the rpc
*/
- tst = ubik_Call(PR_SetFieldsEntry, c_handle->pts, 0, userId, mask, flags,
- newQuota, 0, 0, 0);
+ tst =
+ ubik_PR_SetFieldsEntry(c_handle->pts, 0, userId, mask, flags,
+ newQuota, 0, 0, 0);
if (tst != 0) {
goto fail_pts_UserModify;
}
rc = 1;
-fail_pts_UserModify:
+ fail_pts_UserModify:
if (st != NULL) {
- *st = tst;
+ *st = tst;
}
return rc;
}
* Returns != 0 upon successful completion.
*
*/
-
-int ADMINAPI pts_UserMaxGet(
- const void *cellHandle,
- int *maxUserId,
- afs_status_p st)
+
+int ADMINAPI
+pts_UserMaxGet(const void *cellHandle, int *maxUserId, afs_status_p st)
{
int rc = 0;
afs_status_t tst = 0;
afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
afs_int32 maxGroupId = 0;
-
+
/*
* Validate arguments
*/
goto fail_pts_UserMaxGet;
}
- tst = ubik_Call(PR_ListMax, c_handle->pts, 0, maxUserId, &maxGroupId);
+ tst = ubik_PR_ListMax(c_handle->pts, 0, maxUserId, &maxGroupId);
if (tst != 0) {
goto fail_pts_UserMaxGet;
}
rc = 1;
-fail_pts_UserMaxGet:
+ fail_pts_UserMaxGet:
if (st != NULL) {
- *st = tst;
+ *st = tst;
}
return rc;
}
* Returns != 0 upon successful completion.
*
*/
-
-int ADMINAPI pts_UserMaxSet(
- const void *cellHandle,
- int maxUserId,
- afs_status_p st)
+
+int ADMINAPI
+pts_UserMaxSet(const void *cellHandle, int maxUserId, afs_status_p st)
{
int rc = 0;
afs_status_t tst = 0;
afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
-
+
/*
* Validate arguments
*/
goto fail_pts_UserMaxSet;
}
- tst = ubik_Call(PR_SetMax, c_handle->pts, 0, maxUserId, 0);
+ tst = ubik_PR_SetMax(c_handle->pts, 0, maxUserId, 0);
if (tst != 0) {
goto fail_pts_UserMaxSet;
}
rc = 1;
-fail_pts_UserMaxSet:
+ fail_pts_UserMaxSet:
if (st != NULL) {
- *st = tst;
+ *st = tst;
}
return rc;
}
*
*/
-int ADMINAPI pts_UserMemberListBegin(
- const void *cellHandle,
- const char *userName,
- void **iterationIdP,
- afs_status_p st)
+int ADMINAPI
+pts_UserMemberListBegin(const void *cellHandle, const char *userName,
+ void **iterationIdP, afs_status_p st)
{
return MemberListBegin(cellHandle, userName, ADMPTSUSERNAMENULL,
ADMPTSUSERNAMETOOLONG, iterationIdP, st);
*
*/
-int ADMINAPI pts_UserMemberListNext(
- const void *iterationId,
- char *userName,
- afs_status_p st)
+int ADMINAPI
+pts_UserMemberListNext(const void *iterationId, char *userName,
+ afs_status_p st)
{
return pts_GroupMemberListNext(iterationId, userName, st);
}
* is called only once for each iterator.
*/
-int ADMINAPI pts_UserMemberListDone(
- const void *iterationId,
- afs_status_p st)
+int ADMINAPI
+pts_UserMemberListDone(const void *iterationId, afs_status_p st)
{
return pts_GroupMemberListDone(iterationId, st);
}
typedef struct owned_group_list {
- namelist owned_names; /* the list of character names owned by this id */
- prlist owned_ids; /* the list of pts ids owned by this id */
- afs_int32 index; /* the index into owned_names for the next group */
- afs_int32 owner; /* the pts id of the owner */
- afs_int32 more; /* the last parameter to PR_ListOwned */
- int finished_retrieving; /* set when we've processed the last owned_names */
- afs_cell_handle_p c_handle; /* ubik client to pts server's from c_handle */
- char group[CACHED_ITEMS][PTS_MAX_NAME_LEN]; /* cache of names */
+ namelist owned_names; /* the list of character names owned by this id */
+ prlist owned_ids; /* the list of pts ids owned by this id */
+ afs_int32 index; /* the index into owned_names for the next group */
+ afs_int32 owner; /* the pts id of the owner */
+ afs_int32 more; /* the last parameter to PR_ListOwned */
+ int finished_retrieving; /* set when we've processed the last owned_names */
+ afs_cell_handle_p c_handle; /* ubik client to pts server's from c_handle */
+ char group[CACHED_ITEMS][PTS_MAX_NAME_LEN]; /* cache of names */
} owned_group_list_t, *owned_group_list_p;
-static int DeleteOwnedGroupSpecificData(
- void *rpc_specific,
- afs_status_p st)
+static int
+DeleteOwnedGroupSpecificData(void *rpc_specific, afs_status_p st)
{
int rc = 0;
afs_status_t tst = 0;
rc = 1;
if (st != NULL) {
- *st = tst;
+ *st = tst;
}
return rc;
}
-static int GetOwnedGroupRPC(
- void *rpc_specific,
- int slot,
- int *last_item,
- int *last_item_contains_data,
- afs_status_p st)
+static int
+GetOwnedGroupRPC(void *rpc_specific, int slot, int *last_item,
+ int *last_item_contains_data, afs_status_p st)
{
int rc = 0;
afs_status_t tst = 0;
* Check to see if we are done retrieving data
*/
- if ((list->finished_retrieving) &&
- (list->owned_names.namelist_len == 0)) {
+ if ((list->finished_retrieving) && (list->owned_names.namelist_len == 0)) {
*last_item = 1;
*last_item_contains_data = 0;
goto fail_GetOwnedGroupRPC;
*/
if ((!list->finished_retrieving) && (list->owned_names.namelist_len == 0)) {
- tst = ubik_Call(PR_ListOwned, list->c_handle->pts, 0, list->owner,
- &list->owned_ids, &list->more);
+ tst =
+ ubik_PR_ListOwned(list->c_handle->pts, 0, list->owner,
+ &list->owned_ids, &list->more);
if (tst != 0) {
goto fail_GetOwnedGroupRPC;
}
- if (!TranslatePTSIds(list->c_handle, &list->owned_names,
- (idlist *) &list->owned_ids, &tst)) {
+ if (!TranslatePTSIds
+ (list->c_handle, &list->owned_names, (idlist *) & list->owned_ids,
+ &tst)) {
goto fail_GetOwnedGroupRPC;
}
list->index = 0;
* We can retrieve the next group from data we already received
*/
- strcpy(&list->group[slot], &list->owned_names.namelist_val[list->index]);
+ strcpy(list->group[slot], list->owned_names.namelist_val[list->index]);
list->index++;
/*
}
rc = 1;
-fail_GetOwnedGroupRPC:
+ fail_GetOwnedGroupRPC:
if (st != NULL) {
- *st = tst;
+ *st = tst;
}
return rc;
}
-static int GetOwnedGroupFromCache(
- void *rpc_specific,
- int slot,
- void *dest,
- afs_status_p st)
+static int
+GetOwnedGroupFromCache(void *rpc_specific, int slot, void *dest,
+ afs_status_p st)
{
int rc = 0;
afs_status_t tst = 0;
owned_group_list_p list = (owned_group_list_p) rpc_specific;
- strcpy((char *) dest, &list->group[slot]);
+ strcpy((char *)dest, list->group[slot]);
rc = 1;
if (st != NULL) {
- *st = tst;
+ *st = tst;
}
return rc;
*
*/
-int ADMINAPI pts_OwnedGroupListBegin(
- const void *cellHandle,
- const char *userName,
- void **iterationIdP,
- afs_status_p st)
+int ADMINAPI
+pts_OwnedGroupListBegin(const void *cellHandle, const char *userName,
+ void **iterationIdP, afs_status_p st)
{
int rc = 0;
afs_status_t tst = 0;
afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
- afs_admin_iterator_p iter = (afs_admin_iterator_p) malloc(sizeof(afs_admin_iterator_t));
- owned_group_list_p list = (owned_group_list_p) malloc(sizeof(owned_group_list_t));
-
+ afs_admin_iterator_p iter =
+ (afs_admin_iterator_p) malloc(sizeof(afs_admin_iterator_t));
+ owned_group_list_p list =
+ (owned_group_list_p) malloc(sizeof(owned_group_list_t));
+
/*
* Validate arguments
*/
/*
* Initialize the iterator specific data
*/
-
+
list->index = 0;
list->finished_retrieving = 0;
list->c_handle = c_handle;
* Translate the user name into an id.
*/
- if (!TranslateOneName(c_handle, userName, ADMPTSUSERNAMETOOLONG,
- &list->owner, &tst)) {
+ if (!TranslateOneName
+ (c_handle, userName, ADMPTSUSERNAMETOOLONG, &list->owner, &tst)) {
goto fail_pts_OwnedGroupListBegin;
}
- if (IteratorInit(iter, (void *) list, GetOwnedGroupRPC,
- GetOwnedGroupFromCache, NULL,
- DeleteOwnedGroupSpecificData, &tst)) {
- *iterationIdP = (void *) iter;
+ if (IteratorInit
+ (iter, (void *)list, GetOwnedGroupRPC, GetOwnedGroupFromCache, NULL,
+ DeleteOwnedGroupSpecificData, &tst)) {
+ *iterationIdP = (void *)iter;
rc = 1;
}
-fail_pts_OwnedGroupListBegin:
+ fail_pts_OwnedGroupListBegin:
if (rc == 0) {
if (iter != NULL) {
}
if (st != NULL) {
- *st = tst;
+ *st = tst;
}
return rc;
}
*
*/
-int ADMINAPI pts_OwnedGroupListNext(
- const void *iterationId,
- char *groupName,
- afs_status_p st)
+int ADMINAPI
+pts_OwnedGroupListNext(const void *iterationId, char *groupName,
+ afs_status_p st)
{
int rc = 0;
afs_status_t tst = 0;
afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
-
+
/*
* Validate arguments
*/
goto fail_pts_OwnedGroupListNext;
}
- rc = IteratorNext(iter, (void *) groupName, &tst);
+ rc = IteratorNext(iter, (void *)groupName, &tst);
-fail_pts_OwnedGroupListNext:
+ fail_pts_OwnedGroupListNext:
if (st != NULL) {
- *st = tst;
+ *st = tst;
}
return rc;
}
* It is the user's responsibility to make sure pts_OwnedGroupListDone
* is called only once for each iterator.
*/
-
-int ADMINAPI pts_OwnedGroupListDone(
- const void *iterationId,
- afs_status_p st)
+
+int ADMINAPI
+pts_OwnedGroupListDone(const void *iterationId, afs_status_p st)
{
int rc = 0;
afs_status_t tst = 0;
rc = IteratorDone(iter, &tst);
-fail_pts_OwnedGroupListDone:
+ fail_pts_OwnedGroupListDone:
+
+ if (st != NULL) {
+ *st = tst;
+ }
+ return rc;
+}
+
+typedef struct pts_list {
+ prlistentries *names; /* the current list of pts names in this cell */
+ prlistentries *currName; /* the current pts entry */
+ afs_int32 index; /* the index into names for the next pts entry */
+ afs_int32 nextstartindex; /* the next start index for the RPC */
+ afs_int32 nentries; /* the number of entries in names */
+ afs_int32 flag; /* the type of the list */
+ int finished_retrieving; /* set when we've processed the last owned_names */
+ afs_cell_handle_p c_handle; /* ubik client to pts server's from c_handle */
+ char entries[CACHED_ITEMS][PTS_MAX_NAME_LEN]; /* cache of pts names */
+} pts_list_t, *pts_list_p;
+
+static int
+DeletePTSSpecificData(void *rpc_specific, afs_status_p st)
+{
+ int rc = 0;
+ afs_status_t tst = 0;
+ pts_list_p list = (pts_list_p) rpc_specific;
+
+ if (list->names) {
+ free(list->names);
+ }
+
+ rc = 1;
+
+ if (st != NULL) {
+ *st = tst;
+ }
+ return rc;
+}
+
+static int
+GetPTSRPC(void *rpc_specific, int slot, int *last_item,
+ int *last_item_contains_data, afs_status_p st)
+{
+ int rc = 0;
+ afs_status_t tst = 0;
+ pts_list_p list = (pts_list_p) rpc_specific;
+
+ /*
+ * We really don't make an rpc for every entry we return here
+ * since the pts interface allows several members to be returned
+ * with one rpc, but we fake it to make the iterator happy.
+ */
+
+ /*
+ * Check to see if we are done retrieving data
+ */
+
+ if (list->finished_retrieving) {
+ *last_item = 1;
+ *last_item_contains_data = 0;
+ goto fail_GetPTSRPC;
+ }
+
+ /*
+ * Check to see if we really need to make an rpc
+ */
+
+ if ((!list->finished_retrieving) && (list->index >= list->nentries)) {
+ afs_int32 start = list->nextstartindex;
+ prentries bulkentries;
+ list->nextstartindex = -1;
+ bulkentries.prentries_val = 0;
+ bulkentries.prentries_len = 0;
+
+ tst =
+ ubik_PR_ListEntries(list->c_handle->pts, 0, list->flag,
+ start, &bulkentries, &(list->nextstartindex));
+
+ if (tst != 0) {
+ goto fail_GetPTSRPC;
+ }
+
+ list->nentries = bulkentries.prentries_len;
+ list->names = bulkentries.prentries_val;
+
+ list->index = 0;
+ list->currName = list->names;
+
+ }
+
+ /*
+ * We can retrieve the next entry from data we already received
+ */
+
+ strcpy(list->entries[slot], list->currName->name);
+ list->index++;
+ list->currName++;
+
+
+ /*
+ * Check to see if there is more data to be retrieved
+ * We need to free up the previously retrieved data here
+ * and then check to see if the last rpc indicated that there
+ * were more items to retrieve.
+ */
+
+ if (list->index >= list->nentries) {
+ if (list->names) {
+ free(list->names);
+ }
+ list->names = NULL;
+
+ if (list->nextstartindex == -1) {
+ list->finished_retrieving = 1;
+ }
+ }
+ rc = 1;
+
+ fail_GetPTSRPC:
+
+ if (st != NULL) {
+ *st = tst;
+ }
+
+ return rc;
+}
+
+static int
+GetPTSFromCache(void *rpc_specific, int slot, void *dest, afs_status_p st)
+{
+ int rc = 0;
+ afs_status_t tst = 0;
+ pts_list_p list = (pts_list_p) rpc_specific;
+
+ strcpy((char *)dest, list->entries[slot]);
+ rc = 1;
+
+ if (st != NULL) {
+ *st = tst;
+ }
+
+ return rc;
+}
+
+/*
+ * pts_UserListBegin - begin iterating over the list of users
+ * in a particular cell
+ *
+ * PARAMETERS
+ *
+ * IN cellHandle - a previously opened cellHandle that corresponds
+ * to the cell where the users exist.
+ *
+ * OUT iterationIdP - upon successful completion contains a iterator that
+ * can be passed to pts_UserListNext.
+ *
+ * LOCKS
+ *
+ * No locks are held by this function
+ *
+ * RETURN CODES
+ *
+ * Returns != 0 upon successful completion.
+ *
+ */
+
+int ADMINAPI
+pts_UserListBegin(const void *cellHandle, void **iterationIdP,
+ afs_status_p st)
+{
+ int rc = 0;
+ afs_status_t tst = 0;
+ afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
+ afs_admin_iterator_p iter =
+ (afs_admin_iterator_p) malloc(sizeof(afs_admin_iterator_t));
+ pts_list_p list = (pts_list_p) malloc(sizeof(pts_list_t));
+
+ /*
+ * Validate arguments
+ */
+
+ if (!IsValidCellHandle(c_handle, &tst)) {
+ goto fail_pts_UserListBegin;
+ }
+
+ if (iterationIdP == NULL) {
+ tst = ADMITERATORNULL;
+ goto fail_pts_UserListBegin;
+ }
+
+ if ((iter == NULL) || (list == NULL)) {
+ tst = ADMNOMEM;
+ goto fail_pts_UserListBegin;
+ }
+
+ /*
+ * Initialize the iterator specific data
+ */
+
+ list->index = 0;
+ list->finished_retrieving = 0;
+ list->c_handle = c_handle;
+ list->names = NULL;
+ list->nextstartindex = 0;
+ list->nentries = 0;
+ list->flag = PRUSERS;
+
+ if (IteratorInit
+ (iter, (void *)list, GetPTSRPC, GetPTSFromCache, NULL,
+ DeletePTSSpecificData, &tst)) {
+ *iterationIdP = (void *)iter;
+ rc = 1;
+ }
+
+ fail_pts_UserListBegin:
+
+ if (rc == 0) {
+ if (iter != NULL) {
+ free(iter);
+ }
+ if (list != NULL) {
+ free(list);
+ }
+ }
+
+ if (st != NULL) {
+ *st = tst;
+ }
+ return rc;
+}
+
+/*
+ * pts_UserListNext - get the next user in the cell.
+ *
+ * PARAMETERS
+ *
+ * IN iterationId - an iterator previously returned by pts_UserListBegin
+ *
+ * OUT groupName - upon successful completion contains the next user
+ *
+ * LOCKS
+ *
+ * The iterator mutex is held during the retrieval of the next member.
+ *
+ * RETURN CODES
+ *
+ * Returns != 0 upon successful completion.
+ *
+ */
+
+int ADMINAPI
+pts_UserListNext(const void *iterationId, char *userName, afs_status_p st)
+{
+ int rc = 0;
+ afs_status_t tst = 0;
+ afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
+
+ /*
+ * Validate arguments
+ */
+
+ if (iterationId == NULL) {
+ tst = ADMITERATORNULL;
+ goto fail_pts_UserListNext;
+ }
+
+ if (userName == NULL) {
+ tst = ADMPTSUSERNAMENULL;
+ goto fail_pts_UserListNext;
+ }
+
+ rc = IteratorNext(iter, (void *)userName, &tst);
+
+ fail_pts_UserListNext:
+
+ if (st != NULL) {
+ *st = tst;
+ }
+ return rc;
+}
+
+/*
+ * pts_UserListDone - finish using a user list iterator
+ *
+ * PARAMETERS
+ *
+ * IN iterationId - an iterator previously returned by pts_UserListBegin
+ *
+ * LOCKS
+ *
+ * The iterator is locked and then destroyed
+ *
+ * RETURN CODES
+ *
+ * Returns != 0 upon successful completion.
+ *
+ * ASSUMPTIONS
+ *
+ * It is the user's responsibility to make sure pts_UserListDone
+ * is called only once for each iterator.
+ */
+
+int ADMINAPI
+pts_UserListDone(const void *iterationId, afs_status_p st)
+{
+ int rc = 0;
+ afs_status_t tst = 0;
+ afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
+
+ /*
+ * Validate arguments
+ */
+
+ if (iterationId == NULL) {
+ tst = ADMITERATORNULL;
+ goto fail_pts_UserListDone;
+ }
+
+ rc = IteratorDone(iter, &tst);
+
+ fail_pts_UserListDone:
+
+ if (st != NULL) {
+ *st = tst;
+ }
+ return rc;
+}
+
+/*
+ * pts_GroupListBegin - begin iterating over the list of groups
+ * in a particular cell.
+ *
+ * PARAMETERS
+ *
+ * IN cellHandle - a previously opened cellHandle that corresponds
+ * to the cell where the groups exist.
+ *
+ * OUT iterationIdP - upon successful completion contains a iterator that
+ * can be passed to pts_GroupListNext.
+ *
+ * LOCKS
+ *
+ * No locks are held by this function
+ *
+ * RETURN CODES
+ *
+ * Returns != 0 upon successful completion.
+ *
+ */
+
+int ADMINAPI
+pts_GroupListBegin(const void *cellHandle, void **iterationIdP,
+ afs_status_p st)
+{
+ int rc = 0;
+ afs_status_t tst = 0;
+ afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
+ afs_admin_iterator_p iter =
+ (afs_admin_iterator_p) malloc(sizeof(afs_admin_iterator_t));
+ pts_list_p list = (pts_list_p) malloc(sizeof(pts_list_t));
+
+ /*
+ * Validate arguments
+ */
+
+ if (!IsValidCellHandle(c_handle, &tst)) {
+ goto fail_pts_GroupListBegin;
+ }
+
+ if (iterationIdP == NULL) {
+ tst = ADMITERATORNULL;
+ goto fail_pts_GroupListBegin;
+ }
+
+ if ((iter == NULL) || (list == NULL)) {
+ tst = ADMNOMEM;
+ goto fail_pts_GroupListBegin;
+ }
+
+ /*
+ * Initialize the iterator specific data
+ */
+
+ list->index = 0;
+ list->finished_retrieving = 0;
+ list->c_handle = c_handle;
+ list->names = NULL;
+ list->nextstartindex = 0;
+ list->nentries = 0;
+ list->flag = PRGROUPS;
+
+ if (IteratorInit
+ (iter, (void *)list, GetPTSRPC, GetPTSFromCache, NULL,
+ DeletePTSSpecificData, &tst)) {
+ *iterationIdP = (void *)iter;
+ rc = 1;
+ }
+
+ fail_pts_GroupListBegin:
+
+ if (rc == 0) {
+ if (iter != NULL) {
+ free(iter);
+ }
+ if (list != NULL) {
+ free(list);
+ }
+ }
+
+ if (st != NULL) {
+ *st = tst;
+ }
+ return rc;
+}
+
+/*
+ * pts_UserListNext - get the next group in a cell.
+ *
+ * PARAMETERS
+ *
+ * IN iterationId - an iterator previously returned by pts_GroupListBegin
+ *
+ * OUT groupName - upon successful completion contains the next group
+ *
+ * LOCKS
+ *
+ * The iterator mutex is held during the retrieval of the next member.
+ *
+ * RETURN CODES
+ *
+ * Returns != 0 upon successful completion.
+ *
+ */
+
+int ADMINAPI
+pts_GroupListNext(const void *iterationId, char *groupName, afs_status_p st)
+{
+ int rc = 0;
+ afs_status_t tst = 0;
+ afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
+
+ /*
+ * Validate arguments
+ */
+
+ if (iterationId == NULL) {
+ tst = ADMITERATORNULL;
+ goto fail_pts_GroupListNext;
+ }
+
+ if (groupName == NULL) {
+ tst = ADMPTSGROUPNAMENULL;
+ goto fail_pts_GroupListNext;
+ }
+
+ rc = IteratorNext(iter, (void *)groupName, &tst);
+
+ fail_pts_GroupListNext:
+
+ if (st != NULL) {
+ *st = tst;
+ }
+ return rc;
+}
+
+/*
+ * pts_GroupListDone - finish using a group list iterator
+ *
+ * PARAMETERS
+ *
+ * IN iterationId - an iterator previously returned by pts_GroupListBegin
+ *
+ * LOCKS
+ *
+ * The iterator is locked and then destroyed
+ *
+ * RETURN CODES
+ *
+ * Returns != 0 upon successful completion.
+ *
+ * ASSUMPTIONS
+ *
+ * It is the user's responsibility to make sure pts_GroupListDone
+ * is called only once for each iterator.
+ */
+
+int ADMINAPI
+pts_GroupListDone(const void *iterationId, afs_status_p st)
+{
+ int rc = 0;
+ afs_status_t tst = 0;
+ afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
+
+ /*
+ * Validate arguments
+ */
+
+ if (iterationId == NULL) {
+ tst = ADMITERATORNULL;
+ goto fail_pts_GroupListDone;
+ }
+
+ rc = IteratorDone(iter, &tst);
+
+ fail_pts_GroupListDone:
if (st != NULL) {
- *st = tst;
+ *st = tst;
}
return rc;
}