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>
55 #define MRAFS_OFFSET 9
56 #define ADDPARMOFFSET 26
58 static struct SalvageParms {
63 afs_int32 Optrootfiles;
64 afs_int32 Optsalvagedirs;
65 afs_int32 Optblockreads;
66 afs_int32 OptListResidencies;
67 afs_int32 OptSalvageRemote;
68 afs_int32 OptSalvageArchival;
69 afs_int32 OptIgnoreCheck;
70 afs_int32 OptForceOnLine;
71 afs_int32 OptUseRootDirACL;
72 afs_int32 OptTraceBadLinkCounts;
73 afs_int32 OptDontAskFS;
74 afs_int32 OptLogLevel;
76 afs_uint32 OptResidencies;
79 /* dummy routine for the audit work. It should do nothing since audits */
80 /* occur at the server level and bos is not a server. */
86 /* keep those lines small */
92 return "communications failure (-1)";
94 return "communications timeout (-3)";
96 return (char *)error_message(acode);
99 /* get partition id from a name */
101 GetPartitionID(aname)
109 return -1; /* unknown */
110 /* numbers go straight through */
111 if (tc >= '0' && tc <= '9') {
114 /* otherwise check for vicepa or /vicepa, or just plain "a" */
116 if (strlen(aname) <= 2) {
117 strcpy(ascii, aname);
118 } else if (!strncmp(aname, "/vicep", 6)) {
119 strncpy(ascii, aname + 6, 2);
120 } else if (!strncmp(aname, "vicep", 5)) {
121 strncpy(ascii, aname + 5, 2);
123 return -1; /* bad partition name */
124 /* now partitions are named /vicepa ... /vicepz, /vicepaa, /vicepab,
125 * .../vicepzz, and are numbered from 0. Do the appropriate conversion */
127 /* one char name, 0..25 */
128 if (ascii[0] < 'a' || ascii[0] > 'z')
129 return -1; /* wrongo */
130 return ascii[0] - 'a';
132 /* two char name, 26 .. <whatever> */
133 if (ascii[0] < 'a' || ascii[0] > 'z')
134 return -1; /* wrongo */
135 if (ascii[1] < 'a' || ascii[1] > 'z')
136 return -1; /* just as bad */
137 return (ascii[0] - 'a') * 26 + (ascii[1] - 'a') + 26;
141 /* make ctime easier to use */
146 static char tbuffer[30];
148 time_t t = (time_t) atime;
152 tbuffer[24] = 0; /* get rid of new line */
154 strcpy(tbuffer, "BAD TIME");
158 /* global stuff from main for communicating with GetConn */
159 static struct rx_securityClass *sc[3];
162 /* use the syntax descr to get a connection, authenticated appropriately.
163 * aencrypt is set if we want to encrypt the data on the wire.
165 static struct rx_connection *
166 GetConn(as, aencrypt)
168 struct cmd_syndesc *as;
172 register afs_int32 code;
173 register struct rx_connection *tconn;
175 register struct afsconf_dir *tdir;
177 struct ktc_principal sname;
178 struct ktc_token ttoken;
182 hostname = as->parms[0].items->data;
183 th = hostutil_GetHostByName(hostname);
185 printf("bos: can't find address for host '%s'\n", hostname);
188 memcpy(&addr, th->h_addr, sizeof(afs_int32));
190 /* get tokens for making authenticated connections */
191 localauth = (as->parms[ADDPARMOFFSET + 2].items != 0);
193 (localauth ? AFSDIR_SERVER_ETC_DIRPATH : AFSDIR_CLIENT_ETC_DIRPATH);
194 tdir = afsconf_Open(confdir);
196 struct afsconf_cell info;
199 if (as->parms[ADDPARMOFFSET].items)
200 tname = as->parms[ADDPARMOFFSET].items->data;
203 /* next call expands cell name abbrevs for us and handles looking up
205 code = afsconf_GetCellInfo(tdir, tname, NULL, &info);
207 com_err("bos", code, "(can't find cell '%s' in cell database)",
208 (tname ? tname : "<default>"));
211 strcpy(sname.cell, info.name);
213 printf("bos: can't open cell database (%s)\n", confdir);
216 sname.instance[0] = 0;
217 strcpy(sname.name, "afs");
218 sc[0] = rxnull_NewClientSecurityObject();
223 if (!as->parms[ADDPARMOFFSET + 1].items) { /* not -noauth */
224 if (as->parms[ADDPARMOFFSET + 2].items) { /* -localauth */
225 code = afsconf_GetLatestKey(tdir, 0, 0);
227 com_err("bos", code, "(getting key from local KeyFile)");
230 code = afsconf_ClientAuthSecure(tdir, &sc[2], &scIndex);
232 code = afsconf_ClientAuth(tdir, &sc[2], &scIndex);
234 com_err("bos", code, "(calling ClientAuth)");
235 else if (scIndex != 2) /* this shouldn't happen */
238 } else { /* not -localauth, check for tickets */
239 code = ktc_GetToken(&sname, &ttoken, sizeof(ttoken), NULL);
241 /* have tickets, will travel */
242 if (ttoken.kvno >= 0 && ttoken.kvno <= 255);
245 "bos: funny kvno (%d) in ticket, proceeding\n",
250 encryptLevel = rxkad_crypt;
252 encryptLevel = rxkad_clear;
253 sc[2] = (struct rx_securityClass *)
254 rxkad_NewClientSecurityObject(encryptLevel,
261 com_err("bos", code, "(getting tickets)");
263 if ((scIndex == 0) || (sc[scIndex] == 0)) {
264 fprintf(stderr, "bos: running unauthenticated\n");
269 rx_NewConnection(addr, htons(AFSCONF_NANNYPORT), 1, sc[scIndex],
272 fprintf(stderr, "bos: could not create rx connection\n");
275 rxs_Release(sc[scIndex]);
282 struct cmd_syndesc *as;
284 register afs_int32 code;
285 register struct rx_connection *tconn;
289 tconn = GetConn(as, 0);
290 tp = as->parms[1].items->data;
291 if (strcmp(tp, "on") == 0)
292 flag = 0; /* auth req.: noauthflag is false */
293 else if (strcmp(tp, "off") == 0)
297 ("bos: illegal authentication specifier '%s', must be 'off' or 'on'.\n",
301 code = BOZO_SetNoAuthFlag(tconn, flag);
303 com_err("bos", code, "(failed to set authentication flag)");
307 /* take a name (e.g. foo/bar, and a dir e.g. /usr/afs/bin, and construct
308 * /usr/afs/bin/bar */
310 ComputeDestDir(aname, adir, aresult, alen)
311 char *aname, *adir, *aresult;
316 strcpy(aresult, adir);
317 tp = strrchr(aname, '/');
320 strcat(aresult, "/");
321 strcat(aresult, aname);
323 /* tp points at the / character */
329 /* copy data from fd afd to rx call acall */
331 CopyBytes(afd, acall)
333 register struct rx_call *acall;
335 register afs_int32 code;
336 register afs_int32 len;
340 len = read(afd, tbuffer, sizeof(tbuffer));
344 return 0; /* all done */
345 code = rx_Write(acall, tbuffer, len);
353 register struct cmd_syndesc *as;
355 register afs_int32 code;
356 register struct rx_connection *tconn;
357 register afs_int32 flags;
359 tconn = GetConn(as, 0);
361 if (as->parms[1].items)
362 flags |= BOZO_PRUNEBAK;
363 if (as->parms[2].items)
364 flags |= BOZO_PRUNEOLD;
365 if (as->parms[3].items)
366 flags |= BOZO_PRUNECORE;
367 if (as->parms[4].items)
369 code = BOZO_Prune(tconn, flags);
371 com_err("bos", code, "(failed to prune server files)");
377 register struct cmd_syndesc *as;
379 register struct rx_connection *tconn;
380 register afs_int32 code;
382 tconn = GetConn(as, 0);
383 code = BOZO_Exec(tconn, as->parms[1].items->data);
385 printf("bos: failed to execute command (%s)\n", em(code));
391 register struct cmd_syndesc *as;
393 register afs_int32 code;
396 afs_int32 time, bakTime, oldTime;
397 register struct rx_connection *tconn;
398 register struct cmd_item *ti;
400 tconn = GetConn(as, 0);
401 if (!as->parms[1].items) {
402 printf("bos: no files to check\n");
406 /* compute dest dir or file; default MUST be canonical form of dir path */
407 if (as->parms[2].items)
408 strcpy(destDir, as->parms[2].items->data);
410 strcpy(destDir, AFSDIR_CANONICAL_SERVER_BIN_DIRPATH);
412 for (ti = as->parms[1].items; ti; ti = ti->next) {
413 /* check date for each file */
414 ComputeDestDir(ti->data, destDir, tbuffer, sizeof(tbuffer));
415 code = BOZO_GetDates(tconn, tbuffer, &time, &bakTime, &oldTime);
417 printf("bos: failed to check date on %s (%s)\n", ti->data,
421 printf("File %s ", tbuffer);
423 printf("does not exist, ");
425 printf("dated %s, ", DateOf(time));
427 printf("no .BAK file, ");
429 printf(".BAK file dated %s, ", DateOf(bakTime));
431 printf("no .OLD file.");
433 printf(".OLD file dated %s.", DateOf(oldTime));
442 register struct cmd_syndesc *as;
444 register afs_int32 code;
447 register struct cmd_item *ti;
448 register struct rx_connection *tconn;
450 tconn = GetConn(as, 0);
451 if (!as->parms[1].items) {
452 printf("bos: no files to uninstall\n");
456 /* compute dest dir or file; default MUST be canonical form of dir path */
457 if (as->parms[2].items)
458 strcpy(destDir, as->parms[2].items->data);
460 strcpy(destDir, AFSDIR_CANONICAL_SERVER_BIN_DIRPATH);
462 for (ti = as->parms[1].items; ti; ti = ti->next) {
463 /* uninstall each file */
464 ComputeDestDir(ti->data, destDir, tbuffer, sizeof(tbuffer));
465 code = BOZO_UnInstall(tconn, tbuffer);
467 printf("bos: failed to uninstall %s (%s)\n", ti->data, em(code));
470 printf("bos: uninstalled file %s\n", ti->data);
476 GetServerGoal(aconn, aname)
478 struct rx_connection *aconn;
482 register afs_int32 code;
483 struct bozo_status istatus;
486 code = BOZO_GetInstanceInfo(aconn, aname, &tp, &istatus);
488 printf("bos: failed to get instance info for '%s' (%s)\n", aname,
490 /* if we can't get the answer, assume its running */
493 if (istatus.goal == 0)
494 return BSTAT_SHUTDOWN;
501 struct cmd_syndesc *as;
503 struct rx_connection *tconn;
504 register afs_int32 code;
505 register struct cmd_item *ti;
509 struct rx_call *tcall;
512 tconn = GetConn(as, 0);
513 if (!as->parms[1].items) {
514 printf("bos: no files to install\n");
518 /* compute dest dir or file; default MUST be canonical form of dir path */
519 if (as->parms[2].items)
520 strcpy(destDir, as->parms[2].items->data);
522 strcpy(destDir, AFSDIR_CANONICAL_SERVER_BIN_DIRPATH);
524 for (ti = as->parms[1].items; ti; ti = ti->next) {
525 /* install each file */
526 fd = open(ti->data, O_RDONLY);
528 /* better to quit on error than continue for install command */
529 printf("bos: can't find file '%s', quitting\n", ti->data);
532 code = fstat(fd, &tstat);
534 printf("bos: failed to stat file %s, errno is %d\n", ti->data,
538 /* compute destination dir */
539 ComputeDestDir(ti->data, destDir, tbuffer, sizeof(tbuffer));
540 tcall = rx_NewCall(tconn);
542 StartBOZO_Install(tcall, tbuffer, tstat.st_size,
543 (afs_int32) tstat.st_mode, tstat.st_mtime);
545 code = CopyBytes(fd, tcall);
547 code = rx_EndCall(tcall, code);
549 printf("bos: failed to install %s (%s)\n", ti->data, em(code));
552 printf("bos: installed file %s\n", ti->data);
559 struct cmd_syndesc *as;
561 register struct rx_connection *tconn;
562 register afs_int32 code;
563 register struct cmd_item *ti;
565 tconn = GetConn(as, 0);
566 if (as->parms[1].items == 0) {
567 code = BOZO_ShutdownAll(tconn);
569 printf("bos: failed to shutdown servers (%s)\n", em(code));
571 for (ti = as->parms[1].items; ti; ti = ti->next) {
572 code = BOZO_SetTStatus(tconn, ti->data, BSTAT_SHUTDOWN);
574 printf("bos: failed to shutdown instance %s (%s)\n", ti->data,
578 if (as->parms[8].items) {
579 code = BOZO_WaitAll(tconn);
581 printf("bos: can't wait for processes to shutdown (%s)\n",
588 BlockScannerCmd(as, arock)
589 struct cmd_syndesc *as;
592 register afs_int32 code;
593 struct rx_connection *tconn;
594 char BlockCommand[] = "/usr/afs/bin/scanner -block";
596 tconn = GetConn(as, 0);
597 code = BOZO_Exec(tconn, BlockCommand);
600 ("bos: failed to block scanner from making migration requests (%s)\n",
606 UnBlockScannerCmd(as, arock)
607 struct cmd_syndesc *as;
610 register afs_int32 code;
611 struct rx_connection *tconn;
612 char UnBlockCommand[] = "/usr/afs/bin/scanner -unblock";
614 tconn = GetConn(as, 0);
615 code = BOZO_Exec(tconn, UnBlockCommand);
618 ("bos: failed to allow scanner daemon to make migration requests again (%s)\n",
624 GetRestartCmd(as, arock)
625 struct cmd_syndesc *as;
628 register afs_int32 code;
629 struct ktime generalTime, newBinaryTime;
630 char messageBuffer[256];
631 struct rx_connection *tconn;
634 hostp = as->parms[0].items->data; /* host name for messages */
635 tconn = GetConn(as, 0);
637 code = BOZO_GetRestartTime(tconn, 1, &generalTime);
639 printf("bos: failed to retrieve restart information (%s)\n",
643 code = BOZO_GetRestartTime(tconn, 2, &newBinaryTime);
645 printf("bos: failed to retrieve restart information (%s)\n",
650 code = ktime_DisplayString(&generalTime, messageBuffer);
652 printf("bos: failed to decode restart time (%s)\n", em(code));
655 printf("Server %s restarts %s\n", hostp, messageBuffer);
657 code = ktime_DisplayString(&newBinaryTime, messageBuffer);
659 printf("bos: failed to decode restart time (%s)\n", em(code));
662 printf("Server %s restarts for new binaries %s\n", hostp, messageBuffer);
669 SetRestartCmd(as, arock)
670 struct cmd_syndesc *as;
674 register afs_int32 code;
675 struct ktime restartTime;
677 struct rx_connection *tconn;
680 tconn = GetConn(as, 0);
681 if (as->parms[2].items) {
685 if (as->parms[3].items) {
690 printf("bos: can't specify more than one restart time at a time\n");
694 type = 1; /* by default set general restart time */
696 if (code = ktime_ParsePeriodic(as->parms[1].items->data, &restartTime)) {
697 printf("bos: failed to parse '%s' as periodic restart time(%s)\n",
698 as->parms[1].items->data, em(code));
702 code = BOZO_SetRestartTime(tconn, type, &restartTime);
704 printf("bos: failed to set restart time at server (%s)\n", em(code));
712 struct cmd_syndesc *as;
714 register struct rx_connection *tconn;
715 register afs_int32 code;
716 register struct cmd_item *ti;
718 tconn = GetConn(as, 0);
719 if (as->parms[1].items == 0) {
720 code = BOZO_StartupAll(tconn);
722 printf("bos: failed to startup servers (%s)\n", em(code));
724 for (ti = as->parms[1].items; ti; ti = ti->next) {
725 code = BOZO_SetTStatus(tconn, ti->data, BSTAT_NORMAL);
727 printf("bos: failed to start instance %s (%s)\n", ti->data,
736 struct cmd_syndesc *as;
738 register struct rx_connection *tconn;
739 register afs_int32 code;
740 register struct cmd_item *ti;
742 tconn = GetConn(as, 0);
743 if (as->parms[2].items) {
744 /* this is really a rebozo command */
745 if (as->parms[1].items) {
746 /* specified specific things to restart, can't do this at the same
749 ("bos: can't specify both '-bos' and specific servers to restart.\n");
752 /* otherwise do a rebozo */
753 code = BOZO_ReBozo(tconn);
755 printf("bos: failed to restart bosserver (%s)\n", em(code));
758 if (as->parms[1].items == 0) {
759 if (as->parms[3].items) { /* '-all' */
760 code = BOZO_RestartAll(tconn);
762 printf("bos: failed to restart servers (%s)\n", em(code));
764 printf("bos: To restart all processes please specify '-all'\n");
766 if (as->parms[3].items) {
767 printf("bos: Can't use '-all' along with individual instances\n");
769 for (ti = as->parms[1].items; ti; ti = ti->next) {
770 code = BOZO_Restart(tconn, ti->data);
772 printf("bos: failed to restart instance %s (%s)\n",
782 struct cmd_syndesc *as;
784 register struct rx_connection *tconn;
785 register afs_int32 code;
787 tconn = GetConn(as, 0);
788 code = BOZO_SetCellName(tconn, as->parms[1].items->data);
790 printf("bos: failed to set cell (%s)\n", em(code));
796 register struct cmd_syndesc *as;
798 register struct rx_connection *tconn;
799 register afs_int32 code;
800 register struct cmd_item *ti;
801 char name[MAXHOSTCHARS];
803 tconn = GetConn(as, 0);
804 for (ti = as->parms[1].items; ti; ti = ti->next) {
805 if (as->parms[2].items) {
806 if (strlen(ti->data) > MAXHOSTCHARS - 3) {
807 fprintf(stderr, "bos: host name too long\n");
811 strcpy(&name[1], ti->data);
812 strcat((char *)&name, "]");
813 code = BOZO_AddCellHost(tconn, name);
815 code = BOZO_AddCellHost(tconn, ti->data);
817 printf("bos: failed to add host %s (%s)\n", ti->data, em(code));
824 register struct cmd_syndesc *as;
826 register struct rx_connection *tconn;
827 register afs_int32 code;
828 register struct cmd_item *ti;
830 tconn = GetConn(as, 0);
831 for (ti = as->parms[1].items; ti; ti = ti->next) {
832 code = BOZO_DeleteCellHost(tconn, ti->data);
834 printf("bos: failed to delete host %s (%s)\n", ti->data,
842 register struct cmd_syndesc *as;
844 register struct rx_connection *tconn;
845 register afs_int32 code;
848 register afs_int32 i;
851 tconn = GetConn(as, 0);
852 code = BOZO_GetCellName(tconn, &tp);
854 printf("bos: failed to get cell name (%s)\n", em(code));
857 printf("Cell name is %s\n", tbuffer);
859 code = BOZO_GetCellHost(tconn, i, &tp);
863 printf("bos: failed to get cell host %d (%s)\n", i, em(code));
866 printf(" Host %d is %s\n", i + 1, tbuffer);
873 register struct cmd_syndesc *as;
875 register struct rx_connection *tconn;
876 register afs_int32 code;
877 struct ktc_encryptionKey tkey;
880 char cellBuffer[256];
881 char buf[BUFSIZ], ver[BUFSIZ];
883 tconn = GetConn(as, 1);
884 memset(&tkey, 0, sizeof(struct ktc_encryptionKey));
886 if (as->parms[1].items)
887 strcpy(buf, as->parms[1].items->data);
890 code = des_read_pw_string(buf, sizeof(buf), "input key: ", 0);
891 if (code || strlen(buf) == 0) {
892 fprintf(stderr, "Bad key: \n");
895 code = des_read_pw_string(ver, sizeof(ver), "Retype input key: ", 0);
896 if (code || strlen(ver) == 0) {
897 fprintf(stderr, "Bad key: \n");
900 if (strcmp(ver, buf) != 0) {
901 fprintf(stderr, "\nInput key mismatch\n");
907 temp = atoi(as->parms[2].items->data);
911 strcpy((char *)&tkey, as->parms[1].items->data);
913 strcpy((char *)&tkey, buf);
914 } else { /* kerberos key */
915 if (as->parms[ADDPARMOFFSET].items) {
916 strcpy(cellBuffer, as->parms[ADDPARMOFFSET].items->data);
918 /* string to key needs upper-case cell names */
920 /* I don't believe this is true. The string to key function
921 * actually expands the cell name, then LOWER-CASES it. Perhaps it
922 * didn't use to??? */
923 ucstring(cellBuffer, cellBuffer, strlen(cellBuffer));
926 tcell = NULL; /* no cell specified, use current */
928 ka_StringToKey(as->parms[1].items->data, tcell, &tkey);
930 ka_StringToKey(buf, tcell, &tkey);
932 tconn = GetConn(as, 1);
933 code = BOZO_AddKey(tconn, temp, &tkey);
935 printf("bos: failed to set key %d (%s)\n", temp, em(code));
943 register struct cmd_syndesc *as;
945 register struct rx_connection *tconn;
946 register afs_int32 code;
948 register struct cmd_item *ti;
950 tconn = GetConn(as, 0);
951 for (ti = as->parms[1].items; ti; ti = ti->next) {
952 temp = atoi(ti->data);
953 code = BOZO_DeleteKey(tconn, temp);
955 printf("bos: failed to delete key %d (%s)\n", temp, em(code));
964 IN register struct cmd_syndesc *as;
966 register struct rx_connection *tconn;
967 register afs_int32 code;
968 struct ktc_encryptionKey tkey;
970 struct bozo_keyInfo keyInfo;
972 register afs_int32 i;
974 tconn = GetConn(as, 1);
977 code = BOZO_ListKeys(tconn, i, &kvno, &tkey, &keyInfo);
981 /* first check if key is returned */
982 if ((!ka_KeyIsZero(&tkey, sizeof(tkey))) && (as->parms[1].items)) {
983 printf("key %d is '", kvno);
984 ka_PrintBytes(&tkey, sizeof(tkey));
987 if (keyInfo.keyCheckSum == 0) /* shouldn't happen */
988 printf("key version is %d\n", kvno);
990 printf("key %d has cksum %u\n", kvno, keyInfo.keyCheckSum);
994 printf("Keys last changed on %s.\n", DateOf(keyInfo.mod_sec));
997 printf("bos: %s error encountered while listing keys\n", em(code));
999 printf("All done.\n");
1005 register struct cmd_syndesc *as;
1007 register struct rx_connection *tconn;
1008 register afs_int32 code;
1010 register struct cmd_item *ti;
1013 tconn = GetConn(as, 0);
1014 for (ti = as->parms[1].items; ti; ti = ti->next) {
1015 code = BOZO_AddSUser(tconn, ti->data);
1017 printf("bos: failed to add user '%s' (%s)\n", ti->data, em(code));
1026 register struct cmd_syndesc *as;
1028 register struct rx_connection *tconn;
1029 register struct cmd_item *ti;
1030 register afs_int32 code;
1034 tconn = GetConn(as, 0);
1035 for (ti = as->parms[1].items; ti; ti = ti->next) {
1036 code = BOZO_DeleteSUser(tconn, ti->data);
1038 printf("bos: failed to delete user '%s', ", ti->data);
1040 printf("(no such user)\n");
1042 printf("(%s)\n", em(code));
1049 #define NPERLINE 10 /* dudes to print per line */
1052 register struct cmd_syndesc *as;
1054 register struct rx_connection *tconn;
1056 register afs_int32 code;
1059 int lastNL, printGreeting;
1061 tconn = GetConn(as, 0);
1066 code = BOZO_ListSUsers(tconn, i, &tp);
1069 if (printGreeting) {
1070 printGreeting = 0; /* delay until after first call succeeds */
1071 printf("SUsers are: ");
1073 printf("%s ", tbuffer);
1074 if ((i % NPERLINE) == NPERLINE - 1) {
1081 /* a real error code, instead of scanned past end */
1082 printf("bos: failed to retrieve super-user list (%s)\n", em(code));
1092 register struct cmd_syndesc *as;
1094 register struct rx_connection *tconn;
1095 register afs_int32 code;
1097 char ibuffer[BOZO_BSSIZE];
1101 /* int32p==1 is obsolete, smaller, printout */
1102 int32p = (as->parms[2].items != 0 ? 2 : 0);
1104 /* no parms does something pretty different */
1105 if (as->parms[1].items)
1106 return IStatServer(as, int32p);
1108 tconn = GetConn(as, 0);
1110 /* for each instance */
1112 code = BOZO_EnumerateInstance(tconn, i, &tp);
1116 printf("bos: failed to contact host's bosserver (%s).\n",
1120 DoStat(ibuffer, tconn, int32p, (i == 0)); /* print status line */
1127 register struct cmd_syndesc *as;
1129 register struct rx_connection *tconn;
1130 register afs_int32 code;
1132 register struct cmd_item *ti;
1134 char *type, *name, *notifier = NONOTIFIER;
1136 tconn = GetConn(as, 0);
1137 for (i = 0; i < 6; i++)
1139 for (i = 0, ti = as->parms[3].items; (ti && i < 6); ti = ti->next, i++) {
1140 parms[i] = ti->data;
1142 name = as->parms[1].items->data;
1143 type = as->parms[2].items->data;
1144 if (ti = as->parms[4].items) {
1145 notifier = ti->data;
1148 BOZO_CreateBnode(tconn, type, name, parms[0], parms[1], parms[2],
1149 parms[3], parms[4], notifier);
1152 ("bos: failed to create new server instance %s of type '%s' (%s)\n",
1153 name, type, em(code));
1160 register struct cmd_syndesc *as;
1162 register struct rx_connection *tconn;
1163 register afs_int32 code;
1164 register struct cmd_item *ti;
1167 tconn = GetConn(as, 0);
1168 for (ti = as->parms[1].items; ti; ti = ti->next) {
1169 code = BOZO_DeleteBnode(tconn, ti->data);
1172 printf("bos: can't delete running instance '%s'\n", ti->data);
1174 printf("bos: failed to delete instance '%s' (%s)\n", ti->data,
1183 register struct cmd_syndesc *as;
1185 register struct rx_connection *tconn;
1186 register afs_int32 code;
1187 register struct cmd_item *ti;
1190 tconn = GetConn(as, 0);
1191 for (ti = as->parms[1].items; ti; ti = ti->next) {
1192 code = BOZO_SetStatus(tconn, ti->data, BSTAT_NORMAL);
1194 printf("bos: failed to start instance '%s' (%s)\n", ti->data,
1202 register struct cmd_syndesc *as;
1204 register struct rx_connection *tconn;
1205 register afs_int32 code;
1206 register struct cmd_item *ti;
1209 tconn = GetConn(as, 0);
1210 for (ti = as->parms[1].items; ti; ti = ti->next) {
1211 code = BOZO_SetStatus(tconn, ti->data, BSTAT_SHUTDOWN);
1213 printf("bos: failed to change stop instance '%s' (%s)\n",
1214 ti->data, em(code));
1216 if (as->parms[8].items) {
1217 code = BOZO_WaitAll(tconn);
1219 printf("bos: can't wait for processes to shutdown (%s)\n",
1225 #define PARMBUFFERSSIZE 32
1228 DoSalvage(aconn, aparm1, aparm2, aoutName, showlog, parallel, atmpDir,
1230 struct rx_connection *aconn;
1239 register afs_int32 code;
1242 char tbuffer[BOZO_BSSIZE];
1243 struct bozo_status istatus;
1244 struct rx_call *tcall;
1248 char partName[20]; /* canonical name for partition */
1249 char pbuffer[PARMBUFFERSSIZE];
1250 afs_int32 partNumber;
1251 char *notifier = NONOTIFIER;
1253 /* if a partition was specified, canonicalize the name, since
1254 * the salvager has a stupid partition ID parser */
1256 partNumber = volutil_GetPartitionID(aparm1);
1257 if (partNumber < 0) {
1258 printf("bos: could not parse partition ID '%s'\n", aparm1);
1261 tp = volutil_PartitionName(partNumber);
1263 printf("bos: internal error parsing partition ID '%s'\n", aparm1);
1266 strcpy(partName, tp);
1270 /* open the file name */
1272 outFile = fopen(aoutName, "w");
1274 printf("bos: can't open specified SalvageLog file '%s'\n",
1278 closeIt = 1; /* close this file later */
1281 closeIt = 0; /* don't close this file later */
1284 for (code = 2; code < 6; code++)
1288 /* MUST pass canonical (wire-format) salvager path to bosserver */
1289 strncpy(tbuffer, AFSDIR_CANONICAL_SERVER_SALVAGER_FILEPATH, BOZO_BSSIZE);
1291 if ((strlen(tbuffer) + 1 + strlen(partName) + 1 + strlen(aparm2) +
1293 printf("bos: command line too big\n");
1296 strcat(tbuffer, " ");
1297 strcat(tbuffer, partName);
1298 strcat(tbuffer, " ");
1299 strcat(tbuffer, aparm2);
1301 if ((strlen(tbuffer) + 4 + strlen(partName) + 1) > BOZO_BSSIZE) {
1302 printf("bos: command line too big\n");
1305 strcat(tbuffer, " -f ");
1306 strcat(tbuffer, partName);
1309 /* add the parallel option if given */
1310 if (parallel != NULL) {
1311 if ((strlen(tbuffer) + 11 + strlen(parallel) + 1) > BOZO_BSSIZE) {
1312 printf("bos: command line too big\n");
1315 strcat(tbuffer, " -parallel ");
1316 strcat(tbuffer, parallel);
1319 /* add the tmpdir option if given */
1320 if (atmpDir != NULL) {
1321 if ((strlen(tbuffer) + 9 + strlen(atmpDir) + 1) > BOZO_BSSIZE) {
1322 printf("bos: command line too big\n");
1325 strcat(tbuffer, " -tmpdir ");
1326 strcat(tbuffer, atmpDir);
1329 /* add the orphans option if given */
1330 if (orphans != NULL) {
1331 if ((strlen(tbuffer) + 10 + strlen(orphans) + 1) > BOZO_BSSIZE) {
1332 printf("bos: command line too big\n");
1335 strcat(tbuffer, " -orphans ");
1336 strcat(tbuffer, orphans);
1339 if (mrafsParm.Optdebug)
1340 strcat(tbuffer, " -debug");
1341 if (mrafsParm.Optnowrite)
1342 strcat(tbuffer, " -nowrite");
1343 if (mrafsParm.Optforce)
1344 strcat(tbuffer, " -force");
1345 if (mrafsParm.Optoktozap)
1346 strcat(tbuffer, " -oktozap");
1347 if (mrafsParm.Optrootfiles)
1348 strcat(tbuffer, " -rootfiles");
1349 if (mrafsParm.Optsalvagedirs)
1350 strcat(tbuffer, " -salvagedirs");
1351 if (mrafsParm.Optblockreads)
1352 strcat(tbuffer, " -blockreads");
1353 if (mrafsParm.OptListResidencies)
1354 strcat(tbuffer, " -ListResidencies");
1355 if (mrafsParm.OptSalvageRemote)
1356 strcat(tbuffer, " -SalvageRemote");
1357 if (mrafsParm.OptSalvageArchival)
1358 strcat(tbuffer, " -SalvageArchival");
1359 if (mrafsParm.OptIgnoreCheck)
1360 strcat(tbuffer, " -IgnoreCheck");
1361 if (mrafsParm.OptForceOnLine)
1362 strcat(tbuffer, " -ForceOnLine");
1363 if (mrafsParm.OptUseRootDirACL)
1364 strcat(tbuffer, " -UseRootDirACL");
1365 if (mrafsParm.OptTraceBadLinkCounts)
1366 strcat(tbuffer, " -TraceBadLinkCounts");
1367 if (mrafsParm.OptDontAskFS)
1368 strcat(tbuffer, " -DontAskFS");
1369 if (mrafsParm.OptLogLevel) {
1370 sprintf(pbuffer, " -LogLevel %ld", mrafsParm.OptLogLevel);
1371 strcat(tbuffer, pbuffer);
1373 if (mrafsParm.OptRxDebug)
1374 strcat(tbuffer, " -rxdebug");
1375 if (mrafsParm.OptResidencies) {
1376 sprintf(pbuffer, " -Residencies %lu", mrafsParm.OptResidencies);
1377 strcat(tbuffer, pbuffer);
1381 parms[1] = "now"; /* when to do it */
1383 BOZO_CreateBnode(aconn, "cron", "salvage-tmp", parms[0], parms[1],
1384 parms[2], parms[3], parms[4], notifier);
1386 printf("bos: failed to start 'salvager' (%s)\n", em(code));
1389 /* now wait for bnode to disappear */
1393 code = BOZO_GetInstanceInfo(aconn, "salvage-tmp", &tp, &istatus);
1396 printf("bos: waiting for salvage to complete.\n");
1398 if (code != BZNOENT) {
1399 printf("bos: salvage failed (%s)\n", em(code));
1404 /* now print the log file to the output file */
1405 printf("bos: salvage completed\n");
1406 if (aoutName || showlog) {
1407 fprintf(outFile, "SalvageLog:\n");
1408 tcall = rx_NewCall(aconn);
1409 /* MUST pass canonical (wire-format) salvager log path to bosserver */
1411 StartBOZO_GetLog(tcall, AFSDIR_CANONICAL_SERVER_SLVGLOG_FILEPATH);
1413 rx_EndCall(tcall, code);
1418 code = rx_Read(tcall, &buffer, 1);
1421 putc(buffer, outFile);
1423 break; /* the end delimeter */
1425 code = rx_EndCall(tcall, 0);
1426 /* fall through into cleanup code */
1430 if (closeIt && outFile)
1437 register struct cmd_syndesc *as;
1439 struct rx_connection *tconn;
1440 register struct rx_call *tcall;
1441 register afs_int32 code;
1445 printf("Fetching log file '%s'...\n", as->parms[1].items->data);
1446 tconn = GetConn(as, 0);
1447 tcall = rx_NewCall(tconn);
1448 code = StartBOZO_GetLog(tcall, as->parms[1].items->data);
1450 rx_EndCall(tcall, code);
1456 code = rx_Read(tcall, &buffer, 1);
1462 break; /* the end delimeter */
1465 code = rx_EndCall(tcall, error);
1466 /* fall through into cleanup code */
1470 com_err("bos", code, "(while reading log)");
1476 struct cmd_syndesc *as;
1478 register struct rx_connection *tconn;
1479 register afs_int32 code, rc, i;
1481 char tname[BOZO_BSSIZE];
1483 extern struct ubik_client *cstruct;
1484 afs_int32 curGoal, showlog = 0, mrafs = 0;
1490 memset(&mrafsParm, 0, sizeof(mrafsParm));
1492 /* parm 0 is machine name, 1 is partition, 2 is volume, 3 is -all flag */
1493 tconn = GetConn(as, 0);
1495 /* Find out whether fileserver is running MR-AFS (has a scanner instance) */
1496 /* XXX this should really be done some other way, potentially by RPC */
1498 if (code = BOZO_GetInstanceParm(tconn, "fs", 3, &tp) == 0)
1501 /* we can do a volume, a partition or the whole thing, but not mixtures
1503 if (!as->parms[1].items && as->parms[2].items) {
1504 printf("bos: must specify partition to salvage individual volume.\n");
1507 if (as->parms[5].items && as->parms[3].items) {
1508 printf("bos: can not specify both -file and -showlog.\n");
1511 if (as->parms[4].items && (as->parms[1].items || as->parms[2].items)) {
1512 printf("bos: can not specify -all with other flags.\n");
1516 /* get the output file name, if any */
1517 if (as->parms[3].items)
1518 outName = as->parms[3].items->data;
1522 if (as->parms[5].items)
1525 /* parallel option */
1527 if (as->parms[6].items)
1528 parallel = as->parms[6].items->data;
1530 /* get the tmpdir filename if any */
1532 if (as->parms[7].items)
1533 tmpDir = as->parms[7].items->data;
1535 /* -orphans option */
1537 if (as->parms[8].items) {
1539 printf("Can't specify -orphans for MR-AFS fileserver\n");
1542 orphans = as->parms[8].items->data;
1546 if (as->parms[MRAFS_OFFSET].items)
1547 mrafsParm.Optdebug = 1;
1548 if (as->parms[MRAFS_OFFSET + 1].items)
1549 mrafsParm.Optnowrite = 1;
1550 if (as->parms[MRAFS_OFFSET + 2].items)
1551 mrafsParm.Optforce = 1;
1552 if (as->parms[MRAFS_OFFSET + 3].items)
1553 mrafsParm.Optoktozap = 1;
1554 if (as->parms[MRAFS_OFFSET + 4].items)
1555 mrafsParm.Optrootfiles = 1;
1556 if (as->parms[MRAFS_OFFSET + 5].items)
1557 mrafsParm.Optsalvagedirs = 1;
1558 if (as->parms[MRAFS_OFFSET + 6].items)
1559 mrafsParm.Optblockreads = 1;
1560 if (as->parms[MRAFS_OFFSET + 7].items)
1561 mrafsParm.OptListResidencies = 1;
1562 if (as->parms[MRAFS_OFFSET + 8].items)
1563 mrafsParm.OptSalvageRemote = 1;
1564 if (as->parms[MRAFS_OFFSET + 9].items)
1565 mrafsParm.OptSalvageArchival = 1;
1566 if (as->parms[MRAFS_OFFSET + 10].items)
1567 mrafsParm.OptIgnoreCheck = 1;
1568 if (as->parms[MRAFS_OFFSET + 11].items)
1569 mrafsParm.OptForceOnLine = 1;
1570 if (as->parms[MRAFS_OFFSET + 12].items)
1571 mrafsParm.OptUseRootDirACL = 1;
1572 if (as->parms[MRAFS_OFFSET + 13].items)
1573 mrafsParm.OptTraceBadLinkCounts = 1;
1574 if (as->parms[MRAFS_OFFSET + 14].items)
1575 mrafsParm.OptDontAskFS = 1;
1576 if (as->parms[MRAFS_OFFSET + 15].items)
1577 mrafsParm.OptLogLevel =
1578 atoi(as->parms[MRAFS_OFFSET + 15].items->data);
1579 if (as->parms[MRAFS_OFFSET + 16].items)
1580 mrafsParm.OptRxDebug = 1;
1581 if (as->parms[MRAFS_OFFSET + 17].items) {
1582 if (as->parms[MRAFS_OFFSET + 8].items
1583 || as->parms[MRAFS_OFFSET + 9].items) {
1585 ("Can't specify -Residencies with -SalvageRemote or -SalvageArchival\n");
1589 util_GetUInt32(as->parms[MRAFS_OFFSET + 17].items->data,
1590 &mrafsParm.OptResidencies);
1592 printf("bos: '%s' is not a valid residency mask.\n",
1593 as->parms[MRAFS_OFFSET + 13].items->data);
1600 for (i = 9; i < ADDPARMOFFSET; i++) {
1601 if (as->parms[i].items) {
1602 printf(" %s only possible for MR-AFS fileserver.\n",
1611 if (as->parms[4].items) {
1612 /* salvage whole enchilada */
1613 curGoal = GetServerGoal(tconn, "fs");
1614 if (curGoal == BSTAT_NORMAL) {
1615 printf("bos: shutting down fs.\n");
1616 code = BOZO_SetTStatus(tconn, "fs", BSTAT_SHUTDOWN);
1618 printf("bos: failed to stop 'fs' (%s)\n", em(code));
1621 code = BOZO_WaitAll(tconn); /* wait for shutdown to complete */
1624 ("bos: failed to wait for file server shutdown, continuing.\n");
1626 /* now do the salvage operation */
1627 printf("Starting salvage.\n");
1628 rc = DoSalvage(tconn, NULL, NULL, outName, showlog, parallel, tmpDir,
1630 if (curGoal == BSTAT_NORMAL) {
1631 printf("bos: restarting fs.\n");
1632 code = BOZO_SetTStatus(tconn, "fs", BSTAT_NORMAL);
1634 printf("bos: failed to restart 'fs' (%s)\n", em(code));
1640 } else if (!as->parms[2].items) {
1641 if (!as->parms[1].items) {
1643 ("bos: must specify -all switch to salvage all partitions.\n");
1646 if (volutil_GetPartitionID(as->parms[1].items->data) < 0) {
1647 /* can't parse volume ID, so complain before shutting down
1650 printf("bos: can't interpret %s as partition ID.\n",
1651 as->parms[1].items->data);
1654 curGoal = GetServerGoal(tconn, "fs");
1655 /* salvage a whole partition (specified by parms[1]) */
1656 if (curGoal == BSTAT_NORMAL) {
1657 printf("bos: shutting down fs.\n");
1658 code = BOZO_SetTStatus(tconn, "fs", BSTAT_SHUTDOWN);
1660 printf("bos: can't stop 'fs' (%s)\n", em(code));
1663 code = BOZO_WaitAll(tconn); /* wait for shutdown to complete */
1666 ("bos: failed to wait for file server shutdown, continuing.\n");
1668 /* now do the salvage operation */
1669 printf("Starting salvage.\n");
1670 rc = DoSalvage(tconn, as->parms[1].items->data, NULL, outName,
1671 showlog, parallel, tmpDir, orphans);
1672 if (curGoal == BSTAT_NORMAL) {
1673 printf("bos: restarting fs.\n");
1674 code = BOZO_SetTStatus(tconn, "fs", BSTAT_NORMAL);
1676 printf("bos: failed to restart 'fs' (%s)\n", em(code));
1683 /* salvage individual volume (don't shutdown fs first), just use
1684 * single-shot cron bnode. Must leave server running when using this
1685 * option, since salvager will ask file server for the volume */
1688 const char *confdir;
1691 if (as->parms[ADDPARMOFFSET].items)
1692 tmpname = as->parms[ADDPARMOFFSET].items->data;
1696 localauth = (as->parms[ADDPARMOFFSET + 2].items != 0);
1698 (localauth ? AFSDIR_SERVER_ETC_DIRPATH :
1699 AFSDIR_CLIENT_ETC_DIRPATH);
1700 code = vsu_ClientInit( /* noauth */ 1, confdir, tmpname,
1701 /* server auth */ 0, &cstruct, (int (*)())0);
1703 newID = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err);
1705 printf("bos: can't interpret %s as volume name or ID\n",
1706 as->parms[2].items->data);
1709 sprintf(tname, "%u", newID);
1712 ("bos: can't initialize volume system client (code %d), trying anyway.\n",
1714 strncpy(tname, as->parms[2].items->data, sizeof(tname));
1716 if (volutil_GetPartitionID(as->parms[1].items->data) < 0) {
1717 /* can't parse volume ID, so complain before shutting down
1720 printf("bos: can't interpret %s as partition ID.\n",
1721 as->parms[1].items->data);
1724 printf("Starting salvage.\n");
1725 rc = DoSalvage(tconn, as->parms[1].items->data, tname, outName,
1726 showlog, parallel, tmpDir, orphans);
1734 IStatServer(as, int32p)
1736 register struct cmd_syndesc *as;
1738 register struct rx_connection *tconn;
1739 register struct cmd_item *ti;
1742 tconn = GetConn(as, 0);
1743 for (ti = as->parms[1].items; ti; ti = ti->next) {
1744 DoStat(ti->data, tconn, int32p, firstTime);
1751 DoStat(aname, aconn, aint32p, firstTime)
1753 IN register struct rx_connection *aconn;
1755 IN int firstTime; /* true iff first instance in cmd */
1759 register afs_int32 code;
1760 register afs_int32 i;
1761 struct bozo_status istatus;
1763 char *is1, *is2, *is3, *is4; /* instance strings */
1766 code = BOZO_GetInstanceInfo(aconn, aname, &tp, &istatus);
1768 printf("bos: failed to get instance info for '%s' (%s)\n", aname,
1772 if (firstTime && aint32p && (istatus.flags & BOZO_BADDIRACCESS))
1774 ("Bosserver reports inappropriate access on server directories\n");
1775 printf("Instance %s, ", aname);
1777 printf("(type is %s) ", buffer);
1778 if (istatus.fileGoal == istatus.goal) {
1780 printf("disabled, ");
1782 if (istatus.fileGoal)
1783 printf("temporarily disabled, ");
1785 printf("temporarily enabled, ");
1788 if (istatus.flags & BOZO_ERRORSTOP)
1789 printf("stopped for too many errors, ");
1790 if (istatus.flags & BOZO_HASCORE)
1791 printf("has core file, ");
1794 code = BOZO_GetStatus(aconn, aname, &temp, &tp);
1796 printf("bos: failed to get status for instance '%s' (%s)\n", aname,
1799 printf("currently ");
1800 if (temp == BSTAT_NORMAL)
1801 printf("running normally.\n");
1802 else if (temp == BSTAT_SHUTDOWN)
1803 printf("shutdown.\n");
1804 else if (temp == BSTAT_STARTINGUP)
1805 printf("starting up.\n");
1806 else if (temp == BSTAT_SHUTTINGDOWN)
1807 printf("shutting down.\n");
1808 if (buffer[0] != 0) {
1809 printf(" Auxiliary status is: %s.\n", buffer);
1813 /* are we done yet? */
1817 if (istatus.procStartTime)
1818 printf(" Process last started at %s (%d proc starts)\n",
1819 DateOf(istatus.procStartTime), istatus.procStarts);
1820 if (istatus.lastAnyExit) {
1821 printf(" Last exit at %s\n", DateOf(istatus.lastAnyExit));
1823 if (istatus.lastErrorExit) {
1824 is1 = is2 = is3 = is4 = NULL;
1825 printf(" Last error exit at %s, ", DateOf(istatus.lastErrorExit));
1826 code = BOZO_GetInstanceStrings(aconn, aname, &is1, &is2, &is3, &is4);
1827 /* don't complain about failing call, since could simply mean
1828 * interface mismatch.
1832 /* non-null instance string */
1833 printf("by %s, ", is1);
1840 if (istatus.errorSignal) {
1841 if (istatus.errorSignal == SIGTERM)
1842 printf("due to shutdown request\n");
1844 printf("due to signal %d\n", istatus.errorSignal);
1846 printf("by exiting with code %d\n", istatus.errorCode);
1850 /* try to display all the parms */
1853 code = BOZO_GetInstanceParm(aconn, aname, i, &tp);
1856 printf(" Command %d is '%s'\n", i + 1, buffer);
1859 code = BOZO_GetInstanceParm(aconn, aname, 999, &tp);
1861 /* Any type of failure is treated as not having a notifier program */
1862 printf(" Notifier is '%s'\n", buffer);
1869 #ifdef BOS_RESTRICTED_MODE
1872 struct cmd_syndesc *as;
1874 register struct rx_connection *tconn;
1875 afs_int32 code, val;
1877 tconn = GetConn(as, 0);
1878 code = BOZO_GetRestrictedMode(tconn, &val);
1880 printf("bos: failed to get restricted mode (%s)\n", em(code));
1882 printf("Restricted mode is %s\n", val ? "on" : "off");
1889 struct cmd_syndesc *as;
1891 register struct rx_connection *tconn;
1892 afs_int32 code, val;
1894 tconn = GetConn(as, 0);
1895 util_GetInt32(as->parms[1].items->data, &val);
1896 code = BOZO_SetRestrictedMode(tconn, val);
1898 printf("bos: failed to set restricted mode (%s)\n", em(code));
1905 register struct cmd_syndesc *ts;
1907 cmd_Seek(ts, ADDPARMOFFSET);
1908 /* + 0 */ cmd_AddParm(ts, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell name");
1909 /* + 1 */ cmd_AddParm(ts, "-noauth", CMD_FLAG, CMD_OPTIONAL,
1910 "don't authenticate");
1911 /* + 2 */ cmd_AddParm(ts, "-localauth", CMD_FLAG, CMD_OPTIONAL,
1912 "create tickets from KeyFile");
1915 #include "AFS_component_version_number.c"
1921 register afs_int32 code;
1922 register struct cmd_syndesc *ts;
1923 extern int afsconf_SawCell;
1925 #ifdef AFS_AIX32_ENV
1927 * The following signal action for AIX is necessary so that in case of a
1928 * crash (i.e. core is generated) we can include the user's data section
1929 * in the core dump. Unfortunately, by default, only a partial core is
1930 * generated which, in many cases, isn't too useful.
1932 struct sigaction nsa;
1934 sigemptyset(&nsa.sa_mask);
1935 nsa.sa_handler = SIG_DFL;
1936 nsa.sa_flags = SA_FULLDUMP;
1937 sigaction(SIGSEGV, &nsa, NULL);
1938 sigaction(SIGABRT, &nsa, NULL);
1944 printf("bos: could not initialize rx (%s)\n", em(code));
1948 /* To resolve a AFSCELL environment "Note: ..." problem: Because bos calls ka_Init (why?) before any
1949 * checkup on the existance of a "-cell" option on the particular bos command we don't print the
1950 * message if a cell is passed in. Luckily the rest of the programs don't call these adhoc routines
1951 * and things work fine. Note that if the "-cell" isn't passed then we're still ok since later on
1952 * the proper routine (afsconf_GetCellInfo) is going to be called to do the right thing.
1954 afsconf_SawCell = 1; /* Means don't print warning if AFSCELL is set */
1956 afsconf_SawCell = 0; /* Reset it */
1957 /* don't check error code, since fails sometimes when we're setting up a
1959 initialize_CMD_error_table();
1960 initialize_BZ_error_table();
1962 ts = cmd_CreateSyntax("start", StartServer, 0, "start running a server");
1963 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1964 cmd_AddParm(ts, "-instance", CMD_LIST, 0, "server process name");
1967 ts = cmd_CreateSyntax("stop", StopServer, 0, "halt a server instance");
1968 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1969 cmd_AddParm(ts, "-instance", CMD_LIST, 0, "server process name");
1971 cmd_AddParm(ts, "-wait", CMD_FLAG, CMD_OPTIONAL,
1972 "wait for process to stop");
1975 ts = cmd_CreateSyntax("status", StatServer, 0,
1976 "show server instance status");
1977 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1978 cmd_AddParm(ts, "-instance", CMD_LIST, CMD_OPTIONAL,
1979 "server process name");
1980 cmd_AddParm(ts, "-long", CMD_FLAG, CMD_OPTIONAL, "long status");
1983 ts = cmd_CreateSyntax("shutdown", Shutdown, 0, "shutdown all processes");
1984 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1985 cmd_AddParm(ts, "-instance", CMD_LIST, CMD_OPTIONAL, "instances");
1987 cmd_AddParm(ts, "-wait", CMD_FLAG, CMD_OPTIONAL,
1988 "wait for process to stop");
1991 ts = cmd_CreateSyntax("startup", Startup, 0, "start all processes");
1992 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1993 cmd_AddParm(ts, "-instance", CMD_LIST, CMD_OPTIONAL, "instances");
1996 ts = cmd_CreateSyntax("restart", Restart, 0, "restart processes");
1997 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1998 cmd_AddParm(ts, "-instance", CMD_LIST, CMD_OPTIONAL, "instances");
1999 cmd_AddParm(ts, "-bosserver", CMD_FLAG, CMD_OPTIONAL,
2000 "restart bosserver");
2001 cmd_AddParm(ts, "-all", CMD_FLAG, CMD_OPTIONAL, "restart all processes");
2006 ts = cmd_CreateSyntax("create", CreateServer, 0,
2007 "create a new server instance");
2008 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2009 cmd_AddParm(ts, "-instance", CMD_SINGLE, 0, "server process name");
2010 cmd_AddParm(ts, "-type", CMD_SINGLE, 0, "server type");
2011 cmd_AddParm(ts, "-cmd", CMD_LIST, 0, "command lines");
2012 cmd_AddParm(ts, "-notifier", CMD_SINGLE, CMD_OPTIONAL,
2013 "Notifier program");
2016 ts = cmd_CreateSyntax("delete", DeleteServer, 0,
2017 "delete a server instance");
2018 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2019 cmd_AddParm(ts, "-instance", CMD_LIST, 0, "server process name");
2022 ts = cmd_CreateSyntax("adduser", AddSUser, 0,
2023 "add users to super-user list");
2024 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2025 cmd_AddParm(ts, "-user", CMD_LIST, 0, "user names");
2028 ts = cmd_CreateSyntax("removeuser", RemoveSUser, 0,
2029 "remove users from 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("listusers", ListSUsers, 0, "list super-users");
2035 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2038 ts = cmd_CreateSyntax("addkey", AddKey, 0,
2039 "add keys to key dbase (kvno 999 is bcrypt)");
2040 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2041 cmd_AddParm(ts, "-key", CMD_SINGLE, CMD_OPTIONAL, "key");
2042 cmd_AddParm(ts, "-kvno", CMD_SINGLE, 0, "key version number");
2045 ts = cmd_CreateSyntax("removekey", RemoveKey, 0,
2046 "remove keys from key dbase");
2047 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2048 cmd_AddParm(ts, "-kvno", CMD_LIST, 0, "key version number");
2051 ts = cmd_CreateSyntax("listkeys", ListKeys, 0, "list keys");
2052 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2053 cmd_AddParm(ts, "-showkey", CMD_FLAG, CMD_OPTIONAL,
2054 "show the actual key rather than the checksum");
2057 ts = cmd_CreateSyntax("listhosts", ListHosts, 0, "get cell host list");
2058 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2060 cmd_CreateAlias(ts, "getcell");
2062 ts = cmd_CreateSyntax("setcellname", SetCellName, 0, "set cell name");
2063 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2064 cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "cell name");
2067 ts = cmd_CreateSyntax("addhost", AddHost, 0, "add host to cell dbase");
2068 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2069 cmd_AddParm(ts, "-host", CMD_LIST, 0, "host name");
2070 cmd_AddParm(ts, "-clone", CMD_FLAG, CMD_OPTIONAL, "vote doesn't count");
2073 ts = cmd_CreateSyntax("removehost", RemoveHost, 0,
2074 "remove host from cell dbase");
2075 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2076 cmd_AddParm(ts, "-host", CMD_LIST, 0, "host name");
2079 ts = cmd_CreateSyntax("setauth", SetAuth, 0,
2080 "set authentication required flag");
2081 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2082 cmd_AddParm(ts, "-authrequired", CMD_SINGLE, 0,
2083 "on or off: authentication required for admin requests");
2086 ts = cmd_CreateSyntax("install", Install, 0, "install program");
2087 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2088 cmd_AddParm(ts, "-file", CMD_LIST, 0, "files to install");
2089 cmd_AddParm(ts, "-dir", CMD_SINGLE, CMD_OPTIONAL, "destination dir");
2092 ts = cmd_CreateSyntax("uninstall", UnInstall, 0, "uninstall program");
2093 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2094 cmd_AddParm(ts, "-file", CMD_LIST, 0, "files to uninstall");
2095 cmd_AddParm(ts, "-dir", CMD_SINGLE, CMD_OPTIONAL, "destination dir");
2098 ts = cmd_CreateSyntax("getlog", GetLogCmd, 0, "examine log file");
2099 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2100 cmd_AddParm(ts, "-file", CMD_SINGLE, 0, "log file to examine");
2103 ts = cmd_CreateSyntax("getdate", GetDate, 0, "get dates for programs");
2104 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2105 cmd_AddParm(ts, "-file", CMD_LIST, 0, "files to check");
2106 cmd_AddParm(ts, "-dir", CMD_SINGLE, CMD_OPTIONAL, "destination dir");
2109 ts = cmd_CreateSyntax("exec", Exec, 0, "execute shell command on server");
2110 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2111 cmd_AddParm(ts, "-cmd", CMD_SINGLE, 0, "command to execute");
2114 ts = cmd_CreateSyntax("prune", Prune, 0, "prune server files");
2115 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2116 cmd_AddParm(ts, "-bak", CMD_FLAG, CMD_OPTIONAL, "delete .BAK files");
2117 cmd_AddParm(ts, "-old", CMD_FLAG, CMD_OPTIONAL, "delete .OLD files");
2118 cmd_AddParm(ts, "-core", CMD_FLAG, CMD_OPTIONAL, "delete core files");
2119 cmd_AddParm(ts, "-all", CMD_FLAG, CMD_OPTIONAL, "delete all junk files");
2122 ts = cmd_CreateSyntax("setrestart", SetRestartCmd, 0,
2123 "set restart times");
2124 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_REQUIRED, "machine name");
2125 cmd_AddParm(ts, "-time", CMD_SINGLE, CMD_REQUIRED,
2126 "time to restart server");
2127 cmd_AddParm(ts, "-general", CMD_FLAG, CMD_OPTIONAL,
2128 "set general restart time");
2129 cmd_AddParm(ts, "-newbinary", CMD_FLAG, CMD_OPTIONAL,
2130 "set new binary restart time");
2133 ts = cmd_CreateSyntax("getrestart", GetRestartCmd, 0,
2134 "get restart times");
2135 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_REQUIRED, "machine name");
2138 ts = cmd_CreateSyntax("salvage", SalvageCmd, 0,
2139 "salvage partition or volumes");
2140 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2141 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL,
2142 "salvage partition");
2143 cmd_AddParm(ts, "-volume", CMD_SINGLE, CMD_OPTIONAL,
2144 "salvage volume number or volume name");
2145 cmd_AddParm(ts, "-file", CMD_SINGLE, CMD_OPTIONAL,
2146 "salvage log output file");
2147 cmd_AddParm(ts, "-all", CMD_FLAG, CMD_OPTIONAL, "salvage whole server");
2148 cmd_AddParm(ts, "-showlog", CMD_FLAG, CMD_OPTIONAL,
2149 "display salvage log");
2150 cmd_AddParm(ts, "-parallel", CMD_SINGLE, CMD_OPTIONAL,
2151 "# of max parallel partition salvaging");
2152 cmd_AddParm(ts, "-tmpdir", CMD_SINGLE, CMD_OPTIONAL,
2153 "directory to place tmp files");
2154 cmd_AddParm(ts, "-orphans", CMD_SINGLE, CMD_OPTIONAL,
2155 "ignore | remove | attach");
2156 cmd_AddParm(ts, "-debug", CMD_FLAG, CMD_OPTIONAL,
2157 "(MR-AFS) Run in Debugging mode");
2158 cmd_AddParm(ts, "-nowrite", CMD_FLAG, CMD_OPTIONAL,
2159 "(MR-AFS) Run readonly/test mode");
2160 cmd_AddParm(ts, "-force", CMD_FLAG, CMD_OPTIONAL,
2161 "(MR-AFS) Force full salvaging");
2162 cmd_AddParm(ts, "-oktozap", CMD_FLAG, CMD_OPTIONAL,
2163 "(MR-AFS) Give permission to destroy bogus file residencies/volumes - debugging flag");
2164 cmd_AddParm(ts, "-rootfiles", CMD_FLAG, CMD_OPTIONAL,
2165 "(MR-AFS) Show files owned by root - debugging flag");
2166 cmd_AddParm(ts, "-salvagedirs", CMD_FLAG, CMD_OPTIONAL,
2167 "(MR-AFS) Force rebuild/salvage of all directories");
2168 cmd_AddParm(ts, "-blockreads", CMD_FLAG, CMD_OPTIONAL,
2169 "(MR-AFS) Read smaller blocks to handle IO/bad blocks");
2170 cmd_AddParm(ts, "-ListResidencies", CMD_FLAG, CMD_OPTIONAL,
2171 "(MR-AFS) Just list affected file residencies - debugging flag");
2172 cmd_AddParm(ts, "-SalvageRemote", CMD_FLAG, CMD_OPTIONAL,
2173 "(MR-AFS) Salvage storage systems that are not directly attached");
2174 cmd_AddParm(ts, "-SalvageArchival", CMD_FLAG, CMD_OPTIONAL,
2175 "(MR-AFS) Salvage HSM storage systems");
2176 cmd_AddParm(ts, "-IgnoreCheck", CMD_FLAG, CMD_OPTIONAL,
2177 "(MR-AFS) Don't perform VLDB safety check when deleting unreferenced files. Only a good idea in single server cell.");
2178 cmd_AddParm(ts, "-ForceOnLine", CMD_FLAG, CMD_OPTIONAL,
2179 "(MR-AFS) Force the volume to come online, even if it hasn't salvaged cleanly.");
2180 cmd_AddParm(ts, "-UseRootDirACL", CMD_FLAG, CMD_OPTIONAL,
2181 "(MR-AFS) Use the root directory ACL for lost+found directory if it is created.");
2182 cmd_AddParm(ts, "-TraceBadLinkCounts", CMD_FLAG, CMD_OPTIONAL,
2183 "(MR-AFS) Print out lines about volume reference count changes.");
2184 cmd_AddParm(ts, "-DontAskFS", CMD_FLAG, CMD_OPTIONAL,
2185 "(MR-AFS) Don't ask fileserver to take volume offline. THIS IS VERY DANGEROUS.");
2186 cmd_AddParm(ts, "-LogLevel", CMD_SINGLE, CMD_OPTIONAL,
2187 "(MR-AFS) log level");
2188 cmd_AddParm(ts, "-rxdebug", CMD_FLAG, CMD_OPTIONAL,
2189 "(MR-AFS) Write out rx debug information.");
2190 cmd_AddParm(ts, "-Residencies", CMD_SINGLE, CMD_OPTIONAL,
2191 "(MR-AFS) Numeric mask of residencies to be included in the salvage. Do not use with -SalvageRemote or -SalvageArchival");
2194 ts = cmd_CreateSyntax("blockscanner", BlockScannerCmd, 0,
2195 "block scanner daemon from making migration requests");
2196 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_REQUIRED, "machine name");
2199 ts = cmd_CreateSyntax("unblockscanner", UnBlockScannerCmd, 0,
2200 "allow scanner daemon to make migration requests again");
2201 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_REQUIRED, "machine name");
2204 #ifdef BOS_RESTRICTED_MODE
2205 ts = cmd_CreateSyntax("getrestricted", GetRestrict, 0,
2206 "get restrict mode");
2207 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2210 ts = cmd_CreateSyntax("setrestricted", SetRestrict, 0,
2211 "set restrict mode");
2212 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2213 cmd_AddParm(ts, "-mode", CMD_SINGLE, 0, "mode to set");
2218 code = cmd_Dispatch(argc, argv);