- if (agid == 0 && bgid == 0)
- return;
- if (strcmp(before[L_NAME], after[L_NAME])) {
- sprintf(cmd,
- "%s rename -oldname system:%s -newname system:%s",
- pts, before[L_NAME], after[L_NAME]);
- do_cmd(cmd);
+ if (bgid) {
+ code = pr_DeleteByID(-bgid);
+ if (code && code != PRNOENT) {
+ critical_alert("incremental",
+ "Couldn't delete group %s (id %d): %s",
+ before[L_NAME], -bgid, error_message(code));
+ }
+ return;
+ }
+ if (agid) {
+ strcpy(g1, "system:");
+ strcat(g1, after[L_NAME]);
+ strcpy(g2, "system:administrators");
+ id = -agid;
+ code = pr_CreateGroup(g1, g2, &id);
+ if (code) {
+ critical_alert("incremental",
+ "Couldn't create group %s (id %d): %s",
+ after[L_NAME], id, error_message(code));
+ return;
+ }
+ if (ahide) {
+ code = pr_SetFieldsEntry
+ (-agid, PR_SF_ALLBITS,
+ (ahide ? PRP_STATUS_ANY : 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;
+
+ gethostname(hostname, sizeof(hostname));
+ code = mr_connect(hostname);
+ if (!code) code = mr_auth("afs.incr");
+ if (code) {
+ critical_alert("incremental",
+ "Error contacting Moira server to resolve %s: %s",
+ after[L_NAME], error_message(code));
+ return;
+ }
+ av[0] = "LIST";
+ av[1] = after[L_NAME];
+ get_members(2, av, after[L_NAME]);
+
+ mr_disconnect();