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",
137 info[KMAP_USER], info[KMAP_PRINCIPAL]);
141 case MM_SHOW_FSGROUP:
142 sq_save_args(argc, info, form->extrastuff);
146 sprintf(buf,"Machine: %-20s Directory: %-15s Device: %s\n",
147 info[NFS_NAME], info[NFS_DIR], info[NFS_DEVICE]);
149 sprintf(buf, "Status: %s\n", format_filesys_type(info[NFS_STATUS]));
151 sprintf(buf, "Quota Allocated: %-17s Size: %s\n",
152 info[NFS_ALLOC], info[NFS_SIZE]);
154 sprintf(buf, MOD_FORMAT, info[NFS_MODBY], info[NFS_MODTIME],
159 if (!strcmp(info[Q_TYPE], "ANY"))
160 sprintf(buf, "Filesystem: %s\n", info[Q_FILESYS]);
162 sprintf(buf, "Filesystem: %-45s %s %s\n", info[Q_FILESYS],
163 info[Q_TYPE], info[Q_NAME]);
165 sprintf(buf, "Machine: %-20s Directory: %-15s\n",
166 info[Q_MACHINE], info[Q_DIRECTORY]);
168 sprintf(buf, "Quota: %s\n", info[Q_QUOTA]);
170 sprintf(buf, MOD_FORMAT, info[Q_MODBY], info[Q_MODTIME], info[Q_MODWITH]);
174 (void) sprintf(buf, "List: %s\n", info[L_NAME]);
176 (void) sprintf(buf, "Description: %s\n", info[L_DESC]);
178 if ( atoi(info[L_MAILLIST]))
179 AppendToLog("This list is a mailing list.\n");
181 AppendToLog("This list is NOT a mailing list.\n");
182 if (atoi(info[L_GROUP])) {
183 (void) sprintf(buf,"This list is a Group and its ID number is %s\n",
187 AppendToLog("This list is NOT a Group.\n");
188 if (strcmp(info[L_ACE_TYPE],"NONE") == 0)
189 AppendToLog("This list has no Administrator, how strange?!\n");
191 sprintf(buf, "The Administrator of this list is the %s: %s\n",
192 info[L_ACE_TYPE], info[L_ACE_NAME]);
195 (void) sprintf(buf, "This list is: %s, %s, and %s\n",
196 atoi(info[L_ACTIVE]) ? "active" : "inactive",
197 atoi(info[L_PUBLIC]) ? "public" : "private",
198 atoi(info[L_HIDDEN]) ? "hidden" : "visible");
200 sprintf(buf, MOD_FORMAT, info[L_MODBY], info[L_MODTIME], info[L_MODWITH]);
204 sprintf(buf, "Machine: %-30s Type: %s\n", info[M_NAME], info[M_TYPE]);
206 sprintf(buf, MOD_FORMAT, info[M_MODBY], info[M_MODTIME], info[M_MODWITH]);
209 case MM_SHOW_CLUSTER:
210 sprintf(buf, "Cluster: %s\n", info[C_NAME]);
212 sprintf(buf, "Description: %s\n", info[C_DESCRIPT]);
214 sprintf(buf, "Location: %s\n", info[C_LOCATION]);
216 sprintf(buf, MOD_FORMAT, info[C_MODBY], info[C_MODTIME], info[C_MODWITH]);
220 sprintf(buf, "Cluster: %-20s Label: %-15s Data: %s",
221 info[CD_NAME], info[CD_LABEL], info[CD_DATA]);
225 sprintf(buf, "Machine: %-20s Cluster: %s", info[0], info[1]);
228 case MM_SHOW_MEMBERS:
230 sprintf(buf, "%-9s %s", info[0], info[1]);
232 sprintf(buf, "%s", info[0]);
236 sprintf(buf, "Table: %-20s Modified: %s\n", info[0], info[argc-1]);
238 sprintf(buf, " %-8D appends, %-8d updates, %-8d deletes",
239 info[2], info[3], info[4]);
244 unsigned long host_address;
245 struct hostent *host_entry;
247 host_address = inet_addr(info[1]);
248 if (host_address != NULL) {
249 host_entry = gethostbyaddr((char *)&host_address, 4, AF_INET);
250 if (host_entry != NULL) {
252 info[1] = strsave(host_entry->h_name);
256 sprintf(buf, "Principal %s on %s (%s)\n", info[0], info[1], info[2]);
258 sprintf(buf, " Connected at %s, client %s", info[3], info[4]);
262 sprintf(buf, "Variable: %-20s Value: %s\n", stringval(form, 0),
267 sprintf(buf, "Alias: %-20s Type: %-8s Value: %s\n",
268 info[0], info[1], info[2]);
272 if (atoi(info[SH_HOSTERROR]))
273 sprintf(name, "Error %d: %s", atoi(info[SH_HOSTERROR]),
276 strcpy(name, "No error");
277 sprintf(buf, "%s:%s %s/%s/%s/%s/%s\n",
278 info[SH_MACHINE], info[SH_SERVICE],
279 atoi(info[SH_ENABLE]) ? "Enabled" : "Disabled",
280 atoi(info[SH_SUCCESS]) ? "Success" : "Failure",
281 atoi(info[SH_INPROGRESS]) ? "InProgress" : "Idle",
282 atoi(info[SH_OVERRIDE]) ? "Override" : "Normal", name);
284 AppendToLog("Last Try Last Success Value1 Value2 Value3\n");
285 strcpy(name, atot(info[SH_LASTTRY]));
286 sprintf(buf, "%-20s %-20s %-9d %-9d %s\n", name,
287 atot(info[SH_LASTSUCCESS]), atoi(info[SH_VALUE1]),
288 atoi(info[SH_VALUE2]), info[SH_VALUE3]);
290 sprintf(buf, MOD_FORMAT, info[SH_MODBY], info[SH_MODTIME],
295 sprintf(buf, "The default quota is %s Kbytes.\n", info[0]);
300 sprintf(buf, "%s:%s\n", info[0], info[1]);
302 sprintf(buf, "%s\n", info[0]);
306 sprintf(buf, "Printer: %-35s Spool host: %s\n", info[PCAP_NAME],
307 info[PCAP_SPOOL_HOST]);
309 sprintf(buf, "Spool directory: %-27s Remote Printer Name: %s\n",
310 info[PCAP_SPOOL_DIR], info[PCAP_RPRINTER]);
312 sprintf(buf, "Authentication: %-3s Price/page: %-3s Quota Server: %s\n",
313 atoi(info[PCAP_AUTH]) ? "yes" : "no",
314 info[PCAP_PRICE], info[PCAP_QSERVER]);
316 sprintf(buf, "Comments: %s\n", info[PCAP_COMMENTS]);
318 sprintf(buf, MOD_FORMAT, info[PCAP_MODBY], info[PCAP_MODTIME],
323 sprintf(buf, "Zephyr class: %s\n", info[ZA_CLASS]);
325 if (!strcmp("NONE", info[ZA_XMT_TYPE]))
328 sprintf(name, "Name: %s", info[ZA_XMT_ID]);
329 sprintf(buf, "XMT ACL Type %s %s\n", info[ZA_XMT_TYPE], name);
331 if (!strcmp("NONE", info[ZA_SUB_TYPE]))
334 sprintf(name, "Name: %s", info[ZA_SUB_ID]);
335 sprintf(buf, "SUB ACL Type %s %s\n", info[ZA_SUB_TYPE], name);
337 if (!strcmp("NONE", info[ZA_IWS_TYPE]))
340 sprintf(name, "Name: %s", info[ZA_IWS_ID]);
341 sprintf(buf, "IWS ACL Type %s %s\n", info[ZA_IWS_TYPE], name);
343 if (!strcmp("NONE", info[ZA_IUI_TYPE]))
346 sprintf(name, "Name: %s", info[ZA_IUI_ID]);
347 sprintf(buf, "IUI ACL Type %s %s\n", info[ZA_IUI_TYPE], name);
350 case MM_SHOW_SERVICE:
351 sprintf(name, "%s:%s", info[SVC_ACE_TYPE], info[SVC_ACE_NAME]);
352 sprintf(buf, "Service: %-10s Type: %-8s Owner: %-11s\n",
353 info[SVC_SERVICE], info[SVC_TYPE], name);
355 sprintf(buf, "Interval %s, Target:%s, Script:%s\n",
356 unparse_interval(atoi(info[SVC_INTERVAL])), info[SVC_TARGET],
359 strcpy(name, atot(info[SVC_DFGEN]));
360 sprintf(buf, "Generated %s; Last Checked %s\n", name,
361 atot(info[SVC_DFCHECK]));
363 if (atoi(info[SVC_HARDERROR]))
364 sprintf(name, "Error %d: %s", atoi(info[SVC_HARDERROR]),
367 strcpy(name, "No error");
368 sprintf(buf, "%s/%s/%s\n",
369 atoi(info[SVC_ENABLE]) ? "Enabled" : "Disabled",
370 atoi(info[SVC_INPROGRESS]) ? "InProgress" : "Idle", name);
372 sprintf(buf, MOD_FORMAT, info[SVC_MODBY], info[SVC_MODTIME],
376 case MM_SHOW_ACE_USE:
377 sprintf(buf, "%s: %s", info[0], info[1]);
380 case MM_SHOW_FS_ALIAS:
381 sprintf(buf, "Alias: %s; Real name %s\n", info[0], info[2]);
385 for (i = 0; i < argc; i++) {
386 if (i != 0) AppendToLog(", ");
387 AppendToLog(info[i]);
395 /* Display info about filesystem, doing FS groups & type MUL as well.
396 * frees info before returning.
403 char **argv, buf[256];
404 struct save_queue *sq;
406 if (!strcmp(info[FS_TYPE], "FSGROUP") ||
407 !strcmp(info[FS_TYPE], "MUL")) {
408 sprintf(buf,"%20s %s: %s\n", " ", strcmp(info[FS_TYPE], "MUL") ?
409 "Filesystem Group" : "Multiple Filesystem",
413 sprintf(buf,"Comments: %s\n",info[FS_COMMENTS]);
415 sprintf(buf, MOD_FORMAT, info[FS_MODBY], info[FS_MODTIME],
418 AppendToLog("Containing the filesystems (in order):\n");
421 if ((stat = MoiraQuery("get_fsgroup_members", 1, &info[FS_NAME],
422 save_info, (char *)sq)) != 0) {
423 if (stat == MR_NO_MATCH)
424 AppendToLog(" [no members]");
426 com_err(program_name, stat, "");
428 while (sq_get_data(sq, &argv)) {
429 sprintf(buf, " Filesystem: %-32s (sort key: %s)\n",
439 sprintf(buf,"Filesystem: %s\n", info[FS_NAME]);
441 sprintf(buf,"Type: %-40s Machine: %-15s\n",
442 info[FS_TYPE], info[FS_MACHINE]);
444 sprintf(buf, "Packname: %s\n", info[FS_PACK]);
446 sprintf(buf,"Default Access: %-29s Mountpoint %s\n",
447 info[FS_ACCESS], info[FS_M_POINT]);
449 sprintf(buf,"Comments: %s\n",info[FS_COMMENTS]);
451 sprintf(buf, "User Ownership: %-30s Group Ownership: %s\n",
452 info[FS_OWNER], info[FS_OWNERS]);
454 sprintf(buf, "Update fileserver: %-27s Locker Type: %s\n",
455 atoi(info[FS_CREATE]) ? "On" : "Off",
458 sprintf(buf, MOD_FORMAT, info[FS_MODBY], info[FS_MODTIME],
462 for (i = 0; i < FS_MODWITH; i++)