* support/nfs/clients.c (cfname): Added: current clients file name.
(setnfsclntent): Set it.
({get,end}nfsclntent, syntaxerr): Use it.
* support/nfs/exports.c (efname): Added: current exports file name.
(setnfsexportent): Set it.
(endnfsexportent, parseopts, getexport, syntaxerr): Use it.
+2001-11-21 Chip Salzenberg <chip@pobox.com>
+
+ * support/nfs/clients.c (cfname): Added: current clients file name.
+ (setnfsclntent): Set it.
+ ({get,end}nfsclntent, syntaxerr): Use it.
+ * support/nfs/exports.c (efname): Added: current exports file name.
+ (setnfsexportent): Set it.
+ (endnfsexportent, parseopts, getexport, syntaxerr): Use it.
+
2001-10-11 Chip Salzenberg <chip@pobox.com>
* utils/mountd/mountd.c (main): Close fds > 2 _before_ RPC init.
#include "exportfs.h"
#include "xio.h"
+static char *cfname = NULL;
static XFILE *cfp = NULL;
static int *squash_uids = NULL,
*squash_gids = NULL;
fname = _PATH_NFSCLIENTS;
if ((cfp = xfopen(fname)) == NULL)
xlog(L_ERROR, "can't open %s for reading", fname);
+ cfname = strdup(fname);
}
struct nfsclntent *
/* This is the anon entry */
if (!hosts) {
if (strcmp(cle.c_tag, "anonymous")) {
- xlog(L_ERROR, "nfsclients entry %s allows anonymous "
- "access. Ignored.", cle.c_tag);
+ xlog(L_ERROR,
+ "%s:%d: entry %s allows anonymous access. Ignored.",
+ cfname, xfp->x_line, cle.c_tag);
goto again;
}
return &cle;
nexthost:
if (*hostptr == ':' && strcmp(cle.c_tag, "anonymous")) {
- xlog(L_ERROR, "nfsclients entry %s allows anonymous "
- "access. Ignored.", cle.c_tag);
+ xlog(L_ERROR,
+ "%s:%d: entry %s allows anonymous access. Ignored.",
+ cfname, cfp->x_line, cle.c_tag);
while (*hostptr == ':')
hostptr++;
}
void
endnfsclntent(void)
{
+ if (cfname)
+ free(cfname);
if (cfp)
xfclose(cfp);
if (squash_uids)
xfree(squash_gids);
if (hosts)
xfree(hosts);
+ cfname = NULL;
cfp = NULL;
squash_uids = NULL;
squash_gids = NULL;
xskip(cfp, " \t");
if ((ok = xgettok(cfp, '=', attr, alen)) < 0)
- xlog(L_ERROR, "error parsing attribute");
+ syntaxerr("missing attribute");
if (ok <= 0)
return ok;
xskip(cfp, " \t=");
static void
syntaxerr(char *msg)
{
- xlog(L_ERROR, "syntax error in nfsclients file (line %d): %s",
- cfp->x_line, msg);
+ xlog(L_ERROR, "%s:%d: syntax error: %s",
+ cfname, cfp->x_line, msg);
}
#define EXPORT_DEFAULT_FLAGS \
(NFSEXP_ASYNC|NFSEXP_READONLY|NFSEXP_ROOTSQUASH|NFSEXP_GATHERED_WRITES)
+static char *efname = NULL;
static XFILE *efp = NULL;
static int first;
static int *squids = NULL, nsquids = 0,
if (!(efp = xfopen(fname, type)))
xlog(L_ERROR, "can't open %s for %sing",
fname, strcmp(type, "r")? "writ" : "read");
+ efname = strdup(fname);
first = 1;
}
if (efp)
xfclose(efp);
efp = NULL;
+ if (efname)
+ free(efname);
+ efname = NULL;
freesquash();
}
return -1;
}
} else {
- xlog(L_ERROR,
- "Unknown keyword \"%s\" in export file\n",
- opt);
+ xlog(L_ERROR, "%s:%d: unknown keyword \"%s\"\n",
+ efname, efp->x_line, opt);
ep->e_flags |= NFSEXP_ALLSQUASH | NFSEXP_READONLY;
free(opt);
return -1;
xskip(efp, " \t");
if ((ok = xgettok(efp, 0, exp, len)) < 0)
- xlog(L_ERROR, "error parsing export entry");
+ xlog(L_ERROR, "%s:%d: syntax error",
+ efname, efp->x_line);
return ok;
}
static void
syntaxerr(char *msg)
{
- xlog(L_ERROR, "syntax error in exports file (line %d): %s",
- efp->x_line, msg);
+ xlog(L_ERROR, "%s:%d: syntax error: %s",
+ efname, efp->x_line, msg);
}