they don't cause symbol conflicts with each other.
authorErez Zadok <ezk@cs.sunysb.edu>
Sat, 6 Aug 2005 20:00:56 +0000 (20:00 +0000)
committerErez Zadok <ezk@cs.sunysb.edu>
Sat, 6 Aug 2005 20:00:56 +0000 (20:00 +0000)
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.

ChangeLog
amd/Makefile.am
amd/amd.h
amd/info_exec.c
amd/info_file.c
amd/info_hesiod.c
amd/info_ldap.c
amd/info_ndbm.c
amd/info_nis.c
amd/info_nisplus.c

index c80c6b3981a9c0ba6e6901d7014653c8fcf73f10..0b9875328a41c37b977303cb06b3c9ff67468e64 100644 (file)
--- 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
 
 
 2005-08-06  Erez Zadok  <ezk@cs.sunysb.edu>
 
+       * 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.
 
index 936b8b85ab4d3081bef177b6a859e631e018f6ec..bc5e4253f19be51f06cc7e7b9143c6c46b5e7f2e 100644 (file)
@@ -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
-
index 47895a7176d56b791587d618f28281703ec4954d..0e431290ef0fbdafab08fcbf4c1f93b2665dc0c5 100644 (file)
--- a/amd/amd.h
+++ b/amd/amd.h
  * 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
index 333f664b14a761a9c2c153982fc865ac2c74a898..f9998abc07a0fcc2701788be7717072994712c6a 100644 (file)
@@ -52,6 +52,7 @@
 #endif /* HAVE_CONFIG_H */
 #include <am_defs.h>
 #include <amd.h>
+#include <sun_map.h>
 
 
 /* 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;
index 9ce8e961982ddbf4a9a6802ac2f569c104bfd6f8..f1396461f6977a8300f959ee160261c6dfc53ec1 100644 (file)
@@ -52,6 +52,7 @@
 #include <amd.h>
 #include <sun_map.h>
 
+
 /* 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;
index ef72eb4f96e448706b6e091e5d0f009bbdb61675..eb5e03dc9917394a5fe286195bd955c7f27b2bb1 100644 (file)
@@ -50,6 +50,7 @@
 #endif /* HAVE_CONFIG_H */
 #include <am_defs.h>
 #include <amd.h>
+#include <sun_map.h>
 
 #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;
index 9da26c2d82a8ea5ba6bed16919ecf70cf81ba9ab..852d5e3b001f41c4243c654d9a92bf3757600b89 100644 (file)
@@ -52,6 +52,7 @@
 #endif /* HAVE_CONFIG_H */
 #include <am_defs.h>
 #include <amd.h>
+#include <sun_map.h>
 
 
 /*
@@ -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);
index aed668e42d4c316a07117464b0653231a596d20f..8227a7d94c89c94493d44a8d1d90b36fb1345c16 100644 (file)
@@ -50,6 +50,7 @@
 #endif /* HAVE_CONFIG_H */
 #include <am_defs.h>
 #include <amd.h>
+#include <sun_map.h>
 
 /* 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;
index 1335aa1b69ee238d3353162681f7567f2f021e6c..d8b0faa59c3e9927561c8d09139fbb463fd5b548 100644 (file)
@@ -50,6 +50,7 @@
 #endif /* HAVE_CONFIG_H */
 #include <am_defs.h>
 #include <amd.h>
+#include <sun_map.h>
 
 
 /*
@@ -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
index 41251135cb127f183e532a9203e1dca7e9a0c421..1ada4722b17d34eee34907120b5dabea997c86ae 100644 (file)
@@ -50,6 +50,7 @@
 #endif /* HAVE_CONFIG_H */
 #include <am_defs.h>
 #include <amd.h>
+#include <sun_map.h>
 
 #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;