From: Erez Zadok Date: Sat, 6 Aug 2005 20:00:56 +0000 (+0000) Subject: they don't cause symbol conflicts with each other. X-Git-Tag: before-clocktime-fixes~55 X-Git-Url: https://git.fsl.cs.stonybrook.edu/?a=commitdiff_plain;h=dc84432859b7c772dbd9afeb6019e598f732f33b;p=am-utils-6.0.git they don't cause symbol conflicts with each other. enabled. For each entry line that is passed to the function a copy of the Amd equivalent is returned. * amd/info_file.c (file_search, file_reload): pass mnt_map to file_search_or_reload. (file_search_or_reload): ensure that mnt_map is never NULL. * amd/info_nis.c (nis_search): call sun_entry2amd() if sun_map_syntax=yes. * amd/info_ldap.c (amu_ldap_search): call sun_entry2amd() if sun_map_syntax=yes. * amd/info_hesiod.c (hesiod_search): call sun_entry2amd() if sun_map_syntax=yes. * amd/info_ndbm.c (ndbm_search): pass mnt_map to search_ndbm. (search_ndbm): call sun_entry2amd() if sun_map_syntax=yes. * amd/info_nisplus.c (nisplus_search): call sun_entry2amd() if sun_map_syntax=yes. * amd/info_exec.c (exec_search): pass mnt_map to exec_parse_qanswer. (exec_parse_qanswer): call sun_entry2amd() if sun_map_syntax=yes. --- diff --git a/ChangeLog b/ChangeLog index c80c6b3..0b98753 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,8 +3,8 @@ * amd/Makefile.am: Added new files sun_map.h, sun_map.c, sun_map_parse.y, and sun_map_tok.l. These files add support for parsing Sun style maps. The yacc/lex files needed custom rules so - they don't cause symbol conflicts with each other. - + they don't cause symbol conflicts with each other. + * amd/amd.h: Added "#define INFO_MAX_LINE_LEN" that specifies the line limit for info services. @@ -14,8 +14,8 @@ added support for parsing Sun style maps. The support for Sun maps is done using the sun_entry2amd() function. This function is called for each entry line that is read only when Sun parsing is - enabled. For each entry line that is passed to the function a copy of - the Amd equivalent is returned. + enabled. For each entry line that is passed to the function a + copy of the Amd equivalent is returned. * amd/sun_map.h: new header file for Sun style map support @@ -27,6 +27,29 @@ 2005-08-06 Erez Zadok + * amd/info_file.c (file_search, file_reload): pass mnt_map to + file_search_or_reload. + (file_search_or_reload): ensure that mnt_map is never NULL. + + * amd/info_nis.c (nis_search): call sun_entry2amd() if + sun_map_syntax=yes. + + * amd/info_ldap.c (amu_ldap_search): call sun_entry2amd() if + sun_map_syntax=yes. + + * amd/info_hesiod.c (hesiod_search): call sun_entry2amd() if + sun_map_syntax=yes. + + * amd/info_ndbm.c (ndbm_search): pass mnt_map to search_ndbm. + (search_ndbm): call sun_entry2amd() if sun_map_syntax=yes. + + * amd/info_nisplus.c (nisplus_search): call sun_entry2amd() if + sun_map_syntax=yes. + + * amd/info_exec.c (exec_search): pass mnt_map to + exec_parse_qanswer. + (exec_parse_qanswer): call sun_entry2amd() if sun_map_syntax=yes. + * doc/am-utils.texi (sun_map_syntax Parameter): document new common parameter. diff --git a/amd/Makefile.am b/amd/Makefile.am index 936b8b8..bc5e425 100644 --- a/amd/Makefile.am +++ b/amd/Makefile.am @@ -59,8 +59,7 @@ amd_SOURCES = \ sched.c \ srvr_amfs_auto.c \ srvr_nfs.c \ - \ - sun_map.c + sun_map.c # the complete list of all optional sources EXTRA_amd_SOURCES = \ @@ -97,7 +96,7 @@ EXTRA_amd_SOURCES = \ # AMD_INFO_OBJS: a list of info_*.o objects added, depending on which map # types this system supports. EXTRA_amd_OBJECTS = @AMD_FS_OBJS@ @AMD_INFO_OBJS@ sun_map_parse.o sun_map_tok.o -LDADD = $(EXTRA_amd_OBJECTS) get_args.o ../libamu/libamu.la +LDADD = $(EXTRA_amd_OBJECTS) get_args.o ../libamu/libamu.la # must manually add f/lex library to LIBS, and not to LDADD. LIBS = @LIBS@ @LEXLIB@ @WRAPLIB@ @@ -105,7 +104,7 @@ LIBS = @LIBS@ @LEXLIB@ @WRAPLIB@ sun_map_parse.o : sun_map_parse.c sun_map_parse.c : sun_map_parse.y - $(YACC) -d -psun_map_ -o$@ $< + $(YACC) -d -psun_map_ -o$@ $< sun_map_tok.o : sun_map_tok.c @@ -146,4 +145,3 @@ $(amd_OBJECTS) $(EXTRA_amd_OBJECTS): \ # auto-generate build number build_version.h: $(amd_OBJECTS) $(EXTRA_amd_OBJECTS) get_args.c $(top_srcdir)/m4/update_build_version - diff --git a/amd/amd.h b/amd/amd.h index 47895a7..0e43129 100644 --- a/amd/amd.h +++ b/amd/amd.h @@ -54,11 +54,11 @@ * that support mtab on file. */ #ifdef MOUNT_TABLE_ON_FILE -# define DEBUG_MNTTAB_FILE "/tmp/mnttab" +# define DEBUG_MNTTAB_FILE "/tmp/mnttab" #endif /* MOUNT_TABLE_ON_FILE */ /* Max line length that info services can handle */ -#define INFO_MAX_LINE_LEN 1500 +#define INFO_MAX_LINE_LEN 1500 /* options for amd.conf */ #define CFM_BROWSABLE_DIRS 0x00000001 diff --git a/amd/info_exec.c b/amd/info_exec.c index 333f664..f9998ab 100644 --- a/amd/info_exec.c +++ b/amd/info_exec.c @@ -52,6 +52,7 @@ #endif /* HAVE_CONFIG_H */ #include #include +#include /* forward declarations */ @@ -164,7 +165,7 @@ read_line(char *buf, int size, int fd) * Try to locate a value in a query answer */ static int -exec_parse_qanswer(int fd, char *map, char *key, char **pval, time_t *tp) +exec_parse_qanswer(mnt_map *m, int fd, char *map, char *key, char **pval, time_t *tp) { char qanswer[INFO_MAX_LINE_LEN], *dc = 0; int chuck = 0; @@ -206,7 +207,10 @@ exec_parse_qanswer(int fd, char *map, char *key, char **pval, time_t *tp) /* * Return a copy of the data */ - dc = strdup(cp); + if (m->cfm->cfm_flags & CFM_SUN_MAP_SYNTAX) + dc = sun_entry2amd(cp); + else + dc = strdup(cp); *pval = dc; dlog("%s returns %s", key, dc); @@ -414,7 +418,7 @@ exec_search(mnt_map *m, char *map, char *key, char **pval, time_t *tp) if (tp) *tp = clocktime(); - return exec_parse_qanswer(mapfd, map, key, pval, tp); + return exec_parse_qanswer(m, mapfd, map, key, pval, tp); } return errno; diff --git a/amd/info_file.c b/amd/info_file.c index 9ce8e96..f139646 100644 --- a/amd/info_file.c +++ b/amd/info_file.c @@ -52,6 +52,7 @@ #include #include + /* forward declarations */ int file_init_or_mtime(mnt_map *m, char *map, time_t *tp); int file_reload(mnt_map *m, char *map, void (*fn) (mnt_map *, char *, char *)); @@ -94,11 +95,11 @@ read_line(char *buf, int size, FILE *fp) * Try to locate a key in a file */ static int -file_search_or_reload(FILE *fp, +file_search_or_reload(mnt_map *m, + FILE *fp, char *map, char *key, char **val, - mnt_map *m, void (*fn) (mnt_map *m, char *, char *)) { char key_val[INFO_MAX_LINE_LEN]; @@ -224,10 +225,10 @@ file_init_or_mtime(mnt_map *m, char *map, time_t *tp) int file_reload(mnt_map *m, char *map, void (*fn) (mnt_map *, char *, char *)) { - FILE *mapf = file_open(map, (time_t *) 0); + FILE *mapf = file_open(map, (time_t *) NULL); if (mapf) { - int error = file_search_or_reload(mapf, map, 0, 0, m, fn); + int error = file_search_or_reload(m, mapf, map, NULL, NULL, fn); (void) fclose(mapf); return error; } @@ -247,7 +248,7 @@ file_search(mnt_map *m, char *map, char *key, char **pval, time_t *tp) *tp = t; error = -1; } else { - error = file_search_or_reload(mapf, map, key, pval, 0, 0); + error = file_search_or_reload(m, mapf, map, key, pval, NULL); } (void) fclose(mapf); return error; diff --git a/amd/info_hesiod.c b/amd/info_hesiod.c index ef72eb4..eb5e03d 100644 --- a/amd/info_hesiod.c +++ b/amd/info_hesiod.c @@ -50,6 +50,7 @@ #endif /* HAVE_CONFIG_H */ #include #include +#include #define HES_PREFIX "hesiod." #define HES_PREFLEN 7 @@ -127,7 +128,11 @@ hesiod_search(mnt_map *m, char *map, char *key, char **pval, time_t *tp) * it (and free subsequent replies) */ if (rvec && *rvec) { - *pval = *rvec; + if (m->cfm->cfm_flags & CFM_SUN_MAP_SYNTAX) { + *pval = sun_entry2amd(*rvec); + XFREE(*rvec); + } else + *pval = *rvec; while (*++rvec) XFREE(*rvec); return 0; diff --git a/amd/info_ldap.c b/amd/info_ldap.c index 9da26c2..852d5e3 100644 --- a/amd/info_ldap.c +++ b/amd/info_ldap.c @@ -52,6 +52,7 @@ #endif /* HAVE_CONFIG_H */ #include #include +#include /* @@ -527,7 +528,10 @@ amu_ldap_search(mnt_map *m, char *map, char *key, char **pval, time_t *ts) } dlog("Map %s, %s => %s\n", map, key, vals[0]); if (vals[0]) { - *pval = strdup(vals[0]); + if (m->cfm->cfm_flags & CFM_SUN_MAP_SYNTAX) + *pval = sun_entry2amd(vals[0]); + else + *pval = strdup(vals[0]); err = 0; } else { plog(XLOG_USER, "Empty value for %s in map %s\n", key, map); diff --git a/amd/info_ndbm.c b/amd/info_ndbm.c index aed668e..8227a7d 100644 --- a/amd/info_ndbm.c +++ b/amd/info_ndbm.c @@ -50,6 +50,7 @@ #endif /* HAVE_CONFIG_H */ #include #include +#include /* forward declarations */ int ndbm_init(mnt_map *m, char *map, time_t *tp); @@ -58,7 +59,7 @@ int ndbm_search(mnt_map *m, char *map, char *key, char **pval, time_t *tp); static int -search_ndbm(DBM *db, char *key, char **val) +search_ndbm(mnt_map *m, DBM *db, char *key, char **val) { datum k, v; @@ -66,7 +67,10 @@ search_ndbm(DBM *db, char *key, char **val) k.dsize = strlen(key) + 1; v = dbm_fetch(db, k); if (v.dptr) { - *val = strdup(v.dptr); + if (m->cfm->cfm_flags & CFM_SUN_MAP_SYNTAX) + *val = sun_entry2amd(v.dptr); + else + *val = strdup(v.dptr); return 0; } return ENOENT; @@ -95,7 +99,7 @@ ndbm_search(mnt_map *m, char *map, char *key, char **pval, time_t *tp) *tp = stb.st_mtime; error = -1; } else { - error = search_ndbm(db, key, pval); + error = search_ndbm(m, db, key, pval); } (void) dbm_close(db); return error; diff --git a/amd/info_nis.c b/amd/info_nis.c index 1335aa1..d8b0faa 100644 --- a/amd/info_nis.c +++ b/amd/info_nis.c @@ -50,6 +50,7 @@ #endif /* HAVE_CONFIG_H */ #include #include +#include /* @@ -247,7 +248,7 @@ nis_isup(mnt_map *m, char *map) * Try to locate a key using NIS. */ int -nis_search(mnt_map *m, char *map, char *key, char **val, time_t *tp) +nis_search(mnt_map *m, char *map, char *key, char **pval, time_t *tp) { int outlen; int res; @@ -301,7 +302,12 @@ nis_search(mnt_map *m, char *map, char *key, char **val, time_t *tp) /* * Lookup key */ - res = yp_match(gopt.nis_domain, map, key, strlen(key), val, &outlen); + res = yp_match(gopt.nis_domain, map, key, strlen(key), pval, &outlen); + if (m->cfm->cfm_flags & CFM_SUN_MAP_SYNTAX) { + char *oldval = *pval; + *pval = sun_entry2amd(oldval); + XFREE(*pval); /* yp_match malloc's *pval above */ + } /* * Do something interesting with the return code diff --git a/amd/info_nisplus.c b/amd/info_nisplus.c index 4125113..1ada472 100644 --- a/amd/info_nisplus.c +++ b/amd/info_nisplus.c @@ -50,6 +50,7 @@ #endif /* HAVE_CONFIG_H */ #include #include +#include #define NISPLUS_KEY "key=" #define NISPLUS_ORGDIR ".org_dir" @@ -218,7 +219,12 @@ nisplus_search(mnt_map *m, char *map, char *key, char **val, time_t *tp) if (value != NULL) data.value = strnsave(ENTRY_VAL(value, 1), ENTRY_LEN(value, 1)); } - *val = data.value; + + if (m->cfm->cfm_flags & CFM_SUN_MAP_SYNTAX) { + *val = sun_entry2amd(data.value); + XFREE(data.value); /* strnsave malloc'ed it above */ + } else + *val = data.value; if (*val) { error = 0;