#include <afs/afsutil.h>
#include <afs/cellconfig.h>
#include <rx/rx.h>
-#include <sys/stat.h>
#include <rx/xdr.h>
#include <afs/auth.h>
#include <afs/cellconfig.h>
#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 */
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;
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));
char pbuffer[PARMBUFFERSSIZE];
afs_int32 partNumber;
char *notifier = NONOTIFIER;
+ int count;
/* if a partition was specified, canonicalize the name, since
* the salvager has a stupid partition ID parser */
goto done;
}
/* now wait for bnode to disappear */
+ count = 0;
while (1) {
- IOMGR_Sleep(5);
+ IOMGR_Sleep(1);
tp = tbuffer;
code = BOZO_GetInstanceInfo(aconn, "salvage-tmp", &tp, &istatus);
if (code)
break;
- printf("bos: waiting for salvage to complete.\n");
+ if ((++count % 5) == 0)
+ printf("bos: waiting for salvage to complete.\n");
}
if (code != BZNOENT) {
printf("bos: salvage failed (%s)\n", em(code));
{
afs_int32 code;
struct cmd_syndesc *ts;
+#ifdef AFS_NT40_ENV
+ __declspec(dllimport)
+#endif
extern int afsconf_SawCell;
#ifdef AFS_AIX32_ENV