6 #include <moira_site.h>
9 #include <sys/socket.h>
10 #include <netinet/in.h>
20 static char *MOD_FORMAT = "Modified by %s at %s with %s\n";
23 /* atot: convert ASCII integer unix time into human readable date string */
38 /* Turn an integer number of minutes into a print string */
40 char *unparse_interval(i)
43 static char uibuf[32];
45 sprintf(uibuf, "%d hrs %d mins", i / 60, i % 60);
50 static save_info(argc, argv, sq)
53 struct save_queue *sq;
55 sq_save_args(argc, argv, sq);
60 int DisplayCallback(argc, info, form)
65 char buf[1024], name[128];
71 switch (form->menu->operation) {
73 sprintf(name, "%s, %s %s", info[U_LAST], info[U_FIRST], info[U_MIDDLE]);
74 sprintf(buf, "Login name: %-20s Full name: %s\n", info[U_NAME], name);
76 sprintf(buf, "User id: %-23s Login shell %-10s Class: %s\n",
77 info[U_UID], info[U_SHELL], info[U_CLASS]);
81 sprintf(buf, "%s:%s", info[U_NAME], info[U_MITID]);
83 status = GDSS_Verify(buf, strlen(buf), info[U_SIGNATURE], &si);
85 hex_dump(info[U_SIGNATURE]);
86 sprintf(buf, "GDSS_Verify => %d", status);
93 sprintf(buf, "Account is: %-20s ID number: %-11s Signed: %s\n",
94 user_states[atoi(info[U_STATE])], info[U_MITID],
95 *info[U_SIGNATURE] ? (status ? "Bad" : "Yes") : "No");
97 if (atoi(info[U_SECURE]))
98 sprintf(buf, "Secure password set on %s.\n", atot(info[U_SECURE]));
100 sprintf(buf, "No secure password set.\n");
102 sprintf(buf, "Comments: %s\n", info[U_COMMENT]);
104 sprintf(buf, MOD_FORMAT,
105 info[U_MODBY], info[U_MODTIME],info[U_MODWITH]);
109 sprintf(buf, "Finger information for user: %s\n", info[F_NAME]);
111 sprintf(buf, "Login name: %-27s In real life: %s\n", info[F_NAME],
114 sprintf(buf, "Nickname: %-29s Department: %s\n", info[F_NICKNAME],
117 sprintf(buf, "Home: %-33s Home phone: %s\n", info[F_HOME_ADDR],
120 sprintf(buf, "Office: %-31s Office phone: %s\n", info[F_OFFICE_ADDR],
121 info[F_OFFICE_PHONE]);
123 sprintf(buf, MOD_FORMAT, info[F_MODBY], info[F_MODTIME],
128 sprintf(buf, "Post Office information for user: %s\n", info[PO_NAME]);
130 sprintf(buf, "Type: %-8s Box: %s\n", info[PO_TYPE], info[PO_BOX]);
132 sprintf(buf, MOD_FORMAT, info[4], info[3], info[5]);
136 sprintf(buf, "Kerberos mapping: User %-9s Principal %s\n",
137 info[KMAP_USER], info[KMAP_PRINCIPAL]);
141 case MM_SHOW_FSGROUP:
142 sq_save_args(argc, info, form->extrastuff);
145 if (!strcmp(info[Q_TYPE], "ANY"))
146 sprintf(buf, "Filesystem: %s\n", info[Q_FILESYS]);
148 sprintf(buf, "Filesystem: %-45s %s %s\n", info[Q_FILESYS],
149 info[Q_TYPE], info[Q_NAME]);
151 sprintf(buf, "Machine: %-20s Directory: %-15s\n",
152 info[Q_MACHINE], info[Q_DIRECTORY]);
154 sprintf(buf, "Quota: %s\n", info[Q_QUOTA]);
156 sprintf(buf, MOD_FORMAT, info[Q_MODBY], info[Q_MODTIME], info[Q_MODWITH]);
160 (void) sprintf(buf, "List: %s\n", info[L_NAME]);
162 (void) sprintf(buf, "Description: %s\n", info[L_DESC]);
164 if ( atoi(info[L_MAILLIST]))
165 AppendToLog("This list is a mailing list.\n");
167 AppendToLog("This list is NOT a mailing list.\n");
168 if (atoi(info[L_GROUP])) {
169 (void) sprintf(buf,"This list is a Group and its ID number is %s\n",
173 AppendToLog("This list is NOT a Group.\n");
174 if (strcmp(info[L_ACE_TYPE],"NONE") == 0)
175 AppendToLog("This list has no Administrator, how strange?!\n");
177 sprintf(buf, "The Administrator of this list is the %s: %s\n",
178 info[L_ACE_TYPE], info[L_ACE_NAME]);
181 (void) sprintf(buf, "This list is: %s, %s, and %s\n",
182 atoi(info[L_ACTIVE]) ? "active" : "inactive",
183 atoi(info[L_PUBLIC]) ? "public" : "private",
184 atoi(info[L_HIDDEN]) ? "hidden" : "visible");
186 sprintf(buf, MOD_FORMAT, info[L_MODBY], info[L_MODTIME], info[L_MODWITH]);
190 sprintf(buf, "Machine: %-30s Type: %s\n", info[M_NAME], info[M_TYPE]);
192 sprintf(buf, MOD_FORMAT, info[M_MODBY], info[M_MODTIME], info[M_MODWITH]);
195 case MM_SHOW_CLUSTER:
196 sprintf(buf, "Cluster: %s\n", info[C_NAME]);
198 sprintf(buf, "Description: %s\n", info[C_DESCRIPT]);
200 sprintf(buf, "Location: %s\n", info[C_LOCATION]);
202 sprintf(buf, MOD_FORMAT, info[C_MODBY], info[C_MODTIME], info[C_MODWITH]);
206 sprintf(buf, "Cluster: %-20s Label: %-15s Data: %s\n",
207 info[CD_NAME], info[CD_LABEL], info[CD_DATA]);
211 sprintf(buf, "Machine: %-20s Cluster: %s\n", info[0], info[1]);
214 case MM_SHOW_MEMBERS:
216 sprintf(buf, "%-9s %s\n", info[0], info[1]);
218 sprintf(buf, "%s\n", info[0]);
222 sprintf(buf, "Table: %-20s Modified: %s\n", info[0], info[5]);
224 sprintf(buf, " %-8D appends, %-8d updates, %-8d deletes\n",
225 info[2], info[3], info[4]);
230 unsigned long host_address;
231 struct hostent *host_entry;
233 host_address = inet_addr(info[1]);
234 if (host_address != NULL) {
235 host_entry = gethostbyaddr((char *)&host_address, 4, AF_INET);
236 if (host_entry != NULL) {
238 info[1] = strsave(host_entry->h_name);
242 sprintf(buf, "Principal %s on %s (%s)\n", info[0], info[1], info[2]);
244 sprintf(buf, " Connected at %s, client %s\n", info[3], info[4]);
248 sprintf(buf, "Variable: %-20s Value: %s\n", stringval(form, 0),
253 sprintf(buf, "Alias: %-20s Type: %-8s Value: %s\n",
254 info[0], info[1], info[2]);
258 sprintf(buf, "%s:%s mod by %s on %s with %s\n", info[SH_MACHINE],
259 info[SH_SERVICE], info[SH_MODBY], info[SH_MODTIME],
262 if (atoi(info[SH_HOSTERROR]))
263 sprintf(name, "Error %d: %s", atoi(info[SH_HOSTERROR]),
266 strcpy(name, "No error");
267 sprintf(buf, " %s/%s/%s/%s/%s\n",
268 atoi(info[SH_ENABLE]) ? "Enabled" : "Disabled",
269 atoi(info[SH_SUCCESS]) ? "Success" : "Failure",
270 atoi(info[SH_INPROGRESS]) ? "InProgress" : "Idle",
271 atoi(info[SH_OVERRIDE]) ? "Override" : "Normal", name);
273 AppendToLog(" Last Try Last Success Value1 Value2 Value3\n");
274 strcpy(name, atot(info[SH_LASTTRY]));
275 sprintf(buf, " %-20s %-20s %-9d %-9d %s\n", name,
276 atot(info[SH_LASTSUCCESS]), atoi(info[SH_VALUE1]),
277 atoi(info[SH_VALUE2]), info[SH_VALUE3]);
281 sprintf(buf, "The default quota is %s Kbytes.\n", info[0]);
286 sprintf(buf, "%s:%s\n", info[0], info[1]);
288 sprintf(buf, "%s\n", info[0]);
292 sprintf(buf, "Printer: %-35s Spool host: %s\n", info[PCAP_NAME],
293 info[PCAP_SPOOL_HOST]);
295 sprintf(buf, "Spool directory: %-27s Remote Printer Name: %s\n",
296 info[PCAP_SPOOL_DIR], info[PCAP_RPRINTER]);
298 sprintf(buf, "Authentication: %-3s Price/page: %-3s Quota Server: %s\n",
299 atoi(info[PCAP_AUTH]) ? "yes" : "no",
300 info[PCAP_PRICE], info[PCAP_QSERVER]);
302 sprintf(buf, "Comments: %s\n", info[PCAP_COMMENTS]);
304 sprintf(buf, MOD_FORMAT, info[PCAP_MODBY], info[PCAP_MODTIME],
309 sprintf(buf, "Zephyr class: %s\n", info[ZA_CLASS]);
311 if (!strcmp("NONE", info[ZA_XMT_TYPE]))
314 sprintf(name, "Name: %s", info[ZA_XMT_ID]);
315 sprintf(buf, "XMT ACL Type %s %s\n", info[ZA_XMT_TYPE], name);
317 if (!strcmp("NONE", info[ZA_SUB_TYPE]))
320 sprintf(name, "Name: %s", info[ZA_SUB_ID]);
321 sprintf(buf, "SUB ACL Type %s %s\n", info[ZA_SUB_TYPE], name);
323 if (!strcmp("NONE", info[ZA_IWS_TYPE]))
326 sprintf(name, "Name: %s", info[ZA_IWS_ID]);
327 sprintf(buf, "IWS ACL Type %s %s\n", info[ZA_IWS_TYPE], name);
329 if (!strcmp("NONE", info[ZA_IUI_TYPE]))
332 sprintf(name, "Name: %s", info[ZA_IUI_ID]);
333 sprintf(buf, "IUI ACL Type %s %s\n", info[ZA_IUI_TYPE], name);
336 case MM_SHOW_SERVICE:
337 AppendToLog("Name Type Owner Modified\n");
338 sprintf(name, "%s:%s", info[SVC_ACE_TYPE], info[SVC_ACE_NAME]);
339 sprintf(buf, "%-10s %-8s %-11s by %s on %s with %s\n",
340 info[SVC_SERVICE], info[SVC_TYPE], name, info[SVC_MODBY],
341 info[SVC_MODTIME], info[SVC_MODWITH]);
343 sprintf(buf, " Interval %s, Target:%s, Script:%s\n",
344 unparse_interval(atoi(info[SVC_INTERVAL])), info[SVC_TARGET],
347 strcpy(name, atot(info[SVC_DFGEN]));
348 sprintf(buf, " Generated %s; Last Checked %s\n", name,
349 atot(info[SVC_DFCHECK]));
351 if (atoi(info[SVC_HARDERROR]))
352 sprintf(name, "Error %d: %s", atoi(info[SVC_HARDERROR]),
355 strcpy(name, "No error");
356 sprintf(buf, " %s/%s/%s\n",
357 atoi(info[SVC_ENABLE]) ? "Enabled" : "Disabled",
358 atoi(info[SVC_INPROGRESS]) ? "InProgress" : "Idle", name);
361 case MM_SHOW_ACE_USE:
362 sprintf(buf, "%s: %s\n", info[0], info[1]);
366 for (i = 0; i < argc; i++) {
367 if (i != 0) AppendToLog(", ");
368 AppendToLog(info[i]);
376 /* Display info about filesystem, doing FS groups & type MUL as well.
377 * frees info before returning.
384 char **argv, buf[256];
385 struct save_queue *sq;
387 if (!strcmp(info[FS_TYPE], "FSGROUP") ||
388 !strcmp(info[FS_TYPE], "MUL")) {
389 sprintf(buf,"%20s %s: %s\n", " ", strcmp(info[FS_TYPE], "MUL") ?
390 "Filesystem Group" : "Multiple Filesystem",
394 sprintf(buf,"Comments: %s\n",info[FS_COMMENTS]);
396 sprintf(buf, MOD_FORMAT, info[FS_MODBY], info[FS_MODTIME],
399 AppendToLog("Containing the filesystems (in order):\n");
402 if ((stat = MoiraQuery("get_fsgroup_members", 1, &info[FS_NAME],
403 save_info, (char *)sq)) != 0) {
404 if (stat == MR_NO_MATCH)
405 AppendToLog(" [no members]");
407 com_err(program_name, stat, "");
409 while (sq_get_data(sq, &argv)) {
410 sprintf(buf, " Filesystem: %-32s (sort key: %s)\n",
420 sprintf(buf,"Filesystem: %s\n", info[FS_NAME]);
422 sprintf(buf,"Type: %-40s Machine: %-15s\n",
423 info[FS_TYPE], info[FS_MACHINE]);
425 sprintf(buf, "Packname: %s\n", info[FS_PACK]);
427 sprintf(buf,"Default Access: %-29s Mountpoint %s\n",
428 info[FS_ACCESS], info[FS_M_POINT]);
430 sprintf(buf,"Comments: %s\n",info[FS_COMMENTS]);
432 sprintf(buf, "User Ownership: %-30s Group Ownership: %s\n",
433 info[FS_OWNER], info[FS_OWNERS]);
435 sprintf(buf, "Update fileserver: %-27s Locker Type: %s\n",
436 atoi(info[FS_CREATE]) ? "On" : "Off",
439 sprintf(buf, MOD_FORMAT, info[FS_MODBY], info[FS_MODTIME],
443 for (i = 0; info[i]; i++)