[1910] in Moira
MACHINEs on lists, 3 of 3
daemon@ATHENA.MIT.EDU (Garry Zacheiss)
Fri Dec 14 00:37:00 2001
Message-Id: <200112140536.AAA30251@cutter-john.mit.edu>
To: moiradev@MIT.EDU
Date: Fri, 14 Dec 2001 00:36:57 -0500
From: Garry Zacheiss <zacheiss@MIT.EDU>
Client changes.
Index: blanche/blanche.c
===================================================================
RCS file: /afs/athena.mit.edu/astaff/project/moiradev/repository/moira/clients/blanche/blanche.c,v
retrieving revision 1.56
diff -u -r1.56 blanche.c
--- blanche.c 2001/07/18 02:48:52 1.56
+++ blanche.c 2001/11/12 12:53:34
@@ -33,16 +33,18 @@
#define M_LIST 2
#define M_STRING 3
#define M_KERBEROS 4
-#define M_NONE 5
+#define M_MACHINE 5
+#define M_NONE 6
-char *typename[] = { "ANY", "USER", "LIST", "STRING", "KERBEROS", "NONE" };
+char *typename[] = { "ANY", "USER", "LIST", "STRING", "KERBEROS", "MACHINE",
+ "NONE" };
/* argument parsing macro */
#define argis(a, b) (!strcmp(*arg + 1, a) || !strcmp(*arg + 1, b))
/* flags from command line */
int infoflg, verbose, syncflg, memberflg, recursflg, noauth;
-int showusers, showstrings, showkerberos, showlists, showtags;
+int showusers, showstrings, showkerberos, showlists, showtags, showmachines;
int createflag, setinfo, active, public, hidden, maillist, grouplist;
int nfsgroup;
struct member *owner, *memacl;
@@ -79,7 +81,7 @@
/* clear all flags & lists */
infoflg = verbose = syncflg = memberflg = recursflg = 0;
noauth = showusers = showstrings = showkerberos = showlists = 0;
- createflag = setinfo = 0;
+ showtags = showmachines = createflag = setinfo = 0;
active = public = hidden = maillist = grouplist = nfsgroup = -1;
listname = newname = desc = NULL;
owner = NULL;
@@ -328,9 +330,10 @@
taglist->q_next != taglist))
memberflg++;
- /* If none of {users,strings,lists,kerberos} specified, turn them all on */
+ /* If none of {users,strings,lists,kerberos,machines} specified,
+ turn them all on */
if (!(showusers || showstrings || showlists || showkerberos))
- showusers = showstrings = showlists = showkerberos = 1;
+ showusers = showstrings = showlists = showkerberos = showmachines = 1;
/* fire up Moira */
status = mrcl_connect(server, "blanche", 4, !noauth);
@@ -735,6 +738,18 @@
success = 0;
}
free(membervec[2]);
+ case M_MACHINE:
+ membervec[1] = "MACHINE";
+ membervec[2] = canonicalize_hostname(strdup(memberstruct->name));
+ status = mr_query("add_tagged_member_to_list", 4, membervec,
+ NULL, NULL);
+ if (status != MR_SUCCESS)
+ {
+ com_err(whoami, status, "while adding member %s to %s",
+ memberstruct->name, listname);
+ success = 0;
+ }
+ free(membervec[2]);
}
}
@@ -845,6 +860,18 @@
memberstruct->name, listname);
success = 0;
}
+ case M_MACHINE:
+ membervec[1] = "MACHINE";
+ membervec[2] = canonicalize_hostname(memberstruct->name);
+ status = mr_query("delete_member_from_list", 3, membervec,
+ NULL, NULL);
+ if (status != MR_SUCCESS)
+ {
+ com_err(whoami, status, "while deleting member %s from %s",
+ memberstruct->name, listname);
+ success = 0;
+ }
+ free(membervec[2]);
}
}
@@ -1032,6 +1059,11 @@
return;
s = "KERBEROS";
break;
+ case M_MACHINE:
+ if (!showmachines)
+ return;
+ s = "MACHINE";
+ break;
case M_ANY:
printf("%s\n", memberstruct->name);
return;
@@ -1048,6 +1080,8 @@
else if (memberstruct->type == M_STRING &&
!strchr(memberstruct->name, '@'))
printf("STRING:%s", memberstruct->name);
+ else if (memberstruct->type == M_MACHINE)
+ printf("MACHINE:%s", memberstruct->name);
else
printf("%s", memberstruct->name);
}
@@ -1188,6 +1222,9 @@
case 'K':
m->type = M_KERBEROS;
break;
+ case 'M':
+ m->type = M_MACHINE;
+ break;
}
m->name = strdup(argv[1]);
if (argc == 3)
@@ -1287,6 +1324,8 @@
m->type = M_STRING;
else if (!strcasecmp("kerberos", s))
m->type = M_KERBEROS;
+ else if (!strcasecmp("machine", s))
+ m->type = M_MACHINE;
else if (!strcasecmp("none", s))
m->type = M_NONE;
else
Index: moira/lists.c
===================================================================
RCS file: /afs/athena.mit.edu/astaff/project/moiradev/repository/moira/clients/moira/lists.c,v
retrieving revision 1.47
diff -u -r1.47 lists.c
--- lists.c 2001/05/14 19:40:00 1.47
+++ lists.c 2001/11/12 14:24:45
@@ -158,6 +158,8 @@
case GLOM:
args[0] = name1;
args[1] = name2;
+ if (!strcmp(name1, "MACHINE"))
+ args[1] = canonicalize_hostname(strdup(name2));
if ((status = do_mr_query("get_lists_of_member", 2, args,
StoreInfo, &elem)))
{
@@ -719,6 +721,13 @@
free(args[LM_MEMBER]);
args[LM_MEMBER] = canon;
}
+ else if (!strcmp(args[LM_TYPE], "MACHINE"))
+ {
+ char *canon;
+ canon = canonicalize_hostname(strdup(args[LM_MEMBER]));
+ free(args[LM_MEMBER]);
+ args[LM_MEMBER] = canon;
+ }
if ((status = do_mr_query("add_member_to_list", CountArgs(args), args,
NULL, NULL)) != MR_SUCCESS)
@@ -773,6 +782,17 @@
}
}
}
+ else if ((status == MR_MACHINE || status == MR_NO_MATCH) &&
+ !strcmp(args[LM_TYPE], "MACHINE"))
+ {
+ char *canon;
+ canon = canonicalize_hostname(args[LM_MEMBER]);
+ free(args[LM_MEMBER]);
+ args[LM_MEMBER] = canon;
+ if (do_mr_query("delete_member_from_list", CountArgs(args),
+ args, NULL, NULL) == MR_SUCCESS)
+ status = MR_SUCCESS;
+ }
}
if (status)
com_err(program_name, status, " in DeleteMember");
@@ -870,6 +890,8 @@
args[DM_LIST] = info[GLOM_NAME];
args[DM_TYPE] = type;
args[DM_MEMBER] = name;
+ if (!strcmp("MACHINE", type))
+ args[DM_MEMBER] = canonicalize_hostname(strdup(name));
if ((status = do_mr_query("delete_member_from_list", 3, args,
NULL, NULL)))
{