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>
26 #include <afs/cellconfig.h>
28 #include <afs/com_err.h>
30 #include <afs/ktime.h>
31 #include <afs/kautils.h>
32 #include <afs/afsint.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 "bnode_internal.h"
41 #include "bosprototypes.h"
43 /* command offsets for bos salvage command */
44 #define MRAFS_OFFSET 10
45 #define ADDPARMOFFSET 27
47 /* MR-AFS salvage parameters */
48 struct MRAFSSalvageParms {
53 afs_int32 Optrootfiles;
54 afs_int32 Optsalvagedirs;
55 afs_int32 Optblockreads;
56 afs_int32 OptListResidencies;
57 afs_int32 OptSalvageRemote;
58 afs_int32 OptSalvageArchival;
59 afs_int32 OptIgnoreCheck;
60 afs_int32 OptForceOnLine;
61 afs_int32 OptUseRootDirACL;
62 afs_int32 OptTraceBadLinkCounts;
63 afs_int32 OptDontAskFS;
64 afs_int32 OptLogLevel;
66 afs_uint32 OptResidencies;
69 /* dummy routine for the audit work. It should do nothing since audits */
70 /* occur at the server level and bos is not a server. */
76 /* keep those lines small */
81 return "communications failure (-1)";
83 return "communications timeout (-3)";
85 return (char *)afs_error_message(acode);
88 /* get partition id from a name */
89 /* XXX - unused code - could be removed? */
92 GetPartitionID(char *aname)
99 return -1; /* unknown */
100 /* numbers go straight through */
101 if (tc >= '0' && tc <= '9') {
104 /* otherwise check for vicepa or /vicepa, or just plain "a" */
106 if (strlen(aname) <= 2) {
107 strcpy(ascii, aname);
108 } else if (!strncmp(aname, "/vicep", 6)) {
109 strncpy(ascii, aname + 6, 2);
110 } else if (!strncmp(aname, "vicep", 5)) {
111 strncpy(ascii, aname + 5, 2);
113 return -1; /* bad partition name */
114 /* now partitions are named /vicepa ... /vicepz, /vicepaa, /vicepab,
115 * .../vicepzz, and are numbered from 0. Do the appropriate conversion */
117 /* one char name, 0..25 */
118 if (ascii[0] < 'a' || ascii[0] > 'z')
119 return -1; /* wrongo */
120 return ascii[0] - 'a';
122 /* two char name, 26 .. <whatever> */
123 if (ascii[0] < 'a' || ascii[0] > 'z')
124 return -1; /* wrongo */
125 if (ascii[1] < 'a' || ascii[1] > 'z')
126 return -1; /* just as bad */
127 return (ascii[0] - 'a') * 26 + (ascii[1] - 'a') + 26;
132 /* make ctime easier to use */
134 DateOf(afs_int32 atime)
136 static char tbuffer[30];
138 time_t t = (time_t) atime;
142 tbuffer[24] = 0; /* get rid of new line */
144 strcpy(tbuffer, "BAD TIME");
149 /* use the syntax descr to get a connection, authenticated appropriately.
150 * aencrypt is set if we want to encrypt the data on the wire.
152 static struct rx_connection *
153 GetConn(struct cmd_syndesc *as, int aencrypt)
157 char *cellname = NULL;
160 struct rx_connection *tconn;
162 struct afsconf_dir *tdir = NULL;
163 afsconf_secflags secFlags;
164 struct rx_securityClass *sc;
167 hostname = as->parms[0].items->data;
168 th = hostutil_GetHostByName(hostname);
170 printf("bos: can't find address for host '%s'\n", hostname);
173 memcpy(&addr, th->h_addr, sizeof(afs_int32));
175 secFlags = AFSCONF_SECOPTS_FALLBACK_NULL;
177 if (as->parms[ADDPARMOFFSET + 2].items) { /* -localauth */
178 secFlags |= AFSCONF_SECOPTS_LOCALAUTH;
179 confdir = AFSDIR_SERVER_ETC_DIRPATH;
181 confdir = AFSDIR_CLIENT_ETC_DIRPATH;
184 if (as->parms[ADDPARMOFFSET + 1].items) { /* -noauth */
185 secFlags |= AFSCONF_SECOPTS_NOAUTH;
187 /* If we're running with -noauth, we don't need a configuration
189 tdir = afsconf_Open(confdir);
191 printf("bos: can't open cell database (%s)\n", confdir);
196 if (as->parms[ADDPARMOFFSET].items) /* -cell */
197 cellname = as->parms[ADDPARMOFFSET].items->data;
199 code = afsconf_PickClientSecObj(tdir, secFlags, NULL, cellname,
200 &sc, &scIndex, NULL);
202 afs_com_err("bos", code, "(configuring connection security)");
206 if (scIndex == RX_SECIDX_NULL)
207 fprintf(stderr, "bos: running unauthenticated\n");
210 rx_NewConnection(addr, htons(AFSCONF_NANNYPORT), 1, sc, scIndex);
212 fprintf(stderr, "bos: could not create rx connection\n");
221 SetAuth(struct cmd_syndesc *as, void *arock)
224 struct rx_connection *tconn;
228 tconn = GetConn(as, 0);
229 tp = as->parms[1].items->data;
230 if (strcmp(tp, "on") == 0)
231 flag = 0; /* auth req.: noauthflag is false */
232 else if (strcmp(tp, "off") == 0)
236 ("bos: illegal authentication specifier '%s', must be 'off' or 'on'.\n",
240 code = BOZO_SetNoAuthFlag(tconn, flag);
242 afs_com_err("bos", code, "(failed to set authentication flag)");
246 /* take a name (e.g. foo/bar, and a dir e.g. /usr/afs/bin, and construct
247 * /usr/afs/bin/bar */
249 ComputeDestDir(char *aname, char *adir, char *aresult, afs_int32 alen)
253 strcpy(aresult, adir);
254 tp = strrchr(aname, '/');
257 strcat(aresult, "/");
258 strcat(aresult, aname);
260 /* tp points at the / character */
266 /* copy data from fd afd to rx call acall */
268 CopyBytes(int afd, struct rx_call *acall)
275 len = read(afd, tbuffer, sizeof(tbuffer));
279 return 0; /* all done */
280 code = rx_Write(acall, tbuffer, len);
287 Prune(struct cmd_syndesc *as, void *arock)
290 struct rx_connection *tconn;
293 tconn = GetConn(as, 0);
295 if (as->parms[1].items)
296 flags |= BOZO_PRUNEBAK;
297 if (as->parms[2].items)
298 flags |= BOZO_PRUNEOLD;
299 if (as->parms[3].items)
300 flags |= BOZO_PRUNECORE;
301 if (as->parms[4].items)
303 code = BOZO_Prune(tconn, flags);
305 afs_com_err("bos", code, "(failed to prune server files)");
310 Exec(struct cmd_syndesc *as, void *arock)
312 struct rx_connection *tconn;
315 tconn = GetConn(as, 0);
316 code = BOZO_Exec(tconn, as->parms[1].items->data);
318 printf("bos: failed to execute command (%s)\n", em(code));
323 GetDate(struct cmd_syndesc *as, void *arock)
328 afs_int32 time, bakTime, oldTime;
329 struct rx_connection *tconn;
332 tconn = GetConn(as, 0);
333 if (!as->parms[1].items) {
334 printf("bos: no files to check\n");
338 /* compute dest dir or file; default MUST be canonical form of dir path */
339 if (as->parms[2].items)
340 strcpy(destDir, as->parms[2].items->data);
342 strcpy(destDir, AFSDIR_CANONICAL_SERVER_BIN_DIRPATH);
344 for (ti = as->parms[1].items; ti; ti = ti->next) {
345 /* check date for each file */
346 ComputeDestDir(ti->data, destDir, tbuffer, sizeof(tbuffer));
347 code = BOZO_GetDates(tconn, tbuffer, &time, &bakTime, &oldTime);
349 printf("bos: failed to check date on %s (%s)\n", ti->data,
353 printf("File %s ", tbuffer);
355 printf("does not exist, ");
357 printf("dated %s, ", DateOf(time));
359 printf("no .BAK file, ");
361 printf(".BAK file dated %s, ", DateOf(bakTime));
363 printf("no .OLD file.");
365 printf(".OLD file dated %s.", DateOf(oldTime));
373 UnInstall(struct cmd_syndesc *as, void *arock)
379 struct rx_connection *tconn;
381 tconn = GetConn(as, 0);
382 if (!as->parms[1].items) {
383 printf("bos: no files to uninstall\n");
387 /* compute dest dir or file; default MUST be canonical form of dir path */
388 if (as->parms[2].items)
389 strcpy(destDir, as->parms[2].items->data);
391 strcpy(destDir, AFSDIR_CANONICAL_SERVER_BIN_DIRPATH);
393 for (ti = as->parms[1].items; ti; ti = ti->next) {
394 /* uninstall each file */
395 ComputeDestDir(ti->data, destDir, tbuffer, sizeof(tbuffer));
396 code = BOZO_UnInstall(tconn, tbuffer);
398 printf("bos: failed to uninstall %s (%s)\n", ti->data, em(code));
401 printf("bos: uninstalled file %s\n", ti->data);
407 GetServerGoal(struct rx_connection *aconn, char *aname)
412 struct bozo_status istatus;
415 code = BOZO_GetInstanceInfo(aconn, aname, &tp, &istatus);
417 printf("bos: failed to get instance info for '%s' (%s)\n", aname,
419 /* if we can't get the answer, assume its running */
422 if (istatus.goal == 0)
423 return BSTAT_SHUTDOWN;
429 Install(struct cmd_syndesc *as, void *arock)
431 struct rx_connection *tconn;
437 struct rx_call *tcall;
440 tconn = GetConn(as, 0);
441 if (!as->parms[1].items) {
442 printf("bos: no files to install\n");
446 /* compute dest dir or file; default MUST be canonical form of dir path */
447 if (as->parms[2].items)
448 strcpy(destDir, as->parms[2].items->data);
450 strcpy(destDir, AFSDIR_CANONICAL_SERVER_BIN_DIRPATH);
452 for (ti = as->parms[1].items; ti; ti = ti->next) {
453 /* install each file */
454 fd = open(ti->data, O_RDONLY);
456 /* better to quit on error than continue for install command */
457 printf("bos: can't find file '%s', quitting\n", ti->data);
460 code = fstat(fd, &tstat);
462 printf("bos: failed to stat file %s, errno is %d\n", ti->data,
466 /* compute destination dir */
467 ComputeDestDir(ti->data, destDir, tbuffer, sizeof(tbuffer));
468 tcall = rx_NewCall(tconn);
470 StartBOZO_Install(tcall, tbuffer, tstat.st_size,
471 (afs_int32) tstat.st_mode, tstat.st_mtime);
473 code = CopyBytes(fd, tcall);
475 code = rx_EndCall(tcall, code);
477 printf("bos: failed to install %s (%s)\n", ti->data, em(code));
480 printf("bos: installed file %s\n", ti->data);
486 Shutdown(struct cmd_syndesc *as, void *arock)
488 struct rx_connection *tconn;
492 tconn = GetConn(as, 0);
493 if (as->parms[1].items == 0) {
494 code = BOZO_ShutdownAll(tconn);
496 printf("bos: failed to shutdown servers (%s)\n", em(code));
498 for (ti = as->parms[1].items; ti; ti = ti->next) {
499 code = BOZO_SetTStatus(tconn, ti->data, BSTAT_SHUTDOWN);
501 printf("bos: failed to shutdown instance %s (%s)\n", ti->data,
505 if (as->parms[8].items) {
506 code = BOZO_WaitAll(tconn);
508 printf("bos: can't wait for processes to shutdown (%s)\n",
515 BlockScannerCmd(struct cmd_syndesc *as, void *arock)
518 struct rx_connection *tconn;
519 char BlockCommand[] = "/usr/afs/bin/scanner -block";
521 tconn = GetConn(as, 0);
522 code = BOZO_Exec(tconn, BlockCommand);
525 ("bos: failed to block scanner from making migration requests (%s)\n",
531 UnBlockScannerCmd(struct cmd_syndesc *as, void *arock)
534 struct rx_connection *tconn;
535 char UnBlockCommand[] = "/usr/afs/bin/scanner -unblock";
537 tconn = GetConn(as, 0);
538 code = BOZO_Exec(tconn, UnBlockCommand);
541 ("bos: failed to allow scanner daemon to make migration requests again (%s)\n",
547 GetRestartCmd(struct cmd_syndesc *as, void *arock)
550 struct ktime generalTime, newBinaryTime;
551 char messageBuffer[256];
552 struct rx_connection *tconn;
555 hostp = as->parms[0].items->data; /* host name for messages */
556 tconn = GetConn(as, 0);
558 code = BOZO_GetRestartTime(tconn, 1, (struct bozo_netKTime *) &generalTime);
560 printf("bos: failed to retrieve restart information (%s)\n",
564 code = BOZO_GetRestartTime(tconn, 2, (struct bozo_netKTime *) &newBinaryTime);
566 printf("bos: failed to retrieve restart information (%s)\n",
571 code = ktime_DisplayString(&generalTime, messageBuffer);
573 printf("bos: failed to decode restart time (%s)\n", em(code));
576 printf("Server %s restarts %s\n", hostp, messageBuffer);
578 code = ktime_DisplayString(&newBinaryTime, messageBuffer);
580 printf("bos: failed to decode restart time (%s)\n", em(code));
583 printf("Server %s restarts for new binaries %s\n", hostp, messageBuffer);
590 SetRestartCmd(struct cmd_syndesc *as, void *arock)
594 struct ktime restartTime;
596 struct rx_connection *tconn;
599 tconn = GetConn(as, 0);
600 if (as->parms[2].items) {
604 if (as->parms[3].items) {
609 printf("bos: can't specify more than one restart time at a time\n");
613 type = 1; /* by default set general restart time */
615 if ((code = ktime_ParsePeriodic(as->parms[1].items->data, &restartTime))) {
616 printf("bos: failed to parse '%s' as periodic restart time(%s)\n",
617 as->parms[1].items->data, em(code));
621 code = BOZO_SetRestartTime(tconn, type, (struct bozo_netKTime *) &restartTime);
623 printf("bos: failed to set restart time at server (%s)\n", em(code));
630 Startup(struct cmd_syndesc *as, void *arock)
632 struct rx_connection *tconn;
636 tconn = GetConn(as, 0);
637 if (as->parms[1].items == 0) {
638 code = BOZO_StartupAll(tconn);
640 printf("bos: failed to startup servers (%s)\n", em(code));
642 for (ti = as->parms[1].items; ti; ti = ti->next) {
643 code = BOZO_SetTStatus(tconn, ti->data, BSTAT_NORMAL);
645 printf("bos: failed to start instance %s (%s)\n", ti->data,
653 Restart(struct cmd_syndesc *as, void *arock)
655 struct rx_connection *tconn;
659 tconn = GetConn(as, 0);
660 if (as->parms[2].items) {
661 /* this is really a rebozo command */
662 if (as->parms[1].items) {
663 /* specified specific things to restart, can't do this at the same
666 ("bos: can't specify both '-bos' and specific servers to restart.\n");
669 /* otherwise do a rebozo */
670 code = BOZO_ReBozo(tconn);
672 printf("bos: failed to restart bosserver (%s)\n", em(code));
675 if (as->parms[1].items == 0) {
676 if (as->parms[3].items) { /* '-all' */
677 code = BOZO_RestartAll(tconn);
679 printf("bos: failed to restart servers (%s)\n", em(code));
681 printf("bos: To restart all processes please specify '-all'\n");
683 if (as->parms[3].items) {
684 printf("bos: Can't use '-all' along with individual instances\n");
686 for (ti = as->parms[1].items; ti; ti = ti->next) {
687 code = BOZO_Restart(tconn, ti->data);
689 printf("bos: failed to restart instance %s (%s)\n",
698 SetCellName(struct cmd_syndesc *as, void *arock)
700 struct rx_connection *tconn;
703 tconn = GetConn(as, 0);
704 code = BOZO_SetCellName(tconn, as->parms[1].items->data);
706 printf("bos: failed to set cell (%s)\n", em(code));
711 AddHost(struct cmd_syndesc *as, void *arock)
713 struct rx_connection *tconn;
716 char name[MAXHOSTCHARS];
718 tconn = GetConn(as, 0);
719 for (ti = as->parms[1].items; ti; ti = ti->next) {
720 if (as->parms[2].items) {
721 if (strlen(ti->data) > MAXHOSTCHARS - 3) {
722 fprintf(stderr, "bos: host name too long\n");
726 strcpy(&name[1], ti->data);
727 strcat((char *)&name, "]");
728 code = BOZO_AddCellHost(tconn, name);
730 code = BOZO_AddCellHost(tconn, ti->data);
732 printf("bos: failed to add host %s (%s)\n", ti->data, em(code));
738 RemoveHost(struct cmd_syndesc *as, void *arock)
740 struct rx_connection *tconn;
744 tconn = GetConn(as, 0);
745 for (ti = as->parms[1].items; ti; ti = ti->next) {
746 code = BOZO_DeleteCellHost(tconn, ti->data);
748 printf("bos: failed to delete host %s (%s)\n", ti->data,
755 ListHosts(struct cmd_syndesc *as, void *arock)
757 struct rx_connection *tconn;
764 tconn = GetConn(as, 0);
765 code = BOZO_GetCellName(tconn, &tp);
767 printf("bos: failed to get cell name (%s)\n", em(code));
770 printf("Cell name is %s\n", tbuffer);
772 code = BOZO_GetCellHost(tconn, i, &tp);
776 printf("bos: failed to get cell host %d (%s)\n", i, em(code));
779 printf(" Host %d is %s\n", i + 1, tbuffer);
785 AddKey(struct cmd_syndesc *as, void *arock)
787 struct rx_connection *tconn;
789 struct ktc_encryptionKey tkey;
791 char buf[BUFSIZ], ver[BUFSIZ];
793 tconn = GetConn(as, 1);
794 memset(&tkey, 0, sizeof(struct ktc_encryptionKey));
796 if (as->parms[1].items)
797 strcpy(buf, as->parms[1].items->data);
800 code = UI_UTIL_read_pw_string(buf, sizeof(buf), "input key: ", 0);
801 if (code || strlen(buf) == 0) {
802 fprintf(stderr, "Bad key: \n");
805 code = UI_UTIL_read_pw_string(ver, sizeof(ver), "Retype input key: ", 0);
806 if (code || strlen(ver) == 0) {
807 fprintf(stderr, "Bad key: \n");
810 if (strcmp(ver, buf) != 0) {
811 fprintf(stderr, "\nInput key mismatch\n");
817 temp = atoi(as->parms[2].items->data);
821 strcpy((char *)&tkey, as->parms[1].items->data);
823 strcpy((char *)&tkey, buf);
824 } else { /* kerberos key */
826 if (as->parms[ADDPARMOFFSET].items) {
827 tcell = strdup(as->parms[ADDPARMOFFSET].items->data);
829 fprintf(stderr, "bos: Unable to allocate memory for cellname\n");
833 /* string to key needs upper-case cell names */
835 /* I don't believe this is true. The string to key function
836 * actually expands the cell name, then LOWER-CASES it. Perhaps it
837 * didn't use to??? */
838 ucstring(tcell, tcell, strlen(tcell));
840 tcell = NULL; /* no cell specified, use current */
842 ka_StringToKey(as->parms[1].items->data, tcell, &tkey);
844 ka_StringToKey(buf, tcell, &tkey);
849 code = BOZO_AddKey(tconn, temp, ktc_to_bozoptr(&tkey));
851 printf("bos: failed to set key %d (%s)\n", temp, em(code));
858 RemoveKey(struct cmd_syndesc *as, void *arock)
860 struct rx_connection *tconn;
865 tconn = GetConn(as, 0);
866 for (ti = as->parms[1].items; ti; ti = ti->next) {
867 temp = atoi(ti->data);
868 code = BOZO_DeleteKey(tconn, temp);
870 printf("bos: failed to delete key %d (%s)\n", temp, em(code));
878 ListKeys(struct cmd_syndesc *as, void *arock)
880 struct rx_connection *tconn;
882 struct ktc_encryptionKey tkey;
884 struct bozo_keyInfo keyInfo;
888 tconn = GetConn(as, 1);
891 code = BOZO_ListKeys(tconn, i, &kvno, ktc_to_bozoptr(&tkey), &keyInfo);
895 /* first check if key is returned */
896 if ((!ka_KeyIsZero((char *)&tkey, sizeof(tkey)))
897 && (as->parms[1].items)) {
898 printf("key %d is '", kvno);
899 ka_PrintBytes((char *)&tkey, sizeof(tkey));
902 if (keyInfo.keyCheckSum == 0) /* shouldn't happen */
903 printf("key version is %d\n", kvno);
905 printf("key %d has cksum %u\n", kvno, keyInfo.keyCheckSum);
909 printf("Keys last changed on %s.\n", DateOf(keyInfo.mod_sec));
912 printf("bos: %s error encountered while listing keys\n", em(code));
914 printf("All done.\n");
919 AddSUser(struct cmd_syndesc *as, void *arock)
921 struct rx_connection *tconn;
927 tconn = GetConn(as, 0);
928 for (ti = as->parms[1].items; ti; ti = ti->next) {
929 code = BOZO_AddSUser(tconn, ti->data);
931 printf("bos: failed to add user '%s' (%s)\n", ti->data, em(code));
939 RemoveSUser(struct cmd_syndesc *as, void *arock)
941 struct rx_connection *tconn;
947 tconn = GetConn(as, 0);
948 for (ti = as->parms[1].items; ti; ti = ti->next) {
949 code = BOZO_DeleteSUser(tconn, ti->data);
951 printf("bos: failed to delete user '%s', ", ti->data);
953 printf("(no such user)\n");
955 printf("(%s)\n", em(code));
962 #define NPERLINE 10 /* dudes to print per line */
964 ListSUsers(struct cmd_syndesc *as, void *arock)
966 struct rx_connection *tconn;
971 int lastNL, printGreeting;
973 tconn = GetConn(as, 0);
978 code = BOZO_ListSUsers(tconn, i, &tp);
982 printGreeting = 0; /* delay until after first call succeeds */
983 printf("SUsers are: ");
985 printf("%s ", tbuffer);
986 if ((i % NPERLINE) == NPERLINE - 1) {
993 /* a real error code, instead of scanned past end */
994 printf("bos: failed to retrieve super-user list (%s)\n", em(code));
1003 StatServer(struct cmd_syndesc *as, void *arock)
1005 struct rx_connection *tconn;
1008 char ibuffer[BOZO_BSSIZE];
1012 /* int32p==1 is obsolete, smaller, printout */
1013 int32p = (as->parms[2].items != 0 ? 2 : 0);
1015 /* no parms does something pretty different */
1016 if (as->parms[1].items)
1017 return IStatServer(as, int32p);
1019 tconn = GetConn(as, 0);
1021 /* for each instance */
1023 code = BOZO_EnumerateInstance(tconn, i, &tp);
1027 printf("bos: failed to contact host's bosserver (%s).\n",
1031 DoStat(ibuffer, tconn, int32p, (i == 0)); /* print status line */
1037 CreateServer(struct cmd_syndesc *as, void *arock)
1039 struct rx_connection *tconn;
1042 struct cmd_item *ti;
1044 char *type, *name, *notifier = NONOTIFIER;
1046 tconn = GetConn(as, 0);
1047 for (i = 0; i < 6; i++)
1049 for (i = 0, ti = as->parms[3].items; (ti && i < 6); ti = ti->next, i++) {
1050 parms[i] = ti->data;
1052 name = as->parms[1].items->data;
1053 type = as->parms[2].items->data;
1054 if ((ti = as->parms[4].items)) {
1055 notifier = ti->data;
1058 BOZO_CreateBnode(tconn, type, name, parms[0], parms[1], parms[2],
1059 parms[3], parms[4], notifier);
1062 ("bos: failed to create new server instance %s of type '%s' (%s)\n",
1063 name, type, em(code));
1069 DeleteServer(struct cmd_syndesc *as, void *arock)
1071 struct rx_connection *tconn;
1073 struct cmd_item *ti;
1076 tconn = GetConn(as, 0);
1077 for (ti = as->parms[1].items; ti; ti = ti->next) {
1078 code = BOZO_DeleteBnode(tconn, ti->data);
1081 printf("bos: can't delete running instance '%s'\n", ti->data);
1083 printf("bos: failed to delete instance '%s' (%s)\n", ti->data,
1091 StartServer(struct cmd_syndesc *as, void *arock)
1093 struct rx_connection *tconn;
1095 struct cmd_item *ti;
1098 tconn = GetConn(as, 0);
1099 for (ti = as->parms[1].items; ti; ti = ti->next) {
1100 code = BOZO_SetStatus(tconn, ti->data, BSTAT_NORMAL);
1102 printf("bos: failed to start instance '%s' (%s)\n", ti->data,
1109 StopServer(struct cmd_syndesc *as, void *arock)
1111 struct rx_connection *tconn;
1113 struct cmd_item *ti;
1116 tconn = GetConn(as, 0);
1117 for (ti = as->parms[1].items; ti; ti = ti->next) {
1118 code = BOZO_SetStatus(tconn, ti->data, BSTAT_SHUTDOWN);
1120 printf("bos: failed to change stop instance '%s' (%s)\n",
1121 ti->data, em(code));
1123 if (as->parms[8].items) {
1124 code = BOZO_WaitAll(tconn);
1126 printf("bos: can't wait for processes to shutdown (%s)\n",
1132 #define PARMBUFFERSSIZE 32
1135 DoSalvage(struct rx_connection * aconn, char * aparm1, char * aparm2,
1136 char * aoutName, afs_int32 showlog, char * parallel,
1137 char * atmpDir, char * orphans, int dafs,
1138 struct MRAFSSalvageParms * mrafsParm)
1143 char tbuffer[BOZO_BSSIZE];
1144 struct bozo_status istatus;
1145 struct rx_call *tcall;
1149 char partName[20]; /* canonical name for partition */
1150 char pbuffer[PARMBUFFERSSIZE];
1151 afs_int32 partNumber;
1152 char *notifier = NONOTIFIER;
1155 /* if a partition was specified, canonicalize the name, since
1156 * the salvager has a stupid partition ID parser */
1158 partNumber = volutil_GetPartitionID(aparm1);
1159 if (partNumber < 0) {
1160 printf("bos: could not parse partition ID '%s'\n", aparm1);
1163 tp = volutil_PartitionName(partNumber);
1165 printf("bos: internal error parsing partition ID '%s'\n", aparm1);
1168 strcpy(partName, tp);
1172 /* open the file name */
1174 outFile = fopen(aoutName, "w");
1176 printf("bos: can't open specified SalvageLog file '%s'\n",
1180 closeIt = 1; /* close this file later */
1183 closeIt = 0; /* don't close this file later */
1186 for (code = 2; code < 6; code++)
1191 /* MUST pass canonical (wire-format) salvager path to bosserver */
1193 /* single volume salvage */
1195 /* for DAFS, we call the salvagserver binary with special options.
1196 * in this mode, it simply uses SALVSYNC to tell the currently
1197 * running salvageserver to offline and salvage the volume in question */
1198 strncpy(tbuffer, AFSDIR_CANONICAL_SERVER_SALSRV_FILEPATH, BOZO_BSSIZE);
1200 if ((strlen(tbuffer) + 9 + strlen(partName) + 1 + strlen(aparm2) +
1202 printf("bos: command line too big\n");
1206 strcat(tbuffer, " -client ");
1207 strcat(tbuffer, partName);
1208 strcat(tbuffer, " ");
1209 strcat(tbuffer, aparm2);
1211 strncpy(tbuffer, AFSDIR_CANONICAL_SERVER_SALVAGER_FILEPATH, BOZO_BSSIZE);
1213 if ((strlen(tbuffer) + 1 + strlen(partName) + 1 + strlen(aparm2) +
1215 printf("bos: command line too big\n");
1219 strcat(tbuffer, " ");
1220 strcat(tbuffer, partName);
1221 strcat(tbuffer, " ");
1222 strcat(tbuffer, aparm2);
1225 /* partition salvage */
1226 strncpy(tbuffer, AFSDIR_CANONICAL_SERVER_SALVAGER_FILEPATH, BOZO_BSSIZE);
1227 if ((strlen(tbuffer) + 4 + strlen(partName) + 1) > BOZO_BSSIZE) {
1228 printf("bos: command line too big\n");
1231 strcat(tbuffer, " -force ");
1232 strcat(tbuffer, partName);
1235 /* For DAFS, specifying a single volume does not result in a standard
1236 * salvager call. Instead, it simply results in a SALVSYNC call to the
1237 * online salvager daemon. This interface does not give us the same rich
1238 * set of call flags. Thus, we skip these steps for DAFS single-volume
1240 if (!dafs || (*aparm2 == 0)) {
1241 /* add the parallel option if given */
1242 if (parallel != NULL) {
1243 if ((strlen(tbuffer) + 11 + strlen(parallel) + 1) > BOZO_BSSIZE) {
1244 printf("bos: command line too big\n");
1247 strcat(tbuffer, " -parallel ");
1248 strcat(tbuffer, parallel);
1251 /* add the tmpdir option if given */
1252 if (atmpDir != NULL) {
1253 if ((strlen(tbuffer) + 9 + strlen(atmpDir) + 1) > BOZO_BSSIZE) {
1254 printf("bos: command line too big\n");
1257 strcat(tbuffer, " -tmpdir ");
1258 strcat(tbuffer, atmpDir);
1261 /* add the orphans option if given */
1262 if (orphans != NULL) {
1263 if ((strlen(tbuffer) + 10 + strlen(orphans) + 1) > BOZO_BSSIZE) {
1264 printf("bos: command line too big\n");
1267 strcat(tbuffer, " -orphans ");
1268 strcat(tbuffer, orphans);
1271 if (mrafsParm->Optdebug)
1272 strcat(tbuffer, " -debug");
1273 if (mrafsParm->Optnowrite)
1274 strcat(tbuffer, " -nowrite");
1275 if (mrafsParm->Optforce)
1276 strcat(tbuffer, " -force");
1277 if (mrafsParm->Optoktozap)
1278 strcat(tbuffer, " -oktozap");
1279 if (mrafsParm->Optrootfiles)
1280 strcat(tbuffer, " -rootfiles");
1281 if (mrafsParm->Optsalvagedirs)
1282 strcat(tbuffer, " -salvagedirs");
1283 if (mrafsParm->Optblockreads)
1284 strcat(tbuffer, " -blockreads");
1285 if (mrafsParm->OptListResidencies)
1286 strcat(tbuffer, " -ListResidencies");
1287 if (mrafsParm->OptSalvageRemote)
1288 strcat(tbuffer, " -SalvageRemote");
1289 if (mrafsParm->OptSalvageArchival)
1290 strcat(tbuffer, " -SalvageArchival");
1291 if (mrafsParm->OptIgnoreCheck)
1292 strcat(tbuffer, " -IgnoreCheck");
1293 if (mrafsParm->OptForceOnLine)
1294 strcat(tbuffer, " -ForceOnLine");
1295 if (mrafsParm->OptUseRootDirACL)
1296 strcat(tbuffer, " -UseRootDirACL");
1297 if (mrafsParm->OptTraceBadLinkCounts)
1298 strcat(tbuffer, " -TraceBadLinkCounts");
1299 if (mrafsParm->OptDontAskFS)
1300 strcat(tbuffer, " -DontAskFS");
1301 if (mrafsParm->OptLogLevel) {
1302 sprintf(pbuffer, " -LogLevel %ld", afs_printable_int32_ld(mrafsParm->OptLogLevel));
1303 strcat(tbuffer, pbuffer);
1305 if (mrafsParm->OptRxDebug)
1306 strcat(tbuffer, " -rxdebug");
1307 if (mrafsParm->OptResidencies) {
1308 sprintf(pbuffer, " -Residencies %lu",
1309 afs_printable_uint32_lu(mrafsParm->OptResidencies));
1310 strcat(tbuffer, pbuffer);
1315 parms[1] = "now"; /* when to do it */
1317 BOZO_CreateBnode(aconn, "cron", "salvage-tmp", parms[0], parms[1],
1318 parms[2], parms[3], parms[4], notifier);
1320 printf("bos: failed to start 'salvager' (%s)\n", em(code));
1323 /* now wait for bnode to disappear */
1328 code = BOZO_GetInstanceInfo(aconn, "salvage-tmp", &tp, &istatus);
1331 if ((++count % 5) == 0)
1332 printf("bos: waiting for salvage to complete.\n");
1334 if (code != BZNOENT) {
1335 printf("bos: salvage failed (%s)\n", em(code));
1340 /* now print the log file to the output file */
1341 printf("bos: salvage completed\n");
1342 if (aoutName || showlog) {
1343 fprintf(outFile, "SalvageLog:\n");
1344 tcall = rx_NewCall(aconn);
1345 /* MUST pass canonical (wire-format) salvager log path to bosserver */
1347 StartBOZO_GetLog(tcall, AFSDIR_CANONICAL_SERVER_SLVGLOG_FILEPATH);
1349 rx_EndCall(tcall, code);
1354 code = rx_Read(tcall, &buffer, 1);
1357 putc(buffer, outFile);
1359 break; /* the end delimeter */
1361 code = rx_EndCall(tcall, 0);
1362 /* fall through into cleanup code */
1366 if (closeIt && outFile)
1372 GetLogCmd(struct cmd_syndesc *as, void *arock)
1374 struct rx_connection *tconn;
1375 struct rx_call *tcall;
1380 printf("Fetching log file '%s'...\n", as->parms[1].items->data);
1381 tconn = GetConn(as, 0);
1382 tcall = rx_NewCall(tconn);
1383 code = StartBOZO_GetLog(tcall, as->parms[1].items->data);
1385 rx_EndCall(tcall, code);
1391 code = rx_Read(tcall, &buffer, 1);
1397 break; /* the end delimeter */
1400 code = rx_EndCall(tcall, error);
1401 /* fall through into cleanup code */
1405 afs_com_err("bos", code, "(while reading log)");
1410 IsDAFS(struct rx_connection *aconn)
1412 char buffer[BOZO_BSSIZE];
1414 struct bozo_status istatus;
1419 code = BOZO_GetInstanceInfo(aconn, "dafs", &tp, &istatus);
1421 /* no dafs bnode; cannot be dafs */
1425 /* dafs bnode is running; we must be dafs */
1429 /* At this point, either we have neither a dafs nor fs bnode running, or
1430 * we have an fs bnode running but the dafs bnode is stopped.
1432 * If an fs bnode is running, we are obviously not DAFS. If an fs bnode
1433 * is not running and a dafs bnode is not running... it's not certain if
1434 * we are DAFS or not DAFS. Just return 0 in that case; it shouldn't much
1435 * matter what we return, anyway */
1440 SalvageCmd(struct cmd_syndesc *as, void *arock)
1442 struct rx_connection *tconn;
1443 afs_int32 code, rc, i;
1445 char tname[BOZO_BSSIZE];
1447 extern struct ubik_client *cstruct;
1448 afs_int32 curGoal, showlog = 0, dafs = 0, mrafs = 0;
1454 struct MRAFSSalvageParms mrafsParm;
1456 memset(&mrafsParm, 0, sizeof(mrafsParm));
1458 /* parm 0 is machine name, 1 is partition, 2 is volume, 3 is -all flag */
1459 tconn = GetConn(as, 0);
1463 /* find out whether fileserver is running demand attach fs */
1464 if (IsDAFS(tconn)) {
1466 serviceName = "dafs";
1467 /* Find out whether fileserver is running MR-AFS (has a scanner instance) */
1468 /* XXX this should really be done some other way, potentially by RPC */
1469 if ((code = BOZO_GetInstanceParm(tconn, serviceName, 4, &tp) == 0))
1473 /* Find out whether fileserver is running MR-AFS (has a scanner instance) */
1474 /* XXX this should really be done some other way, potentially by RPC */
1475 if ((code = BOZO_GetInstanceParm(tconn, serviceName, 3, &tp) == 0))
1479 /* we can do a volume, a partition or the whole thing, but not mixtures
1481 if (!as->parms[1].items && as->parms[2].items) {
1482 printf("bos: must specify partition to salvage individual volume.\n");
1485 if (as->parms[5].items && as->parms[3].items) {
1486 printf("bos: can not specify both -file and -showlog.\n");
1489 if (as->parms[4].items && (as->parms[1].items || as->parms[2].items)) {
1490 printf("bos: can not specify -all with other flags.\n");
1494 /* get the output file name, if any */
1495 if (as->parms[3].items)
1496 outName = as->parms[3].items->data;
1500 if (as->parms[5].items)
1503 /* parallel option */
1505 if (as->parms[6].items)
1506 parallel = as->parms[6].items->data;
1508 /* get the tmpdir filename if any */
1510 if (as->parms[7].items)
1511 tmpDir = as->parms[7].items->data;
1513 /* -orphans option */
1515 if (as->parms[8].items) {
1517 printf("Can't specify -orphans for MR-AFS fileserver\n");
1520 orphans = as->parms[8].items->data;
1524 if (!as->parms[9].items) { /* -forceDAFS flag */
1525 printf("This is a demand attach fileserver. Are you sure you want to proceed with a manual salvage?\n");
1526 printf("must specify -forceDAFS flag in order to proceed.\n");
1532 if (as->parms[MRAFS_OFFSET].items)
1533 mrafsParm.Optdebug = 1;
1534 if (as->parms[MRAFS_OFFSET + 1].items)
1535 mrafsParm.Optnowrite = 1;
1536 if (as->parms[MRAFS_OFFSET + 2].items)
1537 mrafsParm.Optforce = 1;
1538 if (as->parms[MRAFS_OFFSET + 3].items)
1539 mrafsParm.Optoktozap = 1;
1540 if (as->parms[MRAFS_OFFSET + 4].items)
1541 mrafsParm.Optrootfiles = 1;
1542 if (as->parms[MRAFS_OFFSET + 5].items)
1543 mrafsParm.Optsalvagedirs = 1;
1544 if (as->parms[MRAFS_OFFSET + 6].items)
1545 mrafsParm.Optblockreads = 1;
1546 if (as->parms[MRAFS_OFFSET + 7].items)
1547 mrafsParm.OptListResidencies = 1;
1548 if (as->parms[MRAFS_OFFSET + 8].items)
1549 mrafsParm.OptSalvageRemote = 1;
1550 if (as->parms[MRAFS_OFFSET + 9].items)
1551 mrafsParm.OptSalvageArchival = 1;
1552 if (as->parms[MRAFS_OFFSET + 10].items)
1553 mrafsParm.OptIgnoreCheck = 1;
1554 if (as->parms[MRAFS_OFFSET + 11].items)
1555 mrafsParm.OptForceOnLine = 1;
1556 if (as->parms[MRAFS_OFFSET + 12].items)
1557 mrafsParm.OptUseRootDirACL = 1;
1558 if (as->parms[MRAFS_OFFSET + 13].items)
1559 mrafsParm.OptTraceBadLinkCounts = 1;
1560 if (as->parms[MRAFS_OFFSET + 14].items)
1561 mrafsParm.OptDontAskFS = 1;
1562 if (as->parms[MRAFS_OFFSET + 15].items)
1563 mrafsParm.OptLogLevel =
1564 atoi(as->parms[MRAFS_OFFSET + 15].items->data);
1565 if (as->parms[MRAFS_OFFSET + 16].items)
1566 mrafsParm.OptRxDebug = 1;
1567 if (as->parms[MRAFS_OFFSET + 17].items) {
1568 if (as->parms[MRAFS_OFFSET + 8].items
1569 || as->parms[MRAFS_OFFSET + 9].items) {
1571 ("Can't specify -Residencies with -SalvageRemote or -SalvageArchival\n");
1575 util_GetUInt32(as->parms[MRAFS_OFFSET + 17].items->data,
1576 &mrafsParm.OptResidencies);
1578 printf("bos: '%s' is not a valid residency mask.\n",
1579 as->parms[MRAFS_OFFSET + 17].items->data);
1586 for (i = MRAFS_OFFSET; i < ADDPARMOFFSET; i++) {
1587 if (as->parms[i].items) {
1588 printf(" %s only possible for MR-AFS fileserver.\n",
1597 if (as->parms[4].items) {
1598 /* salvage whole enchilada */
1599 curGoal = GetServerGoal(tconn, serviceName);
1600 if (curGoal == BSTAT_NORMAL) {
1601 printf("bos: shutting down '%s'.\n", serviceName);
1602 code = BOZO_SetTStatus(tconn, serviceName, BSTAT_SHUTDOWN);
1604 printf("bos: failed to stop '%s' (%s)\n", serviceName, em(code));
1607 code = BOZO_WaitAll(tconn); /* wait for shutdown to complete */
1610 ("bos: failed to wait for file server shutdown, continuing.\n");
1612 /* now do the salvage operation */
1613 printf("Starting salvage.\n");
1614 rc = DoSalvage(tconn, NULL, NULL, outName, showlog, parallel, tmpDir,
1615 orphans, dafs, &mrafsParm);
1616 if (curGoal == BSTAT_NORMAL) {
1617 printf("bos: restarting %s.\n", serviceName);
1618 code = BOZO_SetTStatus(tconn, serviceName, BSTAT_NORMAL);
1620 printf("bos: failed to restart '%s' (%s)\n", serviceName, em(code));
1626 } else if (!as->parms[2].items) {
1627 if (!as->parms[1].items) {
1629 ("bos: must specify -all switch to salvage all partitions.\n");
1632 if (volutil_GetPartitionID(as->parms[1].items->data) < 0) {
1633 /* can't parse volume ID, so complain before shutting down
1636 printf("bos: can't interpret %s as partition ID.\n",
1637 as->parms[1].items->data);
1640 curGoal = GetServerGoal(tconn, serviceName);
1641 /* salvage a whole partition (specified by parms[1]) */
1642 if (curGoal == BSTAT_NORMAL) {
1643 printf("bos: shutting down '%s'.\n", serviceName);
1644 code = BOZO_SetTStatus(tconn, serviceName, BSTAT_SHUTDOWN);
1646 printf("bos: can't stop '%s' (%s)\n", serviceName, em(code));
1649 code = BOZO_WaitAll(tconn); /* wait for shutdown to complete */
1652 ("bos: failed to wait for file server shutdown, continuing.\n");
1654 /* now do the salvage operation */
1655 printf("Starting salvage.\n");
1656 rc = DoSalvage(tconn, as->parms[1].items->data, NULL, outName,
1657 showlog, parallel, tmpDir, orphans, dafs, &mrafsParm);
1658 if (curGoal == BSTAT_NORMAL) {
1659 printf("bos: restarting '%s'.\n", serviceName);
1660 code = BOZO_SetTStatus(tconn, serviceName, BSTAT_NORMAL);
1662 printf("bos: failed to restart '%s' (%s)\n", serviceName, em(code));
1669 /* salvage individual volume (don't shutdown fs first), just use
1670 * single-shot cron bnode. Must leave server running when using this
1671 * option, since salvager will ask file server for the volume */
1674 const char *confdir;
1677 if (as->parms[ADDPARMOFFSET].items)
1678 tmpname = as->parms[ADDPARMOFFSET].items->data;
1682 localauth = (as->parms[ADDPARMOFFSET + 2].items != 0);
1684 (localauth ? AFSDIR_SERVER_ETC_DIRPATH :
1685 AFSDIR_CLIENT_ETC_DIRPATH);
1687 code = vsu_ClientInit(confdir, tmpname,
1688 AFSCONF_SECOPTS_FALLBACK_NULL |
1689 AFSCONF_SECOPTS_NOAUTH,
1693 newID = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err);
1695 printf("bos: can't interpret %s as volume name or ID\n",
1696 as->parms[2].items->data);
1699 sprintf(tname, "%u", newID);
1702 ("bos: can't initialize volume system client (code %d), trying anyway.\n",
1704 strncpy(tname, as->parms[2].items->data, sizeof(tname));
1706 if (volutil_GetPartitionID(as->parms[1].items->data) < 0) {
1707 /* can't parse volume ID, so complain before shutting down
1710 printf("bos: can't interpret %s as partition ID.\n",
1711 as->parms[1].items->data);
1714 printf("Starting salvage.\n");
1715 rc = DoSalvage(tconn, as->parms[1].items->data, tname, outName,
1716 showlog, parallel, tmpDir, orphans, dafs, &mrafsParm);
1724 IStatServer(struct cmd_syndesc *as, int int32p)
1726 struct rx_connection *tconn;
1727 struct cmd_item *ti;
1730 tconn = GetConn(as, 0);
1731 for (ti = as->parms[1].items; ti; ti = ti->next) {
1732 DoStat(ti->data, tconn, int32p, firstTime);
1739 DoStat(IN char *aname,
1740 IN struct rx_connection *aconn,
1742 IN int firstTime) /* true iff first instance in cmd */
1748 struct bozo_status istatus;
1750 char *is1, *is2, *is3, *is4; /* instance strings */
1753 code = BOZO_GetInstanceInfo(aconn, aname, &tp, &istatus);
1755 printf("bos: failed to get instance info for '%s' (%s)\n", aname,
1759 if (firstTime && aint32p && (istatus.flags & BOZO_BADDIRACCESS))
1761 ("Bosserver reports inappropriate access on server directories\n");
1762 printf("Instance %s, ", aname);
1764 printf("(type is %s) ", buffer);
1765 if (istatus.fileGoal == istatus.goal) {
1767 printf("disabled, ");
1769 if (istatus.fileGoal)
1770 printf("temporarily disabled, ");
1772 printf("temporarily enabled, ");
1775 if (istatus.flags & BOZO_ERRORSTOP)
1776 printf("stopped for too many errors, ");
1777 if (istatus.flags & BOZO_HASCORE)
1778 printf("has core file, ");
1781 code = BOZO_GetStatus(aconn, aname, &temp, &tp);
1783 printf("bos: failed to get status for instance '%s' (%s)\n", aname,
1786 printf("currently ");
1787 if (temp == BSTAT_NORMAL)
1788 printf("running normally.\n");
1789 else if (temp == BSTAT_SHUTDOWN)
1790 printf("shutdown.\n");
1791 else if (temp == BSTAT_STARTINGUP)
1792 printf("starting up.\n");
1793 else if (temp == BSTAT_SHUTTINGDOWN)
1794 printf("shutting down.\n");
1795 if (buffer[0] != 0) {
1796 printf(" Auxiliary status is: %s.\n", buffer);
1800 /* are we done yet? */
1804 if (istatus.procStartTime)
1805 printf(" Process last started at %s (%d proc starts)\n",
1806 DateOf(istatus.procStartTime), istatus.procStarts);
1807 if (istatus.lastAnyExit) {
1808 printf(" Last exit at %s\n", DateOf(istatus.lastAnyExit));
1810 if (istatus.lastErrorExit) {
1811 is1 = is2 = is3 = is4 = NULL;
1812 printf(" Last error exit at %s, ", DateOf(istatus.lastErrorExit));
1813 code = BOZO_GetInstanceStrings(aconn, aname, &is1, &is2, &is3, &is4);
1814 /* don't complain about failing call, since could simply mean
1815 * interface mismatch.
1819 /* non-null instance string */
1820 printf("by %s, ", is1);
1827 if (istatus.errorSignal) {
1828 if (istatus.errorSignal == SIGTERM)
1829 printf("due to shutdown request\n");
1831 printf("due to signal %d\n", istatus.errorSignal);
1833 printf("by exiting with code %d\n", istatus.errorCode);
1837 /* try to display all the parms */
1840 code = BOZO_GetInstanceParm(aconn, aname, i, &tp);
1843 printf(" Command %d is '%s'\n", i + 1, buffer);
1846 code = BOZO_GetInstanceParm(aconn, aname, 999, &tp);
1848 /* Any type of failure is treated as not having a notifier program */
1849 printf(" Notifier is '%s'\n", buffer);
1857 GetRestrict(struct cmd_syndesc *as, void *arock)
1859 struct rx_connection *tconn;
1860 afs_int32 code, val;
1862 tconn = GetConn(as, 0);
1863 code = BOZO_GetRestrictedMode(tconn, &val);
1865 printf("bos: failed to get restricted mode (%s)\n", em(code));
1867 printf("Restricted mode is %s\n", val ? "on" : "off");
1873 SetRestrict(struct cmd_syndesc *as, void *arock)
1875 struct rx_connection *tconn;
1876 afs_int32 code, val;
1878 tconn = GetConn(as, 0);
1879 util_GetInt32(as->parms[1].items->data, &val);
1880 code = BOZO_SetRestrictedMode(tconn, val);
1882 printf("bos: failed to set restricted mode (%s)\n", em(code));
1887 add_std_args(struct cmd_syndesc *ts)
1889 cmd_Seek(ts, ADDPARMOFFSET);
1890 /* + 0 */ cmd_AddParm(ts, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell name");
1891 /* + 1 */ cmd_AddParm(ts, "-noauth", CMD_FLAG, CMD_OPTIONAL,
1892 "don't authenticate");
1893 /* + 2 */ cmd_AddParm(ts, "-localauth", CMD_FLAG, CMD_OPTIONAL,
1894 "create tickets from KeyFile");
1897 #include "AFS_component_version_number.c"
1900 main(int argc, char **argv)
1903 struct cmd_syndesc *ts;
1904 extern int afsconf_SawCell;
1906 #ifdef AFS_AIX32_ENV
1908 * The following signal action for AIX is necessary so that in case of a
1909 * crash (i.e. core is generated) we can include the user's data section
1910 * in the core dump. Unfortunately, by default, only a partial core is
1911 * generated which, in many cases, isn't too useful.
1913 struct sigaction nsa;
1915 sigemptyset(&nsa.sa_mask);
1916 nsa.sa_handler = SIG_DFL;
1917 nsa.sa_flags = SA_FULLDUMP;
1918 sigaction(SIGSEGV, &nsa, NULL);
1919 sigaction(SIGABRT, &nsa, NULL);
1925 printf("bos: could not initialize rx (%s)\n", em(code));
1929 /* To resolve a AFSCELL environment "Note: ..." problem: Because bos calls ka_Init (why?) before any
1930 * checkup on the existance of a "-cell" option on the particular bos command we don't print the
1931 * message if a cell is passed in. Luckily the rest of the programs don't call these adhoc routines
1932 * and things work fine. Note that if the "-cell" isn't passed then we're still ok since later on
1933 * the proper routine (afsconf_GetCellInfo) is going to be called to do the right thing.
1935 afsconf_SawCell = 1; /* Means don't print warning if AFSCELL is set */
1937 afsconf_SawCell = 0; /* Reset it */
1938 /* don't check error code, since fails sometimes when we're setting up a
1940 initialize_CMD_error_table();
1941 initialize_BZ_error_table();
1943 ts = cmd_CreateSyntax("start", StartServer, NULL, "start running a server");
1944 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1945 cmd_AddParm(ts, "-instance", CMD_LIST, 0, "server process name");
1948 ts = cmd_CreateSyntax("stop", StopServer, NULL, "halt a server instance");
1949 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1950 cmd_AddParm(ts, "-instance", CMD_LIST, 0, "server process name");
1952 cmd_AddParm(ts, "-wait", CMD_FLAG, CMD_OPTIONAL,
1953 "wait for process to stop");
1956 ts = cmd_CreateSyntax("status", StatServer, NULL,
1957 "show server instance status");
1958 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1959 cmd_AddParm(ts, "-instance", CMD_LIST, CMD_OPTIONAL,
1960 "server process name");
1961 cmd_AddParm(ts, "-long", CMD_FLAG, CMD_OPTIONAL, "long status");
1964 ts = cmd_CreateSyntax("shutdown", Shutdown, NULL, "shutdown all processes");
1965 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1966 cmd_AddParm(ts, "-instance", CMD_LIST, CMD_OPTIONAL, "instances");
1968 cmd_AddParm(ts, "-wait", CMD_FLAG, CMD_OPTIONAL,
1969 "wait for process to stop");
1972 ts = cmd_CreateSyntax("startup", Startup, NULL, "start all processes");
1973 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1974 cmd_AddParm(ts, "-instance", CMD_LIST, CMD_OPTIONAL, "instances");
1977 ts = cmd_CreateSyntax("restart", Restart, NULL, "restart processes");
1978 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1979 cmd_AddParm(ts, "-instance", CMD_LIST, CMD_OPTIONAL, "instances");
1980 cmd_AddParm(ts, "-bosserver", CMD_FLAG, CMD_OPTIONAL,
1981 "restart bosserver");
1982 cmd_AddParm(ts, "-all", CMD_FLAG, CMD_OPTIONAL, "restart all processes");
1987 ts = cmd_CreateSyntax("create", CreateServer, NULL,
1988 "create a new server instance");
1989 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1990 cmd_AddParm(ts, "-instance", CMD_SINGLE, 0, "server process name");
1991 cmd_AddParm(ts, "-type", CMD_SINGLE, 0, "server type");
1992 cmd_AddParm(ts, "-cmd", CMD_LIST, 0, "command lines");
1993 cmd_AddParm(ts, "-notifier", CMD_SINGLE, CMD_OPTIONAL,
1994 "Notifier program");
1997 ts = cmd_CreateSyntax("delete", DeleteServer, NULL,
1998 "delete a server instance");
1999 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2000 cmd_AddParm(ts, "-instance", CMD_LIST, 0, "server process name");
2003 ts = cmd_CreateSyntax("adduser", AddSUser, NULL,
2004 "add users to super-user list");
2005 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2006 cmd_AddParm(ts, "-user", CMD_LIST, 0, "user names");
2009 ts = cmd_CreateSyntax("removeuser", RemoveSUser, NULL,
2010 "remove users from super-user list");
2011 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2012 cmd_AddParm(ts, "-user", CMD_LIST, 0, "user names");
2015 ts = cmd_CreateSyntax("listusers", ListSUsers, NULL, "list super-users");
2016 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2019 ts = cmd_CreateSyntax("addkey", AddKey, NULL,
2020 "add keys to key dbase (kvno 999 is bcrypt)");
2021 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2022 cmd_AddParm(ts, "-key", CMD_SINGLE, CMD_OPTIONAL, "key");
2023 cmd_AddParm(ts, "-kvno", CMD_SINGLE, 0, "key version number");
2026 ts = cmd_CreateSyntax("removekey", RemoveKey, NULL,
2027 "remove keys from key dbase");
2028 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2029 cmd_AddParm(ts, "-kvno", CMD_LIST, 0, "key version number");
2032 ts = cmd_CreateSyntax("listkeys", ListKeys, NULL, "list keys");
2033 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2034 cmd_AddParm(ts, "-showkey", CMD_FLAG, CMD_OPTIONAL,
2035 "show the actual key rather than the checksum");
2038 ts = cmd_CreateSyntax("listhosts", ListHosts, NULL, "get cell host list");
2039 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2041 cmd_CreateAlias(ts, "getcell");
2043 ts = cmd_CreateSyntax("setcellname", SetCellName, NULL, "set cell name");
2044 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2045 cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "cell name");
2048 ts = cmd_CreateSyntax("addhost", AddHost, NULL, "add host to cell dbase");
2049 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2050 cmd_AddParm(ts, "-host", CMD_LIST, 0, "host name");
2051 cmd_AddParm(ts, "-clone", CMD_FLAG, CMD_OPTIONAL, "vote doesn't count");
2054 ts = cmd_CreateSyntax("removehost", RemoveHost, NULL,
2055 "remove host from cell dbase");
2056 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2057 cmd_AddParm(ts, "-host", CMD_LIST, 0, "host name");
2060 ts = cmd_CreateSyntax("setauth", SetAuth, NULL,
2061 "set authentication required flag");
2062 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2063 cmd_AddParm(ts, "-authrequired", CMD_SINGLE, 0,
2064 "on or off: authentication required for admin requests");
2067 ts = cmd_CreateSyntax("install", Install, NULL, "install program");
2068 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2069 cmd_AddParm(ts, "-file", CMD_LIST, 0, "files to install");
2070 cmd_AddParm(ts, "-dir", CMD_SINGLE, CMD_OPTIONAL, "destination dir");
2073 ts = cmd_CreateSyntax("uninstall", UnInstall, NULL, "uninstall program");
2074 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2075 cmd_AddParm(ts, "-file", CMD_LIST, 0, "files to uninstall");
2076 cmd_AddParm(ts, "-dir", CMD_SINGLE, CMD_OPTIONAL, "destination dir");
2079 ts = cmd_CreateSyntax("getlog", GetLogCmd, NULL, "examine log file");
2080 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2081 cmd_AddParm(ts, "-file", CMD_SINGLE, 0, "log file to examine");
2084 ts = cmd_CreateSyntax("getdate", GetDate, NULL, "get dates for programs");
2085 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2086 cmd_AddParm(ts, "-file", CMD_LIST, 0, "files to check");
2087 cmd_AddParm(ts, "-dir", CMD_SINGLE, CMD_OPTIONAL, "destination dir");
2090 ts = cmd_CreateSyntax("exec", Exec, NULL, "execute shell command on server");
2091 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2092 cmd_AddParm(ts, "-cmd", CMD_SINGLE, 0, "command to execute");
2095 ts = cmd_CreateSyntax("prune", Prune, NULL, "prune server files");
2096 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2097 cmd_AddParm(ts, "-bak", CMD_FLAG, CMD_OPTIONAL, "delete .BAK files");
2098 cmd_AddParm(ts, "-old", CMD_FLAG, CMD_OPTIONAL, "delete .OLD files");
2099 cmd_AddParm(ts, "-core", CMD_FLAG, CMD_OPTIONAL, "delete core files");
2100 cmd_AddParm(ts, "-all", CMD_FLAG, CMD_OPTIONAL, "delete all junk files");
2103 ts = cmd_CreateSyntax("setrestart", SetRestartCmd, NULL,
2104 "set restart times");
2105 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_REQUIRED, "machine name");
2106 cmd_AddParm(ts, "-time", CMD_SINGLE, CMD_REQUIRED,
2107 "time to restart server");
2108 cmd_AddParm(ts, "-general", CMD_FLAG, CMD_OPTIONAL,
2109 "set general restart time");
2110 cmd_AddParm(ts, "-newbinary", CMD_FLAG, CMD_OPTIONAL,
2111 "set new binary restart time");
2113 cmd_CreateAlias(ts, "setr");
2115 ts = cmd_CreateSyntax("getrestart", GetRestartCmd, NULL,
2116 "get restart times");
2117 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_REQUIRED, "machine name");
2119 cmd_CreateAlias(ts, "getr");
2121 ts = cmd_CreateSyntax("salvage", SalvageCmd, NULL,
2122 "salvage partition or volumes");
2123 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2124 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL,
2125 "salvage partition");
2126 cmd_AddParm(ts, "-volume", CMD_SINGLE, CMD_OPTIONAL,
2127 "salvage volume number or volume name");
2128 cmd_AddParm(ts, "-file", CMD_SINGLE, CMD_OPTIONAL,
2129 "salvage log output file");
2130 cmd_AddParm(ts, "-all", CMD_FLAG, CMD_OPTIONAL, "salvage whole server");
2131 cmd_AddParm(ts, "-showlog", CMD_FLAG, CMD_OPTIONAL,
2132 "display salvage log");
2133 cmd_AddParm(ts, "-parallel", CMD_SINGLE, CMD_OPTIONAL,
2134 "# of max parallel partition salvaging");
2135 cmd_AddParm(ts, "-tmpdir", CMD_SINGLE, CMD_OPTIONAL,
2136 "directory to place tmp files");
2137 cmd_AddParm(ts, "-orphans", CMD_SINGLE, CMD_OPTIONAL,
2138 "ignore | remove | attach");
2139 cmd_AddParm(ts, "-forceDAFS", CMD_FLAG, CMD_OPTIONAL,
2140 "(DAFS) force salvage of demand attach fileserver");
2141 cmd_AddParm(ts, "-debug", CMD_FLAG, CMD_OPTIONAL,
2142 "(MR-AFS) Run in Debugging mode");
2143 cmd_AddParm(ts, "-nowrite", CMD_FLAG, CMD_OPTIONAL,
2144 "(MR-AFS) Run readonly/test mode");
2145 cmd_AddParm(ts, "-force", CMD_FLAG, CMD_OPTIONAL,
2146 "(MR-AFS) Force full salvaging");
2147 cmd_AddParm(ts, "-oktozap", CMD_FLAG, CMD_OPTIONAL,
2148 "(MR-AFS) Give permission to destroy bogus file residencies/volumes - debugging flag");
2149 cmd_AddParm(ts, "-rootfiles", CMD_FLAG, CMD_OPTIONAL,
2150 "(MR-AFS) Show files owned by root - debugging flag");
2151 cmd_AddParm(ts, "-salvagedirs", CMD_FLAG, CMD_OPTIONAL,
2152 "(MR-AFS) Force rebuild/salvage of all directories");
2153 cmd_AddParm(ts, "-blockreads", CMD_FLAG, CMD_OPTIONAL,
2154 "(MR-AFS) Read smaller blocks to handle IO/bad blocks");
2155 cmd_AddParm(ts, "-ListResidencies", CMD_FLAG, CMD_OPTIONAL,
2156 "(MR-AFS) Just list affected file residencies - debugging flag");
2157 cmd_AddParm(ts, "-SalvageRemote", CMD_FLAG, CMD_OPTIONAL,
2158 "(MR-AFS) Salvage storage systems that are not directly attached");
2159 cmd_AddParm(ts, "-SalvageArchival", CMD_FLAG, CMD_OPTIONAL,
2160 "(MR-AFS) Salvage HSM storage systems");
2161 cmd_AddParm(ts, "-IgnoreCheck", CMD_FLAG, CMD_OPTIONAL,
2162 "(MR-AFS) Don't perform VLDB safety check when deleting unreferenced files. Only a good idea in single server cell.");
2163 cmd_AddParm(ts, "-ForceOnLine", CMD_FLAG, CMD_OPTIONAL,
2164 "(MR-AFS) Force the volume to come online, even if it hasn't salvaged cleanly.");
2165 cmd_AddParm(ts, "-UseRootDirACL", CMD_FLAG, CMD_OPTIONAL,
2166 "(MR-AFS) Use the root directory ACL for lost+found directory if it is created.");
2167 cmd_AddParm(ts, "-TraceBadLinkCounts", CMD_FLAG, CMD_OPTIONAL,
2168 "(MR-AFS) Print out lines about volume reference count changes.");
2169 cmd_AddParm(ts, "-DontAskFS", CMD_FLAG, CMD_OPTIONAL,
2170 "(MR-AFS) Don't ask fileserver to take volume offline. THIS IS VERY DANGEROUS.");
2171 cmd_AddParm(ts, "-LogLevel", CMD_SINGLE, CMD_OPTIONAL,
2172 "(MR-AFS) log level");
2173 cmd_AddParm(ts, "-rxdebug", CMD_FLAG, CMD_OPTIONAL,
2174 "(MR-AFS) Write out rx debug information.");
2175 cmd_AddParm(ts, "-Residencies", CMD_SINGLE, CMD_OPTIONAL,
2176 "(MR-AFS) Numeric mask of residencies to be included in the salvage. Do not use with -SalvageRemote or -SalvageArchival");
2179 ts = cmd_CreateSyntax("blockscanner", BlockScannerCmd, NULL,
2180 "block scanner daemon from making migration requests");
2181 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_REQUIRED, "machine name");
2184 ts = cmd_CreateSyntax("unblockscanner", UnBlockScannerCmd, NULL,
2185 "allow scanner daemon to make migration requests again");
2186 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_REQUIRED, "machine name");
2189 ts = cmd_CreateSyntax("getrestricted", GetRestrict, NULL,
2190 "get restrict mode");
2191 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2194 ts = cmd_CreateSyntax("setrestricted", SetRestrict, NULL,
2195 "set restrict mode");
2196 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2197 cmd_AddParm(ts, "-mode", CMD_SINGLE, 0, "mode to set");
2201 code = cmd_Dispatch(argc, argv);