#include <ubik.h>
#include <afs/ktime.h>
#include <afs/kautils.h>
+#include <afs/afsint.h>
#include <afs/volser.h>
static int IStatServer(struct cmd_syndesc *as, int int32p);
int aint32p, int firstTime);
#include "bosint.h"
+#include "bnode_internal.h"
#include "bosprototypes.h"
/* command offsets for bos salvage command */
#define MRAFS_OFFSET 10
#define ADDPARMOFFSET 27
-/* MR-AFS salvage parameters */
-struct MRAFSSalvageParms {
- afs_int32 Optdebug;
- afs_int32 Optnowrite;
- afs_int32 Optforce;
- afs_int32 Optoktozap;
- afs_int32 Optrootfiles;
- afs_int32 Optsalvagedirs;
- afs_int32 Optblockreads;
- afs_int32 OptListResidencies;
- afs_int32 OptSalvageRemote;
- afs_int32 OptSalvageArchival;
- afs_int32 OptIgnoreCheck;
- afs_int32 OptForceOnLine;
- afs_int32 OptUseRootDirACL;
- afs_int32 OptTraceBadLinkCounts;
- afs_int32 OptDontAskFS;
- afs_int32 OptLogLevel;
- afs_int32 OptRxDebug;
- afs_uint32 OptResidencies;
-};
-
/* dummy routine for the audit work. It should do nothing since audits */
/* occur at the server level and bos is not a server. */
int osi_audit(void )
return (char *)afs_error_message(acode);
}
-/* get partition id from a name */
-/* XXX - unused code - could be removed? */
-#if 0
-static afs_int32
-GetPartitionID(char *aname)
-{
- char tc;
- char ascii[3];
-
- tc = *aname;
- if (tc == 0)
- return -1; /* unknown */
- /* numbers go straight through */
- if (tc >= '0' && tc <= '9') {
- return atoi(aname);
- }
- /* otherwise check for vicepa or /vicepa, or just plain "a" */
- ascii[2] = 0;
- if (strlen(aname) <= 2) {
- strcpy(ascii, aname);
- } else if (!strncmp(aname, "/vicep", 6)) {
- strncpy(ascii, aname + 6, 2);
- } else if (!strncmp(aname, "vicep", 5)) {
- strncpy(ascii, aname + 5, 2);
- } else
- return -1; /* bad partition name */
- /* now partitions are named /vicepa ... /vicepz, /vicepaa, /vicepab,
- * .../vicepzz, and are numbered from 0. Do the appropriate conversion */
- if (ascii[1] == 0) {
- /* one char name, 0..25 */
- if (ascii[0] < 'a' || ascii[0] > 'z')
- return -1; /* wrongo */
- return ascii[0] - 'a';
- } else {
- /* two char name, 26 .. <whatever> */
- if (ascii[0] < 'a' || ascii[0] > 'z')
- return -1; /* wrongo */
- if (ascii[1] < 'a' || ascii[1] > 'z')
- return -1; /* just as bad */
- return (ascii[0] - 'a') * 26 + (ascii[1] - 'a') + 26;
- }
-}
-#endif
-
/* make ctime easier to use */
static char *
-DateOf(afs_int32 atime)
+DateOf(time_t atime)
{
static char tbuffer[30];
char *tp;
- time_t t = (time_t) atime;
- tp = ctime(&t);
+ tp = ctime(&atime);
if (tp) {
- strcpy(tbuffer, tp);
+ strlcpy(tbuffer, tp, sizeof(tbuffer));
tbuffer[24] = 0; /* get rid of new line */
} else
strcpy(tbuffer, "BAD TIME");
}
memcpy(&addr, th->h_addr, sizeof(afs_int32));
- secFlags = AFSCONF_SECOPTS_FALLBACK_NULL;
+ if (aencrypt)
+ secFlags = AFSCONF_SECOPTS_ALWAYSENCRYPT;
+ else
+ secFlags = AFSCONF_SECOPTS_FALLBACK_NULL;
+
if (as->parms[ADDPARMOFFSET + 2].items) { /* -localauth */
secFlags |= AFSCONF_SECOPTS_LOCALAUTH;
}
static int
-BlockScannerCmd(struct cmd_syndesc *as, void *arock)
-{
- afs_int32 code;
- struct rx_connection *tconn;
- char BlockCommand[] = "/usr/afs/bin/scanner -block";
-
- tconn = GetConn(as, 0);
- code = BOZO_Exec(tconn, BlockCommand);
- if (code)
- printf
- ("bos: failed to block scanner from making migration requests (%s)\n",
- em(code));
- return 0;
-}
-
-static int
-UnBlockScannerCmd(struct cmd_syndesc *as, void *arock)
-{
- afs_int32 code;
- struct rx_connection *tconn;
- char UnBlockCommand[] = "/usr/afs/bin/scanner -unblock";
-
- tconn = GetConn(as, 0);
- code = BOZO_Exec(tconn, UnBlockCommand);
- if (code)
- printf
- ("bos: failed to allow scanner daemon to make migration requests again (%s)\n",
- em(code));
- return 0;
-}
-
-static int
GetRestartCmd(struct cmd_syndesc *as, void *arock)
{
afs_int32 code;
afs_int32 code;
struct ktc_encryptionKey tkey;
afs_int32 temp;
- char *tcell;
- char cellBuffer[256];
char buf[BUFSIZ], ver[BUFSIZ];
tconn = GetConn(as, 1);
memset(&tkey, 0, sizeof(struct ktc_encryptionKey));
- if (as->parms[1].items)
- strcpy(buf, as->parms[1].items->data);
- else {
+ if (as->parms[1].items) {
+ if (strlcpy(buf, as->parms[1].items->data, sizeof(buf)) >= sizeof(buf)) {
+ fprintf(stderr, "Key data too long for buffer\n");
+ exit(1);
+ }
+ } else {
/* prompt for key */
code = UI_UTIL_read_pw_string(buf, sizeof(buf), "input key: ", 0);
if (code || strlen(buf) == 0) {
*/
strcpy((char *)&tkey, buf);
} else { /* kerberos key */
+ char *tcell;
if (as->parms[ADDPARMOFFSET].items) {
- strcpy(cellBuffer, as->parms[ADDPARMOFFSET].items->data);
+ tcell = strdup(as->parms[ADDPARMOFFSET].items->data);
+ if (tcell == NULL) {
+ fprintf(stderr, "bos: Unable to allocate memory for cellname\n");
+ exit(1);
+ }
/* string to key needs upper-case cell names */
/* I don't believe this is true. The string to key function
* actually expands the cell name, then LOWER-CASES it. Perhaps it
* didn't use to??? */
- ucstring(cellBuffer, cellBuffer, strlen(cellBuffer));
- tcell = cellBuffer;
+ ucstring(tcell, tcell, strlen(tcell));
} else
tcell = NULL; /* no cell specified, use current */
/*
ka_StringToKey(as->parms[1].items->data, tcell, &tkey);
*/
ka_StringToKey(buf, tcell, &tkey);
+
+ if (tcell)
+ free(tcell);
}
- tconn = GetConn(as, 1);
code = BOZO_AddKey(tconn, temp, ktc_to_bozoptr(&tkey));
if (code) {
printf("bos: failed to set key %d (%s)\n", temp, em(code));
static afs_int32
DoSalvage(struct rx_connection * aconn, char * aparm1, char * aparm2,
char * aoutName, afs_int32 showlog, char * parallel,
- char * atmpDir, char * orphans, int dafs,
- struct MRAFSSalvageParms * mrafsParm)
+ char * atmpDir, char * orphans, int dafs)
{
afs_int32 code;
char *parms[6];
FILE *outFile;
int closeIt;
char partName[20]; /* canonical name for partition */
- char pbuffer[PARMBUFFERSSIZE];
afs_int32 partNumber;
char *notifier = NONOTIFIER;
int count;
strcat(tbuffer, " -orphans ");
strcat(tbuffer, orphans);
}
-
- if (mrafsParm->Optdebug)
- strcat(tbuffer, " -debug");
- if (mrafsParm->Optnowrite)
- strcat(tbuffer, " -nowrite");
- if (mrafsParm->Optforce)
- strcat(tbuffer, " -force");
- if (mrafsParm->Optoktozap)
- strcat(tbuffer, " -oktozap");
- if (mrafsParm->Optrootfiles)
- strcat(tbuffer, " -rootfiles");
- if (mrafsParm->Optsalvagedirs)
- strcat(tbuffer, " -salvagedirs");
- if (mrafsParm->Optblockreads)
- strcat(tbuffer, " -blockreads");
- if (mrafsParm->OptListResidencies)
- strcat(tbuffer, " -ListResidencies");
- if (mrafsParm->OptSalvageRemote)
- strcat(tbuffer, " -SalvageRemote");
- if (mrafsParm->OptSalvageArchival)
- strcat(tbuffer, " -SalvageArchival");
- if (mrafsParm->OptIgnoreCheck)
- strcat(tbuffer, " -IgnoreCheck");
- if (mrafsParm->OptForceOnLine)
- strcat(tbuffer, " -ForceOnLine");
- if (mrafsParm->OptUseRootDirACL)
- strcat(tbuffer, " -UseRootDirACL");
- if (mrafsParm->OptTraceBadLinkCounts)
- strcat(tbuffer, " -TraceBadLinkCounts");
- if (mrafsParm->OptDontAskFS)
- strcat(tbuffer, " -DontAskFS");
- if (mrafsParm->OptLogLevel) {
- sprintf(pbuffer, " -LogLevel %ld", afs_printable_int32_ld(mrafsParm->OptLogLevel));
- strcat(tbuffer, pbuffer);
- }
- if (mrafsParm->OptRxDebug)
- strcat(tbuffer, " -rxdebug");
- if (mrafsParm->OptResidencies) {
- sprintf(pbuffer, " -Residencies %lu",
- afs_printable_uint32_lu(mrafsParm->OptResidencies));
- strcat(tbuffer, pbuffer);
- }
}
parms[0] = tbuffer;
SalvageCmd(struct cmd_syndesc *as, void *arock)
{
struct rx_connection *tconn;
- afs_int32 code, rc, i;
+ afs_int32 code, rc;
char *outName;
char tname[BOZO_BSSIZE];
afs_int32 newID;
extern struct ubik_client *cstruct;
- afs_int32 curGoal, showlog = 0, dafs = 0, mrafs = 0;
+ afs_int32 curGoal, showlog = 0, dafs = 0;
char *parallel;
char *tmpDir;
char *orphans;
- char *tp;
char * serviceName;
- struct MRAFSSalvageParms mrafsParm;
-
- memset(&mrafsParm, 0, sizeof(mrafsParm));
/* parm 0 is machine name, 1 is partition, 2 is volume, 3 is -all flag */
tconn = GetConn(as, 0);
- tp = &tname[0];
-
/* find out whether fileserver is running demand attach fs */
if (IsDAFS(tconn)) {
dafs = 1;
serviceName = "dafs";
- /* Find out whether fileserver is running MR-AFS (has a scanner instance) */
- /* XXX this should really be done some other way, potentially by RPC */
- if ((code = BOZO_GetInstanceParm(tconn, serviceName, 4, &tp) == 0))
- mrafs = 1;
} else {
serviceName = "fs";
- /* Find out whether fileserver is running MR-AFS (has a scanner instance) */
- /* XXX this should really be done some other way, potentially by RPC */
- if ((code = BOZO_GetInstanceParm(tconn, serviceName, 3, &tp) == 0))
- mrafs = 1;
}
/* we can do a volume, a partition or the whole thing, but not mixtures
/* -orphans option */
orphans = NULL;
if (as->parms[8].items) {
- if (mrafs) {
- printf("Can't specify -orphans for MR-AFS fileserver\n");
- return EINVAL;
- }
orphans = as->parms[8].items->data;
}
}
}
- if (mrafs) {
- if (as->parms[MRAFS_OFFSET].items)
- mrafsParm.Optdebug = 1;
- if (as->parms[MRAFS_OFFSET + 1].items)
- mrafsParm.Optnowrite = 1;
- if (as->parms[MRAFS_OFFSET + 2].items)
- mrafsParm.Optforce = 1;
- if (as->parms[MRAFS_OFFSET + 3].items)
- mrafsParm.Optoktozap = 1;
- if (as->parms[MRAFS_OFFSET + 4].items)
- mrafsParm.Optrootfiles = 1;
- if (as->parms[MRAFS_OFFSET + 5].items)
- mrafsParm.Optsalvagedirs = 1;
- if (as->parms[MRAFS_OFFSET + 6].items)
- mrafsParm.Optblockreads = 1;
- if (as->parms[MRAFS_OFFSET + 7].items)
- mrafsParm.OptListResidencies = 1;
- if (as->parms[MRAFS_OFFSET + 8].items)
- mrafsParm.OptSalvageRemote = 1;
- if (as->parms[MRAFS_OFFSET + 9].items)
- mrafsParm.OptSalvageArchival = 1;
- if (as->parms[MRAFS_OFFSET + 10].items)
- mrafsParm.OptIgnoreCheck = 1;
- if (as->parms[MRAFS_OFFSET + 11].items)
- mrafsParm.OptForceOnLine = 1;
- if (as->parms[MRAFS_OFFSET + 12].items)
- mrafsParm.OptUseRootDirACL = 1;
- if (as->parms[MRAFS_OFFSET + 13].items)
- mrafsParm.OptTraceBadLinkCounts = 1;
- if (as->parms[MRAFS_OFFSET + 14].items)
- mrafsParm.OptDontAskFS = 1;
- if (as->parms[MRAFS_OFFSET + 15].items)
- mrafsParm.OptLogLevel =
- atoi(as->parms[MRAFS_OFFSET + 15].items->data);
- if (as->parms[MRAFS_OFFSET + 16].items)
- mrafsParm.OptRxDebug = 1;
- if (as->parms[MRAFS_OFFSET + 17].items) {
- if (as->parms[MRAFS_OFFSET + 8].items
- || as->parms[MRAFS_OFFSET + 9].items) {
- printf
- ("Can't specify -Residencies with -SalvageRemote or -SalvageArchival\n");
- return EINVAL;
- }
- code =
- util_GetUInt32(as->parms[MRAFS_OFFSET + 17].items->data,
- &mrafsParm.OptResidencies);
- if (code) {
- printf("bos: '%s' is not a valid residency mask.\n",
- as->parms[MRAFS_OFFSET + 17].items->data);
- return code;
- }
- }
- } else {
- int stop = 0;
-
- for (i = MRAFS_OFFSET; i < ADDPARMOFFSET; i++) {
- if (as->parms[i].items) {
- printf(" %s only possible for MR-AFS fileserver.\n",
- as->parms[i].name);
- stop = 1;
- }
- }
- if (stop)
- exit(1);
- }
-
if (as->parms[4].items) {
/* salvage whole enchilada */
curGoal = GetServerGoal(tconn, serviceName);
/* now do the salvage operation */
printf("Starting salvage.\n");
rc = DoSalvage(tconn, NULL, NULL, outName, showlog, parallel, tmpDir,
- orphans, dafs, &mrafsParm);
+ orphans, dafs);
if (curGoal == BSTAT_NORMAL) {
printf("bos: restarting %s.\n", serviceName);
code = BOZO_SetTStatus(tconn, serviceName, BSTAT_NORMAL);
/* now do the salvage operation */
printf("Starting salvage.\n");
rc = DoSalvage(tconn, as->parms[1].items->data, NULL, outName,
- showlog, parallel, tmpDir, orphans, dafs, &mrafsParm);
+ showlog, parallel, tmpDir, orphans, dafs);
if (curGoal == BSTAT_NORMAL) {
printf("bos: restarting '%s'.\n", serviceName);
code = BOZO_SetTStatus(tconn, serviceName, BSTAT_NORMAL);
}
printf("Starting salvage.\n");
rc = DoSalvage(tconn, as->parms[1].items->data, tname, outName,
- showlog, parallel, tmpDir, orphans, dafs, &mrafsParm);
+ showlog, parallel, tmpDir, orphans, dafs);
if (rc)
return rc;
}
{
afs_int32 code;
struct cmd_syndesc *ts;
+#ifdef AFS_NT40_ENV
+ __declspec(dllimport)
+#endif
extern int afsconf_SawCell;
#ifdef AFS_AIX32_ENV
"ignore | remove | attach");
cmd_AddParm(ts, "-forceDAFS", CMD_FLAG, CMD_OPTIONAL,
"(DAFS) force salvage of demand attach fileserver");
- cmd_AddParm(ts, "-debug", CMD_FLAG, CMD_OPTIONAL,
- "(MR-AFS) Run in Debugging mode");
- cmd_AddParm(ts, "-nowrite", CMD_FLAG, CMD_OPTIONAL,
- "(MR-AFS) Run readonly/test mode");
- cmd_AddParm(ts, "-force", CMD_FLAG, CMD_OPTIONAL,
- "(MR-AFS) Force full salvaging");
- cmd_AddParm(ts, "-oktozap", CMD_FLAG, CMD_OPTIONAL,
- "(MR-AFS) Give permission to destroy bogus file residencies/volumes - debugging flag");
- cmd_AddParm(ts, "-rootfiles", CMD_FLAG, CMD_OPTIONAL,
- "(MR-AFS) Show files owned by root - debugging flag");
- cmd_AddParm(ts, "-salvagedirs", CMD_FLAG, CMD_OPTIONAL,
- "(MR-AFS) Force rebuild/salvage of all directories");
- cmd_AddParm(ts, "-blockreads", CMD_FLAG, CMD_OPTIONAL,
- "(MR-AFS) Read smaller blocks to handle IO/bad blocks");
- cmd_AddParm(ts, "-ListResidencies", CMD_FLAG, CMD_OPTIONAL,
- "(MR-AFS) Just list affected file residencies - debugging flag");
- cmd_AddParm(ts, "-SalvageRemote", CMD_FLAG, CMD_OPTIONAL,
- "(MR-AFS) Salvage storage systems that are not directly attached");
- cmd_AddParm(ts, "-SalvageArchival", CMD_FLAG, CMD_OPTIONAL,
- "(MR-AFS) Salvage HSM storage systems");
- cmd_AddParm(ts, "-IgnoreCheck", CMD_FLAG, CMD_OPTIONAL,
- "(MR-AFS) Don't perform VLDB safety check when deleting unreferenced files. Only a good idea in single server cell.");
- cmd_AddParm(ts, "-ForceOnLine", CMD_FLAG, CMD_OPTIONAL,
- "(MR-AFS) Force the volume to come online, even if it hasn't salvaged cleanly.");
- cmd_AddParm(ts, "-UseRootDirACL", CMD_FLAG, CMD_OPTIONAL,
- "(MR-AFS) Use the root directory ACL for lost+found directory if it is created.");
- cmd_AddParm(ts, "-TraceBadLinkCounts", CMD_FLAG, CMD_OPTIONAL,
- "(MR-AFS) Print out lines about volume reference count changes.");
- cmd_AddParm(ts, "-DontAskFS", CMD_FLAG, CMD_OPTIONAL,
- "(MR-AFS) Don't ask fileserver to take volume offline. THIS IS VERY DANGEROUS.");
- cmd_AddParm(ts, "-LogLevel", CMD_SINGLE, CMD_OPTIONAL,
- "(MR-AFS) log level");
- cmd_AddParm(ts, "-rxdebug", CMD_FLAG, CMD_OPTIONAL,
- "(MR-AFS) Write out rx debug information.");
- cmd_AddParm(ts, "-Residencies", CMD_SINGLE, CMD_OPTIONAL,
- "(MR-AFS) Numeric mask of residencies to be included in the salvage. Do not use with -SalvageRemote or -SalvageArchival");
- add_std_args(ts);
-
- ts = cmd_CreateSyntax("blockscanner", BlockScannerCmd, NULL,
- "block scanner daemon from making migration requests");
- cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_REQUIRED, "machine name");
- add_std_args(ts);
-
- ts = cmd_CreateSyntax("unblockscanner", UnBlockScannerCmd, NULL,
- "allow scanner daemon to make migration requests again");
- cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_REQUIRED, "machine name");
add_std_args(ts);
ts = cmd_CreateSyntax("getrestricted", GetRestrict, NULL,