+ if (bgid) {
+ tries = 0;
+ while (code = pr_DeleteByID(-bgid)) {
+ if (++tries > PR_TRIES)
+ break;
+ if (code == UNOQUORUM) { sleep(90); continue; }
+ sleep(PR_DELAY);
+ }
+ 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;
+ tries = 0;
+ while (code = pr_CreateGroup(g1, g2, &id)) {
+ if (++tries > PR_TRIES)
+ break;
+ if (code == UNOQUORUM) { sleep(90); continue; }
+ sleep(PR_DELAY);
+ }
+ if (code) {
+ critical_alert("incremental",
+ "Couldn't create group %s (id %d): %s",
+ after[L_NAME], id, error_message(code));
+ return;
+ }
+ if (ahide) {
+ tries = 0;
+ while (code = pr_SetFieldsEntry
+ (-agid, PR_SF_ALLBITS,
+ (ahide ?PRP_STATUS_ANY :PRP_GROUP_DEFAULT)>>PRIVATE_SHIFT,
+ 0 /*ngroups*/, 0 /*nusers*/)) {
+ if (++tries > PR_TRIES)
+ break;
+ if (code == UNOQUORUM) { sleep(90); continue; }
+ sleep(PR_DELAY);
+ }
+ if (code) {
+ critical_alert("incremental",
+ "Couldn't set flags of group %s: %s",
+ after[L_NAME], error_message(code));
+ }
+ }
+
+ sleep(1); /* give ptserver some time */
+
+ /* 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();