From 8ec23c21783e8533cf7af22edd612cebfe200916 Mon Sep 17 00:00:00 2001 From: probe Date: Sun, 7 Jun 1992 04:20:08 +0000 Subject: [PATCH] Preserve hidden status of groups --- afssync/sync.qc | 30 +++++++++++++++++------- incremental/afs.c | 59 ++++++++++++++++++++++++++++++++++------------- 2 files changed, 65 insertions(+), 24 deletions(-) diff --git a/afssync/sync.qc b/afssync/sync.qc index ed6606d2..f443c340 100644 --- a/afssync/sync.qc +++ b/afssync/sync.qc @@ -9,16 +9,16 @@ #include #include #include + #include -#include -#include -#include +#include "ptint.h" +#include "ptserver.h" +#include "pterror.h" + #include #include #include -#define USERSMS 14487 - #define min(x,y) ((x) < (y) ? (x) : (y)) struct hash *users = NULL; char *whoami = "sync"; @@ -52,10 +52,13 @@ char **argv; ## begin transaction do_passwd(); +#if 0 +#define USERSMS 14487 status = PR_AddToGroup(NULL, USERSMS, SYSADMINID); if (status) { prserror(status, "adding MR to system:administrators", 0, 0); } +#endif do_groups(); ## end transaction @@ -164,7 +167,7 @@ do_groups() struct hash *groups; long u, g, status; ## char name[33], namebuf[128]; -## int gid, id, lid; +## int gid, id, lid, hide; fprintf(stderr, "Doing groups\n"); @@ -178,14 +181,25 @@ do_groups() ## retrieve (name = l.modtime) where l.list_id = 0 ## retrieve (name = users.modtime) where users.users_id = 0 -## retrieve (name = l.#name, gid = l.#gid, lid = l.list_id) +## retrieve (name = l.#name, gid = l.#gid, lid = l.list_id, hide = l.hidden) ## where l.group != 0 and l.active != 0 { strtrim(name); sprintf(namebuf, "system:%s", name); hash_store(groups, lid, -gid); status = PR_INewEntry(NULL, namebuf, -gid, SYSADMINID); if (status) - prserror(status, "adding list %s gid %d", namebuf, -gid); + prserror(status, "adding list %s gid %d", namebuf, -gid); + else { + if (hide) { + status = PR_SetFieldsEntry + (NULL/*call*/, -gid, + PR_SF_ALLBITS/*mask*/, + PRP_STATUS_MEM >> PRIVATE_SHIFT /*flags*/, + 0/*ngroups*/, 0/*nusers*/, 0/*spare1*/, 0/*spare2*/); + } + if (status) + prserror(status, "setting flags on list %s", namebuf); + } ## } diff --git a/incremental/afs.c b/incremental/afs.c index 80e73245..b38347bc 100644 --- a/incremental/afs.c +++ b/incremental/afs.c @@ -180,22 +180,25 @@ int beforec; char **after; int afterc; { - int agid, bgid; + register int agid, bgid; + int ahide, bhide; long code, id; char hostname[64]; char g1[PR_MAXNAMELEN], g2[PR_MAXNAMELEN]; char *av[2]; agid = bgid = 0; - if (beforec > L_GID && atoi(before[L_ACTIVE]) && atoi(before[L_GROUP])) + if (beforec > L_GID && atoi(before[L_ACTIVE]) && atoi(before[L_GROUP])) { bgid = atoi(before[L_GID]); - if (afterc > L_GID && atoi(after[L_ACTIVE]) && atoi(after[L_GROUP])) + bhide = atoi(before[L_HIDDEN]); + } + if (afterc > L_GID && atoi(after[L_ACTIVE]) && atoi(after[L_GROUP])) { agid = atoi(after[L_GID]); + ahide = atoi(after[L_HIDDEN]); + } if (agid == 0 && bgid == 0) /* Not active groups */ return; - if (agid == bgid && !strcmp(after[L_NAME], before[L_NAME])) - return; /* No change */ code=pr_Initialize(1, AFSCONF_CLIENTNAME, 0); if (code) { @@ -205,17 +208,30 @@ int afterc; } if (agid && bgid) { - /* Only a modify is required */ - strcpy(g1, "system:"); - strcpy(g2, "system:"); - strcat(g1, before[L_NAME]); - strcat(g2, after[L_NAME]); - code = pr_ChangeEntry(g1, g2, (agid==bgid) ? 0 : -agid, ""); - if (code) { - critical_alert("incremental", - "Couldn't change group %s (id %d) to %s (id %d): %s", - before[L_NAME], -bgid, after[L_NAME], -agid, - error_message(code)); + if (strcmp(after[L_NAME], before[L_NAME])) { + /* Only a modify is required */ + strcpy(g1, "system:"); + strcpy(g2, "system:"); + strcat(g1, before[L_NAME]); + strcat(g2, after[L_NAME]); + code = pr_ChangeEntry(g1, g2, (agid==bgid) ? 0 : -agid, ""); + if (code) { + critical_alert("incremental", + "Couldn't change group %s (id %d) to %s (id %d): %s", + before[L_NAME], -bgid, after[L_NAME], -agid, + error_message(code)); + } + } + if (ahide != bhide) { + code = pr_SetFieldsEntry + (-agid, PR_SF_ALLBITS, + (ahide ? PRP_STATUS_MEM : PRP_GROUP_DEFAULT) >> PRIVATE_SHIFT, + 0 /*ngroups*/, 0 /*nusers*/); + if (code) { + critical_alert("incremental", + "Couldn't set flags of group %s: %s", + after[L_NAME], error_message(code)); + } } return; } @@ -240,6 +256,17 @@ int afterc; after[L_NAME], id, error_message(code)); return; } + if (ahide) { + code = pr_SetFieldsEntry + (-agid, PR_SF_ALLBITS, + (ahide ? PRP_STATUS_MEM : PRP_GROUP_DEFAULT) >> PRIVATE_SHIFT, + 0 /*ngroups*/, 0 /*nusers*/); + if (code) { + critical_alert("incremental", + "Couldn't set flags of group %s: %s", + after[L_NAME], error_message(code)); + } + } /* We need to make sure the group is properly populated */ if (beforec < L_ACTIVE || atoi(before[L_ACTIVE]) == 0) return; -- 2.45.2