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 *)afs_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 afs_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 afs_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 afs_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 afs_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]);
282 SetAuth(struct cmd_syndesc *as, void *arock)
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 afs_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);
352 Prune(register struct cmd_syndesc *as, void *arock)
354 register afs_int32 code;
355 register struct rx_connection *tconn;
356 register afs_int32 flags;
358 tconn = GetConn(as, 0);
360 if (as->parms[1].items)
361 flags |= BOZO_PRUNEBAK;
362 if (as->parms[2].items)
363 flags |= BOZO_PRUNEOLD;
364 if (as->parms[3].items)
365 flags |= BOZO_PRUNECORE;
366 if (as->parms[4].items)
368 code = BOZO_Prune(tconn, flags);
370 afs_com_err("bos", code, "(failed to prune server files)");
375 Exec(register struct cmd_syndesc *as, void *arock)
377 register struct rx_connection *tconn;
378 register afs_int32 code;
380 tconn = GetConn(as, 0);
381 code = BOZO_Exec(tconn, as->parms[1].items->data);
383 printf("bos: failed to execute command (%s)\n", em(code));
388 GetDate(register struct cmd_syndesc *as, void *arock)
390 register afs_int32 code;
393 afs_int32 time, bakTime, oldTime;
394 register struct rx_connection *tconn;
395 register struct cmd_item *ti;
397 tconn = GetConn(as, 0);
398 if (!as->parms[1].items) {
399 printf("bos: no files to check\n");
403 /* compute dest dir or file; default MUST be canonical form of dir path */
404 if (as->parms[2].items)
405 strcpy(destDir, as->parms[2].items->data);
407 strcpy(destDir, AFSDIR_CANONICAL_SERVER_BIN_DIRPATH);
409 for (ti = as->parms[1].items; ti; ti = ti->next) {
410 /* check date for each file */
411 ComputeDestDir(ti->data, destDir, tbuffer, sizeof(tbuffer));
412 code = BOZO_GetDates(tconn, tbuffer, &time, &bakTime, &oldTime);
414 printf("bos: failed to check date on %s (%s)\n", ti->data,
418 printf("File %s ", tbuffer);
420 printf("does not exist, ");
422 printf("dated %s, ", DateOf(time));
424 printf("no .BAK file, ");
426 printf(".BAK file dated %s, ", DateOf(bakTime));
428 printf("no .OLD file.");
430 printf(".OLD file dated %s.", DateOf(oldTime));
438 UnInstall(register struct cmd_syndesc *as, void *arock)
440 register afs_int32 code;
443 register struct cmd_item *ti;
444 register struct rx_connection *tconn;
446 tconn = GetConn(as, 0);
447 if (!as->parms[1].items) {
448 printf("bos: no files to uninstall\n");
452 /* compute dest dir or file; default MUST be canonical form of dir path */
453 if (as->parms[2].items)
454 strcpy(destDir, as->parms[2].items->data);
456 strcpy(destDir, AFSDIR_CANONICAL_SERVER_BIN_DIRPATH);
458 for (ti = as->parms[1].items; ti; ti = ti->next) {
459 /* uninstall each file */
460 ComputeDestDir(ti->data, destDir, tbuffer, sizeof(tbuffer));
461 code = BOZO_UnInstall(tconn, tbuffer);
463 printf("bos: failed to uninstall %s (%s)\n", ti->data, em(code));
466 printf("bos: uninstalled file %s\n", ti->data);
472 GetServerGoal(aconn, aname)
474 struct rx_connection *aconn;
478 register afs_int32 code;
479 struct bozo_status istatus;
482 code = BOZO_GetInstanceInfo(aconn, aname, &tp, &istatus);
484 printf("bos: failed to get instance info for '%s' (%s)\n", aname,
486 /* if we can't get the answer, assume its running */
489 if (istatus.goal == 0)
490 return BSTAT_SHUTDOWN;
496 Install(struct cmd_syndesc *as, void *arock)
498 struct rx_connection *tconn;
499 register afs_int32 code;
500 register struct cmd_item *ti;
504 struct rx_call *tcall;
507 tconn = GetConn(as, 0);
508 if (!as->parms[1].items) {
509 printf("bos: no files to install\n");
513 /* compute dest dir or file; default MUST be canonical form of dir path */
514 if (as->parms[2].items)
515 strcpy(destDir, as->parms[2].items->data);
517 strcpy(destDir, AFSDIR_CANONICAL_SERVER_BIN_DIRPATH);
519 for (ti = as->parms[1].items; ti; ti = ti->next) {
520 /* install each file */
521 fd = open(ti->data, O_RDONLY);
523 /* better to quit on error than continue for install command */
524 printf("bos: can't find file '%s', quitting\n", ti->data);
527 code = fstat(fd, &tstat);
529 printf("bos: failed to stat file %s, errno is %d\n", ti->data,
533 /* compute destination dir */
534 ComputeDestDir(ti->data, destDir, tbuffer, sizeof(tbuffer));
535 tcall = rx_NewCall(tconn);
537 StartBOZO_Install(tcall, tbuffer, tstat.st_size,
538 (afs_int32) tstat.st_mode, tstat.st_mtime);
540 code = CopyBytes(fd, tcall);
542 code = rx_EndCall(tcall, code);
544 printf("bos: failed to install %s (%s)\n", ti->data, em(code));
547 printf("bos: installed file %s\n", ti->data);
553 Shutdown(struct cmd_syndesc *as, void *arock)
555 register struct rx_connection *tconn;
556 register afs_int32 code;
557 register struct cmd_item *ti;
559 tconn = GetConn(as, 0);
560 if (as->parms[1].items == 0) {
561 code = BOZO_ShutdownAll(tconn);
563 printf("bos: failed to shutdown servers (%s)\n", em(code));
565 for (ti = as->parms[1].items; ti; ti = ti->next) {
566 code = BOZO_SetTStatus(tconn, ti->data, BSTAT_SHUTDOWN);
568 printf("bos: failed to shutdown instance %s (%s)\n", ti->data,
572 if (as->parms[8].items) {
573 code = BOZO_WaitAll(tconn);
575 printf("bos: can't wait for processes to shutdown (%s)\n",
582 BlockScannerCmd(struct cmd_syndesc *as, void *arock)
584 register afs_int32 code;
585 struct rx_connection *tconn;
586 char BlockCommand[] = "/usr/afs/bin/scanner -block";
588 tconn = GetConn(as, 0);
589 code = BOZO_Exec(tconn, BlockCommand);
592 ("bos: failed to block scanner from making migration requests (%s)\n",
598 UnBlockScannerCmd(struct cmd_syndesc *as, void *arock)
600 register afs_int32 code;
601 struct rx_connection *tconn;
602 char UnBlockCommand[] = "/usr/afs/bin/scanner -unblock";
604 tconn = GetConn(as, 0);
605 code = BOZO_Exec(tconn, UnBlockCommand);
608 ("bos: failed to allow scanner daemon to make migration requests again (%s)\n",
614 GetRestartCmd(struct cmd_syndesc *as, void *arock)
616 register afs_int32 code;
617 struct ktime generalTime, newBinaryTime;
618 char messageBuffer[256];
619 struct rx_connection *tconn;
622 hostp = as->parms[0].items->data; /* host name for messages */
623 tconn = GetConn(as, 0);
625 code = BOZO_GetRestartTime(tconn, 1, &generalTime);
627 printf("bos: failed to retrieve restart information (%s)\n",
631 code = BOZO_GetRestartTime(tconn, 2, &newBinaryTime);
633 printf("bos: failed to retrieve restart information (%s)\n",
638 code = ktime_DisplayString(&generalTime, messageBuffer);
640 printf("bos: failed to decode restart time (%s)\n", em(code));
643 printf("Server %s restarts %s\n", hostp, messageBuffer);
645 code = ktime_DisplayString(&newBinaryTime, messageBuffer);
647 printf("bos: failed to decode restart time (%s)\n", em(code));
650 printf("Server %s restarts for new binaries %s\n", hostp, messageBuffer);
657 SetRestartCmd(struct cmd_syndesc *as, void *arock)
660 register afs_int32 code;
661 struct ktime restartTime;
663 struct rx_connection *tconn;
666 tconn = GetConn(as, 0);
667 if (as->parms[2].items) {
671 if (as->parms[3].items) {
676 printf("bos: can't specify more than one restart time at a time\n");
680 type = 1; /* by default set general restart time */
682 if (code = ktime_ParsePeriodic(as->parms[1].items->data, &restartTime)) {
683 printf("bos: failed to parse '%s' as periodic restart time(%s)\n",
684 as->parms[1].items->data, em(code));
688 code = BOZO_SetRestartTime(tconn, type, &restartTime);
690 printf("bos: failed to set restart time at server (%s)\n", em(code));
697 Startup(struct cmd_syndesc *as, void *arock)
699 register struct rx_connection *tconn;
700 register afs_int32 code;
701 register struct cmd_item *ti;
703 tconn = GetConn(as, 0);
704 if (as->parms[1].items == 0) {
705 code = BOZO_StartupAll(tconn);
707 printf("bos: failed to startup servers (%s)\n", em(code));
709 for (ti = as->parms[1].items; ti; ti = ti->next) {
710 code = BOZO_SetTStatus(tconn, ti->data, BSTAT_NORMAL);
712 printf("bos: failed to start instance %s (%s)\n", ti->data,
720 Restart(struct cmd_syndesc *as, void *arock)
722 register struct rx_connection *tconn;
723 register afs_int32 code;
724 register struct cmd_item *ti;
726 tconn = GetConn(as, 0);
727 if (as->parms[2].items) {
728 /* this is really a rebozo command */
729 if (as->parms[1].items) {
730 /* specified specific things to restart, can't do this at the same
733 ("bos: can't specify both '-bos' and specific servers to restart.\n");
736 /* otherwise do a rebozo */
737 code = BOZO_ReBozo(tconn);
739 printf("bos: failed to restart bosserver (%s)\n", em(code));
742 if (as->parms[1].items == 0) {
743 if (as->parms[3].items) { /* '-all' */
744 code = BOZO_RestartAll(tconn);
746 printf("bos: failed to restart servers (%s)\n", em(code));
748 printf("bos: To restart all processes please specify '-all'\n");
750 if (as->parms[3].items) {
751 printf("bos: Can't use '-all' along with individual instances\n");
753 for (ti = as->parms[1].items; ti; ti = ti->next) {
754 code = BOZO_Restart(tconn, ti->data);
756 printf("bos: failed to restart instance %s (%s)\n",
765 SetCellName(struct cmd_syndesc *as, void *arock)
767 register struct rx_connection *tconn;
768 register afs_int32 code;
770 tconn = GetConn(as, 0);
771 code = BOZO_SetCellName(tconn, as->parms[1].items->data);
773 printf("bos: failed to set cell (%s)\n", em(code));
778 AddHost(register struct cmd_syndesc *as, void *arock)
780 register struct rx_connection *tconn;
781 register afs_int32 code;
782 register struct cmd_item *ti;
783 char name[MAXHOSTCHARS];
785 tconn = GetConn(as, 0);
786 for (ti = as->parms[1].items; ti; ti = ti->next) {
787 if (as->parms[2].items) {
788 if (strlen(ti->data) > MAXHOSTCHARS - 3) {
789 fprintf(stderr, "bos: host name too long\n");
793 strcpy(&name[1], ti->data);
794 strcat((char *)&name, "]");
795 code = BOZO_AddCellHost(tconn, name);
797 code = BOZO_AddCellHost(tconn, ti->data);
799 printf("bos: failed to add host %s (%s)\n", ti->data, em(code));
805 RemoveHost(register struct cmd_syndesc *as, void *arock)
807 register struct rx_connection *tconn;
808 register afs_int32 code;
809 register struct cmd_item *ti;
811 tconn = GetConn(as, 0);
812 for (ti = as->parms[1].items; ti; ti = ti->next) {
813 code = BOZO_DeleteCellHost(tconn, ti->data);
815 printf("bos: failed to delete host %s (%s)\n", ti->data,
822 ListHosts(register struct cmd_syndesc *as, void *arock)
824 register struct rx_connection *tconn;
825 register afs_int32 code;
828 register afs_int32 i;
831 tconn = GetConn(as, 0);
832 code = BOZO_GetCellName(tconn, &tp);
834 printf("bos: failed to get cell name (%s)\n", em(code));
837 printf("Cell name is %s\n", tbuffer);
839 code = BOZO_GetCellHost(tconn, i, &tp);
843 printf("bos: failed to get cell host %d (%s)\n", i, em(code));
846 printf(" Host %d is %s\n", i + 1, tbuffer);
852 AddKey(register struct cmd_syndesc *as, void *arock)
854 register struct rx_connection *tconn;
855 register afs_int32 code;
856 struct ktc_encryptionKey tkey;
859 char cellBuffer[256];
860 char buf[BUFSIZ], ver[BUFSIZ];
862 tconn = GetConn(as, 1);
863 memset(&tkey, 0, sizeof(struct ktc_encryptionKey));
865 if (as->parms[1].items)
866 strcpy(buf, as->parms[1].items->data);
869 code = des_read_pw_string(buf, sizeof(buf), "input key: ", 0);
870 if (code || strlen(buf) == 0) {
871 fprintf(stderr, "Bad key: \n");
874 code = des_read_pw_string(ver, sizeof(ver), "Retype input key: ", 0);
875 if (code || strlen(ver) == 0) {
876 fprintf(stderr, "Bad key: \n");
879 if (strcmp(ver, buf) != 0) {
880 fprintf(stderr, "\nInput key mismatch\n");
886 temp = atoi(as->parms[2].items->data);
890 strcpy((char *)&tkey, as->parms[1].items->data);
892 strcpy((char *)&tkey, buf);
893 } else { /* kerberos key */
894 if (as->parms[ADDPARMOFFSET].items) {
895 strcpy(cellBuffer, as->parms[ADDPARMOFFSET].items->data);
897 /* string to key needs upper-case cell names */
899 /* I don't believe this is true. The string to key function
900 * actually expands the cell name, then LOWER-CASES it. Perhaps it
901 * didn't use to??? */
902 ucstring(cellBuffer, cellBuffer, strlen(cellBuffer));
905 tcell = NULL; /* no cell specified, use current */
907 ka_StringToKey(as->parms[1].items->data, tcell, &tkey);
909 ka_StringToKey(buf, tcell, &tkey);
911 tconn = GetConn(as, 1);
912 code = BOZO_AddKey(tconn, temp, &tkey);
914 printf("bos: failed to set key %d (%s)\n", temp, em(code));
921 RemoveKey(register struct cmd_syndesc *as, void *arock)
923 register struct rx_connection *tconn;
924 register afs_int32 code;
926 register struct cmd_item *ti;
928 tconn = GetConn(as, 0);
929 for (ti = as->parms[1].items; ti; ti = ti->next) {
930 temp = atoi(ti->data);
931 code = BOZO_DeleteKey(tconn, temp);
933 printf("bos: failed to delete key %d (%s)\n", temp, em(code));
941 ListKeys(register struct cmd_syndesc *as, void *arock)
943 register struct rx_connection *tconn;
944 register afs_int32 code;
945 struct ktc_encryptionKey tkey;
947 struct bozo_keyInfo keyInfo;
949 register afs_int32 i;
951 tconn = GetConn(as, 1);
954 code = BOZO_ListKeys(tconn, i, &kvno, &tkey, &keyInfo);
958 /* first check if key is returned */
959 if ((!ka_KeyIsZero(&tkey, sizeof(tkey))) && (as->parms[1].items)) {
960 printf("key %d is '", kvno);
961 ka_PrintBytes(&tkey, sizeof(tkey));
964 if (keyInfo.keyCheckSum == 0) /* shouldn't happen */
965 printf("key version is %d\n", kvno);
967 printf("key %d has cksum %u\n", kvno, keyInfo.keyCheckSum);
971 printf("Keys last changed on %s.\n", DateOf(keyInfo.mod_sec));
974 printf("bos: %s error encountered while listing keys\n", em(code));
976 printf("All done.\n");
981 AddSUser(register struct cmd_syndesc *as, void *arock)
983 register struct rx_connection *tconn;
984 register afs_int32 code;
986 register struct cmd_item *ti;
989 tconn = GetConn(as, 0);
990 for (ti = as->parms[1].items; ti; ti = ti->next) {
991 code = BOZO_AddSUser(tconn, ti->data);
993 printf("bos: failed to add user '%s' (%s)\n", ti->data, em(code));
1001 RemoveSUser(register struct cmd_syndesc *as, void *arock)
1003 register struct rx_connection *tconn;
1004 register struct cmd_item *ti;
1005 register afs_int32 code;
1009 tconn = GetConn(as, 0);
1010 for (ti = as->parms[1].items; ti; ti = ti->next) {
1011 code = BOZO_DeleteSUser(tconn, ti->data);
1013 printf("bos: failed to delete user '%s', ", ti->data);
1015 printf("(no such user)\n");
1017 printf("(%s)\n", em(code));
1024 #define NPERLINE 10 /* dudes to print per line */
1026 ListSUsers(register struct cmd_syndesc *as, void *arock)
1028 register struct rx_connection *tconn;
1030 register afs_int32 code;
1033 int lastNL, printGreeting;
1035 tconn = GetConn(as, 0);
1040 code = BOZO_ListSUsers(tconn, i, &tp);
1043 if (printGreeting) {
1044 printGreeting = 0; /* delay until after first call succeeds */
1045 printf("SUsers are: ");
1047 printf("%s ", tbuffer);
1048 if ((i % NPERLINE) == NPERLINE - 1) {
1055 /* a real error code, instead of scanned past end */
1056 printf("bos: failed to retrieve super-user list (%s)\n", em(code));
1065 StatServer(register struct cmd_syndesc *as, void *arock)
1067 register struct rx_connection *tconn;
1068 register afs_int32 code;
1070 char ibuffer[BOZO_BSSIZE];
1074 /* int32p==1 is obsolete, smaller, printout */
1075 int32p = (as->parms[2].items != 0 ? 2 : 0);
1077 /* no parms does something pretty different */
1078 if (as->parms[1].items)
1079 return IStatServer(as, int32p);
1081 tconn = GetConn(as, 0);
1083 /* for each instance */
1085 code = BOZO_EnumerateInstance(tconn, i, &tp);
1089 printf("bos: failed to contact host's bosserver (%s).\n",
1093 DoStat(ibuffer, tconn, int32p, (i == 0)); /* print status line */
1099 CreateServer(register struct cmd_syndesc *as, void *arock)
1101 register struct rx_connection *tconn;
1102 register afs_int32 code;
1104 register struct cmd_item *ti;
1106 char *type, *name, *notifier = NONOTIFIER;
1108 tconn = GetConn(as, 0);
1109 for (i = 0; i < 6; i++)
1111 for (i = 0, ti = as->parms[3].items; (ti && i < 6); ti = ti->next, i++) {
1112 parms[i] = ti->data;
1114 name = as->parms[1].items->data;
1115 type = as->parms[2].items->data;
1116 if (ti = as->parms[4].items) {
1117 notifier = ti->data;
1120 BOZO_CreateBnode(tconn, type, name, parms[0], parms[1], parms[2],
1121 parms[3], parms[4], notifier);
1124 ("bos: failed to create new server instance %s of type '%s' (%s)\n",
1125 name, type, em(code));
1131 DeleteServer(register struct cmd_syndesc *as, void *arock)
1133 register struct rx_connection *tconn;
1134 register afs_int32 code;
1135 register struct cmd_item *ti;
1138 tconn = GetConn(as, 0);
1139 for (ti = as->parms[1].items; ti; ti = ti->next) {
1140 code = BOZO_DeleteBnode(tconn, ti->data);
1143 printf("bos: can't delete running instance '%s'\n", ti->data);
1145 printf("bos: failed to delete instance '%s' (%s)\n", ti->data,
1153 StartServer(register struct cmd_syndesc *as, void *arock)
1155 register struct rx_connection *tconn;
1156 register afs_int32 code;
1157 register struct cmd_item *ti;
1160 tconn = GetConn(as, 0);
1161 for (ti = as->parms[1].items; ti; ti = ti->next) {
1162 code = BOZO_SetStatus(tconn, ti->data, BSTAT_NORMAL);
1164 printf("bos: failed to start instance '%s' (%s)\n", ti->data,
1171 StopServer(register struct cmd_syndesc *as, void *arock)
1173 register struct rx_connection *tconn;
1174 register afs_int32 code;
1175 register struct cmd_item *ti;
1178 tconn = GetConn(as, 0);
1179 for (ti = as->parms[1].items; ti; ti = ti->next) {
1180 code = BOZO_SetStatus(tconn, ti->data, BSTAT_SHUTDOWN);
1182 printf("bos: failed to change stop instance '%s' (%s)\n",
1183 ti->data, em(code));
1185 if (as->parms[8].items) {
1186 code = BOZO_WaitAll(tconn);
1188 printf("bos: can't wait for processes to shutdown (%s)\n",
1194 #define PARMBUFFERSSIZE 32
1197 DoSalvage(struct rx_connection * aconn, char * aparm1, char * aparm2,
1198 char * aoutName, afs_int32 showlog, char * parallel,
1199 char * atmpDir, char * orphans, int dafs,
1200 struct MRAFSSalvageParms * mrafsParm)
1202 register afs_int32 code;
1205 char tbuffer[BOZO_BSSIZE];
1206 struct bozo_status istatus;
1207 struct rx_call *tcall;
1211 char partName[20]; /* canonical name for partition */
1212 char pbuffer[PARMBUFFERSSIZE];
1213 afs_int32 partNumber;
1214 char *notifier = NONOTIFIER;
1216 /* if a partition was specified, canonicalize the name, since
1217 * the salvager has a stupid partition ID parser */
1219 partNumber = volutil_GetPartitionID(aparm1);
1220 if (partNumber < 0) {
1221 printf("bos: could not parse partition ID '%s'\n", aparm1);
1224 tp = volutil_PartitionName(partNumber);
1226 printf("bos: internal error parsing partition ID '%s'\n", aparm1);
1229 strcpy(partName, tp);
1233 /* open the file name */
1235 outFile = fopen(aoutName, "w");
1237 printf("bos: can't open specified SalvageLog file '%s'\n",
1241 closeIt = 1; /* close this file later */
1244 closeIt = 0; /* don't close this file later */
1247 for (code = 2; code < 6; code++)
1252 /* MUST pass canonical (wire-format) salvager path to bosserver */
1254 /* single volume salvage */
1256 /* for DAFS, we call the salvagserver binary with special options.
1257 * in this mode, it simply uses SALVSYNC to tell the currently
1258 * running salvageserver to offline and salvage the volume in question */
1259 strncpy(tbuffer, AFSDIR_CANONICAL_SERVER_SALSRV_FILEPATH, BOZO_BSSIZE);
1261 if ((strlen(tbuffer) + 9 + strlen(partName) + 1 + strlen(aparm2) +
1263 printf("bos: command line too big\n");
1267 strcat(tbuffer, " -client ");
1268 strcat(tbuffer, partName);
1269 strcat(tbuffer, " ");
1270 strcat(tbuffer, aparm2);
1272 strncpy(tbuffer, AFSDIR_CANONICAL_SERVER_SALVAGER_FILEPATH, BOZO_BSSIZE);
1274 if ((strlen(tbuffer) + 1 + strlen(partName) + 1 + strlen(aparm2) +
1276 printf("bos: command line too big\n");
1280 strcat(tbuffer, " ");
1281 strcat(tbuffer, partName);
1282 strcat(tbuffer, " ");
1283 strcat(tbuffer, aparm2);
1286 /* partition salvage */
1287 strncpy(tbuffer, AFSDIR_CANONICAL_SERVER_SALVAGER_FILEPATH, BOZO_BSSIZE);
1288 if ((strlen(tbuffer) + 4 + strlen(partName) + 1) > BOZO_BSSIZE) {
1289 printf("bos: command line too big\n");
1292 strcat(tbuffer, " -f ");
1293 strcat(tbuffer, partName);
1296 /* For DAFS, specifying a single volume does not result in a standard
1297 * salvager call. Instead, it simply results in a SALVSYNC call to the
1298 * online salvager daemon. This interface does not give us the same rich
1299 * set of call flags. Thus, we skip these steps for DAFS single-volume
1301 if (!dafs || (*aparm2 == 0)) {
1302 /* add the parallel option if given */
1303 if (parallel != NULL) {
1304 if ((strlen(tbuffer) + 11 + strlen(parallel) + 1) > BOZO_BSSIZE) {
1305 printf("bos: command line too big\n");
1308 strcat(tbuffer, " -parallel ");
1309 strcat(tbuffer, parallel);
1312 /* add the tmpdir option if given */
1313 if (atmpDir != NULL) {
1314 if ((strlen(tbuffer) + 9 + strlen(atmpDir) + 1) > BOZO_BSSIZE) {
1315 printf("bos: command line too big\n");
1318 strcat(tbuffer, " -tmpdir ");
1319 strcat(tbuffer, atmpDir);
1322 /* add the orphans option if given */
1323 if (orphans != NULL) {
1324 if ((strlen(tbuffer) + 10 + strlen(orphans) + 1) > BOZO_BSSIZE) {
1325 printf("bos: command line too big\n");
1328 strcat(tbuffer, " -orphans ");
1329 strcat(tbuffer, orphans);
1332 if (mrafsParm->Optdebug)
1333 strcat(tbuffer, " -debug");
1334 if (mrafsParm->Optnowrite)
1335 strcat(tbuffer, " -nowrite");
1336 if (mrafsParm->Optforce)
1337 strcat(tbuffer, " -force");
1338 if (mrafsParm->Optoktozap)
1339 strcat(tbuffer, " -oktozap");
1340 if (mrafsParm->Optrootfiles)
1341 strcat(tbuffer, " -rootfiles");
1342 if (mrafsParm->Optsalvagedirs)
1343 strcat(tbuffer, " -salvagedirs");
1344 if (mrafsParm->Optblockreads)
1345 strcat(tbuffer, " -blockreads");
1346 if (mrafsParm->OptListResidencies)
1347 strcat(tbuffer, " -ListResidencies");
1348 if (mrafsParm->OptSalvageRemote)
1349 strcat(tbuffer, " -SalvageRemote");
1350 if (mrafsParm->OptSalvageArchival)
1351 strcat(tbuffer, " -SalvageArchival");
1352 if (mrafsParm->OptIgnoreCheck)
1353 strcat(tbuffer, " -IgnoreCheck");
1354 if (mrafsParm->OptForceOnLine)
1355 strcat(tbuffer, " -ForceOnLine");
1356 if (mrafsParm->OptUseRootDirACL)
1357 strcat(tbuffer, " -UseRootDirACL");
1358 if (mrafsParm->OptTraceBadLinkCounts)
1359 strcat(tbuffer, " -TraceBadLinkCounts");
1360 if (mrafsParm->OptDontAskFS)
1361 strcat(tbuffer, " -DontAskFS");
1362 if (mrafsParm->OptLogLevel) {
1363 sprintf(pbuffer, " -LogLevel %ld", mrafsParm->OptLogLevel);
1364 strcat(tbuffer, pbuffer);
1366 if (mrafsParm->OptRxDebug)
1367 strcat(tbuffer, " -rxdebug");
1368 if (mrafsParm->OptResidencies) {
1369 sprintf(pbuffer, " -Residencies %lu", mrafsParm->OptResidencies);
1370 strcat(tbuffer, pbuffer);
1375 parms[1] = "now"; /* when to do it */
1377 BOZO_CreateBnode(aconn, "cron", "salvage-tmp", parms[0], parms[1],
1378 parms[2], parms[3], parms[4], notifier);
1380 printf("bos: failed to start 'salvager' (%s)\n", em(code));
1383 /* now wait for bnode to disappear */
1387 code = BOZO_GetInstanceInfo(aconn, "salvage-tmp", &tp, &istatus);
1390 printf("bos: waiting for salvage to complete.\n");
1392 if (code != BZNOENT) {
1393 printf("bos: salvage failed (%s)\n", em(code));
1398 /* now print the log file to the output file */
1399 printf("bos: salvage completed\n");
1400 if (aoutName || showlog) {
1401 fprintf(outFile, "SalvageLog:\n");
1402 tcall = rx_NewCall(aconn);
1403 /* MUST pass canonical (wire-format) salvager log path to bosserver */
1405 StartBOZO_GetLog(tcall, AFSDIR_CANONICAL_SERVER_SLVGLOG_FILEPATH);
1407 rx_EndCall(tcall, code);
1412 code = rx_Read(tcall, &buffer, 1);
1415 putc(buffer, outFile);
1417 break; /* the end delimeter */
1419 code = rx_EndCall(tcall, 0);
1420 /* fall through into cleanup code */
1424 if (closeIt && outFile)
1430 GetLogCmd(register struct cmd_syndesc *as, void *arock)
1432 struct rx_connection *tconn;
1433 register struct rx_call *tcall;
1434 register afs_int32 code;
1438 printf("Fetching log file '%s'...\n", as->parms[1].items->data);
1439 tconn = GetConn(as, 0);
1440 tcall = rx_NewCall(tconn);
1441 code = StartBOZO_GetLog(tcall, as->parms[1].items->data);
1443 rx_EndCall(tcall, code);
1449 code = rx_Read(tcall, &buffer, 1);
1455 break; /* the end delimeter */
1458 code = rx_EndCall(tcall, error);
1459 /* fall through into cleanup code */
1463 afs_com_err("bos", code, "(while reading log)");
1468 SalvageCmd(struct cmd_syndesc *as, void *arock)
1470 register struct rx_connection *tconn;
1471 register afs_int32 code, rc, i;
1473 char tname[BOZO_BSSIZE];
1475 extern struct ubik_client *cstruct;
1476 afs_int32 curGoal, showlog = 0, dafs = 0, mrafs = 0;
1482 struct MRAFSSalvageParms mrafsParm;
1484 memset(&mrafsParm, 0, sizeof(mrafsParm));
1486 /* parm 0 is machine name, 1 is partition, 2 is volume, 3 is -all flag */
1487 tconn = GetConn(as, 0);
1491 /* find out whether fileserver is running demand attach fs */
1492 if (code = BOZO_GetInstanceParm(tconn, "dafs", 0, &tp) == 0) {
1494 serviceName = "dafs";
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 */
1497 if (code = BOZO_GetInstanceParm(tconn, serviceName, 4, &tp) == 0)
1501 /* Find out whether fileserver is running MR-AFS (has a scanner instance) */
1502 /* XXX this should really be done some other way, potentially by RPC */
1503 if (code = BOZO_GetInstanceParm(tconn, serviceName, 3, &tp) == 0)
1507 /* we can do a volume, a partition or the whole thing, but not mixtures
1509 if (!as->parms[1].items && as->parms[2].items) {
1510 printf("bos: must specify partition to salvage individual volume.\n");
1513 if (as->parms[5].items && as->parms[3].items) {
1514 printf("bos: can not specify both -file and -showlog.\n");
1517 if (as->parms[4].items && (as->parms[1].items || as->parms[2].items)) {
1518 printf("bos: can not specify -all with other flags.\n");
1522 /* get the output file name, if any */
1523 if (as->parms[3].items)
1524 outName = as->parms[3].items->data;
1528 if (as->parms[5].items)
1531 /* parallel option */
1533 if (as->parms[6].items)
1534 parallel = as->parms[6].items->data;
1536 /* get the tmpdir filename if any */
1538 if (as->parms[7].items)
1539 tmpDir = as->parms[7].items->data;
1541 /* -orphans option */
1543 if (as->parms[8].items) {
1545 printf("Can't specify -orphans for MR-AFS fileserver\n");
1548 orphans = as->parms[8].items->data;
1552 if (!as->parms[9].items) { /* -forceDAFS flag */
1553 printf("This is a demand attach fileserver. Are you sure you want to proceed with a manual salvage?\n");
1554 printf("must specify -forceDAFS flag in order to proceed.\n");
1560 if (as->parms[MRAFS_OFFSET].items)
1561 mrafsParm.Optdebug = 1;
1562 if (as->parms[MRAFS_OFFSET + 1].items)
1563 mrafsParm.Optnowrite = 1;
1564 if (as->parms[MRAFS_OFFSET + 2].items)
1565 mrafsParm.Optforce = 1;
1566 if (as->parms[MRAFS_OFFSET + 3].items)
1567 mrafsParm.Optoktozap = 1;
1568 if (as->parms[MRAFS_OFFSET + 4].items)
1569 mrafsParm.Optrootfiles = 1;
1570 if (as->parms[MRAFS_OFFSET + 5].items)
1571 mrafsParm.Optsalvagedirs = 1;
1572 if (as->parms[MRAFS_OFFSET + 6].items)
1573 mrafsParm.Optblockreads = 1;
1574 if (as->parms[MRAFS_OFFSET + 7].items)
1575 mrafsParm.OptListResidencies = 1;
1576 if (as->parms[MRAFS_OFFSET + 8].items)
1577 mrafsParm.OptSalvageRemote = 1;
1578 if (as->parms[MRAFS_OFFSET + 9].items)
1579 mrafsParm.OptSalvageArchival = 1;
1580 if (as->parms[MRAFS_OFFSET + 10].items)
1581 mrafsParm.OptIgnoreCheck = 1;
1582 if (as->parms[MRAFS_OFFSET + 11].items)
1583 mrafsParm.OptForceOnLine = 1;
1584 if (as->parms[MRAFS_OFFSET + 12].items)
1585 mrafsParm.OptUseRootDirACL = 1;
1586 if (as->parms[MRAFS_OFFSET + 13].items)
1587 mrafsParm.OptTraceBadLinkCounts = 1;
1588 if (as->parms[MRAFS_OFFSET + 14].items)
1589 mrafsParm.OptDontAskFS = 1;
1590 if (as->parms[MRAFS_OFFSET + 15].items)
1591 mrafsParm.OptLogLevel =
1592 atoi(as->parms[MRAFS_OFFSET + 15].items->data);
1593 if (as->parms[MRAFS_OFFSET + 16].items)
1594 mrafsParm.OptRxDebug = 1;
1595 if (as->parms[MRAFS_OFFSET + 17].items) {
1596 if (as->parms[MRAFS_OFFSET + 8].items
1597 || as->parms[MRAFS_OFFSET + 9].items) {
1599 ("Can't specify -Residencies with -SalvageRemote or -SalvageArchival\n");
1603 util_GetUInt32(as->parms[MRAFS_OFFSET + 17].items->data,
1604 &mrafsParm.OptResidencies);
1606 printf("bos: '%s' is not a valid residency mask.\n",
1607 as->parms[MRAFS_OFFSET + 13].items->data);
1614 for (i = MRAFS_OFFSET; i < ADDPARMOFFSET; i++) {
1615 if (as->parms[i].items) {
1616 printf(" %s only possible for MR-AFS fileserver.\n",
1625 if (as->parms[4].items) {
1626 /* salvage whole enchilada */
1627 curGoal = GetServerGoal(tconn, serviceName);
1628 if (curGoal == BSTAT_NORMAL) {
1629 printf("bos: shutting down '%s'.\n", serviceName);
1630 code = BOZO_SetTStatus(tconn, serviceName, BSTAT_SHUTDOWN);
1632 printf("bos: failed to stop '%s' (%s)\n", serviceName, em(code));
1635 code = BOZO_WaitAll(tconn); /* wait for shutdown to complete */
1638 ("bos: failed to wait for file server shutdown, continuing.\n");
1640 /* now do the salvage operation */
1641 printf("Starting salvage.\n");
1642 rc = DoSalvage(tconn, NULL, NULL, outName, showlog, parallel, tmpDir,
1643 orphans, dafs, &mrafsParm);
1644 if (curGoal == BSTAT_NORMAL) {
1645 printf("bos: restarting %s.\n", serviceName);
1646 code = BOZO_SetTStatus(tconn, serviceName, BSTAT_NORMAL);
1648 printf("bos: failed to restart '%s' (%s)\n", serviceName, em(code));
1654 } else if (!as->parms[2].items) {
1655 if (!as->parms[1].items) {
1657 ("bos: must specify -all switch to salvage all partitions.\n");
1660 if (volutil_GetPartitionID(as->parms[1].items->data) < 0) {
1661 /* can't parse volume ID, so complain before shutting down
1664 printf("bos: can't interpret %s as partition ID.\n",
1665 as->parms[1].items->data);
1668 curGoal = GetServerGoal(tconn, serviceName);
1669 /* salvage a whole partition (specified by parms[1]) */
1670 if (curGoal == BSTAT_NORMAL) {
1671 printf("bos: shutting down '%s'.\n", serviceName);
1672 code = BOZO_SetTStatus(tconn, serviceName, BSTAT_SHUTDOWN);
1674 printf("bos: can't stop '%s' (%s)\n", serviceName, em(code));
1677 code = BOZO_WaitAll(tconn); /* wait for shutdown to complete */
1680 ("bos: failed to wait for file server shutdown, continuing.\n");
1682 /* now do the salvage operation */
1683 printf("Starting salvage.\n");
1684 rc = DoSalvage(tconn, as->parms[1].items->data, NULL, outName,
1685 showlog, parallel, tmpDir, orphans, dafs, &mrafsParm);
1686 if (curGoal == BSTAT_NORMAL) {
1687 printf("bos: restarting '%s'.\n", serviceName);
1688 code = BOZO_SetTStatus(tconn, serviceName, BSTAT_NORMAL);
1690 printf("bos: failed to restart '%s' (%s)\n", serviceName, em(code));
1697 /* salvage individual volume (don't shutdown fs first), just use
1698 * single-shot cron bnode. Must leave server running when using this
1699 * option, since salvager will ask file server for the volume */
1702 const char *confdir;
1705 if (as->parms[ADDPARMOFFSET].items)
1706 tmpname = as->parms[ADDPARMOFFSET].items->data;
1710 localauth = (as->parms[ADDPARMOFFSET + 2].items != 0);
1712 (localauth ? AFSDIR_SERVER_ETC_DIRPATH :
1713 AFSDIR_CLIENT_ETC_DIRPATH);
1714 code = vsu_ClientInit( /* noauth */ 1, confdir, tmpname,
1715 /* server auth */ 0, &cstruct, (int (*)())0);
1717 newID = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err);
1719 printf("bos: can't interpret %s as volume name or ID\n",
1720 as->parms[2].items->data);
1723 sprintf(tname, "%u", newID);
1726 ("bos: can't initialize volume system client (code %d), trying anyway.\n",
1728 strncpy(tname, as->parms[2].items->data, sizeof(tname));
1730 if (volutil_GetPartitionID(as->parms[1].items->data) < 0) {
1731 /* can't parse volume ID, so complain before shutting down
1734 printf("bos: can't interpret %s as partition ID.\n",
1735 as->parms[1].items->data);
1738 printf("Starting salvage.\n");
1739 rc = DoSalvage(tconn, as->parms[1].items->data, tname, outName,
1740 showlog, parallel, tmpDir, orphans, dafs, &mrafsParm);
1748 IStatServer(as, int32p)
1750 register struct cmd_syndesc *as;
1752 register struct rx_connection *tconn;
1753 register struct cmd_item *ti;
1756 tconn = GetConn(as, 0);
1757 for (ti = as->parms[1].items; ti; ti = ti->next) {
1758 DoStat(ti->data, tconn, int32p, firstTime);
1765 DoStat(aname, aconn, aint32p, firstTime)
1767 IN register struct rx_connection *aconn;
1769 IN int firstTime; /* true iff first instance in cmd */
1773 register afs_int32 code;
1774 register afs_int32 i;
1775 struct bozo_status istatus;
1777 char *is1, *is2, *is3, *is4; /* instance strings */
1780 code = BOZO_GetInstanceInfo(aconn, aname, &tp, &istatus);
1782 printf("bos: failed to get instance info for '%s' (%s)\n", aname,
1786 if (firstTime && aint32p && (istatus.flags & BOZO_BADDIRACCESS))
1788 ("Bosserver reports inappropriate access on server directories\n");
1789 printf("Instance %s, ", aname);
1791 printf("(type is %s) ", buffer);
1792 if (istatus.fileGoal == istatus.goal) {
1794 printf("disabled, ");
1796 if (istatus.fileGoal)
1797 printf("temporarily disabled, ");
1799 printf("temporarily enabled, ");
1802 if (istatus.flags & BOZO_ERRORSTOP)
1803 printf("stopped for too many errors, ");
1804 if (istatus.flags & BOZO_HASCORE)
1805 printf("has core file, ");
1808 code = BOZO_GetStatus(aconn, aname, &temp, &tp);
1810 printf("bos: failed to get status for instance '%s' (%s)\n", aname,
1813 printf("currently ");
1814 if (temp == BSTAT_NORMAL)
1815 printf("running normally.\n");
1816 else if (temp == BSTAT_SHUTDOWN)
1817 printf("shutdown.\n");
1818 else if (temp == BSTAT_STARTINGUP)
1819 printf("starting up.\n");
1820 else if (temp == BSTAT_SHUTTINGDOWN)
1821 printf("shutting down.\n");
1822 if (buffer[0] != 0) {
1823 printf(" Auxiliary status is: %s.\n", buffer);
1827 /* are we done yet? */
1831 if (istatus.procStartTime)
1832 printf(" Process last started at %s (%d proc starts)\n",
1833 DateOf(istatus.procStartTime), istatus.procStarts);
1834 if (istatus.lastAnyExit) {
1835 printf(" Last exit at %s\n", DateOf(istatus.lastAnyExit));
1837 if (istatus.lastErrorExit) {
1838 is1 = is2 = is3 = is4 = NULL;
1839 printf(" Last error exit at %s, ", DateOf(istatus.lastErrorExit));
1840 code = BOZO_GetInstanceStrings(aconn, aname, &is1, &is2, &is3, &is4);
1841 /* don't complain about failing call, since could simply mean
1842 * interface mismatch.
1846 /* non-null instance string */
1847 printf("by %s, ", is1);
1854 if (istatus.errorSignal) {
1855 if (istatus.errorSignal == SIGTERM)
1856 printf("due to shutdown request\n");
1858 printf("due to signal %d\n", istatus.errorSignal);
1860 printf("by exiting with code %d\n", istatus.errorCode);
1864 /* try to display all the parms */
1867 code = BOZO_GetInstanceParm(aconn, aname, i, &tp);
1870 printf(" Command %d is '%s'\n", i + 1, buffer);
1873 code = BOZO_GetInstanceParm(aconn, aname, 999, &tp);
1875 /* Any type of failure is treated as not having a notifier program */
1876 printf(" Notifier is '%s'\n", buffer);
1883 #ifdef BOS_RESTRICTED_MODE
1885 GetRestrict(struct cmd_syndesc *as, void *arock)
1887 register struct rx_connection *tconn;
1888 afs_int32 code, val;
1890 tconn = GetConn(as, 0);
1891 code = BOZO_GetRestrictedMode(tconn, &val);
1893 printf("bos: failed to get restricted mode (%s)\n", em(code));
1895 printf("Restricted mode is %s\n", val ? "on" : "off");
1901 SetRestrict(struct cmd_syndesc *as, void *arock)
1903 register struct rx_connection *tconn;
1904 afs_int32 code, val;
1906 tconn = GetConn(as, 0);
1907 util_GetInt32(as->parms[1].items->data, &val);
1908 code = BOZO_SetRestrictedMode(tconn, val);
1910 printf("bos: failed to set restricted mode (%s)\n", em(code));
1917 register struct cmd_syndesc *ts;
1919 cmd_Seek(ts, ADDPARMOFFSET);
1920 /* + 0 */ cmd_AddParm(ts, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell name");
1921 /* + 1 */ cmd_AddParm(ts, "-noauth", CMD_FLAG, CMD_OPTIONAL,
1922 "don't authenticate");
1923 /* + 2 */ cmd_AddParm(ts, "-localauth", CMD_FLAG, CMD_OPTIONAL,
1924 "create tickets from KeyFile");
1927 #include "AFS_component_version_number.c"
1933 register afs_int32 code;
1934 register struct cmd_syndesc *ts;
1935 extern int afsconf_SawCell;
1937 #ifdef AFS_AIX32_ENV
1939 * The following signal action for AIX is necessary so that in case of a
1940 * crash (i.e. core is generated) we can include the user's data section
1941 * in the core dump. Unfortunately, by default, only a partial core is
1942 * generated which, in many cases, isn't too useful.
1944 struct sigaction nsa;
1946 sigemptyset(&nsa.sa_mask);
1947 nsa.sa_handler = SIG_DFL;
1948 nsa.sa_flags = SA_FULLDUMP;
1949 sigaction(SIGSEGV, &nsa, NULL);
1950 sigaction(SIGABRT, &nsa, NULL);
1956 printf("bos: could not initialize rx (%s)\n", em(code));
1960 /* To resolve a AFSCELL environment "Note: ..." problem: Because bos calls ka_Init (why?) before any
1961 * checkup on the existance of a "-cell" option on the particular bos command we don't print the
1962 * message if a cell is passed in. Luckily the rest of the programs don't call these adhoc routines
1963 * and things work fine. Note that if the "-cell" isn't passed then we're still ok since later on
1964 * the proper routine (afsconf_GetCellInfo) is going to be called to do the right thing.
1966 afsconf_SawCell = 1; /* Means don't print warning if AFSCELL is set */
1968 afsconf_SawCell = 0; /* Reset it */
1969 /* don't check error code, since fails sometimes when we're setting up a
1971 initialize_CMD_error_table();
1972 initialize_BZ_error_table();
1974 ts = cmd_CreateSyntax("start", StartServer, NULL, "start running a server");
1975 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1976 cmd_AddParm(ts, "-instance", CMD_LIST, 0, "server process name");
1979 ts = cmd_CreateSyntax("stop", StopServer, NULL, "halt a server instance");
1980 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1981 cmd_AddParm(ts, "-instance", CMD_LIST, 0, "server process name");
1983 cmd_AddParm(ts, "-wait", CMD_FLAG, CMD_OPTIONAL,
1984 "wait for process to stop");
1987 ts = cmd_CreateSyntax("status", StatServer, NULL,
1988 "show server instance status");
1989 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1990 cmd_AddParm(ts, "-instance", CMD_LIST, CMD_OPTIONAL,
1991 "server process name");
1992 cmd_AddParm(ts, "-long", CMD_FLAG, CMD_OPTIONAL, "long status");
1995 ts = cmd_CreateSyntax("shutdown", Shutdown, NULL, "shutdown all processes");
1996 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1997 cmd_AddParm(ts, "-instance", CMD_LIST, CMD_OPTIONAL, "instances");
1999 cmd_AddParm(ts, "-wait", CMD_FLAG, CMD_OPTIONAL,
2000 "wait for process to stop");
2003 ts = cmd_CreateSyntax("startup", Startup, NULL, "start all processes");
2004 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2005 cmd_AddParm(ts, "-instance", CMD_LIST, CMD_OPTIONAL, "instances");
2008 ts = cmd_CreateSyntax("restart", Restart, NULL, "restart processes");
2009 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2010 cmd_AddParm(ts, "-instance", CMD_LIST, CMD_OPTIONAL, "instances");
2011 cmd_AddParm(ts, "-bosserver", CMD_FLAG, CMD_OPTIONAL,
2012 "restart bosserver");
2013 cmd_AddParm(ts, "-all", CMD_FLAG, CMD_OPTIONAL, "restart all processes");
2018 ts = cmd_CreateSyntax("create", CreateServer, NULL,
2019 "create a new server instance");
2020 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2021 cmd_AddParm(ts, "-instance", CMD_SINGLE, 0, "server process name");
2022 cmd_AddParm(ts, "-type", CMD_SINGLE, 0, "server type");
2023 cmd_AddParm(ts, "-cmd", CMD_LIST, 0, "command lines");
2024 cmd_AddParm(ts, "-notifier", CMD_SINGLE, CMD_OPTIONAL,
2025 "Notifier program");
2028 ts = cmd_CreateSyntax("delete", DeleteServer, NULL,
2029 "delete a server instance");
2030 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2031 cmd_AddParm(ts, "-instance", CMD_LIST, 0, "server process name");
2034 ts = cmd_CreateSyntax("adduser", AddSUser, NULL,
2035 "add users to super-user list");
2036 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2037 cmd_AddParm(ts, "-user", CMD_LIST, 0, "user names");
2040 ts = cmd_CreateSyntax("removeuser", RemoveSUser, NULL,
2041 "remove users from super-user list");
2042 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2043 cmd_AddParm(ts, "-user", CMD_LIST, 0, "user names");
2046 ts = cmd_CreateSyntax("listusers", ListSUsers, NULL, "list super-users");
2047 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2050 ts = cmd_CreateSyntax("addkey", AddKey, NULL,
2051 "add keys to key dbase (kvno 999 is bcrypt)");
2052 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2053 cmd_AddParm(ts, "-key", CMD_SINGLE, CMD_OPTIONAL, "key");
2054 cmd_AddParm(ts, "-kvno", CMD_SINGLE, 0, "key version number");
2057 ts = cmd_CreateSyntax("removekey", RemoveKey, NULL,
2058 "remove keys from key dbase");
2059 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2060 cmd_AddParm(ts, "-kvno", CMD_LIST, 0, "key version number");
2063 ts = cmd_CreateSyntax("listkeys", ListKeys, NULL, "list keys");
2064 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2065 cmd_AddParm(ts, "-showkey", CMD_FLAG, CMD_OPTIONAL,
2066 "show the actual key rather than the checksum");
2069 ts = cmd_CreateSyntax("listhosts", ListHosts, NULL, "get cell host list");
2070 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2072 cmd_CreateAlias(ts, "getcell");
2074 ts = cmd_CreateSyntax("setcellname", SetCellName, NULL, "set cell name");
2075 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2076 cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "cell name");
2079 ts = cmd_CreateSyntax("addhost", AddHost, NULL, "add host to cell dbase");
2080 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2081 cmd_AddParm(ts, "-host", CMD_LIST, 0, "host name");
2082 cmd_AddParm(ts, "-clone", CMD_FLAG, CMD_OPTIONAL, "vote doesn't count");
2085 ts = cmd_CreateSyntax("removehost", RemoveHost, NULL,
2086 "remove host from cell dbase");
2087 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2088 cmd_AddParm(ts, "-host", CMD_LIST, 0, "host name");
2091 ts = cmd_CreateSyntax("setauth", SetAuth, NULL,
2092 "set authentication required flag");
2093 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2094 cmd_AddParm(ts, "-authrequired", CMD_SINGLE, 0,
2095 "on or off: authentication required for admin requests");
2098 ts = cmd_CreateSyntax("install", Install, NULL, "install program");
2099 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2100 cmd_AddParm(ts, "-file", CMD_LIST, 0, "files to install");
2101 cmd_AddParm(ts, "-dir", CMD_SINGLE, CMD_OPTIONAL, "destination dir");
2104 ts = cmd_CreateSyntax("uninstall", UnInstall, NULL, "uninstall program");
2105 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2106 cmd_AddParm(ts, "-file", CMD_LIST, 0, "files to uninstall");
2107 cmd_AddParm(ts, "-dir", CMD_SINGLE, CMD_OPTIONAL, "destination dir");
2110 ts = cmd_CreateSyntax("getlog", GetLogCmd, NULL, "examine log file");
2111 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2112 cmd_AddParm(ts, "-file", CMD_SINGLE, 0, "log file to examine");
2115 ts = cmd_CreateSyntax("getdate", GetDate, NULL, "get dates for programs");
2116 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2117 cmd_AddParm(ts, "-file", CMD_LIST, 0, "files to check");
2118 cmd_AddParm(ts, "-dir", CMD_SINGLE, CMD_OPTIONAL, "destination dir");
2121 ts = cmd_CreateSyntax("exec", Exec, NULL, "execute shell command on server");
2122 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2123 cmd_AddParm(ts, "-cmd", CMD_SINGLE, 0, "command to execute");
2126 ts = cmd_CreateSyntax("prune", Prune, NULL, "prune server files");
2127 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2128 cmd_AddParm(ts, "-bak", CMD_FLAG, CMD_OPTIONAL, "delete .BAK files");
2129 cmd_AddParm(ts, "-old", CMD_FLAG, CMD_OPTIONAL, "delete .OLD files");
2130 cmd_AddParm(ts, "-core", CMD_FLAG, CMD_OPTIONAL, "delete core files");
2131 cmd_AddParm(ts, "-all", CMD_FLAG, CMD_OPTIONAL, "delete all junk files");
2134 ts = cmd_CreateSyntax("setrestart", SetRestartCmd, NULL,
2135 "set restart times");
2136 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_REQUIRED, "machine name");
2137 cmd_AddParm(ts, "-time", CMD_SINGLE, CMD_REQUIRED,
2138 "time to restart server");
2139 cmd_AddParm(ts, "-general", CMD_FLAG, CMD_OPTIONAL,
2140 "set general restart time");
2141 cmd_AddParm(ts, "-newbinary", CMD_FLAG, CMD_OPTIONAL,
2142 "set new binary restart time");
2145 ts = cmd_CreateSyntax("getrestart", GetRestartCmd, NULL,
2146 "get restart times");
2147 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_REQUIRED, "machine name");
2150 ts = cmd_CreateSyntax("salvage", SalvageCmd, NULL,
2151 "salvage partition or volumes");
2152 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2153 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL,
2154 "salvage partition");
2155 cmd_AddParm(ts, "-volume", CMD_SINGLE, CMD_OPTIONAL,
2156 "salvage volume number or volume name");
2157 cmd_AddParm(ts, "-file", CMD_SINGLE, CMD_OPTIONAL,
2158 "salvage log output file");
2159 cmd_AddParm(ts, "-all", CMD_FLAG, CMD_OPTIONAL, "salvage whole server");
2160 cmd_AddParm(ts, "-showlog", CMD_FLAG, CMD_OPTIONAL,
2161 "display salvage log");
2162 cmd_AddParm(ts, "-parallel", CMD_SINGLE, CMD_OPTIONAL,
2163 "# of max parallel partition salvaging");
2164 cmd_AddParm(ts, "-tmpdir", CMD_SINGLE, CMD_OPTIONAL,
2165 "directory to place tmp files");
2166 cmd_AddParm(ts, "-orphans", CMD_SINGLE, CMD_OPTIONAL,
2167 "ignore | remove | attach");
2168 cmd_AddParm(ts, "-forceDAFS", CMD_FLAG, CMD_OPTIONAL,
2169 "(DAFS) force salvage of demand attach fileserver");
2170 cmd_AddParm(ts, "-debug", CMD_FLAG, CMD_OPTIONAL,
2171 "(MR-AFS) Run in Debugging mode");
2172 cmd_AddParm(ts, "-nowrite", CMD_FLAG, CMD_OPTIONAL,
2173 "(MR-AFS) Run readonly/test mode");
2174 cmd_AddParm(ts, "-force", CMD_FLAG, CMD_OPTIONAL,
2175 "(MR-AFS) Force full salvaging");
2176 cmd_AddParm(ts, "-oktozap", CMD_FLAG, CMD_OPTIONAL,
2177 "(MR-AFS) Give permission to destroy bogus file residencies/volumes - debugging flag");
2178 cmd_AddParm(ts, "-rootfiles", CMD_FLAG, CMD_OPTIONAL,
2179 "(MR-AFS) Show files owned by root - debugging flag");
2180 cmd_AddParm(ts, "-salvagedirs", CMD_FLAG, CMD_OPTIONAL,
2181 "(MR-AFS) Force rebuild/salvage of all directories");
2182 cmd_AddParm(ts, "-blockreads", CMD_FLAG, CMD_OPTIONAL,
2183 "(MR-AFS) Read smaller blocks to handle IO/bad blocks");
2184 cmd_AddParm(ts, "-ListResidencies", CMD_FLAG, CMD_OPTIONAL,
2185 "(MR-AFS) Just list affected file residencies - debugging flag");
2186 cmd_AddParm(ts, "-SalvageRemote", CMD_FLAG, CMD_OPTIONAL,
2187 "(MR-AFS) Salvage storage systems that are not directly attached");
2188 cmd_AddParm(ts, "-SalvageArchival", CMD_FLAG, CMD_OPTIONAL,
2189 "(MR-AFS) Salvage HSM storage systems");
2190 cmd_AddParm(ts, "-IgnoreCheck", CMD_FLAG, CMD_OPTIONAL,
2191 "(MR-AFS) Don't perform VLDB safety check when deleting unreferenced files. Only a good idea in single server cell.");
2192 cmd_AddParm(ts, "-ForceOnLine", CMD_FLAG, CMD_OPTIONAL,
2193 "(MR-AFS) Force the volume to come online, even if it hasn't salvaged cleanly.");
2194 cmd_AddParm(ts, "-UseRootDirACL", CMD_FLAG, CMD_OPTIONAL,
2195 "(MR-AFS) Use the root directory ACL for lost+found directory if it is created.");
2196 cmd_AddParm(ts, "-TraceBadLinkCounts", CMD_FLAG, CMD_OPTIONAL,
2197 "(MR-AFS) Print out lines about volume reference count changes.");
2198 cmd_AddParm(ts, "-DontAskFS", CMD_FLAG, CMD_OPTIONAL,
2199 "(MR-AFS) Don't ask fileserver to take volume offline. THIS IS VERY DANGEROUS.");
2200 cmd_AddParm(ts, "-LogLevel", CMD_SINGLE, CMD_OPTIONAL,
2201 "(MR-AFS) log level");
2202 cmd_AddParm(ts, "-rxdebug", CMD_FLAG, CMD_OPTIONAL,
2203 "(MR-AFS) Write out rx debug information.");
2204 cmd_AddParm(ts, "-Residencies", CMD_SINGLE, CMD_OPTIONAL,
2205 "(MR-AFS) Numeric mask of residencies to be included in the salvage. Do not use with -SalvageRemote or -SalvageArchival");
2208 ts = cmd_CreateSyntax("blockscanner", BlockScannerCmd, NULL,
2209 "block scanner daemon from making migration requests");
2210 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_REQUIRED, "machine name");
2213 ts = cmd_CreateSyntax("unblockscanner", UnBlockScannerCmd, NULL,
2214 "allow scanner daemon to make migration requests again");
2215 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_REQUIRED, "machine name");
2218 #ifdef BOS_RESTRICTED_MODE
2219 ts = cmd_CreateSyntax("getrestricted", GetRestrict, NULL,
2220 "get restrict mode");
2221 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2224 ts = cmd_CreateSyntax("setrestricted", SetRestrict, NULL,
2225 "set restrict mode");
2226 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2227 cmd_AddParm(ts, "-mode", CMD_SINGLE, 0, "mode to set");
2232 code = cmd_Dispatch(argc, argv);