aboutsummaryrefslogtreecommitdiffstats
path: root/modules/lookup_nisplus.c
diff options
context:
space:
mode:
Diffstat (limited to 'modules/lookup_nisplus.c')
-rw-r--r--modules/lookup_nisplus.c25
1 files changed, 11 insertions, 14 deletions
diff --git a/modules/lookup_nisplus.c b/modules/lookup_nisplus.c
index dfaf675..f3a3121 100644
--- a/modules/lookup_nisplus.c
+++ b/modules/lookup_nisplus.c
@@ -16,7 +16,6 @@
#include <rpc/rpc.h>
#include <rpc/xdr.h>
#include <rpcsvc/nis.h>
-#include <rpcsvc/ypclnt.h>
#define MODULE_LOOKUP
#include "automount.h"
@@ -26,17 +25,17 @@
#define MODPREFIX "lookup(nisplus): "
struct lookup_context {
- char *domainname;
- char *mapname;
+ const char *domainname;
+ const char *mapname;
struct parse_mod *parse;
};
int lookup_version = AUTOFS_LOOKUP_VERSION; /* Required by protocol */
-int lookup_init(char *mapfmt, int argc, char **argv, void **context)
+int lookup_init(const char *mapfmt, int argc, const char * const *argv,
+ void **context)
{
struct lookup_context *ctxt;
- int err;
if ( !(*context = ctxt = malloc(sizeof(struct lookup_context))) ) {
syslog(LOG_CRIT, MODPREFIX "%m");
@@ -49,11 +48,9 @@ int lookup_init(char *mapfmt, int argc, char **argv, void **context)
}
ctxt->mapname = argv[0];
- err = yp_get_default_domain(&ctxt->domainname);
- if ( err ) {
- syslog(LOG_CRIT, MODPREFIX "map %s: %s\n", ctxt->mapname, yperr_string(err));
- return 1;
- }
+ /* nis_local_directory () returns a pointer to a static buffer.
+ We don't need to copy or free it. */
+ ctxt->domainname = nis_local_directory ();
if ( !mapfmt )
mapfmt = MAPFMT_DEFAULT;
@@ -61,7 +58,8 @@ int lookup_init(char *mapfmt, int argc, char **argv, void **context)
return !(ctxt->parse = open_parse(mapfmt,MODPREFIX,argc-1,argv+1));
}
-int lookup_mount(char *root, char *name, int name_len, void *context)
+int lookup_mount(const char *root, const char *name, int name_len,
+ void *context)
{
struct lookup_context *ctxt = (struct lookup_context *) context;
char tablename[strlen (name) + strlen (ctxt->mapname) +
@@ -71,15 +69,14 @@ int lookup_mount(char *root, char *name, int name_len, void *context)
syslog(LOG_DEBUG, MODPREFIX "looking up %s", name);
- sprintf (tablename, "[key=%s],%s.org_dir.%s.", name, ctxt->mapname,
+ sprintf (tablename, "[key=%s],%s.org_dir.%s", name, ctxt->mapname,
ctxt->domainname);
-
result = nis_list (tablename, FOLLOW_PATH | FOLLOW_LINKS, NULL, NULL);
if (result->status != NIS_SUCCESS && result->status != NIS_S_SUCCESS) {
/* Try to get the "*" entry if there is one - note that we *don't*
modify "name" so & -> the name we used, not "*" */
- sprintf (tablename, "[key=*],%s.org_dir.%s.", ctxt->mapname,
+ sprintf (tablename, "[key=*],%s.org_dir.%s", ctxt->mapname,
ctxt->domainname);
result = nis_list (tablename, FOLLOW_PATH | FOLLOW_LINKS, NULL, NULL);
}