nfs-utils: Merge libnfsidmap tree with nfs-utils UPDATED
Subsystems (2)
cover nfs-utils: Merge libnfsidmap tree with nfs-utils UPDATED
It was suggested that merging the trees is more desirable than splitting the common code out into a shared library, so this patch set attempts to merge the libnfsidmap code into nfs-utils.
The main body of the code, copyright notices, and readme are copied across, omitting the shared conffile code, and trimming unused files like strlcpy.c and queue.h. The build files of both are adjusted to the new structure, and the dependent nfs-utils now link to the included shared library instead of an external one.
The source libnfsidmap tree did include some packaging files for debian/dkpg which have been omitted, there are no packaging materials in nfs-utils to merge them with, and i welcome advice on what should be done here.
Change: libnfsidmap imported as support/nfsidmap/
Justin Mitchell (7):
nfs-utils: const-ify the config handling functions
nfs-utils: Merge conf_get_str and conf_get_section
nfs-utils: Add get_str with default value
nfs-utils: split conffile to a separate convenience lib
nfs-utils: Import libnfsidmap codebase integrate libnfsidmap code with rest of nfs-utils
nfs-utils: cleanup warnings from merged libnfsidmap code
configure.ac | 50 +- support/Makefile.am | 8 +- support/include/conffile.h | 23 +- support/nfs/Makefile.am | 13 +- support/nfs/conffile.c | 85 +-- support/nfs/xlog.c | 2 + support/nfsidmap/AUTHORS | 1 + support/nfsidmap/COPYING | 30 + support/nfsidmap/Makefile.am | 61 ++ support/nfsidmap/README | 126 ++++ support/nfsidmap/gums.c | 788 ++++++++++++++++++++ support/nfsidmap/idmapd.conf | 137 ++++ support/nfsidmap/idmapd.conf.5 | 308 ++++++++ support/nfsidmap/libnfsidmap.c | 712 +++++++++++++++++++ support/nfsidmap/libnfsidmap.pc.in | 11 + support/nfsidmap/libtest.c | 160 +++++ support/nfsidmap/nfs4_uid_to_name.3 | 174 +++++ support/nfsidmap/nfsidmap.h | 67 ++ support/nfsidmap/nfsidmap_internal.h | 79 +++ support/nfsidmap/nss.c | 468 ++++++++++++ support/nfsidmap/static.c | 413 +++++++++++ support/nfsidmap/umich_ldap.c | 1303 ++++++++++++++++++++++++++++++++++ utils/Makefile.am | 2 - utils/blkmapd/Makefile.am | 2 +- utils/exportfs/Makefile.am | 2 +- utils/gssd/Makefile.am | 7 +- utils/idmapd/Makefile.am | 4 +- utils/mount/Makefile.am | 2 +- utils/mountd/Makefile.am | 2 +- utils/nfsd/Makefile.am | 2 +- utils/nfsdcltrack/Makefile.am | 2 +- utils/nfsidmap/Makefile.am | 4 +- utils/statd/Makefile.am | 4 +- 33 files changed, 4973 insertions(+), 79 deletions(-) create mode 100644 support/nfsidmap/AUTHORS create mode 100644 support/nfsidmap/COPYING create mode 100644 support/nfsidmap/Makefile.am create mode 100644 support/nfsidmap/README create mode 100644 support/nfsidmap/gums.c create mode 100644 support/nfsidmap/idmapd.conf create mode 100644 support/nfsidmap/idmapd.conf.5 create mode 100644 support/nfsidmap/libnfsidmap.c create mode 100644 support/nfsidmap/libnfsidmap.pc.in create mode 100644 support/nfsidmap/libtest.c create mode 100644 support/nfsidmap/nfs4_uid_to_name.3 create mode 100644 support/nfsidmap/nfsidmap.h create mode 100644 support/nfsidmap/nfsidmap_internal.h create mode 100644 support/nfsidmap/nss.c create mode 100644 support/nfsidmap/static.c create mode 100644 support/nfsidmap/umich_ldap.c
Signature · 1 line
1.8.3.1
PATCH 1/7 nfs-utils: const-ify the config handling functions
Tighten up the conffile interface by switching to const arguments where appropriate.
--- support/include/conffile.h | 22 +++++++++++----------- support/nfs/conffile.c | 38 +++++++++++++++++++------------------- 2 files changed, 30 insertions(+), 30 deletions(-)
support/include/conffile.h +11 -11
@@ -49,21 +49,21 @@ struct conf_list { };extern int conf_begin (void ); -extern int conf_decode_base64 (uint8_t *,uint32_t *,unsigned char *); +extern int conf_decode_base64 (uint8_t *,uint32_t *,const unsigned char *);extern int conf_end (int ,int );extern void conf_free_list (struct conf_list *); -extern struct sockaddr *conf_get_address (char *,char *); -extern struct conf_list *conf_get_list (char *,char *); -extern struct conf_list *conf_get_tag_list (char *,char *); -extern int conf_get_num (char *,char *,int ); -extern _Bool conf_get_bool (char *,char *,_Bool ); -extern char *conf_get_str (char *,char *); -extern char *conf_get_section (char *,char *,char *); +extern struct sockaddr *conf_get_address (const char *,const char *); +extern struct conf_list *conf_get_list (const char *,const char *); +extern struct conf_list *conf_get_tag_list (const char *,const char *); +extern int conf_get_num (const char *,const char *,int ); +extern _Bool conf_get_bool (const char *,const char *,_Bool ); +extern char *conf_get_str (const char *,const char *); +extern char *conf_get_section (const char *,const char *,const char *);extern void conf_init (const char *);extern void conf_cleanup (void ); -extern int conf_match_num (char *,char *,int ); -extern int conf_remove (int ,char *,char *); -extern int conf_remove_section (int ,char *); +extern int conf_match_num (const char *,const char *,int ); +extern int conf_remove (int ,const char *,const char *); +extern int conf_remove_section (int ,const char *);extern void conf_report (void );/*
support/nfs/conffile.c +19 -19
@@ -57,8 +57,8 @@static void conf_load_defaults (void );static char *conf_load (const char *path); -static int conf_set (int ,char *,char *,char *, -char *,int ,int ); +static int conf_set (int ,const char *,const char *,const char *, +const char *,int ,int );static void conf_parse (int trans,char *buf,char **section,char **subsection);
@@ -116,7 +116,7 @@ struct conf_binding { LIST_HEAD (conf_bindings, conf_binding) conf_bindings[256];static __inline__uint8_t -conf_hash (char *s) +conf_hash (const char *s) {uint8_t hash =0 ;
@@ -131,7 +131,7 @@ conf_hash(char *s)* Insert a tag-value combination from LINE (the equal sign is at POS) */ static int -conf_remove_now (char *section,char *tag) +conf_remove_now (const char *section,const char *tag) {struct conf_binding *cb, *next;
@@ -154,7 +154,7 @@ conf_remove_now(char *section, char *tag) }static int -conf_remove_section_now (char *section) +conf_remove_section_now (const char *section) {struct conf_binding *cb, *next;int unseen =1 ;
@@ -181,8 +181,8 @@ conf_remove_section_now(char *section)* into SECTION of our configuration database. */ static int -conf_set_now (char *section,char *arg,char *tag, -char *value,int override,int is_default) +conf_set_now (const char *section,const char *arg,const char *tag, +const char *value,int override,int is_default) {struct conf_binding *node =0 ;
@@ -565,7 +565,7 @@ conf_cleanup(void)* if that tag does not exist. */ int -conf_get_num (char *section,char *tag,int def) +conf_get_num (const char *section,const char *tag,int def) {char *value =conf_get_str (section, tag);
@@ -583,7 +583,7 @@ conf_get_num(char *section, char *tag, int def)* A failure to match one of these results in DEF */ _Bool -conf_get_bool (char *section,char *tag,_Bool def) +conf_get_bool (const char *section,const char *tag,_Bool def) {char *value =conf_get_str (section, tag);
@@ -609,7 +609,7 @@ conf_get_bool(char *section, char *tag, _Bool def)/* Validate X according to the range denoted by TAG in section SECTION. */ int -conf_match_num (char *section,char *tag,int x) +conf_match_num (const char *section,const char *tag,int x) {char *value =conf_get_str (section, tag);int val, min, max, n;
@@ -634,7 +634,7 @@ conf_match_num(char *section, char *tag, int x)/* Return the string value denoted by TAG in section SECTION. */ char * -conf_get_str (char *section,char *tag) +conf_get_str (const char *section,const char *tag) {struct conf_binding *cb; retry:
@@ -662,7 +662,7 @@ retry:* Find a section that may or may not have an argument */ char * -conf_get_section (char *section,char *arg,char *tag) +conf_get_section (const char *section,const char *arg,const char *tag) {struct conf_binding *cb;
@@ -684,7 +684,7 @@ conf_get_section(char *section, char *arg, char *tag)* TAG in SECTION. */ struct conf_list * -conf_get_list (char *section,char *tag) +conf_get_list (const char *section,const char *tag) {char *liststr =0 , *p, *field, *t;struct conf_list *list =0 ;
@@ -738,7 +738,7 @@ cleanup: }struct conf_list * -conf_get_tag_list (char *section,char *arg) +conf_get_tag_list (const char *section,const char *arg) {struct conf_list *list =0 ;struct conf_list_node *node;
@@ -776,7 +776,7 @@ cleanup:/* Decode a PEM encoded buffer. */ int -conf_decode_base64 (uint8_t *out,uint32_t *len,unsigned char *buf) +conf_decode_base64 (uint8_t *out,uint32_t *len,const unsigned char *buf) {uint32_t c =0 ;uint8_t c1, c2, c3, c4;
@@ -873,8 +873,8 @@ conf_trans_node(int transaction, enum conf_op op)/* Queue a set operation. */ static int -conf_set (int transaction,char *section,char *arg, -char *tag,char *value,int override,int is_default) +conf_set (int transaction,const char *section,const char *arg, +const char *tag,const char *value,int override,int is_default) {struct conf_trans *node;
@@ -926,7 +926,7 @@ fail:/* Queue a remove operation. */ int -conf_remove (int transaction,char *section,char *tag) +conf_remove (int transaction,const char *section,const char *tag) {struct conf_trans *node;
@@ -955,7 +955,7 @@ fail:/* Queue a remove section operation. */ int -conf_remove_section (int transaction,char *section) +conf_remove_section (int transaction,const char *section) {struct conf_trans *node;
Signature · 1 line
1.8.3.1
PATCH 2/7 nfs-utils: Merge conf_get_str and conf_get_section
In reply to Justin Mitchellconf_get_section() started as conf_get_str() with one extra search parameter, subsequent patches have not maintained feature parity, combine the code to make a single more generic function and just call that differently where required.
--- support/nfs/conffile.c | 36 ++++++++++++++---------------------- 1 file changed, 14 insertions(+), 22 deletions(-)
support/nfs/conffile.c +14 -22
@@ -636,28 +636,9 @@ conf_match_num(const char *section, const char *tag, int x)char *conf_get_str (const char *section,const char *tag) { -struct conf_binding *cb; -retry: - cb =LIST_FIRST (&conf_bindings[conf_hash (section)]); -for (; cb; cb =LIST_NEXT (cb, link)) { -if (strcasecmp (section, cb->section) ==0 - &&strcasecmp (tag, cb->tag) ==0 ) { -if (cb->value[0 ] =='$' ) { -/* expand $name from [environment] section, -* or from environment -*/ -char *env =getenv (cb->value+1 ); -if (env && *env) -return env; - section ="environment" ; - tag = cb->value +1 ; - goto retry; - } -return cb->value; - } - } -return 0 ; +return conf_get_section (section,NULL , tag); } +/* * Find a section that may or may not have an argument */
@@ -665,7 +646,7 @@ char * conf_get_section(const char *section, const char *arg, const char *tag) { struct conf_binding *cb; - +retry: cb =LIST_FIRST (&conf_bindings[conf_hash (section)]);for (; cb; cb =LIST_NEXT (cb, link)) {if (strcasecmp (section, cb->section) !=0 )
@@ -674,6 +655,17 @@ conf_get_section(const char *section, const char *arg, const char *tag)continue ;if (strcasecmp (tag, cb->tag) !=0 )continue ; +if (cb->value[0 ] =='$' ) { +/* expand $name from [environment] section, +* or from environment +*/ +char *env =getenv (cb->value+1 ); +if (env && *env) +return env; + section ="environment" ; + tag = cb->value +1 ; + goto retry; + }return cb->value; }return 0 ;
Signature · 1 line
1.8.3.1
PATCH 3/7 nfs-utils: Add get_str with default value
In reply to Justin MitchellThe similar config code in libnfsidmap had one additional feature of a get_str function with a default value option, include an equivalent function here to maintain compatibility.
--- support/include/conffile.h | 1 + support/nfs/conffile.c | 11 +++++++++++ 2 files changed, 12 insertions(+)
support/include/conffile.h +1 -0
@@ -58,6 +58,7 @@ extern struct conf_list *conf_get_tag_list(const char *, const char *);extern int conf_get_num (const char *,const char *,int );extern _Bool conf_get_bool (const char *,const char *,_Bool );extern char *conf_get_str (const char *,const char *); +extern char *conf_get_str_with_def (const char *,const char *,char *);extern char *conf_get_section (const char *,const char *,const char *);extern void conf_init (const char *);extern void conf_cleanup (void );
support/nfs/conffile.c +11 -0
@@ -639,6 +639,17 @@ conf_get_str(const char *section, const char *tag)return conf_get_section (section,NULL , tag); } +/* Return the string value denoted by TAG in section SECTION, +* unless it is not set, in which case return def +*/ +char * +conf_get_str_with_def (const char *section,const char *tag,char *def) +{ +char * result =conf_get_section (section,NULL , tag); +if (!result)return def; +return result; +} +/* * Find a section that may or may not have an argument */
Signature · 1 line
1.8.3.1
PATCH 4/7 nfs-utils: split conffile to a separate convenience lib
In reply to Justin MitchellTo allow better reuse of the code we split conffile and xlog into their own separate convenience library, then merge it back so as to not create extra dependancies for everything
--- support/nfs/Makefile.am | 13 +++++++++---- support/nfs/xlog.c | 2 ++ utils/blkmapd/Makefile.am | 2 +- utils/exportfs/Makefile.am | 2 +- utils/gssd/Makefile.am | 4 ++-- utils/idmapd/Makefile.am | 2 +- utils/mount/Makefile.am | 2 +- utils/mountd/Makefile.am | 2 +- utils/nfsd/Makefile.am | 2 +- utils/nfsdcltrack/Makefile.am | 2 +- utils/nfsidmap/Makefile.am | 2 +- utils/statd/Makefile.am | 4 ++-- 12 files changed, 23 insertions(+), 16 deletions(-)
support/nfs/Makefile.am +9 -4
@@ -1,11 +1,16 @@ ## Process this file with automake to produce Makefile.in -noinst_LIBRARIES = libnfs.a -libnfs_a_SOURCES = exports.c rmtab.c xio.c rpcmisc.c rpcdispatch.c \ - xlog.c xcommon.c wildmat.c mydaemon.c \ +noinst_LIBRARIES = +noinst_LTLIBRARIES = libnfs.la libnfsconf.la + +libnfs_la_SOURCES = exports.c rmtab.c xio.c rpcmisc.c rpcdispatch.c \ + xcommon.c wildmat.c mydaemon.c \ rpc_socket.c getport.c \ - svc_socket.c cacheio.c closeall.c nfs_mntent.c conffile.c \ + svc_socket.c cacheio.c closeall.c nfs_mntent.c \ svc_create.c atomicio.c strlcpy.c strlcat.c +libnfs_la_LIBADD = libnfsconf.la + +libnfsconf_la_SOURCES = conffile.c xlog.c MAINTAINERCLEANFILES = Makefile.in
support/nfs/xlog.c +2 -0
@@ -33,6 +33,8 @@#undef VERBOSE_PRINTF +#pragma GCC visibility push(hidden) +static int log_stderr =1 ;static int log_syslog =1 ;static int logging =0 ;/* enable/disable DEBUG logs */
utils/blkmapd/Makefile.am +1 -1
@@ -13,7 +13,7 @@ blkmapd_SOURCES = \ dm-device.c \ device-discovery.h -blkmapd_LDADD = -ldevmapper ../../support/nfs/libnfs.a +blkmapd_LDADD = -ldevmapper ../../support/nfs/libnfs.la MAINTAINERCLEANFILES = Makefile.in
utils/exportfs/Makefile.am +1 -1
@@ -8,7 +8,7 @@ EXTRA_DIST = $(man5_MANS) $(man7_MANS) $(man8_MANS) sbin_PROGRAMS = exportfs exportfs_SOURCES = exportfs.c exportfs_LDADD = ../../support/export/libexport.a \ - ../../support/nfs/libnfs.a \ + ../../support/nfs/libnfs.la \ ../../support/misc/libmisc.a \ $(LIBWRAP) $(LIBNSL)
utils/gssd/Makefile.am +2 -2
@@ -44,7 +44,7 @@ gssd_SOURCES = \ write_bytes.h gssd_LDADD = \ - ../../support/nfs/libnfs.a \ + ../../support/nfs/libnfs.la \ $(LIBEVENT) \ $(RPCSECGSS_LIBS) \ $(KRBLIBS) \
@@ -74,7 +74,7 @@ svcgssd_SOURCES = \ svcgssd.h svcgssd_LDADD = \ - ../../support/nfs/libnfs.a \ + ../../support/nfs/libnfs.la \ $(RPCSECGSS_LIBS) $(LIBNFSIDMAP) \ $(KRBLIBS) $(GSSAPI_LIBS) $(LIBTIRPC)
utils/idmapd/Makefile.am +1 -1
@@ -15,7 +15,7 @@ idmapd_SOURCES = \ nfs_idmap.h \ queue.h -idmapd_LDADD = ../../support/nfs/libnfs.a $(LIBEVENT) $(LIBNFSIDMAP) +idmapd_LDADD = ../../support/nfs/libnfs.la $(LIBEVENT) $(LIBNFSIDMAP) MAINTAINERCLEANFILES = Makefile.in
utils/mount/Makefile.am +1 -1
@@ -25,7 +25,7 @@ else EXTRA_DIST += nfsmount.conf.man endif -mount_nfs_LDADD = ../../support/nfs/libnfs.a \ +mount_nfs_LDADD = ../../support/nfs/libnfs.la \ ../../support/export/libexport.a \ $(LIBTIRPC)
utils/mountd/Makefile.am +1 -1
@@ -11,7 +11,7 @@ noinst_HEADERS = fsloc.h mountd_SOURCES = mountd.c mount_dispatch.c auth.c rmtab.c cache.c \ svc_run.c fsloc.c v4root.c mountd.h mountd_LDADD = ../../support/export/libexport.a \ - ../../support/nfs/libnfs.a \ + ../../support/nfs/libnfs.la \ ../../support/misc/libmisc.a \ $(LIBBSD) $(LIBWRAP) $(LIBNSL) $(LIBBLKID) $(LIBDL) $(LIBTIRPC) mountd_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS) \
utils/nfsd/Makefile.am +1 -1
@@ -9,7 +9,7 @@ sbin_PROGRAMS = nfsd noinst_HEADERS = nfssvc.h nfsd_SOURCES = nfsd.c nfssvc.c -nfsd_LDADD = ../../support/nfs/libnfs.a $(LIBTIRPC) +nfsd_LDADD = ../../support/nfs/libnfs.la $(LIBTIRPC) MAINTAINERCLEANFILES = Makefile.in
utils/nfsdcltrack/Makefile.am +1 -1
@@ -13,7 +13,7 @@ sbin_PROGRAMS = nfsdcltrack noinst_HEADERS = sqlite.h nfsdcltrack_SOURCES = nfsdcltrack.c sqlite.c -nfsdcltrack_LDADD = ../../support/nfs/libnfs.a $(LIBSQLITE) $(LIBCAP) +nfsdcltrack_LDADD = ../../support/nfs/libnfs.la $(LIBSQLITE) $(LIBCAP) MAINTAINERCLEANFILES = Makefile.in
utils/nfsidmap/Makefile.am +1 -1
@@ -4,7 +4,7 @@ man8_MANS = nfsidmap.man sbin_PROGRAMS = nfsidmap nfsidmap_SOURCES = nfsidmap.c -nfsidmap_LDADD = $(LIBNFSIDMAP) -lkeyutils ../../support/nfs/libnfs.a +nfsidmap_LDADD = $(LIBNFSIDMAP) -lkeyutils ../../support/nfs/libnfs.la MAINTAINERCLEANFILES = Makefile.in EXTRA_DIST = id_resolver.conf $(man8_MANS)
utils/statd/Makefile.am +2 -2
@@ -13,11 +13,11 @@ sm_notify_SOURCES = sm-notify.c BUILT_SOURCES = $(GENFILES) statd_LDADD = ../../support/nsm/libnsm.a \ - ../../support/nfs/libnfs.a \ + ../../support/nfs/libnfs.la \ ../../support/misc/libmisc.a \ $(LIBWRAP) $(LIBNSL) $(LIBCAP) $(LIBTIRPC) sm_notify_LDADD = ../../support/nsm/libnsm.a \ - ../../support/nfs/libnfs.a \ + ../../support/nfs/libnfs.la \ ../../support/misc/libmisc.a \ $(LIBNSL) $(LIBCAP) $(LIBTIRPC)
Signature · 1 line
1.8.3.1
PATCH 6/7 integrate libnfsidmap code with rest of nfs-utils
In reply to Justin MitchellModify libnfsidmap to use the now shared conffile code, adjust the build structure to generate everything correctly, and modify the other utils to use the merged version of libnfsidmap instead of testing for an external dependancy.
--- configure.ac | 50 ++++++++++++++++++++++++++++++++++++------ support/Makefile.am | 8 ++++++- support/nfsidmap/Makefile.am | 5 ++--- support/nfsidmap/libnfsidmap.c | 5 +++-- support/nfsidmap/nss.c | 2 +- support/nfsidmap/static.c | 5 ++--- support/nfsidmap/umich_ldap.c | 2 +- utils/Makefile.am | 2 -- utils/gssd/Makefile.am | 3 ++- utils/idmapd/Makefile.am | 4 +++- utils/nfsidmap/Makefile.am | 4 +++- 11 files changed, 67 insertions(+), 23 deletions(-)
configure.ac +43 -7
@@ -304,9 +304,6 @@ if test "$enable_nfsv4" = yes; then dnl check for libevent libraries and headers AC_LIBEVENT - dnl check for nfsidmap libraries and headers - AC_LIBNFSIDMAP - dnl check for the keyutils libraries and headers AC_KEYUTILS
@@ -339,7 +336,6 @@ fi dnl enable nfsidmap when its support by libnfsidmap AM_CONDITIONAL(CONFIG_NFSDCLTRACK, [test "$enable_nfsdcltrack" = "yes" ]) -AM_CONDITIONAL(CONFIG_NFSIDMAP, [test "$ac_cv_header_keyutils_h$ac_cv_lib_nfsidmap_nfs4_owner_to_uid" = "yesyes"]) if test "$knfsd_cv_glibc2" = no; then
@@ -382,9 +378,6 @@ if test "$enable_gss" = yes; then dnl check for libevent libraries and headers AC_LIBEVENT - dnl 'gss' also depends on nfsidmap.h - at least for svcgssd_proc.c - AC_LIBNFSIDMAP - dnl Check for Kerberos V5 AC_KERBEROS_V5
@@ -407,6 +400,47 @@ if test "$enable_gss" = yes; then fi fi +dnl libdnsidmap specific checks +AC_CHECK_LIB([resolv], [__res_querydomain], , AC_MSG_ERROR(res_querydomain needed)) + +AC_ARG_ENABLE([ldap], + [AS_HELP_STRING([--disable-ldap],[Disable support for LDAP @<:default=detect@:>@])]) + +dnl will libdnsidmap support LDAP ? +if test "x$enable_ldap" != "xno" ; then + AC_CHECK_HEADER([ldap.h], + [AC_CHECK_LIB([ldap], [ldap_initialize], + [have_ldap="yes"],[have_ldap="no"])], + [have_ldap="no"]) + if test "x$have_ldap" = "xyes" ; then + AC_DEFINE([ENABLE_LDAP], 1, [Enable LDAP Support]) + elif test "x$enable_ldap$have_ldap" = "xyesno" ; then + AC_MSG_ERROR(LDAP support not found!) + fi +fi +AM_CONDITIONAL(ENABLE_LDAP, test "x$have_ldap" = "xyes") + +dnl Should we build gums mapping library? +AC_ARG_ENABLE([gums], + [AS_HELP_STRING([--enable-gums],[Enable support for the GUMS mapping library @<:@default=false@:>@])]) +if test "x$enable_gums" = "xyes" ; then + AC_DEFINE([ENABLE_GUMS], 1, [Enable GUMS mapping library support]) +fi +AM_CONDITIONAL(ENABLE_GUMS, test "x$enable_gums" = "xyes") + +dnl Where do the Plugins live +AC_ARG_WITH(pluginpath, + [AS_HELP_STRING([--with-pluginpath=/foo],[Causes the library to look in /foo instead of /usr/lib/libnfsidmap for plugins + ])], + path_plugins=$withval, + path_plugins="" + ) +if test -n "$path_plugins" ; then + AC_DEFINE_UNQUOTED(PATH_PLUGINS, "$path_plugins", + [Define this to change the plugins path]) +fi +AM_CONDITIONAL(PATH_PLUGINS, test -n "$path_plugins") + dnl Check for IPv6 support AC_IPV6
@@ -537,6 +571,8 @@ AC_CONFIG_FILES([ support/misc/Makefile support/nfs/Makefile support/nsm/Makefile + support/nfsidmap/Makefile + support/nfsidmap/libnfsidmap.pc tools/Makefile tools/locktest/Makefile tools/nlmtest/Makefile
support/Makefile.am +7 -1
@@ -1,6 +1,12 @@ ## Process this file with automake to produce Makefile.in -SUBDIRS = export include misc nfs nsm +OPTDIRS = + +if CONFIG_NFSV4 +OPTDIRS += nfsidmap +endif + +SUBDIRS = export include misc nfs nsm $(OPTDIRS) MAINTAINERCLEANFILES = Makefile.in
support/nfsidmap/Makefile.am +2 -3
@@ -1,4 +1,3 @@ -ACLOCAL_AMFLAGS = -I m4 if ENABLE_LDAP UMICH_LDAP_LIB = umich_ldap.la
@@ -25,9 +24,9 @@ pkglib_LTLIBRARIES = nsswitch.la static.la $(UMICH_LDAP_LIB) $(GUMS_MAPPING_LIB) # <age> The number of previous additional interfaces supported # by this library. -libnfsidmap_la_SOURCES = libnfsidmap.c cfg.c strlcpy.c cfg.h nfsidmap_internal.h queue.h +libnfsidmap_la_SOURCES = libnfsidmap.c nfsidmap_internal.h libnfsidmap_la_LDFLAGS = -version-info 3:0:3 -libnfsidmap_la_LIBADD = -ldl +libnfsidmap_la_LIBADD = -ldl ../../support/nfs/libnfsconf.la nsswitch_la_SOURCES = nss.c nsswitch_la_LDFLAGS = -module -avoid-version
support/nfsidmap/libnfsidmap.c +3 -2
@@ -59,7 +59,7 @@#include "nfsidmap.h" #include "nfsidmap_internal.h" -#include "cfg.h" +#include "conffile.h" static char *default_domain;static struct conf_list *local_realms;
@@ -340,6 +340,7 @@ int nfs4_init_name_mapping(char *conffile)char *nobody_user, *nobody_group;char *nostrip;char *reformatgroup; +char *conf_path;/* XXX: need to be able to reload configurations... */ if (nfs4_plugins)/* already succesfully initialized */
@@ -348,7 +349,7 @@ int nfs4_init_name_mapping(char *conffile) conf_path = conffile; else conf_path =PATH_IDMAPDCONF ; -conf_init (); +conf_init (conf_path); default_domain =conf_get_str ("General" ,"Domain" );if (default_domain ==NULL ) { dflt =1 ;
support/nfsidmap/nss.c +1 -1
@@ -48,7 +48,7 @@#include <ctype.h> #include "nfsidmap.h" #include "nfsidmap_internal.h" -#include "cfg.h" +#include "conffile.h" #include <syslog.h> /*
support/nfsidmap/static.c +2 -3
@@ -41,8 +41,7 @@#include <errno.h> #include <err.h> -#include "queue.h" -#include "cfg.h" +#include "conffile.h" #include "nfsidmap.h" #include "nfsidmap_internal.h"
@@ -317,7 +316,7 @@ static int static_init() {LIST_INIT (&uid_mappings[i]);//get all principals for which we have mappings - princ_list =conf_get_tag_list ("Static" ); + princ_list =conf_get_tag_list ("Static" ,NULL );if (!princ_list) {return -ENOENT ;
support/nfsidmap/umich_ldap.c +1 -1
@@ -48,7 +48,7 @@#include <ldap.h> #include "nfsidmap.h" #include "nfsidmap_internal.h" -#include "cfg.h" +#include "conffile.h" /* attribute/objectclass default mappings */ #define DEFAULT_UMICH_OBJCLASS_REMOTE_PERSON "NFSv4RemotePerson"
utils/Makefile.am +0 -2
@@ -4,10 +4,8 @@ OPTDIRS = if CONFIG_NFSV4 OPTDIRS += idmapd -if CONFIG_NFSIDMAP OPTDIRS += nfsidmap endif -endif if CONFIG_NFSV41 OPTDIRS += blkmapd
utils/gssd/Makefile.am +2 -1
@@ -75,7 +75,8 @@ svcgssd_SOURCES = \ svcgssd_LDADD = \ ../../support/nfs/libnfs.la \ - $(RPCSECGSS_LIBS) $(LIBNFSIDMAP) \ + ../../support/nfsidmap/libnfsidmap.la \ + $(RPCSECGSS_LIBS) \ $(KRBLIBS) $(GSSAPI_LIBS) $(LIBTIRPC) svcgssd_LDFLAGS = $(KRBLDFLAGS)
utils/idmapd/Makefile.am +3 -1
@@ -15,7 +15,9 @@ idmapd_SOURCES = \ nfs_idmap.h \ queue.h -idmapd_LDADD = ../../support/nfs/libnfs.la $(LIBEVENT) $(LIBNFSIDMAP) +idmapd_LDADD = ../../support/nfs/libnfs.la \ + ../../support/nfsidmap/libnfsidmap.la \ + $(LIBEVENT) MAINTAINERCLEANFILES = Makefile.in
utils/nfsidmap/Makefile.am +3 -1
@@ -4,7 +4,9 @@ man8_MANS = nfsidmap.man sbin_PROGRAMS = nfsidmap nfsidmap_SOURCES = nfsidmap.c -nfsidmap_LDADD = $(LIBNFSIDMAP) -lkeyutils ../../support/nfs/libnfs.la +nfsidmap_LDADD = -lkeyutils \ + ../../support/nfs/libnfs.la \ + ../../support/nfsidmap/libnfsidmap.la MAINTAINERCLEANFILES = Makefile.in EXTRA_DIST = id_resolver.conf $(man8_MANS)
Signature · 1 line
1.8.3.1
PATCH 7/7 nfs-utils: cleanup warnings from merged libnfsidmap code
In reply to Justin MitchellClean up a bunch of warnings about unused parameters, signedness differences, etc that we inherited from the merged libnfsidmap code.
--- support/nfsidmap/libnfsidmap.c | 10 ++++++---- support/nfsidmap/nfsidmap_internal.h | 7 +++++++ support/nfsidmap/nss.c | 6 +++--- support/nfsidmap/static.c | 20 +++++++++++--------- support/nfsidmap/umich_ldap.c | 11 ++++++----- 5 files changed, 33 insertions(+), 21 deletions(-)
support/nfsidmap/libnfsidmap.c +6 -4
@@ -103,7 +103,7 @@ nfs4_idmap_log_function_t idmap_log_func = default_logger;static char *toupper_str (char *s) { -int i; +size_t i;for (i=0 ; i <strlen (s); i++) s[i] =toupper (s[i]);return s;
@@ -128,7 +128,8 @@ static int id_as_chars(char *name, uid_t *id)static int dns_txt_query (char *domain,char **nfs4domain) {char *txtname =NFS4DNSTXTREC ; -char *msg, *answ, *eom, *mptr; +unsigned char *msg, *eom, *mptr; +char *answ;int len, status =-1 ;HEADER *hdr;
@@ -323,7 +324,8 @@ out:unload_plugins (plgns);return ret; } -void nfs4_cleanup_name_mapping () + +void nfs4_cleanup_name_mapping (void ) {if (nfs4_plugins)unload_plugins (nfs4_plugins);
@@ -534,7 +536,7 @@ struct conf_list *get_local_realms(void) }int -nfs4_get_default_domain (char *server,char *domain,size_t len) +nfs4_get_default_domain (char *UNUSED (server ),char *domain,size_t len) {char *d =get_default_domain ();
support/nfsidmap/nfsidmap_internal.h +7 -0
@@ -70,3 +70,10 @@ extern nfs4_idmap_log_function_t idmap_log_func;/* Level zero always prints, others print depending on verbosity level */ #define IDMAP_LOG (LVL ,MSG ) \ do { if (LVL <= idmap_verbosity) (*idmap_log_func)MSG; } while (0) + +#ifdef __GNUC__ +#define UNUSED (foo) UNUSED_ ## foo __attribute__((__unused__)) +#else +#define UNUSED (foo) UNUSED_ ## foo +#endif +
support/nfsidmap/nss.c +3 -3
@@ -379,7 +379,7 @@ out:static int nss_gss_princ_to_ids (char *secname,char *princ,uid_t *uid,uid_t *gid, -extra_mapping_params **ex) +extra_mapping_params **UNUSED (ex )) {struct passwd *pw;int err =0 ;
@@ -429,7 +429,7 @@ out:int nss_gss_princ_to_grouplist (char *secname,char *princ,gid_t *groups,int *ngroups, -extra_mapping_params **ex) +extra_mapping_params **UNUSED (ex )) {struct passwd *pw;int ret = -EINVAL ;
@@ -462,7 +462,7 @@ struct trans_func nss_trans = { .gss_princ_to_grouplist = nss_gss_princ_to_grouplist, }; -struct trans_func *libnfsidmap_plugin_init () +struct trans_func *libnfsidmap_plugin_init (void ) {return (&nss_trans); }
support/nfsidmap/static.c +11 -9
@@ -92,7 +92,8 @@ static __inline__ u_int8_t gid_hash (gid_t gid) LIST_HEAD (uid_mappings, uid_mapping) uid_mappings[256]; LIST_HEAD (gid_mappings, gid_mapping) gid_mappings[256]; -static struct passwd *static_getpwnam (const char *name,const char *domain, +static struct passwd *static_getpwnam (const char *name, +const char *UNUSED (domain ),int *err_p) {struct passwd *pw;
@@ -142,8 +143,9 @@ err:return NULL ; } -static struct group *static_getgrnam (const char *name,const char *domain, -int *err_p) +static struct group *static_getgrnam (const char *name, +const char *UNUSED (domain ), +int *err_p) {struct group *gr;struct grbuf *buf;
@@ -194,7 +196,7 @@ err:static int static_gss_princ_to_ids (char *secname,char *princ,uid_t *uid,uid_t *gid, -extra_mapping_params **ex) +extra_mapping_params **UNUSED (ex )) {struct passwd *pw;int err;
@@ -216,7 +218,7 @@ static int static_gss_princ_to_ids(char *secname, char *princ,static int static_gss_princ_to_grouplist (char *secname,char *princ,gid_t *groups,int *ngroups, -extra_mapping_params **ex) +extra_mapping_params **UNUSED (ex )) {struct passwd *pw;int err;
@@ -266,7 +268,7 @@ static int static_name_to_gid(char *name, gid_t *gid)return -err; } -static int static_uid_to_name (uid_t uid,char *domain,char *name,size_t len) +static int static_uid_to_name (uid_t uid,char *UNUSED (domain ),char *name,size_t UNUSED (len )) {struct uid_mapping * um;
@@ -281,7 +283,7 @@ static int static_uid_to_name(uid_t uid, char *domain, char *name, size_t len)return -ENOENT ; } -static int static_gid_to_name (gid_t gid,char *domain,char *name,size_t len) +static int static_gid_to_name (gid_t gid,char *UNUSED (domain ),char *name,size_t UNUSED (len )) {struct gid_mapping * gm;
@@ -301,7 +303,7 @@ static int static_gid_to_name(gid_t gid, char *domain, char *name, size_t len)* uid_to_name functions will be fast enough. */ -static int static_init () { +static int static_init (void ) {int err;struct conf_list * princ_list =NULL ;struct conf_list_node * cln, *next;
@@ -404,7 +406,7 @@ struct trans_func static_trans = { .gss_princ_to_grouplist = static_gss_princ_to_grouplist, }; -struct trans_func *libnfsidmap_plugin_init () +struct trans_func *libnfsidmap_plugin_init (void ) {return (&static_trans); }
support/nfsidmap/umich_ldap.c +6 -5
@@ -970,7 +970,8 @@ out:*/ static int umichldap_gss_princ_to_ids (char *secname,char *principal, -uid_t *uid,gid_t *gid,extra_mapping_params **ex) +uid_t *uid,gid_t *gid, +extra_mapping_params **UNUSED (ex )) {uid_t rtnd_uid =-1 ;gid_t rtnd_gid =-1 ;
@@ -1012,20 +1013,20 @@ umichldap_name_to_gid(char *name, gid_t *gid) }static int -umichldap_uid_to_name (uid_t uid,char *domain,char *name,size_t len) +umichldap_uid_to_name (uid_t uid,char *UNUSED (domain ),char *name,size_t len) {return umich_id_to_name (uid,IDTYPE_USER , &name, len, &ldap_info); }static int -umichldap_gid_to_name (gid_t gid,char *domain,char *name,size_t len) +umichldap_gid_to_name (gid_t gid,char *UNUSED (domain ),char *name,size_t len) {return umich_id_to_name (gid,IDTYPE_GROUP , &name, len, &ldap_info); }static int umichldap_gss_princ_to_grouplist (char *secname,char *principal, -gid_t *groups,int *ngroups,extra_mapping_params **ex) +gid_t *groups,int *ngroups,extra_mapping_params **UNUSED (ex )) {int err = -EINVAL ;
@@ -1296,7 +1297,7 @@ struct trans_func umichldap_trans = { .gss_princ_to_grouplist = umichldap_gss_princ_to_grouplist, }; -struct trans_func *libnfsidmap_plugin_init () +struct trans_func *libnfsidmap_plugin_init (void ) {return (&umichldap_trans); }
Signature · 1 line
1.8.3.1
Quoted 10 lines · Justin Mitchell
It was suggested that merging the trees is more desirable than splitting the common code out into a shared library, so this patch set attempts to merge the libnfsidmap code into nfs-utils.
The main body of the code, copyright notices, and readme are copied across, omitting the shared conffile code, and trimming unused files like
strlcpy.candqueue.h. The build files of both are adjusted to the new structure, and the dependent nfs-utils now link to the included shared library instead of an external one.
Quoted 6 lines
The source libnfsidmap tree did include some packaging files for debian/dkpg which have been omitted, there are no packaging materials in nfs-utils to merge them with, and i welcome advice on what should be done here.
Change: libnfsidmap imported as support/nfsidmap/
A quick status on this... I'm working on this but this patch is going to cause a packaging nightmare... since the libnfsidmap package is required by nfs-utils which now is installing that lib... so this might take some time...
steved.
Quoted 61 lines
Justin Mitchell (7):
nfs-utils: const-ify the config handling functions
nfs-utils: Mergeconf_get_strandconf_get_section
nfs-utils: Addget_strwith default value
nfs-utils: split conffile to a separate convenience lib
nfs-utils: Import libnfsidmap codebase integrate libnfsidmap code with rest of nfs-utils
nfs-utils: cleanup warnings from merged libnfsidmap codeconfigure.ac | 50 +- support/Makefile.am | 8 +- support/include/conffile.h | 23 +- support/nfs/Makefile.am | 13 +- support/nfs/conffile.c | 85 +-- support/nfs/xlog.c | 2 + support/nfsidmap/AUTHORS | 1 + support/nfsidmap/COPYING | 30 + support/nfsidmap/Makefile.am | 61 ++ support/nfsidmap/README | 126 ++++ support/nfsidmap/gums.c | 788 ++++++++++++++++++++ support/nfsidmap/idmapd.conf | 137 ++++ support/nfsidmap/idmapd.conf.5 | 308 ++++++++ support/nfsidmap/libnfsidmap.c | 712 +++++++++++++++++++ support/nfsidmap/libnfsidmap.pc.in | 11 + support/nfsidmap/libtest.c | 160 +++++ support/nfsidmap/nfs4_uid_to_name.3 | 174 +++++ support/nfsidmap/nfsidmap.h | 67 ++ support/nfsidmap/nfsidmap_internal.h | 79 +++ support/nfsidmap/nss.c | 468 ++++++++++++ support/nfsidmap/static.c | 413 +++++++++++ support/nfsidmap/umich_ldap.c | 1303 ++++++++++++++++++++++++++++++++++ utils/Makefile.am | 2 - utils/blkmapd/Makefile.am | 2 +- utils/exportfs/Makefile.am | 2 +- utils/gssd/Makefile.am | 7 +- utils/idmapd/Makefile.am | 4 +- utils/mount/Makefile.am | 2 +- utils/mountd/Makefile.am | 2 +- utils/nfsd/Makefile.am | 2 +- utils/nfsdcltrack/Makefile.am | 2 +- utils/nfsidmap/Makefile.am | 4 +- utils/statd/Makefile.am | 4 +- 33 files changed, 4973 insertions(+), 79 deletions(-) create mode 100644 support/nfsidmap/AUTHORS create mode 100644 support/nfsidmap/COPYING create mode 100644 support/nfsidmap/Makefile.am create mode 100644 support/nfsidmap/README create mode 100644 support/nfsidmap/gums.c create mode 100644 support/nfsidmap/idmapd.conf create mode 100644 support/nfsidmap/idmapd.conf.5 create mode 100644 support/nfsidmap/libnfsidmap.c create mode 100644 support/nfsidmap/libnfsidmap.pc.in create mode 100644 support/nfsidmap/libtest.c create mode 100644 support/nfsidmap/nfs4_uid_to_name.3 create mode 100644 support/nfsidmap/nfsidmap.h create mode 100644 support/nfsidmap/nfsidmap_internal.h create mode 100644 support/nfsidmap/nss.c create mode 100644 support/nfsidmap/static.c create mode 100644 support/nfsidmap/umich_ldap.c
Quoted 18 lines · Steve Dickson
Quoted 15 lines · Justin Mitchell
It was suggested that merging the trees is more desirable than splitting the common code out into a shared library, so this patch set attempts to merge the libnfsidmap code into nfs-utils.
The main body of the code, copyright notices, and readme are copied across, omitting the shared conffile code, and trimming unused files like
strlcpy.candqueue.h. The build files of both are adjusted to the new structure, and the dependent nfs-utils now link to the included shared library instead of an external one.The source libnfsidmap tree did include some packaging files for debian/dkpg which have been omitted, there are no packaging materials in nfs-utils to merge them with, and i welcome advice on what should be done here.
Quoted 5 lines
Quoted 1 line
Change: libnfsidmap imported as support/nfsidmap/
A quick status on this... I'm working on this but this patch is going to cause a packaging nightmare... since the libnfsidmap package is required by nfs-utils which now is installing that lib... so this might take some time...
Would it help to start by keeping the separate libnfsidmap rpm, but just building it from nfs-utils instead of from separate source?
--b.
Quoted 19 lines · J. Bruce Fields
Quoted 18 lines · Steve Dickson
Quoted 15 lines · Justin Mitchell
It was suggested that merging the trees is more desirable than splitting the common code out into a shared library, so this patch set attempts to merge the libnfsidmap code into nfs-utils.
The main body of the code, copyright notices, and readme are copied across, omitting the shared conffile code, and trimming unused files like
strlcpy.candqueue.h. The build files of both are adjusted to the new structure, and the dependent nfs-utils now link to the included shared library instead of an external one.The source libnfsidmap tree did include some packaging files for debian/dkpg which have been omitted, there are no packaging materials in nfs-utils to merge them with, and i welcome advice on what should be done here.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Change: libnfsidmap imported as support/nfsidmap/
A quick status on this... I'm working on this but this patch is going to cause a packaging nightmare... since the libnfsidmap package is required by nfs-utils which now is installing that lib... so this might take some time...
Would it help to start by keeping the separate libnfsidmap rpm, but just building it from nfs-utils instead of from separate source?
The BuildRequires for libnfsidmap is no longer necessary, as when you configure and build nfs-utils from the top it will automatically build and link to the merged libnfsidmap code.
I would expect then to list libnfsidmap as a sub-package within the nfs-utils spec file so that the end result is the same set of rpms out as we had before the merge.
Neither source tree contained any rpm packaging materials otherwise I would have adjusted and tested it as part of the patch set.
Quoted 10 lines · Justin Mitchell
It was suggested that merging the trees is more desirable than splitting the common code out into a shared library, so this patch set attempts to merge the libnfsidmap code into nfs-utils.
The main body of the code, copyright notices, and readme are copied across, omitting the shared conffile code, and trimming unused files like
strlcpy.candqueue.h. The build files of both are adjusted to the new structure, and the dependent nfs-utils now link to the included shared library instead of an external one.
Quoted 6 lines
The source libnfsidmap tree did include some packaging files for debian/dkpg which have been omitted, there are no packaging materials in nfs-utils to merge them with, and i welcome advice on what should be done here.
Change: libnfsidmap imported as support/nfsidmap/
Committed...
steved.
Quoted 61 lines
Justin Mitchell (7):
nfs-utils: const-ify the config handling functions
nfs-utils: Mergeconf_get_strandconf_get_section
nfs-utils: Addget_strwith default value
nfs-utils: split conffile to a separate convenience lib
nfs-utils: Import libnfsidmap codebase integrate libnfsidmap code with rest of nfs-utils
nfs-utils: cleanup warnings from merged libnfsidmap codeconfigure.ac | 50 +- support/Makefile.am | 8 +- support/include/conffile.h | 23 +- support/nfs/Makefile.am | 13 +- support/nfs/conffile.c | 85 +-- support/nfs/xlog.c | 2 + support/nfsidmap/AUTHORS | 1 + support/nfsidmap/COPYING | 30 + support/nfsidmap/Makefile.am | 61 ++ support/nfsidmap/README | 126 ++++ support/nfsidmap/gums.c | 788 ++++++++++++++++++++ support/nfsidmap/idmapd.conf | 137 ++++ support/nfsidmap/idmapd.conf.5 | 308 ++++++++ support/nfsidmap/libnfsidmap.c | 712 +++++++++++++++++++ support/nfsidmap/libnfsidmap.pc.in | 11 + support/nfsidmap/libtest.c | 160 +++++ support/nfsidmap/nfs4_uid_to_name.3 | 174 +++++ support/nfsidmap/nfsidmap.h | 67 ++ support/nfsidmap/nfsidmap_internal.h | 79 +++ support/nfsidmap/nss.c | 468 ++++++++++++ support/nfsidmap/static.c | 413 +++++++++++ support/nfsidmap/umich_ldap.c | 1303 ++++++++++++++++++++++++++++++++++ utils/Makefile.am | 2 - utils/blkmapd/Makefile.am | 2 +- utils/exportfs/Makefile.am | 2 +- utils/gssd/Makefile.am | 7 +- utils/idmapd/Makefile.am | 4 +- utils/mount/Makefile.am | 2 +- utils/mountd/Makefile.am | 2 +- utils/nfsd/Makefile.am | 2 +- utils/nfsdcltrack/Makefile.am | 2 +- utils/nfsidmap/Makefile.am | 4 +- utils/statd/Makefile.am | 4 +- 33 files changed, 4973 insertions(+), 79 deletions(-) create mode 100644 support/nfsidmap/AUTHORS create mode 100644 support/nfsidmap/COPYING create mode 100644 support/nfsidmap/Makefile.am create mode 100644 support/nfsidmap/README create mode 100644 support/nfsidmap/gums.c create mode 100644 support/nfsidmap/idmapd.conf create mode 100644 support/nfsidmap/idmapd.conf.5 create mode 100644 support/nfsidmap/libnfsidmap.c create mode 100644 support/nfsidmap/libnfsidmap.pc.in create mode 100644 support/nfsidmap/libtest.c create mode 100644 support/nfsidmap/nfs4_uid_to_name.3 create mode 100644 support/nfsidmap/nfsidmap.h create mode 100644 support/nfsidmap/nfsidmap_internal.h create mode 100644 support/nfsidmap/nss.c create mode 100644 support/nfsidmap/static.c create mode 100644 support/nfsidmap/umich_ldap.c