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>
42 #include <afs/cellconfig.h>
45 #include <afs/com_err.h>
47 #include <afs/ktime.h>
54 /* command offsets for bos salvage command */
55 #define MRAFS_OFFSET 10
56 #define ADDPARMOFFSET 27
58 /* MR-AFS salvage parameters */
59 struct MRAFSSalvageParms {
64 afs_int32 Optrootfiles;
65 afs_int32 Optsalvagedirs;
66 afs_int32 Optblockreads;
67 afs_int32 OptListResidencies;
68 afs_int32 OptSalvageRemote;
69 afs_int32 OptSalvageArchival;
70 afs_int32 OptIgnoreCheck;
71 afs_int32 OptForceOnLine;
72 afs_int32 OptUseRootDirACL;
73 afs_int32 OptTraceBadLinkCounts;
74 afs_int32 OptDontAskFS;
75 afs_int32 OptLogLevel;
77 afs_uint32 OptResidencies;
80 /* dummy routine for the audit work. It should do nothing since audits */
81 /* occur at the server level and bos is not a server. */
87 /* keep those lines small */
93 return "communications failure (-1)";
95 return "communications timeout (-3)";
97 return (char *)error_message(acode);
100 /* get partition id from a name */
102 GetPartitionID(aname)
110 return -1; /* unknown */
111 /* numbers go straight through */
112 if (tc >= '0' && tc <= '9') {
115 /* otherwise check for vicepa or /vicepa, or just plain "a" */
117 if (strlen(aname) <= 2) {
118 strcpy(ascii, aname);
119 } else if (!strncmp(aname, "/vicep", 6)) {
120 strncpy(ascii, aname + 6, 2);
121 } else if (!strncmp(aname, "vicep", 5)) {
122 strncpy(ascii, aname + 5, 2);
124 return -1; /* bad partition name */
125 /* now partitions are named /vicepa ... /vicepz, /vicepaa, /vicepab,
126 * .../vicepzz, and are numbered from 0. Do the appropriate conversion */
128 /* one char name, 0..25 */
129 if (ascii[0] < 'a' || ascii[0] > 'z')
130 return -1; /* wrongo */
131 return ascii[0] - 'a';
133 /* two char name, 26 .. <whatever> */
134 if (ascii[0] < 'a' || ascii[0] > 'z')
135 return -1; /* wrongo */
136 if (ascii[1] < 'a' || ascii[1] > 'z')
137 return -1; /* just as bad */
138 return (ascii[0] - 'a') * 26 + (ascii[1] - 'a') + 26;
142 /* make ctime easier to use */
147 static char tbuffer[30];
149 time_t t = (time_t) atime;
153 tbuffer[24] = 0; /* get rid of new line */
155 strcpy(tbuffer, "BAD TIME");
159 /* global stuff from main for communicating with GetConn */
160 static struct rx_securityClass *sc[3];
163 /* use the syntax descr to get a connection, authenticated appropriately.
164 * aencrypt is set if we want to encrypt the data on the wire.
166 static struct rx_connection *
167 GetConn(as, aencrypt)
169 struct cmd_syndesc *as;
173 register afs_int32 code;
174 register struct rx_connection *tconn;
176 register struct afsconf_dir *tdir;
178 struct ktc_principal sname;
179 struct ktc_token ttoken;
183 hostname = as->parms[0].items->data;
184 th = hostutil_GetHostByName(hostname);
186 printf("bos: can't find address for host '%s'\n", hostname);
189 memcpy(&addr, th->h_addr, sizeof(afs_int32));
191 /* get tokens for making authenticated connections */
192 localauth = (as->parms[ADDPARMOFFSET + 2].items != 0);
194 (localauth ? AFSDIR_SERVER_ETC_DIRPATH : AFSDIR_CLIENT_ETC_DIRPATH);
195 tdir = afsconf_Open(confdir);
197 struct afsconf_cell info;
200 if (as->parms[ADDPARMOFFSET].items)
201 tname = as->parms[ADDPARMOFFSET].items->data;
204 /* next call expands cell name abbrevs for us and handles looking up
206 code = afsconf_GetCellInfo(tdir, tname, NULL, &info);
208 com_err("bos", code, "(can't find cell '%s' in cell database)",
209 (tname ? tname : "<default>"));
212 strcpy(sname.cell, info.name);
214 printf("bos: can't open cell database (%s)\n", confdir);
217 sname.instance[0] = 0;
218 strcpy(sname.name, "afs");
219 sc[0] = rxnull_NewClientSecurityObject();
224 if (!as->parms[ADDPARMOFFSET + 1].items) { /* not -noauth */
225 if (as->parms[ADDPARMOFFSET + 2].items) { /* -localauth */
226 code = afsconf_GetLatestKey(tdir, 0, 0);
228 com_err("bos", code, "(getting key from local KeyFile)");
231 code = afsconf_ClientAuthSecure(tdir, &sc[2], &scIndex);
233 code = afsconf_ClientAuth(tdir, &sc[2], &scIndex);
235 com_err("bos", code, "(calling ClientAuth)");
236 else if (scIndex != 2) /* this shouldn't happen */
239 } else { /* not -localauth, check for tickets */
240 code = ktc_GetToken(&sname, &ttoken, sizeof(ttoken), NULL);
242 /* have tickets, will travel */
243 if (ttoken.kvno >= 0 && ttoken.kvno <= 256);
246 "bos: funny kvno (%d) in ticket, proceeding\n",
251 encryptLevel = rxkad_crypt;
253 encryptLevel = rxkad_clear;
254 sc[2] = (struct rx_securityClass *)
255 rxkad_NewClientSecurityObject(encryptLevel,
262 com_err("bos", code, "(getting tickets)");
264 if ((scIndex == 0) || (sc[scIndex] == 0)) {
265 fprintf(stderr, "bos: running unauthenticated\n");
270 rx_NewConnection(addr, htons(AFSCONF_NANNYPORT), 1, sc[scIndex],
273 fprintf(stderr, "bos: could not create rx connection\n");
276 rxs_Release(sc[scIndex]);
283 struct cmd_syndesc *as;
285 register afs_int32 code;
286 register struct rx_connection *tconn;
290 tconn = GetConn(as, 0);
291 tp = as->parms[1].items->data;
292 if (strcmp(tp, "on") == 0)
293 flag = 0; /* auth req.: noauthflag is false */
294 else if (strcmp(tp, "off") == 0)
298 ("bos: illegal authentication specifier '%s', must be 'off' or 'on'.\n",
302 code = BOZO_SetNoAuthFlag(tconn, flag);
304 com_err("bos", code, "(failed to set authentication flag)");
308 /* take a name (e.g. foo/bar, and a dir e.g. /usr/afs/bin, and construct
309 * /usr/afs/bin/bar */
311 ComputeDestDir(aname, adir, aresult, alen)
312 char *aname, *adir, *aresult;
317 strcpy(aresult, adir);
318 tp = strrchr(aname, '/');
321 strcat(aresult, "/");
322 strcat(aresult, aname);
324 /* tp points at the / character */
330 /* copy data from fd afd to rx call acall */
332 CopyBytes(afd, acall)
334 register struct rx_call *acall;
336 register afs_int32 code;
337 register afs_int32 len;
341 len = read(afd, tbuffer, sizeof(tbuffer));
345 return 0; /* all done */
346 code = rx_Write(acall, tbuffer, len);
354 register struct cmd_syndesc *as;
356 register afs_int32 code;
357 register struct rx_connection *tconn;
358 register afs_int32 flags;
360 tconn = GetConn(as, 0);
362 if (as->parms[1].items)
363 flags |= BOZO_PRUNEBAK;
364 if (as->parms[2].items)
365 flags |= BOZO_PRUNEOLD;
366 if (as->parms[3].items)
367 flags |= BOZO_PRUNECORE;
368 if (as->parms[4].items)
370 code = BOZO_Prune(tconn, flags);
372 com_err("bos", code, "(failed to prune server files)");
378 register struct cmd_syndesc *as;
380 register struct rx_connection *tconn;
381 register afs_int32 code;
383 tconn = GetConn(as, 0);
384 code = BOZO_Exec(tconn, as->parms[1].items->data);
386 printf("bos: failed to execute command (%s)\n", em(code));
392 register struct cmd_syndesc *as;
394 register afs_int32 code;
397 afs_int32 time, bakTime, oldTime;
398 register struct rx_connection *tconn;
399 register struct cmd_item *ti;
401 tconn = GetConn(as, 0);
402 if (!as->parms[1].items) {
403 printf("bos: no files to check\n");
407 /* compute dest dir or file; default MUST be canonical form of dir path */
408 if (as->parms[2].items)
409 strcpy(destDir, as->parms[2].items->data);
411 strcpy(destDir, AFSDIR_CANONICAL_SERVER_BIN_DIRPATH);
413 for (ti = as->parms[1].items; ti; ti = ti->next) {
414 /* check date for each file */
415 ComputeDestDir(ti->data, destDir, tbuffer, sizeof(tbuffer));
416 code = BOZO_GetDates(tconn, tbuffer, &time, &bakTime, &oldTime);
418 printf("bos: failed to check date on %s (%s)\n", ti->data,
422 printf("File %s ", tbuffer);
424 printf("does not exist, ");
426 printf("dated %s, ", DateOf(time));
428 printf("no .BAK file, ");
430 printf(".BAK file dated %s, ", DateOf(bakTime));
432 printf("no .OLD file.");
434 printf(".OLD file dated %s.", DateOf(oldTime));
443 register struct cmd_syndesc *as;
445 register afs_int32 code;
448 register struct cmd_item *ti;
449 register struct rx_connection *tconn;
451 tconn = GetConn(as, 0);
452 if (!as->parms[1].items) {
453 printf("bos: no files to uninstall\n");
457 /* compute dest dir or file; default MUST be canonical form of dir path */
458 if (as->parms[2].items)
459 strcpy(destDir, as->parms[2].items->data);
461 strcpy(destDir, AFSDIR_CANONICAL_SERVER_BIN_DIRPATH);
463 for (ti = as->parms[1].items; ti; ti = ti->next) {
464 /* uninstall each file */
465 ComputeDestDir(ti->data, destDir, tbuffer, sizeof(tbuffer));
466 code = BOZO_UnInstall(tconn, tbuffer);
468 printf("bos: failed to uninstall %s (%s)\n", ti->data, em(code));
471 printf("bos: uninstalled file %s\n", ti->data);
477 GetServerGoal(aconn, aname)
479 struct rx_connection *aconn;
483 register afs_int32 code;
484 struct bozo_status istatus;
487 code = BOZO_GetInstanceInfo(aconn, aname, &tp, &istatus);
489 printf("bos: failed to get instance info for '%s' (%s)\n", aname,
491 /* if we can't get the answer, assume its running */
494 if (istatus.goal == 0)
495 return BSTAT_SHUTDOWN;
502 struct cmd_syndesc *as;
504 struct rx_connection *tconn;
505 register afs_int32 code;
506 register struct cmd_item *ti;
510 struct rx_call *tcall;
513 tconn = GetConn(as, 0);
514 if (!as->parms[1].items) {
515 printf("bos: no files to install\n");
519 /* compute dest dir or file; default MUST be canonical form of dir path */
520 if (as->parms[2].items)
521 strcpy(destDir, as->parms[2].items->data);
523 strcpy(destDir, AFSDIR_CANONICAL_SERVER_BIN_DIRPATH);
525 for (ti = as->parms[1].items; ti; ti = ti->next) {
526 /* install each file */
527 fd = open(ti->data, O_RDONLY);
529 /* better to quit on error than continue for install command */
530 printf("bos: can't find file '%s', quitting\n", ti->data);
533 code = fstat(fd, &tstat);
535 printf("bos: failed to stat file %s, errno is %d\n", ti->data,
539 /* compute destination dir */
540 ComputeDestDir(ti->data, destDir, tbuffer, sizeof(tbuffer));
541 tcall = rx_NewCall(tconn);
543 StartBOZO_Install(tcall, tbuffer, tstat.st_size,
544 (afs_int32) tstat.st_mode, tstat.st_mtime);
546 code = CopyBytes(fd, tcall);
548 code = rx_EndCall(tcall, code);
550 printf("bos: failed to install %s (%s)\n", ti->data, em(code));
553 printf("bos: installed file %s\n", ti->data);
560 struct cmd_syndesc *as;
562 register struct rx_connection *tconn;
563 register afs_int32 code;
564 register struct cmd_item *ti;
566 tconn = GetConn(as, 0);
567 if (as->parms[1].items == 0) {
568 code = BOZO_ShutdownAll(tconn);
570 printf("bos: failed to shutdown servers (%s)\n", em(code));
572 for (ti = as->parms[1].items; ti; ti = ti->next) {
573 code = BOZO_SetTStatus(tconn, ti->data, BSTAT_SHUTDOWN);
575 printf("bos: failed to shutdown instance %s (%s)\n", ti->data,
579 if (as->parms[8].items) {
580 code = BOZO_WaitAll(tconn);
582 printf("bos: can't wait for processes to shutdown (%s)\n",
589 BlockScannerCmd(as, arock)
590 struct cmd_syndesc *as;
593 register afs_int32 code;
594 struct rx_connection *tconn;
595 char BlockCommand[] = "/usr/afs/bin/scanner -block";
597 tconn = GetConn(as, 0);
598 code = BOZO_Exec(tconn, BlockCommand);
601 ("bos: failed to block scanner from making migration requests (%s)\n",
607 UnBlockScannerCmd(as, arock)
608 struct cmd_syndesc *as;
611 register afs_int32 code;
612 struct rx_connection *tconn;
613 char UnBlockCommand[] = "/usr/afs/bin/scanner -unblock";
615 tconn = GetConn(as, 0);
616 code = BOZO_Exec(tconn, UnBlockCommand);
619 ("bos: failed to allow scanner daemon to make migration requests again (%s)\n",
625 GetRestartCmd(as, arock)
626 struct cmd_syndesc *as;
629 register afs_int32 code;
630 struct ktime generalTime, newBinaryTime;
631 char messageBuffer[256];
632 struct rx_connection *tconn;
635 hostp = as->parms[0].items->data; /* host name for messages */
636 tconn = GetConn(as, 0);
638 code = BOZO_GetRestartTime(tconn, 1, &generalTime);
640 printf("bos: failed to retrieve restart information (%s)\n",
644 code = BOZO_GetRestartTime(tconn, 2, &newBinaryTime);
646 printf("bos: failed to retrieve restart information (%s)\n",
651 code = ktime_DisplayString(&generalTime, messageBuffer);
653 printf("bos: failed to decode restart time (%s)\n", em(code));
656 printf("Server %s restarts %s\n", hostp, messageBuffer);
658 code = ktime_DisplayString(&newBinaryTime, messageBuffer);
660 printf("bos: failed to decode restart time (%s)\n", em(code));
663 printf("Server %s restarts for new binaries %s\n", hostp, messageBuffer);
670 SetRestartCmd(as, arock)
671 struct cmd_syndesc *as;
675 register afs_int32 code;
676 struct ktime restartTime;
678 struct rx_connection *tconn;
681 tconn = GetConn(as, 0);
682 if (as->parms[2].items) {
686 if (as->parms[3].items) {
691 printf("bos: can't specify more than one restart time at a time\n");
695 type = 1; /* by default set general restart time */
697 if (code = ktime_ParsePeriodic(as->parms[1].items->data, &restartTime)) {
698 printf("bos: failed to parse '%s' as periodic restart time(%s)\n",
699 as->parms[1].items->data, em(code));
703 code = BOZO_SetRestartTime(tconn, type, &restartTime);
705 printf("bos: failed to set restart time at server (%s)\n", em(code));
713 struct cmd_syndesc *as;
715 register struct rx_connection *tconn;
716 register afs_int32 code;
717 register struct cmd_item *ti;
719 tconn = GetConn(as, 0);
720 if (as->parms[1].items == 0) {
721 code = BOZO_StartupAll(tconn);
723 printf("bos: failed to startup servers (%s)\n", em(code));
725 for (ti = as->parms[1].items; ti; ti = ti->next) {
726 code = BOZO_SetTStatus(tconn, ti->data, BSTAT_NORMAL);
728 printf("bos: failed to start instance %s (%s)\n", ti->data,
737 struct cmd_syndesc *as;
739 register struct rx_connection *tconn;
740 register afs_int32 code;
741 register struct cmd_item *ti;
743 tconn = GetConn(as, 0);
744 if (as->parms[2].items) {
745 /* this is really a rebozo command */
746 if (as->parms[1].items) {
747 /* specified specific things to restart, can't do this at the same
750 ("bos: can't specify both '-bos' and specific servers to restart.\n");
753 /* otherwise do a rebozo */
754 code = BOZO_ReBozo(tconn);
756 printf("bos: failed to restart bosserver (%s)\n", em(code));
759 if (as->parms[1].items == 0) {
760 if (as->parms[3].items) { /* '-all' */
761 code = BOZO_RestartAll(tconn);
763 printf("bos: failed to restart servers (%s)\n", em(code));
765 printf("bos: To restart all processes please specify '-all'\n");
767 if (as->parms[3].items) {
768 printf("bos: Can't use '-all' along with individual instances\n");
770 for (ti = as->parms[1].items; ti; ti = ti->next) {
771 code = BOZO_Restart(tconn, ti->data);
773 printf("bos: failed to restart instance %s (%s)\n",
783 struct cmd_syndesc *as;
785 register struct rx_connection *tconn;
786 register afs_int32 code;
788 tconn = GetConn(as, 0);
789 code = BOZO_SetCellName(tconn, as->parms[1].items->data);
791 printf("bos: failed to set cell (%s)\n", em(code));
797 register struct cmd_syndesc *as;
799 register struct rx_connection *tconn;
800 register afs_int32 code;
801 register struct cmd_item *ti;
802 char name[MAXHOSTCHARS];
804 tconn = GetConn(as, 0);
805 for (ti = as->parms[1].items; ti; ti = ti->next) {
806 if (as->parms[2].items) {
807 if (strlen(ti->data) > MAXHOSTCHARS - 3) {
808 fprintf(stderr, "bos: host name too long\n");
812 strcpy(&name[1], ti->data);
813 strcat((char *)&name, "]");
814 code = BOZO_AddCellHost(tconn, name);
816 code = BOZO_AddCellHost(tconn, ti->data);
818 printf("bos: failed to add host %s (%s)\n", ti->data, em(code));
825 register struct cmd_syndesc *as;
827 register struct rx_connection *tconn;
828 register afs_int32 code;
829 register struct cmd_item *ti;
831 tconn = GetConn(as, 0);
832 for (ti = as->parms[1].items; ti; ti = ti->next) {
833 code = BOZO_DeleteCellHost(tconn, ti->data);
835 printf("bos: failed to delete host %s (%s)\n", ti->data,
843 register struct cmd_syndesc *as;
845 register struct rx_connection *tconn;
846 register afs_int32 code;
849 register afs_int32 i;
852 tconn = GetConn(as, 0);
853 code = BOZO_GetCellName(tconn, &tp);
855 printf("bos: failed to get cell name (%s)\n", em(code));
858 printf("Cell name is %s\n", tbuffer);
860 code = BOZO_GetCellHost(tconn, i, &tp);
864 printf("bos: failed to get cell host %d (%s)\n", i, em(code));
867 printf(" Host %d is %s\n", i + 1, tbuffer);
874 register struct cmd_syndesc *as;
876 register struct rx_connection *tconn;
877 register afs_int32 code;
878 struct ktc_encryptionKey tkey;
881 char cellBuffer[256];
882 char buf[BUFSIZ], ver[BUFSIZ];
884 tconn = GetConn(as, 1);
885 memset(&tkey, 0, sizeof(struct ktc_encryptionKey));
887 if (as->parms[1].items)
888 strcpy(buf, as->parms[1].items->data);
891 code = des_read_pw_string(buf, sizeof(buf), "input key: ", 0);
892 if (code || strlen(buf) == 0) {
893 fprintf(stderr, "Bad key: \n");
896 code = des_read_pw_string(ver, sizeof(ver), "Retype input key: ", 0);
897 if (code || strlen(ver) == 0) {
898 fprintf(stderr, "Bad key: \n");
901 if (strcmp(ver, buf) != 0) {
902 fprintf(stderr, "\nInput key mismatch\n");
908 temp = atoi(as->parms[2].items->data);
912 strcpy((char *)&tkey, as->parms[1].items->data);
914 strcpy((char *)&tkey, buf);
915 } else { /* kerberos key */
916 if (as->parms[ADDPARMOFFSET].items) {
917 strcpy(cellBuffer, as->parms[ADDPARMOFFSET].items->data);
919 /* string to key needs upper-case cell names */
921 /* I don't believe this is true. The string to key function
922 * actually expands the cell name, then LOWER-CASES it. Perhaps it
923 * didn't use to??? */
924 ucstring(cellBuffer, cellBuffer, strlen(cellBuffer));
927 tcell = NULL; /* no cell specified, use current */
929 ka_StringToKey(as->parms[1].items->data, tcell, &tkey);
931 ka_StringToKey(buf, tcell, &tkey);
933 tconn = GetConn(as, 1);
934 code = BOZO_AddKey(tconn, temp, &tkey);
936 printf("bos: failed to set key %d (%s)\n", temp, em(code));
944 register struct cmd_syndesc *as;
946 register struct rx_connection *tconn;
947 register afs_int32 code;
949 register struct cmd_item *ti;
951 tconn = GetConn(as, 0);
952 for (ti = as->parms[1].items; ti; ti = ti->next) {
953 temp = atoi(ti->data);
954 code = BOZO_DeleteKey(tconn, temp);
956 printf("bos: failed to delete key %d (%s)\n", temp, em(code));
965 IN register struct cmd_syndesc *as;
967 register struct rx_connection *tconn;
968 register afs_int32 code;
969 struct ktc_encryptionKey tkey;
971 struct bozo_keyInfo keyInfo;
973 register afs_int32 i;
975 tconn = GetConn(as, 1);
978 code = BOZO_ListKeys(tconn, i, &kvno, &tkey, &keyInfo);
982 /* first check if key is returned */
983 if ((!ka_KeyIsZero(&tkey, sizeof(tkey))) && (as->parms[1].items)) {
984 printf("key %d is '", kvno);
985 ka_PrintBytes(&tkey, sizeof(tkey));
988 if (keyInfo.keyCheckSum == 0) /* shouldn't happen */
989 printf("key version is %d\n", kvno);
991 printf("key %d has cksum %u\n", kvno, keyInfo.keyCheckSum);
995 printf("Keys last changed on %s.\n", DateOf(keyInfo.mod_sec));
998 printf("bos: %s error encountered while listing keys\n", em(code));
1000 printf("All done.\n");
1006 register struct cmd_syndesc *as;
1008 register struct rx_connection *tconn;
1009 register afs_int32 code;
1011 register struct cmd_item *ti;
1014 tconn = GetConn(as, 0);
1015 for (ti = as->parms[1].items; ti; ti = ti->next) {
1016 code = BOZO_AddSUser(tconn, ti->data);
1018 printf("bos: failed to add user '%s' (%s)\n", ti->data, em(code));
1027 register struct cmd_syndesc *as;
1029 register struct rx_connection *tconn;
1030 register struct cmd_item *ti;
1031 register afs_int32 code;
1035 tconn = GetConn(as, 0);
1036 for (ti = as->parms[1].items; ti; ti = ti->next) {
1037 code = BOZO_DeleteSUser(tconn, ti->data);
1039 printf("bos: failed to delete user '%s', ", ti->data);
1041 printf("(no such user)\n");
1043 printf("(%s)\n", em(code));
1050 #define NPERLINE 10 /* dudes to print per line */
1053 register struct cmd_syndesc *as;
1055 register struct rx_connection *tconn;
1057 register afs_int32 code;
1060 int lastNL, printGreeting;
1062 tconn = GetConn(as, 0);
1067 code = BOZO_ListSUsers(tconn, i, &tp);
1070 if (printGreeting) {
1071 printGreeting = 0; /* delay until after first call succeeds */
1072 printf("SUsers are: ");
1074 printf("%s ", tbuffer);
1075 if ((i % NPERLINE) == NPERLINE - 1) {
1082 /* a real error code, instead of scanned past end */
1083 printf("bos: failed to retrieve super-user list (%s)\n", em(code));
1093 register struct cmd_syndesc *as;
1095 register struct rx_connection *tconn;
1096 register afs_int32 code;
1098 char ibuffer[BOZO_BSSIZE];
1102 /* int32p==1 is obsolete, smaller, printout */
1103 int32p = (as->parms[2].items != 0 ? 2 : 0);
1105 /* no parms does something pretty different */
1106 if (as->parms[1].items)
1107 return IStatServer(as, int32p);
1109 tconn = GetConn(as, 0);
1111 /* for each instance */
1113 code = BOZO_EnumerateInstance(tconn, i, &tp);
1117 printf("bos: failed to contact host's bosserver (%s).\n",
1121 DoStat(ibuffer, tconn, int32p, (i == 0)); /* print status line */
1128 register struct cmd_syndesc *as;
1130 register struct rx_connection *tconn;
1131 register afs_int32 code;
1133 register struct cmd_item *ti;
1135 char *type, *name, *notifier = NONOTIFIER;
1137 tconn = GetConn(as, 0);
1138 for (i = 0; i < 6; i++)
1140 for (i = 0, ti = as->parms[3].items; (ti && i < 6); ti = ti->next, i++) {
1141 parms[i] = ti->data;
1143 name = as->parms[1].items->data;
1144 type = as->parms[2].items->data;
1145 if (ti = as->parms[4].items) {
1146 notifier = ti->data;
1149 BOZO_CreateBnode(tconn, type, name, parms[0], parms[1], parms[2],
1150 parms[3], parms[4], notifier);
1153 ("bos: failed to create new server instance %s of type '%s' (%s)\n",
1154 name, type, em(code));
1161 register struct cmd_syndesc *as;
1163 register struct rx_connection *tconn;
1164 register afs_int32 code;
1165 register struct cmd_item *ti;
1168 tconn = GetConn(as, 0);
1169 for (ti = as->parms[1].items; ti; ti = ti->next) {
1170 code = BOZO_DeleteBnode(tconn, ti->data);
1173 printf("bos: can't delete running instance '%s'\n", ti->data);
1175 printf("bos: failed to delete instance '%s' (%s)\n", ti->data,
1184 register struct cmd_syndesc *as;
1186 register struct rx_connection *tconn;
1187 register afs_int32 code;
1188 register struct cmd_item *ti;
1191 tconn = GetConn(as, 0);
1192 for (ti = as->parms[1].items; ti; ti = ti->next) {
1193 code = BOZO_SetStatus(tconn, ti->data, BSTAT_NORMAL);
1195 printf("bos: failed to start instance '%s' (%s)\n", ti->data,
1203 register struct cmd_syndesc *as;
1205 register struct rx_connection *tconn;
1206 register afs_int32 code;
1207 register struct cmd_item *ti;
1210 tconn = GetConn(as, 0);
1211 for (ti = as->parms[1].items; ti; ti = ti->next) {
1212 code = BOZO_SetStatus(tconn, ti->data, BSTAT_SHUTDOWN);
1214 printf("bos: failed to change stop instance '%s' (%s)\n",
1215 ti->data, em(code));
1217 if (as->parms[8].items) {
1218 code = BOZO_WaitAll(tconn);
1220 printf("bos: can't wait for processes to shutdown (%s)\n",
1226 #define PARMBUFFERSSIZE 32
1229 DoSalvage(struct rx_connection * aconn, char * aparm1, char * aparm2,
1230 char * aoutName, afs_int32 showlog, char * parallel,
1231 char * atmpDir, char * orphans, int dafs,
1232 struct MRAFSSalvageParms * mrafsParm)
1234 register afs_int32 code;
1237 char tbuffer[BOZO_BSSIZE];
1238 struct bozo_status istatus;
1239 struct rx_call *tcall;
1243 char partName[20]; /* canonical name for partition */
1244 char pbuffer[PARMBUFFERSSIZE];
1245 afs_int32 partNumber;
1246 char *notifier = NONOTIFIER;
1248 /* if a partition was specified, canonicalize the name, since
1249 * the salvager has a stupid partition ID parser */
1251 partNumber = volutil_GetPartitionID(aparm1);
1252 if (partNumber < 0) {
1253 printf("bos: could not parse partition ID '%s'\n", aparm1);
1256 tp = volutil_PartitionName(partNumber);
1258 printf("bos: internal error parsing partition ID '%s'\n", aparm1);
1261 strcpy(partName, tp);
1265 /* open the file name */
1267 outFile = fopen(aoutName, "w");
1269 printf("bos: can't open specified SalvageLog file '%s'\n",
1273 closeIt = 1; /* close this file later */
1276 closeIt = 0; /* don't close this file later */
1279 for (code = 2; code < 6; code++)
1284 /* MUST pass canonical (wire-format) salvager path to bosserver */
1286 /* single volume salvage */
1288 /* for DAFS, we call the salvagserver binary with special options.
1289 * in this mode, it simply uses SALVSYNC to tell the currently
1290 * running salvageserver to offline and salvage the volume in question */
1291 strncpy(tbuffer, AFSDIR_CANONICAL_SERVER_SALSRV_FILEPATH, BOZO_BSSIZE);
1293 if ((strlen(tbuffer) + 9 + strlen(partName) + 1 + strlen(aparm2) +
1295 printf("bos: command line too big\n");
1299 strcat(tbuffer, " -client ");
1300 strcat(tbuffer, partName);
1301 strcat(tbuffer, " ");
1302 strcat(tbuffer, aparm2);
1304 strncpy(tbuffer, AFSDIR_CANONICAL_SERVER_SALVAGER_FILEPATH, BOZO_BSSIZE);
1306 if ((strlen(tbuffer) + 1 + strlen(partName) + 1 + strlen(aparm2) +
1308 printf("bos: command line too big\n");
1312 strcat(tbuffer, " ");
1313 strcat(tbuffer, partName);
1314 strcat(tbuffer, " ");
1315 strcat(tbuffer, aparm2);
1318 /* partition salvage */
1319 strncpy(tbuffer, AFSDIR_CANONICAL_SERVER_SALVAGER_FILEPATH, BOZO_BSSIZE);
1320 if ((strlen(tbuffer) + 4 + strlen(partName) + 1) > BOZO_BSSIZE) {
1321 printf("bos: command line too big\n");
1324 strcat(tbuffer, " -f ");
1325 strcat(tbuffer, partName);
1328 /* For DAFS, specifying a single volume does not result in a standard
1329 * salvager call. Instead, it simply results in a SALVSYNC call to the
1330 * online salvager daemon. This interface does not give us the same rich
1331 * set of call flags. Thus, we skip these steps for DAFS single-volume
1333 if (!dafs || (*aparm2 == 0)) {
1334 /* add the parallel option if given */
1335 if (parallel != NULL) {
1336 if ((strlen(tbuffer) + 11 + strlen(parallel) + 1) > BOZO_BSSIZE) {
1337 printf("bos: command line too big\n");
1340 strcat(tbuffer, " -parallel ");
1341 strcat(tbuffer, parallel);
1344 /* add the tmpdir option if given */
1345 if (atmpDir != NULL) {
1346 if ((strlen(tbuffer) + 9 + strlen(atmpDir) + 1) > BOZO_BSSIZE) {
1347 printf("bos: command line too big\n");
1350 strcat(tbuffer, " -tmpdir ");
1351 strcat(tbuffer, atmpDir);
1354 /* add the orphans option if given */
1355 if (orphans != NULL) {
1356 if ((strlen(tbuffer) + 10 + strlen(orphans) + 1) > BOZO_BSSIZE) {
1357 printf("bos: command line too big\n");
1360 strcat(tbuffer, " -orphans ");
1361 strcat(tbuffer, orphans);
1364 if (mrafsParm->Optdebug)
1365 strcat(tbuffer, " -debug");
1366 if (mrafsParm->Optnowrite)
1367 strcat(tbuffer, " -nowrite");
1368 if (mrafsParm->Optforce)
1369 strcat(tbuffer, " -force");
1370 if (mrafsParm->Optoktozap)
1371 strcat(tbuffer, " -oktozap");
1372 if (mrafsParm->Optrootfiles)
1373 strcat(tbuffer, " -rootfiles");
1374 if (mrafsParm->Optsalvagedirs)
1375 strcat(tbuffer, " -salvagedirs");
1376 if (mrafsParm->Optblockreads)
1377 strcat(tbuffer, " -blockreads");
1378 if (mrafsParm->OptListResidencies)
1379 strcat(tbuffer, " -ListResidencies");
1380 if (mrafsParm->OptSalvageRemote)
1381 strcat(tbuffer, " -SalvageRemote");
1382 if (mrafsParm->OptSalvageArchival)
1383 strcat(tbuffer, " -SalvageArchival");
1384 if (mrafsParm->OptIgnoreCheck)
1385 strcat(tbuffer, " -IgnoreCheck");
1386 if (mrafsParm->OptForceOnLine)
1387 strcat(tbuffer, " -ForceOnLine");
1388 if (mrafsParm->OptUseRootDirACL)
1389 strcat(tbuffer, " -UseRootDirACL");
1390 if (mrafsParm->OptTraceBadLinkCounts)
1391 strcat(tbuffer, " -TraceBadLinkCounts");
1392 if (mrafsParm->OptDontAskFS)
1393 strcat(tbuffer, " -DontAskFS");
1394 if (mrafsParm->OptLogLevel) {
1395 sprintf(pbuffer, " -LogLevel %ld", mrafsParm->OptLogLevel);
1396 strcat(tbuffer, pbuffer);
1398 if (mrafsParm->OptRxDebug)
1399 strcat(tbuffer, " -rxdebug");
1400 if (mrafsParm->OptResidencies) {
1401 sprintf(pbuffer, " -Residencies %lu", mrafsParm->OptResidencies);
1402 strcat(tbuffer, pbuffer);
1407 parms[1] = "now"; /* when to do it */
1409 BOZO_CreateBnode(aconn, "cron", "salvage-tmp", parms[0], parms[1],
1410 parms[2], parms[3], parms[4], notifier);
1412 printf("bos: failed to start 'salvager' (%s)\n", em(code));
1415 /* now wait for bnode to disappear */
1419 code = BOZO_GetInstanceInfo(aconn, "salvage-tmp", &tp, &istatus);
1422 printf("bos: waiting for salvage to complete.\n");
1424 if (code != BZNOENT) {
1425 printf("bos: salvage failed (%s)\n", em(code));
1430 /* now print the log file to the output file */
1431 printf("bos: salvage completed\n");
1432 if (aoutName || showlog) {
1433 fprintf(outFile, "SalvageLog:\n");
1434 tcall = rx_NewCall(aconn);
1435 /* MUST pass canonical (wire-format) salvager log path to bosserver */
1437 StartBOZO_GetLog(tcall, AFSDIR_CANONICAL_SERVER_SLVGLOG_FILEPATH);
1439 rx_EndCall(tcall, code);
1444 code = rx_Read(tcall, &buffer, 1);
1447 putc(buffer, outFile);
1449 break; /* the end delimeter */
1451 code = rx_EndCall(tcall, 0);
1452 /* fall through into cleanup code */
1456 if (closeIt && outFile)
1463 register struct cmd_syndesc *as;
1465 struct rx_connection *tconn;
1466 register struct rx_call *tcall;
1467 register afs_int32 code;
1471 printf("Fetching log file '%s'...\n", as->parms[1].items->data);
1472 tconn = GetConn(as, 0);
1473 tcall = rx_NewCall(tconn);
1474 code = StartBOZO_GetLog(tcall, as->parms[1].items->data);
1476 rx_EndCall(tcall, code);
1482 code = rx_Read(tcall, &buffer, 1);
1488 break; /* the end delimeter */
1491 code = rx_EndCall(tcall, error);
1492 /* fall through into cleanup code */
1496 com_err("bos", code, "(while reading log)");
1502 struct cmd_syndesc *as;
1504 register struct rx_connection *tconn;
1505 register afs_int32 code, rc, i;
1507 char tname[BOZO_BSSIZE];
1509 extern struct ubik_client *cstruct;
1510 afs_int32 curGoal, showlog = 0, dafs = 0, mrafs = 0;
1516 struct MRAFSSalvageParms mrafsParm;
1518 memset(&mrafsParm, 0, sizeof(mrafsParm));
1520 /* parm 0 is machine name, 1 is partition, 2 is volume, 3 is -all flag */
1521 tconn = GetConn(as, 0);
1525 /* find out whether fileserver is running demand attach fs */
1526 if (code = BOZO_GetInstanceParm(tconn, "dafs", 0, &tp) == 0) {
1528 serviceName = "dafs";
1529 /* Find out whether fileserver is running MR-AFS (has a scanner instance) */
1530 /* XXX this should really be done some other way, potentially by RPC */
1531 if (code = BOZO_GetInstanceParm(tconn, serviceName, 4, &tp) == 0)
1535 /* Find out whether fileserver is running MR-AFS (has a scanner instance) */
1536 /* XXX this should really be done some other way, potentially by RPC */
1537 if (code = BOZO_GetInstanceParm(tconn, serviceName, 3, &tp) == 0)
1541 /* we can do a volume, a partition or the whole thing, but not mixtures
1543 if (!as->parms[1].items && as->parms[2].items) {
1544 printf("bos: must specify partition to salvage individual volume.\n");
1547 if (as->parms[5].items && as->parms[3].items) {
1548 printf("bos: can not specify both -file and -showlog.\n");
1551 if (as->parms[4].items && (as->parms[1].items || as->parms[2].items)) {
1552 printf("bos: can not specify -all with other flags.\n");
1556 /* get the output file name, if any */
1557 if (as->parms[3].items)
1558 outName = as->parms[3].items->data;
1562 if (as->parms[5].items)
1565 /* parallel option */
1567 if (as->parms[6].items)
1568 parallel = as->parms[6].items->data;
1570 /* get the tmpdir filename if any */
1572 if (as->parms[7].items)
1573 tmpDir = as->parms[7].items->data;
1575 /* -orphans option */
1577 if (as->parms[8].items) {
1579 printf("Can't specify -orphans for MR-AFS fileserver\n");
1582 orphans = as->parms[8].items->data;
1586 if (!as->parms[9].items) { /* -forceDAFS flag */
1587 printf("This is a demand attach fileserver. Are you sure you want to proceed with a manual salvage?\n");
1588 printf("must specify -forceDAFS flag in order to proceed.\n");
1594 if (as->parms[MRAFS_OFFSET].items)
1595 mrafsParm.Optdebug = 1;
1596 if (as->parms[MRAFS_OFFSET + 1].items)
1597 mrafsParm.Optnowrite = 1;
1598 if (as->parms[MRAFS_OFFSET + 2].items)
1599 mrafsParm.Optforce = 1;
1600 if (as->parms[MRAFS_OFFSET + 3].items)
1601 mrafsParm.Optoktozap = 1;
1602 if (as->parms[MRAFS_OFFSET + 4].items)
1603 mrafsParm.Optrootfiles = 1;
1604 if (as->parms[MRAFS_OFFSET + 5].items)
1605 mrafsParm.Optsalvagedirs = 1;
1606 if (as->parms[MRAFS_OFFSET + 6].items)
1607 mrafsParm.Optblockreads = 1;
1608 if (as->parms[MRAFS_OFFSET + 7].items)
1609 mrafsParm.OptListResidencies = 1;
1610 if (as->parms[MRAFS_OFFSET + 8].items)
1611 mrafsParm.OptSalvageRemote = 1;
1612 if (as->parms[MRAFS_OFFSET + 9].items)
1613 mrafsParm.OptSalvageArchival = 1;
1614 if (as->parms[MRAFS_OFFSET + 10].items)
1615 mrafsParm.OptIgnoreCheck = 1;
1616 if (as->parms[MRAFS_OFFSET + 11].items)
1617 mrafsParm.OptForceOnLine = 1;
1618 if (as->parms[MRAFS_OFFSET + 12].items)
1619 mrafsParm.OptUseRootDirACL = 1;
1620 if (as->parms[MRAFS_OFFSET + 13].items)
1621 mrafsParm.OptTraceBadLinkCounts = 1;
1622 if (as->parms[MRAFS_OFFSET + 14].items)
1623 mrafsParm.OptDontAskFS = 1;
1624 if (as->parms[MRAFS_OFFSET + 15].items)
1625 mrafsParm.OptLogLevel =
1626 atoi(as->parms[MRAFS_OFFSET + 15].items->data);
1627 if (as->parms[MRAFS_OFFSET + 16].items)
1628 mrafsParm.OptRxDebug = 1;
1629 if (as->parms[MRAFS_OFFSET + 17].items) {
1630 if (as->parms[MRAFS_OFFSET + 8].items
1631 || as->parms[MRAFS_OFFSET + 9].items) {
1633 ("Can't specify -Residencies with -SalvageRemote or -SalvageArchival\n");
1637 util_GetUInt32(as->parms[MRAFS_OFFSET + 17].items->data,
1638 &mrafsParm.OptResidencies);
1640 printf("bos: '%s' is not a valid residency mask.\n",
1641 as->parms[MRAFS_OFFSET + 13].items->data);
1648 for (i = MRAFS_OFFSET; i < ADDPARMOFFSET; i++) {
1649 if (as->parms[i].items) {
1650 printf(" %s only possible for MR-AFS fileserver.\n",
1659 if (as->parms[4].items) {
1660 /* salvage whole enchilada */
1661 curGoal = GetServerGoal(tconn, serviceName);
1662 if (curGoal == BSTAT_NORMAL) {
1663 printf("bos: shutting down '%s'.\n", serviceName);
1664 code = BOZO_SetTStatus(tconn, serviceName, BSTAT_SHUTDOWN);
1666 printf("bos: failed to stop '%s' (%s)\n", serviceName, 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, NULL, NULL, outName, showlog, parallel, tmpDir,
1677 orphans, dafs, &mrafsParm);
1678 if (curGoal == BSTAT_NORMAL) {
1679 printf("bos: restarting %s.\n", serviceName);
1680 code = BOZO_SetTStatus(tconn, serviceName, BSTAT_NORMAL);
1682 printf("bos: failed to restart '%s' (%s)\n", serviceName, em(code));
1688 } else if (!as->parms[2].items) {
1689 if (!as->parms[1].items) {
1691 ("bos: must specify -all switch to salvage all partitions.\n");
1694 if (volutil_GetPartitionID(as->parms[1].items->data) < 0) {
1695 /* can't parse volume ID, so complain before shutting down
1698 printf("bos: can't interpret %s as partition ID.\n",
1699 as->parms[1].items->data);
1702 curGoal = GetServerGoal(tconn, serviceName);
1703 /* salvage a whole partition (specified by parms[1]) */
1704 if (curGoal == BSTAT_NORMAL) {
1705 printf("bos: shutting down '%s'.\n", serviceName);
1706 code = BOZO_SetTStatus(tconn, serviceName, BSTAT_SHUTDOWN);
1708 printf("bos: can't stop '%s' (%s)\n", serviceName, em(code));
1711 code = BOZO_WaitAll(tconn); /* wait for shutdown to complete */
1714 ("bos: failed to wait for file server shutdown, continuing.\n");
1716 /* now do the salvage operation */
1717 printf("Starting salvage.\n");
1718 rc = DoSalvage(tconn, as->parms[1].items->data, NULL, outName,
1719 showlog, parallel, tmpDir, orphans, dafs, &mrafsParm);
1720 if (curGoal == BSTAT_NORMAL) {
1721 printf("bos: restarting '%s'.\n", serviceName);
1722 code = BOZO_SetTStatus(tconn, serviceName, BSTAT_NORMAL);
1724 printf("bos: failed to restart '%s' (%s)\n", serviceName, em(code));
1731 /* salvage individual volume (don't shutdown fs first), just use
1732 * single-shot cron bnode. Must leave server running when using this
1733 * option, since salvager will ask file server for the volume */
1736 const char *confdir;
1739 if (as->parms[ADDPARMOFFSET].items)
1740 tmpname = as->parms[ADDPARMOFFSET].items->data;
1744 localauth = (as->parms[ADDPARMOFFSET + 2].items != 0);
1746 (localauth ? AFSDIR_SERVER_ETC_DIRPATH :
1747 AFSDIR_CLIENT_ETC_DIRPATH);
1748 code = vsu_ClientInit( /* noauth */ 1, confdir, tmpname,
1749 /* server auth */ 0, &cstruct, (int (*)())0);
1751 newID = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err);
1753 printf("bos: can't interpret %s as volume name or ID\n",
1754 as->parms[2].items->data);
1757 sprintf(tname, "%u", newID);
1760 ("bos: can't initialize volume system client (code %d), trying anyway.\n",
1762 strncpy(tname, as->parms[2].items->data, sizeof(tname));
1764 if (volutil_GetPartitionID(as->parms[1].items->data) < 0) {
1765 /* can't parse volume ID, so complain before shutting down
1768 printf("bos: can't interpret %s as partition ID.\n",
1769 as->parms[1].items->data);
1772 printf("Starting salvage.\n");
1773 rc = DoSalvage(tconn, as->parms[1].items->data, tname, outName,
1774 showlog, parallel, tmpDir, orphans, dafs, &mrafsParm);
1782 IStatServer(as, int32p)
1784 register struct cmd_syndesc *as;
1786 register struct rx_connection *tconn;
1787 register struct cmd_item *ti;
1790 tconn = GetConn(as, 0);
1791 for (ti = as->parms[1].items; ti; ti = ti->next) {
1792 DoStat(ti->data, tconn, int32p, firstTime);
1799 DoStat(aname, aconn, aint32p, firstTime)
1801 IN register struct rx_connection *aconn;
1803 IN int firstTime; /* true iff first instance in cmd */
1807 register afs_int32 code;
1808 register afs_int32 i;
1809 struct bozo_status istatus;
1811 char *is1, *is2, *is3, *is4; /* instance strings */
1814 code = BOZO_GetInstanceInfo(aconn, aname, &tp, &istatus);
1816 printf("bos: failed to get instance info for '%s' (%s)\n", aname,
1820 if (firstTime && aint32p && (istatus.flags & BOZO_BADDIRACCESS))
1822 ("Bosserver reports inappropriate access on server directories\n");
1823 printf("Instance %s, ", aname);
1825 printf("(type is %s) ", buffer);
1826 if (istatus.fileGoal == istatus.goal) {
1828 printf("disabled, ");
1830 if (istatus.fileGoal)
1831 printf("temporarily disabled, ");
1833 printf("temporarily enabled, ");
1836 if (istatus.flags & BOZO_ERRORSTOP)
1837 printf("stopped for too many errors, ");
1838 if (istatus.flags & BOZO_HASCORE)
1839 printf("has core file, ");
1842 code = BOZO_GetStatus(aconn, aname, &temp, &tp);
1844 printf("bos: failed to get status for instance '%s' (%s)\n", aname,
1847 printf("currently ");
1848 if (temp == BSTAT_NORMAL)
1849 printf("running normally.\n");
1850 else if (temp == BSTAT_SHUTDOWN)
1851 printf("shutdown.\n");
1852 else if (temp == BSTAT_STARTINGUP)
1853 printf("starting up.\n");
1854 else if (temp == BSTAT_SHUTTINGDOWN)
1855 printf("shutting down.\n");
1856 if (buffer[0] != 0) {
1857 printf(" Auxiliary status is: %s.\n", buffer);
1861 /* are we done yet? */
1865 if (istatus.procStartTime)
1866 printf(" Process last started at %s (%d proc starts)\n",
1867 DateOf(istatus.procStartTime), istatus.procStarts);
1868 if (istatus.lastAnyExit) {
1869 printf(" Last exit at %s\n", DateOf(istatus.lastAnyExit));
1871 if (istatus.lastErrorExit) {
1872 is1 = is2 = is3 = is4 = NULL;
1873 printf(" Last error exit at %s, ", DateOf(istatus.lastErrorExit));
1874 code = BOZO_GetInstanceStrings(aconn, aname, &is1, &is2, &is3, &is4);
1875 /* don't complain about failing call, since could simply mean
1876 * interface mismatch.
1880 /* non-null instance string */
1881 printf("by %s, ", is1);
1888 if (istatus.errorSignal) {
1889 if (istatus.errorSignal == SIGTERM)
1890 printf("due to shutdown request\n");
1892 printf("due to signal %d\n", istatus.errorSignal);
1894 printf("by exiting with code %d\n", istatus.errorCode);
1898 /* try to display all the parms */
1901 code = BOZO_GetInstanceParm(aconn, aname, i, &tp);
1904 printf(" Command %d is '%s'\n", i + 1, buffer);
1907 code = BOZO_GetInstanceParm(aconn, aname, 999, &tp);
1909 /* Any type of failure is treated as not having a notifier program */
1910 printf(" Notifier is '%s'\n", buffer);
1917 #ifdef BOS_RESTRICTED_MODE
1920 struct cmd_syndesc *as;
1922 register struct rx_connection *tconn;
1923 afs_int32 code, val;
1925 tconn = GetConn(as, 0);
1926 code = BOZO_GetRestrictedMode(tconn, &val);
1928 printf("bos: failed to get restricted mode (%s)\n", em(code));
1930 printf("Restricted mode is %s\n", val ? "on" : "off");
1937 struct cmd_syndesc *as;
1939 register struct rx_connection *tconn;
1940 afs_int32 code, val;
1942 tconn = GetConn(as, 0);
1943 util_GetInt32(as->parms[1].items->data, &val);
1944 code = BOZO_SetRestrictedMode(tconn, val);
1946 printf("bos: failed to set restricted mode (%s)\n", em(code));
1953 register struct cmd_syndesc *ts;
1955 cmd_Seek(ts, ADDPARMOFFSET);
1956 /* + 0 */ cmd_AddParm(ts, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell name");
1957 /* + 1 */ cmd_AddParm(ts, "-noauth", CMD_FLAG, CMD_OPTIONAL,
1958 "don't authenticate");
1959 /* + 2 */ cmd_AddParm(ts, "-localauth", CMD_FLAG, CMD_OPTIONAL,
1960 "create tickets from KeyFile");
1963 #include "AFS_component_version_number.c"
1969 register afs_int32 code;
1970 register struct cmd_syndesc *ts;
1971 extern int afsconf_SawCell;
1973 #ifdef AFS_AIX32_ENV
1975 * The following signal action for AIX is necessary so that in case of a
1976 * crash (i.e. core is generated) we can include the user's data section
1977 * in the core dump. Unfortunately, by default, only a partial core is
1978 * generated which, in many cases, isn't too useful.
1980 struct sigaction nsa;
1982 sigemptyset(&nsa.sa_mask);
1983 nsa.sa_handler = SIG_DFL;
1984 nsa.sa_flags = SA_FULLDUMP;
1985 sigaction(SIGSEGV, &nsa, NULL);
1986 sigaction(SIGABRT, &nsa, NULL);
1992 printf("bos: could not initialize rx (%s)\n", em(code));
1996 /* To resolve a AFSCELL environment "Note: ..." problem: Because bos calls ka_Init (why?) before any
1997 * checkup on the existance of a "-cell" option on the particular bos command we don't print the
1998 * message if a cell is passed in. Luckily the rest of the programs don't call these adhoc routines
1999 * and things work fine. Note that if the "-cell" isn't passed then we're still ok since later on
2000 * the proper routine (afsconf_GetCellInfo) is going to be called to do the right thing.
2002 afsconf_SawCell = 1; /* Means don't print warning if AFSCELL is set */
2004 afsconf_SawCell = 0; /* Reset it */
2005 /* don't check error code, since fails sometimes when we're setting up a
2007 initialize_CMD_error_table();
2008 initialize_BZ_error_table();
2010 ts = cmd_CreateSyntax("start", StartServer, 0, "start running a server");
2011 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2012 cmd_AddParm(ts, "-instance", CMD_LIST, 0, "server process name");
2015 ts = cmd_CreateSyntax("stop", StopServer, 0, "halt a server instance");
2016 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2017 cmd_AddParm(ts, "-instance", CMD_LIST, 0, "server process name");
2019 cmd_AddParm(ts, "-wait", CMD_FLAG, CMD_OPTIONAL,
2020 "wait for process to stop");
2023 ts = cmd_CreateSyntax("status", StatServer, 0,
2024 "show server instance status");
2025 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2026 cmd_AddParm(ts, "-instance", CMD_LIST, CMD_OPTIONAL,
2027 "server process name");
2028 cmd_AddParm(ts, "-long", CMD_FLAG, CMD_OPTIONAL, "long status");
2031 ts = cmd_CreateSyntax("shutdown", Shutdown, 0, "shutdown all processes");
2032 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2033 cmd_AddParm(ts, "-instance", CMD_LIST, CMD_OPTIONAL, "instances");
2035 cmd_AddParm(ts, "-wait", CMD_FLAG, CMD_OPTIONAL,
2036 "wait for process to stop");
2039 ts = cmd_CreateSyntax("startup", Startup, 0, "start all processes");
2040 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2041 cmd_AddParm(ts, "-instance", CMD_LIST, CMD_OPTIONAL, "instances");
2044 ts = cmd_CreateSyntax("restart", Restart, 0, "restart processes");
2045 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2046 cmd_AddParm(ts, "-instance", CMD_LIST, CMD_OPTIONAL, "instances");
2047 cmd_AddParm(ts, "-bosserver", CMD_FLAG, CMD_OPTIONAL,
2048 "restart bosserver");
2049 cmd_AddParm(ts, "-all", CMD_FLAG, CMD_OPTIONAL, "restart all processes");
2054 ts = cmd_CreateSyntax("create", CreateServer, 0,
2055 "create a new server instance");
2056 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2057 cmd_AddParm(ts, "-instance", CMD_SINGLE, 0, "server process name");
2058 cmd_AddParm(ts, "-type", CMD_SINGLE, 0, "server type");
2059 cmd_AddParm(ts, "-cmd", CMD_LIST, 0, "command lines");
2060 cmd_AddParm(ts, "-notifier", CMD_SINGLE, CMD_OPTIONAL,
2061 "Notifier program");
2064 ts = cmd_CreateSyntax("delete", DeleteServer, 0,
2065 "delete a server instance");
2066 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2067 cmd_AddParm(ts, "-instance", CMD_LIST, 0, "server process name");
2070 ts = cmd_CreateSyntax("adduser", AddSUser, 0,
2071 "add users to super-user list");
2072 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2073 cmd_AddParm(ts, "-user", CMD_LIST, 0, "user names");
2076 ts = cmd_CreateSyntax("removeuser", RemoveSUser, 0,
2077 "remove users from super-user list");
2078 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2079 cmd_AddParm(ts, "-user", CMD_LIST, 0, "user names");
2082 ts = cmd_CreateSyntax("listusers", ListSUsers, 0, "list super-users");
2083 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2086 ts = cmd_CreateSyntax("addkey", AddKey, 0,
2087 "add keys to key dbase (kvno 999 is bcrypt)");
2088 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2089 cmd_AddParm(ts, "-key", CMD_SINGLE, CMD_OPTIONAL, "key");
2090 cmd_AddParm(ts, "-kvno", CMD_SINGLE, 0, "key version number");
2093 ts = cmd_CreateSyntax("removekey", RemoveKey, 0,
2094 "remove keys from key dbase");
2095 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2096 cmd_AddParm(ts, "-kvno", CMD_LIST, 0, "key version number");
2099 ts = cmd_CreateSyntax("listkeys", ListKeys, 0, "list keys");
2100 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2101 cmd_AddParm(ts, "-showkey", CMD_FLAG, CMD_OPTIONAL,
2102 "show the actual key rather than the checksum");
2105 ts = cmd_CreateSyntax("listhosts", ListHosts, 0, "get cell host list");
2106 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2108 cmd_CreateAlias(ts, "getcell");
2110 ts = cmd_CreateSyntax("setcellname", SetCellName, 0, "set cell name");
2111 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2112 cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "cell name");
2115 ts = cmd_CreateSyntax("addhost", AddHost, 0, "add host to cell dbase");
2116 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2117 cmd_AddParm(ts, "-host", CMD_LIST, 0, "host name");
2118 cmd_AddParm(ts, "-clone", CMD_FLAG, CMD_OPTIONAL, "vote doesn't count");
2121 ts = cmd_CreateSyntax("removehost", RemoveHost, 0,
2122 "remove host from cell dbase");
2123 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2124 cmd_AddParm(ts, "-host", CMD_LIST, 0, "host name");
2127 ts = cmd_CreateSyntax("setauth", SetAuth, 0,
2128 "set authentication required flag");
2129 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2130 cmd_AddParm(ts, "-authrequired", CMD_SINGLE, 0,
2131 "on or off: authentication required for admin requests");
2134 ts = cmd_CreateSyntax("install", Install, 0, "install program");
2135 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2136 cmd_AddParm(ts, "-file", CMD_LIST, 0, "files to install");
2137 cmd_AddParm(ts, "-dir", CMD_SINGLE, CMD_OPTIONAL, "destination dir");
2140 ts = cmd_CreateSyntax("uninstall", UnInstall, 0, "uninstall program");
2141 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2142 cmd_AddParm(ts, "-file", CMD_LIST, 0, "files to uninstall");
2143 cmd_AddParm(ts, "-dir", CMD_SINGLE, CMD_OPTIONAL, "destination dir");
2146 ts = cmd_CreateSyntax("getlog", GetLogCmd, 0, "examine log file");
2147 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2148 cmd_AddParm(ts, "-file", CMD_SINGLE, 0, "log file to examine");
2151 ts = cmd_CreateSyntax("getdate", GetDate, 0, "get dates for programs");
2152 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2153 cmd_AddParm(ts, "-file", CMD_LIST, 0, "files to check");
2154 cmd_AddParm(ts, "-dir", CMD_SINGLE, CMD_OPTIONAL, "destination dir");
2157 ts = cmd_CreateSyntax("exec", Exec, 0, "execute shell command on server");
2158 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2159 cmd_AddParm(ts, "-cmd", CMD_SINGLE, 0, "command to execute");
2162 ts = cmd_CreateSyntax("prune", Prune, 0, "prune server files");
2163 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2164 cmd_AddParm(ts, "-bak", CMD_FLAG, CMD_OPTIONAL, "delete .BAK files");
2165 cmd_AddParm(ts, "-old", CMD_FLAG, CMD_OPTIONAL, "delete .OLD files");
2166 cmd_AddParm(ts, "-core", CMD_FLAG, CMD_OPTIONAL, "delete core files");
2167 cmd_AddParm(ts, "-all", CMD_FLAG, CMD_OPTIONAL, "delete all junk files");
2170 ts = cmd_CreateSyntax("setrestart", SetRestartCmd, 0,
2171 "set restart times");
2172 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_REQUIRED, "machine name");
2173 cmd_AddParm(ts, "-time", CMD_SINGLE, CMD_REQUIRED,
2174 "time to restart server");
2175 cmd_AddParm(ts, "-general", CMD_FLAG, CMD_OPTIONAL,
2176 "set general restart time");
2177 cmd_AddParm(ts, "-newbinary", CMD_FLAG, CMD_OPTIONAL,
2178 "set new binary restart time");
2181 ts = cmd_CreateSyntax("getrestart", GetRestartCmd, 0,
2182 "get restart times");
2183 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_REQUIRED, "machine name");
2186 ts = cmd_CreateSyntax("salvage", SalvageCmd, 0,
2187 "salvage partition or volumes");
2188 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2189 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL,
2190 "salvage partition");
2191 cmd_AddParm(ts, "-volume", CMD_SINGLE, CMD_OPTIONAL,
2192 "salvage volume number or volume name");
2193 cmd_AddParm(ts, "-file", CMD_SINGLE, CMD_OPTIONAL,
2194 "salvage log output file");
2195 cmd_AddParm(ts, "-all", CMD_FLAG, CMD_OPTIONAL, "salvage whole server");
2196 cmd_AddParm(ts, "-showlog", CMD_FLAG, CMD_OPTIONAL,
2197 "display salvage log");
2198 cmd_AddParm(ts, "-parallel", CMD_SINGLE, CMD_OPTIONAL,
2199 "# of max parallel partition salvaging");
2200 cmd_AddParm(ts, "-tmpdir", CMD_SINGLE, CMD_OPTIONAL,
2201 "directory to place tmp files");
2202 cmd_AddParm(ts, "-orphans", CMD_SINGLE, CMD_OPTIONAL,
2203 "ignore | remove | attach");
2204 cmd_AddParm(ts, "-forceDAFS", CMD_FLAG, CMD_OPTIONAL,
2205 "(DAFS) force salvage of demand attach fileserver");
2206 cmd_AddParm(ts, "-debug", CMD_FLAG, CMD_OPTIONAL,
2207 "(MR-AFS) Run in Debugging mode");
2208 cmd_AddParm(ts, "-nowrite", CMD_FLAG, CMD_OPTIONAL,
2209 "(MR-AFS) Run readonly/test mode");
2210 cmd_AddParm(ts, "-force", CMD_FLAG, CMD_OPTIONAL,
2211 "(MR-AFS) Force full salvaging");
2212 cmd_AddParm(ts, "-oktozap", CMD_FLAG, CMD_OPTIONAL,
2213 "(MR-AFS) Give permission to destroy bogus file residencies/volumes - debugging flag");
2214 cmd_AddParm(ts, "-rootfiles", CMD_FLAG, CMD_OPTIONAL,
2215 "(MR-AFS) Show files owned by root - debugging flag");
2216 cmd_AddParm(ts, "-salvagedirs", CMD_FLAG, CMD_OPTIONAL,
2217 "(MR-AFS) Force rebuild/salvage of all directories");
2218 cmd_AddParm(ts, "-blockreads", CMD_FLAG, CMD_OPTIONAL,
2219 "(MR-AFS) Read smaller blocks to handle IO/bad blocks");
2220 cmd_AddParm(ts, "-ListResidencies", CMD_FLAG, CMD_OPTIONAL,
2221 "(MR-AFS) Just list affected file residencies - debugging flag");
2222 cmd_AddParm(ts, "-SalvageRemote", CMD_FLAG, CMD_OPTIONAL,
2223 "(MR-AFS) Salvage storage systems that are not directly attached");
2224 cmd_AddParm(ts, "-SalvageArchival", CMD_FLAG, CMD_OPTIONAL,
2225 "(MR-AFS) Salvage HSM storage systems");
2226 cmd_AddParm(ts, "-IgnoreCheck", CMD_FLAG, CMD_OPTIONAL,
2227 "(MR-AFS) Don't perform VLDB safety check when deleting unreferenced files. Only a good idea in single server cell.");
2228 cmd_AddParm(ts, "-ForceOnLine", CMD_FLAG, CMD_OPTIONAL,
2229 "(MR-AFS) Force the volume to come online, even if it hasn't salvaged cleanly.");
2230 cmd_AddParm(ts, "-UseRootDirACL", CMD_FLAG, CMD_OPTIONAL,
2231 "(MR-AFS) Use the root directory ACL for lost+found directory if it is created.");
2232 cmd_AddParm(ts, "-TraceBadLinkCounts", CMD_FLAG, CMD_OPTIONAL,
2233 "(MR-AFS) Print out lines about volume reference count changes.");
2234 cmd_AddParm(ts, "-DontAskFS", CMD_FLAG, CMD_OPTIONAL,
2235 "(MR-AFS) Don't ask fileserver to take volume offline. THIS IS VERY DANGEROUS.");
2236 cmd_AddParm(ts, "-LogLevel", CMD_SINGLE, CMD_OPTIONAL,
2237 "(MR-AFS) log level");
2238 cmd_AddParm(ts, "-rxdebug", CMD_FLAG, CMD_OPTIONAL,
2239 "(MR-AFS) Write out rx debug information.");
2240 cmd_AddParm(ts, "-Residencies", CMD_SINGLE, CMD_OPTIONAL,
2241 "(MR-AFS) Numeric mask of residencies to be included in the salvage. Do not use with -SalvageRemote or -SalvageArchival");
2244 ts = cmd_CreateSyntax("blockscanner", BlockScannerCmd, 0,
2245 "block scanner daemon from making migration requests");
2246 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_REQUIRED, "machine name");
2249 ts = cmd_CreateSyntax("unblockscanner", UnBlockScannerCmd, 0,
2250 "allow scanner daemon to make migration requests again");
2251 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_REQUIRED, "machine name");
2254 #ifdef BOS_RESTRICTED_MODE
2255 ts = cmd_CreateSyntax("getrestricted", GetRestrict, 0,
2256 "get restrict mode");
2257 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2260 ts = cmd_CreateSyntax("setrestricted", SetRestrict, 0,
2261 "set restrict mode");
2262 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2263 cmd_AddParm(ts, "-mode", CMD_SINGLE, 0, "mode to set");
2268 code = cmd_Dispatch(argc, argv);