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 sprintf(buf,"Machine: %-20s Directory: %-15s Device: %s\n",
146 info[NFS_NAME], info[NFS_DIR], info[NFS_DEVICE]);
148 sprintf(buf, "Status: %s\n", format_filesys_type(info[NFS_STATUS]));
150 sprintf(buf, "Quota Allocated: %-17s Size: %s\n",
151 info[NFS_ALLOC], info[NFS_SIZE]);
153 sprintf(buf, MOD_FORMAT, info[NFS_MODBY], info[NFS_MODTIME],
158 if (!strcmp(info[Q_TYPE], "ANY"))
159 sprintf(buf, "Filesystem: %s\n", info[Q_FILESYS]);
161 sprintf(buf, "Filesystem: %-45s %s %s\n", info[Q_FILESYS],
162 info[Q_TYPE], info[Q_NAME]);
164 sprintf(buf, "Machine: %-20s Directory: %-15s\n",
165 info[Q_MACHINE], info[Q_DIRECTORY]);
167 sprintf(buf, "Quota: %s\n", info[Q_QUOTA]);
169 sprintf(buf, MOD_FORMAT, info[Q_MODBY], info[Q_MODTIME], info[Q_MODWITH]);
173 (void) sprintf(buf, "List: %s\n", info[L_NAME]);
175 (void) sprintf(buf, "Description: %s\n", info[L_DESC]);
177 if ( atoi(info[L_MAILLIST]))
178 AppendToLog("This list is a mailing list.\n");
180 AppendToLog("This list is NOT a mailing list.\n");
181 if (atoi(info[L_GROUP])) {
182 (void) sprintf(buf,"This list is a Group and its ID number is %s\n",
186 AppendToLog("This list is NOT a Group.\n");
187 if (strcmp(info[L_ACE_TYPE],"NONE") == 0)
188 AppendToLog("This list has no Administrator, how strange?!\n");
190 sprintf(buf, "The Administrator of this list is the %s: %s\n",
191 info[L_ACE_TYPE], info[L_ACE_NAME]);
194 (void) sprintf(buf, "This list is: %s, %s, and %s\n",
195 atoi(info[L_ACTIVE]) ? "active" : "inactive",
196 atoi(info[L_PUBLIC]) ? "public" : "private",
197 atoi(info[L_HIDDEN]) ? "hidden" : "visible");
199 sprintf(buf, MOD_FORMAT, info[L_MODBY], info[L_MODTIME], info[L_MODWITH]);
203 sprintf(buf, "Machine: %-30s Type: %s\n", info[M_NAME], info[M_TYPE]);
205 sprintf(buf, MOD_FORMAT, info[M_MODBY], info[M_MODTIME], info[M_MODWITH]);
208 case MM_SHOW_CLUSTER:
209 sprintf(buf, "Cluster: %s\n", info[C_NAME]);
211 sprintf(buf, "Description: %s\n", info[C_DESCRIPT]);
213 sprintf(buf, "Location: %s\n", info[C_LOCATION]);
215 sprintf(buf, MOD_FORMAT, info[C_MODBY], info[C_MODTIME], info[C_MODWITH]);
219 sprintf(buf, "Cluster: %-20s Label: %-15s Data: %s\n",
220 info[CD_NAME], info[CD_LABEL], info[CD_DATA]);
224 sprintf(buf, "Machine: %-20s Cluster: %s\n", info[0], info[1]);
227 case MM_SHOW_MEMBERS:
229 sprintf(buf, "%-9s %s\n", info[0], info[1]);
231 sprintf(buf, "%s\n", info[0]);
235 sprintf(buf, "Table: %-20s Modified: %s\n", info[0], info[5]);
237 sprintf(buf, " %-8D appends, %-8d updates, %-8d deletes\n",
238 info[2], info[3], info[4]);
243 unsigned long host_address;
244 struct hostent *host_entry;
246 host_address = inet_addr(info[1]);
247 if (host_address != NULL) {
248 host_entry = gethostbyaddr((char *)&host_address, 4, AF_INET);
249 if (host_entry != NULL) {
251 info[1] = strsave(host_entry->h_name);
255 sprintf(buf, "Principal %s on %s (%s)\n", info[0], info[1], info[2]);
257 sprintf(buf, " Connected at %s, client %s\n", info[3], info[4]);
261 sprintf(buf, "Variable: %-20s Value: %s\n", stringval(form, 0),
266 sprintf(buf, "Alias: %-20s Type: %-8s Value: %s\n",
267 info[0], info[1], info[2]);
271 sprintf(buf, "%s:%s mod by %s on %s with %s\n", info[SH_MACHINE],
272 info[SH_SERVICE], info[SH_MODBY], info[SH_MODTIME],
275 if (atoi(info[SH_HOSTERROR]))
276 sprintf(name, "Error %d: %s", atoi(info[SH_HOSTERROR]),
279 strcpy(name, "No error");
280 sprintf(buf, " %s/%s/%s/%s/%s\n",
281 atoi(info[SH_ENABLE]) ? "Enabled" : "Disabled",
282 atoi(info[SH_SUCCESS]) ? "Success" : "Failure",
283 atoi(info[SH_INPROGRESS]) ? "InProgress" : "Idle",
284 atoi(info[SH_OVERRIDE]) ? "Override" : "Normal", name);
286 AppendToLog(" Last Try Last Success Value1 Value2 Value3\n");
287 strcpy(name, atot(info[SH_LASTTRY]));
288 sprintf(buf, " %-20s %-20s %-9d %-9d %s\n", name,
289 atot(info[SH_LASTSUCCESS]), atoi(info[SH_VALUE1]),
290 atoi(info[SH_VALUE2]), info[SH_VALUE3]);
294 sprintf(buf, "The default quota is %s Kbytes.\n", info[0]);
299 sprintf(buf, "%s:%s\n", info[0], info[1]);
301 sprintf(buf, "%s\n", info[0]);
305 sprintf(buf, "Printer: %-35s Spool host: %s\n", info[PCAP_NAME],
306 info[PCAP_SPOOL_HOST]);
308 sprintf(buf, "Spool directory: %-27s Remote Printer Name: %s\n",
309 info[PCAP_SPOOL_DIR], info[PCAP_RPRINTER]);
311 sprintf(buf, "Authentication: %-3s Price/page: %-3s Quota Server: %s\n",
312 atoi(info[PCAP_AUTH]) ? "yes" : "no",
313 info[PCAP_PRICE], info[PCAP_QSERVER]);
315 sprintf(buf, "Comments: %s\n", info[PCAP_COMMENTS]);
317 sprintf(buf, MOD_FORMAT, info[PCAP_MODBY], info[PCAP_MODTIME],
322 sprintf(buf, "Zephyr class: %s\n", info[ZA_CLASS]);
324 if (!strcmp("NONE", info[ZA_XMT_TYPE]))
327 sprintf(name, "Name: %s", info[ZA_XMT_ID]);
328 sprintf(buf, "XMT ACL Type %s %s\n", info[ZA_XMT_TYPE], name);
330 if (!strcmp("NONE", info[ZA_SUB_TYPE]))
333 sprintf(name, "Name: %s", info[ZA_SUB_ID]);
334 sprintf(buf, "SUB ACL Type %s %s\n", info[ZA_SUB_TYPE], name);
336 if (!strcmp("NONE", info[ZA_IWS_TYPE]))
339 sprintf(name, "Name: %s", info[ZA_IWS_ID]);
340 sprintf(buf, "IWS ACL Type %s %s\n", info[ZA_IWS_TYPE], name);
342 if (!strcmp("NONE", info[ZA_IUI_TYPE]))
345 sprintf(name, "Name: %s", info[ZA_IUI_ID]);
346 sprintf(buf, "IUI ACL Type %s %s\n", info[ZA_IUI_TYPE], name);
349 case MM_SHOW_SERVICE:
350 AppendToLog("Name Type Owner Modified\n");
351 sprintf(name, "%s:%s", info[SVC_ACE_TYPE], info[SVC_ACE_NAME]);
352 sprintf(buf, "%-10s %-8s %-11s by %s on %s with %s\n",
353 info[SVC_SERVICE], info[SVC_TYPE], name, info[SVC_MODBY],
354 info[SVC_MODTIME], info[SVC_MODWITH]);
356 sprintf(buf, " Interval %s, Target:%s, Script:%s\n",
357 unparse_interval(atoi(info[SVC_INTERVAL])), info[SVC_TARGET],
360 strcpy(name, atot(info[SVC_DFGEN]));
361 sprintf(buf, " Generated %s; Last Checked %s\n", name,
362 atot(info[SVC_DFCHECK]));
364 if (atoi(info[SVC_HARDERROR]))
365 sprintf(name, "Error %d: %s", atoi(info[SVC_HARDERROR]),
368 strcpy(name, "No error");
369 sprintf(buf, " %s/%s/%s\n",
370 atoi(info[SVC_ENABLE]) ? "Enabled" : "Disabled",
371 atoi(info[SVC_INPROGRESS]) ? "InProgress" : "Idle", name);
374 case MM_SHOW_ACE_USE:
375 sprintf(buf, "%s: %s\n", info[0], info[1]);
379 for (i = 0; i < argc; i++) {
380 if (i != 0) AppendToLog(", ");
381 AppendToLog(info[i]);
389 /* Display info about filesystem, doing FS groups & type MUL as well.
390 * frees info before returning.
397 char **argv, buf[256];
398 struct save_queue *sq;
400 if (!strcmp(info[FS_TYPE], "FSGROUP") ||
401 !strcmp(info[FS_TYPE], "MUL")) {
402 sprintf(buf,"%20s %s: %s\n", " ", strcmp(info[FS_TYPE], "MUL") ?
403 "Filesystem Group" : "Multiple Filesystem",
407 sprintf(buf,"Comments: %s\n",info[FS_COMMENTS]);
409 sprintf(buf, MOD_FORMAT, info[FS_MODBY], info[FS_MODTIME],
412 AppendToLog("Containing the filesystems (in order):\n");
415 if ((stat = MoiraQuery("get_fsgroup_members", 1, &info[FS_NAME],
416 save_info, (char *)sq)) != 0) {
417 if (stat == MR_NO_MATCH)
418 AppendToLog(" [no members]");
420 com_err(program_name, stat, "");
422 while (sq_get_data(sq, &argv)) {
423 sprintf(buf, " Filesystem: %-32s (sort key: %s)\n",
433 sprintf(buf,"Filesystem: %s\n", info[FS_NAME]);
435 sprintf(buf,"Type: %-40s Machine: %-15s\n",
436 info[FS_TYPE], info[FS_MACHINE]);
438 sprintf(buf, "Packname: %s\n", info[FS_PACK]);
440 sprintf(buf,"Default Access: %-29s Mountpoint %s\n",
441 info[FS_ACCESS], info[FS_M_POINT]);
443 sprintf(buf,"Comments: %s\n",info[FS_COMMENTS]);
445 sprintf(buf, "User Ownership: %-30s Group Ownership: %s\n",
446 info[FS_OWNER], info[FS_OWNERS]);
448 sprintf(buf, "Update fileserver: %-27s Locker Type: %s\n",
449 atoi(info[FS_CREATE]) ? "On" : "Off",
452 sprintf(buf, MOD_FORMAT, info[FS_MODBY], info[FS_MODTIME],
456 for (i = 0; info[i]; i++)