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 */
136 static char tbuffer[30];
140 strlcpy(tbuffer, tp, sizeof(tbuffer));
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));
175 secFlags = AFSCONF_SECOPTS_ALWAYSENCRYPT;
177 secFlags = AFSCONF_SECOPTS_FALLBACK_NULL;
180 if (as->parms[ADDPARMOFFSET + 2].items) { /* -localauth */
181 secFlags |= AFSCONF_SECOPTS_LOCALAUTH;
182 confdir = AFSDIR_SERVER_ETC_DIRPATH;
184 confdir = AFSDIR_CLIENT_ETC_DIRPATH;
187 if (as->parms[ADDPARMOFFSET + 1].items) { /* -noauth */
188 secFlags |= AFSCONF_SECOPTS_NOAUTH;
190 /* If we're running with -noauth, we don't need a configuration
192 tdir = afsconf_Open(confdir);
194 printf("bos: can't open cell database (%s)\n", confdir);
199 if (as->parms[ADDPARMOFFSET].items) /* -cell */
200 cellname = as->parms[ADDPARMOFFSET].items->data;
202 code = afsconf_PickClientSecObj(tdir, secFlags, NULL, cellname,
203 &sc, &scIndex, NULL);
205 afs_com_err("bos", code, "(configuring connection security)");
209 if (scIndex == RX_SECIDX_NULL)
210 fprintf(stderr, "bos: running unauthenticated\n");
213 rx_NewConnection(addr, htons(AFSCONF_NANNYPORT), 1, sc, scIndex);
215 fprintf(stderr, "bos: could not create rx connection\n");
224 SetAuth(struct cmd_syndesc *as, void *arock)
227 struct rx_connection *tconn;
231 tconn = GetConn(as, 0);
232 tp = as->parms[1].items->data;
233 if (strcmp(tp, "on") == 0)
234 flag = 0; /* auth req.: noauthflag is false */
235 else if (strcmp(tp, "off") == 0)
239 ("bos: illegal authentication specifier '%s', must be 'off' or 'on'.\n",
243 code = BOZO_SetNoAuthFlag(tconn, flag);
245 afs_com_err("bos", code, "(failed to set authentication flag)");
249 /* take a name (e.g. foo/bar, and a dir e.g. /usr/afs/bin, and construct
250 * /usr/afs/bin/bar */
252 ComputeDestDir(char *aname, char *adir, char *aresult, afs_int32 alen)
256 strcpy(aresult, adir);
257 tp = strrchr(aname, '/');
260 strcat(aresult, "/");
261 strcat(aresult, aname);
263 /* tp points at the / character */
269 /* copy data from fd afd to rx call acall */
271 CopyBytes(int afd, struct rx_call *acall)
278 len = read(afd, tbuffer, sizeof(tbuffer));
282 return 0; /* all done */
283 code = rx_Write(acall, tbuffer, len);
290 Prune(struct cmd_syndesc *as, void *arock)
293 struct rx_connection *tconn;
296 tconn = GetConn(as, 0);
298 if (as->parms[1].items)
299 flags |= BOZO_PRUNEBAK;
300 if (as->parms[2].items)
301 flags |= BOZO_PRUNEOLD;
302 if (as->parms[3].items)
303 flags |= BOZO_PRUNECORE;
304 if (as->parms[4].items)
306 code = BOZO_Prune(tconn, flags);
308 afs_com_err("bos", code, "(failed to prune server files)");
313 Exec(struct cmd_syndesc *as, void *arock)
315 struct rx_connection *tconn;
318 tconn = GetConn(as, 0);
319 code = BOZO_Exec(tconn, as->parms[1].items->data);
321 printf("bos: failed to execute command (%s)\n", em(code));
326 GetDate(struct cmd_syndesc *as, void *arock)
331 afs_int32 time, bakTime, oldTime;
332 struct rx_connection *tconn;
335 tconn = GetConn(as, 0);
336 if (!as->parms[1].items) {
337 printf("bos: no files to check\n");
341 /* compute dest dir or file; default MUST be canonical form of dir path */
342 if (as->parms[2].items)
343 strcpy(destDir, as->parms[2].items->data);
345 strcpy(destDir, AFSDIR_CANONICAL_SERVER_BIN_DIRPATH);
347 for (ti = as->parms[1].items; ti; ti = ti->next) {
348 /* check date for each file */
349 ComputeDestDir(ti->data, destDir, tbuffer, sizeof(tbuffer));
350 code = BOZO_GetDates(tconn, tbuffer, &time, &bakTime, &oldTime);
352 printf("bos: failed to check date on %s (%s)\n", ti->data,
356 printf("File %s ", tbuffer);
358 printf("does not exist, ");
360 printf("dated %s, ", DateOf(time));
362 printf("no .BAK file, ");
364 printf(".BAK file dated %s, ", DateOf(bakTime));
366 printf("no .OLD file.");
368 printf(".OLD file dated %s.", DateOf(oldTime));
376 UnInstall(struct cmd_syndesc *as, void *arock)
382 struct rx_connection *tconn;
384 tconn = GetConn(as, 0);
385 if (!as->parms[1].items) {
386 printf("bos: no files to uninstall\n");
390 /* compute dest dir or file; default MUST be canonical form of dir path */
391 if (as->parms[2].items)
392 strcpy(destDir, as->parms[2].items->data);
394 strcpy(destDir, AFSDIR_CANONICAL_SERVER_BIN_DIRPATH);
396 for (ti = as->parms[1].items; ti; ti = ti->next) {
397 /* uninstall each file */
398 ComputeDestDir(ti->data, destDir, tbuffer, sizeof(tbuffer));
399 code = BOZO_UnInstall(tconn, tbuffer);
401 printf("bos: failed to uninstall %s (%s)\n", ti->data, em(code));
404 printf("bos: uninstalled file %s\n", ti->data);
410 GetServerGoal(struct rx_connection *aconn, char *aname)
415 struct bozo_status istatus;
418 code = BOZO_GetInstanceInfo(aconn, aname, &tp, &istatus);
420 printf("bos: failed to get instance info for '%s' (%s)\n", aname,
422 /* if we can't get the answer, assume its running */
425 if (istatus.goal == 0)
426 return BSTAT_SHUTDOWN;
432 Install(struct cmd_syndesc *as, void *arock)
434 struct rx_connection *tconn;
440 struct rx_call *tcall;
443 tconn = GetConn(as, 0);
444 if (!as->parms[1].items) {
445 printf("bos: no files to install\n");
449 /* compute dest dir or file; default MUST be canonical form of dir path */
450 if (as->parms[2].items)
451 strcpy(destDir, as->parms[2].items->data);
453 strcpy(destDir, AFSDIR_CANONICAL_SERVER_BIN_DIRPATH);
455 for (ti = as->parms[1].items; ti; ti = ti->next) {
456 /* install each file */
457 fd = open(ti->data, O_RDONLY);
459 /* better to quit on error than continue for install command */
460 printf("bos: can't find file '%s', quitting\n", ti->data);
463 code = fstat(fd, &tstat);
465 printf("bos: failed to stat file %s, errno is %d\n", ti->data,
469 /* compute destination dir */
470 ComputeDestDir(ti->data, destDir, tbuffer, sizeof(tbuffer));
471 tcall = rx_NewCall(tconn);
473 StartBOZO_Install(tcall, tbuffer, tstat.st_size,
474 (afs_int32) tstat.st_mode, tstat.st_mtime);
476 code = CopyBytes(fd, tcall);
478 code = rx_EndCall(tcall, code);
480 printf("bos: failed to install %s (%s)\n", ti->data, em(code));
483 printf("bos: installed file %s\n", ti->data);
489 Shutdown(struct cmd_syndesc *as, void *arock)
491 struct rx_connection *tconn;
495 tconn = GetConn(as, 0);
496 if (as->parms[1].items == 0) {
497 code = BOZO_ShutdownAll(tconn);
499 printf("bos: failed to shutdown servers (%s)\n", em(code));
501 for (ti = as->parms[1].items; ti; ti = ti->next) {
502 code = BOZO_SetTStatus(tconn, ti->data, BSTAT_SHUTDOWN);
504 printf("bos: failed to shutdown instance %s (%s)\n", ti->data,
508 if (as->parms[8].items) {
509 code = BOZO_WaitAll(tconn);
511 printf("bos: can't wait for processes to shutdown (%s)\n",
518 BlockScannerCmd(struct cmd_syndesc *as, void *arock)
521 struct rx_connection *tconn;
522 char BlockCommand[] = "/usr/afs/bin/scanner -block";
524 tconn = GetConn(as, 0);
525 code = BOZO_Exec(tconn, BlockCommand);
528 ("bos: failed to block scanner from making migration requests (%s)\n",
534 UnBlockScannerCmd(struct cmd_syndesc *as, void *arock)
537 struct rx_connection *tconn;
538 char UnBlockCommand[] = "/usr/afs/bin/scanner -unblock";
540 tconn = GetConn(as, 0);
541 code = BOZO_Exec(tconn, UnBlockCommand);
544 ("bos: failed to allow scanner daemon to make migration requests again (%s)\n",
550 GetRestartCmd(struct cmd_syndesc *as, void *arock)
553 struct ktime generalTime, newBinaryTime;
554 char messageBuffer[256];
555 struct rx_connection *tconn;
558 hostp = as->parms[0].items->data; /* host name for messages */
559 tconn = GetConn(as, 0);
561 code = BOZO_GetRestartTime(tconn, 1, (struct bozo_netKTime *) &generalTime);
563 printf("bos: failed to retrieve restart information (%s)\n",
567 code = BOZO_GetRestartTime(tconn, 2, (struct bozo_netKTime *) &newBinaryTime);
569 printf("bos: failed to retrieve restart information (%s)\n",
574 code = ktime_DisplayString(&generalTime, messageBuffer);
576 printf("bos: failed to decode restart time (%s)\n", em(code));
579 printf("Server %s restarts %s\n", hostp, messageBuffer);
581 code = ktime_DisplayString(&newBinaryTime, messageBuffer);
583 printf("bos: failed to decode restart time (%s)\n", em(code));
586 printf("Server %s restarts for new binaries %s\n", hostp, messageBuffer);
593 SetRestartCmd(struct cmd_syndesc *as, void *arock)
597 struct ktime restartTime;
599 struct rx_connection *tconn;
602 tconn = GetConn(as, 0);
603 if (as->parms[2].items) {
607 if (as->parms[3].items) {
612 printf("bos: can't specify more than one restart time at a time\n");
616 type = 1; /* by default set general restart time */
618 if ((code = ktime_ParsePeriodic(as->parms[1].items->data, &restartTime))) {
619 printf("bos: failed to parse '%s' as periodic restart time(%s)\n",
620 as->parms[1].items->data, em(code));
624 code = BOZO_SetRestartTime(tconn, type, (struct bozo_netKTime *) &restartTime);
626 printf("bos: failed to set restart time at server (%s)\n", em(code));
633 Startup(struct cmd_syndesc *as, void *arock)
635 struct rx_connection *tconn;
639 tconn = GetConn(as, 0);
640 if (as->parms[1].items == 0) {
641 code = BOZO_StartupAll(tconn);
643 printf("bos: failed to startup servers (%s)\n", em(code));
645 for (ti = as->parms[1].items; ti; ti = ti->next) {
646 code = BOZO_SetTStatus(tconn, ti->data, BSTAT_NORMAL);
648 printf("bos: failed to start instance %s (%s)\n", ti->data,
656 Restart(struct cmd_syndesc *as, void *arock)
658 struct rx_connection *tconn;
662 tconn = GetConn(as, 0);
663 if (as->parms[2].items) {
664 /* this is really a rebozo command */
665 if (as->parms[1].items) {
666 /* specified specific things to restart, can't do this at the same
669 ("bos: can't specify both '-bos' and specific servers to restart.\n");
672 /* otherwise do a rebozo */
673 code = BOZO_ReBozo(tconn);
675 printf("bos: failed to restart bosserver (%s)\n", em(code));
678 if (as->parms[1].items == 0) {
679 if (as->parms[3].items) { /* '-all' */
680 code = BOZO_RestartAll(tconn);
682 printf("bos: failed to restart servers (%s)\n", em(code));
684 printf("bos: To restart all processes please specify '-all'\n");
686 if (as->parms[3].items) {
687 printf("bos: Can't use '-all' along with individual instances\n");
689 for (ti = as->parms[1].items; ti; ti = ti->next) {
690 code = BOZO_Restart(tconn, ti->data);
692 printf("bos: failed to restart instance %s (%s)\n",
701 SetCellName(struct cmd_syndesc *as, void *arock)
703 struct rx_connection *tconn;
706 tconn = GetConn(as, 0);
707 code = BOZO_SetCellName(tconn, as->parms[1].items->data);
709 printf("bos: failed to set cell (%s)\n", em(code));
714 AddHost(struct cmd_syndesc *as, void *arock)
716 struct rx_connection *tconn;
719 char name[MAXHOSTCHARS];
721 tconn = GetConn(as, 0);
722 for (ti = as->parms[1].items; ti; ti = ti->next) {
723 if (as->parms[2].items) {
724 if (strlen(ti->data) > MAXHOSTCHARS - 3) {
725 fprintf(stderr, "bos: host name too long\n");
729 strcpy(&name[1], ti->data);
730 strcat((char *)&name, "]");
731 code = BOZO_AddCellHost(tconn, name);
733 code = BOZO_AddCellHost(tconn, ti->data);
735 printf("bos: failed to add host %s (%s)\n", ti->data, em(code));
741 RemoveHost(struct cmd_syndesc *as, void *arock)
743 struct rx_connection *tconn;
747 tconn = GetConn(as, 0);
748 for (ti = as->parms[1].items; ti; ti = ti->next) {
749 code = BOZO_DeleteCellHost(tconn, ti->data);
751 printf("bos: failed to delete host %s (%s)\n", ti->data,
758 ListHosts(struct cmd_syndesc *as, void *arock)
760 struct rx_connection *tconn;
767 tconn = GetConn(as, 0);
768 code = BOZO_GetCellName(tconn, &tp);
770 printf("bos: failed to get cell name (%s)\n", em(code));
773 printf("Cell name is %s\n", tbuffer);
775 code = BOZO_GetCellHost(tconn, i, &tp);
779 printf("bos: failed to get cell host %d (%s)\n", i, em(code));
782 printf(" Host %d is %s\n", i + 1, tbuffer);
788 AddKey(struct cmd_syndesc *as, void *arock)
790 struct rx_connection *tconn;
792 struct ktc_encryptionKey tkey;
794 char buf[BUFSIZ], ver[BUFSIZ];
796 tconn = GetConn(as, 1);
797 memset(&tkey, 0, sizeof(struct ktc_encryptionKey));
799 if (as->parms[1].items) {
800 if (strlcpy(buf, as->parms[1].items->data, sizeof(buf)) >= sizeof(buf)) {
801 fprintf(stderr, "Key data too long for buffer\n");
806 code = UI_UTIL_read_pw_string(buf, sizeof(buf), "input key: ", 0);
807 if (code || strlen(buf) == 0) {
808 fprintf(stderr, "Bad key: \n");
811 code = UI_UTIL_read_pw_string(ver, sizeof(ver), "Retype input key: ", 0);
812 if (code || strlen(ver) == 0) {
813 fprintf(stderr, "Bad key: \n");
816 if (strcmp(ver, buf) != 0) {
817 fprintf(stderr, "\nInput key mismatch\n");
823 temp = atoi(as->parms[2].items->data);
827 strcpy((char *)&tkey, as->parms[1].items->data);
829 strcpy((char *)&tkey, buf);
830 } else { /* kerberos key */
832 if (as->parms[ADDPARMOFFSET].items) {
833 tcell = strdup(as->parms[ADDPARMOFFSET].items->data);
835 fprintf(stderr, "bos: Unable to allocate memory for cellname\n");
839 /* string to key needs upper-case cell names */
841 /* I don't believe this is true. The string to key function
842 * actually expands the cell name, then LOWER-CASES it. Perhaps it
843 * didn't use to??? */
844 ucstring(tcell, tcell, strlen(tcell));
846 tcell = NULL; /* no cell specified, use current */
848 ka_StringToKey(as->parms[1].items->data, tcell, &tkey);
850 ka_StringToKey(buf, tcell, &tkey);
855 code = BOZO_AddKey(tconn, temp, ktc_to_bozoptr(&tkey));
857 printf("bos: failed to set key %d (%s)\n", temp, em(code));
864 RemoveKey(struct cmd_syndesc *as, void *arock)
866 struct rx_connection *tconn;
871 tconn = GetConn(as, 0);
872 for (ti = as->parms[1].items; ti; ti = ti->next) {
873 temp = atoi(ti->data);
874 code = BOZO_DeleteKey(tconn, temp);
876 printf("bos: failed to delete key %d (%s)\n", temp, em(code));
884 ListKeys(struct cmd_syndesc *as, void *arock)
886 struct rx_connection *tconn;
888 struct ktc_encryptionKey tkey;
890 struct bozo_keyInfo keyInfo;
894 tconn = GetConn(as, 1);
897 code = BOZO_ListKeys(tconn, i, &kvno, ktc_to_bozoptr(&tkey), &keyInfo);
901 /* first check if key is returned */
902 if ((!ka_KeyIsZero((char *)&tkey, sizeof(tkey)))
903 && (as->parms[1].items)) {
904 printf("key %d is '", kvno);
905 ka_PrintBytes((char *)&tkey, sizeof(tkey));
908 if (keyInfo.keyCheckSum == 0) /* shouldn't happen */
909 printf("key version is %d\n", kvno);
911 printf("key %d has cksum %u\n", kvno, keyInfo.keyCheckSum);
915 printf("Keys last changed on %s.\n", DateOf(keyInfo.mod_sec));
918 printf("bos: %s error encountered while listing keys\n", em(code));
920 printf("All done.\n");
925 AddSUser(struct cmd_syndesc *as, void *arock)
927 struct rx_connection *tconn;
933 tconn = GetConn(as, 0);
934 for (ti = as->parms[1].items; ti; ti = ti->next) {
935 code = BOZO_AddSUser(tconn, ti->data);
937 printf("bos: failed to add user '%s' (%s)\n", ti->data, em(code));
945 RemoveSUser(struct cmd_syndesc *as, void *arock)
947 struct rx_connection *tconn;
953 tconn = GetConn(as, 0);
954 for (ti = as->parms[1].items; ti; ti = ti->next) {
955 code = BOZO_DeleteSUser(tconn, ti->data);
957 printf("bos: failed to delete user '%s', ", ti->data);
959 printf("(no such user)\n");
961 printf("(%s)\n", em(code));
968 #define NPERLINE 10 /* dudes to print per line */
970 ListSUsers(struct cmd_syndesc *as, void *arock)
972 struct rx_connection *tconn;
977 int lastNL, printGreeting;
979 tconn = GetConn(as, 0);
984 code = BOZO_ListSUsers(tconn, i, &tp);
988 printGreeting = 0; /* delay until after first call succeeds */
989 printf("SUsers are: ");
991 printf("%s ", tbuffer);
992 if ((i % NPERLINE) == NPERLINE - 1) {
999 /* a real error code, instead of scanned past end */
1000 printf("bos: failed to retrieve super-user list (%s)\n", em(code));
1009 StatServer(struct cmd_syndesc *as, void *arock)
1011 struct rx_connection *tconn;
1014 char ibuffer[BOZO_BSSIZE];
1018 /* int32p==1 is obsolete, smaller, printout */
1019 int32p = (as->parms[2].items != 0 ? 2 : 0);
1021 /* no parms does something pretty different */
1022 if (as->parms[1].items)
1023 return IStatServer(as, int32p);
1025 tconn = GetConn(as, 0);
1027 /* for each instance */
1029 code = BOZO_EnumerateInstance(tconn, i, &tp);
1033 printf("bos: failed to contact host's bosserver (%s).\n",
1037 DoStat(ibuffer, tconn, int32p, (i == 0)); /* print status line */
1043 CreateServer(struct cmd_syndesc *as, void *arock)
1045 struct rx_connection *tconn;
1048 struct cmd_item *ti;
1050 char *type, *name, *notifier = NONOTIFIER;
1052 tconn = GetConn(as, 0);
1053 for (i = 0; i < 6; i++)
1055 for (i = 0, ti = as->parms[3].items; (ti && i < 6); ti = ti->next, i++) {
1056 parms[i] = ti->data;
1058 name = as->parms[1].items->data;
1059 type = as->parms[2].items->data;
1060 if ((ti = as->parms[4].items)) {
1061 notifier = ti->data;
1064 BOZO_CreateBnode(tconn, type, name, parms[0], parms[1], parms[2],
1065 parms[3], parms[4], notifier);
1068 ("bos: failed to create new server instance %s of type '%s' (%s)\n",
1069 name, type, em(code));
1075 DeleteServer(struct cmd_syndesc *as, void *arock)
1077 struct rx_connection *tconn;
1079 struct cmd_item *ti;
1082 tconn = GetConn(as, 0);
1083 for (ti = as->parms[1].items; ti; ti = ti->next) {
1084 code = BOZO_DeleteBnode(tconn, ti->data);
1087 printf("bos: can't delete running instance '%s'\n", ti->data);
1089 printf("bos: failed to delete instance '%s' (%s)\n", ti->data,
1097 StartServer(struct cmd_syndesc *as, void *arock)
1099 struct rx_connection *tconn;
1101 struct cmd_item *ti;
1104 tconn = GetConn(as, 0);
1105 for (ti = as->parms[1].items; ti; ti = ti->next) {
1106 code = BOZO_SetStatus(tconn, ti->data, BSTAT_NORMAL);
1108 printf("bos: failed to start instance '%s' (%s)\n", ti->data,
1115 StopServer(struct cmd_syndesc *as, void *arock)
1117 struct rx_connection *tconn;
1119 struct cmd_item *ti;
1122 tconn = GetConn(as, 0);
1123 for (ti = as->parms[1].items; ti; ti = ti->next) {
1124 code = BOZO_SetStatus(tconn, ti->data, BSTAT_SHUTDOWN);
1126 printf("bos: failed to change stop instance '%s' (%s)\n",
1127 ti->data, em(code));
1129 if (as->parms[8].items) {
1130 code = BOZO_WaitAll(tconn);
1132 printf("bos: can't wait for processes to shutdown (%s)\n",
1138 #define PARMBUFFERSSIZE 32
1141 DoSalvage(struct rx_connection * aconn, char * aparm1, char * aparm2,
1142 char * aoutName, afs_int32 showlog, char * parallel,
1143 char * atmpDir, char * orphans, int dafs,
1144 struct MRAFSSalvageParms * mrafsParm)
1149 char tbuffer[BOZO_BSSIZE];
1150 struct bozo_status istatus;
1151 struct rx_call *tcall;
1155 char partName[20]; /* canonical name for partition */
1156 char pbuffer[PARMBUFFERSSIZE];
1157 afs_int32 partNumber;
1158 char *notifier = NONOTIFIER;
1161 /* if a partition was specified, canonicalize the name, since
1162 * the salvager has a stupid partition ID parser */
1164 partNumber = volutil_GetPartitionID(aparm1);
1165 if (partNumber < 0) {
1166 printf("bos: could not parse partition ID '%s'\n", aparm1);
1169 tp = volutil_PartitionName(partNumber);
1171 printf("bos: internal error parsing partition ID '%s'\n", aparm1);
1174 strcpy(partName, tp);
1178 /* open the file name */
1180 outFile = fopen(aoutName, "w");
1182 printf("bos: can't open specified SalvageLog file '%s'\n",
1186 closeIt = 1; /* close this file later */
1189 closeIt = 0; /* don't close this file later */
1192 for (code = 2; code < 6; code++)
1197 /* MUST pass canonical (wire-format) salvager path to bosserver */
1199 /* single volume salvage */
1201 /* for DAFS, we call the salvagserver binary with special options.
1202 * in this mode, it simply uses SALVSYNC to tell the currently
1203 * running salvageserver to offline and salvage the volume in question */
1204 strncpy(tbuffer, AFSDIR_CANONICAL_SERVER_SALSRV_FILEPATH, BOZO_BSSIZE);
1206 if ((strlen(tbuffer) + 9 + strlen(partName) + 1 + strlen(aparm2) +
1208 printf("bos: command line too big\n");
1212 strcat(tbuffer, " -client ");
1213 strcat(tbuffer, partName);
1214 strcat(tbuffer, " ");
1215 strcat(tbuffer, aparm2);
1217 strncpy(tbuffer, AFSDIR_CANONICAL_SERVER_SALVAGER_FILEPATH, BOZO_BSSIZE);
1219 if ((strlen(tbuffer) + 1 + strlen(partName) + 1 + strlen(aparm2) +
1221 printf("bos: command line too big\n");
1225 strcat(tbuffer, " ");
1226 strcat(tbuffer, partName);
1227 strcat(tbuffer, " ");
1228 strcat(tbuffer, aparm2);
1231 /* partition salvage */
1232 strncpy(tbuffer, AFSDIR_CANONICAL_SERVER_SALVAGER_FILEPATH, BOZO_BSSIZE);
1233 if ((strlen(tbuffer) + 4 + strlen(partName) + 1) > BOZO_BSSIZE) {
1234 printf("bos: command line too big\n");
1237 strcat(tbuffer, " -force ");
1238 strcat(tbuffer, partName);
1241 /* For DAFS, specifying a single volume does not result in a standard
1242 * salvager call. Instead, it simply results in a SALVSYNC call to the
1243 * online salvager daemon. This interface does not give us the same rich
1244 * set of call flags. Thus, we skip these steps for DAFS single-volume
1246 if (!dafs || (*aparm2 == 0)) {
1247 /* add the parallel option if given */
1248 if (parallel != NULL) {
1249 if ((strlen(tbuffer) + 11 + strlen(parallel) + 1) > BOZO_BSSIZE) {
1250 printf("bos: command line too big\n");
1253 strcat(tbuffer, " -parallel ");
1254 strcat(tbuffer, parallel);
1257 /* add the tmpdir option if given */
1258 if (atmpDir != NULL) {
1259 if ((strlen(tbuffer) + 9 + strlen(atmpDir) + 1) > BOZO_BSSIZE) {
1260 printf("bos: command line too big\n");
1263 strcat(tbuffer, " -tmpdir ");
1264 strcat(tbuffer, atmpDir);
1267 /* add the orphans option if given */
1268 if (orphans != NULL) {
1269 if ((strlen(tbuffer) + 10 + strlen(orphans) + 1) > BOZO_BSSIZE) {
1270 printf("bos: command line too big\n");
1273 strcat(tbuffer, " -orphans ");
1274 strcat(tbuffer, orphans);
1277 if (mrafsParm->Optdebug)
1278 strcat(tbuffer, " -debug");
1279 if (mrafsParm->Optnowrite)
1280 strcat(tbuffer, " -nowrite");
1281 if (mrafsParm->Optforce)
1282 strcat(tbuffer, " -force");
1283 if (mrafsParm->Optoktozap)
1284 strcat(tbuffer, " -oktozap");
1285 if (mrafsParm->Optrootfiles)
1286 strcat(tbuffer, " -rootfiles");
1287 if (mrafsParm->Optsalvagedirs)
1288 strcat(tbuffer, " -salvagedirs");
1289 if (mrafsParm->Optblockreads)
1290 strcat(tbuffer, " -blockreads");
1291 if (mrafsParm->OptListResidencies)
1292 strcat(tbuffer, " -ListResidencies");
1293 if (mrafsParm->OptSalvageRemote)
1294 strcat(tbuffer, " -SalvageRemote");
1295 if (mrafsParm->OptSalvageArchival)
1296 strcat(tbuffer, " -SalvageArchival");
1297 if (mrafsParm->OptIgnoreCheck)
1298 strcat(tbuffer, " -IgnoreCheck");
1299 if (mrafsParm->OptForceOnLine)
1300 strcat(tbuffer, " -ForceOnLine");
1301 if (mrafsParm->OptUseRootDirACL)
1302 strcat(tbuffer, " -UseRootDirACL");
1303 if (mrafsParm->OptTraceBadLinkCounts)
1304 strcat(tbuffer, " -TraceBadLinkCounts");
1305 if (mrafsParm->OptDontAskFS)
1306 strcat(tbuffer, " -DontAskFS");
1307 if (mrafsParm->OptLogLevel) {
1308 sprintf(pbuffer, " -LogLevel %ld", afs_printable_int32_ld(mrafsParm->OptLogLevel));
1309 strcat(tbuffer, pbuffer);
1311 if (mrafsParm->OptRxDebug)
1312 strcat(tbuffer, " -rxdebug");
1313 if (mrafsParm->OptResidencies) {
1314 sprintf(pbuffer, " -Residencies %lu",
1315 afs_printable_uint32_lu(mrafsParm->OptResidencies));
1316 strcat(tbuffer, pbuffer);
1321 parms[1] = "now"; /* when to do it */
1323 BOZO_CreateBnode(aconn, "cron", "salvage-tmp", parms[0], parms[1],
1324 parms[2], parms[3], parms[4], notifier);
1326 printf("bos: failed to start 'salvager' (%s)\n", em(code));
1329 /* now wait for bnode to disappear */
1334 code = BOZO_GetInstanceInfo(aconn, "salvage-tmp", &tp, &istatus);
1337 if ((++count % 5) == 0)
1338 printf("bos: waiting for salvage to complete.\n");
1340 if (code != BZNOENT) {
1341 printf("bos: salvage failed (%s)\n", em(code));
1346 /* now print the log file to the output file */
1347 printf("bos: salvage completed\n");
1348 if (aoutName || showlog) {
1349 fprintf(outFile, "SalvageLog:\n");
1350 tcall = rx_NewCall(aconn);
1351 /* MUST pass canonical (wire-format) salvager log path to bosserver */
1353 StartBOZO_GetLog(tcall, AFSDIR_CANONICAL_SERVER_SLVGLOG_FILEPATH);
1355 rx_EndCall(tcall, code);
1360 code = rx_Read(tcall, &buffer, 1);
1363 putc(buffer, outFile);
1365 break; /* the end delimeter */
1367 code = rx_EndCall(tcall, 0);
1368 /* fall through into cleanup code */
1372 if (closeIt && outFile)
1378 GetLogCmd(struct cmd_syndesc *as, void *arock)
1380 struct rx_connection *tconn;
1381 struct rx_call *tcall;
1386 printf("Fetching log file '%s'...\n", as->parms[1].items->data);
1387 tconn = GetConn(as, 0);
1388 tcall = rx_NewCall(tconn);
1389 code = StartBOZO_GetLog(tcall, as->parms[1].items->data);
1391 rx_EndCall(tcall, code);
1397 code = rx_Read(tcall, &buffer, 1);
1403 break; /* the end delimeter */
1406 code = rx_EndCall(tcall, error);
1407 /* fall through into cleanup code */
1411 afs_com_err("bos", code, "(while reading log)");
1416 IsDAFS(struct rx_connection *aconn)
1418 char buffer[BOZO_BSSIZE];
1420 struct bozo_status istatus;
1425 code = BOZO_GetInstanceInfo(aconn, "dafs", &tp, &istatus);
1427 /* no dafs bnode; cannot be dafs */
1431 /* dafs bnode is running; we must be dafs */
1435 /* At this point, either we have neither a dafs nor fs bnode running, or
1436 * we have an fs bnode running but the dafs bnode is stopped.
1438 * If an fs bnode is running, we are obviously not DAFS. If an fs bnode
1439 * is not running and a dafs bnode is not running... it's not certain if
1440 * we are DAFS or not DAFS. Just return 0 in that case; it shouldn't much
1441 * matter what we return, anyway */
1446 SalvageCmd(struct cmd_syndesc *as, void *arock)
1448 struct rx_connection *tconn;
1449 afs_int32 code, rc, i;
1451 char tname[BOZO_BSSIZE];
1453 extern struct ubik_client *cstruct;
1454 afs_int32 curGoal, showlog = 0, dafs = 0, mrafs = 0;
1460 struct MRAFSSalvageParms mrafsParm;
1462 memset(&mrafsParm, 0, sizeof(mrafsParm));
1464 /* parm 0 is machine name, 1 is partition, 2 is volume, 3 is -all flag */
1465 tconn = GetConn(as, 0);
1469 /* find out whether fileserver is running demand attach fs */
1470 if (IsDAFS(tconn)) {
1472 serviceName = "dafs";
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, 4, &tp) == 0))
1479 /* Find out whether fileserver is running MR-AFS (has a scanner instance) */
1480 /* XXX this should really be done some other way, potentially by RPC */
1481 if ((code = BOZO_GetInstanceParm(tconn, serviceName, 3, &tp) == 0))
1485 /* we can do a volume, a partition or the whole thing, but not mixtures
1487 if (!as->parms[1].items && as->parms[2].items) {
1488 printf("bos: must specify partition to salvage individual volume.\n");
1491 if (as->parms[5].items && as->parms[3].items) {
1492 printf("bos: can not specify both -file and -showlog.\n");
1495 if (as->parms[4].items && (as->parms[1].items || as->parms[2].items)) {
1496 printf("bos: can not specify -all with other flags.\n");
1500 /* get the output file name, if any */
1501 if (as->parms[3].items)
1502 outName = as->parms[3].items->data;
1506 if (as->parms[5].items)
1509 /* parallel option */
1511 if (as->parms[6].items)
1512 parallel = as->parms[6].items->data;
1514 /* get the tmpdir filename if any */
1516 if (as->parms[7].items)
1517 tmpDir = as->parms[7].items->data;
1519 /* -orphans option */
1521 if (as->parms[8].items) {
1523 printf("Can't specify -orphans for MR-AFS fileserver\n");
1526 orphans = as->parms[8].items->data;
1530 if (!as->parms[9].items) { /* -forceDAFS flag */
1531 printf("This is a demand attach fileserver. Are you sure you want to proceed with a manual salvage?\n");
1532 printf("must specify -forceDAFS flag in order to proceed.\n");
1538 if (as->parms[MRAFS_OFFSET].items)
1539 mrafsParm.Optdebug = 1;
1540 if (as->parms[MRAFS_OFFSET + 1].items)
1541 mrafsParm.Optnowrite = 1;
1542 if (as->parms[MRAFS_OFFSET + 2].items)
1543 mrafsParm.Optforce = 1;
1544 if (as->parms[MRAFS_OFFSET + 3].items)
1545 mrafsParm.Optoktozap = 1;
1546 if (as->parms[MRAFS_OFFSET + 4].items)
1547 mrafsParm.Optrootfiles = 1;
1548 if (as->parms[MRAFS_OFFSET + 5].items)
1549 mrafsParm.Optsalvagedirs = 1;
1550 if (as->parms[MRAFS_OFFSET + 6].items)
1551 mrafsParm.Optblockreads = 1;
1552 if (as->parms[MRAFS_OFFSET + 7].items)
1553 mrafsParm.OptListResidencies = 1;
1554 if (as->parms[MRAFS_OFFSET + 8].items)
1555 mrafsParm.OptSalvageRemote = 1;
1556 if (as->parms[MRAFS_OFFSET + 9].items)
1557 mrafsParm.OptSalvageArchival = 1;
1558 if (as->parms[MRAFS_OFFSET + 10].items)
1559 mrafsParm.OptIgnoreCheck = 1;
1560 if (as->parms[MRAFS_OFFSET + 11].items)
1561 mrafsParm.OptForceOnLine = 1;
1562 if (as->parms[MRAFS_OFFSET + 12].items)
1563 mrafsParm.OptUseRootDirACL = 1;
1564 if (as->parms[MRAFS_OFFSET + 13].items)
1565 mrafsParm.OptTraceBadLinkCounts = 1;
1566 if (as->parms[MRAFS_OFFSET + 14].items)
1567 mrafsParm.OptDontAskFS = 1;
1568 if (as->parms[MRAFS_OFFSET + 15].items)
1569 mrafsParm.OptLogLevel =
1570 atoi(as->parms[MRAFS_OFFSET + 15].items->data);
1571 if (as->parms[MRAFS_OFFSET + 16].items)
1572 mrafsParm.OptRxDebug = 1;
1573 if (as->parms[MRAFS_OFFSET + 17].items) {
1574 if (as->parms[MRAFS_OFFSET + 8].items
1575 || as->parms[MRAFS_OFFSET + 9].items) {
1577 ("Can't specify -Residencies with -SalvageRemote or -SalvageArchival\n");
1581 util_GetUInt32(as->parms[MRAFS_OFFSET + 17].items->data,
1582 &mrafsParm.OptResidencies);
1584 printf("bos: '%s' is not a valid residency mask.\n",
1585 as->parms[MRAFS_OFFSET + 17].items->data);
1592 for (i = MRAFS_OFFSET; i < ADDPARMOFFSET; i++) {
1593 if (as->parms[i].items) {
1594 printf(" %s only possible for MR-AFS fileserver.\n",
1603 if (as->parms[4].items) {
1604 /* salvage whole enchilada */
1605 curGoal = GetServerGoal(tconn, serviceName);
1606 if (curGoal == BSTAT_NORMAL) {
1607 printf("bos: shutting down '%s'.\n", serviceName);
1608 code = BOZO_SetTStatus(tconn, serviceName, BSTAT_SHUTDOWN);
1610 printf("bos: failed to stop '%s' (%s)\n", serviceName, em(code));
1613 code = BOZO_WaitAll(tconn); /* wait for shutdown to complete */
1616 ("bos: failed to wait for file server shutdown, continuing.\n");
1618 /* now do the salvage operation */
1619 printf("Starting salvage.\n");
1620 rc = DoSalvage(tconn, NULL, NULL, outName, showlog, parallel, tmpDir,
1621 orphans, dafs, &mrafsParm);
1622 if (curGoal == BSTAT_NORMAL) {
1623 printf("bos: restarting %s.\n", serviceName);
1624 code = BOZO_SetTStatus(tconn, serviceName, BSTAT_NORMAL);
1626 printf("bos: failed to restart '%s' (%s)\n", serviceName, em(code));
1632 } else if (!as->parms[2].items) {
1633 if (!as->parms[1].items) {
1635 ("bos: must specify -all switch to salvage all partitions.\n");
1638 if (volutil_GetPartitionID(as->parms[1].items->data) < 0) {
1639 /* can't parse volume ID, so complain before shutting down
1642 printf("bos: can't interpret %s as partition ID.\n",
1643 as->parms[1].items->data);
1646 curGoal = GetServerGoal(tconn, serviceName);
1647 /* salvage a whole partition (specified by parms[1]) */
1648 if (curGoal == BSTAT_NORMAL) {
1649 printf("bos: shutting down '%s'.\n", serviceName);
1650 code = BOZO_SetTStatus(tconn, serviceName, BSTAT_SHUTDOWN);
1652 printf("bos: can't stop '%s' (%s)\n", serviceName, em(code));
1655 code = BOZO_WaitAll(tconn); /* wait for shutdown to complete */
1658 ("bos: failed to wait for file server shutdown, continuing.\n");
1660 /* now do the salvage operation */
1661 printf("Starting salvage.\n");
1662 rc = DoSalvage(tconn, as->parms[1].items->data, NULL, outName,
1663 showlog, parallel, tmpDir, orphans, dafs, &mrafsParm);
1664 if (curGoal == BSTAT_NORMAL) {
1665 printf("bos: restarting '%s'.\n", serviceName);
1666 code = BOZO_SetTStatus(tconn, serviceName, BSTAT_NORMAL);
1668 printf("bos: failed to restart '%s' (%s)\n", serviceName, em(code));
1675 /* salvage individual volume (don't shutdown fs first), just use
1676 * single-shot cron bnode. Must leave server running when using this
1677 * option, since salvager will ask file server for the volume */
1680 const char *confdir;
1683 if (as->parms[ADDPARMOFFSET].items)
1684 tmpname = as->parms[ADDPARMOFFSET].items->data;
1688 localauth = (as->parms[ADDPARMOFFSET + 2].items != 0);
1690 (localauth ? AFSDIR_SERVER_ETC_DIRPATH :
1691 AFSDIR_CLIENT_ETC_DIRPATH);
1693 code = vsu_ClientInit(confdir, tmpname,
1694 AFSCONF_SECOPTS_FALLBACK_NULL |
1695 AFSCONF_SECOPTS_NOAUTH,
1699 newID = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err);
1701 printf("bos: can't interpret %s as volume name or ID\n",
1702 as->parms[2].items->data);
1705 sprintf(tname, "%u", newID);
1708 ("bos: can't initialize volume system client (code %d), trying anyway.\n",
1710 strncpy(tname, as->parms[2].items->data, sizeof(tname));
1712 if (volutil_GetPartitionID(as->parms[1].items->data) < 0) {
1713 /* can't parse volume ID, so complain before shutting down
1716 printf("bos: can't interpret %s as partition ID.\n",
1717 as->parms[1].items->data);
1720 printf("Starting salvage.\n");
1721 rc = DoSalvage(tconn, as->parms[1].items->data, tname, outName,
1722 showlog, parallel, tmpDir, orphans, dafs, &mrafsParm);
1730 IStatServer(struct cmd_syndesc *as, int int32p)
1732 struct rx_connection *tconn;
1733 struct cmd_item *ti;
1736 tconn = GetConn(as, 0);
1737 for (ti = as->parms[1].items; ti; ti = ti->next) {
1738 DoStat(ti->data, tconn, int32p, firstTime);
1745 DoStat(IN char *aname,
1746 IN struct rx_connection *aconn,
1748 IN int firstTime) /* true iff first instance in cmd */
1754 struct bozo_status istatus;
1756 char *is1, *is2, *is3, *is4; /* instance strings */
1759 code = BOZO_GetInstanceInfo(aconn, aname, &tp, &istatus);
1761 printf("bos: failed to get instance info for '%s' (%s)\n", aname,
1765 if (firstTime && aint32p && (istatus.flags & BOZO_BADDIRACCESS))
1767 ("Bosserver reports inappropriate access on server directories\n");
1768 printf("Instance %s, ", aname);
1770 printf("(type is %s) ", buffer);
1771 if (istatus.fileGoal == istatus.goal) {
1773 printf("disabled, ");
1775 if (istatus.fileGoal)
1776 printf("temporarily disabled, ");
1778 printf("temporarily enabled, ");
1781 if (istatus.flags & BOZO_ERRORSTOP)
1782 printf("stopped for too many errors, ");
1783 if (istatus.flags & BOZO_HASCORE)
1784 printf("has core file, ");
1787 code = BOZO_GetStatus(aconn, aname, &temp, &tp);
1789 printf("bos: failed to get status for instance '%s' (%s)\n", aname,
1792 printf("currently ");
1793 if (temp == BSTAT_NORMAL)
1794 printf("running normally.\n");
1795 else if (temp == BSTAT_SHUTDOWN)
1796 printf("shutdown.\n");
1797 else if (temp == BSTAT_STARTINGUP)
1798 printf("starting up.\n");
1799 else if (temp == BSTAT_SHUTTINGDOWN)
1800 printf("shutting down.\n");
1801 if (buffer[0] != 0) {
1802 printf(" Auxiliary status is: %s.\n", buffer);
1806 /* are we done yet? */
1810 if (istatus.procStartTime)
1811 printf(" Process last started at %s (%d proc starts)\n",
1812 DateOf(istatus.procStartTime), istatus.procStarts);
1813 if (istatus.lastAnyExit) {
1814 printf(" Last exit at %s\n", DateOf(istatus.lastAnyExit));
1816 if (istatus.lastErrorExit) {
1817 is1 = is2 = is3 = is4 = NULL;
1818 printf(" Last error exit at %s, ", DateOf(istatus.lastErrorExit));
1819 code = BOZO_GetInstanceStrings(aconn, aname, &is1, &is2, &is3, &is4);
1820 /* don't complain about failing call, since could simply mean
1821 * interface mismatch.
1825 /* non-null instance string */
1826 printf("by %s, ", is1);
1833 if (istatus.errorSignal) {
1834 if (istatus.errorSignal == SIGTERM)
1835 printf("due to shutdown request\n");
1837 printf("due to signal %d\n", istatus.errorSignal);
1839 printf("by exiting with code %d\n", istatus.errorCode);
1843 /* try to display all the parms */
1846 code = BOZO_GetInstanceParm(aconn, aname, i, &tp);
1849 printf(" Command %d is '%s'\n", i + 1, buffer);
1852 code = BOZO_GetInstanceParm(aconn, aname, 999, &tp);
1854 /* Any type of failure is treated as not having a notifier program */
1855 printf(" Notifier is '%s'\n", buffer);
1863 GetRestrict(struct cmd_syndesc *as, void *arock)
1865 struct rx_connection *tconn;
1866 afs_int32 code, val;
1868 tconn = GetConn(as, 0);
1869 code = BOZO_GetRestrictedMode(tconn, &val);
1871 printf("bos: failed to get restricted mode (%s)\n", em(code));
1873 printf("Restricted mode is %s\n", val ? "on" : "off");
1879 SetRestrict(struct cmd_syndesc *as, void *arock)
1881 struct rx_connection *tconn;
1882 afs_int32 code, val;
1884 tconn = GetConn(as, 0);
1885 util_GetInt32(as->parms[1].items->data, &val);
1886 code = BOZO_SetRestrictedMode(tconn, val);
1888 printf("bos: failed to set restricted mode (%s)\n", em(code));
1893 add_std_args(struct cmd_syndesc *ts)
1895 cmd_Seek(ts, ADDPARMOFFSET);
1896 /* + 0 */ cmd_AddParm(ts, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell name");
1897 /* + 1 */ cmd_AddParm(ts, "-noauth", CMD_FLAG, CMD_OPTIONAL,
1898 "don't authenticate");
1899 /* + 2 */ cmd_AddParm(ts, "-localauth", CMD_FLAG, CMD_OPTIONAL,
1900 "create tickets from KeyFile");
1903 #include "AFS_component_version_number.c"
1906 main(int argc, char **argv)
1909 struct cmd_syndesc *ts;
1911 __declspec(dllimport)
1913 extern int afsconf_SawCell;
1915 #ifdef AFS_AIX32_ENV
1917 * The following signal action for AIX is necessary so that in case of a
1918 * crash (i.e. core is generated) we can include the user's data section
1919 * in the core dump. Unfortunately, by default, only a partial core is
1920 * generated which, in many cases, isn't too useful.
1922 struct sigaction nsa;
1924 sigemptyset(&nsa.sa_mask);
1925 nsa.sa_handler = SIG_DFL;
1926 nsa.sa_flags = SA_FULLDUMP;
1927 sigaction(SIGSEGV, &nsa, NULL);
1928 sigaction(SIGABRT, &nsa, NULL);
1934 printf("bos: could not initialize rx (%s)\n", em(code));
1938 /* To resolve a AFSCELL environment "Note: ..." problem: Because bos calls ka_Init (why?) before any
1939 * checkup on the existance of a "-cell" option on the particular bos command we don't print the
1940 * message if a cell is passed in. Luckily the rest of the programs don't call these adhoc routines
1941 * and things work fine. Note that if the "-cell" isn't passed then we're still ok since later on
1942 * the proper routine (afsconf_GetCellInfo) is going to be called to do the right thing.
1944 afsconf_SawCell = 1; /* Means don't print warning if AFSCELL is set */
1946 afsconf_SawCell = 0; /* Reset it */
1947 /* don't check error code, since fails sometimes when we're setting up a
1949 initialize_CMD_error_table();
1950 initialize_BZ_error_table();
1952 ts = cmd_CreateSyntax("start", StartServer, NULL, "start running a server");
1953 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1954 cmd_AddParm(ts, "-instance", CMD_LIST, 0, "server process name");
1957 ts = cmd_CreateSyntax("stop", StopServer, NULL, "halt a server instance");
1958 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1959 cmd_AddParm(ts, "-instance", CMD_LIST, 0, "server process name");
1961 cmd_AddParm(ts, "-wait", CMD_FLAG, CMD_OPTIONAL,
1962 "wait for process to stop");
1965 ts = cmd_CreateSyntax("status", StatServer, NULL,
1966 "show server instance status");
1967 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1968 cmd_AddParm(ts, "-instance", CMD_LIST, CMD_OPTIONAL,
1969 "server process name");
1970 cmd_AddParm(ts, "-long", CMD_FLAG, CMD_OPTIONAL, "long status");
1973 ts = cmd_CreateSyntax("shutdown", Shutdown, NULL, "shutdown all processes");
1974 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1975 cmd_AddParm(ts, "-instance", CMD_LIST, CMD_OPTIONAL, "instances");
1977 cmd_AddParm(ts, "-wait", CMD_FLAG, CMD_OPTIONAL,
1978 "wait for process to stop");
1981 ts = cmd_CreateSyntax("startup", Startup, NULL, "start all processes");
1982 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1983 cmd_AddParm(ts, "-instance", CMD_LIST, CMD_OPTIONAL, "instances");
1986 ts = cmd_CreateSyntax("restart", Restart, NULL, "restart processes");
1987 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1988 cmd_AddParm(ts, "-instance", CMD_LIST, CMD_OPTIONAL, "instances");
1989 cmd_AddParm(ts, "-bosserver", CMD_FLAG, CMD_OPTIONAL,
1990 "restart bosserver");
1991 cmd_AddParm(ts, "-all", CMD_FLAG, CMD_OPTIONAL, "restart all processes");
1996 ts = cmd_CreateSyntax("create", CreateServer, NULL,
1997 "create a new server instance");
1998 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1999 cmd_AddParm(ts, "-instance", CMD_SINGLE, 0, "server process name");
2000 cmd_AddParm(ts, "-type", CMD_SINGLE, 0, "server type");
2001 cmd_AddParm(ts, "-cmd", CMD_LIST, 0, "command lines");
2002 cmd_AddParm(ts, "-notifier", CMD_SINGLE, CMD_OPTIONAL,
2003 "Notifier program");
2006 ts = cmd_CreateSyntax("delete", DeleteServer, NULL,
2007 "delete a server instance");
2008 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2009 cmd_AddParm(ts, "-instance", CMD_LIST, 0, "server process name");
2012 ts = cmd_CreateSyntax("adduser", AddSUser, NULL,
2013 "add users to super-user list");
2014 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2015 cmd_AddParm(ts, "-user", CMD_LIST, 0, "user names");
2018 ts = cmd_CreateSyntax("removeuser", RemoveSUser, NULL,
2019 "remove users from super-user list");
2020 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2021 cmd_AddParm(ts, "-user", CMD_LIST, 0, "user names");
2024 ts = cmd_CreateSyntax("listusers", ListSUsers, NULL, "list super-users");
2025 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2028 ts = cmd_CreateSyntax("addkey", AddKey, NULL,
2029 "add keys to key dbase (kvno 999 is bcrypt)");
2030 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2031 cmd_AddParm(ts, "-key", CMD_SINGLE, CMD_OPTIONAL, "key");
2032 cmd_AddParm(ts, "-kvno", CMD_SINGLE, 0, "key version number");
2035 ts = cmd_CreateSyntax("removekey", RemoveKey, NULL,
2036 "remove keys from key dbase");
2037 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2038 cmd_AddParm(ts, "-kvno", CMD_LIST, 0, "key version number");
2041 ts = cmd_CreateSyntax("listkeys", ListKeys, NULL, "list keys");
2042 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2043 cmd_AddParm(ts, "-showkey", CMD_FLAG, CMD_OPTIONAL,
2044 "show the actual key rather than the checksum");
2047 ts = cmd_CreateSyntax("listhosts", ListHosts, NULL, "get cell host list");
2048 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2050 cmd_CreateAlias(ts, "getcell");
2052 ts = cmd_CreateSyntax("setcellname", SetCellName, NULL, "set cell name");
2053 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2054 cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "cell name");
2057 ts = cmd_CreateSyntax("addhost", AddHost, NULL, "add host to cell dbase");
2058 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2059 cmd_AddParm(ts, "-host", CMD_LIST, 0, "host name");
2060 cmd_AddParm(ts, "-clone", CMD_FLAG, CMD_OPTIONAL, "vote doesn't count");
2063 ts = cmd_CreateSyntax("removehost", RemoveHost, NULL,
2064 "remove host from cell dbase");
2065 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2066 cmd_AddParm(ts, "-host", CMD_LIST, 0, "host name");
2069 ts = cmd_CreateSyntax("setauth", SetAuth, NULL,
2070 "set authentication required flag");
2071 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2072 cmd_AddParm(ts, "-authrequired", CMD_SINGLE, 0,
2073 "on or off: authentication required for admin requests");
2076 ts = cmd_CreateSyntax("install", Install, NULL, "install program");
2077 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2078 cmd_AddParm(ts, "-file", CMD_LIST, 0, "files to install");
2079 cmd_AddParm(ts, "-dir", CMD_SINGLE, CMD_OPTIONAL, "destination dir");
2082 ts = cmd_CreateSyntax("uninstall", UnInstall, NULL, "uninstall program");
2083 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2084 cmd_AddParm(ts, "-file", CMD_LIST, 0, "files to uninstall");
2085 cmd_AddParm(ts, "-dir", CMD_SINGLE, CMD_OPTIONAL, "destination dir");
2088 ts = cmd_CreateSyntax("getlog", GetLogCmd, NULL, "examine log file");
2089 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2090 cmd_AddParm(ts, "-file", CMD_SINGLE, 0, "log file to examine");
2093 ts = cmd_CreateSyntax("getdate", GetDate, NULL, "get dates for programs");
2094 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2095 cmd_AddParm(ts, "-file", CMD_LIST, 0, "files to check");
2096 cmd_AddParm(ts, "-dir", CMD_SINGLE, CMD_OPTIONAL, "destination dir");
2099 ts = cmd_CreateSyntax("exec", Exec, NULL, "execute shell command on server");
2100 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2101 cmd_AddParm(ts, "-cmd", CMD_SINGLE, 0, "command to execute");
2104 ts = cmd_CreateSyntax("prune", Prune, NULL, "prune server files");
2105 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2106 cmd_AddParm(ts, "-bak", CMD_FLAG, CMD_OPTIONAL, "delete .BAK files");
2107 cmd_AddParm(ts, "-old", CMD_FLAG, CMD_OPTIONAL, "delete .OLD files");
2108 cmd_AddParm(ts, "-core", CMD_FLAG, CMD_OPTIONAL, "delete core files");
2109 cmd_AddParm(ts, "-all", CMD_FLAG, CMD_OPTIONAL, "delete all junk files");
2112 ts = cmd_CreateSyntax("setrestart", SetRestartCmd, NULL,
2113 "set restart times");
2114 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_REQUIRED, "machine name");
2115 cmd_AddParm(ts, "-time", CMD_SINGLE, CMD_REQUIRED,
2116 "time to restart server");
2117 cmd_AddParm(ts, "-general", CMD_FLAG, CMD_OPTIONAL,
2118 "set general restart time");
2119 cmd_AddParm(ts, "-newbinary", CMD_FLAG, CMD_OPTIONAL,
2120 "set new binary restart time");
2122 cmd_CreateAlias(ts, "setr");
2124 ts = cmd_CreateSyntax("getrestart", GetRestartCmd, NULL,
2125 "get restart times");
2126 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_REQUIRED, "machine name");
2128 cmd_CreateAlias(ts, "getr");
2130 ts = cmd_CreateSyntax("salvage", SalvageCmd, NULL,
2131 "salvage partition or volumes");
2132 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2133 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL,
2134 "salvage partition");
2135 cmd_AddParm(ts, "-volume", CMD_SINGLE, CMD_OPTIONAL,
2136 "salvage volume number or volume name");
2137 cmd_AddParm(ts, "-file", CMD_SINGLE, CMD_OPTIONAL,
2138 "salvage log output file");
2139 cmd_AddParm(ts, "-all", CMD_FLAG, CMD_OPTIONAL, "salvage whole server");
2140 cmd_AddParm(ts, "-showlog", CMD_FLAG, CMD_OPTIONAL,
2141 "display salvage log");
2142 cmd_AddParm(ts, "-parallel", CMD_SINGLE, CMD_OPTIONAL,
2143 "# of max parallel partition salvaging");
2144 cmd_AddParm(ts, "-tmpdir", CMD_SINGLE, CMD_OPTIONAL,
2145 "directory to place tmp files");
2146 cmd_AddParm(ts, "-orphans", CMD_SINGLE, CMD_OPTIONAL,
2147 "ignore | remove | attach");
2148 cmd_AddParm(ts, "-forceDAFS", CMD_FLAG, CMD_OPTIONAL,
2149 "(DAFS) force salvage of demand attach fileserver");
2150 cmd_AddParm(ts, "-debug", CMD_FLAG, CMD_OPTIONAL,
2151 "(MR-AFS) Run in Debugging mode");
2152 cmd_AddParm(ts, "-nowrite", CMD_FLAG, CMD_OPTIONAL,
2153 "(MR-AFS) Run readonly/test mode");
2154 cmd_AddParm(ts, "-force", CMD_FLAG, CMD_OPTIONAL,
2155 "(MR-AFS) Force full salvaging");
2156 cmd_AddParm(ts, "-oktozap", CMD_FLAG, CMD_OPTIONAL,
2157 "(MR-AFS) Give permission to destroy bogus file residencies/volumes - debugging flag");
2158 cmd_AddParm(ts, "-rootfiles", CMD_FLAG, CMD_OPTIONAL,
2159 "(MR-AFS) Show files owned by root - debugging flag");
2160 cmd_AddParm(ts, "-salvagedirs", CMD_FLAG, CMD_OPTIONAL,
2161 "(MR-AFS) Force rebuild/salvage of all directories");
2162 cmd_AddParm(ts, "-blockreads", CMD_FLAG, CMD_OPTIONAL,
2163 "(MR-AFS) Read smaller blocks to handle IO/bad blocks");
2164 cmd_AddParm(ts, "-ListResidencies", CMD_FLAG, CMD_OPTIONAL,
2165 "(MR-AFS) Just list affected file residencies - debugging flag");
2166 cmd_AddParm(ts, "-SalvageRemote", CMD_FLAG, CMD_OPTIONAL,
2167 "(MR-AFS) Salvage storage systems that are not directly attached");
2168 cmd_AddParm(ts, "-SalvageArchival", CMD_FLAG, CMD_OPTIONAL,
2169 "(MR-AFS) Salvage HSM storage systems");
2170 cmd_AddParm(ts, "-IgnoreCheck", CMD_FLAG, CMD_OPTIONAL,
2171 "(MR-AFS) Don't perform VLDB safety check when deleting unreferenced files. Only a good idea in single server cell.");
2172 cmd_AddParm(ts, "-ForceOnLine", CMD_FLAG, CMD_OPTIONAL,
2173 "(MR-AFS) Force the volume to come online, even if it hasn't salvaged cleanly.");
2174 cmd_AddParm(ts, "-UseRootDirACL", CMD_FLAG, CMD_OPTIONAL,
2175 "(MR-AFS) Use the root directory ACL for lost+found directory if it is created.");
2176 cmd_AddParm(ts, "-TraceBadLinkCounts", CMD_FLAG, CMD_OPTIONAL,
2177 "(MR-AFS) Print out lines about volume reference count changes.");
2178 cmd_AddParm(ts, "-DontAskFS", CMD_FLAG, CMD_OPTIONAL,
2179 "(MR-AFS) Don't ask fileserver to take volume offline. THIS IS VERY DANGEROUS.");
2180 cmd_AddParm(ts, "-LogLevel", CMD_SINGLE, CMD_OPTIONAL,
2181 "(MR-AFS) log level");
2182 cmd_AddParm(ts, "-rxdebug", CMD_FLAG, CMD_OPTIONAL,
2183 "(MR-AFS) Write out rx debug information.");
2184 cmd_AddParm(ts, "-Residencies", CMD_SINGLE, CMD_OPTIONAL,
2185 "(MR-AFS) Numeric mask of residencies to be included in the salvage. Do not use with -SalvageRemote or -SalvageArchival");
2188 ts = cmd_CreateSyntax("blockscanner", BlockScannerCmd, NULL,
2189 "block scanner daemon from making migration requests");
2190 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_REQUIRED, "machine name");
2193 ts = cmd_CreateSyntax("unblockscanner", UnBlockScannerCmd, NULL,
2194 "allow scanner daemon to make migration requests again");
2195 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_REQUIRED, "machine name");
2198 ts = cmd_CreateSyntax("getrestricted", GetRestrict, NULL,
2199 "get restrict mode");
2200 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2203 ts = cmd_CreateSyntax("setrestricted", SetRestrict, NULL,
2204 "set restrict mode");
2205 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2206 cmd_AddParm(ts, "-mode", CMD_SINGLE, 0, "mode to set");
2210 code = cmd_Dispatch(argc, argv);