#endif /* HAVE_CONFIG_H */
#include "xlog.h"
-#include "cfg.h"
+#include "conffile.h"
#include "queue.h"
#include "nfslib.h"
TAILQ_ENTRY(idmap_client) ic_next;
};
static struct idmap_client nfsd_ic[2] = {
-{IC_IDNAME, "Server", "", IC_IDNAME_CHAN, -1, -1, 0},
-{IC_NAMEID, "Server", "", IC_NAMEID_CHAN, -1, -1, 0},
+{
+ .ic_which = IC_IDNAME,
+ .ic_clid = "",
+ .ic_id = "Server",
+ .ic_path = IC_IDNAME_CHAN,
+ .ic_fd = -1,
+ .ic_dirfd = -1,
+ .ic_scanned = 0
+},
+{
+ .ic_which = IC_NAMEID,
+ .ic_clid = "",
+ .ic_id = "Server",
+ .ic_path = IC_NAMEID_CHAN,
+ .ic_fd = -1,
+ .ic_dirfd = -1,
+ .ic_scanned = 0
+},
};
TAILQ_HEAD(idmap_clientq, idmap_client);
static int nfsdopen(void);
static int nfsdopenone(struct idmap_client *);
+static void nfsdreopen_one(struct idmap_client *);
static void nfsdreopen(void);
-size_t strlcat(char *, const char *, size_t);
-size_t strlcpy(char *, const char *, size_t);
-ssize_t atomicio(ssize_t (*f) (int, void*, size_t),
- int, void *, size_t);
void mydaemon(int, int);
void release_parent(void);
static uid_t nobodyuid;
static gid_t nobodygid;
-/* Used by cfg.c */
+/* Used by conffile.c in libnfs.a */
char *conf_path;
static int
fd = open(path, O_RDWR);
if (fd == -1)
return -1;
- if (write(fd, stime, strlen(stime)) != strlen(stime)) {
+ if (write(fd, stime, strlen(stime)) != (ssize_t)strlen(stime)) {
errx(1, "Flushing nfsd cache failed: errno %d (%s)",
errno, strerror(errno));
}
}
static void
-dirscancb(int fd, short which, void *data)
+dirscancb(int UNUSED(fd), short UNUSED(which), void *data)
{
int nent, i;
struct dirent **ents;
}
static void
-svrreopen(int fd, short which, void *data)
+svrreopen(int UNUSED(fd), short UNUSED(which), void *UNUSED(data))
{
nfsdreopen();
}
static void
-clntscancb(int fd, short which, void *data)
+clntscancb(int UNUSED(fd), short UNUSED(which), void *data)
{
struct idmap_clientq *icq = data;
struct idmap_client *ic;
}
static void
-nfsdcb(int fd, short which, void *data)
+nfsdcb(int UNUSED(fd), short which, void *data)
{
struct idmap_client *ic = data;
struct idmap_msg im;
xlog_warn("nfsdcb: read(%s) failed: errno %d (%s)",
ic->ic_path, len?errno:0,
len?strerror(errno):"End of File");
- goto out;
+ nfsdreopen_one(ic);
+ return;
}
/* Get rid of newline and terminate buffer*/
/* Authentication name -- ignored for now*/
if (getfield(&bp, authbuf, sizeof(authbuf)) == -1) {
xlog_warn("nfsdcb: bad authentication name in upcall\n");
- return;
+ goto out;
}
if (getfield(&bp, typebuf, sizeof(typebuf)) == -1) {
xlog_warn("nfsdcb: bad type in upcall\n");
- return;
+ goto out;
}
if (verbose > 0)
xlog_warn("nfsdcb: authbuf=%s authtype=%s",
im.im_conv = IDMAP_CONV_NAMETOID;
if (getfield(&bp, im.im_name, sizeof(im.im_name)) == -1) {
xlog_warn("nfsdcb: bad name in upcall\n");
- return;
+ goto out;
}
break;
case IC_IDNAME:
im.im_conv = IDMAP_CONV_IDTONAME;
if (getfield(&bp, buf1, sizeof(buf1)) == -1) {
xlog_warn("nfsdcb: bad id in upcall\n");
- return;
+ goto out;
}
tmp = strtoul(buf1, (char **)NULL, 10);
im.im_id = (u_int32_t)tmp;
if ((tmp == ULONG_MAX && errno == ERANGE)
|| (unsigned long)im.im_id != tmp) {
xlog_warn("nfsdcb: id '%s' too big!\n", buf1);
- return;
+ goto out;
}
break;
default:
xlog_warn("nfsdcb: Unknown which type %d", ic->ic_which);
- return;
+ goto out;
}
imconv(ic, &im);
break;
default:
xlog_warn("nfsdcb: Unknown which type %d", ic->ic_which);
- return;
+ goto out;
}
bsiz = sizeof(buf) - bsiz;
}
static void
-nfscb(int fd, short which, void *data)
+nfscb(int UNUSED(fd), short which, void *data)
{
struct idmap_client *ic = data;
struct idmap_msg im;
} else {
event_set(&ic->ic_event, ic->ic_fd, EV_READ, nfscb, ic);
event_add(&ic->ic_event, NULL);
- fcntl(ic->ic_dirfd, F_SETSIG, 0);
fcntl(ic->ic_dirfd, F_NOTIFY, 0);
+ fcntl(ic->ic_dirfd, F_SETSIG, 0);
if (verbose > 0)
xlog_warn("Opened %s", ic->ic_path);
}
static int
validateascii(char *string, u_int32_t len)
{
- int i;
+ u_int32_t i;
for (i = 0; i < len; i++) {
if (string[i] == '\0')
getfield(char **bpp, char *fld, size_t fldsz)
{
char *bp;
- u_int val, n;
+ int val, n;
while ((bp = strsep(bpp, " ")) != NULL && bp[0] == '\0')
;
if (*bp == '\\') {
if ((n = sscanf(bp, "\\%03o", &val)) != 1)
return (-1);
- if (val > (char)-1)
+ if (val > UCHAR_MAX)
return (-1);
- *fld++ = (char)val;
+ *fld++ = val;
bp += 4;
} else {
*fld++ = *bp;