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>
17 #include <sys/types.h>
24 #include <netinet/in.h>
26 #include <sys/socket.h>
28 #endif /* AFS_NT40_ENV */
30 #include <afs/procmgmt.h> /* signal(), kill(), wait(), etc. */
34 #include <afs/afsutil.h>
35 #include <afs/cellconfig.h>
40 #include <afs/cellconfig.h>
43 #include <afs/com_err.h>
45 #include <afs/ktime.h>
47 #include <des_prototypes.h>
48 #include <afs/kautils.h>
49 #include <afs/volser.h>
51 static int IStatServer(register struct cmd_syndesc *as, int int32p);
52 static int DoStat(char *aname, register struct rx_connection *aconn,
53 int aint32p, int firstTime);
56 #include "bosprototypes.h"
58 /* command offsets for bos salvage command */
59 #define MRAFS_OFFSET 10
60 #define ADDPARMOFFSET 27
62 /* MR-AFS salvage parameters */
63 struct MRAFSSalvageParms {
68 afs_int32 Optrootfiles;
69 afs_int32 Optsalvagedirs;
70 afs_int32 Optblockreads;
71 afs_int32 OptListResidencies;
72 afs_int32 OptSalvageRemote;
73 afs_int32 OptSalvageArchival;
74 afs_int32 OptIgnoreCheck;
75 afs_int32 OptForceOnLine;
76 afs_int32 OptUseRootDirACL;
77 afs_int32 OptTraceBadLinkCounts;
78 afs_int32 OptDontAskFS;
79 afs_int32 OptLogLevel;
81 afs_uint32 OptResidencies;
84 /* dummy routine for the audit work. It should do nothing since audits */
85 /* occur at the server level and bos is not a server. */
91 /* keep those lines small */
96 return "communications failure (-1)";
98 return "communications timeout (-3)";
100 return (char *)afs_error_message(acode);
103 /* get partition id from a name */
104 /* XXX - unused code - could be removed? */
107 GetPartitionID(char *aname)
114 return -1; /* unknown */
115 /* numbers go straight through */
116 if (tc >= '0' && tc <= '9') {
119 /* otherwise check for vicepa or /vicepa, or just plain "a" */
121 if (strlen(aname) <= 2) {
122 strcpy(ascii, aname);
123 } else if (!strncmp(aname, "/vicep", 6)) {
124 strncpy(ascii, aname + 6, 2);
125 } else if (!strncmp(aname, "vicep", 5)) {
126 strncpy(ascii, aname + 5, 2);
128 return -1; /* bad partition name */
129 /* now partitions are named /vicepa ... /vicepz, /vicepaa, /vicepab,
130 * .../vicepzz, and are numbered from 0. Do the appropriate conversion */
132 /* one char name, 0..25 */
133 if (ascii[0] < 'a' || ascii[0] > 'z')
134 return -1; /* wrongo */
135 return ascii[0] - 'a';
137 /* two char name, 26 .. <whatever> */
138 if (ascii[0] < 'a' || ascii[0] > 'z')
139 return -1; /* wrongo */
140 if (ascii[1] < 'a' || ascii[1] > 'z')
141 return -1; /* just as bad */
142 return (ascii[0] - 'a') * 26 + (ascii[1] - 'a') + 26;
147 /* make ctime easier to use */
149 DateOf(afs_int32 atime)
151 static char tbuffer[30];
153 time_t t = (time_t) atime;
157 tbuffer[24] = 0; /* get rid of new line */
159 strcpy(tbuffer, "BAD TIME");
164 /* use the syntax descr to get a connection, authenticated appropriately.
165 * aencrypt is set if we want to encrypt the data on the wire.
167 static struct rx_connection *
168 GetConn(struct cmd_syndesc *as, int aencrypt)
172 char *cellname = NULL;
174 register afs_int32 code;
175 register struct rx_connection *tconn;
177 struct afsconf_dir *tdir = NULL;
178 afsconf_secflags secFlags;
179 struct rx_securityClass *sc;
182 hostname = as->parms[0].items->data;
183 th = hostutil_GetHostByName(hostname);
185 printf("bos: can't find address for host '%s'\n", hostname);
188 memcpy(&addr, th->h_addr, sizeof(afs_int32));
190 secFlags = AFSCONF_SECOPTS_FALLBACK_NULL;
192 if (as->parms[ADDPARMOFFSET + 2].items) { /* -localauth */
193 secFlags |= AFSCONF_SECOPTS_LOCALAUTH;
194 confdir = AFSDIR_SERVER_ETC_DIRPATH;
196 confdir = AFSDIR_CLIENT_ETC_DIRPATH;
199 if (as->parms[ADDPARMOFFSET + 1].items) { /* -noauth */
200 secFlags |= AFSCONF_SECOPTS_NOAUTH;
202 /* If we're running with -noauth, we don't need a configuration
204 tdir = afsconf_Open(confdir);
206 printf("bos: can't open cell database (%s)\n", confdir);
211 if (as->parms[ADDPARMOFFSET].items) /* -cell */
212 cellname = as->parms[ADDPARMOFFSET].items->data;
214 code = afsconf_PickClientSecObj(tdir, secFlags, NULL, cellname,
215 &sc, &scIndex, NULL);
217 afs_com_err("bos", code, "(configuring connection security)");
222 fprintf(stderr, "bos: running unauthenticated\n");
225 rx_NewConnection(addr, htons(AFSCONF_NANNYPORT), 1, sc, scIndex);
227 fprintf(stderr, "bos: could not create rx connection\n");
236 SetAuth(struct cmd_syndesc *as, void *arock)
238 register afs_int32 code;
239 register struct rx_connection *tconn;
243 tconn = GetConn(as, 0);
244 tp = as->parms[1].items->data;
245 if (strcmp(tp, "on") == 0)
246 flag = 0; /* auth req.: noauthflag is false */
247 else if (strcmp(tp, "off") == 0)
251 ("bos: illegal authentication specifier '%s', must be 'off' or 'on'.\n",
255 code = BOZO_SetNoAuthFlag(tconn, flag);
257 afs_com_err("bos", code, "(failed to set authentication flag)");
261 /* take a name (e.g. foo/bar, and a dir e.g. /usr/afs/bin, and construct
262 * /usr/afs/bin/bar */
264 ComputeDestDir(char *aname, char *adir, char *aresult, afs_int32 alen)
268 strcpy(aresult, adir);
269 tp = strrchr(aname, '/');
272 strcat(aresult, "/");
273 strcat(aresult, aname);
275 /* tp points at the / character */
281 /* copy data from fd afd to rx call acall */
283 CopyBytes(int afd, register struct rx_call *acall)
285 register afs_int32 code;
286 register afs_int32 len;
290 len = read(afd, tbuffer, sizeof(tbuffer));
294 return 0; /* all done */
295 code = rx_Write(acall, tbuffer, len);
302 Prune(register struct cmd_syndesc *as, void *arock)
304 register afs_int32 code;
305 register struct rx_connection *tconn;
306 register afs_int32 flags;
308 tconn = GetConn(as, 0);
310 if (as->parms[1].items)
311 flags |= BOZO_PRUNEBAK;
312 if (as->parms[2].items)
313 flags |= BOZO_PRUNEOLD;
314 if (as->parms[3].items)
315 flags |= BOZO_PRUNECORE;
316 if (as->parms[4].items)
318 code = BOZO_Prune(tconn, flags);
320 afs_com_err("bos", code, "(failed to prune server files)");
325 Exec(register struct cmd_syndesc *as, void *arock)
327 register struct rx_connection *tconn;
328 register afs_int32 code;
330 tconn = GetConn(as, 0);
331 code = BOZO_Exec(tconn, as->parms[1].items->data);
333 printf("bos: failed to execute command (%s)\n", em(code));
338 GetDate(register struct cmd_syndesc *as, void *arock)
340 register afs_int32 code;
343 afs_int32 time, bakTime, oldTime;
344 register struct rx_connection *tconn;
345 register struct cmd_item *ti;
347 tconn = GetConn(as, 0);
348 if (!as->parms[1].items) {
349 printf("bos: no files to check\n");
353 /* compute dest dir or file; default MUST be canonical form of dir path */
354 if (as->parms[2].items)
355 strcpy(destDir, as->parms[2].items->data);
357 strcpy(destDir, AFSDIR_CANONICAL_SERVER_BIN_DIRPATH);
359 for (ti = as->parms[1].items; ti; ti = ti->next) {
360 /* check date for each file */
361 ComputeDestDir(ti->data, destDir, tbuffer, sizeof(tbuffer));
362 code = BOZO_GetDates(tconn, tbuffer, &time, &bakTime, &oldTime);
364 printf("bos: failed to check date on %s (%s)\n", ti->data,
368 printf("File %s ", tbuffer);
370 printf("does not exist, ");
372 printf("dated %s, ", DateOf(time));
374 printf("no .BAK file, ");
376 printf(".BAK file dated %s, ", DateOf(bakTime));
378 printf("no .OLD file.");
380 printf(".OLD file dated %s.", DateOf(oldTime));
388 UnInstall(register struct cmd_syndesc *as, void *arock)
390 register afs_int32 code;
393 register struct cmd_item *ti;
394 register struct rx_connection *tconn;
396 tconn = GetConn(as, 0);
397 if (!as->parms[1].items) {
398 printf("bos: no files to uninstall\n");
402 /* compute dest dir or file; default MUST be canonical form of dir path */
403 if (as->parms[2].items)
404 strcpy(destDir, as->parms[2].items->data);
406 strcpy(destDir, AFSDIR_CANONICAL_SERVER_BIN_DIRPATH);
408 for (ti = as->parms[1].items; ti; ti = ti->next) {
409 /* uninstall each file */
410 ComputeDestDir(ti->data, destDir, tbuffer, sizeof(tbuffer));
411 code = BOZO_UnInstall(tconn, tbuffer);
413 printf("bos: failed to uninstall %s (%s)\n", ti->data, em(code));
416 printf("bos: uninstalled file %s\n", ti->data);
422 GetServerGoal(struct rx_connection *aconn, char *aname)
426 register afs_int32 code;
427 struct bozo_status istatus;
430 code = BOZO_GetInstanceInfo(aconn, aname, &tp, &istatus);
432 printf("bos: failed to get instance info for '%s' (%s)\n", aname,
434 /* if we can't get the answer, assume its running */
437 if (istatus.goal == 0)
438 return BSTAT_SHUTDOWN;
444 Install(struct cmd_syndesc *as, void *arock)
446 struct rx_connection *tconn;
447 register afs_int32 code;
448 register struct cmd_item *ti;
452 struct rx_call *tcall;
455 tconn = GetConn(as, 0);
456 if (!as->parms[1].items) {
457 printf("bos: no files to install\n");
461 /* compute dest dir or file; default MUST be canonical form of dir path */
462 if (as->parms[2].items)
463 strcpy(destDir, as->parms[2].items->data);
465 strcpy(destDir, AFSDIR_CANONICAL_SERVER_BIN_DIRPATH);
467 for (ti = as->parms[1].items; ti; ti = ti->next) {
468 /* install each file */
469 fd = open(ti->data, O_RDONLY);
471 /* better to quit on error than continue for install command */
472 printf("bos: can't find file '%s', quitting\n", ti->data);
475 code = fstat(fd, &tstat);
477 printf("bos: failed to stat file %s, errno is %d\n", ti->data,
481 /* compute destination dir */
482 ComputeDestDir(ti->data, destDir, tbuffer, sizeof(tbuffer));
483 tcall = rx_NewCall(tconn);
485 StartBOZO_Install(tcall, tbuffer, tstat.st_size,
486 (afs_int32) tstat.st_mode, tstat.st_mtime);
488 code = CopyBytes(fd, tcall);
490 code = rx_EndCall(tcall, code);
492 printf("bos: failed to install %s (%s)\n", ti->data, em(code));
495 printf("bos: installed file %s\n", ti->data);
501 Shutdown(struct cmd_syndesc *as, void *arock)
503 register struct rx_connection *tconn;
504 register afs_int32 code;
505 register struct cmd_item *ti;
507 tconn = GetConn(as, 0);
508 if (as->parms[1].items == 0) {
509 code = BOZO_ShutdownAll(tconn);
511 printf("bos: failed to shutdown servers (%s)\n", em(code));
513 for (ti = as->parms[1].items; ti; ti = ti->next) {
514 code = BOZO_SetTStatus(tconn, ti->data, BSTAT_SHUTDOWN);
516 printf("bos: failed to shutdown instance %s (%s)\n", ti->data,
520 if (as->parms[8].items) {
521 code = BOZO_WaitAll(tconn);
523 printf("bos: can't wait for processes to shutdown (%s)\n",
530 BlockScannerCmd(struct cmd_syndesc *as, void *arock)
532 register afs_int32 code;
533 struct rx_connection *tconn;
534 char BlockCommand[] = "/usr/afs/bin/scanner -block";
536 tconn = GetConn(as, 0);
537 code = BOZO_Exec(tconn, BlockCommand);
540 ("bos: failed to block scanner from making migration requests (%s)\n",
546 UnBlockScannerCmd(struct cmd_syndesc *as, void *arock)
548 register afs_int32 code;
549 struct rx_connection *tconn;
550 char UnBlockCommand[] = "/usr/afs/bin/scanner -unblock";
552 tconn = GetConn(as, 0);
553 code = BOZO_Exec(tconn, UnBlockCommand);
556 ("bos: failed to allow scanner daemon to make migration requests again (%s)\n",
562 GetRestartCmd(struct cmd_syndesc *as, void *arock)
564 register afs_int32 code;
565 struct ktime generalTime, newBinaryTime;
566 char messageBuffer[256];
567 struct rx_connection *tconn;
570 hostp = as->parms[0].items->data; /* host name for messages */
571 tconn = GetConn(as, 0);
573 code = BOZO_GetRestartTime(tconn, 1, (struct bozo_netKTime *) &generalTime);
575 printf("bos: failed to retrieve restart information (%s)\n",
579 code = BOZO_GetRestartTime(tconn, 2, (struct bozo_netKTime *) &newBinaryTime);
581 printf("bos: failed to retrieve restart information (%s)\n",
586 code = ktime_DisplayString(&generalTime, messageBuffer);
588 printf("bos: failed to decode restart time (%s)\n", em(code));
591 printf("Server %s restarts %s\n", hostp, messageBuffer);
593 code = ktime_DisplayString(&newBinaryTime, messageBuffer);
595 printf("bos: failed to decode restart time (%s)\n", em(code));
598 printf("Server %s restarts for new binaries %s\n", hostp, messageBuffer);
605 SetRestartCmd(struct cmd_syndesc *as, void *arock)
608 register afs_int32 code;
609 struct ktime restartTime;
611 struct rx_connection *tconn;
614 tconn = GetConn(as, 0);
615 if (as->parms[2].items) {
619 if (as->parms[3].items) {
624 printf("bos: can't specify more than one restart time at a time\n");
628 type = 1; /* by default set general restart time */
630 if ((code = ktime_ParsePeriodic(as->parms[1].items->data, &restartTime))) {
631 printf("bos: failed to parse '%s' as periodic restart time(%s)\n",
632 as->parms[1].items->data, em(code));
636 code = BOZO_SetRestartTime(tconn, type, (struct bozo_netKTime *) &restartTime);
638 printf("bos: failed to set restart time at server (%s)\n", em(code));
645 Startup(struct cmd_syndesc *as, void *arock)
647 register struct rx_connection *tconn;
648 register afs_int32 code;
649 register struct cmd_item *ti;
651 tconn = GetConn(as, 0);
652 if (as->parms[1].items == 0) {
653 code = BOZO_StartupAll(tconn);
655 printf("bos: failed to startup servers (%s)\n", em(code));
657 for (ti = as->parms[1].items; ti; ti = ti->next) {
658 code = BOZO_SetTStatus(tconn, ti->data, BSTAT_NORMAL);
660 printf("bos: failed to start instance %s (%s)\n", ti->data,
668 Restart(struct cmd_syndesc *as, void *arock)
670 register struct rx_connection *tconn;
671 register afs_int32 code;
672 register struct cmd_item *ti;
674 tconn = GetConn(as, 0);
675 if (as->parms[2].items) {
676 /* this is really a rebozo command */
677 if (as->parms[1].items) {
678 /* specified specific things to restart, can't do this at the same
681 ("bos: can't specify both '-bos' and specific servers to restart.\n");
684 /* otherwise do a rebozo */
685 code = BOZO_ReBozo(tconn);
687 printf("bos: failed to restart bosserver (%s)\n", em(code));
690 if (as->parms[1].items == 0) {
691 if (as->parms[3].items) { /* '-all' */
692 code = BOZO_RestartAll(tconn);
694 printf("bos: failed to restart servers (%s)\n", em(code));
696 printf("bos: To restart all processes please specify '-all'\n");
698 if (as->parms[3].items) {
699 printf("bos: Can't use '-all' along with individual instances\n");
701 for (ti = as->parms[1].items; ti; ti = ti->next) {
702 code = BOZO_Restart(tconn, ti->data);
704 printf("bos: failed to restart instance %s (%s)\n",
713 SetCellName(struct cmd_syndesc *as, void *arock)
715 register struct rx_connection *tconn;
716 register afs_int32 code;
718 tconn = GetConn(as, 0);
719 code = BOZO_SetCellName(tconn, as->parms[1].items->data);
721 printf("bos: failed to set cell (%s)\n", em(code));
726 AddHost(register struct cmd_syndesc *as, void *arock)
728 register struct rx_connection *tconn;
729 register afs_int32 code;
730 register struct cmd_item *ti;
731 char name[MAXHOSTCHARS];
733 tconn = GetConn(as, 0);
734 for (ti = as->parms[1].items; ti; ti = ti->next) {
735 if (as->parms[2].items) {
736 if (strlen(ti->data) > MAXHOSTCHARS - 3) {
737 fprintf(stderr, "bos: host name too long\n");
741 strcpy(&name[1], ti->data);
742 strcat((char *)&name, "]");
743 code = BOZO_AddCellHost(tconn, name);
745 code = BOZO_AddCellHost(tconn, ti->data);
747 printf("bos: failed to add host %s (%s)\n", ti->data, em(code));
753 RemoveHost(register struct cmd_syndesc *as, void *arock)
755 register struct rx_connection *tconn;
756 register afs_int32 code;
757 register struct cmd_item *ti;
759 tconn = GetConn(as, 0);
760 for (ti = as->parms[1].items; ti; ti = ti->next) {
761 code = BOZO_DeleteCellHost(tconn, ti->data);
763 printf("bos: failed to delete host %s (%s)\n", ti->data,
770 ListHosts(register struct cmd_syndesc *as, void *arock)
772 register struct rx_connection *tconn;
773 register afs_int32 code;
776 register afs_int32 i;
779 tconn = GetConn(as, 0);
780 code = BOZO_GetCellName(tconn, &tp);
782 printf("bos: failed to get cell name (%s)\n", em(code));
785 printf("Cell name is %s\n", tbuffer);
787 code = BOZO_GetCellHost(tconn, i, &tp);
791 printf("bos: failed to get cell host %d (%s)\n", i, em(code));
794 printf(" Host %d is %s\n", i + 1, tbuffer);
800 AddKey(register struct cmd_syndesc *as, void *arock)
802 register struct rx_connection *tconn;
803 register afs_int32 code;
804 struct ktc_encryptionKey tkey;
807 char cellBuffer[256];
808 char buf[BUFSIZ], ver[BUFSIZ];
810 tconn = GetConn(as, 1);
811 memset(&tkey, 0, sizeof(struct ktc_encryptionKey));
813 if (as->parms[1].items)
814 strcpy(buf, as->parms[1].items->data);
817 code = des_read_pw_string(buf, sizeof(buf), "input key: ", 0);
818 if (code || strlen(buf) == 0) {
819 fprintf(stderr, "Bad key: \n");
822 code = des_read_pw_string(ver, sizeof(ver), "Retype input key: ", 0);
823 if (code || strlen(ver) == 0) {
824 fprintf(stderr, "Bad key: \n");
827 if (strcmp(ver, buf) != 0) {
828 fprintf(stderr, "\nInput key mismatch\n");
834 temp = atoi(as->parms[2].items->data);
838 strcpy((char *)&tkey, as->parms[1].items->data);
840 strcpy((char *)&tkey, buf);
841 } else { /* kerberos key */
842 if (as->parms[ADDPARMOFFSET].items) {
843 strcpy(cellBuffer, as->parms[ADDPARMOFFSET].items->data);
845 /* string to key needs upper-case cell names */
847 /* I don't believe this is true. The string to key function
848 * actually expands the cell name, then LOWER-CASES it. Perhaps it
849 * didn't use to??? */
850 ucstring(cellBuffer, cellBuffer, strlen(cellBuffer));
853 tcell = NULL; /* no cell specified, use current */
855 ka_StringToKey(as->parms[1].items->data, tcell, &tkey);
857 ka_StringToKey(buf, tcell, &tkey);
859 tconn = GetConn(as, 1);
860 code = BOZO_AddKey(tconn, temp, ktc_to_bozoptr(&tkey));
862 printf("bos: failed to set key %d (%s)\n", temp, em(code));
869 RemoveKey(register struct cmd_syndesc *as, void *arock)
871 register struct rx_connection *tconn;
872 register afs_int32 code;
874 register struct cmd_item *ti;
876 tconn = GetConn(as, 0);
877 for (ti = as->parms[1].items; ti; ti = ti->next) {
878 temp = atoi(ti->data);
879 code = BOZO_DeleteKey(tconn, temp);
881 printf("bos: failed to delete key %d (%s)\n", temp, em(code));
889 ListKeys(register struct cmd_syndesc *as, void *arock)
891 register struct rx_connection *tconn;
892 register afs_int32 code;
893 struct ktc_encryptionKey tkey;
895 struct bozo_keyInfo keyInfo;
897 register afs_int32 i;
899 tconn = GetConn(as, 1);
902 code = BOZO_ListKeys(tconn, i, &kvno, ktc_to_bozoptr(&tkey), &keyInfo);
906 /* first check if key is returned */
907 if ((!ka_KeyIsZero(ktc_to_charptr(&tkey), sizeof(tkey))) && (as->parms[1].items)) {
908 printf("key %d is '", kvno);
909 ka_PrintBytes(ktc_to_charptr(&tkey), sizeof(tkey));
912 if (keyInfo.keyCheckSum == 0) /* shouldn't happen */
913 printf("key version is %d\n", kvno);
915 printf("key %d has cksum %u\n", kvno, keyInfo.keyCheckSum);
919 printf("Keys last changed on %s.\n", DateOf(keyInfo.mod_sec));
922 printf("bos: %s error encountered while listing keys\n", em(code));
924 printf("All done.\n");
929 AddSUser(register struct cmd_syndesc *as, void *arock)
931 register struct rx_connection *tconn;
932 register afs_int32 code;
934 register struct cmd_item *ti;
937 tconn = GetConn(as, 0);
938 for (ti = as->parms[1].items; ti; ti = ti->next) {
939 code = BOZO_AddSUser(tconn, ti->data);
941 printf("bos: failed to add user '%s' (%s)\n", ti->data, em(code));
949 RemoveSUser(register struct cmd_syndesc *as, void *arock)
951 register struct rx_connection *tconn;
952 register struct cmd_item *ti;
953 register afs_int32 code;
957 tconn = GetConn(as, 0);
958 for (ti = as->parms[1].items; ti; ti = ti->next) {
959 code = BOZO_DeleteSUser(tconn, ti->data);
961 printf("bos: failed to delete user '%s', ", ti->data);
963 printf("(no such user)\n");
965 printf("(%s)\n", em(code));
972 #define NPERLINE 10 /* dudes to print per line */
974 ListSUsers(register struct cmd_syndesc *as, void *arock)
976 register struct rx_connection *tconn;
978 register afs_int32 code;
981 int lastNL, printGreeting;
983 tconn = GetConn(as, 0);
988 code = BOZO_ListSUsers(tconn, i, &tp);
992 printGreeting = 0; /* delay until after first call succeeds */
993 printf("SUsers are: ");
995 printf("%s ", tbuffer);
996 if ((i % NPERLINE) == NPERLINE - 1) {
1003 /* a real error code, instead of scanned past end */
1004 printf("bos: failed to retrieve super-user list (%s)\n", em(code));
1013 StatServer(register struct cmd_syndesc *as, void *arock)
1015 register struct rx_connection *tconn;
1016 register afs_int32 code;
1018 char ibuffer[BOZO_BSSIZE];
1022 /* int32p==1 is obsolete, smaller, printout */
1023 int32p = (as->parms[2].items != 0 ? 2 : 0);
1025 /* no parms does something pretty different */
1026 if (as->parms[1].items)
1027 return IStatServer(as, int32p);
1029 tconn = GetConn(as, 0);
1031 /* for each instance */
1033 code = BOZO_EnumerateInstance(tconn, i, &tp);
1037 printf("bos: failed to contact host's bosserver (%s).\n",
1041 DoStat(ibuffer, tconn, int32p, (i == 0)); /* print status line */
1047 CreateServer(register struct cmd_syndesc *as, void *arock)
1049 register struct rx_connection *tconn;
1050 register afs_int32 code;
1052 register struct cmd_item *ti;
1054 char *type, *name, *notifier = NONOTIFIER;
1056 tconn = GetConn(as, 0);
1057 for (i = 0; i < 6; i++)
1059 for (i = 0, ti = as->parms[3].items; (ti && i < 6); ti = ti->next, i++) {
1060 parms[i] = ti->data;
1062 name = as->parms[1].items->data;
1063 type = as->parms[2].items->data;
1064 if ((ti = as->parms[4].items)) {
1065 notifier = ti->data;
1068 BOZO_CreateBnode(tconn, type, name, parms[0], parms[1], parms[2],
1069 parms[3], parms[4], notifier);
1072 ("bos: failed to create new server instance %s of type '%s' (%s)\n",
1073 name, type, em(code));
1079 DeleteServer(register struct cmd_syndesc *as, void *arock)
1081 register struct rx_connection *tconn;
1082 register afs_int32 code;
1083 register struct cmd_item *ti;
1086 tconn = GetConn(as, 0);
1087 for (ti = as->parms[1].items; ti; ti = ti->next) {
1088 code = BOZO_DeleteBnode(tconn, ti->data);
1091 printf("bos: can't delete running instance '%s'\n", ti->data);
1093 printf("bos: failed to delete instance '%s' (%s)\n", ti->data,
1101 StartServer(register struct cmd_syndesc *as, void *arock)
1103 register struct rx_connection *tconn;
1104 register afs_int32 code;
1105 register struct cmd_item *ti;
1108 tconn = GetConn(as, 0);
1109 for (ti = as->parms[1].items; ti; ti = ti->next) {
1110 code = BOZO_SetStatus(tconn, ti->data, BSTAT_NORMAL);
1112 printf("bos: failed to start instance '%s' (%s)\n", ti->data,
1119 StopServer(register struct cmd_syndesc *as, void *arock)
1121 register struct rx_connection *tconn;
1122 register afs_int32 code;
1123 register struct cmd_item *ti;
1126 tconn = GetConn(as, 0);
1127 for (ti = as->parms[1].items; ti; ti = ti->next) {
1128 code = BOZO_SetStatus(tconn, ti->data, BSTAT_SHUTDOWN);
1130 printf("bos: failed to change stop instance '%s' (%s)\n",
1131 ti->data, em(code));
1133 if (as->parms[8].items) {
1134 code = BOZO_WaitAll(tconn);
1136 printf("bos: can't wait for processes to shutdown (%s)\n",
1142 #define PARMBUFFERSSIZE 32
1145 DoSalvage(struct rx_connection * aconn, char * aparm1, char * aparm2,
1146 char * aoutName, afs_int32 showlog, char * parallel,
1147 char * atmpDir, char * orphans, int dafs,
1148 struct MRAFSSalvageParms * mrafsParm)
1150 register afs_int32 code;
1153 char tbuffer[BOZO_BSSIZE];
1154 struct bozo_status istatus;
1155 struct rx_call *tcall;
1159 char partName[20]; /* canonical name for partition */
1160 char pbuffer[PARMBUFFERSSIZE];
1161 afs_int32 partNumber;
1162 char *notifier = NONOTIFIER;
1164 /* if a partition was specified, canonicalize the name, since
1165 * the salvager has a stupid partition ID parser */
1167 partNumber = volutil_GetPartitionID(aparm1);
1168 if (partNumber < 0) {
1169 printf("bos: could not parse partition ID '%s'\n", aparm1);
1172 tp = volutil_PartitionName(partNumber);
1174 printf("bos: internal error parsing partition ID '%s'\n", aparm1);
1177 strcpy(partName, tp);
1181 /* open the file name */
1183 outFile = fopen(aoutName, "w");
1185 printf("bos: can't open specified SalvageLog file '%s'\n",
1189 closeIt = 1; /* close this file later */
1192 closeIt = 0; /* don't close this file later */
1195 for (code = 2; code < 6; code++)
1200 /* MUST pass canonical (wire-format) salvager path to bosserver */
1202 /* single volume salvage */
1204 /* for DAFS, we call the salvagserver binary with special options.
1205 * in this mode, it simply uses SALVSYNC to tell the currently
1206 * running salvageserver to offline and salvage the volume in question */
1207 strncpy(tbuffer, AFSDIR_CANONICAL_SERVER_SALSRV_FILEPATH, BOZO_BSSIZE);
1209 if ((strlen(tbuffer) + 9 + strlen(partName) + 1 + strlen(aparm2) +
1211 printf("bos: command line too big\n");
1215 strcat(tbuffer, " -client ");
1216 strcat(tbuffer, partName);
1217 strcat(tbuffer, " ");
1218 strcat(tbuffer, aparm2);
1220 strncpy(tbuffer, AFSDIR_CANONICAL_SERVER_SALVAGER_FILEPATH, BOZO_BSSIZE);
1222 if ((strlen(tbuffer) + 1 + strlen(partName) + 1 + strlen(aparm2) +
1224 printf("bos: command line too big\n");
1228 strcat(tbuffer, " ");
1229 strcat(tbuffer, partName);
1230 strcat(tbuffer, " ");
1231 strcat(tbuffer, aparm2);
1234 /* partition salvage */
1235 strncpy(tbuffer, AFSDIR_CANONICAL_SERVER_SALVAGER_FILEPATH, BOZO_BSSIZE);
1236 if ((strlen(tbuffer) + 4 + strlen(partName) + 1) > BOZO_BSSIZE) {
1237 printf("bos: command line too big\n");
1240 strcat(tbuffer, " -force ");
1241 strcat(tbuffer, partName);
1244 /* For DAFS, specifying a single volume does not result in a standard
1245 * salvager call. Instead, it simply results in a SALVSYNC call to the
1246 * online salvager daemon. This interface does not give us the same rich
1247 * set of call flags. Thus, we skip these steps for DAFS single-volume
1249 if (!dafs || (*aparm2 == 0)) {
1250 /* add the parallel option if given */
1251 if (parallel != NULL) {
1252 if ((strlen(tbuffer) + 11 + strlen(parallel) + 1) > BOZO_BSSIZE) {
1253 printf("bos: command line too big\n");
1256 strcat(tbuffer, " -parallel ");
1257 strcat(tbuffer, parallel);
1260 /* add the tmpdir option if given */
1261 if (atmpDir != NULL) {
1262 if ((strlen(tbuffer) + 9 + strlen(atmpDir) + 1) > BOZO_BSSIZE) {
1263 printf("bos: command line too big\n");
1266 strcat(tbuffer, " -tmpdir ");
1267 strcat(tbuffer, atmpDir);
1270 /* add the orphans option if given */
1271 if (orphans != NULL) {
1272 if ((strlen(tbuffer) + 10 + strlen(orphans) + 1) > BOZO_BSSIZE) {
1273 printf("bos: command line too big\n");
1276 strcat(tbuffer, " -orphans ");
1277 strcat(tbuffer, orphans);
1280 if (mrafsParm->Optdebug)
1281 strcat(tbuffer, " -debug");
1282 if (mrafsParm->Optnowrite)
1283 strcat(tbuffer, " -nowrite");
1284 if (mrafsParm->Optforce)
1285 strcat(tbuffer, " -force");
1286 if (mrafsParm->Optoktozap)
1287 strcat(tbuffer, " -oktozap");
1288 if (mrafsParm->Optrootfiles)
1289 strcat(tbuffer, " -rootfiles");
1290 if (mrafsParm->Optsalvagedirs)
1291 strcat(tbuffer, " -salvagedirs");
1292 if (mrafsParm->Optblockreads)
1293 strcat(tbuffer, " -blockreads");
1294 if (mrafsParm->OptListResidencies)
1295 strcat(tbuffer, " -ListResidencies");
1296 if (mrafsParm->OptSalvageRemote)
1297 strcat(tbuffer, " -SalvageRemote");
1298 if (mrafsParm->OptSalvageArchival)
1299 strcat(tbuffer, " -SalvageArchival");
1300 if (mrafsParm->OptIgnoreCheck)
1301 strcat(tbuffer, " -IgnoreCheck");
1302 if (mrafsParm->OptForceOnLine)
1303 strcat(tbuffer, " -ForceOnLine");
1304 if (mrafsParm->OptUseRootDirACL)
1305 strcat(tbuffer, " -UseRootDirACL");
1306 if (mrafsParm->OptTraceBadLinkCounts)
1307 strcat(tbuffer, " -TraceBadLinkCounts");
1308 if (mrafsParm->OptDontAskFS)
1309 strcat(tbuffer, " -DontAskFS");
1310 if (mrafsParm->OptLogLevel) {
1311 sprintf(pbuffer, " -LogLevel %ld", afs_printable_int32_ld(mrafsParm->OptLogLevel));
1312 strcat(tbuffer, pbuffer);
1314 if (mrafsParm->OptRxDebug)
1315 strcat(tbuffer, " -rxdebug");
1316 if (mrafsParm->OptResidencies) {
1317 sprintf(pbuffer, " -Residencies %lu",
1318 afs_printable_uint32_lu(mrafsParm->OptResidencies));
1319 strcat(tbuffer, pbuffer);
1324 parms[1] = "now"; /* when to do it */
1326 BOZO_CreateBnode(aconn, "cron", "salvage-tmp", parms[0], parms[1],
1327 parms[2], parms[3], parms[4], notifier);
1329 printf("bos: failed to start 'salvager' (%s)\n", em(code));
1332 /* now wait for bnode to disappear */
1336 code = BOZO_GetInstanceInfo(aconn, "salvage-tmp", &tp, &istatus);
1339 printf("bos: waiting for salvage to complete.\n");
1341 if (code != BZNOENT) {
1342 printf("bos: salvage failed (%s)\n", em(code));
1347 /* now print the log file to the output file */
1348 printf("bos: salvage completed\n");
1349 if (aoutName || showlog) {
1350 fprintf(outFile, "SalvageLog:\n");
1351 tcall = rx_NewCall(aconn);
1352 /* MUST pass canonical (wire-format) salvager log path to bosserver */
1354 StartBOZO_GetLog(tcall, AFSDIR_CANONICAL_SERVER_SLVGLOG_FILEPATH);
1356 rx_EndCall(tcall, code);
1361 code = rx_Read(tcall, &buffer, 1);
1364 putc(buffer, outFile);
1366 break; /* the end delimeter */
1368 code = rx_EndCall(tcall, 0);
1369 /* fall through into cleanup code */
1373 if (closeIt && outFile)
1379 GetLogCmd(register struct cmd_syndesc *as, void *arock)
1381 struct rx_connection *tconn;
1382 register struct rx_call *tcall;
1383 register afs_int32 code;
1387 printf("Fetching log file '%s'...\n", as->parms[1].items->data);
1388 tconn = GetConn(as, 0);
1389 tcall = rx_NewCall(tconn);
1390 code = StartBOZO_GetLog(tcall, as->parms[1].items->data);
1392 rx_EndCall(tcall, code);
1398 code = rx_Read(tcall, &buffer, 1);
1404 break; /* the end delimeter */
1407 code = rx_EndCall(tcall, error);
1408 /* fall through into cleanup code */
1412 afs_com_err("bos", code, "(while reading log)");
1417 SalvageCmd(struct cmd_syndesc *as, void *arock)
1419 register struct rx_connection *tconn;
1420 register afs_int32 code, rc, i;
1422 char tname[BOZO_BSSIZE];
1424 extern struct ubik_client *cstruct;
1425 afs_int32 curGoal, showlog = 0, dafs = 0, mrafs = 0;
1431 struct MRAFSSalvageParms mrafsParm;
1433 memset(&mrafsParm, 0, sizeof(mrafsParm));
1435 /* parm 0 is machine name, 1 is partition, 2 is volume, 3 is -all flag */
1436 tconn = GetConn(as, 0);
1440 /* find out whether fileserver is running demand attach fs */
1441 if ((code = BOZO_GetInstanceParm(tconn, "dafs", 0, &tp) == 0)) {
1443 serviceName = "dafs";
1444 /* Find out whether fileserver is running MR-AFS (has a scanner instance) */
1445 /* XXX this should really be done some other way, potentially by RPC */
1446 if ((code = BOZO_GetInstanceParm(tconn, serviceName, 4, &tp) == 0))
1450 /* Find out whether fileserver is running MR-AFS (has a scanner instance) */
1451 /* XXX this should really be done some other way, potentially by RPC */
1452 if ((code = BOZO_GetInstanceParm(tconn, serviceName, 3, &tp) == 0))
1456 /* we can do a volume, a partition or the whole thing, but not mixtures
1458 if (!as->parms[1].items && as->parms[2].items) {
1459 printf("bos: must specify partition to salvage individual volume.\n");
1462 if (as->parms[5].items && as->parms[3].items) {
1463 printf("bos: can not specify both -file and -showlog.\n");
1466 if (as->parms[4].items && (as->parms[1].items || as->parms[2].items)) {
1467 printf("bos: can not specify -all with other flags.\n");
1471 /* get the output file name, if any */
1472 if (as->parms[3].items)
1473 outName = as->parms[3].items->data;
1477 if (as->parms[5].items)
1480 /* parallel option */
1482 if (as->parms[6].items)
1483 parallel = as->parms[6].items->data;
1485 /* get the tmpdir filename if any */
1487 if (as->parms[7].items)
1488 tmpDir = as->parms[7].items->data;
1490 /* -orphans option */
1492 if (as->parms[8].items) {
1494 printf("Can't specify -orphans for MR-AFS fileserver\n");
1497 orphans = as->parms[8].items->data;
1501 if (!as->parms[9].items) { /* -forceDAFS flag */
1502 printf("This is a demand attach fileserver. Are you sure you want to proceed with a manual salvage?\n");
1503 printf("must specify -forceDAFS flag in order to proceed.\n");
1509 if (as->parms[MRAFS_OFFSET].items)
1510 mrafsParm.Optdebug = 1;
1511 if (as->parms[MRAFS_OFFSET + 1].items)
1512 mrafsParm.Optnowrite = 1;
1513 if (as->parms[MRAFS_OFFSET + 2].items)
1514 mrafsParm.Optforce = 1;
1515 if (as->parms[MRAFS_OFFSET + 3].items)
1516 mrafsParm.Optoktozap = 1;
1517 if (as->parms[MRAFS_OFFSET + 4].items)
1518 mrafsParm.Optrootfiles = 1;
1519 if (as->parms[MRAFS_OFFSET + 5].items)
1520 mrafsParm.Optsalvagedirs = 1;
1521 if (as->parms[MRAFS_OFFSET + 6].items)
1522 mrafsParm.Optblockreads = 1;
1523 if (as->parms[MRAFS_OFFSET + 7].items)
1524 mrafsParm.OptListResidencies = 1;
1525 if (as->parms[MRAFS_OFFSET + 8].items)
1526 mrafsParm.OptSalvageRemote = 1;
1527 if (as->parms[MRAFS_OFFSET + 9].items)
1528 mrafsParm.OptSalvageArchival = 1;
1529 if (as->parms[MRAFS_OFFSET + 10].items)
1530 mrafsParm.OptIgnoreCheck = 1;
1531 if (as->parms[MRAFS_OFFSET + 11].items)
1532 mrafsParm.OptForceOnLine = 1;
1533 if (as->parms[MRAFS_OFFSET + 12].items)
1534 mrafsParm.OptUseRootDirACL = 1;
1535 if (as->parms[MRAFS_OFFSET + 13].items)
1536 mrafsParm.OptTraceBadLinkCounts = 1;
1537 if (as->parms[MRAFS_OFFSET + 14].items)
1538 mrafsParm.OptDontAskFS = 1;
1539 if (as->parms[MRAFS_OFFSET + 15].items)
1540 mrafsParm.OptLogLevel =
1541 atoi(as->parms[MRAFS_OFFSET + 15].items->data);
1542 if (as->parms[MRAFS_OFFSET + 16].items)
1543 mrafsParm.OptRxDebug = 1;
1544 if (as->parms[MRAFS_OFFSET + 17].items) {
1545 if (as->parms[MRAFS_OFFSET + 8].items
1546 || as->parms[MRAFS_OFFSET + 9].items) {
1548 ("Can't specify -Residencies with -SalvageRemote or -SalvageArchival\n");
1552 util_GetUInt32(as->parms[MRAFS_OFFSET + 17].items->data,
1553 &mrafsParm.OptResidencies);
1555 printf("bos: '%s' is not a valid residency mask.\n",
1556 as->parms[MRAFS_OFFSET + 13].items->data);
1563 for (i = MRAFS_OFFSET; i < ADDPARMOFFSET; i++) {
1564 if (as->parms[i].items) {
1565 printf(" %s only possible for MR-AFS fileserver.\n",
1574 if (as->parms[4].items) {
1575 /* salvage whole enchilada */
1576 curGoal = GetServerGoal(tconn, serviceName);
1577 if (curGoal == BSTAT_NORMAL) {
1578 printf("bos: shutting down '%s'.\n", serviceName);
1579 code = BOZO_SetTStatus(tconn, serviceName, BSTAT_SHUTDOWN);
1581 printf("bos: failed to stop '%s' (%s)\n", serviceName, em(code));
1584 code = BOZO_WaitAll(tconn); /* wait for shutdown to complete */
1587 ("bos: failed to wait for file server shutdown, continuing.\n");
1589 /* now do the salvage operation */
1590 printf("Starting salvage.\n");
1591 rc = DoSalvage(tconn, NULL, NULL, outName, showlog, parallel, tmpDir,
1592 orphans, dafs, &mrafsParm);
1593 if (curGoal == BSTAT_NORMAL) {
1594 printf("bos: restarting %s.\n", serviceName);
1595 code = BOZO_SetTStatus(tconn, serviceName, BSTAT_NORMAL);
1597 printf("bos: failed to restart '%s' (%s)\n", serviceName, em(code));
1603 } else if (!as->parms[2].items) {
1604 if (!as->parms[1].items) {
1606 ("bos: must specify -all switch to salvage all partitions.\n");
1609 if (volutil_GetPartitionID(as->parms[1].items->data) < 0) {
1610 /* can't parse volume ID, so complain before shutting down
1613 printf("bos: can't interpret %s as partition ID.\n",
1614 as->parms[1].items->data);
1617 curGoal = GetServerGoal(tconn, serviceName);
1618 /* salvage a whole partition (specified by parms[1]) */
1619 if (curGoal == BSTAT_NORMAL) {
1620 printf("bos: shutting down '%s'.\n", serviceName);
1621 code = BOZO_SetTStatus(tconn, serviceName, BSTAT_SHUTDOWN);
1623 printf("bos: can't stop '%s' (%s)\n", serviceName, em(code));
1626 code = BOZO_WaitAll(tconn); /* wait for shutdown to complete */
1629 ("bos: failed to wait for file server shutdown, continuing.\n");
1631 /* now do the salvage operation */
1632 printf("Starting salvage.\n");
1633 rc = DoSalvage(tconn, as->parms[1].items->data, NULL, outName,
1634 showlog, parallel, tmpDir, orphans, dafs, &mrafsParm);
1635 if (curGoal == BSTAT_NORMAL) {
1636 printf("bos: restarting '%s'.\n", serviceName);
1637 code = BOZO_SetTStatus(tconn, serviceName, BSTAT_NORMAL);
1639 printf("bos: failed to restart '%s' (%s)\n", serviceName, em(code));
1646 /* salvage individual volume (don't shutdown fs first), just use
1647 * single-shot cron bnode. Must leave server running when using this
1648 * option, since salvager will ask file server for the volume */
1651 const char *confdir;
1654 if (as->parms[ADDPARMOFFSET].items)
1655 tmpname = as->parms[ADDPARMOFFSET].items->data;
1659 localauth = (as->parms[ADDPARMOFFSET + 2].items != 0);
1661 (localauth ? AFSDIR_SERVER_ETC_DIRPATH :
1662 AFSDIR_CLIENT_ETC_DIRPATH);
1663 code = vsu_ClientInit( /* noauth */ 1, confdir, tmpname,
1664 /* server auth */ 0, &cstruct, (int (*)())0);
1666 newID = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err);
1668 printf("bos: can't interpret %s as volume name or ID\n",
1669 as->parms[2].items->data);
1672 sprintf(tname, "%u", newID);
1675 ("bos: can't initialize volume system client (code %d), trying anyway.\n",
1677 strncpy(tname, as->parms[2].items->data, sizeof(tname));
1679 if (volutil_GetPartitionID(as->parms[1].items->data) < 0) {
1680 /* can't parse volume ID, so complain before shutting down
1683 printf("bos: can't interpret %s as partition ID.\n",
1684 as->parms[1].items->data);
1687 printf("Starting salvage.\n");
1688 rc = DoSalvage(tconn, as->parms[1].items->data, tname, outName,
1689 showlog, parallel, tmpDir, orphans, dafs, &mrafsParm);
1697 IStatServer(register struct cmd_syndesc *as, int int32p)
1699 register struct rx_connection *tconn;
1700 register struct cmd_item *ti;
1703 tconn = GetConn(as, 0);
1704 for (ti = as->parms[1].items; ti; ti = ti->next) {
1705 DoStat(ti->data, tconn, int32p, firstTime);
1712 DoStat(IN char *aname,
1713 IN register struct rx_connection *aconn,
1715 IN int firstTime) /* true iff first instance in cmd */
1719 register afs_int32 code;
1720 register afs_int32 i;
1721 struct bozo_status istatus;
1723 char *is1, *is2, *is3, *is4; /* instance strings */
1726 code = BOZO_GetInstanceInfo(aconn, aname, &tp, &istatus);
1728 printf("bos: failed to get instance info for '%s' (%s)\n", aname,
1732 if (firstTime && aint32p && (istatus.flags & BOZO_BADDIRACCESS))
1734 ("Bosserver reports inappropriate access on server directories\n");
1735 printf("Instance %s, ", aname);
1737 printf("(type is %s) ", buffer);
1738 if (istatus.fileGoal == istatus.goal) {
1740 printf("disabled, ");
1742 if (istatus.fileGoal)
1743 printf("temporarily disabled, ");
1745 printf("temporarily enabled, ");
1748 if (istatus.flags & BOZO_ERRORSTOP)
1749 printf("stopped for too many errors, ");
1750 if (istatus.flags & BOZO_HASCORE)
1751 printf("has core file, ");
1754 code = BOZO_GetStatus(aconn, aname, &temp, &tp);
1756 printf("bos: failed to get status for instance '%s' (%s)\n", aname,
1759 printf("currently ");
1760 if (temp == BSTAT_NORMAL)
1761 printf("running normally.\n");
1762 else if (temp == BSTAT_SHUTDOWN)
1763 printf("shutdown.\n");
1764 else if (temp == BSTAT_STARTINGUP)
1765 printf("starting up.\n");
1766 else if (temp == BSTAT_SHUTTINGDOWN)
1767 printf("shutting down.\n");
1768 if (buffer[0] != 0) {
1769 printf(" Auxiliary status is: %s.\n", buffer);
1773 /* are we done yet? */
1777 if (istatus.procStartTime)
1778 printf(" Process last started at %s (%d proc starts)\n",
1779 DateOf(istatus.procStartTime), istatus.procStarts);
1780 if (istatus.lastAnyExit) {
1781 printf(" Last exit at %s\n", DateOf(istatus.lastAnyExit));
1783 if (istatus.lastErrorExit) {
1784 is1 = is2 = is3 = is4 = NULL;
1785 printf(" Last error exit at %s, ", DateOf(istatus.lastErrorExit));
1786 code = BOZO_GetInstanceStrings(aconn, aname, &is1, &is2, &is3, &is4);
1787 /* don't complain about failing call, since could simply mean
1788 * interface mismatch.
1792 /* non-null instance string */
1793 printf("by %s, ", is1);
1800 if (istatus.errorSignal) {
1801 if (istatus.errorSignal == SIGTERM)
1802 printf("due to shutdown request\n");
1804 printf("due to signal %d\n", istatus.errorSignal);
1806 printf("by exiting with code %d\n", istatus.errorCode);
1810 /* try to display all the parms */
1813 code = BOZO_GetInstanceParm(aconn, aname, i, &tp);
1816 printf(" Command %d is '%s'\n", i + 1, buffer);
1819 code = BOZO_GetInstanceParm(aconn, aname, 999, &tp);
1821 /* Any type of failure is treated as not having a notifier program */
1822 printf(" Notifier is '%s'\n", buffer);
1830 GetRestrict(struct cmd_syndesc *as, void *arock)
1832 register struct rx_connection *tconn;
1833 afs_int32 code, val;
1835 tconn = GetConn(as, 0);
1836 code = BOZO_GetRestrictedMode(tconn, &val);
1838 printf("bos: failed to get restricted mode (%s)\n", em(code));
1840 printf("Restricted mode is %s\n", val ? "on" : "off");
1846 SetRestrict(struct cmd_syndesc *as, void *arock)
1848 register struct rx_connection *tconn;
1849 afs_int32 code, val;
1851 tconn = GetConn(as, 0);
1852 util_GetInt32(as->parms[1].items->data, &val);
1853 code = BOZO_SetRestrictedMode(tconn, val);
1855 printf("bos: failed to set restricted mode (%s)\n", em(code));
1860 add_std_args(register struct cmd_syndesc *ts)
1862 cmd_Seek(ts, ADDPARMOFFSET);
1863 /* + 0 */ cmd_AddParm(ts, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell name");
1864 /* + 1 */ cmd_AddParm(ts, "-noauth", CMD_FLAG, CMD_OPTIONAL,
1865 "don't authenticate");
1866 /* + 2 */ cmd_AddParm(ts, "-localauth", CMD_FLAG, CMD_OPTIONAL,
1867 "create tickets from KeyFile");
1870 #include "AFS_component_version_number.c"
1873 main(int argc, char **argv)
1875 register afs_int32 code;
1876 register struct cmd_syndesc *ts;
1877 extern int afsconf_SawCell;
1879 #ifdef AFS_AIX32_ENV
1881 * The following signal action for AIX is necessary so that in case of a
1882 * crash (i.e. core is generated) we can include the user's data section
1883 * in the core dump. Unfortunately, by default, only a partial core is
1884 * generated which, in many cases, isn't too useful.
1886 struct sigaction nsa;
1888 sigemptyset(&nsa.sa_mask);
1889 nsa.sa_handler = SIG_DFL;
1890 nsa.sa_flags = SA_FULLDUMP;
1891 sigaction(SIGSEGV, &nsa, NULL);
1892 sigaction(SIGABRT, &nsa, NULL);
1898 printf("bos: could not initialize rx (%s)\n", em(code));
1902 /* To resolve a AFSCELL environment "Note: ..." problem: Because bos calls ka_Init (why?) before any
1903 * checkup on the existance of a "-cell" option on the particular bos command we don't print the
1904 * message if a cell is passed in. Luckily the rest of the programs don't call these adhoc routines
1905 * and things work fine. Note that if the "-cell" isn't passed then we're still ok since later on
1906 * the proper routine (afsconf_GetCellInfo) is going to be called to do the right thing.
1908 afsconf_SawCell = 1; /* Means don't print warning if AFSCELL is set */
1910 afsconf_SawCell = 0; /* Reset it */
1911 /* don't check error code, since fails sometimes when we're setting up a
1913 initialize_CMD_error_table();
1914 initialize_BZ_error_table();
1916 ts = cmd_CreateSyntax("start", StartServer, NULL, "start running a server");
1917 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1918 cmd_AddParm(ts, "-instance", CMD_LIST, 0, "server process name");
1921 ts = cmd_CreateSyntax("stop", StopServer, NULL, "halt a server instance");
1922 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1923 cmd_AddParm(ts, "-instance", CMD_LIST, 0, "server process name");
1925 cmd_AddParm(ts, "-wait", CMD_FLAG, CMD_OPTIONAL,
1926 "wait for process to stop");
1929 ts = cmd_CreateSyntax("status", StatServer, NULL,
1930 "show server instance status");
1931 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1932 cmd_AddParm(ts, "-instance", CMD_LIST, CMD_OPTIONAL,
1933 "server process name");
1934 cmd_AddParm(ts, "-long", CMD_FLAG, CMD_OPTIONAL, "long status");
1937 ts = cmd_CreateSyntax("shutdown", Shutdown, NULL, "shutdown all processes");
1938 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1939 cmd_AddParm(ts, "-instance", CMD_LIST, CMD_OPTIONAL, "instances");
1941 cmd_AddParm(ts, "-wait", CMD_FLAG, CMD_OPTIONAL,
1942 "wait for process to stop");
1945 ts = cmd_CreateSyntax("startup", Startup, NULL, "start all processes");
1946 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1947 cmd_AddParm(ts, "-instance", CMD_LIST, CMD_OPTIONAL, "instances");
1950 ts = cmd_CreateSyntax("restart", Restart, NULL, "restart processes");
1951 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1952 cmd_AddParm(ts, "-instance", CMD_LIST, CMD_OPTIONAL, "instances");
1953 cmd_AddParm(ts, "-bosserver", CMD_FLAG, CMD_OPTIONAL,
1954 "restart bosserver");
1955 cmd_AddParm(ts, "-all", CMD_FLAG, CMD_OPTIONAL, "restart all processes");
1960 ts = cmd_CreateSyntax("create", CreateServer, NULL,
1961 "create a new server instance");
1962 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1963 cmd_AddParm(ts, "-instance", CMD_SINGLE, 0, "server process name");
1964 cmd_AddParm(ts, "-type", CMD_SINGLE, 0, "server type");
1965 cmd_AddParm(ts, "-cmd", CMD_LIST, 0, "command lines");
1966 cmd_AddParm(ts, "-notifier", CMD_SINGLE, CMD_OPTIONAL,
1967 "Notifier program");
1970 ts = cmd_CreateSyntax("delete", DeleteServer, NULL,
1971 "delete a server instance");
1972 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1973 cmd_AddParm(ts, "-instance", CMD_LIST, 0, "server process name");
1976 ts = cmd_CreateSyntax("adduser", AddSUser, NULL,
1977 "add users to super-user list");
1978 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1979 cmd_AddParm(ts, "-user", CMD_LIST, 0, "user names");
1982 ts = cmd_CreateSyntax("removeuser", RemoveSUser, NULL,
1983 "remove users from super-user list");
1984 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1985 cmd_AddParm(ts, "-user", CMD_LIST, 0, "user names");
1988 ts = cmd_CreateSyntax("listusers", ListSUsers, NULL, "list super-users");
1989 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1992 ts = cmd_CreateSyntax("addkey", AddKey, NULL,
1993 "add keys to key dbase (kvno 999 is bcrypt)");
1994 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1995 cmd_AddParm(ts, "-key", CMD_SINGLE, CMD_OPTIONAL, "key");
1996 cmd_AddParm(ts, "-kvno", CMD_SINGLE, 0, "key version number");
1999 ts = cmd_CreateSyntax("removekey", RemoveKey, NULL,
2000 "remove keys from key dbase");
2001 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2002 cmd_AddParm(ts, "-kvno", CMD_LIST, 0, "key version number");
2005 ts = cmd_CreateSyntax("listkeys", ListKeys, NULL, "list keys");
2006 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2007 cmd_AddParm(ts, "-showkey", CMD_FLAG, CMD_OPTIONAL,
2008 "show the actual key rather than the checksum");
2011 ts = cmd_CreateSyntax("listhosts", ListHosts, NULL, "get cell host list");
2012 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2014 cmd_CreateAlias(ts, "getcell");
2016 ts = cmd_CreateSyntax("setcellname", SetCellName, NULL, "set cell name");
2017 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2018 cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "cell name");
2021 ts = cmd_CreateSyntax("addhost", AddHost, NULL, "add host to cell dbase");
2022 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2023 cmd_AddParm(ts, "-host", CMD_LIST, 0, "host name");
2024 cmd_AddParm(ts, "-clone", CMD_FLAG, CMD_OPTIONAL, "vote doesn't count");
2027 ts = cmd_CreateSyntax("removehost", RemoveHost, NULL,
2028 "remove host from cell dbase");
2029 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2030 cmd_AddParm(ts, "-host", CMD_LIST, 0, "host name");
2033 ts = cmd_CreateSyntax("setauth", SetAuth, NULL,
2034 "set authentication required flag");
2035 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2036 cmd_AddParm(ts, "-authrequired", CMD_SINGLE, 0,
2037 "on or off: authentication required for admin requests");
2040 ts = cmd_CreateSyntax("install", Install, NULL, "install program");
2041 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2042 cmd_AddParm(ts, "-file", CMD_LIST, 0, "files to install");
2043 cmd_AddParm(ts, "-dir", CMD_SINGLE, CMD_OPTIONAL, "destination dir");
2046 ts = cmd_CreateSyntax("uninstall", UnInstall, NULL, "uninstall program");
2047 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2048 cmd_AddParm(ts, "-file", CMD_LIST, 0, "files to uninstall");
2049 cmd_AddParm(ts, "-dir", CMD_SINGLE, CMD_OPTIONAL, "destination dir");
2052 ts = cmd_CreateSyntax("getlog", GetLogCmd, NULL, "examine log file");
2053 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2054 cmd_AddParm(ts, "-file", CMD_SINGLE, 0, "log file to examine");
2057 ts = cmd_CreateSyntax("getdate", GetDate, NULL, "get dates for programs");
2058 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2059 cmd_AddParm(ts, "-file", CMD_LIST, 0, "files to check");
2060 cmd_AddParm(ts, "-dir", CMD_SINGLE, CMD_OPTIONAL, "destination dir");
2063 ts = cmd_CreateSyntax("exec", Exec, NULL, "execute shell command on server");
2064 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2065 cmd_AddParm(ts, "-cmd", CMD_SINGLE, 0, "command to execute");
2068 ts = cmd_CreateSyntax("prune", Prune, NULL, "prune server files");
2069 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2070 cmd_AddParm(ts, "-bak", CMD_FLAG, CMD_OPTIONAL, "delete .BAK files");
2071 cmd_AddParm(ts, "-old", CMD_FLAG, CMD_OPTIONAL, "delete .OLD files");
2072 cmd_AddParm(ts, "-core", CMD_FLAG, CMD_OPTIONAL, "delete core files");
2073 cmd_AddParm(ts, "-all", CMD_FLAG, CMD_OPTIONAL, "delete all junk files");
2076 ts = cmd_CreateSyntax("setrestart", SetRestartCmd, NULL,
2077 "set restart times");
2078 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_REQUIRED, "machine name");
2079 cmd_AddParm(ts, "-time", CMD_SINGLE, CMD_REQUIRED,
2080 "time to restart server");
2081 cmd_AddParm(ts, "-general", CMD_FLAG, CMD_OPTIONAL,
2082 "set general restart time");
2083 cmd_AddParm(ts, "-newbinary", CMD_FLAG, CMD_OPTIONAL,
2084 "set new binary restart time");
2086 cmd_CreateAlias(ts, "setr");
2088 ts = cmd_CreateSyntax("getrestart", GetRestartCmd, NULL,
2089 "get restart times");
2090 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_REQUIRED, "machine name");
2092 cmd_CreateAlias(ts, "getr");
2094 ts = cmd_CreateSyntax("salvage", SalvageCmd, NULL,
2095 "salvage partition or volumes");
2096 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2097 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL,
2098 "salvage partition");
2099 cmd_AddParm(ts, "-volume", CMD_SINGLE, CMD_OPTIONAL,
2100 "salvage volume number or volume name");
2101 cmd_AddParm(ts, "-file", CMD_SINGLE, CMD_OPTIONAL,
2102 "salvage log output file");
2103 cmd_AddParm(ts, "-all", CMD_FLAG, CMD_OPTIONAL, "salvage whole server");
2104 cmd_AddParm(ts, "-showlog", CMD_FLAG, CMD_OPTIONAL,
2105 "display salvage log");
2106 cmd_AddParm(ts, "-parallel", CMD_SINGLE, CMD_OPTIONAL,
2107 "# of max parallel partition salvaging");
2108 cmd_AddParm(ts, "-tmpdir", CMD_SINGLE, CMD_OPTIONAL,
2109 "directory to place tmp files");
2110 cmd_AddParm(ts, "-orphans", CMD_SINGLE, CMD_OPTIONAL,
2111 "ignore | remove | attach");
2112 cmd_AddParm(ts, "-forceDAFS", CMD_FLAG, CMD_OPTIONAL,
2113 "(DAFS) force salvage of demand attach fileserver");
2114 cmd_AddParm(ts, "-debug", CMD_FLAG, CMD_OPTIONAL,
2115 "(MR-AFS) Run in Debugging mode");
2116 cmd_AddParm(ts, "-nowrite", CMD_FLAG, CMD_OPTIONAL,
2117 "(MR-AFS) Run readonly/test mode");
2118 cmd_AddParm(ts, "-force", CMD_FLAG, CMD_OPTIONAL,
2119 "(MR-AFS) Force full salvaging");
2120 cmd_AddParm(ts, "-oktozap", CMD_FLAG, CMD_OPTIONAL,
2121 "(MR-AFS) Give permission to destroy bogus file residencies/volumes - debugging flag");
2122 cmd_AddParm(ts, "-rootfiles", CMD_FLAG, CMD_OPTIONAL,
2123 "(MR-AFS) Show files owned by root - debugging flag");
2124 cmd_AddParm(ts, "-salvagedirs", CMD_FLAG, CMD_OPTIONAL,
2125 "(MR-AFS) Force rebuild/salvage of all directories");
2126 cmd_AddParm(ts, "-blockreads", CMD_FLAG, CMD_OPTIONAL,
2127 "(MR-AFS) Read smaller blocks to handle IO/bad blocks");
2128 cmd_AddParm(ts, "-ListResidencies", CMD_FLAG, CMD_OPTIONAL,
2129 "(MR-AFS) Just list affected file residencies - debugging flag");
2130 cmd_AddParm(ts, "-SalvageRemote", CMD_FLAG, CMD_OPTIONAL,
2131 "(MR-AFS) Salvage storage systems that are not directly attached");
2132 cmd_AddParm(ts, "-SalvageArchival", CMD_FLAG, CMD_OPTIONAL,
2133 "(MR-AFS) Salvage HSM storage systems");
2134 cmd_AddParm(ts, "-IgnoreCheck", CMD_FLAG, CMD_OPTIONAL,
2135 "(MR-AFS) Don't perform VLDB safety check when deleting unreferenced files. Only a good idea in single server cell.");
2136 cmd_AddParm(ts, "-ForceOnLine", CMD_FLAG, CMD_OPTIONAL,
2137 "(MR-AFS) Force the volume to come online, even if it hasn't salvaged cleanly.");
2138 cmd_AddParm(ts, "-UseRootDirACL", CMD_FLAG, CMD_OPTIONAL,
2139 "(MR-AFS) Use the root directory ACL for lost+found directory if it is created.");
2140 cmd_AddParm(ts, "-TraceBadLinkCounts", CMD_FLAG, CMD_OPTIONAL,
2141 "(MR-AFS) Print out lines about volume reference count changes.");
2142 cmd_AddParm(ts, "-DontAskFS", CMD_FLAG, CMD_OPTIONAL,
2143 "(MR-AFS) Don't ask fileserver to take volume offline. THIS IS VERY DANGEROUS.");
2144 cmd_AddParm(ts, "-LogLevel", CMD_SINGLE, CMD_OPTIONAL,
2145 "(MR-AFS) log level");
2146 cmd_AddParm(ts, "-rxdebug", CMD_FLAG, CMD_OPTIONAL,
2147 "(MR-AFS) Write out rx debug information.");
2148 cmd_AddParm(ts, "-Residencies", CMD_SINGLE, CMD_OPTIONAL,
2149 "(MR-AFS) Numeric mask of residencies to be included in the salvage. Do not use with -SalvageRemote or -SalvageArchival");
2152 ts = cmd_CreateSyntax("blockscanner", BlockScannerCmd, NULL,
2153 "block scanner daemon from making migration requests");
2154 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_REQUIRED, "machine name");
2157 ts = cmd_CreateSyntax("unblockscanner", UnBlockScannerCmd, NULL,
2158 "allow scanner daemon to make migration requests again");
2159 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_REQUIRED, "machine name");
2162 ts = cmd_CreateSyntax("getrestricted", GetRestrict, NULL,
2163 "get restrict mode");
2164 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2167 ts = cmd_CreateSyntax("setrestricted", SetRestrict, NULL,
2168 "set restrict mode");
2169 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
2170 cmd_AddParm(ts, "-mode", CMD_SINGLE, 0, "mode to set");
2174 code = cmd_Dispatch(argc, argv);