#include <afs/kautils.h>
#include "bnode.h"
+#include "bnode_internal.h"
#include "bosint.h"
#include "bosprototypes.h"
strcpy(fpOld, filepath);
strcat(fpOld, ".OLD");
- code = renamefile(fpBak, filepath);
+ code = rk_rename(fpBak, filepath);
if (code) {
/* can't find .BAK, try .OLD */
- code = renamefile(fpOld, filepath);
+ code = rk_rename(fpOld, filepath);
if (code && errno == ENOENT) /* If doesn't exist don't fail */
code = 0;
} else {
/* now rename .OLD to .BAK */
if (stat(fpOld, &tstat) == 0)
- code = renamefile(fpOld, fpBak);
+ code = rk_rename(fpOld, fpBak);
}
if (code)
code = errno;
if (bakTime && (oldTime == 0 || bakTime < now - BOZO_OLDTIME)) {
/* no .OLD file, or .BAK is at least a week old */
- code = renamefile(bbuffer, obuffer);
+ rk_rename(bbuffer, obuffer);
}
/* finally rename to .BAK extension */
- renamefile(aname, bbuffer);
+ rk_rename(aname, bbuffer);
}
afs_int32
/* all done, rename to final name */
strcpy(tbuffer, filepath);
strcat(tbuffer, ".NEW");
- code = (renamefile(tbuffer, filepath) ? errno : 0);
+ code = (rk_rename(tbuffer, filepath) ? errno : 0);
/* label file with same time for our sanity */
#ifdef AFS_NT40_ENV
code = afsconf_GetLocalCell(bozo_confdir, tname, sizeof(tname));
if (code) {
/* must set output parameters even if aborting */
- *aname = (char *)malloc(1);
+ *aname = malloc(1);
**aname = 0;
} else {
- *aname = (char *)malloc(strlen(tname) + 1);
- strcpy(*aname, tname);
+ *aname = strdup(tname);
}
return code;
}
tp = tcell.hostName[awhich];
- *aname = (char *)malloc(strlen(tp) + 3);
if (clones[awhich]) {
- strcpy(*aname, "[");
- strcat(*aname, tp);
- strcat(*aname, "]");
+ asprintf(aname, "[%s]", tp);
} else
- strcpy(*aname, tp);
+ *aname = strdup(tp);
goto done;
fail:
- *aname = (char *)malloc(1); /* return fake string */
+ *aname = malloc(1); /* return fake string */
**aname = 0;
done:
if (code == 0) {
akeyinfo->mod_sec = tstat.st_mtime;
}
- ka_KeyCheckSum(tkeys.key[an].key, &akeyinfo->keyCheckSum);
- /* only errors is bad key parity */
+
+ /* This will return an error if the key is 'bad' (bad checksum, weak DES
+ * key, etc). But we don't care, since we can still return the other
+ * information about the key, so ignore the result. */
+ (void)ka_KeyCheckSum(tkeys.key[an].key, &akeyinfo->keyCheckSum);
fail:
if (noauth)
afs_int32 code;
char *tp;
- tp = *aname = (char *)malloc(256);
+ tp = *aname = malloc(256);
*tp = 0; /* in case getnthuser doesn't null-terminate the string */
code = afsconf_GetNthUser(bozo_confdir, an, tp, 256);
goto fail;
}
- /* setup return code */
- code = 0;
-
bnode_Hold(tb);
bnode_SetStat(tb, BSTAT_SHUTDOWN);
code = bnode_WaitStatus(tb, BSTAT_SHUTDOWN); /* this can fail */
goto fail;
}
- *astatDescr = (char *)malloc(BOZO_BSSIZE);
+ *astatDescr = malloc(BOZO_BSSIZE);
code = bnode_GetString(tb, *astatDescr, BOZO_BSSIZE);
bnode_Release(tb);
if (code)
return 0;
fail:
- *astatDescr = (char *)malloc(1);
+ *astatDescr = malloc(1);
**astatDescr = 0;
return code;
}
{
struct eidata tdata;
- *ainstance = (char *)malloc(BOZO_BSSIZE);
+ *ainstance = malloc(BOZO_BSSIZE);
**ainstance = 0;
tdata.counter = anum;
tdata.iname = *ainstance;
struct bnode *tb;
tb = bnode_FindInstance(ainstance);
- *atype = (char *)malloc(BOZO_BSSIZE);
+ *atype = malloc(BOZO_BSSIZE);
**atype = 0;
if (!tb)
return BZNOENT;
char *tp;
afs_int32 code;
- tp = (char *)malloc(BOZO_BSSIZE);
+ tp = malloc(BOZO_BSSIZE);
*aparm = tp;
*tp = 0; /* null-terminate string in error case */
tb = bnode_FindInstance(ainstance);
{
struct bnode *tb;
- *as2 = (char *)malloc(1);
+ *as2 = malloc(1);
**as2 = 0;
- *as3 = (char *)malloc(1);
+ *as3 = malloc(1);
**as3 = 0;
- *as4 = (char *)malloc(1);
+ *as4 = malloc(1);
**as4 = 0;
tb = bnode_FindInstance(abnodeName);
if (!tb)
/* now, return the appropriate error string, if any */
if (tb->lastErrorName) {
- *as1 = (char *)malloc(strlen(tb->lastErrorName) + 1);
- strcpy(*as1, tb->lastErrorName);
+ *as1 = strdup(tb->lastErrorName);
} else {
- *as1 = (char *)malloc(1);
+ *as1 = malloc(1);
**as1 = 0;
}
return 0;
fail:
- *as1 = (char *)malloc(1);
+ *as1 = malloc(1);
**as1 = 0;
return BZNOENT;
}