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>
14 #include <afs/procmgmt.h>
18 #include <hcrypto/ui.h>
21 #include <afs/afsutil.h>
22 #include <afs/cellconfig.h>
27 #include <afs/cellconfig.h>
29 #include <afs/com_err.h>
31 #include <afs/ktime.h>
32 #include <afs/kautils.h>
33 #include <afs/volser.h>
35 static int IStatServer(struct cmd_syndesc *as, int int32p);
36 static int DoStat(char *aname, struct rx_connection *aconn,
37 int aint32p, int firstTime);
40 #include "bosprototypes.h"
42 /* command offsets for bos salvage command */
43 #define MRAFS_OFFSET 10
44 #define ADDPARMOFFSET 27
46 /* MR-AFS salvage parameters */
47 struct MRAFSSalvageParms {
52 afs_int32 Optrootfiles;
53 afs_int32 Optsalvagedirs;
54 afs_int32 Optblockreads;
55 afs_int32 OptListResidencies;
56 afs_int32 OptSalvageRemote;
57 afs_int32 OptSalvageArchival;
58 afs_int32 OptIgnoreCheck;
59 afs_int32 OptForceOnLine;
60 afs_int32 OptUseRootDirACL;
61 afs_int32 OptTraceBadLinkCounts;
62 afs_int32 OptDontAskFS;
63 afs_int32 OptLogLevel;
65 afs_uint32 OptResidencies;
68 /* dummy routine for the audit work. It should do nothing since audits */
69 /* occur at the server level and bos is not a server. */
75 /* keep those lines small */
80 return "communications failure (-1)";
82 return "communications timeout (-3)";
84 return (char *)afs_error_message(acode);
87 /* get partition id from a name */
88 /* XXX - unused code - could be removed? */
91 GetPartitionID(char *aname)
98 return -1; /* unknown */
99 /* numbers go straight through */
100 if (tc >= '0' && tc <= '9') {
103 /* otherwise check for vicepa or /vicepa, or just plain "a" */
105 if (strlen(aname) <= 2) {
106 strcpy(ascii, aname);
107 } else if (!strncmp(aname, "/vicep", 6)) {
108 strncpy(ascii, aname + 6, 2);
109 } else if (!strncmp(aname, "vicep", 5)) {
110 strncpy(ascii, aname + 5, 2);
112 return -1; /* bad partition name */
113 /* now partitions are named /vicepa ... /vicepz, /vicepaa, /vicepab,
114 * .../vicepzz, and are numbered from 0. Do the appropriate conversion */
116 /* one char name, 0..25 */
117 if (ascii[0] < 'a' || ascii[0] > 'z')
118 return -1; /* wrongo */
119 return ascii[0] - 'a';
121 /* two char name, 26 .. <whatever> */
122 if (ascii[0] < 'a' || ascii[0] > 'z')
123 return -1; /* wrongo */
124 if (ascii[1] < 'a' || ascii[1] > 'z')
125 return -1; /* just as bad */
126 return (ascii[0] - 'a') * 26 + (ascii[1] - 'a') + 26;
131 /* make ctime easier to use */
133 DateOf(afs_int32 atime)
135 static char tbuffer[30];
137 time_t t = (time_t) atime;
141 tbuffer[24] = 0; /* get rid of new line */
143 strcpy(tbuffer, "BAD TIME");
148 /* use the syntax descr to get a connection, authenticated appropriately.
149 * aencrypt is set if we want to encrypt the data on the wire.
151 static struct rx_connection *
152 GetConn(struct cmd_syndesc *as, int aencrypt)
156 char *cellname = NULL;
159 struct rx_connection *tconn;
161 struct afsconf_dir *tdir = NULL;
162 afsconf_secflags secFlags;
163 struct rx_securityClass *sc;
166 hostname = as->parms[0].items->data;
167 th = hostutil_GetHostByName(hostname);
169 printf("bos: can't find address for host '%s'\n", hostname);
172 memcpy(&addr, th->h_addr, sizeof(afs_int32));
174 secFlags = AFSCONF_SECOPTS_FALLBACK_NULL;
176 if (as->parms[ADDPARMOFFSET + 2].items) { /* -localauth */
177 secFlags |= AFSCONF_SECOPTS_LOCALAUTH;
178 confdir = AFSDIR_SERVER_ETC_DIRPATH;
180 confdir = AFSDIR_CLIENT_ETC_DIRPATH;
183 if (as->parms[ADDPARMOFFSET + 1].items) { /* -noauth */
184 secFlags |= AFSCONF_SECOPTS_NOAUTH;
186 /* If we're running with -noauth, we don't need a configuration
188 tdir = afsconf_Open(confdir);
190 printf("bos: can't open cell database (%s)\n", confdir);
195 if (as->parms[ADDPARMOFFSET].items) /* -cell */
196 cellname = as->parms[ADDPARMOFFSET].items->data;
198 code = afsconf_PickClientSecObj(tdir, secFlags, NULL, cellname,
199 &sc, &scIndex, NULL);
201 afs_com_err("bos", code, "(configuring connection security)");
205 if (scIndex == RX_SECIDX_NULL)
206 fprintf(stderr, "bos: running unauthenticated\n");
209 rx_NewConnection(addr, htons(AFSCONF_NANNYPORT), 1, sc, scIndex);
211 fprintf(stderr, "bos: could not create rx connection\n");
220 SetAuth(struct cmd_syndesc *as, void *arock)
223 struct rx_connection *tconn;
227 tconn = GetConn(as, 0);
228 tp = as->parms[1].items->data;
229 if (strcmp(tp, "on") == 0)
230 flag = 0; /* auth req.: noauthflag is false */
231 else if (strcmp(tp, "off") == 0)
235 ("bos: illegal authentication specifier '%s', must be 'off' or 'on'.\n",
239 code = BOZO_SetNoAuthFlag(tconn, flag);
241 afs_com_err("bos", code, "(failed to set authentication flag)");
245 /* take a name (e.g. foo/bar, and a dir e.g. /usr/afs/bin, and construct
246 * /usr/afs/bin/bar */
248 ComputeDestDir(char *aname, char *adir, char *aresult, afs_int32 alen)
252 strcpy(aresult, adir);
253 tp = strrchr(aname, '/');
256 strcat(aresult, "/");
257 strcat(aresult, aname);
259 /* tp points at the / character */
265 /* copy data from fd afd to rx call acall */
267 CopyBytes(int afd, struct rx_call *acall)
274 len = read(afd, tbuffer, sizeof(tbuffer));
278 return 0; /* all done */
279 code = rx_Write(acall, tbuffer, len);
286 Prune(struct cmd_syndesc *as, void *arock)
289 struct rx_connection *tconn;
292 tconn = GetConn(as, 0);
294 if (as->parms[1].items)
295 flags |= BOZO_PRUNEBAK;
296 if (as->parms[2].items)
297 flags |= BOZO_PRUNEOLD;
298 if (as->parms[3].items)
299 flags |= BOZO_PRUNECORE;
300 if (as->parms[4].items)
302 code = BOZO_Prune(tconn, flags);
304 afs_com_err("bos", code, "(failed to prune server files)");
309 Exec(struct cmd_syndesc *as, void *arock)
311 struct rx_connection *tconn;
314 tconn = GetConn(as, 0);
315 code = BOZO_Exec(tconn, as->parms[1].items->data);
317 printf("bos: failed to execute command (%s)\n", em(code));
322 GetDate(struct cmd_syndesc *as, void *arock)
327 afs_int32 time, bakTime, oldTime;
328 struct rx_connection *tconn;
331 tconn = GetConn(as, 0);
332 if (!as->parms[1].items) {
333 printf("bos: no files to check\n");
337 /* compute dest dir or file; default MUST be canonical form of dir path */
338 if (as->parms[2].items)
339 strcpy(destDir, as->parms[2].items->data);
341 strcpy(destDir, AFSDIR_CANONICAL_SERVER_BIN_DIRPATH);
343 for (ti = as->parms[1].items; ti; ti = ti->next) {
344 /* check date for each file */
345 ComputeDestDir(ti->data, destDir, tbuffer, sizeof(tbuffer));
346 code = BOZO_GetDates(tconn, tbuffer, &time, &bakTime, &oldTime);
348 printf("bos: failed to check date on %s (%s)\n", ti->data,
352 printf("File %s ", tbuffer);
354 printf("does not exist, ");
356 printf("dated %s, ", DateOf(time));
358 printf("no .BAK file, ");
360 printf(".BAK file dated %s, ", DateOf(bakTime));
362 printf("no .OLD file.");
364 printf(".OLD file dated %s.", DateOf(oldTime));
372 UnInstall(struct cmd_syndesc *as, void *arock)
378 struct rx_connection *tconn;
380 tconn = GetConn(as, 0);
381 if (!as->parms[1].items) {
382 printf("bos: no files to uninstall\n");
386 /* compute dest dir or file; default MUST be canonical form of dir path */
387 if (as->parms[2].items)
388 strcpy(destDir, as->parms[2].items->data);
390 strcpy(destDir, AFSDIR_CANONICAL_SERVER_BIN_DIRPATH);
392 for (ti = as->parms[1].items; ti; ti = ti->next) {
393 /* uninstall each file */
394 ComputeDestDir(ti->data, destDir, tbuffer, sizeof(tbuffer));
395 code = BOZO_UnInstall(tconn, tbuffer);
397 printf("bos: failed to uninstall %s (%s)\n", ti->data, em(code));
400 printf("bos: uninstalled file %s\n", ti->data);
406 GetServerGoal(struct rx_connection *aconn, char *aname)
411 struct bozo_status istatus;
414 code = BOZO_GetInstanceInfo(aconn, aname, &tp, &istatus);
416 printf("bos: failed to get instance info for '%s' (%s)\n", aname,
418 /* if we can't get the answer, assume its running */
421 if (istatus.goal == 0)
422 return BSTAT_SHUTDOWN;
428 Install(struct cmd_syndesc *as, void *arock)
430 struct rx_connection *tconn;
436 struct rx_call *tcall;
439 tconn = GetConn(as, 0);
440 if (!as->parms[1].items) {
441 printf("bos: no files to install\n");
445 /* compute dest dir or file; default MUST be canonical form of dir path */
446 if (as->parms[2].items)
447 strcpy(destDir, as->parms[2].items->data);
449 strcpy(destDir, AFSDIR_CANONICAL_SERVER_BIN_DIRPATH);
451 for (ti = as->parms[1].items; ti; ti = ti->next) {
452 /* install each file */
453 fd = open(ti->data, O_RDONLY);
455 /* better to quit on error than continue for install command */
456 printf("bos: can't find file '%s', quitting\n", ti->data);
459 code = fstat(fd, &tstat);
461 printf("bos: failed to stat file %s, errno is %d\n", ti->data,
465 /* compute destination dir */
466 ComputeDestDir(ti->data, destDir, tbuffer, sizeof(tbuffer));
467 tcall = rx_NewCall(tconn);
469 StartBOZO_Install(tcall, tbuffer, tstat.st_size,
470 (afs_int32) tstat.st_mode, tstat.st_mtime);
472 code = CopyBytes(fd, tcall);
474 code = rx_EndCall(tcall, code);
476 printf("bos: failed to install %s (%s)\n", ti->data, em(code));
479 printf("bos: installed file %s\n", ti->data);
485 Shutdown(struct cmd_syndesc *as, void *arock)
487 struct rx_connection *tconn;
491 tconn = GetConn(as, 0);
492 if (as->parms[1].items == 0) {
493 code = BOZO_ShutdownAll(tconn);
495 printf("bos: failed to shutdown servers (%s)\n", em(code));
497 for (ti = as->parms[1].items; ti; ti = ti->next) {
498 code = BOZO_SetTStatus(tconn, ti->data, BSTAT_SHUTDOWN);
500 printf("bos: failed to shutdown instance %s (%s)\n", ti->data,
504 if (as->parms[8].items) {
505 code = BOZO_WaitAll(tconn);
507 printf("bos: can't wait for processes to shutdown (%s)\n",
514 BlockScannerCmd(struct cmd_syndesc *as, void *arock)
517 struct rx_connection *tconn;
518 char BlockCommand[] = "/usr/afs/bin/scanner -block";
520 tconn = GetConn(as, 0);
521 code = BOZO_Exec(tconn, BlockCommand);
524 ("bos: failed to block scanner from making migration requests (%s)\n",
530 UnBlockScannerCmd(struct cmd_syndesc *as, void *arock)
533 struct rx_connection *tconn;
534 char UnBlockCommand[] = "/usr/afs/bin/scanner -unblock";
536 tconn = GetConn(as, 0);
537 code = BOZO_Exec(tconn, UnBlockCommand);
540 ("bos: failed to allow scanner daemon to make migration requests again (%s)\n",
546 GetRestartCmd(struct cmd_syndesc *as, void *arock)
549 struct ktime generalTime, newBinaryTime;
550 char messageBuffer[256];
551 struct rx_connection *tconn;
554 hostp = as->parms[0].items->data; /* host name for messages */
555 tconn = GetConn(as, 0);
557 code = BOZO_GetRestartTime(tconn, 1, (struct bozo_netKTime *) &generalTime);
559 printf("bos: failed to retrieve restart information (%s)\n",
563 code = BOZO_GetRestartTime(tconn, 2, (struct bozo_netKTime *) &newBinaryTime);
565 printf("bos: failed to retrieve restart information (%s)\n",
570 code = ktime_DisplayString(&generalTime, messageBuffer);
572 printf("bos: failed to decode restart time (%s)\n", em(code));
575 printf("Server %s restarts %s\n", hostp, messageBuffer);
577 code = ktime_DisplayString(&newBinaryTime, messageBuffer);
579 printf("bos: failed to decode restart time (%s)\n", em(code));
582 printf("Server %s restarts for new binaries %s\n", hostp, messageBuffer);
589 SetRestartCmd(struct cmd_syndesc *as, void *arock)
593 struct ktime restartTime;
595 struct rx_connection *tconn;
598 tconn = GetConn(as, 0);
599 if (as->parms[2].items) {
603 if (as->parms[3].items) {
608 printf("bos: can't specify more than one restart time at a time\n");
612 type = 1; /* by default set general restart time */
614 if ((code = ktime_ParsePeriodic(as->parms[1].items->data, &restartTime))) {
615 printf("bos: failed to parse '%s' as periodic restart time(%s)\n",
616 as->parms[1].items->data, em(code));
620 code = BOZO_SetRestartTime(tconn, type, (struct bozo_netKTime *) &restartTime);
622 printf("bos: failed to set restart time at server (%s)\n", em(code));
629 Startup(struct cmd_syndesc *as, void *arock)
631 struct rx_connection *tconn;
635 tconn = GetConn(as, 0);
636 if (as->parms[1].items == 0) {
637 code = BOZO_StartupAll(tconn);
639 printf("bos: failed to startup servers (%s)\n", em(code));
641 for (ti = as->parms[1].items; ti; ti = ti->next) {
642 code = BOZO_SetTStatus(tconn, ti->data, BSTAT_NORMAL);
644 printf("bos: failed to start instance %s (%s)\n", ti->data,
652 Restart(struct cmd_syndesc *as, void *arock)
654 struct rx_connection *tconn;
658 tconn = GetConn(as, 0);
659 if (as->parms[2].items) {
660 /* this is really a rebozo command */
661 if (as->parms[1].items) {
662 /* specified specific things to restart, can't do this at the same
665 ("bos: can't specify both '-bos' and specific servers to restart.\n");
668 /* otherwise do a rebozo */
669 code = BOZO_ReBozo(tconn);
671 printf("bos: failed to restart bosserver (%s)\n", em(code));
674 if (as->parms[1].items == 0) {
675 if (as->parms[3].items) { /* '-all' */
676 code = BOZO_RestartAll(tconn);
678 printf("bos: failed to restart servers (%s)\n", em(code));
680 printf("bos: To restart all processes please specify '-all'\n");
682 if (as->parms[3].items) {
683 printf("bos: Can't use '-all' along with individual instances\n");
685 for (ti = as->parms[1].items; ti; ti = ti->next) {
686 code = BOZO_Restart(tconn, ti->data);
688 printf("bos: failed to restart instance %s (%s)\n",
697 SetCellName(struct cmd_syndesc *as, void *arock)
699 struct rx_connection *tconn;
702 tconn = GetConn(as, 0);
703 code = BOZO_SetCellName(tconn, as->parms[1].items->data);
705 printf("bos: failed to set cell (%s)\n", em(code));
710 AddHost(struct cmd_syndesc *as, void *arock)
712 struct rx_connection *tconn;
715 char name[MAXHOSTCHARS];
717 tconn = GetConn(as, 0);
718 for (ti = as->parms[1].items; ti; ti = ti->next) {
719 if (as->parms[2].items) {
720 if (strlen(ti->data) > MAXHOSTCHARS - 3) {
721 fprintf(stderr, "bos: host name too long\n");
725 strcpy(&name[1], ti->data);
726 strcat((char *)&name, "]");
727 code = BOZO_AddCellHost(tconn, name);
729 code = BOZO_AddCellHost(tconn, ti->data);
731 printf("bos: failed to add host %s (%s)\n", ti->data, em(code));
737 RemoveHost(struct cmd_syndesc *as, void *arock)
739 struct rx_connection *tconn;
743 tconn = GetConn(as, 0);
744 for (ti = as->parms[1].items; ti; ti = ti->next) {
745 code = BOZO_DeleteCellHost(tconn, ti->data);
747 printf("bos: failed to delete host %s (%s)\n", ti->data,
754 ListHosts(struct cmd_syndesc *as, void *arock)
756 struct rx_connection *tconn;
763 tconn = GetConn(as, 0);
764 code = BOZO_GetCellName(tconn, &tp);
766 printf("bos: failed to get cell name (%s)\n", em(code));
769 printf("Cell name is %s\n", tbuffer);
771 code = BOZO_GetCellHost(tconn, i, &tp);
775 printf("bos: failed to get cell host %d (%s)\n", i, em(code));
778 printf(" Host %d is %s\n", i + 1, tbuffer);
784 AddKey(struct cmd_syndesc *as, void *arock)
786 struct rx_connection *tconn;
788 struct ktc_encryptionKey tkey;
791 char cellBuffer[256];
792 char buf[BUFSIZ], ver[BUFSIZ];
794 tconn = GetConn(as, 1);
795 memset(&tkey, 0, sizeof(struct ktc_encryptionKey));
797 if (as->parms[1].items)
798 strcpy(buf, as->parms[1].items->data);
801 code = UI_UTIL_read_pw_string(buf, sizeof(buf), "input key: ", 0);
802 if (code || strlen(buf) == 0) {
803 fprintf(stderr, "Bad key: \n");
806 code = UI_UTIL_read_pw_string(ver, sizeof(ver), "Retype input key: ", 0);
807 if (code || strlen(ver) == 0) {
808 fprintf(stderr, "Bad key: \n");
811 if (strcmp(ver, buf) != 0) {
812 fprintf(stderr, "\nInput key mismatch\n");
818 temp = atoi(as->parms[2].items->data);
822 strcpy((char *)&tkey, as->parms[1].items->data);
824 strcpy((char *)&tkey, buf);
825 } else { /* kerberos key */
826 if (as->parms[ADDPARMOFFSET].items) {
827 strcpy(cellBuffer, as->parms[ADDPARMOFFSET].items->data);
829 /* string to key needs upper-case cell names */
831 /* I don't believe this is true. The string to key function
832 * actually expands the cell name, then LOWER-CASES it. Perhaps it
833 * didn't use to??? */
834 ucstring(cellBuffer, cellBuffer, strlen(cellBuffer));
837 tcell = NULL; /* no cell specified, use current */
839 ka_StringToKey(as->parms[1].items->data, tcell, &tkey);
841 ka_StringToKey(buf, tcell, &tkey);
843 tconn = GetConn(as, 1);
844 code = BOZO_AddKey(tconn, temp, ktc_to_bozoptr(&tkey));
846 printf("bos: failed to set key %d (%s)\n", temp, em(code));
853 RemoveKey(struct cmd_syndesc *as, void *arock)
855 struct rx_connection *tconn;
860 tconn = GetConn(as, 0);
861 for (ti = as->parms[1].items; ti; ti = ti->next) {
862 temp = atoi(ti->data);
863 code = BOZO_DeleteKey(tconn, temp);
865 printf("bos: failed to delete key %d (%s)\n", temp, em(code));
873 ListKeys(struct cmd_syndesc *as, void *arock)
875 struct rx_connection *tconn;
877 struct ktc_encryptionKey tkey;
879 struct bozo_keyInfo keyInfo;
883 tconn = GetConn(as, 1);
886 code = BOZO_ListKeys(tconn, i, &kvno, ktc_to_bozoptr(&tkey), &keyInfo);
890 /* first check if key is returned */
891 if ((!ka_KeyIsZero((char *)&tkey, sizeof(tkey)))
892 && (as->parms[1].items)) {
893 printf("key %d is '", kvno);
894 ka_PrintBytes((char *)&tkey, sizeof(tkey));
897 if (keyInfo.keyCheckSum == 0) /* shouldn't happen */
898 printf("key version is %d\n", kvno);
900 printf("key %d has cksum %u\n", kvno, keyInfo.keyCheckSum);
904 printf("Keys last changed on %s.\n", DateOf(keyInfo.mod_sec));
907 printf("bos: %s error encountered while listing keys\n", em(code));
909 printf("All done.\n");
914 AddSUser(struct cmd_syndesc *as, void *arock)
916 struct rx_connection *tconn;
922 tconn = GetConn(as, 0);
923 for (ti = as->parms[1].items; ti; ti = ti->next) {
924 code = BOZO_AddSUser(tconn, ti->data);
926 printf("bos: failed to add user '%s' (%s)\n", ti->data, em(code));
934 RemoveSUser(struct cmd_syndesc *as, void *arock)
936 struct rx_connection *tconn;
942 tconn = GetConn(as, 0);
943 for (ti = as->parms[1].items; ti; ti = ti->next) {
944 code = BOZO_DeleteSUser(tconn, ti->data);
946 printf("bos: failed to delete user '%s', ", ti->data);
948 printf("(no such user)\n");
950 printf("(%s)\n", em(code));
957 #define NPERLINE 10 /* dudes to print per line */
959 ListSUsers(struct cmd_syndesc *as, void *arock)
961 struct rx_connection *tconn;
966 int lastNL, printGreeting;
968 tconn = GetConn(as, 0);
973 code = BOZO_ListSUsers(tconn, i, &tp);
977 printGreeting = 0; /* delay until after first call succeeds */
978 printf("SUsers are: ");
980 printf("%s ", tbuffer);
981 if ((i % NPERLINE) == NPERLINE - 1) {
988 /* a real error code, instead of scanned past end */
989 printf("bos: failed to retrieve super-user list (%s)\n", em(code));
998 StatServer(struct cmd_syndesc *as, void *arock)
1000 struct rx_connection *tconn;
1003 char ibuffer[BOZO_BSSIZE];
1007 /* int32p==1 is obsolete, smaller, printout */
1008 int32p = (as->parms[2].items != 0 ? 2 : 0);
1010 /* no parms does something pretty different */
1011 if (as->parms[1].items)
1012 return IStatServer(as, int32p);
1014 tconn = GetConn(as, 0);
1016 /* for each instance */
1018 code = BOZO_EnumerateInstance(tconn, i, &tp);
1022 printf("bos: failed to contact host's bosserver (%s).\n",
1026 DoStat(ibuffer, tconn, int32p, (i == 0)); /* print status line */
1032 CreateServer(struct cmd_syndesc *as, void *arock)
1034 struct rx_connection *tconn;
1037 struct cmd_item *ti;
1039 char *type, *name, *notifier = NONOTIFIER;
1041 tconn = GetConn(as, 0);
1042 for (i = 0; i < 6; i++)
1044 for (i = 0, ti = as->parms[3].items; (ti && i < 6); ti = ti->next, i++) {
1045 parms[i] = ti->data;
1047 name = as->parms[1].items->data;
1048 type = as->parms[2].items->data;
1049 if ((ti = as->parms[4].items)) {
1050 notifier = ti->data;
1053 BOZO_CreateBnode(tconn, type, name, parms[0], parms[1], parms[2],
1054 parms[3], parms[4], notifier);
1057 ("bos: failed to create new server instance %s of type '%s' (%s)\n",
1058 name, type, em(code));
1064 DeleteServer(struct cmd_syndesc *as, void *arock)
1066 struct rx_connection *tconn;
1068 struct cmd_item *ti;
1071 tconn = GetConn(as, 0);
1072 for (ti = as->parms[1].items; ti; ti = ti->next) {
1073 code = BOZO_DeleteBnode(tconn, ti->data);
1076 printf("bos: can't delete running instance '%s'\n", ti->data);
1078 printf("bos: failed to delete instance '%s' (%s)\n", ti->data,
1086 StartServer(struct cmd_syndesc *as, void *arock)
1088 struct rx_connection *tconn;
1090 struct cmd_item *ti;
1093 tconn = GetConn(as, 0);
1094 for (ti = as->parms[1].items; ti; ti = ti->next) {
1095 code = BOZO_SetStatus(tconn, ti->data, BSTAT_NORMAL);
1097 printf("bos: failed to start instance '%s' (%s)\n", ti->data,
1104 StopServer(struct cmd_syndesc *as, void *arock)
1106 struct rx_connection *tconn;
1108 struct cmd_item *ti;
1111 tconn = GetConn(as, 0);
1112 for (ti = as->parms[1].items; ti; ti = ti->next) {
1113 code = BOZO_SetStatus(tconn, ti->data, BSTAT_SHUTDOWN);
1115 printf("bos: failed to change stop instance '%s' (%s)\n",
1116 ti->data, em(code));
1118 if (as->parms[8].items) {
1119 code = BOZO_WaitAll(tconn);
1121 printf("bos: can't wait for processes to shutdown (%s)\n",
1127 #define PARMBUFFERSSIZE 32
1130 DoSalvage(struct rx_connection * aconn, char * aparm1, char * aparm2,
1131 char * aoutName, afs_int32 showlog, char * parallel,
1132 char * atmpDir, char * orphans, int dafs,
1133 struct MRAFSSalvageParms * mrafsParm)
1138 char tbuffer[BOZO_BSSIZE];
1139 struct bozo_status istatus;
1140 struct rx_call *tcall;
1144 char partName[20]; /* canonical name for partition */
1145 char pbuffer[PARMBUFFERSSIZE];
1146 afs_int32 partNumber;
1147 char *notifier = NONOTIFIER;
1149 /* if a partition was specified, canonicalize the name, since
1150 * the salvager has a stupid partition ID parser */
1152 partNumber = volutil_GetPartitionID(aparm1);
1153 if (partNumber < 0) {
1154 printf("bos: could not parse partition ID '%s'\n", aparm1);
1157 tp = volutil_PartitionName(partNumber);
1159 printf("bos: internal error parsing partition ID '%s'\n", aparm1);
1162 strcpy(partName, tp);
1166 /* open the file name */
1168 outFile = fopen(aoutName, "w");
1170 printf("bos: can't open specified SalvageLog file '%s'\n",
1174 closeIt = 1; /* close this file later */
1177 closeIt = 0; /* don't close this file later */
1180 for (code = 2; code < 6; code++)
1185 /* MUST pass canonical (wire-format) salvager path to bosserver */
1187 /* single volume salvage */
1189 /* for DAFS, we call the salvagserver binary with special options.
1190 * in this mode, it simply uses SALVSYNC to tell the currently
1191 * running salvageserver to offline and salvage the volume in question */
1192 strncpy(tbuffer, AFSDIR_CANONICAL_SERVER_SALSRV_FILEPATH, BOZO_BSSIZE);
1194 if ((strlen(tbuffer) + 9 + strlen(partName) + 1 + strlen(aparm2) +
1196 printf("bos: command line too big\n");
1200 strcat(tbuffer, " -client ");
1201 strcat(tbuffer, partName);
1202 strcat(tbuffer, " ");
1203 strcat(tbuffer, aparm2);
1205 strncpy(tbuffer, AFSDIR_CANONICAL_SERVER_SALVAGER_FILEPATH, BOZO_BSSIZE);
1207 if ((strlen(tbuffer) + 1 + strlen(partName) + 1 + strlen(aparm2) +
1209 printf("bos: command line too big\n");
1213 strcat(tbuffer, " ");
1214 strcat(tbuffer, partName);
1215 strcat(tbuffer, " ");
1216 strcat(tbuffer, aparm2);
1219 /* partition salvage */
1220 strncpy(tbuffer, AFSDIR_CANONICAL_SERVER_SALVAGER_FILEPATH, BOZO_BSSIZE);
1221 if ((strlen(tbuffer) + 4 + strlen(partName) + 1) > BOZO_BSSIZE) {
1222 printf("bos: command line too big\n");
1225 strcat(tbuffer, " -force ");
1226 strcat(tbuffer, partName);
1229 /* For DAFS, specifying a single volume does not result in a standard
1230 * salvager call. Instead, it simply results in a SALVSYNC call to the
1231 * online salvager daemon. This interface does not give us the same rich
1232 * set of call flags. Thus, we skip these steps for DAFS single-volume
1234 if (!dafs || (*aparm2 == 0)) {
1235 /* add the parallel option if given */
1236 if (parallel != NULL) {
1237 if ((strlen(tbuffer) + 11 + strlen(parallel) + 1) > BOZO_BSSIZE) {
1238 printf("bos: command line too big\n");
1241 strcat(tbuffer, " -parallel ");
1242 strcat(tbuffer, parallel);
1245 /* add the tmpdir option if given */
1246 if (atmpDir != NULL) {
1247 if ((strlen(tbuffer) + 9 + strlen(atmpDir) + 1) > BOZO_BSSIZE) {
1248 printf("bos: command line too big\n");
1251 strcat(tbuffer, " -tmpdir ");
1252 strcat(tbuffer, atmpDir);
1255 /* add the orphans option if given */
1256 if (orphans != NULL) {
1257 if ((strlen(tbuffer) + 10 + strlen(orphans) + 1) > BOZO_BSSIZE) {
1258 printf("bos: command line too big\n");
1261 strcat(tbuffer, " -orphans ");
1262 strcat(tbuffer, orphans);
1265 if (mrafsParm->Optdebug)
1266 strcat(tbuffer, " -debug");
1267 if (mrafsParm->Optnowrite)
1268 strcat(tbuffer, " -nowrite");
1269 if (mrafsParm->Optforce)
1270 strcat(tbuffer, " -force");
1271 if (mrafsParm->Optoktozap)
1272 strcat(tbuffer, " -oktozap");
1273 if (mrafsParm->Optrootfiles)
1274 strcat(tbuffer, " -rootfiles");
1275 if (mrafsParm->Optsalvagedirs)
1276 strcat(tbuffer, " -salvagedirs");
1277 if (mrafsParm->Optblockreads)
1278 strcat(tbuffer, " -blockreads");
1279 if (mrafsParm->OptListResidencies)
1280 strcat(tbuffer, " -ListResidencies");
1281 if (mrafsParm->OptSalvageRemote)
1282 strcat(tbuffer, " -SalvageRemote");
1283 if (mrafsParm->OptSalvageArchival)
1284 strcat(tbuffer, " -SalvageArchival");
1285 if (mrafsParm->OptIgnoreCheck)
1286 strcat(tbuffer, " -IgnoreCheck");
1287 if (mrafsParm->OptForceOnLine)
1288 strcat(tbuffer, " -ForceOnLine");
1289 if (mrafsParm->OptUseRootDirACL)
1290 strcat(tbuffer, " -UseRootDirACL");
1291 if (mrafsParm->OptTraceBadLinkCounts)
1292 strcat(tbuffer, " -TraceBadLinkCounts");
1293 if (mrafsParm->OptDontAskFS)
1294 strcat(tbuffer, " -DontAskFS");
1295 if (mrafsParm->OptLogLevel) {
1296 sprintf(pbuffer, " -LogLevel %ld", afs_printable_int32_ld(mrafsParm->OptLogLevel));
1297 strcat(tbuffer, pbuffer);
1299 if (mrafsParm->OptRxDebug)
1300 strcat(tbuffer, " -rxdebug");
1301 if (mrafsParm->OptResidencies) {
1302 sprintf(pbuffer, " -Residencies %lu",
1303 afs_printable_uint32_lu(mrafsParm->OptResidencies));
1304 strcat(tbuffer, pbuffer);
1309 parms[1] = "now"; /* when to do it */
1311 BOZO_CreateBnode(aconn, "cron", "salvage-tmp", parms[0], parms[1],
1312 parms[2], parms[3], parms[4], notifier);
1314 printf("bos: failed to start 'salvager' (%s)\n", em(code));
1317 /* now wait for bnode to disappear */
1321 code = BOZO_GetInstanceInfo(aconn, "salvage-tmp", &tp, &istatus);
1324 printf("bos: waiting for salvage to complete.\n");
1326 if (code != BZNOENT) {
1327 printf("bos: salvage failed (%s)\n", em(code));
1332 /* now print the log file to the output file */
1333 printf("bos: salvage completed\n");
1334 if (aoutName || showlog) {
1335 fprintf(outFile, "SalvageLog:\n");
1336 tcall = rx_NewCall(aconn);
1337 /* MUST pass canonical (wire-format) salvager log path to bosserver */
1339 StartBOZO_GetLog(tcall, AFSDIR_CANONICAL_SERVER_SLVGLOG_FILEPATH);
1341 rx_EndCall(tcall, code);
1346 code = rx_Read(tcall, &buffer, 1);
1349 putc(buffer, outFile);
1351 break; /* the end delimeter */
1353 code = rx_EndCall(tcall, 0);
1354 /* fall through into cleanup code */
1358 if (closeIt && outFile)
1364 GetLogCmd(struct cmd_syndesc *as, void *arock)
1366 struct rx_connection *tconn;
1367 struct rx_call *tcall;
1372 printf("Fetching log file '%s'...\n", as->parms[1].items->data);
1373 tconn = GetConn(as, 0);
1374 tcall = rx_NewCall(tconn);
1375 code = StartBOZO_GetLog(tcall, as->parms[1].items->data);
1377 rx_EndCall(tcall, code);
1383 code = rx_Read(tcall, &buffer, 1);
1389 break; /* the end delimeter */
1392 code = rx_EndCall(tcall, error);
1393 /* fall through into cleanup code */
1397 afs_com_err("bos", code, "(while reading log)");
1402 IsDAFS(struct rx_connection *aconn)
1404 char buffer[BOZO_BSSIZE];
1406 struct bozo_status istatus;
1411 code = BOZO_GetInstanceInfo(aconn, "dafs", &tp, &istatus);
1413 /* no dafs bnode; cannot be dafs */
1417 /* dafs bnode is running; we must be dafs */
1421 /* At this point, either we have neither a dafs nor fs bnode running, or
1422 * we have an fs bnode running but the dafs bnode is stopped.
1424 * If an fs bnode is running, we are obviously not DAFS. If an fs bnode
1425 * is not running and a dafs bnode is not running... it's not certain if
1426 * we are DAFS or not DAFS. Just return 0 in that case; it shouldn't much
1427 * matter what we return, anyway */
1432 SalvageCmd(struct cmd_syndesc *as, void *arock)
1434 struct rx_connection *tconn;
1435 afs_int32 code, rc, i;
1437 char tname[BOZO_BSSIZE];
1439 extern struct ubik_client *cstruct;
1440 afs_int32 curGoal, showlog = 0, dafs = 0, mrafs = 0;
1446 struct MRAFSSalvageParms mrafsParm;
1448 memset(&mrafsParm, 0, sizeof(mrafsParm));
1450 /* parm 0 is machine name, 1 is partition, 2 is volume, 3 is -all flag */
1451 tconn = GetConn(as, 0);
1455 /* find out whether fileserver is running demand attach fs */
1456 if (IsDAFS(tconn)) {
1458 serviceName = "dafs";
1459 /* Find out whether fileserver is running MR-AFS (has a scanner instance) */
1460 /* XXX this should really be done some other way, potentially by RPC */
1461 if ((code = BOZO_GetInstanceParm(tconn, serviceName, 4, &tp) == 0))
1465 /* Find out whether fileserver is running MR-AFS (has a scanner instance) */
1466 /* XXX this should really be done some other way, potentially by RPC */
1467 if ((code = BOZO_GetInstanceParm(tconn, serviceName, 3, &tp) == 0))
1471 /* we can do a volume, a partition or the whole thing, but not mixtures
1473 if (!as->parms[1].items && as->parms[2].items) {
1474 printf("bos: must specify partition to salvage individual volume.\n");
1477 if (as->parms[5].items && as->parms[3].items) {
1478 printf("bos: can not specify both -file and -showlog.\n");
1481 if (as->parms[4].items && (as->parms[1].items || as->parms[2].items)) {
1482 printf("bos: can not specify -all with other flags.\n");
1486 /* get the output file name, if any */
1487 if (as->parms[3].items)
1488 outName = as->parms[3].items->data;
1492 if (as->parms[5].items)
1495 /* parallel option */
1497 if (as->parms[6].items)
1498 parallel = as->parms[6].items->data;
1500 /* get the tmpdir filename if any */
1502 if (as->parms[7].items)
1503 tmpDir = as->parms[7].items->data;
1505 /* -orphans option */
1507 if (as->parms[8].items) {
1509 printf("Can't specify -orphans for MR-AFS fileserver\n");
1512 orphans = as->parms[8].items->data;
1516 if (!as->parms[9].items) { /* -forceDAFS flag */
1517 printf("This is a demand attach fileserver. Are you sure you want to proceed with a manual salvage?\n");
1518 printf("must specify -forceDAFS flag in order to proceed.\n");
1524 if (as->parms[MRAFS_OFFSET].items)
1525 mrafsParm.Optdebug = 1;
1526 if (as->parms[MRAFS_OFFSET + 1].items)
1527 mrafsParm.Optnowrite = 1;
1528 if (as->parms[MRAFS_OFFSET + 2].items)
1529 mrafsParm.Optforce = 1;
1530 if (as->parms[MRAFS_OFFSET + 3].items)
1531 mrafsParm.Optoktozap = 1;
1532 if (as->parms[MRAFS_OFFSET + 4].items)
1533 mrafsParm.Optrootfiles = 1;
1534 if (as->parms[MRAFS_OFFSET + 5].items)
1535 mrafsParm.Optsalvagedirs = 1;
1536 if (as->parms[MRAFS_OFFSET + 6].items)
1537 mrafsParm.Optblockreads = 1;
1538 if (as->parms[MRAFS_OFFSET + 7].items)
1539 mrafsParm.OptListResidencies = 1;
1540 if (as->parms[MRAFS_OFFSET + 8].items)
1541 mrafsParm.OptSalvageRemote = 1;
1542 if (as->parms[MRAFS_OFFSET + 9].items)
1543 mrafsParm.OptSalvageArchival = 1;
1544 if (as->parms[MRAFS_OFFSET + 10].items)
1545 mrafsParm.OptIgnoreCheck = 1;
1546 if (as->parms[MRAFS_OFFSET + 11].items)
1547 mrafsParm.OptForceOnLine = 1;
1548 if (as->parms[MRAFS_OFFSET + 12].items)
1549 mrafsParm.OptUseRootDirACL = 1;
1550 if (as->parms[MRAFS_OFFSET + 13].items)
1551 mrafsParm.OptTraceBadLinkCounts = 1;
1552 if (as->parms[MRAFS_OFFSET + 14].items)
1553 mrafsParm.OptDontAskFS = 1;
1554 if (as->parms[MRAFS_OFFSET + 15].items)
1555 mrafsParm.OptLogLevel =
1556 atoi(as->parms[MRAFS_OFFSET + 15].items->data);
1557 if (as->parms[MRAFS_OFFSET + 16].items)
1558 mrafsParm.OptRxDebug = 1;
1559 if (as->parms[MRAFS_OFFSET + 17].items) {
1560 if (as->parms[MRAFS_OFFSET + 8].items
1561 || as->parms[MRAFS_OFFSET + 9].items) {
1563 ("Can't specify -Residencies with -SalvageRemote or -SalvageArchival\n");
1567 util_GetUInt32(as->parms[MRAFS_OFFSET + 17].items->data,
1568 &mrafsParm.OptResidencies);
1570 printf("bos: '%s' is not a valid residency mask.\n",
1571 as->parms[MRAFS_OFFSET + 17].items->data);
1578 for (i = MRAFS_OFFSET; i < ADDPARMOFFSET; i++) {
1579 if (as->parms[i].items) {
1580 printf(" %s only possible for MR-AFS fileserver.\n",
1589 if (as->parms[4].items) {
1590 /* salvage whole enchilada */
1591 curGoal = GetServerGoal(tconn, serviceName);
1592 if (curGoal == BSTAT_NORMAL) {
1593 printf("bos: shutting down '%s'.\n", serviceName);
1594 code = BOZO_SetTStatus(tconn, serviceName, BSTAT_SHUTDOWN);
1596 printf("bos: failed to stop '%s' (%s)\n", serviceName, em(code));
1599 code = BOZO_WaitAll(tconn); /* wait for shutdown to complete */
1602 ("bos: failed to wait for file server shutdown, continuing.\n");
1604 /* now do the salvage operation */
1605 printf("Starting salvage.\n");
1606 rc = DoSalvage(tconn, NULL, NULL, outName, showlog, parallel, tmpDir,
1607 orphans, dafs, &mrafsParm);
1608 if (curGoal == BSTAT_NORMAL) {
1609 printf("bos: restarting %s.\n", serviceName);
1610 code = BOZO_SetTStatus(tconn, serviceName, BSTAT_NORMAL);
1612 printf("bos: failed to restart '%s' (%s)\n", serviceName, em(code));
1618 } else if (!as->parms[2].items) {
1619 if (!as->parms[1].items) {
1621 ("bos: must specify -all switch to salvage all partitions.\n");
1624 if (volutil_GetPartitionID(as->parms[1].items->data) < 0) {
1625 /* can't parse volume ID, so complain before shutting down
1628 printf("bos: can't interpret %s as partition ID.\n",
1629 as->parms[1].items->data);
1632 curGoal = GetServerGoal(tconn, serviceName);
1633 /* salvage a whole partition (specified by parms[1]) */
1634 if (curGoal == BSTAT_NORMAL) {
1635 printf("bos: shutting down '%s'.\n", serviceName);
1636 code = BOZO_SetTStatus(tconn, serviceName, BSTAT_SHUTDOWN);
1638 printf("bos: can't stop '%s' (%s)\n", serviceName, em(code));
1641 code = BOZO_WaitAll(tconn); /* wait for shutdown to complete */
1644 ("bos: failed to wait for file server shutdown, continuing.\n");
1646 /* now do the salvage operation */
1647 printf("Starting salvage.\n");
1648 rc = DoSalvage(tconn, as->parms[1].items->data, NULL, outName,
1649 showlog, parallel, tmpDir, orphans, dafs, &mrafsParm);
1650 if (curGoal == BSTAT_NORMAL) {
1651 printf("bos: restarting '%s'.\n", serviceName);
1652 code = BOZO_SetTStatus(tconn, serviceName, BSTAT_NORMAL);
1654 printf("bos: failed to restart '%s' (%s)\n", serviceName, em(code));
1661 /* salvage individual volume (don't shutdown fs first), just use
1662 * single-shot cron bnode. Must leave server running when using this
1663 * option, since salvager will ask file server for the volume */
1666 const char *confdir;
1669 if (as->parms[ADDPARMOFFSET].items)
1670 tmpname = as->parms[ADDPARMOFFSET].items->data;
1674 localauth = (as->parms[ADDPARMOFFSET + 2].items != 0);
1676 (localauth ? AFSDIR_SERVER_ETC_DIRPATH :
1677 AFSDIR_CLIENT_ETC_DIRPATH);
1679 code = vsu_ClientInit(confdir, tmpname,
1680 AFSCONF_SECOPTS_FALLBACK_NULL |
1681 AFSCONF_SECOPTS_NOAUTH,
1685 newID = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err);
1687 printf("bos: can't interpret %s as volume name or ID\n",
1688 as->parms[2].items->data);
1691 sprintf(tname, "%u", newID);
1694 ("bos: can't initialize volume system client (code %d), trying anyway.\n",
1696 strncpy(tname, as->parms[2].items->data, sizeof(tname));
1698 if (volutil_GetPartitionID(as->parms[1].items->data) < 0) {
1699 /* can't parse volume ID, so complain before shutting down
1702 printf("bos: can't interpret %s as partition ID.\n",
1703 as->parms[1].items->data);
1706 printf("Starting salvage.\n");
1707 rc = DoSalvage(tconn, as->parms[1].items->data, tname, outName,
1708 showlog, parallel, tmpDir, orphans, dafs, &mrafsParm);
1716 IStatServer(struct cmd_syndesc *as, int int32p)
1718 struct rx_connection *tconn;
1719 struct cmd_item *ti;
1722 tconn = GetConn(as, 0);
1723 for (ti = as->parms[1].items; ti; ti = ti->next) {
1724 DoStat(ti->data, tconn, int32p, firstTime);
1731 DoStat(IN char *aname,
1732 IN struct rx_connection *aconn,
1734 IN int firstTime) /* true iff first instance in cmd */
1740 struct bozo_status istatus;
1742 char *is1, *is2, *is3, *is4; /* instance strings */
1745 code = BOZO_GetInstanceInfo(aconn, aname, &tp, &istatus);
1747 printf("bos: failed to get instance info for '%s' (%s)\n", aname,
1751 if (firstTime && aint32p && (istatus.flags & BOZO_BADDIRACCESS))
1753 ("Bosserver reports inappropriate access on server directories\n");
1754 printf("Instance %s, ", aname);
1756 printf("(type is %s) ", buffer);
1757 if (istatus.fileGoal == istatus.goal) {
1759 printf("disabled, ");
1761 if (istatus.fileGoal)
1762 printf("temporarily disabled, ");
1764 printf("temporarily enabled, ");
1767 if (istatus.flags & BOZO_ERRORSTOP)
1768 printf("stopped for too many errors, ");
1769 if (istatus.flags & BOZO_HASCORE)
1770 printf("has core file, ");
1773 code = BOZO_GetStatus(aconn, aname, &temp, &tp);
1775 printf("bos: failed to get status for instance '%s' (%s)\n", aname,
1778 printf("currently ");
1779 if (temp == BSTAT_NORMAL)
1780 printf("running normally.\n");
1781 else if (temp == BSTAT_SHUTDOWN)
1782 printf("shutdown.\n");
1783 else if (temp == BSTAT_STARTINGUP)
1784 printf("starting up.\n");
1785 else if (temp == BSTAT_SHUTTINGDOWN)
1786 printf("shutting down.\n");
1787 if (buffer[0] != 0) {
1788 printf(" Auxiliary status is: %s.\n", buffer);
1792 /* are we done yet? */
1796 if (istatus.procStartTime)
1797 printf(" Process last started at %s (%d proc starts)\n",
1798 DateOf(istatus.procStartTime), istatus.procStarts);
1799 if (istatus.lastAnyExit) {
1800 printf(" Last exit at %s\n", DateOf(istatus.lastAnyExit));
1802 if (istatus.lastErrorExit) {
1803 is1 = is2 = is3 = is4 = NULL;
1804 printf(" Last error exit at %s, ", DateOf(istatus.lastErrorExit));
1805 code = BOZO_GetInstanceStrings(aconn, aname, &is1, &is2, &is3, &is4);
1806 /* don't complain about failing call, since could simply mean
1807 * interface mismatch.
1811 /* non-null instance string */
1812 printf("by %s, ", is1);
1819 if (istatus.errorSignal) {
1820 if (istatus.errorSignal == SIGTERM)
1821 printf("due to shutdown request\n");
1823 printf("due to signal %d\n", istatus.errorSignal);
1825 printf("by exiting with code %d\n", istatus.errorCode);
1829 /* try to display all the parms */
1832 code = BOZO_GetInstanceParm(aconn, aname, i, &tp);
1835 printf(" Command %d is '%s'\n", i + 1, buffer);
1838 code = BOZO_GetInstanceParm(aconn, aname, 999, &tp);
1840 /* Any type of failure is treated as not having a notifier program */
1841 printf(" Notifier is '%s'\n", buffer);
1849 GetRestrict(struct cmd_syndesc *as, void *arock)
1851 struct rx_connection *tconn;
1852 afs_int32 code, val;
1854 tconn = GetConn(as, 0);
1855 code = BOZO_GetRestrictedMode(tconn, &val);
1857 printf("bos: failed to get restricted mode (%s)\n", em(code));
1859 printf("Restricted mode is %s\n", val ? "on" : "off");
1865 SetRestrict(struct cmd_syndesc *as, void *arock)
1867 struct rx_connection *tconn;
1868 afs_int32 code, val;
1870 tconn = GetConn(as, 0);
1871 util_GetInt32(as->parms[1].items->data, &val);
1872 code = BOZO_SetRestrictedMode(tconn, val);
1874 printf("bos: failed to set restricted mode (%s)\n", em(code));
1879 add_std_args(struct cmd_syndesc *ts)
1881 cmd_Seek(ts, ADDPARMOFFSET);
1882 /* + 0 */ cmd_AddParm(ts, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell name");
1883 /* + 1 */ cmd_AddParm(ts, "-noauth", CMD_FLAG, CMD_OPTIONAL,
1884 "don't authenticate");
1885 /* + 2 */ cmd_AddParm(ts, "-localauth", CMD_FLAG, CMD_OPTIONAL,
1886 "create tickets from KeyFile");
1889 #include "AFS_component_version_number.c"
1892 main(int argc, char **argv)
1895 struct cmd_syndesc *ts;
1896 extern int afsconf_SawCell;
1898 #ifdef AFS_AIX32_ENV
1900 * The following signal action for AIX is necessary so that in case of a
1901 * crash (i.e. core is generated) we can include the user's data section
1902 * in the core dump. Unfortunately, by default, only a partial core is
1903 * generated which, in many cases, isn't too useful.
1905 struct sigaction nsa;
1907 sigemptyset(&nsa.sa_mask);
1908 nsa.sa_handler = SIG_DFL;
1909 nsa.sa_flags = SA_FULLDUMP;
1910 sigaction(SIGSEGV, &nsa, NULL);
1911 sigaction(SIGABRT, &nsa, NULL);
1917 printf("bos: could not initialize rx (%s)\n", em(code));
1921 /* To resolve a AFSCELL environment "Note: ..." problem: Because bos calls ka_Init (why?) before any
1922 * checkup on the existance of a "-cell" option on the particular bos command we don't print the
1923 * message if a cell is passed in. Luckily the rest of the programs don't call these adhoc routines
1924 * and things work fine. Note that if the "-cell" isn't passed then we're still ok since later on
1925 * the proper routine (afsconf_GetCellInfo) is going to be called to do the right thing.
1927 afsconf_SawCell = 1; /* Means don't print warning if AFSCELL is set */
1929 afsconf_SawCell = 0; /* Reset it */
1930 /* don't check error code, since fails sometimes when we're setting up a
1932 initialize_CMD_error_table();
1933 initialize_BZ_error_table();
1935 ts = cmd_CreateSyntax("start", StartServer, NULL, "start running a server");
1936 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1937 cmd_AddParm(ts, "-instance", CMD_LIST, 0, "server process name");
1940 ts = cmd_CreateSyntax("stop", StopServer, NULL, "halt a server instance");
1941 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1942 cmd_AddParm(ts, "-instance", CMD_LIST, 0, "server process name");
1944 cmd_AddParm(ts, "-wait", CMD_FLAG, CMD_OPTIONAL,
1945 "wait for process to stop");
1948 ts = cmd_CreateSyntax("status", StatServer, NULL,
1949 "show server instance status");
1950 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1951 cmd_AddParm(ts, "-instance", CMD_LIST, CMD_OPTIONAL,
1952 "server process name");
1953 cmd_AddParm(ts, "-long", CMD_FLAG, CMD_OPTIONAL, "long status");
1956 ts = cmd_CreateSyntax("shutdown", Shutdown, NULL, "shutdown all processes");
1957 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1958 cmd_AddParm(ts, "-instance", CMD_LIST, CMD_OPTIONAL, "instances");
1960 cmd_AddParm(ts, "-wait", CMD_FLAG, CMD_OPTIONAL,
1961 "wait for process to stop");
1964 ts = cmd_CreateSyntax("startup", Startup, NULL, "start all processes");
1965 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1966 cmd_AddParm(ts, "-instance", CMD_LIST, CMD_OPTIONAL, "instances");
1969 ts = cmd_CreateSyntax("restart", Restart, NULL, "restart processes");
1970 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1971 cmd_AddParm(ts, "-instance", CMD_LIST, CMD_OPTIONAL, "instances");
1972 cmd_AddParm(ts, "-bosserver", CMD_FLAG, CMD_OPTIONAL,
1973 "restart bosserver");
1974 cmd_AddParm(ts, "-all", CMD_FLAG, CMD_OPTIONAL, "restart all processes");
1979 ts = cmd_CreateSyntax("create", CreateServer, NULL,
1980 "create a new server instance");
1981 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1982 cmd_AddParm(ts, "-instance", CMD_SINGLE, 0, "server process name");
1983 cmd_AddParm(ts, "-type", CMD_SINGLE, 0, "server type");
1984 cmd_AddParm(ts, "-cmd", CMD_LIST, 0, "command lines");
1985 cmd_AddParm(ts, "-notifier", CMD_SINGLE, CMD_OPTIONAL,
1986 "Notifier program");
1989 ts = cmd_CreateSyntax("delete", DeleteServer, NULL,
1990 "delete a server instance");
1991 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1992 cmd_AddParm(ts, "-instance", CMD_LIST, 0, "server process name");
1995 ts = cmd_CreateSyntax("adduser", AddSUser, NULL,
1996 "add users to super-user list");
1997 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1998 cmd_AddParm(ts, "-user", CMD_LIST, 0, "user names");
2001 ts = cmd_CreateSyntax("removeuser", RemoveSUser, NULL,
2002 "remove users from super-user list");
2003 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2004 cmd_AddParm(ts, "-user", CMD_LIST, 0, "user names");
2007 ts = cmd_CreateSyntax("listusers", ListSUsers, NULL, "list super-users");
2008 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2011 ts = cmd_CreateSyntax("addkey", AddKey, NULL,
2012 "add keys to key dbase (kvno 999 is bcrypt)");
2013 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2014 cmd_AddParm(ts, "-key", CMD_SINGLE, CMD_OPTIONAL, "key");
2015 cmd_AddParm(ts, "-kvno", CMD_SINGLE, 0, "key version number");
2018 ts = cmd_CreateSyntax("removekey", RemoveKey, NULL,
2019 "remove keys from key dbase");
2020 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2021 cmd_AddParm(ts, "-kvno", CMD_LIST, 0, "key version number");
2024 ts = cmd_CreateSyntax("listkeys", ListKeys, NULL, "list keys");
2025 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2026 cmd_AddParm(ts, "-showkey", CMD_FLAG, CMD_OPTIONAL,
2027 "show the actual key rather than the checksum");
2030 ts = cmd_CreateSyntax("listhosts", ListHosts, NULL, "get cell host list");
2031 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2033 cmd_CreateAlias(ts, "getcell");
2035 ts = cmd_CreateSyntax("setcellname", SetCellName, NULL, "set cell name");
2036 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2037 cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "cell name");
2040 ts = cmd_CreateSyntax("addhost", AddHost, NULL, "add host to cell dbase");
2041 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2042 cmd_AddParm(ts, "-host", CMD_LIST, 0, "host name");
2043 cmd_AddParm(ts, "-clone", CMD_FLAG, CMD_OPTIONAL, "vote doesn't count");
2046 ts = cmd_CreateSyntax("removehost", RemoveHost, NULL,
2047 "remove host from cell dbase");
2048 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2049 cmd_AddParm(ts, "-host", CMD_LIST, 0, "host name");
2052 ts = cmd_CreateSyntax("setauth", SetAuth, NULL,
2053 "set authentication required flag");
2054 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2055 cmd_AddParm(ts, "-authrequired", CMD_SINGLE, 0,
2056 "on or off: authentication required for admin requests");
2059 ts = cmd_CreateSyntax("install", Install, NULL, "install program");
2060 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2061 cmd_AddParm(ts, "-file", CMD_LIST, 0, "files to install");
2062 cmd_AddParm(ts, "-dir", CMD_SINGLE, CMD_OPTIONAL, "destination dir");
2065 ts = cmd_CreateSyntax("uninstall", UnInstall, NULL, "uninstall program");
2066 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2067 cmd_AddParm(ts, "-file", CMD_LIST, 0, "files to uninstall");
2068 cmd_AddParm(ts, "-dir", CMD_SINGLE, CMD_OPTIONAL, "destination dir");
2071 ts = cmd_CreateSyntax("getlog", GetLogCmd, NULL, "examine log file");
2072 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2073 cmd_AddParm(ts, "-file", CMD_SINGLE, 0, "log file to examine");
2076 ts = cmd_CreateSyntax("getdate", GetDate, NULL, "get dates for programs");
2077 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2078 cmd_AddParm(ts, "-file", CMD_LIST, 0, "files to check");
2079 cmd_AddParm(ts, "-dir", CMD_SINGLE, CMD_OPTIONAL, "destination dir");
2082 ts = cmd_CreateSyntax("exec", Exec, NULL, "execute shell command on server");
2083 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2084 cmd_AddParm(ts, "-cmd", CMD_SINGLE, 0, "command to execute");
2087 ts = cmd_CreateSyntax("prune", Prune, NULL, "prune server files");
2088 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2089 cmd_AddParm(ts, "-bak", CMD_FLAG, CMD_OPTIONAL, "delete .BAK files");
2090 cmd_AddParm(ts, "-old", CMD_FLAG, CMD_OPTIONAL, "delete .OLD files");
2091 cmd_AddParm(ts, "-core", CMD_FLAG, CMD_OPTIONAL, "delete core files");
2092 cmd_AddParm(ts, "-all", CMD_FLAG, CMD_OPTIONAL, "delete all junk files");
2095 ts = cmd_CreateSyntax("setrestart", SetRestartCmd, NULL,
2096 "set restart times");
2097 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_REQUIRED, "machine name");
2098 cmd_AddParm(ts, "-time", CMD_SINGLE, CMD_REQUIRED,
2099 "time to restart server");
2100 cmd_AddParm(ts, "-general", CMD_FLAG, CMD_OPTIONAL,
2101 "set general restart time");
2102 cmd_AddParm(ts, "-newbinary", CMD_FLAG, CMD_OPTIONAL,
2103 "set new binary restart time");
2105 cmd_CreateAlias(ts, "setr");
2107 ts = cmd_CreateSyntax("getrestart", GetRestartCmd, NULL,
2108 "get restart times");
2109 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_REQUIRED, "machine name");
2111 cmd_CreateAlias(ts, "getr");
2113 ts = cmd_CreateSyntax("salvage", SalvageCmd, NULL,
2114 "salvage partition or volumes");
2115 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2116 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL,
2117 "salvage partition");
2118 cmd_AddParm(ts, "-volume", CMD_SINGLE, CMD_OPTIONAL,
2119 "salvage volume number or volume name");
2120 cmd_AddParm(ts, "-file", CMD_SINGLE, CMD_OPTIONAL,
2121 "salvage log output file");
2122 cmd_AddParm(ts, "-all", CMD_FLAG, CMD_OPTIONAL, "salvage whole server");
2123 cmd_AddParm(ts, "-showlog", CMD_FLAG, CMD_OPTIONAL,
2124 "display salvage log");
2125 cmd_AddParm(ts, "-parallel", CMD_SINGLE, CMD_OPTIONAL,
2126 "# of max parallel partition salvaging");
2127 cmd_AddParm(ts, "-tmpdir", CMD_SINGLE, CMD_OPTIONAL,
2128 "directory to place tmp files");
2129 cmd_AddParm(ts, "-orphans", CMD_SINGLE, CMD_OPTIONAL,
2130 "ignore | remove | attach");
2131 cmd_AddParm(ts, "-forceDAFS", CMD_FLAG, CMD_OPTIONAL,
2132 "(DAFS) force salvage of demand attach fileserver");
2133 cmd_AddParm(ts, "-debug", CMD_FLAG, CMD_OPTIONAL,
2134 "(MR-AFS) Run in Debugging mode");
2135 cmd_AddParm(ts, "-nowrite", CMD_FLAG, CMD_OPTIONAL,
2136 "(MR-AFS) Run readonly/test mode");
2137 cmd_AddParm(ts, "-force", CMD_FLAG, CMD_OPTIONAL,
2138 "(MR-AFS) Force full salvaging");
2139 cmd_AddParm(ts, "-oktozap", CMD_FLAG, CMD_OPTIONAL,
2140 "(MR-AFS) Give permission to destroy bogus file residencies/volumes - debugging flag");
2141 cmd_AddParm(ts, "-rootfiles", CMD_FLAG, CMD_OPTIONAL,
2142 "(MR-AFS) Show files owned by root - debugging flag");
2143 cmd_AddParm(ts, "-salvagedirs", CMD_FLAG, CMD_OPTIONAL,
2144 "(MR-AFS) Force rebuild/salvage of all directories");
2145 cmd_AddParm(ts, "-blockreads", CMD_FLAG, CMD_OPTIONAL,
2146 "(MR-AFS) Read smaller blocks to handle IO/bad blocks");
2147 cmd_AddParm(ts, "-ListResidencies", CMD_FLAG, CMD_OPTIONAL,
2148 "(MR-AFS) Just list affected file residencies - debugging flag");
2149 cmd_AddParm(ts, "-SalvageRemote", CMD_FLAG, CMD_OPTIONAL,
2150 "(MR-AFS) Salvage storage systems that are not directly attached");
2151 cmd_AddParm(ts, "-SalvageArchival", CMD_FLAG, CMD_OPTIONAL,
2152 "(MR-AFS) Salvage HSM storage systems");
2153 cmd_AddParm(ts, "-IgnoreCheck", CMD_FLAG, CMD_OPTIONAL,
2154 "(MR-AFS) Don't perform VLDB safety check when deleting unreferenced files. Only a good idea in single server cell.");
2155 cmd_AddParm(ts, "-ForceOnLine", CMD_FLAG, CMD_OPTIONAL,
2156 "(MR-AFS) Force the volume to come online, even if it hasn't salvaged cleanly.");
2157 cmd_AddParm(ts, "-UseRootDirACL", CMD_FLAG, CMD_OPTIONAL,
2158 "(MR-AFS) Use the root directory ACL for lost+found directory if it is created.");
2159 cmd_AddParm(ts, "-TraceBadLinkCounts", CMD_FLAG, CMD_OPTIONAL,
2160 "(MR-AFS) Print out lines about volume reference count changes.");
2161 cmd_AddParm(ts, "-DontAskFS", CMD_FLAG, CMD_OPTIONAL,
2162 "(MR-AFS) Don't ask fileserver to take volume offline. THIS IS VERY DANGEROUS.");
2163 cmd_AddParm(ts, "-LogLevel", CMD_SINGLE, CMD_OPTIONAL,
2164 "(MR-AFS) log level");
2165 cmd_AddParm(ts, "-rxdebug", CMD_FLAG, CMD_OPTIONAL,
2166 "(MR-AFS) Write out rx debug information.");
2167 cmd_AddParm(ts, "-Residencies", CMD_SINGLE, CMD_OPTIONAL,
2168 "(MR-AFS) Numeric mask of residencies to be included in the salvage. Do not use with -SalvageRemote or -SalvageArchival");
2171 ts = cmd_CreateSyntax("blockscanner", BlockScannerCmd, NULL,
2172 "block scanner daemon from making migration requests");
2173 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_REQUIRED, "machine name");
2176 ts = cmd_CreateSyntax("unblockscanner", UnBlockScannerCmd, NULL,
2177 "allow scanner daemon to make migration requests again");
2178 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_REQUIRED, "machine name");
2181 ts = cmd_CreateSyntax("getrestricted", GetRestrict, NULL,
2182 "get restrict mode");
2183 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2186 ts = cmd_CreateSyntax("setrestricted", SetRestrict, NULL,
2187 "set restrict mode");
2188 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2189 cmd_AddParm(ts, "-mode", CMD_SINGLE, 0, "mode to set");
2193 code = cmd_Dispatch(argc, argv);