aboutsummaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>1998-03-29 02:02:55 +0000
committerH. Peter Anvin <hpa@zytor.com>1998-03-29 02:02:55 +0000
commit43d9d88fd0160c7beecba8b78227cc7247e8d6e9 (patch)
treeaf128eb634b9edb8c20e0e56480dea5c0975374c /modules
parentcb3194a59be9fd8dd4e98d4d9632af40a0315fbc (diff)
downloadautofs3-43d9d88fd0160c7beecba8b78227cc7247e8d6e9.tar.gz
autofs3-43d9d88fd0160c7beecba8b78227cc7247e8d6e9.tar.xz
autofs3-43d9d88fd0160c7beecba8b78227cc7247e8d6e9.zip
NIS+ cleanups (patch from Thorsten); changed YPLIBS to LIBNSL; some
Makefile cleanups.
Diffstat (limited to 'modules')
-rw-r--r--modules/Makefile8
-rw-r--r--modules/lookup_nisplus.c25
2 files changed, 16 insertions, 17 deletions
diff --git a/modules/Makefile b/modules/Makefile
index 694a8c9..7d6634c 100644
--- a/modules/Makefile
+++ b/modules/Makefile
@@ -40,13 +40,15 @@ install: all
# Ad hoc compilation rules for modules which need auxilliary libraries
#
lookup_yp.so: lookup_yp.c
- $(CC) $(SOLDFLAGS) $(CFLAGS) -o lookup_yp.so lookup_yp.c $(YPLIBS)
+ $(CC) $(SOLDFLAGS) $(CFLAGS) -o lookup_yp.so lookup_yp.c $(LIBNSL)
$(STRIP) lookup_yp.so
lookup_nisplus.so: lookup_nisplus.c
- $(CC) $(SOLDFLAGS) $(CFLAGS) -o lookup_nisplus.so lookup_nisplus.c $(YPLIBS)
+ $(CC) $(SOLDFLAGS) $(CFLAGS) -o lookup_nisplus.so lookup_nisplus.c \
+ $(LIBNSL)
$(STRIP) lookup_nisplus.so
lookup_hesiod.so: lookup_hesiod.c
$(CC) $(SOLDFLAGS) $(CFLAGS) -I$(HESIOD)/include -o lookup_hesiod.so \
- lookup_hesiod.c $(HESIOD_LIBS)
+ lookup_hesiod.c $(HESIOD_LIBS)
+ $(STRIP) lookup_hesiod.so
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);
}