2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 #include <afsconfig.h>
11 #include <afs/param.h>
19 #include <sys/types.h>
26 #include <netinet/in.h>
28 #include <sys/socket.h>
30 #endif /* AFS_NT40_ENV */
32 #include <afs/procmgmt.h> /* signal(), kill(), wait(), etc. */
36 #include <afs/afsutil.h>
37 #include <afs/cellconfig.h>
43 #include <afs/cellconfig.h>
46 #include <afs/com_err.h>
48 #include <afs/ktime.h>
52 extern char *volutil_PartitionName();
53 extern struct rx_call *rx_NewCall();
54 extern char *volutil_PartitionName();
55 extern struct hostent *hostutil_GetHostByName();
62 #define MRAFS_OFFSET 9
63 #define ADDPARMOFFSET 26
65 static struct SalvageParms {
70 afs_int32 Optrootfiles;
71 afs_int32 Optsalvagedirs;
72 afs_int32 Optblockreads;
73 afs_int32 OptListResidencies;
74 afs_int32 OptSalvageRemote;
75 afs_int32 OptSalvageArchival;
76 afs_int32 OptIgnoreCheck;
77 afs_int32 OptForceOnLine;
78 afs_int32 OptUseRootDirACL;
79 afs_int32 OptTraceBadLinkCounts;
80 afs_int32 OptDontAskFS;
81 afs_int32 OptLogLevel;
83 afs_uint32 OptResidencies;
86 /* dummy routine for the audit work. It should do nothing since audits */
87 /* occur at the server level and bos is not a server. */
93 /* keep those lines small */
99 return "communications failure (-1)";
100 else if (acode == -3)
101 return "communications timeout (-3)";
103 return (char *)error_message(acode);
106 /* get partition id from a name */
108 GetPartitionID(aname)
116 return -1; /* unknown */
117 /* numbers go straight through */
118 if (tc >= '0' && tc <= '9') {
121 /* otherwise check for vicepa or /vicepa, or just plain "a" */
123 if (strlen(aname) <= 2) {
124 strcpy(ascii, aname);
125 } else if (!strncmp(aname, "/vicep", 6)) {
126 strncpy(ascii, aname + 6, 2);
127 } else if (!strncmp(aname, "vicep", 5)) {
128 strncpy(ascii, aname + 5, 2);
130 return -1; /* bad partition name */
131 /* now partitions are named /vicepa ... /vicepz, /vicepaa, /vicepab,
132 * .../vicepzz, and are numbered from 0. Do the appropriate conversion */
134 /* one char name, 0..25 */
135 if (ascii[0] < 'a' || ascii[0] > 'z')
136 return -1; /* wrongo */
137 return ascii[0] - 'a';
139 /* two char name, 26 .. <whatever> */
140 if (ascii[0] < 'a' || ascii[0] > 'z')
141 return -1; /* wrongo */
142 if (ascii[1] < 'a' || ascii[1] > 'z')
143 return -1; /* just as bad */
144 return (ascii[0] - 'a') * 26 + (ascii[1] - 'a') + 26;
148 /* make ctime easier to use */
153 static char tbuffer[30];
155 tp = ctime((time_t *) & atime);
158 tbuffer[24] = 0; /* get rid of new line */
160 strcpy(tbuffer, "BAD TIME");
164 /* global stuff from main for communicating with GetConn */
165 static struct rx_securityClass *sc[3];
168 /* use the syntax descr to get a connection, authenticated appropriately.
169 * aencrypt is set if we want to encrypt the data on the wire.
171 static struct rx_connection *
172 GetConn(as, aencrypt)
174 struct cmd_syndesc *as;
178 register afs_int32 code;
179 register struct rx_connection *tconn;
181 register struct afsconf_dir *tdir;
183 struct ktc_principal sname;
184 struct ktc_token ttoken;
188 hostname = as->parms[0].items->data;
189 th = hostutil_GetHostByName(hostname);
191 printf("bos: can't find address for host '%s'\n", hostname);
194 memcpy(&addr, th->h_addr, sizeof(afs_int32));
196 /* get tokens for making authenticated connections */
197 localauth = (as->parms[ADDPARMOFFSET + 2].items != 0);
199 (localauth ? AFSDIR_SERVER_ETC_DIRPATH : AFSDIR_CLIENT_ETC_DIRPATH);
200 tdir = afsconf_Open(confdir);
202 struct afsconf_cell info;
205 if (as->parms[ADDPARMOFFSET].items)
206 tname = as->parms[ADDPARMOFFSET].items->data;
209 /* next call expands cell name abbrevs for us and handles looking up
211 code = afsconf_GetCellInfo(tdir, tname, NULL, &info);
213 com_err("bos", code, "(can't find cell '%s' in cell database)",
214 (tname ? tname : "<default>"));
217 strcpy(sname.cell, info.name);
219 printf("bos: can't open cell database (%s)\n", confdir);
222 sname.instance[0] = 0;
223 strcpy(sname.name, "afs");
224 sc[0] = rxnull_NewClientSecurityObject();
229 if (!as->parms[ADDPARMOFFSET + 1].items) { /* not -noauth */
230 if (as->parms[ADDPARMOFFSET + 2].items) { /* -localauth */
231 code = afsconf_GetLatestKey(tdir, 0, 0);
233 com_err("bos", code, "(getting key from local KeyFile)");
236 code = afsconf_ClientAuthSecure(tdir, &sc[2], &scIndex);
238 code = afsconf_ClientAuth(tdir, &sc[2], &scIndex);
240 com_err("bos", code, "(calling ClientAuth)");
241 else if (scIndex != 2) /* this shouldn't happen */
244 } else { /* not -localauth, check for tickets */
245 code = ktc_GetToken(&sname, &ttoken, sizeof(ttoken), NULL);
247 /* have tickets, will travel */
248 if (ttoken.kvno >= 0 && ttoken.kvno <= 255);
251 "bos: funny kvno (%d) in ticket, proceeding\n",
256 encryptLevel = rxkad_crypt;
258 encryptLevel = rxkad_clear;
259 sc[2] = (struct rx_securityClass *)
260 rxkad_NewClientSecurityObject(encryptLevel,
267 com_err("bos", code, "(getting tickets)");
269 if ((scIndex == 0) || (sc[scIndex] == 0)) {
270 fprintf(stderr, "bos: running unauthenticated\n");
275 rx_NewConnection(addr, htons(AFSCONF_NANNYPORT), 1, sc[scIndex],
278 fprintf(stderr, "bos: could not create rx connection\n");
281 rxs_Release(sc[scIndex]);
288 struct cmd_syndesc *as;
290 register afs_int32 code;
291 register struct rx_connection *tconn;
295 tconn = GetConn(as, 0);
296 tp = as->parms[1].items->data;
297 if (strcmp(tp, "on") == 0)
298 flag = 0; /* auth req.: noauthflag is false */
299 else if (strcmp(tp, "off") == 0)
303 ("bos: illegal authentication specifier '%s', must be 'off' or 'on'.\n",
307 code = BOZO_SetNoAuthFlag(tconn, flag);
309 com_err("bos", code, "(failed to set authentication flag)");
313 /* take a name (e.g. foo/bar, and a dir e.g. /usr/afs/bin, and construct
314 * /usr/afs/bin/bar */
316 ComputeDestDir(aname, adir, aresult, alen)
317 char *aname, *adir, *aresult;
322 strcpy(aresult, adir);
323 tp = strrchr(aname, '/');
326 strcat(aresult, "/");
327 strcat(aresult, aname);
329 /* tp points at the / character */
335 /* copy data from fd afd to rx call acall */
337 CopyBytes(afd, acall)
339 register struct rx_call *acall;
341 register afs_int32 code;
342 register afs_int32 len;
346 len = read(afd, tbuffer, sizeof(tbuffer));
350 return 0; /* all done */
351 code = rx_Write(acall, tbuffer, len);
359 register struct cmd_syndesc *as;
361 register afs_int32 code;
362 register struct rx_connection *tconn;
363 register afs_int32 flags;
365 tconn = GetConn(as, 0);
367 if (as->parms[1].items)
368 flags |= BOZO_PRUNEBAK;
369 if (as->parms[2].items)
370 flags |= BOZO_PRUNEOLD;
371 if (as->parms[3].items)
372 flags |= BOZO_PRUNECORE;
373 if (as->parms[4].items)
375 code = BOZO_Prune(tconn, flags);
377 com_err("bos", code, "(failed to prune server files)");
383 register struct cmd_syndesc *as;
385 register struct rx_connection *tconn;
386 register afs_int32 code;
388 tconn = GetConn(as, 0);
389 code = BOZO_Exec(tconn, as->parms[1].items->data);
391 printf("bos: failed to execute command (%s)\n", em(code));
397 register struct cmd_syndesc *as;
399 register afs_int32 code;
402 afs_int32 time, bakTime, oldTime;
403 register struct rx_connection *tconn;
404 register struct cmd_item *ti;
406 tconn = GetConn(as, 0);
407 if (!as->parms[1].items) {
408 printf("bos: no files to check\n");
412 /* compute dest dir or file; default MUST be canonical form of dir path */
413 if (as->parms[2].items)
414 strcpy(destDir, as->parms[2].items->data);
416 strcpy(destDir, AFSDIR_CANONICAL_SERVER_BIN_DIRPATH);
418 for (ti = as->parms[1].items; ti; ti = ti->next) {
419 /* check date for each file */
420 ComputeDestDir(ti->data, destDir, tbuffer, sizeof(tbuffer));
421 code = BOZO_GetDates(tconn, tbuffer, &time, &bakTime, &oldTime);
423 printf("bos: failed to check date on %s (%s)\n", ti->data,
427 printf("File %s ", tbuffer);
429 printf("does not exist, ");
431 printf("dated %s, ", DateOf(time));
433 printf("no .BAK file, ");
435 printf(".BAK file dated %s, ", DateOf(bakTime));
437 printf("no .OLD file.");
439 printf(".OLD file dated %s.", DateOf(oldTime));
448 register struct cmd_syndesc *as;
450 register afs_int32 code;
453 register struct cmd_item *ti;
454 register struct rx_connection *tconn;
456 tconn = GetConn(as, 0);
457 if (!as->parms[1].items) {
458 printf("bos: no files to uninstall\n");
462 /* compute dest dir or file; default MUST be canonical form of dir path */
463 if (as->parms[2].items)
464 strcpy(destDir, as->parms[2].items->data);
466 strcpy(destDir, AFSDIR_CANONICAL_SERVER_BIN_DIRPATH);
468 for (ti = as->parms[1].items; ti; ti = ti->next) {
469 /* uninstall each file */
470 ComputeDestDir(ti->data, destDir, tbuffer, sizeof(tbuffer));
471 code = BOZO_UnInstall(tconn, tbuffer);
473 printf("bos: failed to uninstall %s (%s)\n", ti->data, em(code));
476 printf("bos: uninstalled file %s\n", ti->data);
482 GetServerGoal(aconn, aname)
484 struct rx_connection *aconn;
488 register afs_int32 code;
489 struct bozo_status istatus;
492 code = BOZO_GetInstanceInfo(aconn, aname, &tp, &istatus);
494 printf("bos: failed to get instance info for '%s' (%s)\n", aname,
496 /* if we can't get the answer, assume its running */
499 if (istatus.goal == 0)
500 return BSTAT_SHUTDOWN;
507 struct cmd_syndesc *as;
509 struct rx_connection *tconn;
510 register afs_int32 code;
511 register struct cmd_item *ti;
515 struct rx_call *tcall;
518 tconn = GetConn(as, 0);
519 if (!as->parms[1].items) {
520 printf("bos: no files to install\n");
524 /* compute dest dir or file; default MUST be canonical form of dir path */
525 if (as->parms[2].items)
526 strcpy(destDir, as->parms[2].items->data);
528 strcpy(destDir, AFSDIR_CANONICAL_SERVER_BIN_DIRPATH);
530 for (ti = as->parms[1].items; ti; ti = ti->next) {
531 /* install each file */
532 fd = open(ti->data, O_RDONLY);
534 /* better to quit on error than continue for install command */
535 printf("bos: can't find file '%s', quitting\n", ti->data);
538 code = fstat(fd, &tstat);
540 printf("bos: failed to stat file %s, errno is %d\n", ti->data,
544 /* compute destination dir */
545 ComputeDestDir(ti->data, destDir, tbuffer, sizeof(tbuffer));
546 tcall = rx_NewCall(tconn);
548 StartBOZO_Install(tcall, tbuffer, tstat.st_size,
549 (afs_int32) tstat.st_mode, tstat.st_mtime);
551 code = CopyBytes(fd, tcall);
553 code = rx_EndCall(tcall, code);
555 printf("bos: failed to install %s (%s)\n", ti->data, em(code));
558 printf("bos: installed file %s\n", ti->data);
565 struct cmd_syndesc *as;
567 register struct rx_connection *tconn;
568 register afs_int32 code;
569 register struct cmd_item *ti;
571 tconn = GetConn(as, 0);
572 if (as->parms[1].items == 0) {
573 code = BOZO_ShutdownAll(tconn);
575 printf("bos: failed to shutdown servers (%s)\n", em(code));
577 for (ti = as->parms[1].items; ti; ti = ti->next) {
578 code = BOZO_SetTStatus(tconn, ti->data, BSTAT_SHUTDOWN);
580 printf("bos: failed to shutdown instance %s (%s)\n", ti->data,
584 if (as->parms[8].items) {
585 code = BOZO_WaitAll(tconn);
587 printf("bos: can't wait for processes to shutdown (%s)\n",
594 BlockScannerCmd(as, arock)
595 struct cmd_syndesc *as;
598 register afs_int32 code;
599 struct rx_connection *tconn;
600 char BlockCommand[] = "/usr/afs/bin/scanner -block";
602 tconn = GetConn(as, 0);
603 code = BOZO_Exec(tconn, BlockCommand);
606 ("bos: failed to block scanner from making migration requests (%s)\n",
612 UnBlockScannerCmd(as, arock)
613 struct cmd_syndesc *as;
616 register afs_int32 code;
617 struct rx_connection *tconn;
618 char UnBlockCommand[] = "/usr/afs/bin/scanner -unblock";
620 tconn = GetConn(as, 0);
621 code = BOZO_Exec(tconn, UnBlockCommand);
624 ("bos: failed to allow scanner daemon to make migration requests again (%s)\n",
630 GetRestartCmd(as, arock)
631 struct cmd_syndesc *as;
634 register afs_int32 code;
635 struct ktime generalTime, newBinaryTime;
636 char messageBuffer[256];
637 struct rx_connection *tconn;
640 hostp = as->parms[0].items->data; /* host name for messages */
641 tconn = GetConn(as, 0);
643 code = BOZO_GetRestartTime(tconn, 1, &generalTime);
645 printf("bos: failed to retrieve restart information (%s)\n",
649 code = BOZO_GetRestartTime(tconn, 2, &newBinaryTime);
651 printf("bos: failed to retrieve restart information (%s)\n",
656 code = ktime_DisplayString(&generalTime, messageBuffer);
658 printf("bos: failed to decode restart time (%s)\n", em(code));
661 printf("Server %s restarts %s\n", hostp, messageBuffer);
663 code = ktime_DisplayString(&newBinaryTime, messageBuffer);
665 printf("bos: failed to decode restart time (%s)\n", em(code));
668 printf("Server %s restarts for new binaries %s\n", hostp, messageBuffer);
675 SetRestartCmd(as, arock)
676 struct cmd_syndesc *as;
680 register afs_int32 code;
681 struct ktime restartTime;
683 struct rx_connection *tconn;
686 tconn = GetConn(as, 0);
687 if (as->parms[2].items) {
691 if (as->parms[3].items) {
696 printf("bos: can't specify more than one restart time at a time\n");
700 type = 1; /* by default set general restart time */
702 if (code = ktime_ParsePeriodic(as->parms[1].items->data, &restartTime)) {
703 printf("bos: failed to parse '%s' as periodic restart time(%s)\n",
704 as->parms[1].items->data, em(code));
708 code = BOZO_SetRestartTime(tconn, type, &restartTime);
710 printf("bos: failed to set restart time at server (%s)\n", em(code));
718 struct cmd_syndesc *as;
720 register struct rx_connection *tconn;
721 register afs_int32 code;
722 register struct cmd_item *ti;
724 tconn = GetConn(as, 0);
725 if (as->parms[1].items == 0) {
726 code = BOZO_StartupAll(tconn);
728 printf("bos: failed to startup servers (%s)\n", em(code));
730 for (ti = as->parms[1].items; ti; ti = ti->next) {
731 code = BOZO_SetTStatus(tconn, ti->data, BSTAT_NORMAL);
733 printf("bos: failed to start instance %s (%s)\n", ti->data,
742 struct cmd_syndesc *as;
744 register struct rx_connection *tconn;
745 register afs_int32 code;
746 register struct cmd_item *ti;
748 tconn = GetConn(as, 0);
749 if (as->parms[2].items) {
750 /* this is really a rebozo command */
751 if (as->parms[1].items) {
752 /* specified specific things to restart, can't do this at the same
755 ("bos: can't specify both '-bos' and specific servers to restart.\n");
758 /* otherwise do a rebozo */
759 code = BOZO_ReBozo(tconn);
761 printf("bos: failed to restart bosserver (%s)\n", em(code));
764 if (as->parms[1].items == 0) {
765 if (as->parms[3].items) { /* '-all' */
766 code = BOZO_RestartAll(tconn);
768 printf("bos: failed to restart servers (%s)\n", em(code));
770 printf("bos: To restart all processes please specify '-all'\n");
772 if (as->parms[3].items) {
773 printf("bos: Can't use '-all' along with individual instances\n");
775 for (ti = as->parms[1].items; ti; ti = ti->next) {
776 code = BOZO_Restart(tconn, ti->data);
778 printf("bos: failed to restart instance %s (%s)\n",
788 struct cmd_syndesc *as;
790 register struct rx_connection *tconn;
791 register afs_int32 code;
793 tconn = GetConn(as, 0);
794 code = BOZO_SetCellName(tconn, as->parms[1].items->data);
796 printf("bos: failed to set cell (%s)\n", em(code));
802 register struct cmd_syndesc *as;
804 register struct rx_connection *tconn;
805 register afs_int32 code;
806 register struct cmd_item *ti;
807 char name[MAXHOSTCHARS];
809 tconn = GetConn(as, 0);
810 for (ti = as->parms[1].items; ti; ti = ti->next) {
811 if (as->parms[2].items) {
812 if (strlen(ti->data) > MAXHOSTCHARS - 3) {
813 fprintf(stderr, "bos: host name too long\n");
817 strcpy(&name[1], ti->data);
818 strcat((char *)&name, "]");
819 code = BOZO_AddCellHost(tconn, name);
821 code = BOZO_AddCellHost(tconn, ti->data);
823 printf("bos: failed to add host %s (%s)\n", ti->data, em(code));
830 register struct cmd_syndesc *as;
832 register struct rx_connection *tconn;
833 register afs_int32 code;
834 register struct cmd_item *ti;
836 tconn = GetConn(as, 0);
837 for (ti = as->parms[1].items; ti; ti = ti->next) {
838 code = BOZO_DeleteCellHost(tconn, ti->data);
840 printf("bos: failed to delete host %s (%s)\n", ti->data,
848 register struct cmd_syndesc *as;
850 register struct rx_connection *tconn;
851 register afs_int32 code;
854 register afs_int32 i;
857 tconn = GetConn(as, 0);
858 code = BOZO_GetCellName(tconn, &tp);
860 printf("bos: failed to get cell name (%s)\n", em(code));
863 printf("Cell name is %s\n", tbuffer);
865 code = BOZO_GetCellHost(tconn, i, &tp);
869 printf("bos: failed to get cell host %d (%s)\n", i, em(code));
872 printf(" Host %d is %s\n", i + 1, tbuffer);
879 register struct cmd_syndesc *as;
881 register struct rx_connection *tconn;
882 register afs_int32 code;
883 struct ktc_encryptionKey tkey;
886 char cellBuffer[256];
887 char buf[BUFSIZ], ver[BUFSIZ];
889 tconn = GetConn(as, 1);
890 memset(&tkey, 0, sizeof(struct ktc_encryptionKey));
892 if (as->parms[1].items)
893 strcpy(buf, as->parms[1].items->data);
896 code = des_read_pw_string(buf, sizeof(buf), "input key: ", 0);
897 if (code || strlen(buf) == 0) {
898 fprintf(stderr, "Bad key: \n");
901 code = des_read_pw_string(ver, sizeof(ver), "Retype input key: ", 0);
902 if (code || strlen(ver) == 0) {
903 fprintf(stderr, "Bad key: \n");
906 if (strcmp(ver, buf) != 0) {
907 fprintf(stderr, "\nInput key mismatch\n");
913 temp = atoi(as->parms[2].items->data);
917 strcpy((char *)&tkey, as->parms[1].items->data);
919 strcpy((char *)&tkey, buf);
920 } else { /* kerberos key */
921 if (as->parms[ADDPARMOFFSET].items) {
922 strcpy(cellBuffer, as->parms[ADDPARMOFFSET].items->data);
924 /* string to key needs upper-case cell names */
926 /* I don't believe this is true. The string to key function
927 * actually expands the cell name, then LOWER-CASES it. Perhaps it
928 * didn't use to??? */
929 ucstring(cellBuffer, cellBuffer, strlen(cellBuffer));
932 tcell = NULL; /* no cell specified, use current */
934 ka_StringToKey(as->parms[1].items->data, tcell, &tkey);
936 ka_StringToKey(buf, tcell, &tkey);
938 tconn = GetConn(as, 1);
939 code = BOZO_AddKey(tconn, temp, &tkey);
941 printf("bos: failed to set key %d (%s)\n", temp, em(code));
949 register struct cmd_syndesc *as;
951 register struct rx_connection *tconn;
952 register afs_int32 code;
954 register struct cmd_item *ti;
956 tconn = GetConn(as, 0);
957 for (ti = as->parms[1].items; ti; ti = ti->next) {
958 temp = atoi(ti->data);
959 code = BOZO_DeleteKey(tconn, temp);
961 printf("bos: failed to delete key %d (%s)\n", temp, em(code));
970 IN register struct cmd_syndesc *as;
972 register struct rx_connection *tconn;
973 register afs_int32 code;
974 struct ktc_encryptionKey tkey;
976 struct bozo_keyInfo keyInfo;
978 register afs_int32 i;
980 tconn = GetConn(as, 1);
983 code = BOZO_ListKeys(tconn, i, &kvno, &tkey, &keyInfo);
987 /* first check if key is returned */
988 if ((!ka_KeyIsZero(&tkey, sizeof(tkey))) && (as->parms[1].items)) {
989 printf("key %d is '", kvno);
990 ka_PrintBytes(&tkey, sizeof(tkey));
993 if (keyInfo.keyCheckSum == 0) /* shouldn't happen */
994 printf("key version is %d\n", kvno);
996 printf("key %d has cksum %u\n", kvno, keyInfo.keyCheckSum);
1000 printf("Keys last changed on %s.\n", DateOf(keyInfo.mod_sec));
1003 printf("bos: %s error encountered while listing keys\n", em(code));
1005 printf("All done.\n");
1011 register struct cmd_syndesc *as;
1013 register struct rx_connection *tconn;
1014 register afs_int32 code;
1016 register struct cmd_item *ti;
1019 tconn = GetConn(as, 0);
1020 for (ti = as->parms[1].items; ti; ti = ti->next) {
1021 code = BOZO_AddSUser(tconn, ti->data);
1023 printf("bos: failed to add user '%s' (%s)\n", ti->data, em(code));
1032 register struct cmd_syndesc *as;
1034 register struct rx_connection *tconn;
1035 register struct cmd_item *ti;
1036 register afs_int32 code;
1040 tconn = GetConn(as, 0);
1041 for (ti = as->parms[1].items; ti; ti = ti->next) {
1042 code = BOZO_DeleteSUser(tconn, ti->data);
1044 printf("bos: failed to delete user '%s', ", ti->data);
1046 printf("(no such user)\n");
1048 printf("(%s)\n", em(code));
1055 #define NPERLINE 10 /* dudes to print per line */
1058 register struct cmd_syndesc *as;
1060 register struct rx_connection *tconn;
1062 register afs_int32 code;
1065 int lastNL, printGreeting;
1067 tconn = GetConn(as, 0);
1072 code = BOZO_ListSUsers(tconn, i, &tp);
1075 if (printGreeting) {
1076 printGreeting = 0; /* delay until after first call succeeds */
1077 printf("SUsers are: ");
1079 printf("%s ", tbuffer);
1080 if ((i % NPERLINE) == NPERLINE - 1) {
1087 /* a real error code, instead of scanned past end */
1088 printf("bos: failed to retrieve super-user list (%s)\n", em(code));
1098 register struct cmd_syndesc *as;
1100 register struct rx_connection *tconn;
1101 register afs_int32 code;
1103 char ibuffer[BOZO_BSSIZE];
1107 /* int32p==1 is obsolete, smaller, printout */
1108 int32p = (as->parms[2].items != 0 ? 2 : 0);
1110 /* no parms does something pretty different */
1111 if (as->parms[1].items)
1112 return IStatServer(as, int32p);
1114 tconn = GetConn(as, 0);
1116 /* for each instance */
1118 code = BOZO_EnumerateInstance(tconn, i, &tp);
1122 printf("bos: failed to contact host's bosserver (%s).\n",
1126 DoStat(ibuffer, tconn, int32p, (i == 0)); /* print status line */
1133 register struct cmd_syndesc *as;
1135 register struct rx_connection *tconn;
1136 register afs_int32 code;
1138 register struct cmd_item *ti;
1140 char *type, *name, *notifier = NONOTIFIER;
1142 tconn = GetConn(as, 0);
1143 for (i = 0; i < 6; i++)
1145 for (i = 0, ti = as->parms[3].items; (ti && i < 6); ti = ti->next, i++) {
1146 parms[i] = ti->data;
1148 name = as->parms[1].items->data;
1149 type = as->parms[2].items->data;
1150 if (ti = as->parms[4].items) {
1151 notifier = ti->data;
1154 BOZO_CreateBnode(tconn, type, name, parms[0], parms[1], parms[2],
1155 parms[3], parms[4], notifier);
1158 ("bos: failed to create new server instance %s of type '%s' (%s)\n",
1159 name, type, em(code));
1166 register struct cmd_syndesc *as;
1168 register struct rx_connection *tconn;
1169 register afs_int32 code;
1170 register struct cmd_item *ti;
1173 tconn = GetConn(as, 0);
1174 for (ti = as->parms[1].items; ti; ti = ti->next) {
1175 code = BOZO_DeleteBnode(tconn, ti->data);
1178 printf("bos: can't delete running instance '%s'\n", ti->data);
1180 printf("bos: failed to delete instance '%s' (%s)\n", ti->data,
1189 register struct cmd_syndesc *as;
1191 register struct rx_connection *tconn;
1192 register afs_int32 code;
1193 register struct cmd_item *ti;
1196 tconn = GetConn(as, 0);
1197 for (ti = as->parms[1].items; ti; ti = ti->next) {
1198 code = BOZO_SetStatus(tconn, ti->data, BSTAT_NORMAL);
1200 printf("bos: failed to start instance '%s' (%s)\n", ti->data,
1208 register struct cmd_syndesc *as;
1210 register struct rx_connection *tconn;
1211 register afs_int32 code;
1212 register struct cmd_item *ti;
1215 tconn = GetConn(as, 0);
1216 for (ti = as->parms[1].items; ti; ti = ti->next) {
1217 code = BOZO_SetStatus(tconn, ti->data, BSTAT_SHUTDOWN);
1219 printf("bos: failed to change stop instance '%s' (%s)\n",
1220 ti->data, em(code));
1222 if (as->parms[8].items) {
1223 code = BOZO_WaitAll(tconn);
1225 printf("bos: can't wait for processes to shutdown (%s)\n",
1231 #define PARMBUFFERSSIZE 32
1234 DoSalvage(aconn, aparm1, aparm2, aoutName, showlog, parallel, atmpDir,
1236 struct rx_connection *aconn;
1245 register afs_int32 code;
1248 char tbuffer[BOZO_BSSIZE];
1249 struct bozo_status istatus;
1250 struct rx_call *tcall;
1254 char partName[20]; /* canonical name for partition */
1255 char pbuffer[PARMBUFFERSSIZE];
1256 afs_int32 partNumber;
1257 char *notifier = NONOTIFIER;
1259 /* if a partition was specified, canonicalize the name, since
1260 * the salvager has a stupid partition ID parser */
1262 partNumber = volutil_GetPartitionID(aparm1);
1263 if (partNumber < 0) {
1264 printf("bos: could not parse partition ID '%s'\n", aparm1);
1267 tp = volutil_PartitionName(partNumber);
1269 printf("bos: internal error parsing partition ID '%s'\n", aparm1);
1272 strcpy(partName, tp);
1276 /* open the file name */
1278 outFile = fopen(aoutName, "w");
1280 printf("bos: can't open specified SalvageLog file '%s'\n",
1284 closeIt = 1; /* close this file later */
1287 closeIt = 0; /* don't close this file later */
1290 for (code = 2; code < 6; code++)
1294 /* MUST pass canonical (wire-format) salvager path to bosserver */
1295 strncpy(tbuffer, AFSDIR_CANONICAL_SERVER_SALVAGER_FILEPATH, BOZO_BSSIZE);
1297 if ((strlen(tbuffer) + 1 + strlen(partName) + 1 + strlen(aparm2) +
1299 printf("bos: command line too big\n");
1302 strcat(tbuffer, " ");
1303 strcat(tbuffer, partName);
1304 strcat(tbuffer, " ");
1305 strcat(tbuffer, aparm2);
1307 if ((strlen(tbuffer) + 4 + strlen(partName) + 1) > BOZO_BSSIZE) {
1308 printf("bos: command line too big\n");
1311 strcat(tbuffer, " -f ");
1312 strcat(tbuffer, partName);
1315 /* add the parallel option if given */
1316 if (parallel != NULL) {
1317 if ((strlen(tbuffer) + 11 + strlen(parallel) + 1) > BOZO_BSSIZE) {
1318 printf("bos: command line too big\n");
1321 strcat(tbuffer, " -parallel ");
1322 strcat(tbuffer, parallel);
1325 /* add the tmpdir option if given */
1326 if (atmpDir != NULL) {
1327 if ((strlen(tbuffer) + 9 + strlen(atmpDir) + 1) > BOZO_BSSIZE) {
1328 printf("bos: command line too big\n");
1331 strcat(tbuffer, " -tmpdir ");
1332 strcat(tbuffer, atmpDir);
1335 /* add the orphans option if given */
1336 if (orphans != NULL) {
1337 if ((strlen(tbuffer) + 10 + strlen(orphans) + 1) > BOZO_BSSIZE) {
1338 printf("bos: command line too big\n");
1341 strcat(tbuffer, " -orphans ");
1342 strcat(tbuffer, orphans);
1345 if (mrafsParm.Optdebug)
1346 strcat(tbuffer, " -debug");
1347 if (mrafsParm.Optnowrite)
1348 strcat(tbuffer, " -nowrite");
1349 if (mrafsParm.Optforce)
1350 strcat(tbuffer, " -force");
1351 if (mrafsParm.Optoktozap)
1352 strcat(tbuffer, " -oktozap");
1353 if (mrafsParm.Optrootfiles)
1354 strcat(tbuffer, " -rootfiles");
1355 if (mrafsParm.Optsalvagedirs)
1356 strcat(tbuffer, " -salvagedirs");
1357 if (mrafsParm.Optblockreads)
1358 strcat(tbuffer, " -blockreads");
1359 if (mrafsParm.OptListResidencies)
1360 strcat(tbuffer, " -ListResidencies");
1361 if (mrafsParm.OptSalvageRemote)
1362 strcat(tbuffer, " -SalvageRemote");
1363 if (mrafsParm.OptSalvageArchival)
1364 strcat(tbuffer, " -SalvageArchival");
1365 if (mrafsParm.OptIgnoreCheck)
1366 strcat(tbuffer, " -IgnoreCheck");
1367 if (mrafsParm.OptForceOnLine)
1368 strcat(tbuffer, " -ForceOnLine");
1369 if (mrafsParm.OptUseRootDirACL)
1370 strcat(tbuffer, " -UseRootDirACL");
1371 if (mrafsParm.OptTraceBadLinkCounts)
1372 strcat(tbuffer, " -TraceBadLinkCounts");
1373 if (mrafsParm.OptDontAskFS)
1374 strcat(tbuffer, " -DontAskFS");
1375 if (mrafsParm.OptLogLevel) {
1376 sprintf(pbuffer, " -LogLevel %ld", mrafsParm.OptLogLevel);
1377 strcat(tbuffer, pbuffer);
1379 if (mrafsParm.OptRxDebug)
1380 strcat(tbuffer, " -rxdebug");
1381 if (mrafsParm.OptResidencies) {
1382 sprintf(pbuffer, " -Residencies %lu", mrafsParm.OptResidencies);
1383 strcat(tbuffer, pbuffer);
1387 parms[1] = "now"; /* when to do it */
1389 BOZO_CreateBnode(aconn, "cron", "salvage-tmp", parms[0], parms[1],
1390 parms[2], parms[3], parms[4], notifier);
1392 printf("bos: failed to start 'salvager' (%s)\n", em(code));
1395 /* now wait for bnode to disappear */
1399 code = BOZO_GetInstanceInfo(aconn, "salvage-tmp", &tp, &istatus);
1402 printf("bos: waiting for salvage to complete.\n");
1404 if (code != BZNOENT) {
1405 printf("bos: salvage failed (%s)\n", em(code));
1410 /* now print the log file to the output file */
1411 printf("bos: salvage completed\n");
1412 if (aoutName || showlog) {
1413 fprintf(outFile, "SalvageLog:\n");
1414 tcall = rx_NewCall(aconn);
1415 /* MUST pass canonical (wire-format) salvager log path to bosserver */
1417 StartBOZO_GetLog(tcall, AFSDIR_CANONICAL_SERVER_SLVGLOG_FILEPATH);
1419 rx_EndCall(tcall, code);
1424 code = rx_Read(tcall, &buffer, 1);
1427 putc(buffer, outFile);
1429 break; /* the end delimeter */
1431 code = rx_EndCall(tcall, 0);
1432 /* fall through into cleanup code */
1436 if (closeIt && outFile)
1443 register struct cmd_syndesc *as;
1445 struct rx_connection *tconn;
1446 register struct rx_call *tcall;
1447 register afs_int32 code;
1451 printf("Fetching log file '%s'...\n", as->parms[1].items->data);
1452 tconn = GetConn(as, 0);
1453 tcall = rx_NewCall(tconn);
1454 code = StartBOZO_GetLog(tcall, as->parms[1].items->data);
1456 rx_EndCall(tcall, code);
1462 code = rx_Read(tcall, &buffer, 1);
1468 break; /* the end delimeter */
1471 code = rx_EndCall(tcall, error);
1472 /* fall through into cleanup code */
1476 com_err("bos", code, "(while reading log)");
1482 struct cmd_syndesc *as;
1484 register struct rx_connection *tconn;
1485 register afs_int32 code, rc, i;
1487 char tname[BOZO_BSSIZE];
1489 extern struct ubik_client *cstruct;
1490 afs_int32 curGoal, showlog = 0, mrafs = 0;
1496 memset(&mrafsParm, 0, sizeof(mrafsParm));
1498 /* parm 0 is machine name, 1 is partition, 2 is volume, 3 is -all flag */
1499 tconn = GetConn(as, 0);
1501 /* Find out whether fileserver is running MR-AFS (has a scanner instance) */
1502 /* XXX this should really be done some other way, potentially by RPC */
1504 if (code = BOZO_GetInstanceParm(tconn, "fs", 3, &tp) == 0)
1507 /* we can do a volume, a partition or the whole thing, but not mixtures
1509 if (!as->parms[1].items && as->parms[2].items) {
1510 printf("bos: must specify partition to salvage individual volume.\n");
1513 if (as->parms[5].items && as->parms[3].items) {
1514 printf("bos: can not specify both -file and -showlog.\n");
1517 if (as->parms[4].items && (as->parms[1].items || as->parms[2].items)) {
1518 printf("bos: can not specify -all with other flags.\n");
1522 /* get the output file name, if any */
1523 if (as->parms[3].items)
1524 outName = as->parms[3].items->data;
1528 if (as->parms[5].items)
1531 /* parallel option */
1533 if (as->parms[6].items)
1534 parallel = as->parms[6].items->data;
1536 /* get the tmpdir filename if any */
1538 if (as->parms[7].items)
1539 tmpDir = as->parms[7].items->data;
1541 /* -orphans option */
1543 if (as->parms[8].items) {
1545 printf("Can't specify -orphans for MR-AFS fileserver\n");
1548 orphans = as->parms[8].items->data;
1552 if (as->parms[MRAFS_OFFSET].items)
1553 mrafsParm.Optdebug = 1;
1554 if (as->parms[MRAFS_OFFSET + 1].items)
1555 mrafsParm.Optnowrite = 1;
1556 if (as->parms[MRAFS_OFFSET + 2].items)
1557 mrafsParm.Optforce = 1;
1558 if (as->parms[MRAFS_OFFSET + 3].items)
1559 mrafsParm.Optoktozap = 1;
1560 if (as->parms[MRAFS_OFFSET + 4].items)
1561 mrafsParm.Optrootfiles = 1;
1562 if (as->parms[MRAFS_OFFSET + 5].items)
1563 mrafsParm.Optsalvagedirs = 1;
1564 if (as->parms[MRAFS_OFFSET + 6].items)
1565 mrafsParm.Optblockreads = 1;
1566 if (as->parms[MRAFS_OFFSET + 7].items)
1567 mrafsParm.OptListResidencies = 1;
1568 if (as->parms[MRAFS_OFFSET + 8].items)
1569 mrafsParm.OptSalvageRemote = 1;
1570 if (as->parms[MRAFS_OFFSET + 9].items)
1571 mrafsParm.OptSalvageArchival = 1;
1572 if (as->parms[MRAFS_OFFSET + 10].items)
1573 mrafsParm.OptIgnoreCheck = 1;
1574 if (as->parms[MRAFS_OFFSET + 11].items)
1575 mrafsParm.OptForceOnLine = 1;
1576 if (as->parms[MRAFS_OFFSET + 12].items)
1577 mrafsParm.OptUseRootDirACL = 1;
1578 if (as->parms[MRAFS_OFFSET + 13].items)
1579 mrafsParm.OptTraceBadLinkCounts = 1;
1580 if (as->parms[MRAFS_OFFSET + 14].items)
1581 mrafsParm.OptDontAskFS = 1;
1582 if (as->parms[MRAFS_OFFSET + 15].items)
1583 mrafsParm.OptLogLevel =
1584 atoi(as->parms[MRAFS_OFFSET + 15].items->data);
1585 if (as->parms[MRAFS_OFFSET + 16].items)
1586 mrafsParm.OptRxDebug = 1;
1587 if (as->parms[MRAFS_OFFSET + 17].items) {
1588 if (as->parms[MRAFS_OFFSET + 8].items
1589 || as->parms[MRAFS_OFFSET + 9].items) {
1591 ("Can't specify -Residencies with -SalvageRemote or -SalvageArchival\n");
1595 util_GetUInt32(as->parms[MRAFS_OFFSET + 17].items->data,
1596 &mrafsParm.OptResidencies);
1598 printf("bos: '%s' is not a valid residency mask.\n",
1599 as->parms[MRAFS_OFFSET + 13].items->data);
1606 for (i = 9; i < ADDPARMOFFSET; i++) {
1607 if (as->parms[i].items) {
1608 printf(" %s only possible for MR-AFS fileserver.\n",
1617 if (as->parms[4].items) {
1618 /* salvage whole enchilada */
1619 curGoal = GetServerGoal(tconn, "fs");
1620 if (curGoal == BSTAT_NORMAL) {
1621 printf("bos: shutting down fs.\n");
1622 code = BOZO_SetTStatus(tconn, "fs", BSTAT_SHUTDOWN);
1624 printf("bos: failed to stop 'fs' (%s)\n", em(code));
1627 code = BOZO_WaitAll(tconn); /* wait for shutdown to complete */
1630 ("bos: failed to wait for file server shutdown, continuing.\n");
1632 /* now do the salvage operation */
1633 printf("Starting salvage.\n");
1634 rc = DoSalvage(tconn, NULL, NULL, outName, showlog, parallel, tmpDir,
1636 if (curGoal == BSTAT_NORMAL) {
1637 printf("bos: restarting fs.\n");
1638 code = BOZO_SetTStatus(tconn, "fs", BSTAT_NORMAL);
1640 printf("bos: failed to restart 'fs' (%s)\n", em(code));
1646 } else if (!as->parms[2].items) {
1647 if (!as->parms[1].items) {
1649 ("bos: must specify -all switch to salvage all partitions.\n");
1652 if (volutil_GetPartitionID(as->parms[1].items->data) < 0) {
1653 /* can't parse volume ID, so complain before shutting down
1656 printf("bos: can't interpret %s as partition ID.\n",
1657 as->parms[1].items->data);
1660 curGoal = GetServerGoal(tconn, "fs");
1661 /* salvage a whole partition (specified by parms[1]) */
1662 if (curGoal == BSTAT_NORMAL) {
1663 printf("bos: shutting down fs.\n");
1664 code = BOZO_SetTStatus(tconn, "fs", BSTAT_SHUTDOWN);
1666 printf("bos: can't stop 'fs' (%s)\n", em(code));
1669 code = BOZO_WaitAll(tconn); /* wait for shutdown to complete */
1672 ("bos: failed to wait for file server shutdown, continuing.\n");
1674 /* now do the salvage operation */
1675 printf("Starting salvage.\n");
1676 rc = DoSalvage(tconn, as->parms[1].items->data, NULL, outName,
1677 showlog, parallel, tmpDir, orphans);
1678 if (curGoal == BSTAT_NORMAL) {
1679 printf("bos: restarting fs.\n");
1680 code = BOZO_SetTStatus(tconn, "fs", BSTAT_NORMAL);
1682 printf("bos: failed to restart 'fs' (%s)\n", em(code));
1689 /* salvage individual volume (don't shutdown fs first), just use
1690 * single-shot cron bnode. Must leave server running when using this
1691 * option, since salvager will ask file server for the volume */
1694 const char *confdir;
1697 if (as->parms[ADDPARMOFFSET].items)
1698 tmpname = as->parms[ADDPARMOFFSET].items->data;
1702 localauth = (as->parms[ADDPARMOFFSET + 2].items != 0);
1704 (localauth ? AFSDIR_SERVER_ETC_DIRPATH :
1705 AFSDIR_CLIENT_ETC_DIRPATH);
1706 code = vsu_ClientInit( /* noauth */ 1, confdir, tmpname,
1707 /* server auth */ 0, &cstruct, (int (*)())0);
1709 newID = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err);
1711 printf("bos: can't interpret %s as volume name or ID\n",
1712 as->parms[2].items->data);
1715 sprintf(tname, "%u", newID);
1718 ("bos: can't initialize volume system client (code %d), trying anyway.\n",
1720 strncpy(tname, as->parms[2].items->data, sizeof(tname));
1722 if (volutil_GetPartitionID(as->parms[1].items->data) < 0) {
1723 /* can't parse volume ID, so complain before shutting down
1726 printf("bos: can't interpret %s as partition ID.\n",
1727 as->parms[1].items->data);
1730 printf("Starting salvage.\n");
1731 rc = DoSalvage(tconn, as->parms[1].items->data, tname, outName,
1732 showlog, parallel, tmpDir, orphans);
1740 IStatServer(as, int32p)
1742 register struct cmd_syndesc *as;
1744 register struct rx_connection *tconn;
1745 register struct cmd_item *ti;
1748 tconn = GetConn(as, 0);
1749 for (ti = as->parms[1].items; ti; ti = ti->next) {
1750 DoStat(ti->data, tconn, int32p, firstTime);
1757 DoStat(aname, aconn, aint32p, firstTime)
1759 IN register struct rx_connection *aconn;
1761 IN int firstTime; /* true iff first instance in cmd */
1765 register afs_int32 code;
1766 register afs_int32 i;
1767 struct bozo_status istatus;
1769 char *is1, *is2, *is3, *is4; /* instance strings */
1772 code = BOZO_GetInstanceInfo(aconn, aname, &tp, &istatus);
1774 printf("bos: failed to get instance info for '%s' (%s)\n", aname,
1778 if (firstTime && aint32p && (istatus.flags & BOZO_BADDIRACCESS))
1780 ("Bosserver reports inappropriate access on server directories\n");
1781 printf("Instance %s, ", aname);
1783 printf("(type is %s) ", buffer);
1784 if (istatus.fileGoal == istatus.goal) {
1786 printf("disabled, ");
1788 if (istatus.fileGoal)
1789 printf("temporarily disabled, ");
1791 printf("temporarily enabled, ");
1794 if (istatus.flags & BOZO_ERRORSTOP)
1795 printf("stopped for too many errors, ");
1796 if (istatus.flags & BOZO_HASCORE)
1797 printf("has core file, ");
1800 code = BOZO_GetStatus(aconn, aname, &temp, &tp);
1802 printf("bos: failed to get status for instance '%s' (%s)\n", aname,
1805 printf("currently ");
1806 if (temp == BSTAT_NORMAL)
1807 printf("running normally.\n");
1808 else if (temp == BSTAT_SHUTDOWN)
1809 printf("shutdown.\n");
1810 else if (temp == BSTAT_STARTINGUP)
1811 printf("starting up.\n");
1812 else if (temp == BSTAT_SHUTTINGDOWN)
1813 printf("shutting down.\n");
1814 if (buffer[0] != 0) {
1815 printf(" Auxiliary status is: %s.\n", buffer);
1819 /* are we done yet? */
1823 if (istatus.procStartTime)
1824 printf(" Process last started at %s (%d proc starts)\n",
1825 DateOf(istatus.procStartTime), istatus.procStarts);
1826 if (istatus.lastAnyExit) {
1827 printf(" Last exit at %s\n", DateOf(istatus.lastAnyExit));
1829 if (istatus.lastErrorExit) {
1830 is1 = is2 = is3 = is4 = NULL;
1831 printf(" Last error exit at %s, ", DateOf(istatus.lastErrorExit));
1832 code = BOZO_GetInstanceStrings(aconn, aname, &is1, &is2, &is3, &is4);
1833 /* don't complain about failing call, since could simply mean
1834 * interface mismatch.
1838 /* non-null instance string */
1839 printf("by %s, ", is1);
1846 if (istatus.errorSignal) {
1847 if (istatus.errorSignal == SIGTERM)
1848 printf("due to shutdown request\n");
1850 printf("due to signal %d\n", istatus.errorSignal);
1852 printf("by exiting with code %d\n", istatus.errorCode);
1856 /* try to display all the parms */
1859 code = BOZO_GetInstanceParm(aconn, aname, i, &tp);
1862 printf(" Command %d is '%s'\n", i + 1, buffer);
1865 code = BOZO_GetInstanceParm(aconn, aname, 999, &tp);
1867 /* Any type of failure is treated as not having a notifier program */
1868 printf(" Notifier is '%s'\n", buffer);
1875 #ifdef BOS_RESTRICTED_MODE
1878 struct cmd_syndesc *as;
1880 register struct rx_connection *tconn;
1881 afs_int32 code, val;
1883 tconn = GetConn(as, 0);
1884 code = BOZO_GetRestrictedMode(tconn, &val);
1886 printf("bos: failed to get restricted mode (%s)\n", em(code));
1888 printf("Restricted mode is %s\n", val ? "on" : "off");
1895 struct cmd_syndesc *as;
1897 register struct rx_connection *tconn;
1898 afs_int32 code, val;
1900 tconn = GetConn(as, 0);
1901 util_GetInt32(as->parms[1].items->data, &val);
1902 code = BOZO_SetRestrictedMode(tconn, val);
1904 printf("bos: failed to set restricted mode (%s)\n", em(code));
1911 register struct cmd_syndesc *ts;
1913 cmd_Seek(ts, ADDPARMOFFSET);
1914 /* + 0 */ cmd_AddParm(ts, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell name");
1915 /* + 1 */ cmd_AddParm(ts, "-noauth", CMD_FLAG, CMD_OPTIONAL,
1916 "don't authenticate");
1917 /* + 2 */ cmd_AddParm(ts, "-localauth", CMD_FLAG, CMD_OPTIONAL,
1918 "create tickets from KeyFile");
1921 #include "AFS_component_version_number.c"
1927 register afs_int32 code;
1928 register struct cmd_syndesc *ts;
1929 extern int afsconf_SawCell;
1931 #ifdef AFS_AIX32_ENV
1933 * The following signal action for AIX is necessary so that in case of a
1934 * crash (i.e. core is generated) we can include the user's data section
1935 * in the core dump. Unfortunately, by default, only a partial core is
1936 * generated which, in many cases, isn't too useful.
1938 struct sigaction nsa;
1940 sigemptyset(&nsa.sa_mask);
1941 nsa.sa_handler = SIG_DFL;
1942 nsa.sa_flags = SA_FULLDUMP;
1943 sigaction(SIGSEGV, &nsa, NULL);
1944 sigaction(SIGABRT, &nsa, NULL);
1950 printf("bos: could not initialize rx (%s)\n", em(code));
1954 /* To resolve a AFSCELL environment "Note: ..." problem: Because bos calls ka_Init (why?) before any
1955 * checkup on the existance of a "-cell" option on the particular bos command we don't print the
1956 * message if a cell is passed in. Luckily the rest of the programs don't call these adhoc routines
1957 * and things work fine. Note that if the "-cell" isn't passed then we're still ok since later on
1958 * the proper routine (afsconf_GetCellInfo) is going to be called to do the right thing.
1960 afsconf_SawCell = 1; /* Means don't print warning if AFSCELL is set */
1962 afsconf_SawCell = 0; /* Reset it */
1963 /* don't check error code, since fails sometimes when we're setting up a
1965 initialize_CMD_error_table();
1966 initialize_BZ_error_table();
1968 ts = cmd_CreateSyntax("start", StartServer, 0, "start running a server");
1969 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1970 cmd_AddParm(ts, "-instance", CMD_LIST, 0, "server process name");
1973 ts = cmd_CreateSyntax("stop", StopServer, 0, "halt a server instance");
1974 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1975 cmd_AddParm(ts, "-instance", CMD_LIST, 0, "server process name");
1977 cmd_AddParm(ts, "-wait", CMD_FLAG, CMD_OPTIONAL,
1978 "wait for process to stop");
1981 ts = cmd_CreateSyntax("status", StatServer, 0,
1982 "show server instance status");
1983 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1984 cmd_AddParm(ts, "-instance", CMD_LIST, CMD_OPTIONAL,
1985 "server process name");
1986 cmd_AddParm(ts, "-long", CMD_FLAG, CMD_OPTIONAL, "long status");
1989 ts = cmd_CreateSyntax("shutdown", Shutdown, 0, "shutdown all processes");
1990 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1991 cmd_AddParm(ts, "-instance", CMD_LIST, CMD_OPTIONAL, "instances");
1993 cmd_AddParm(ts, "-wait", CMD_FLAG, CMD_OPTIONAL,
1994 "wait for process to stop");
1997 ts = cmd_CreateSyntax("startup", Startup, 0, "start all processes");
1998 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1999 cmd_AddParm(ts, "-instance", CMD_LIST, CMD_OPTIONAL, "instances");
2002 ts = cmd_CreateSyntax("restart", Restart, 0, "restart processes");
2003 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2004 cmd_AddParm(ts, "-instance", CMD_LIST, CMD_OPTIONAL, "instances");
2005 cmd_AddParm(ts, "-bosserver", CMD_FLAG, CMD_OPTIONAL,
2006 "restart bosserver");
2007 cmd_AddParm(ts, "-all", CMD_FLAG, CMD_OPTIONAL, "restart all processes");
2012 ts = cmd_CreateSyntax("create", CreateServer, 0,
2013 "create a new server instance");
2014 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2015 cmd_AddParm(ts, "-instance", CMD_SINGLE, 0, "server process name");
2016 cmd_AddParm(ts, "-type", CMD_SINGLE, 0, "server type");
2017 cmd_AddParm(ts, "-cmd", CMD_LIST, 0, "command lines");
2018 cmd_AddParm(ts, "-notifier", CMD_SINGLE, CMD_OPTIONAL,
2019 "Notifier program");
2022 ts = cmd_CreateSyntax("delete", DeleteServer, 0,
2023 "delete a server instance");
2024 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2025 cmd_AddParm(ts, "-instance", CMD_LIST, 0, "server process name");
2028 ts = cmd_CreateSyntax("adduser", AddSUser, 0,
2029 "add users to super-user list");
2030 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2031 cmd_AddParm(ts, "-user", CMD_LIST, 0, "user names");
2034 ts = cmd_CreateSyntax("removeuser", RemoveSUser, 0,
2035 "remove users from super-user list");
2036 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2037 cmd_AddParm(ts, "-user", CMD_LIST, 0, "user names");
2040 ts = cmd_CreateSyntax("listusers", ListSUsers, 0, "list super-users");
2041 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2044 ts = cmd_CreateSyntax("addkey", AddKey, 0,
2045 "add keys to key dbase (kvno 999 is bcrypt)");
2046 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2047 cmd_AddParm(ts, "-key", CMD_SINGLE, CMD_OPTIONAL, "key");
2048 cmd_AddParm(ts, "-kvno", CMD_SINGLE, 0, "key version number");
2051 ts = cmd_CreateSyntax("removekey", RemoveKey, 0,
2052 "remove keys from key dbase");
2053 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2054 cmd_AddParm(ts, "-kvno", CMD_LIST, 0, "key version number");
2057 ts = cmd_CreateSyntax("listkeys", ListKeys, 0, "list keys");
2058 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2059 cmd_AddParm(ts, "-showkey", CMD_FLAG, CMD_OPTIONAL,
2060 "show the actual key rather than the checksum");
2063 ts = cmd_CreateSyntax("listhosts", ListHosts, 0, "get cell host list");
2064 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2066 cmd_CreateAlias(ts, "getcell");
2068 ts = cmd_CreateSyntax("setcellname", SetCellName, 0, "set cell name");
2069 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2070 cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "cell name");
2073 ts = cmd_CreateSyntax("addhost", AddHost, 0, "add host to cell dbase");
2074 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2075 cmd_AddParm(ts, "-host", CMD_LIST, 0, "host name");
2076 cmd_AddParm(ts, "-clone", CMD_FLAG, CMD_OPTIONAL, "vote doesn't count");
2079 ts = cmd_CreateSyntax("removehost", RemoveHost, 0,
2080 "remove host from cell dbase");
2081 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2082 cmd_AddParm(ts, "-host", CMD_LIST, 0, "host name");
2085 ts = cmd_CreateSyntax("setauth", SetAuth, 0,
2086 "set authentication required flag");
2087 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2088 cmd_AddParm(ts, "-authrequired", CMD_SINGLE, 0,
2089 "on or off: authentication required for admin requests");
2092 ts = cmd_CreateSyntax("install", Install, 0, "install program");
2093 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2094 cmd_AddParm(ts, "-file", CMD_LIST, 0, "files to install");
2095 cmd_AddParm(ts, "-dir", CMD_SINGLE, CMD_OPTIONAL, "destination dir");
2098 ts = cmd_CreateSyntax("uninstall", UnInstall, 0, "uninstall program");
2099 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2100 cmd_AddParm(ts, "-file", CMD_LIST, 0, "files to uninstall");
2101 cmd_AddParm(ts, "-dir", CMD_SINGLE, CMD_OPTIONAL, "destination dir");
2104 ts = cmd_CreateSyntax("getlog", GetLogCmd, 0, "examine log file");
2105 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2106 cmd_AddParm(ts, "-file", CMD_SINGLE, 0, "log file to examine");
2109 ts = cmd_CreateSyntax("getdate", GetDate, 0, "get dates for programs");
2110 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2111 cmd_AddParm(ts, "-file", CMD_LIST, 0, "files to check");
2112 cmd_AddParm(ts, "-dir", CMD_SINGLE, CMD_OPTIONAL, "destination dir");
2115 ts = cmd_CreateSyntax("exec", Exec, 0, "execute shell command on server");
2116 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2117 cmd_AddParm(ts, "-cmd", CMD_SINGLE, 0, "command to execute");
2120 ts = cmd_CreateSyntax("prune", Prune, 0, "prune server files");
2121 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2122 cmd_AddParm(ts, "-bak", CMD_FLAG, CMD_OPTIONAL, "delete .BAK files");
2123 cmd_AddParm(ts, "-old", CMD_FLAG, CMD_OPTIONAL, "delete .OLD files");
2124 cmd_AddParm(ts, "-core", CMD_FLAG, CMD_OPTIONAL, "delete core files");
2125 cmd_AddParm(ts, "-all", CMD_FLAG, CMD_OPTIONAL, "delete all junk files");
2128 ts = cmd_CreateSyntax("setrestart", SetRestartCmd, 0,
2129 "set restart times");
2130 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_REQUIRED, "machine name");
2131 cmd_AddParm(ts, "-time", CMD_SINGLE, CMD_REQUIRED,
2132 "time to restart server");
2133 cmd_AddParm(ts, "-general", CMD_FLAG, CMD_OPTIONAL,
2134 "set general restart time");
2135 cmd_AddParm(ts, "-newbinary", CMD_FLAG, CMD_OPTIONAL,
2136 "set new binary restart time");
2139 ts = cmd_CreateSyntax("getrestart", GetRestartCmd, 0,
2140 "get restart times");
2141 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_REQUIRED, "machine name");
2144 ts = cmd_CreateSyntax("salvage", SalvageCmd, 0,
2145 "salvage partition or volumes");
2146 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2147 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL,
2148 "salvage partition");
2149 cmd_AddParm(ts, "-volume", CMD_SINGLE, CMD_OPTIONAL,
2150 "salvage volume number or volume name");
2151 cmd_AddParm(ts, "-file", CMD_SINGLE, CMD_OPTIONAL,
2152 "salvage log output file");
2153 cmd_AddParm(ts, "-all", CMD_FLAG, CMD_OPTIONAL, "salvage whole server");
2154 cmd_AddParm(ts, "-showlog", CMD_FLAG, CMD_OPTIONAL,
2155 "display salvage log");
2156 cmd_AddParm(ts, "-parallel", CMD_SINGLE, CMD_OPTIONAL,
2157 "# of max parallel partition salvaging");
2158 cmd_AddParm(ts, "-tmpdir", CMD_SINGLE, CMD_OPTIONAL,
2159 "directory to place tmp files");
2160 cmd_AddParm(ts, "-orphans", CMD_SINGLE, CMD_OPTIONAL,
2161 "ignore | remove | attach");
2162 cmd_AddParm(ts, "-debug", CMD_FLAG, CMD_OPTIONAL,
2163 "(MR-AFS) Run in Debugging mode");
2164 cmd_AddParm(ts, "-nowrite", CMD_FLAG, CMD_OPTIONAL,
2165 "(MR-AFS) Run readonly/test mode");
2166 cmd_AddParm(ts, "-force", CMD_FLAG, CMD_OPTIONAL,
2167 "(MR-AFS) Force full salvaging");
2168 cmd_AddParm(ts, "-oktozap", CMD_FLAG, CMD_OPTIONAL,
2169 "(MR-AFS) Give permission to destroy bogus file residencies/volumes - debugging flag");
2170 cmd_AddParm(ts, "-rootfiles", CMD_FLAG, CMD_OPTIONAL,
2171 "(MR-AFS) Show files owned by root - debugging flag");
2172 cmd_AddParm(ts, "-salvagedirs", CMD_FLAG, CMD_OPTIONAL,
2173 "(MR-AFS) Force rebuild/salvage of all directories");
2174 cmd_AddParm(ts, "-blockreads", CMD_FLAG, CMD_OPTIONAL,
2175 "(MR-AFS) Read smaller blocks to handle IO/bad blocks");
2176 cmd_AddParm(ts, "-ListResidencies", CMD_FLAG, CMD_OPTIONAL,
2177 "(MR-AFS) Just list affected file residencies - debugging flag");
2178 cmd_AddParm(ts, "-SalvageRemote", CMD_FLAG, CMD_OPTIONAL,
2179 "(MR-AFS) Salvage storage systems that are not directly attached");
2180 cmd_AddParm(ts, "-SalvageArchival", CMD_FLAG, CMD_OPTIONAL,
2181 "(MR-AFS) Salvage HSM storage systems");
2182 cmd_AddParm(ts, "-IgnoreCheck", CMD_FLAG, CMD_OPTIONAL,
2183 "(MR-AFS) Don't perform VLDB safety check when deleting unreferenced files. Only a good idea in single server cell.");
2184 cmd_AddParm(ts, "-ForceOnLine", CMD_FLAG, CMD_OPTIONAL,
2185 "(MR-AFS) Force the volume to come online, even if it hasn't salvaged cleanly.");
2186 cmd_AddParm(ts, "-UseRootDirACL", CMD_FLAG, CMD_OPTIONAL,
2187 "(MR-AFS) Use the root directory ACL for lost+found directory if it is created.");
2188 cmd_AddParm(ts, "-TraceBadLinkCounts", CMD_FLAG, CMD_OPTIONAL,
2189 "(MR-AFS) Print out lines about volume reference count changes.");
2190 cmd_AddParm(ts, "-DontAskFS", CMD_FLAG, CMD_OPTIONAL,
2191 "(MR-AFS) Don't ask fileserver to take volume offline. THIS IS VERY DANGEROUS.");
2192 cmd_AddParm(ts, "-LogLevel", CMD_SINGLE, CMD_OPTIONAL,
2193 "(MR-AFS) log level");
2194 cmd_AddParm(ts, "-rxdebug", CMD_FLAG, CMD_OPTIONAL,
2195 "(MR-AFS) Write out rx debug information.");
2196 cmd_AddParm(ts, "-Residencies", CMD_SINGLE, CMD_OPTIONAL,
2197 "(MR-AFS) Numeric mask of residencies to be included in the salvage. Do not use with -SalvageRemote or -SalvageArchival");
2200 ts = cmd_CreateSyntax("blockscanner", BlockScannerCmd, 0,
2201 "block scanner daemon from making migration requests");
2202 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_REQUIRED, "machine name");
2205 ts = cmd_CreateSyntax("unblockscanner", UnBlockScannerCmd, 0,
2206 "allow scanner daemon to make migration requests again");
2207 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_REQUIRED, "machine name");
2210 #ifdef BOS_RESTRICTED_MODE
2211 ts = cmd_CreateSyntax("getrestricted", GetRestrict, 0,
2212 "get restrict mode");
2213 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2216 ts = cmd_CreateSyntax("setrestricted", SetRestrict, 0,
2217 "set restrict mode");
2218 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2219 cmd_AddParm(ts, "-mode", CMD_SINGLE, 0, "mode to set");
2224 code = cmd_Dispatch(argc, argv);