Misc fixes & cleanups for nfs-utils
Subsystems (2)
cover Misc fixes & cleanups for nfs-utils
Most of this work centers around gssd, however a few items I did tree wide. It's been compile tested with both gcc & clang on x86_64 & arm32 and runtime tested on x86_64.
Doug Nazar (10):
gssd: Refcount struct clnt_info to protect multithread usage Update to libevent 2.x apis.
gssd: Cleanup on exit to support valgrind.
gssd: gssd_k5_err_msg() returns a strdup'd msg. Use free() to release.
gssd: Fix locking for machine principal list
gssd: Add a few debug statements to help track client_info lifetimes.
gssd: Lookup local hostname when srchost is '*'
gssd: We never use the nocache param of gssd_check_if_cc_exists() Cleanup printf format attribute handling and fix format strings Fix various clang warnings.
aclocal/libevent.m4 | 6 +- configure.ac | 6 +- support/include/compiler.h | 14 + support/include/xcommon.h | 12 +- support/include/xlog.h | 20 +- support/nfs/xcommon.c | 2 + support/nfsidmap/gums.c | 2 + support/nfsidmap/libnfsidmap.c | 8 +- support/nfsidmap/nfsidmap.h | 10 +- support/nfsidmap/nfsidmap_common.c | 1 + support/nfsidmap/nss.c | 4 +- support/nfsidmap/regex.c | 6 +- support/nfsidmap/static.c | 1 + support/nfsidmap/umich_ldap.c | 10 +- tools/locktest/testlk.c | 6 +- utils/exportfs/exportfs.c | 5 +- utils/gssd/err_util.h | 4 +- utils/gssd/gss_names.c | 9 +- utils/gssd/gss_util.c | 2 +- utils/gssd/gssd.c | 165 ++++++++--- utils/gssd/gssd.h | 10 +- utils/gssd/gssd_proc.c | 14 +- utils/gssd/krb5_util.c | 422 +++++++++++++++++------------ utils/gssd/krb5_util.h | 16 +- utils/gssd/svcgssd.c | 4 +- utils/gssd/svcgssd_proc.c | 9 +- utils/idmapd/idmapd.c | 65 +++-- utils/mount/network.c | 4 +- utils/mount/stropts.c | 2 - utils/mountd/cache.c | 2 +- utils/nfsdcld/cld-internal.h | 2 +- utils/nfsdcld/nfsdcld.c | 29 +- utils/nfsdcld/sqlite.c | 1 - utils/nfsdcltrack/sqlite.c | 2 +- utils/nfsidmap/nfsidmap.c | 3 +- 35 files changed, 536 insertions(+), 342 deletions(-) create mode 100644 support/include/compiler.h
Signature · 1 line
2.26.2
PATCH 1/10 gssd: Refcount struct clnt_info to protect multithread usage
Struct clnt_info is shared with the various upcall threads so we need to ensure that it stays around even if the client dir gets removed.
--- utils/gssd/gssd.c | 67 ++++++++++++++++++++++++++++++++---------- utils/gssd/gssd.h | 5 ++-- utils/gssd/gssd_proc.c | 4 +-- 3 files changed, 55 insertions(+), 21 deletions(-)
utils/gssd/gssd.c +51 -16
@@ -90,9 +90,7 @@ char *ccachedir = NULL;/* Avoid DNS reverse lookups on server names */ static bool avoid_dns = true;static bool use_gssproxy = false; -int thread_started = false; -pthread_mutex_t pmutex =PTHREAD_MUTEX_INITIALIZER ; -pthread_cond_t pcond =PTHREAD_COND_INITIALIZER ; +pthread_mutex_t clp_lock =PTHREAD_MUTEX_INITIALIZER ; TAILQ_HEAD(topdir_list_head, topdir) topdir_list;
@@ -359,20 +357,28 @@ out:free (port); } +/* Actually frees clp and fields that might be used from other +* threads if was last reference. +*/ static void -gssd_destroy_client (struct clnt_info *clp) +gssd_free_client (struct clnt_info *clp) { -if (clp->krb5_fd >=0 ) { +int refcnt; + +pthread_mutex_lock (&clp_lock); + refcnt = --clp->refcount; +pthread_mutex_unlock (&clp_lock); +if (refcnt >0 ) +return ; + +printerr (3 ,"freeing client %s\n" , clp->relpath); + +if (clp->krb5_fd >=0 )close (clp->krb5_fd); -event_del (&clp->krb5_ev); - } -if (clp->gssd_fd >=0 ) { +if (clp->gssd_fd >=0 )close (clp->gssd_fd); -event_del (&clp->gssd_ev); - } -inotify_rm_watch (inotify_fd, clp->wd);free (clp->relpath);free (clp->servicename);free (clp->servername);
@@ -380,6 +386,24 @@ gssd_destroy_client(struct clnt_info *clp)free (clp); } +/* Called when removing from clnt_list to tear down event handling. +* Will then free clp if was last reference. +*/ +static void +gssd_destroy_client (struct clnt_info *clp) +{ +printerr (3 ,"destroying client %s\n" , clp->relpath); + +if (clp->krb5_fd >=0 ) +event_del (&clp->krb5_ev); + +if (clp->gssd_fd >=0 ) +event_del (&clp->gssd_ev); + +inotify_rm_watch (inotify_fd, clp->wd); +gssd_free_client (clp); +} +static void gssd_scan (void ); static int
@@ -416,11 +440,21 @@ static struct clnt_upcall_info *alloc_upcall_info(struct clnt_info *clp) info =malloc (sizeof (struct clnt_upcall_info ));if (info ==NULL )return NULL ; + +pthread_mutex_lock (&clp_lock); + clp->refcount++; +pthread_mutex_unlock (&clp_lock); info->clp = clp;return info; } +void free_upcall_info (struct clnt_upcall_info *info) +{ +gssd_free_client (info->clp); +free (info); +} +/* For each upcall read the upcall info into the buffer, then create a * thread in a detached state so that resources are released back into * the system without the need for a join.
@@ -438,13 +472,13 @@ gssd_clnt_gssd_cb(int UNUSED(fd), short UNUSED(which), void *data) info->lbuflen =read (clp->gssd_fd, info->lbuf,sizeof (info->lbuf));if (info->lbuflen <=0 || info->lbuf[info->lbuflen-1 ] !='\n' ) {printerr (0 ,"WARNING: %s: failed reading request\n" , __func__); -free (info); +free_upcall_info (info);return ; } info->lbuf[info->lbuflen-1 ] =0 ;if (start_upcall_thread (handle_gssd_upcall, info)) -free (info); +free_upcall_info (info); } static void
@@ -461,12 +495,12 @@ gssd_clnt_krb5_cb(int UNUSED(fd), short UNUSED(which), void *data) sizeof(info->uid)) < (ssize_t)sizeof(info->uid)) {printerr (0 ,"WARNING: %s: failed reading uid from krb5 " "upcall pipe: %s\n" , __func__,strerror (errno)); -free (info); +free_upcall_info (info);return ; }if (start_upcall_thread (handle_krb5_upcall, info)) -free (info); +free_upcall_info (info); } static struct clnt_info *
@@ -501,6 +535,7 @@ gssd_get_clnt(struct topdir *tdi, const char *name) clp->name = clp->relpath +strlen (tdi->name) +1 ; clp->krb5_fd =-1 ; clp->gssd_fd =-1 ; + clp->refcount =1 ;TAILQ_INSERT_HEAD (&tdi->clnt_list, clp, list);return clp;
@@ -651,7 +686,7 @@ gssd_scan_topdir(const char *name)if (clp->scanned)continue ; -printerr (3 ,"destroying client %s\n" , clp->relpath); +printerr (3 ,"orphaned client %s\n" , clp->relpath); saveprev = clp->list.tqe_prev;TAILQ_REMOVE (&tdi->clnt_list, clp, list);gssd_destroy_client (clp);
utils/gssd/gssd.h +2 -3
@@ -63,12 +63,10 @@ extern unsigned int context_timeout;extern unsigned int rpc_timeout;extern char *preferred_realm;extern pthread_mutex_t ple_lock; -extern pthread_cond_t pcond; -extern pthread_mutex_t pmutex; -extern int thread_started;struct clnt_info {TAILQ_ENTRY (clnt_info) list; +int refcount;int wd;bool scanned;char *name;
@@ -94,6 +92,7 @@ struct clnt_upcall_info {void handle_krb5_upcall (struct clnt_upcall_info *clp);void handle_gssd_upcall (struct clnt_upcall_info *clp); +void free_upcall_info (struct clnt_upcall_info *info);#endif /* _RPC_GSSD_H_ */
utils/gssd/gssd_proc.c +2 -2
@@ -730,7 +730,7 @@ handle_krb5_upcall(struct clnt_upcall_info *info)printerr (2 ,"\n%s: uid %d (%s)\n" , __func__, info->uid, clp->relpath);process_krb5_upcall (clp, info->uid, clp->krb5_fd,NULL ,NULL ,NULL ); -free (info); +free_upcall_info (info); }void
@@ -830,6 +830,6 @@ handle_gssd_upcall(struct clnt_upcall_info *info) out:free (upcall_str); out_nomem: -free (info); +free_upcall_info (info);return ; }
Signature · 1 line
2.26.2
PATCH 2/10 Update to libevent 2.x apis.
In reply to Doug Nazar--- aclocal/libevent.m4 | 6 ++-- utils/gssd/gssd.c | 58 +++++++++++++++++++++------------ utils/gssd/gssd.h | 4 +-- utils/idmapd/idmapd.c | 62 ++++++++++++++++++++---------------- utils/nfsdcld/cld-internal.h | 2 +- utils/nfsdcld/nfsdcld.c | 29 +++++++++-------- utils/nfsdcld/sqlite.c | 1 - utils/nfsdcltrack/sqlite.c | 2 +- 8 files changed, 94 insertions(+), 70 deletions(-)
aclocal/libevent.m4 +3 -3
@@ -1,12 +1,12 @@ dnl Checks for libevent AC_DEFUN([AC_LIBEVENT], [ - dnl Check for libevent, but do not add -levent to LIBS - AC_CHECK_LIB([event], [event_dispatch], [LIBEVENT=-levent], + dnl Check for libevent, but do not add -levent_core to LIBS + AC_CHECK_LIB([event_core], [event_base_dispatch], [LIBEVENT=-levent_core], [AC_MSG_ERROR([libevent not found.])]) AC_SUBST(LIBEVENT) - AC_CHECK_HEADERS([event.h], , + AC_CHECK_HEADERS([event2/event.h], , [AC_MSG_ERROR([libevent headers not found.])]) ])dnl
utils/gssd/gssd.c +37 -21
125 lines not on this page · raw message
utils/gssd/gssd.h +2 -2
@@ -77,9 +77,9 @@ struct clnt_info {int vers;char *protocol;int krb5_fd; -struct event krb5_ev; +struct event *krb5_ev;int gssd_fd; -struct event gssd_ev; +struct event *gssd_ev;struct sockaddr_storage addr; };
utils/idmapd/idmapd.c +34 -28
149 lines not on this page · raw message
utils/nfsdcld/cld-internal.h +1 -1
@@ -26,7 +26,7 @@struct cld_client {int cl_fd; -struct event cl_event; +struct event *cl_event;union {struct cld_msg cl_msg;#if UPCALL_VERSION >=2
utils/nfsdcld/nfsdcld.c +16 -13
@@ -24,7 +24,7 @@#endif /* HAVE_CONFIG_H */ #include <errno.h> -#include <event.h> +#include <event2/event.h> #include <stdbool.h> #include <getopt.h> #include <string.h>
@@ -66,7 +66,8 @@static char pipefs_dir[PATH_MAX ] =DEFAULT_PIPEFS_DIR ;static char pipepath[PATH_MAX ];static int inotify_fd =-1 ; -static struct event pipedir_event; +static struct event *pipedir_event; +static struct event_base *evbase;static bool old_kernel = false;uint64_t current_epoch;
@@ -149,13 +150,15 @@ cld_pipe_open(struct cld_client *clnt)return -errno; } -if (event_initialized (&clnt->cl_event)) -event_del (&clnt->cl_event); +if (clnt->cl_event &&event_initialized (clnt->cl_event)) { +event_del (clnt->cl_event); +event_free (clnt->cl_event); + }if (clnt->cl_fd >=0 )close (clnt->cl_fd); clnt->cl_fd = fd; -event_set (&clnt->cl_event, clnt->cl_fd,EV_READ , cldcb, clnt); + clnt->cl_event =event_new (evbase, clnt->cl_fd,EV_READ , cldcb, clnt);/* event_add is done by the caller */ return 0 ; }
@@ -208,7 +211,7 @@ cld_inotify_cb(int UNUSED(fd), short which, void *data)switch (ret) {case 0 :/* readd the event for the cl_event pipe */ -event_add (&clnt->cl_event,NULL ); +event_add (clnt->cl_event,NULL );break ;case -ENOENT :/* pipe must have disappeared, wait for it to come back */
@@ -221,7 +224,7 @@ cld_inotify_cb(int UNUSED(fd), short which, void *data) } out: -event_add (&pipedir_event,NULL ); +event_add (pipedir_event,NULL );free (dirc); }
@@ -286,7 +289,7 @@ cld_pipe_init(struct cld_client *clnt)switch (ret) {case 0 :/* add the event and we're good to go */ -event_add (&clnt->cl_event,NULL ); +event_add (clnt->cl_event,NULL );break ;case -ENOENT :/* ignore this error -- cld_inotify_cb will handle it */
@@ -299,8 +302,8 @@ cld_pipe_init(struct cld_client *clnt) }/* set event for inotify read */ -event_set (&pipedir_event, inotify_fd,EV_READ , cld_inotify_cb, clnt); -event_add (&pipedir_event,NULL ); + pipedir_event =event_new (evbase, inotify_fd,EV_READ , cld_inotify_cb, clnt); +event_add (pipedir_event,NULL ); out:return ret; }
@@ -737,7 +740,7 @@ cldcb(int UNUSED(fd), short which, void *data)cld_not_implemented (clnt); } out: -event_add (&clnt->cl_event,NULL ); +event_add (clnt->cl_event,NULL ); }int
@@ -762,7 +765,7 @@ main(int argc, char **argv)return 1 ; } -event_init (); + evbase =event_base_new ();xlog_syslog (0 );xlog_stderr (1 );
@@ -860,7 +863,7 @@ main(int argc, char **argv) goto out;xlog (D_GENERAL ,"%s: Starting event dispatch handler." , __func__); - rc =event_dispatch (); + rc =event_base_dispatch (evbase);if (rc <0 )xlog (L_ERROR ,"%s: event_dispatch failed: %m" , __func__);
utils/nfsdcld/sqlite.c +0 -1
@@ -48,7 +48,6 @@#include <dirent.h> #include <errno.h> -#include <event.h> #include <stdbool.h> #include <string.h> #include <sys/stat.h>
utils/nfsdcltrack/sqlite.c +1 -1
@@ -40,7 +40,7 @@#include <dirent.h> #include <errno.h> -#include <event.h> +#include <stdio.h> #include <stdbool.h> #include <string.h> #include <sys/stat.h>
Signature · 1 line
2.26.2
PATCH 3/10 gssd: Cleanup on exit to support valgrind.
In reply to Doug Nazar--- utils/gssd/gssd.c | 46 +++++++++++++++++++++++++++++++------ utils/gssd/krb5_util.c | 52 ++++++++++++++++++++++++------------------ utils/gssd/krb5_util.h | 2 +- 3 files changed, 70 insertions(+), 30 deletions(-)
utils/gssd/gssd.c +39 -7
@@ -91,6 +91,7 @@ char *ccachedir = NULL;static bool avoid_dns = true;static bool use_gssproxy = false;pthread_mutex_t clp_lock =PTHREAD_MUTEX_INITIALIZER ; +static bool signal_received = false;static struct event_base *evbase =NULL ; TAILQ_HEAD(topdir_list_head, topdir) topdir_list;
@@ -872,10 +873,16 @@ found:static void sig_die (int signal) { -if (root_uses_machine_creds) -gssd_destroy_krb5_machine_creds (); +if (signal_received) + { +gssd_destroy_krb5_principals (root_uses_machine_creds); +printerr (1 ,"forced exiting on signal %d\n" , signal); +exit (0 ); + } + + signal_received = true;printerr (1 ,"exiting on signal %d\n" , signal); -exit (0 ); +event_base_loopexit (evbase,NULL ); } static void
@@ -932,6 +939,7 @@ main(int argc, char *argv[])int rpc_verbosity =0 ;int opt;int i; +int rc;extern char *optarg;char *progname;struct event *sighup_ev;
@@ -1109,9 +1117,33 @@ main(int argc, char *argv[])gssd_scan ();daemon_ready (); -event_base_dispatch (evbase); + rc =event_base_dispatch (evbase); -printerr (0 ,"ERROR: event_dispatch() returned!\n" ); -return EXIT_FAILURE ; -} +printerr (0 ,"event_dispatch() returned %i!\n" , rc); +gssd_destroy_krb5_principals (root_uses_machine_creds); + +while (!TAILQ_EMPTY (&topdir_list)) { +struct topdir *tdi =TAILQ_FIRST (&topdir_list); +TAILQ_REMOVE (&topdir_list, tdi, list); +while (!TAILQ_EMPTY (&tdi->clnt_list)) { +struct clnt_info *clp =TAILQ_FIRST (&tdi->clnt_list); +TAILQ_REMOVE (&tdi->clnt_list, clp, list); +gssd_destroy_client (clp); + } +free (tdi); + } + +event_free (inotify_ev); +event_free (sighup_ev); +event_base_free (evbase); + +close (inotify_fd); +close (pipefs_fd); +closedir (pipefs_dir); + +free (preferred_realm); +free (ccachesearch); + +return rc <0 ?EXIT_FAILURE :EXIT_SUCCESS ; +}
utils/gssd/krb5_util.c +30 -22
70 lines not on this page · raw message
utils/gssd/krb5_util.h +1 -1
@@ -27,7 +27,7 @@ int gssd_setup_krb5_user_gss_ccache(uid_t uid, char *servername, char *dirname);int gssd_get_krb5_machine_cred_list (char ***list);void gssd_free_krb5_machine_cred_list (char **list); -void gssd_destroy_krb5_machine_creds (void ); +void gssd_destroy_krb5_principals (int destroy_machine_creds);int gssd_refresh_krb5_machine_credential (char *hostname,struct gssd_k5_kt_princ *ple,char *service,char *srchost);
Signature · 1 line
2.26.2
PATCH 4/10 gssd: gssd_k5_err_msg() returns a strdup'd msg. Use free() to release.
In reply to Doug Nazar--- utils/gssd/krb5_util.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
utils/gssd/krb5_util.c +7 -7
@@ -484,7 +484,7 @@ gssd_get_single_krb5_cred(krb5_context context,if (ccache)krb5_cc_close (context, ccache);krb5_free_cred_contents (context, &my_creds); -krb5_free_string (context, k5err); +free (k5err);return (code); }
@@ -723,7 +723,7 @@ gssd_search_krb5_keytab(krb5_context context, krb5_keytab kt,"we failed to unparse principal name: %s\n" , k5err);k5_free_kt_entry (context, kte); -krb5_free_string (context, k5err); +free (k5err); k5err =NULL ;continue ; }
@@ -770,7 +770,7 @@ gssd_search_krb5_keytab(krb5_context context, krb5_keytab kt,if (retval <0 ) retval =0 ; out: -krb5_free_string (context, k5err); +free (k5err);return retval; }
@@ -927,7 +927,7 @@ find_keytab_entry(krb5_context context, krb5_keytab kt, k5err =gssd_k5_err_msg (context, code);printerr (1 ,"%s while building principal for '%s'\n" , k5err, spn); -krb5_free_string (context, k5err); +free (k5err); k5err =NULL ;continue ; }
@@ -937,7 +937,7 @@ find_keytab_entry(krb5_context context, krb5_keytab kt, k5err =gssd_k5_err_msg (context, code);printerr (3 ,"%s while getting keytab entry for '%s'\n" , k5err, spn); -krb5_free_string (context, k5err); +free (k5err); k5err =NULL ;/* * We tried the active directory machine account
@@ -986,7 +986,7 @@ out:k5_free_default_realm (context, default_realm);if (realmnames)krb5_free_host_realm (context, realmnames); -krb5_free_string (context, k5err); +free (k5err);return retval; }
@@ -1355,7 +1355,7 @@ out_free_kt: out_free_context:krb5_free_context (context); out: -krb5_free_string (context, k5err); +free (k5err);return retval; }
Signature · 1 line
2.26.2
Re: [PATCH 04/10] gssd: gssd_k5_err_msg() returns a ". Use free() to release.
Hello,
Quoted 65 lines · Doug Nazar
Signed-off-by Doug Nazar <[email protected]>--- utils/gssd/krb5_util.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)utils/gssd/krb5_util.c +6
-6@@ -484,7 +484,7 @@ gssd_get_single_krb5_cred(krb5_context context,if (ccache)krb5_cc_close (context, ccache);krb5_free_cred_contents (context, &my_creds); -krb5_free_string (context, k5err); +free (k5err);return (code); }@@ -723,7 +723,7 @@ gssd_search_krb5_keytab(krb5_context context, krb5_keytab kt,"we failed to unparse principal name: %s\n" , k5err);k5_free_kt_entry (context, kte); -krb5_free_string (context, k5err); +free (k5err); k5err =NULL ;continue ; }@@ -770,7 +770,7 @@ gssd_search_krb5_keytab(krb5_context context, krb5_keytab kt,if (retval <0 ) retval =0 ; out: -krb5_free_string (context, k5err); +free (k5err);return retval; }@@ -927,7 +927,7 @@ find_keytab_entry(krb5_context context, krb5_keytab kt, k5err =gssd_k5_err_msg (context, code);printerr (1 ,"%s while building principal for '%s'\n" , k5err, spn); -krb5_free_string (context, k5err); +free (k5err); k5err =NULL ;continue ; }@@ -937,7 +937,7 @@ find_keytab_entry(krb5_context context, krb5_keytab kt, k5err =gssd_k5_err_msg (context, code);printerr (3 ,"%s while getting keytab entry for '%s'\n" , k5err, spn); -krb5_free_string (context, k5err); +free (k5err); k5err =NULL ;/* * We tried the active directory machine account @@ -986,7 +986,7 @@ out:k5_free_default_realm (context, default_realm);if (realmnames)krb5_free_host_realm (context, realmnames); -krb5_free_string (context, k5err); +free (k5err);return retval; }
utils/gssd/krb5_util.c out_free_kt: · line 1361
Quoted 8 lines
utils/gssd/krb5_util.c +1
-1@@ -1355,7 +1355,7 @@ out_free_kt: out_free_context:krb5_free_context (context); out: -krb5_free_string (context, k5err); +free (k5err);return retval; }
I'm curious about these changes... since all krb5_free_string() does is call free()... where is the "strdup'd msg" coming from?
steved.
Re: [PATCH 04/10] gssd: gssd_k5_err_msg() returns a ". Use free() to release.
Quoted 2 lines · Steve Dickson
I'm curious about these changes... since all
krb5_free_string()does is callfree()... where is the "strdup'd msg" coming from?
gssd_k5_err_msg() always returns a local strdup() of the error message. We shouldn't be using a Kerberos library method to free them. There's no guarantee that the library won't change, or even that the library was compiled with the same malloc library.
Doug
Re: [PATCH 04/10] gssd: gssd_k5_err_msg() returns a ". Use free() to release.
Quoted 5 lines · Doug Nazar
Quoted 2 lines · Steve Dickson
I'm curious about these changes... since all
krb5_free_string()does is callfree()... where is the "strdup'd msg" coming from?
gssd_k5_err_msg()always returns a localstrdup()of the error message.
True...
Quoted 1 line
We shouldn't be using a Kerberos library method to free them. There's no guarantee that the library won't change,
I guess I'm not too worry about this... I would the change was for the better. and lets face the krb5 has not changed in a 100 years ;-)
Quoted 1 line
or even that the library was compiled with the same malloc library.
There are different malloc libraries other than glibc?
steved.
Re: [PATCH 04/10] gssd: gssd_k5_err_msg() returns a ". Use free() to release.
Quoted 2 lines · Steve Dickson
or even that the library was compiled with the same malloc library. There are different malloc libraries other than glibc?
Not including the various libc implementations (dietlibc, klibc, uclibc) there are several specialized malloc libraries (dmalloc & jemalloc are the most common) that you can compile or link against. Usually since they replace malloc and friends everything works, but you can get into issues depending on order of linking and how you compile.
I recently put gssd though a few rounds of mallocfail, which allows you to progressive test every allocation point (during normal running) to ensure it's handled (instead of crashing). I've an updated patchset that fixes the event2 conversion to check for successful allocation and a couple other spots that crashed if the allocation failed.
I'm taking it a bit slower this time... kinda rushed the last patchset out the door since I was needed on another project. ;-)
Doug
PATCH 5/10 gssd: Fix locking for machine principal list
In reply to Doug NazarAdd missing locking for some scans of the global list. There was also no prevention of ple->ccname being changed concurrently so use the same lock to protect that. Reference counting was also added to ensure that the ple is not freed out from under us in the few places we now drop the lock while doing work.
--- utils/gssd/gssd.h | 1 - utils/gssd/gssd_proc.c | 2 +- utils/gssd/krb5_util.c | 294 ++++++++++++++++++++++++++--------------- utils/gssd/krb5_util.h | 14 -- 4 files changed, 185 insertions(+), 126 deletions(-)
utils/gssd/gssd.h +0 -1
@@ -62,7 +62,6 @@ extern int root_uses_machine_creds;extern unsigned int context_timeout;extern unsigned int rpc_timeout;extern char *preferred_realm; -extern pthread_mutex_t ple_lock;struct clnt_info {TAILQ_ENTRY (clnt_info) list;
utils/gssd/gssd_proc.c +1 -1
@@ -548,7 +548,7 @@ krb5_use_machine_creds(struct clnt_info *clp, uid_t uid, uid, tgtname); do { - gssd_refresh_krb5_machine_credential(clp->servername, NULL, + gssd_refresh_krb5_machine_credential(clp->servername, service, srchost); /* * Get a list of credential cache names and try each
utils/gssd/krb5_util.c +184 -110
405 lines not on this page · raw message
utils/gssd/krb5_util.h +0 -14
@@ -9,19 +9,6 @@#include "gss_oids.h" #endif -/* -* List of principals from our keytab that we -* will try to use to obtain credentials -* (known as a principal list entry (ple)) -*/ -struct gssd_k5_kt_princ { -struct gssd_k5_kt_princ *next; -krb5_principal princ; -char *ccname; -char *realm; -krb5_timestamp endtime; -}; -int gssd_setup_krb5_user_gss_ccache (uid_t uid,char *servername,char *dirname);
@@ -29,7 +16,6 @@ int gssd_get_krb5_machine_cred_list(char ***list);void gssd_free_krb5_machine_cred_list (char **list);void gssd_destroy_krb5_principals (int destroy_machine_creds);int gssd_refresh_krb5_machine_credential (char *hostname, -struct gssd_k5_kt_princ *ple,char *service,char *srchost);char *gssd_k5_err_msg (krb5_context context,krb5_error_code code);void gssd_k5_get_default_realm (char **def_realm);
Signature · 1 line
2.26.2
PATCH 6/10 gssd: Add a few debug statements to help track client_info lifetimes.
In reply to Doug Nazar--- utils/gssd/gssd.c | 4 ++++ 1 file changed, 4 insertions(+)
utils/gssd/gssd.c +4 -0
@@ -520,6 +520,8 @@ gssd_get_clnt(struct topdir *tdi, const char *name)if (!strcmp (clp->name, name))return clp; +printerr (3 ,"creating client %s/%s\n" , tdi->name, name); + clp =calloc (1 ,sizeof (struct clnt_info ));if (!clp) { printerr(0, "ERROR: can't malloc clnt_info: %s\n",
@@ -561,6 +563,8 @@ gssd_scan_clnt(struct clnt_info *clp)bool gssd_was_closed;bool krb5_was_closed; +printerr (3 ,"scanning client %s\n" , clp->relpath); + gssd_was_closed = clp->gssd_fd <0 ? true : false; krb5_was_closed = clp->krb5_fd <0 ? true : false;
Signature · 1 line
2.26.2
PATCH 7/10 gssd: Lookup local hostname when srchost is '*'
In reply to Doug NazarCurrently when we receive a '*' srchost, we scan our keytab for a matching host but of course none match. We then fall back to scanning for any service/realm match and eventually find our hostname. Let's lookup our hostname instead and quickly find our specific match.
--- utils/gssd/krb5_util.c | 52 ++++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 25 deletions(-)
utils/gssd/krb5_util.c +27 -25
@@ -757,6 +757,7 @@ gssd_search_krb5_keytab(krb5_context context, krb5_keytab kt, goto out; } +printerr (4 ,"Scanning keytab for %s/*@%s\n" , service, realm);while ((code =krb5_kt_next_entry (context, kt, kte, &cursor)) ==0 ) {if ((code =krb5_unparse_name (context, kte->principal, &pname))) {
@@ -853,43 +854,44 @@ find_keytab_entry(krb5_context context, krb5_keytab kt, goto out;/* Get full local hostname */ -if (srchost) { +if (srchost &&strcmp (srchost,"*" ) !=0 ) {strcpy (myhostname, srchost); - }else if (gethostname (myhostname,sizeof (myhostname)) ==-1 ) { - retval = errno; - k5err =gssd_k5_err_msg (context, retval); -printerr (1 ,"%s while getting local hostname\n" , k5err); - goto out; +strcpy (myhostad, myhostname); + }else { +/* Borrow myhostad for gethostname(), we need it later anyways */ +if (gethostname (myhostad,sizeof (myhostad)-1 ) ==-1 ) { + retval = errno; + k5err =gssd_k5_err_msg (context, retval); +printerr (1 ,"%s while getting local hostname\n" , k5err); + goto out; + } + retval =get_full_hostname (myhostad, myhostname,sizeof (myhostname)); +if (retval) { +/* Don't use myhostname */ + myhostname[0 ] =0 ; + } }/* Compute the active directory machine name HOST$ */ -krb5_appdefault_string (context,"nfs" ,NULL ,"ad_principal_name" , +krb5_appdefault_string (context,"nfs" ,NULL ,"ad_principal_name" , notsetstr, &adhostoverride);if (strcmp (adhostoverride, notsetstr) !=0 ) { -printerr (1 , -"AD host string overridden with \"%s\" from appdefaults\n" , +printerr (1 , +"AD host string overridden with \"%s\" from appdefaults\n" , adhostoverride); -/* No overflow: Windows cannot handle strings longer than 19 chars */ -strcpy (myhostad, adhostoverride); +/* No overflow: Windows cannot handle strings longer than 19 chars */ +strcpy (myhostad, adhostoverride); }else { -strcpy (myhostad, myhostname); -for (i =0 ; myhostad[i] !=0 ; ++i) { -if (myhostad[i] =='.' )break ; - } - myhostad[i] ='$' ; - myhostad[i+1 ] =0 ; +/* In this case, it's been pre-filled above */ +for (i =0 ; myhostad[i] !=0 ; ++i) { +if (myhostad[i] =='.' )break ; + } + myhostad[i] ='$' ; + myhostad[i+1 ] =0 ; }if (adhostoverride)krb5_free_string (context, adhostoverride); -if (!srchost) { - retval =get_full_hostname (myhostname, myhostname,sizeof (myhostname)); -if (retval) { -/* Don't use myhostname */ - myhostname[0 ] =0 ; - } - } - code =krb5_get_default_realm (context, &default_realm);if (code) { retval = code;
Signature · 1 line
2.26.2
PATCH 8/10 gssd: We never use the nocache param of gssd_check_if_cc_exists()
In reply to Doug Nazar--- utils/gssd/krb5_util.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
utils/gssd/krb5_util.c +5 -5
@@ -165,7 +165,7 @@ static int select_krb5_ccache(const struct dirent *d);static int gssd_find_existing_krb5_ccache (uid_t uid,char *dirname,const char **cctype,struct dirent **d);static int gssd_get_single_krb5_cred (krb5_context context, -krb5_keytab kt,struct gssd_k5_kt_princ *ple,int nocache); +krb5_keytab kt,struct gssd_k5_kt_princ *ple);static int query_krb5_ccache (const char * cred_cache,char **ret_princname,char **ret_realm);
@@ -380,8 +380,7 @@ gssd_check_if_cc_exists(struct gssd_k5_kt_princ *ple)static int gssd_get_single_krb5_cred (krb5_context context,krb5_keytab kt, -struct gssd_k5_kt_princ *ple, -int nocache) +struct gssd_k5_kt_princ *ple) {#ifdef HAVE_KRB5_GET_INIT_CREDS_OPT_SET_ADDRESSLESS krb5_get_init_creds_opt *init_opts =NULL ;
@@ -398,10 +397,11 @@ gssd_get_single_krb5_cred(krb5_context context,char *cache_type;char *pname =NULL ;char *k5err =NULL ; +int nocache =0 ;memset (&my_creds,0 ,sizeof (my_creds)); -if (!nocache && !use_memcache) +if (!use_memcache) nocache =gssd_check_if_cc_exists (ple);/* * Workaround for clock skew among NFS server, NFS client and KDC
@@ -1199,7 +1199,7 @@ gssd_refresh_krb5_machine_credential_internal(char *hostname, goto out_free_kt; } } - retval =gssd_get_single_krb5_cred (context, kt, ple,0 ); + retval =gssd_get_single_krb5_cred (context, kt, ple); out_free_kt:krb5_kt_close (context, kt); out_free_context:
Signature · 1 line
2.26.2
PATCH 9/10 Cleanup printf format attribute handling and fix format strings
In reply to Doug Nazar--- support/include/compiler.h | 14 ++++++++++++++ support/include/xcommon.h | 10 +--------- support/include/xlog.h | 20 ++++++-------------- support/nfs/xcommon.c | 2 ++ support/nfsidmap/gums.c | 2 ++ support/nfsidmap/libnfsidmap.c | 8 +++++--- support/nfsidmap/nfsidmap.h | 10 +++++++++- support/nfsidmap/nfsidmap_common.c | 1 + support/nfsidmap/nss.c | 4 +++- support/nfsidmap/regex.c | 6 ++++-- support/nfsidmap/static.c | 1 + support/nfsidmap/umich_ldap.c | 10 ++++++---- tools/locktest/testlk.c | 6 ++++-- utils/exportfs/exportfs.c | 5 ++--- utils/gssd/err_util.h | 4 +++- utils/gssd/gss_names.c | 9 +++++---- utils/gssd/gss_util.c | 2 +- utils/gssd/gssd_proc.c | 8 ++++---- utils/gssd/krb5_util.c | 12 ++++++++---- utils/gssd/svcgssd.c | 4 +++- utils/gssd/svcgssd_proc.c | 9 +++++---- utils/idmapd/idmapd.c | 3 ++- utils/nfsidmap/nfsidmap.c | 3 ++- 23 files changed, 93 insertions(+), 60 deletions(-) create mode 100644 support/include/compiler.h
support/include/compiler.h new file +14 -0
@@ -0,0 +1,14 @@ +#ifndef COMPILER_H +#define COMPILER_H + +#ifndef CONFIG_H +#include <config.h> +#endif + +#ifdef HAVE_FUNC_ATTRIBUTE_FORMAT +#define X_FORMAT (_x) __attribute__((__format__ _x)) +#else +#define X_FORMAT (_x) +#endif + +#endif
support/include/xcommon.h +1 -9
@@ -9,9 +9,7 @@#ifndef _XMALLOC_H#define _MALLOC_H -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif +#include "compiler.h" #include <sys/types.h> #include <fcntl.h>
@@ -29,12 +27,6 @@#define streq (s, t) (strcmp ((s), (t)) == 0) -#ifdef HAVE_FUNC_ATTRIBUTE_FORMAT -#define X_FORMAT (_x) __attribute__((__format__ _x)) -#else -#define X_FORMAT (_x) -#endif -/* Functions in sundries.c that are used in mount.c and umount.c */ char *canonicalize (const char *path); void nfs_error (const char *fmt, ...) X_FORMAT((printf, 1, 2));
support/include/xlog.h +6 -14
@@ -7,9 +7,7 @@#ifndef XLOG_H #define XLOG_H -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif +#include "compiler.h" #include <stdarg.h>
@@ -39,12 +37,6 @@ struct xlog_debugfac {int df_fac; }; -#ifdef HAVE_FUNC_ATTRIBUTE_FORMAT -#define XLOG_FORMAT (_x) __attribute__((__format__ _x)) -#else -#define XLOG_FORMAT (_x) -#endif -extern int export_errno;void xlog_open (char *progname);void xlog_stderr (int on);
@@ -53,10 +45,10 @@ void xlog_config(int fac, int on);void xlog_sconfig (char *,int on);void xlog_from_conffile (char *);int xlog_enabled (int fac); -void xlog(int fac, const char *fmt, ...) XLOG_FORMAT((printf, 2, 3)); -void xlog_warn(const char *fmt, ...) XLOG_FORMAT((printf, 1, 2)); -void xlog_err(const char *fmt, ...) XLOG_FORMAT((printf, 1, 2)); -void xlog_errno(int err, const char *fmt, ...) XLOG_FORMAT((printf, 2, 3)); -void xlog_backend(int fac, const char *fmt, va_list args) XLOG_FORMAT((printf, 2, 0)); +void xlog(int fac, const char *fmt, ...) X_FORMAT((printf, 2, 3)); +void xlog_warn(const char *fmt, ...) X_FORMAT((printf, 1, 2)); +void xlog_err(const char *fmt, ...) X_FORMAT((printf, 1, 2)); +void xlog_errno(int err, const char *fmt, ...) X_FORMAT((printf, 2, 3)); +void xlog_backend(int fac, const char *fmt, va_list args) X_FORMAT((printf, 2, 0));#endif /* XLOG_H */
support/nfs/xcommon.c +2 -0
@@ -98,7 +98,9 @@ nfs_error (const char *fmt, ...) { fmt2 =xstrconcat2 (fmt,"\n" );va_start (args, fmt); +#pragma GCC diagnostic ignored "-Wformat-nonliteral"vfprintf (stderr, fmt2, args); +#pragma GCC diagnostic warning "-Wformat-nonliteral"va_end (args);free (fmt2); }
support/nfsidmap/gums.c +2 -0
@@ -41,6 +41,8 @@#include <grp.h> #include <err.h> #include <syslog.h> + +#include "compiler.h" #include "nfsidmap.h" #include "nfsidmap_plugin.h"
support/nfsidmap/libnfsidmap.c +5 -3
@@ -57,6 +57,7 @@#include <arpa/nameser.h> #include <arpa/nameser_compat.h> +#include "compiler.h" #include "nfsidmap.h" #include "nfsidmap_private.h" #include "nfsidmap_plugin.h"
@@ -94,6 +95,7 @@ gid_t nobody_gid = (gid_t)-1;#endif /* Default logging fuction */ +X_FORMAT((__printf__, 1, 2))static void default_logger (const char *fmt, ...) {va_list vp;
@@ -258,7 +260,7 @@ static int load_translation_plugin(char *method, struct mapping_plugin *plgn) } trans =init_func ();if (trans ==NULL ) { -IDMAP_LOG (1 , ("libnfsidmap: Failed to initialize plugin %s" , +IDMAP_LOG (1 , ("libnfsidmap: %s failed to initialize plugin %s" ,PLUGIN_INIT_FUNC , plgname));dlclose (dl);return -1 ;
@@ -451,7 +453,7 @@ int nfs4_init_name_mapping(char *conffile) nobody_user, strerror(errno)));free (buf); }else -IDMAP_LOG (0 ,("libnfsidmap: Nobody-User: no memory : %s" , +IDMAP_LOG (0 ,("libnfsidmap: Nobody-User (%s): no memory : %s" , nobody_user,strerror (errno))); }
@@ -472,7 +474,7 @@ int nfs4_init_name_mapping(char *conffile) nobody_group, strerror(errno)));free (buf); }else -IDMAP_LOG (0 ,("libnfsidmap: Nobody-Group: no memory : %s" , +IDMAP_LOG (0 ,("libnfsidmap: Nobody-Group (%s): no memory : %s" , nobody_group,strerror (errno))); }
support/nfsidmap/nfsidmap.h +9 -1
@@ -35,6 +35,14 @@* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#ifndef X_FORMAT +# ifdef __GNUC__ +# define X_FORMAT (_x) __attribute__((__format__ _x)) +# else +# define X_FORMAT (_x) +# endif +#endif +/* XXX arbitrary */ #define NFS4_MAX_DOMAIN_LEN 512 typedef enum {
@@ -47,7 +55,7 @@ typedef struct _extra_mapping_params {int content_len; } extra_mapping_params; -typedef void (*nfs4_idmap_log_function_t )(const char *, ...); +typedef void (* nfs4_idmap_log_function_t)(const char *, ...) X_FORMAT((printf, 1, 2));int nfs4_init_name_mapping (char *conffile);int nfs4_get_default_domain (char *server,char *domain,size_t len);
support/nfsidmap/nfsidmap_common.c +1 -0
@@ -19,6 +19,7 @@#include <errno.h> #include <string.h> +#include "compiler.h" #include "nfsidmap.h" #include "nfsidmap_private.h" #include "nfsidmap_plugin.h"
support/nfsidmap/nss.c +3 -1
@@ -47,10 +47,12 @@#include <grp.h> #include <limits.h> #include <ctype.h> +#include <syslog.h> + +#include "compiler.h" #include "nfsidmap.h" #include "nfsidmap_plugin.h" #include "nfsidmap_private.h" -#include <syslog.h> static char *get_default_domain (void ) {
support/nfsidmap/regex.c +4 -2
@@ -44,6 +44,7 @@#include <err.h> #include <regex.h> +#include "compiler.h" #include "nfsidmap.h" #include "nfsidmap_plugin.h"
@@ -229,8 +230,9 @@ static struct group *regex_getgrnam(const char *name, const char *UNUSED(domain)if (err) { -IDMAP_LOG (4 , ("regexp_getgrnam: removing prefix '%s' (%d long) from group '%s'" , group_name_prefix, group_name_prefix_length, localgroup)); - groupname += group_name_prefix_length; +IDMAP_LOG (4 , ("regexp_getgrnam: removing prefix '%s' (%zd long) from group '%s'" , + group_name_prefix, group_name_prefix_length, localgroup)); + groupname += group_name_prefix_length; }else {
support/nfsidmap/static.c +1 -0
@@ -41,6 +41,7 @@#include <errno.h> #include <err.h> +#include "compiler.h" #include "conffile.h" #include "nfsidmap.h" #include "nfsidmap_plugin.h"
support/nfsidmap/umich_ldap.c +6 -4
@@ -56,6 +56,8 @@/* We are using deprecated functions, get the prototypes... */ #define LDAP_DEPRECATED 1#include <ldap.h> + +#include "compiler.h" #include "nfslib.h" #include "nfsidmap.h" #include "nfsidmap_plugin.h"
@@ -795,8 +797,8 @@ umich_id_to_name(uid_t id, int idtype, char **name, size_t len,*/ if (strlen (names[0 ]) >= len) {/* not enough space to return the name */ -IDMAP_LOG (1 , ("umich_id_to_name: output buffer size (%d) " -"too small to return string, '%s', of length %d" , +IDMAP_LOG (1 , ("umich_id_to_name: output buffer size (%zd) " +"too small to return string, '%s', of length %zd" , len, names[0 ],strlen (names[0 ]))); goto out_memfree; }
@@ -1307,7 +1309,7 @@ get_canonical_hostname(const char *inname) sizeof(tmphost), NULL, 0, 0);if (error) {IDMAP_LOG (1 , ("%s: getnameinfo for host '%s' failed (%d)" , - __FUNCTION__, inname)); + __FUNCTION__, inname, error)); goto out_free; } return_name =strdup (tmphost);
@@ -1356,7 +1358,7 @@ umichldap_init(void) ldap_info.tls_reqcert =LDAP_OPT_X_TLS_NEVER ; else {IDMAP_LOG (0 , ("umichldap_init: Invalid value(%s) for " -"LDAP_tls_reqcert." )); +"LDAP_tls_reqcert." , cert_req)); goto fail; } }
tools/locktest/testlk.c +4 -2
@@ -2,6 +2,7 @@#include <config.h> #endif +#include <inttypes.h> #include <stdlib.h> #include <stdio.h> #include <unistd.h>
@@ -81,8 +82,9 @@ main(int argc, char **argv)if (fl.l_type ==F_UNLCK ) {printf ("%s: no conflicting lock\n" , fname); }else { -printf ("%s: conflicting lock by %d on (%zd;%zd)\n" , - fname, fl.l_pid, fl.l_start, fl.l_len); +printf ("%s: conflicting lock by %d on " +"(%" PRId64";%" PRId64")\n" , + fname, fl.l_pid, fl.l_start, fl.l_len); }return 0 ; }
utils/exportfs/exportfs.c +2 -3
@@ -38,6 +38,7 @@#include "exportfs.h" #include "xlog.h" #include "conffile.h" +#include "compiler.h" static void export_all (int verbose);static void exportfs (char *arg,char *options,int verbose);
@@ -651,9 +652,7 @@ out:return result; } -#ifdef HAVE_FUNC_ATTRIBUTE_FORMAT -__attribute__((format (printf, 2, 3))) -#endif +X_FORMAT((printf, 2, 3))static char dumpopt (char c,char *fmt, ...) {
utils/gssd/err_util.h +3 -1
@@ -31,8 +31,10 @@#ifndef _ERR_UTIL_H_#define _ERR_UTIL_H_ +#include "compiler.h" +void initerr (char *progname,int verbosity,int fg); -void printerr (int priority,char *format, ...); +void printerr(int priority, char *format, ...) X_FORMAT((printf, 2, 3));int get_verbosity (void );#endif /* _ERR_UTIL_H_ */
utils/gssd/gss_names.c +5 -4
@@ -45,10 +45,11 @@#include <string.h> #include <fcntl.h> #include <errno.h> -#include <nfsidmap.h> -#include <nfslib.h> #include <time.h> +#include "compiler.h" +#include "nfsidmap.h" +#include "nfslib.h" #include "svcgssd.h" #include "gss_util.h" #include "gss_names.h"
@@ -65,7 +66,7 @@ get_krb5_hostbased_name(gss_buffer_desc *name, char **hostbased_name)if (strchr (name->value,'@' ) &&strchr (name->value,'/' )) {if ((sname =calloc (name->length,1 )) ==NULL ) {printerr (0 ,"ERROR: get_krb5_hostbased_name failed " -"to allocate %d bytes\n" , name->length); +"to allocate %zu bytes\n" , name->length);return -1 ; }/* read in name and instance and replace '/' with '@' */
@@ -102,7 +103,7 @@ get_hostbased_client_name(gss_name_t client_name, gss_OID mech, }if (name.length >=0xffff ) {/* don't overflow */ printerr (0 ,"ERROR: get_hostbased_client_name: " -"received gss_name is too long (%d bytes)\n" , +"received gss_name is too long (%zu bytes)\n" , name.length); goto out_rel_buf; }
utils/gssd/gss_util.c +1 -1
@@ -304,7 +304,7 @@ gssd_acquire_cred(char *server_name, const gss_OID oid) target_name, &pbuf, NULL);if (ignore_maj_stat ==GSS_S_COMPLETE ) {printerr (1 ,"Unable to obtain credentials for '%.*s'\n" , - pbuf.length, pbuf.value); + (int )pbuf.length, (char *)pbuf.value); ignore_maj_stat =gss_release_buffer (&ignore_min_stat, &pbuf); }
utils/gssd/gssd_proc.c +4 -4
@@ -151,7 +151,7 @@ do_downcall(int k5_fd, uid_t uid, struct authgss_private_data *pd,unsigned int buf_size =0 ;printerr (2 ,"doing downcall: lifetime_rec=%u acceptor=%.*s\n" , - lifetime_rec, acceptor->length, acceptor->value); + lifetime_rec, (int )acceptor->length, (char *)acceptor->value); buf_size =sizeof (uid) +sizeof (timeout) +sizeof (pd->pd_seq_win) +sizeof (pd->pd_ctx_hndl.length) + pd->pd_ctx_hndl.length + sizeof(context_token->length) + context_token->length +
@@ -266,13 +266,13 @@ populate_port(struct sockaddr *sa, const socklen_t salen, port =nfs_getport (sa, salen, program, version, protocol);if (!port) { -printerr (0 ,"ERROR: unable to obtain port for prog %ld " -"vers %ld\n" , program, version); +printerr (0 ,"ERROR: unable to obtain port for prog %u " +"vers %u\n" , program, version);return 0 ; } set_port: -printerr (2 ,"DEBUG: setting port to %hu for prog %lu vers %lu\n" , port, +printerr (2 ,"DEBUG: setting port to %hu for prog %u vers %u\n" , port, program, version);switch (sa->sa_family) {
utils/gssd/krb5_util.c +8 -4
@@ -293,7 +293,7 @@ gssd_find_existing_krb5_ccache(uid_t uid, char *dirname, score++;printerr (3 ,"CC '%s'(%s@%s) passed all checks and" -" has mtime of %u\n" , +" has mtime of %ld\n" , buf, princname, realm, tmp_stat.st_mtime);/*
@@ -330,8 +330,8 @@ gssd_find_existing_krb5_ccache(uid_t uid, char *dirname, }printerr (3 ,"CC '%s:%s/%s' is our " "current best match " -"with mtime of %u\n" , - cctype, dirname, +"with mtime of %lu\n" , + *cctype, dirname, best_match_dir->d_name, best_match_stat.st_mtime); }
@@ -1260,8 +1260,12 @@ gssd_setup_krb5_user_gss_ccache(uid_t uid, char *servername, char *dirpattern)if (err)return err; -snprintf (buf,sizeof (buf),"%s:%s/%s" , cctype, dirname, d->d_name); + err =snprintf (buf,sizeof (buf),"%s:%s/%s" , cctype, dirname, d->d_name);free (d); +if (err <0 ) { +printerr (0 ,"WARNING: buffer to small for krb5 ccache" ); +return -ENOMEM ; + }printerr (2 ,"using %s as credentials cache for client with " "uid %u for server %s\n" , buf, uid, servername);
utils/gssd/svcgssd.c +3 -1
@@ -56,7 +56,9 @@#include <stdlib.h> #include <string.h> #include <signal.h> -#include <nfsidmap.h> + +#include "compiler.h" +#include "nfsidmap.h" #include "nfslib.h" #include "svcgssd.h" #include "gss_util.h"
utils/gssd/svcgssd_proc.c +5 -4
@@ -48,10 +48,11 @@#include <string.h> #include <fcntl.h> #include <errno.h> -#include <nfsidmap.h> #include <nfslib.h> #include <time.h> +#include "compiler.h" +#include "nfsidmap.h" #include "svcgssd.h" #include "gss_util.h" #include "err_util.h"
@@ -102,7 +103,7 @@ do_svc_downcall(gss_buffer_desc *out_handle, struct svc_cred *cred,qword_addint (&bp, &blen, cred->cr_uid);qword_addint (&bp, &blen, cred->cr_gid);qword_addint (&bp, &blen, cred->cr_ngroups); - printerr(2, "mech: %s, hndl len: %d, ctx len %d, timeout: %d (%d from now), " + printerr(2, "mech: %s, hndl len: %zd, ctx len %zd, timeout: %d (%ld from now), " "clnt: %s, uid: %d, gid: %d, num aux grps: %d:\n", fname, out_handle->length, context_token->length, endtime, endtime - time(0),
@@ -232,7 +233,7 @@ get_ids(gss_name_t client_name, gss_OID mech, struct svc_cred *cred) }if (name.length >=0xffff ||/* be certain name.length+1 doesn't overflow */ !(sname =calloc (name.length +1 ,1 ))) { -printerr (0 ,"WARNING: get_ids: error allocating %d bytes " +printerr (0 ,"WARNING: get_ids: error allocating %zd bytes " "for sname\n" , name.length +1 );gss_release_buffer (&min_stat, &name); goto out;
@@ -373,7 +374,7 @@ handle_nullreq(int f) {if (in_handle.length !=0 ) {/* CONTINUE_INIT case */ if (in_handle.length !=sizeof (ctx)) {printerr (0 ,"WARNING: handle_nullreq: " -"input handle has unexpected length %d\n" , +"input handle has unexpected length %zd\n" , in_handle.length); goto out_err; }
utils/idmapd/idmapd.c +2 -1
@@ -65,8 +65,9 @@#include <limits.h> #include <ctype.h> #include <libgen.h> -#include <nfsidmap.h> +#include "compiler.h" +#include "nfsidmap.h" #include "xlog.h" #include "conffile.h" #include "queue.h"
utils/nfsidmap/nfsidmap.c +2 -1
@@ -10,9 +10,10 @@#include <pwd.h> #include <grp.h> #include <keyutils.h> -#include <nfsidmap.h> #include <unistd.h> +#include "compiler.h" +#include "nfsidmap.h" #include "xlog.h" #include "conffile.h" #include "xcommon.h"
Signature · 1 line
2.26.2
PATCH 9/10 Cleanup printf format attribute handling and fix various format strings
In reply to Doug Nazar--- support/include/compiler.h | 14 ++++++++++++++ support/include/xcommon.h | 10 +--------- support/include/xlog.h | 20 ++++++-------------- support/nfs/xcommon.c | 2 ++ support/nfsidmap/gums.c | 2 ++ support/nfsidmap/libnfsidmap.c | 8 +++++--- support/nfsidmap/nfsidmap.h | 10 +++++++++- support/nfsidmap/nfsidmap_common.c | 1 + support/nfsidmap/nss.c | 4 +++- support/nfsidmap/regex.c | 6 ++++-- support/nfsidmap/static.c | 1 + support/nfsidmap/umich_ldap.c | 10 ++++++---- tools/locktest/testlk.c | 6 ++++-- utils/exportfs/exportfs.c | 5 ++--- utils/gssd/err_util.h | 4 +++- utils/gssd/gss_names.c | 9 +++++---- utils/gssd/gss_util.c | 2 +- utils/gssd/gssd_proc.c | 8 ++++---- utils/gssd/krb5_util.c | 12 ++++++++---- utils/gssd/svcgssd.c | 4 +++- utils/gssd/svcgssd_proc.c | 9 +++++---- utils/idmapd/idmapd.c | 3 ++- utils/nfsidmap/nfsidmap.c | 3 ++- 23 files changed, 93 insertions(+), 60 deletions(-) create mode 100644 support/include/compiler.h
support/include/compiler.h new file +14 -0
@@ -0,0 +1,14 @@ +#ifndef COMPILER_H +#define COMPILER_H + +#ifndef CONFIG_H +#include <config.h> +#endif + +#ifdef HAVE_FUNC_ATTRIBUTE_FORMAT +#define X_FORMAT (_x) __attribute__((__format__ _x)) +#else +#define X_FORMAT (_x) +#endif + +#endif
support/include/xcommon.h +1 -9
@@ -9,9 +9,7 @@#ifndef _XMALLOC_H#define _MALLOC_H -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif +#include "compiler.h" #include <sys/types.h> #include <fcntl.h>
@@ -29,12 +27,6 @@#define streq (s, t) (strcmp ((s), (t)) == 0) -#ifdef HAVE_FUNC_ATTRIBUTE_FORMAT -#define X_FORMAT (_x) __attribute__((__format__ _x)) -#else -#define X_FORMAT (_x) -#endif -/* Functions in sundries.c that are used in mount.c and umount.c */ char *canonicalize (const char *path); void nfs_error (const char *fmt, ...) X_FORMAT((printf, 1, 2));
support/include/xlog.h +6 -14
@@ -7,9 +7,7 @@#ifndef XLOG_H #define XLOG_H -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif +#include "compiler.h" #include <stdarg.h>
@@ -39,12 +37,6 @@ struct xlog_debugfac {int df_fac; }; -#ifdef HAVE_FUNC_ATTRIBUTE_FORMAT -#define XLOG_FORMAT (_x) __attribute__((__format__ _x)) -#else -#define XLOG_FORMAT (_x) -#endif -extern int export_errno;void xlog_open (char *progname);void xlog_stderr (int on);
@@ -53,10 +45,10 @@ void xlog_config(int fac, int on);void xlog_sconfig (char *,int on);void xlog_from_conffile (char *);int xlog_enabled (int fac); -void xlog(int fac, const char *fmt, ...) XLOG_FORMAT((printf, 2, 3)); -void xlog_warn(const char *fmt, ...) XLOG_FORMAT((printf, 1, 2)); -void xlog_err(const char *fmt, ...) XLOG_FORMAT((printf, 1, 2)); -void xlog_errno(int err, const char *fmt, ...) XLOG_FORMAT((printf, 2, 3)); -void xlog_backend(int fac, const char *fmt, va_list args) XLOG_FORMAT((printf, 2, 0)); +void xlog(int fac, const char *fmt, ...) X_FORMAT((printf, 2, 3)); +void xlog_warn(const char *fmt, ...) X_FORMAT((printf, 1, 2)); +void xlog_err(const char *fmt, ...) X_FORMAT((printf, 1, 2)); +void xlog_errno(int err, const char *fmt, ...) X_FORMAT((printf, 2, 3)); +void xlog_backend(int fac, const char *fmt, va_list args) X_FORMAT((printf, 2, 0));#endif /* XLOG_H */
support/nfs/xcommon.c +2 -0
@@ -98,7 +98,9 @@ nfs_error (const char *fmt, ...) { fmt2 =xstrconcat2 (fmt,"\n" );va_start (args, fmt); +#pragma GCC diagnostic ignored "-Wformat-nonliteral"vfprintf (stderr, fmt2, args); +#pragma GCC diagnostic warning "-Wformat-nonliteral"va_end (args);free (fmt2); }
support/nfsidmap/gums.c +2 -0
@@ -41,6 +41,8 @@#include <grp.h> #include <err.h> #include <syslog.h> + +#include "compiler.h" #include "nfsidmap.h" #include "nfsidmap_plugin.h"
support/nfsidmap/libnfsidmap.c +5 -3
@@ -57,6 +57,7 @@#include <arpa/nameser.h> #include <arpa/nameser_compat.h> +#include "compiler.h" #include "nfsidmap.h" #include "nfsidmap_private.h" #include "nfsidmap_plugin.h"
@@ -94,6 +95,7 @@ gid_t nobody_gid = (gid_t)-1;#endif /* Default logging fuction */ +X_FORMAT((__printf__, 1, 2))static void default_logger (const char *fmt, ...) {va_list vp;
@@ -258,7 +260,7 @@ static int load_translation_plugin(char *method, struct mapping_plugin *plgn) } trans =init_func ();if (trans ==NULL ) { -IDMAP_LOG (1 , ("libnfsidmap: Failed to initialize plugin %s" , +IDMAP_LOG (1 , ("libnfsidmap: %s failed to initialize plugin %s" ,PLUGIN_INIT_FUNC , plgname));dlclose (dl);return -1 ;
@@ -451,7 +453,7 @@ int nfs4_init_name_mapping(char *conffile) nobody_user, strerror(errno)));free (buf); }else -IDMAP_LOG (0 ,("libnfsidmap: Nobody-User: no memory : %s" , +IDMAP_LOG (0 ,("libnfsidmap: Nobody-User (%s): no memory : %s" , nobody_user,strerror (errno))); }
@@ -472,7 +474,7 @@ int nfs4_init_name_mapping(char *conffile) nobody_group, strerror(errno)));free (buf); }else -IDMAP_LOG (0 ,("libnfsidmap: Nobody-Group: no memory : %s" , +IDMAP_LOG (0 ,("libnfsidmap: Nobody-Group (%s): no memory : %s" , nobody_group,strerror (errno))); }
support/nfsidmap/nfsidmap.h +9 -1
@@ -35,6 +35,14 @@* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#ifndef X_FORMAT +# ifdef __GNUC__ +# define X_FORMAT (_x) __attribute__((__format__ _x)) +# else +# define X_FORMAT (_x) +# endif +#endif +/* XXX arbitrary */ #define NFS4_MAX_DOMAIN_LEN 512 typedef enum {
@@ -47,7 +55,7 @@ typedef struct _extra_mapping_params {int content_len; } extra_mapping_params; -typedef void (*nfs4_idmap_log_function_t )(const char *, ...); +typedef void (* nfs4_idmap_log_function_t)(const char *, ...) X_FORMAT((printf, 1, 2));int nfs4_init_name_mapping (char *conffile);int nfs4_get_default_domain (char *server,char *domain,size_t len);
support/nfsidmap/nfsidmap_common.c +1 -0
@@ -19,6 +19,7 @@#include <errno.h> #include <string.h> +#include "compiler.h" #include "nfsidmap.h" #include "nfsidmap_private.h" #include "nfsidmap_plugin.h"
support/nfsidmap/nss.c +3 -1
@@ -47,10 +47,12 @@#include <grp.h> #include <limits.h> #include <ctype.h> +#include <syslog.h> + +#include "compiler.h" #include "nfsidmap.h" #include "nfsidmap_plugin.h" #include "nfsidmap_private.h" -#include <syslog.h> static char *get_default_domain (void ) {
support/nfsidmap/regex.c +4 -2
@@ -44,6 +44,7 @@#include <err.h> #include <regex.h> +#include "compiler.h" #include "nfsidmap.h" #include "nfsidmap_plugin.h"
@@ -229,8 +230,9 @@ static struct group *regex_getgrnam(const char *name, const char *UNUSED(domain)if (err) { -IDMAP_LOG (4 , ("regexp_getgrnam: removing prefix '%s' (%d long) from group '%s'" , group_name_prefix, group_name_prefix_length, localgroup)); - groupname += group_name_prefix_length; +IDMAP_LOG (4 , ("regexp_getgrnam: removing prefix '%s' (%zd long) from group '%s'" , + group_name_prefix, group_name_prefix_length, localgroup)); + groupname += group_name_prefix_length; }else {
support/nfsidmap/static.c +1 -0
@@ -41,6 +41,7 @@#include <errno.h> #include <err.h> +#include "compiler.h" #include "conffile.h" #include "nfsidmap.h" #include "nfsidmap_plugin.h"
support/nfsidmap/umich_ldap.c +6 -4
@@ -56,6 +56,8 @@/* We are using deprecated functions, get the prototypes... */ #define LDAP_DEPRECATED 1#include <ldap.h> + +#include "compiler.h" #include "nfslib.h" #include "nfsidmap.h" #include "nfsidmap_plugin.h"
@@ -795,8 +797,8 @@ umich_id_to_name(uid_t id, int idtype, char **name, size_t len,*/ if (strlen (names[0 ]) >= len) {/* not enough space to return the name */ -IDMAP_LOG (1 , ("umich_id_to_name: output buffer size (%d) " -"too small to return string, '%s', of length %d" , +IDMAP_LOG (1 , ("umich_id_to_name: output buffer size (%zd) " +"too small to return string, '%s', of length %zd" , len, names[0 ],strlen (names[0 ]))); goto out_memfree; }
@@ -1307,7 +1309,7 @@ get_canonical_hostname(const char *inname) sizeof(tmphost), NULL, 0, 0);if (error) {IDMAP_LOG (1 , ("%s: getnameinfo for host '%s' failed (%d)" , - __FUNCTION__, inname)); + __FUNCTION__, inname, error)); goto out_free; } return_name =strdup (tmphost);
@@ -1356,7 +1358,7 @@ umichldap_init(void) ldap_info.tls_reqcert =LDAP_OPT_X_TLS_NEVER ; else {IDMAP_LOG (0 , ("umichldap_init: Invalid value(%s) for " -"LDAP_tls_reqcert." )); +"LDAP_tls_reqcert." , cert_req)); goto fail; } }
tools/locktest/testlk.c +4 -2
@@ -2,6 +2,7 @@#include <config.h> #endif +#include <inttypes.h> #include <stdlib.h> #include <stdio.h> #include <unistd.h>
@@ -81,8 +82,9 @@ main(int argc, char **argv)if (fl.l_type ==F_UNLCK ) {printf ("%s: no conflicting lock\n" , fname); }else { -printf ("%s: conflicting lock by %d on (%zd;%zd)\n" , - fname, fl.l_pid, fl.l_start, fl.l_len); +printf ("%s: conflicting lock by %d on " +"(%" PRId64";%" PRId64")\n" , + fname, fl.l_pid, fl.l_start, fl.l_len); }return 0 ; }
utils/exportfs/exportfs.c +2 -3
@@ -38,6 +38,7 @@#include "exportfs.h" #include "xlog.h" #include "conffile.h" +#include "compiler.h" static void export_all (int verbose);static void exportfs (char *arg,char *options,int verbose);
@@ -651,9 +652,7 @@ out:return result; } -#ifdef HAVE_FUNC_ATTRIBUTE_FORMAT -__attribute__((format (printf, 2, 3))) -#endif +X_FORMAT((printf, 2, 3))static char dumpopt (char c,char *fmt, ...) {
utils/gssd/err_util.h +3 -1
@@ -31,8 +31,10 @@#ifndef _ERR_UTIL_H_#define _ERR_UTIL_H_ +#include "compiler.h" +void initerr (char *progname,int verbosity,int fg); -void printerr (int priority,char *format, ...); +void printerr(int priority, char *format, ...) X_FORMAT((printf, 2, 3));int get_verbosity (void );#endif /* _ERR_UTIL_H_ */
utils/gssd/gss_names.c +5 -4
@@ -45,10 +45,11 @@#include <string.h> #include <fcntl.h> #include <errno.h> -#include <nfsidmap.h> -#include <nfslib.h> #include <time.h> +#include "compiler.h" +#include "nfsidmap.h" +#include "nfslib.h" #include "svcgssd.h" #include "gss_util.h" #include "gss_names.h"
@@ -65,7 +66,7 @@ get_krb5_hostbased_name(gss_buffer_desc *name, char **hostbased_name)if (strchr (name->value,'@' ) &&strchr (name->value,'/' )) {if ((sname =calloc (name->length,1 )) ==NULL ) {printerr (0 ,"ERROR: get_krb5_hostbased_name failed " -"to allocate %d bytes\n" , name->length); +"to allocate %zu bytes\n" , name->length);return -1 ; }/* read in name and instance and replace '/' with '@' */
@@ -102,7 +103,7 @@ get_hostbased_client_name(gss_name_t client_name, gss_OID mech, }if (name.length >=0xffff ) {/* don't overflow */ printerr (0 ,"ERROR: get_hostbased_client_name: " -"received gss_name is too long (%d bytes)\n" , +"received gss_name is too long (%zu bytes)\n" , name.length); goto out_rel_buf; }
utils/gssd/gss_util.c +1 -1
@@ -304,7 +304,7 @@ gssd_acquire_cred(char *server_name, const gss_OID oid) target_name, &pbuf, NULL);if (ignore_maj_stat ==GSS_S_COMPLETE ) {printerr (1 ,"Unable to obtain credentials for '%.*s'\n" , - pbuf.length, pbuf.value); + (int )pbuf.length, (char *)pbuf.value); ignore_maj_stat =gss_release_buffer (&ignore_min_stat, &pbuf); }
utils/gssd/gssd_proc.c +4 -4
@@ -151,7 +151,7 @@ do_downcall(int k5_fd, uid_t uid, struct authgss_private_data *pd,unsigned int buf_size =0 ;printerr (2 ,"doing downcall: lifetime_rec=%u acceptor=%.*s\n" , - lifetime_rec, acceptor->length, acceptor->value); + lifetime_rec, (int )acceptor->length, (char *)acceptor->value); buf_size =sizeof (uid) +sizeof (timeout) +sizeof (pd->pd_seq_win) +sizeof (pd->pd_ctx_hndl.length) + pd->pd_ctx_hndl.length + sizeof(context_token->length) + context_token->length +
@@ -266,13 +266,13 @@ populate_port(struct sockaddr *sa, const socklen_t salen, port =nfs_getport (sa, salen, program, version, protocol);if (!port) { -printerr (0 ,"ERROR: unable to obtain port for prog %ld " -"vers %ld\n" , program, version); +printerr (0 ,"ERROR: unable to obtain port for prog %u " +"vers %u\n" , program, version);return 0 ; } set_port: -printerr (2 ,"DEBUG: setting port to %hu for prog %lu vers %lu\n" , port, +printerr (2 ,"DEBUG: setting port to %hu for prog %u vers %u\n" , port, program, version);switch (sa->sa_family) {
utils/gssd/krb5_util.c +8 -4
@@ -293,7 +293,7 @@ gssd_find_existing_krb5_ccache(uid_t uid, char *dirname, score++;printerr (3 ,"CC '%s'(%s@%s) passed all checks and" -" has mtime of %u\n" , +" has mtime of %ld\n" , buf, princname, realm, tmp_stat.st_mtime);/*
@@ -330,8 +330,8 @@ gssd_find_existing_krb5_ccache(uid_t uid, char *dirname, }printerr (3 ,"CC '%s:%s/%s' is our " "current best match " -"with mtime of %u\n" , - cctype, dirname, +"with mtime of %lu\n" , + *cctype, dirname, best_match_dir->d_name, best_match_stat.st_mtime); }
@@ -1260,8 +1260,12 @@ gssd_setup_krb5_user_gss_ccache(uid_t uid, char *servername, char *dirpattern)if (err)return err; -snprintf (buf,sizeof (buf),"%s:%s/%s" , cctype, dirname, d->d_name); + err =snprintf (buf,sizeof (buf),"%s:%s/%s" , cctype, dirname, d->d_name);free (d); +if (err <0 ) { +printerr (0 ,"WARNING: buffer to small for krb5 ccache" ); +return -ENOMEM ; + }printerr (2 ,"using %s as credentials cache for client with " "uid %u for server %s\n" , buf, uid, servername);
utils/gssd/svcgssd.c +3 -1
@@ -56,7 +56,9 @@#include <stdlib.h> #include <string.h> #include <signal.h> -#include <nfsidmap.h> + +#include "compiler.h" +#include "nfsidmap.h" #include "nfslib.h" #include "svcgssd.h" #include "gss_util.h"
utils/gssd/svcgssd_proc.c +5 -4
@@ -48,10 +48,11 @@#include <string.h> #include <fcntl.h> #include <errno.h> -#include <nfsidmap.h> #include <nfslib.h> #include <time.h> +#include "compiler.h" +#include "nfsidmap.h" #include "svcgssd.h" #include "gss_util.h" #include "err_util.h"
@@ -102,7 +103,7 @@ do_svc_downcall(gss_buffer_desc *out_handle, struct svc_cred *cred,qword_addint (&bp, &blen, cred->cr_uid);qword_addint (&bp, &blen, cred->cr_gid);qword_addint (&bp, &blen, cred->cr_ngroups); - printerr(2, "mech: %s, hndl len: %d, ctx len %d, timeout: %d (%d from now), " + printerr(2, "mech: %s, hndl len: %zd, ctx len %zd, timeout: %d (%ld from now), " "clnt: %s, uid: %d, gid: %d, num aux grps: %d:\n", fname, out_handle->length, context_token->length, endtime, endtime - time(0),
@@ -232,7 +233,7 @@ get_ids(gss_name_t client_name, gss_OID mech, struct svc_cred *cred) }if (name.length >=0xffff ||/* be certain name.length+1 doesn't overflow */ !(sname =calloc (name.length +1 ,1 ))) { -printerr (0 ,"WARNING: get_ids: error allocating %d bytes " +printerr (0 ,"WARNING: get_ids: error allocating %zd bytes " "for sname\n" , name.length +1 );gss_release_buffer (&min_stat, &name); goto out;
@@ -373,7 +374,7 @@ handle_nullreq(int f) {if (in_handle.length !=0 ) {/* CONTINUE_INIT case */ if (in_handle.length !=sizeof (ctx)) {printerr (0 ,"WARNING: handle_nullreq: " -"input handle has unexpected length %d\n" , +"input handle has unexpected length %zd\n" , in_handle.length); goto out_err; }
utils/idmapd/idmapd.c +2 -1
@@ -65,8 +65,9 @@#include <limits.h> #include <ctype.h> #include <libgen.h> -#include <nfsidmap.h> +#include "compiler.h" +#include "nfsidmap.h" #include "xlog.h" #include "conffile.h" #include "queue.h"
utils/nfsidmap/nfsidmap.c +2 -1
@@ -10,9 +10,10 @@#include <pwd.h> #include <grp.h> #include <keyutils.h> -#include <nfsidmap.h> #include <unistd.h> +#include "compiler.h" +#include "nfsidmap.h" #include "xlog.h" #include "conffile.h" #include "xcommon.h"
Signature · 1 line
2.26.2
PATCH 9/10 Consolidate printf format attribute handling and fix various format strings
In reply to Doug Nazar--- support/include/compiler.h | 14 ++++++++++++++ support/include/xcommon.h | 10 +--------- support/include/xlog.h | 20 ++++++-------------- support/nfs/xcommon.c | 2 ++ support/nfsidmap/gums.c | 2 ++ support/nfsidmap/libnfsidmap.c | 8 +++++--- support/nfsidmap/nfsidmap.h | 10 +++++++++- support/nfsidmap/nfsidmap_common.c | 1 + support/nfsidmap/nss.c | 4 +++- support/nfsidmap/regex.c | 6 ++++-- support/nfsidmap/static.c | 1 + support/nfsidmap/umich_ldap.c | 10 ++++++---- tools/locktest/testlk.c | 6 ++++-- utils/exportfs/exportfs.c | 5 ++--- utils/gssd/err_util.h | 4 +++- utils/gssd/gss_names.c | 9 +++++---- utils/gssd/gss_util.c | 2 +- utils/gssd/gssd_proc.c | 8 ++++---- utils/gssd/krb5_util.c | 12 ++++++++---- utils/gssd/svcgssd.c | 4 +++- utils/gssd/svcgssd_proc.c | 9 +++++---- utils/idmapd/idmapd.c | 3 ++- utils/nfsidmap/nfsidmap.c | 3 ++- 23 files changed, 93 insertions(+), 60 deletions(-) create mode 100644 support/include/compiler.h
support/include/compiler.h new file +14 -0
@@ -0,0 +1,14 @@ +#ifndef COMPILER_H +#define COMPILER_H + +#ifndef CONFIG_H +#include <config.h> +#endif + +#ifdef HAVE_FUNC_ATTRIBUTE_FORMAT +#define X_FORMAT (_x) __attribute__((__format__ _x)) +#else +#define X_FORMAT (_x) +#endif + +#endif
support/include/xcommon.h +1 -9
@@ -9,9 +9,7 @@#ifndef _XMALLOC_H#define _MALLOC_H -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif +#include "compiler.h" #include <sys/types.h> #include <fcntl.h>
@@ -29,12 +27,6 @@#define streq (s, t) (strcmp ((s), (t)) == 0) -#ifdef HAVE_FUNC_ATTRIBUTE_FORMAT -#define X_FORMAT (_x) __attribute__((__format__ _x)) -#else -#define X_FORMAT (_x) -#endif -/* Functions in sundries.c that are used in mount.c and umount.c */ char *canonicalize (const char *path); void nfs_error (const char *fmt, ...) X_FORMAT((printf, 1, 2));
support/include/xlog.h +6 -14
@@ -7,9 +7,7 @@#ifndef XLOG_H #define XLOG_H -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif +#include "compiler.h" #include <stdarg.h>
@@ -39,12 +37,6 @@ struct xlog_debugfac {int df_fac; }; -#ifdef HAVE_FUNC_ATTRIBUTE_FORMAT -#define XLOG_FORMAT (_x) __attribute__((__format__ _x)) -#else -#define XLOG_FORMAT (_x) -#endif -extern int export_errno;void xlog_open (char *progname);void xlog_stderr (int on);
@@ -53,10 +45,10 @@ void xlog_config(int fac, int on);void xlog_sconfig (char *,int on);void xlog_from_conffile (char *);int xlog_enabled (int fac); -void xlog(int fac, const char *fmt, ...) XLOG_FORMAT((printf, 2, 3)); -void xlog_warn(const char *fmt, ...) XLOG_FORMAT((printf, 1, 2)); -void xlog_err(const char *fmt, ...) XLOG_FORMAT((printf, 1, 2)); -void xlog_errno(int err, const char *fmt, ...) XLOG_FORMAT((printf, 2, 3)); -void xlog_backend(int fac, const char *fmt, va_list args) XLOG_FORMAT((printf, 2, 0)); +void xlog(int fac, const char *fmt, ...) X_FORMAT((printf, 2, 3)); +void xlog_warn(const char *fmt, ...) X_FORMAT((printf, 1, 2)); +void xlog_err(const char *fmt, ...) X_FORMAT((printf, 1, 2)); +void xlog_errno(int err, const char *fmt, ...) X_FORMAT((printf, 2, 3)); +void xlog_backend(int fac, const char *fmt, va_list args) X_FORMAT((printf, 2, 0));#endif /* XLOG_H */
support/nfs/xcommon.c +2 -0
@@ -98,7 +98,9 @@ nfs_error (const char *fmt, ...) { fmt2 =xstrconcat2 (fmt,"\n" );va_start (args, fmt); +#pragma GCC diagnostic ignored "-Wformat-nonliteral"vfprintf (stderr, fmt2, args); +#pragma GCC diagnostic warning "-Wformat-nonliteral"va_end (args);free (fmt2); }
support/nfsidmap/gums.c +2 -0
@@ -41,6 +41,8 @@#include <grp.h> #include <err.h> #include <syslog.h> + +#include "compiler.h" #include "nfsidmap.h" #include "nfsidmap_plugin.h"
support/nfsidmap/libnfsidmap.c +5 -3
@@ -57,6 +57,7 @@#include <arpa/nameser.h> #include <arpa/nameser_compat.h> +#include "compiler.h" #include "nfsidmap.h" #include "nfsidmap_private.h" #include "nfsidmap_plugin.h"
@@ -94,6 +95,7 @@ gid_t nobody_gid = (gid_t)-1;#endif /* Default logging fuction */ +X_FORMAT((__printf__, 1, 2))static void default_logger (const char *fmt, ...) {va_list vp;
@@ -258,7 +260,7 @@ static int load_translation_plugin(char *method, struct mapping_plugin *plgn) } trans =init_func ();if (trans ==NULL ) { -IDMAP_LOG (1 , ("libnfsidmap: Failed to initialize plugin %s" , +IDMAP_LOG (1 , ("libnfsidmap: %s failed to initialize plugin %s" ,PLUGIN_INIT_FUNC , plgname));dlclose (dl);return -1 ;
@@ -451,7 +453,7 @@ int nfs4_init_name_mapping(char *conffile) nobody_user, strerror(errno)));free (buf); }else -IDMAP_LOG (0 ,("libnfsidmap: Nobody-User: no memory : %s" , +IDMAP_LOG (0 ,("libnfsidmap: Nobody-User (%s): no memory : %s" , nobody_user,strerror (errno))); }
@@ -472,7 +474,7 @@ int nfs4_init_name_mapping(char *conffile) nobody_group, strerror(errno)));free (buf); }else -IDMAP_LOG (0 ,("libnfsidmap: Nobody-Group: no memory : %s" , +IDMAP_LOG (0 ,("libnfsidmap: Nobody-Group (%s): no memory : %s" , nobody_group,strerror (errno))); }
support/nfsidmap/nfsidmap.h +9 -1
@@ -35,6 +35,14 @@* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#ifndef X_FORMAT +# ifdef __GNUC__ +# define X_FORMAT (_x) __attribute__((__format__ _x)) +# else +# define X_FORMAT (_x) +# endif +#endif +/* XXX arbitrary */ #define NFS4_MAX_DOMAIN_LEN 512 typedef enum {
@@ -47,7 +55,7 @@ typedef struct _extra_mapping_params {int content_len; } extra_mapping_params; -typedef void (*nfs4_idmap_log_function_t )(const char *, ...); +typedef void (* nfs4_idmap_log_function_t)(const char *, ...) X_FORMAT((printf, 1, 2));int nfs4_init_name_mapping (char *conffile);int nfs4_get_default_domain (char *server,char *domain,size_t len);
support/nfsidmap/nfsidmap_common.c +1 -0
@@ -19,6 +19,7 @@#include <errno.h> #include <string.h> +#include "compiler.h" #include "nfsidmap.h" #include "nfsidmap_private.h" #include "nfsidmap_plugin.h"
support/nfsidmap/nss.c +3 -1
@@ -47,10 +47,12 @@#include <grp.h> #include <limits.h> #include <ctype.h> +#include <syslog.h> + +#include "compiler.h" #include "nfsidmap.h" #include "nfsidmap_plugin.h" #include "nfsidmap_private.h" -#include <syslog.h> static char *get_default_domain (void ) {
support/nfsidmap/regex.c +4 -2
@@ -44,6 +44,7 @@#include <err.h> #include <regex.h> +#include "compiler.h" #include "nfsidmap.h" #include "nfsidmap_plugin.h"
@@ -229,8 +230,9 @@ static struct group *regex_getgrnam(const char *name, const char *UNUSED(domain)if (err) { -IDMAP_LOG (4 , ("regexp_getgrnam: removing prefix '%s' (%d long) from group '%s'" , group_name_prefix, group_name_prefix_length, localgroup)); - groupname += group_name_prefix_length; +IDMAP_LOG (4 , ("regexp_getgrnam: removing prefix '%s' (%zd long) from group '%s'" , + group_name_prefix, group_name_prefix_length, localgroup)); + groupname += group_name_prefix_length; }else {
support/nfsidmap/static.c +1 -0
@@ -41,6 +41,7 @@#include <errno.h> #include <err.h> +#include "compiler.h" #include "conffile.h" #include "nfsidmap.h" #include "nfsidmap_plugin.h"
support/nfsidmap/umich_ldap.c +6 -4
@@ -56,6 +56,8 @@/* We are using deprecated functions, get the prototypes... */ #define LDAP_DEPRECATED 1#include <ldap.h> + +#include "compiler.h" #include "nfslib.h" #include "nfsidmap.h" #include "nfsidmap_plugin.h"
@@ -795,8 +797,8 @@ umich_id_to_name(uid_t id, int idtype, char **name, size_t len,*/ if (strlen (names[0 ]) >= len) {/* not enough space to return the name */ -IDMAP_LOG (1 , ("umich_id_to_name: output buffer size (%d) " -"too small to return string, '%s', of length %d" , +IDMAP_LOG (1 , ("umich_id_to_name: output buffer size (%zd) " +"too small to return string, '%s', of length %zd" , len, names[0 ],strlen (names[0 ]))); goto out_memfree; }
@@ -1307,7 +1309,7 @@ get_canonical_hostname(const char *inname) sizeof(tmphost), NULL, 0, 0);if (error) {IDMAP_LOG (1 , ("%s: getnameinfo for host '%s' failed (%d)" , - __FUNCTION__, inname)); + __FUNCTION__, inname, error)); goto out_free; } return_name =strdup (tmphost);
@@ -1356,7 +1358,7 @@ umichldap_init(void) ldap_info.tls_reqcert =LDAP_OPT_X_TLS_NEVER ; else {IDMAP_LOG (0 , ("umichldap_init: Invalid value(%s) for " -"LDAP_tls_reqcert." )); +"LDAP_tls_reqcert." , cert_req)); goto fail; } }
tools/locktest/testlk.c +4 -2
@@ -2,6 +2,7 @@#include <config.h> #endif +#include <inttypes.h> #include <stdlib.h> #include <stdio.h> #include <unistd.h>
@@ -81,8 +82,9 @@ main(int argc, char **argv)if (fl.l_type ==F_UNLCK ) {printf ("%s: no conflicting lock\n" , fname); }else { -printf ("%s: conflicting lock by %d on (%zd;%zd)\n" , - fname, fl.l_pid, fl.l_start, fl.l_len); +printf ("%s: conflicting lock by %d on " +"(%" PRId64";%" PRId64")\n" , + fname, fl.l_pid, fl.l_start, fl.l_len); }return 0 ; }
utils/exportfs/exportfs.c +2 -3
@@ -38,6 +38,7 @@#include "exportfs.h" #include "xlog.h" #include "conffile.h" +#include "compiler.h" static void export_all (int verbose);static void exportfs (char *arg,char *options,int verbose);
@@ -651,9 +652,7 @@ out:return result; } -#ifdef HAVE_FUNC_ATTRIBUTE_FORMAT -__attribute__((format (printf, 2, 3))) -#endif +X_FORMAT((printf, 2, 3))static char dumpopt (char c,char *fmt, ...) {
utils/gssd/err_util.h +3 -1
@@ -31,8 +31,10 @@#ifndef _ERR_UTIL_H_#define _ERR_UTIL_H_ +#include "compiler.h" +void initerr (char *progname,int verbosity,int fg); -void printerr (int priority,char *format, ...); +void printerr(int priority, char *format, ...) X_FORMAT((printf, 2, 3));int get_verbosity (void );#endif /* _ERR_UTIL_H_ */
utils/gssd/gss_names.c +5 -4
@@ -45,10 +45,11 @@#include <string.h> #include <fcntl.h> #include <errno.h> -#include <nfsidmap.h> -#include <nfslib.h> #include <time.h> +#include "compiler.h" +#include "nfsidmap.h" +#include "nfslib.h" #include "svcgssd.h" #include "gss_util.h" #include "gss_names.h"
@@ -65,7 +66,7 @@ get_krb5_hostbased_name(gss_buffer_desc *name, char **hostbased_name)if (strchr (name->value,'@' ) &&strchr (name->value,'/' )) {if ((sname =calloc (name->length,1 )) ==NULL ) {printerr (0 ,"ERROR: get_krb5_hostbased_name failed " -"to allocate %d bytes\n" , name->length); +"to allocate %zu bytes\n" , name->length);return -1 ; }/* read in name and instance and replace '/' with '@' */
@@ -102,7 +103,7 @@ get_hostbased_client_name(gss_name_t client_name, gss_OID mech, }if (name.length >=0xffff ) {/* don't overflow */ printerr (0 ,"ERROR: get_hostbased_client_name: " -"received gss_name is too long (%d bytes)\n" , +"received gss_name is too long (%zu bytes)\n" , name.length); goto out_rel_buf; }
utils/gssd/gss_util.c +1 -1
@@ -304,7 +304,7 @@ gssd_acquire_cred(char *server_name, const gss_OID oid) target_name, &pbuf, NULL);if (ignore_maj_stat ==GSS_S_COMPLETE ) {printerr (1 ,"Unable to obtain credentials for '%.*s'\n" , - pbuf.length, pbuf.value); + (int )pbuf.length, (char *)pbuf.value); ignore_maj_stat =gss_release_buffer (&ignore_min_stat, &pbuf); }
utils/gssd/gssd_proc.c +4 -4
@@ -151,7 +151,7 @@ do_downcall(int k5_fd, uid_t uid, struct authgss_private_data *pd,unsigned int buf_size =0 ;printerr (2 ,"doing downcall: lifetime_rec=%u acceptor=%.*s\n" , - lifetime_rec, acceptor->length, acceptor->value); + lifetime_rec, (int )acceptor->length, (char *)acceptor->value); buf_size =sizeof (uid) +sizeof (timeout) +sizeof (pd->pd_seq_win) +sizeof (pd->pd_ctx_hndl.length) + pd->pd_ctx_hndl.length + sizeof(context_token->length) + context_token->length +
@@ -266,13 +266,13 @@ populate_port(struct sockaddr *sa, const socklen_t salen, port =nfs_getport (sa, salen, program, version, protocol);if (!port) { -printerr (0 ,"ERROR: unable to obtain port for prog %ld " -"vers %ld\n" , program, version); +printerr (0 ,"ERROR: unable to obtain port for prog %u " +"vers %u\n" , program, version);return 0 ; } set_port: -printerr (2 ,"DEBUG: setting port to %hu for prog %lu vers %lu\n" , port, +printerr (2 ,"DEBUG: setting port to %hu for prog %u vers %u\n" , port, program, version);switch (sa->sa_family) {
utils/gssd/krb5_util.c +8 -4
@@ -293,7 +293,7 @@ gssd_find_existing_krb5_ccache(uid_t uid, char *dirname, score++;printerr (3 ,"CC '%s'(%s@%s) passed all checks and" -" has mtime of %u\n" , +" has mtime of %ld\n" , buf, princname, realm, tmp_stat.st_mtime);/*
@@ -330,8 +330,8 @@ gssd_find_existing_krb5_ccache(uid_t uid, char *dirname, }printerr (3 ,"CC '%s:%s/%s' is our " "current best match " -"with mtime of %u\n" , - cctype, dirname, +"with mtime of %lu\n" , + *cctype, dirname, best_match_dir->d_name, best_match_stat.st_mtime); }
@@ -1260,8 +1260,12 @@ gssd_setup_krb5_user_gss_ccache(uid_t uid, char *servername, char *dirpattern)if (err)return err; -snprintf (buf,sizeof (buf),"%s:%s/%s" , cctype, dirname, d->d_name); + err =snprintf (buf,sizeof (buf),"%s:%s/%s" , cctype, dirname, d->d_name);free (d); +if (err <0 ) { +printerr (0 ,"WARNING: buffer to small for krb5 ccache" ); +return -ENOMEM ; + }printerr (2 ,"using %s as credentials cache for client with " "uid %u for server %s\n" , buf, uid, servername);
utils/gssd/svcgssd.c +3 -1
@@ -56,7 +56,9 @@#include <stdlib.h> #include <string.h> #include <signal.h> -#include <nfsidmap.h> + +#include "compiler.h" +#include "nfsidmap.h" #include "nfslib.h" #include "svcgssd.h" #include "gss_util.h"
utils/gssd/svcgssd_proc.c +5 -4
@@ -48,10 +48,11 @@#include <string.h> #include <fcntl.h> #include <errno.h> -#include <nfsidmap.h> #include <nfslib.h> #include <time.h> +#include "compiler.h" +#include "nfsidmap.h" #include "svcgssd.h" #include "gss_util.h" #include "err_util.h"
@@ -102,7 +103,7 @@ do_svc_downcall(gss_buffer_desc *out_handle, struct svc_cred *cred,qword_addint (&bp, &blen, cred->cr_uid);qword_addint (&bp, &blen, cred->cr_gid);qword_addint (&bp, &blen, cred->cr_ngroups); - printerr(2, "mech: %s, hndl len: %d, ctx len %d, timeout: %d (%d from now), " + printerr(2, "mech: %s, hndl len: %zd, ctx len %zd, timeout: %d (%ld from now), " "clnt: %s, uid: %d, gid: %d, num aux grps: %d:\n", fname, out_handle->length, context_token->length, endtime, endtime - time(0),
@@ -232,7 +233,7 @@ get_ids(gss_name_t client_name, gss_OID mech, struct svc_cred *cred) }if (name.length >=0xffff ||/* be certain name.length+1 doesn't overflow */ !(sname =calloc (name.length +1 ,1 ))) { -printerr (0 ,"WARNING: get_ids: error allocating %d bytes " +printerr (0 ,"WARNING: get_ids: error allocating %zd bytes " "for sname\n" , name.length +1 );gss_release_buffer (&min_stat, &name); goto out;
@@ -373,7 +374,7 @@ handle_nullreq(int f) {if (in_handle.length !=0 ) {/* CONTINUE_INIT case */ if (in_handle.length !=sizeof (ctx)) {printerr (0 ,"WARNING: handle_nullreq: " -"input handle has unexpected length %d\n" , +"input handle has unexpected length %zd\n" , in_handle.length); goto out_err; }
utils/idmapd/idmapd.c +2 -1
@@ -65,8 +65,9 @@#include <limits.h> #include <ctype.h> #include <libgen.h> -#include <nfsidmap.h> +#include "compiler.h" +#include "nfsidmap.h" #include "xlog.h" #include "conffile.h" #include "queue.h"
utils/nfsidmap/nfsidmap.c +2 -1
@@ -10,9 +10,10 @@#include <pwd.h> #include <grp.h> #include <keyutils.h> -#include <nfsidmap.h> #include <unistd.h> +#include "compiler.h" +#include "nfsidmap.h" #include "xlog.h" #include "conffile.h" #include "xcommon.h"
Signature · 1 line
2.26.2
PATCH 10/10 Fix various clang warnings.
In reply to Doug Nazar--- configure.ac | 6 +++--- support/include/xcommon.h | 2 +- utils/mount/network.c | 4 ++-- utils/mount/stropts.c | 2 -- utils/mountd/cache.c | 2 +- 5 files changed, 7 insertions(+), 9 deletions(-)
configure.ac +3 -3
@@ -638,13 +638,12 @@ my_am_cflags="\ -Werror=parentheses \ -Werror=aggregate-return \ -Werror=unused-result \ - -Wno-cast-function-type \ -fno-strict-aliasing \ " AC_DEFUN([CHECK_CCSUPPORT], [ my_save_cflags="$CFLAGS" - CFLAGS=$1 + CFLAGS="-Werror $1" AC_MSG_CHECKING([whether CC supports $1]) AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], [AC_MSG_RESULT([yes])]
@@ -658,9 +657,10 @@ CHECK_CCSUPPORT([-Werror=format-overflow=2], [flg1]) CHECK_CCSUPPORT([-Werror=int-conversion], [flg2]) CHECK_CCSUPPORT([-Werror=incompatible-pointer-types], [flg3]) CHECK_CCSUPPORT([-Werror=misleading-indentation], [flg4]) +CHECK_CCSUPPORT([-Wno-cast-function-type], [flg5]) AX_GCC_FUNC_ATTRIBUTE([format]) -AC_SUBST([AM_CFLAGS], ["$my_am_cflags $flg1 $flg2 $flg3 $flg4"]) +AC_SUBST([AM_CFLAGS], ["$my_am_cflags $flg1 $flg2 $flg3 $flg4 $flg5"]) # Make sure that $ACLOCAL_FLAGS are used during a rebuild AC_SUBST([ACLOCAL_AMFLAGS], ["-I $ac_macro_dir \$(ACLOCAL_FLAGS)"])
support/include/xcommon.h +1 -1
@@ -7,7 +7,7 @@*/ #ifndef _XMALLOC_H -#define _MALLOC_H +#define _XMALLOC_H#include "compiler.h"
utils/mount/network.c +2 -2
@@ -1268,14 +1268,14 @@ nfs_nfs_program(struct mount_options *options, unsigned long *program)int nfs_nfs_version (char *type,struct mount_options *options,struct nfs_version *version) { -char *version_key, *version_val, *cptr; +char *version_key, *version_val =NULL , *cptr;int i, found =0 ; version->v_mode =V_DEFAULT ;for (i =0 ; nfs_version_opttbl[i]; i++) {if (po_contains_prefix (options, nfs_version_opttbl[i], - &version_key) ==PO_FOUND ) { + &version_key) ==PO_FOUND ) { found++;break ; }
utils/mount/stropts.c +0 -2
@@ -1094,9 +1094,7 @@ static int nfsmount_fg(struct nfsmount_info *mi)if (nfs_try_mount (mi))return EX_SUCCESS ; -#pragma GCC diagnostic ignored "-Wdiscarded-qualifiers"if (errno ==EBUSY &&is_mountpoint (mi->node)) { -#pragma GCC diagnostic warning "-Wdiscarded-qualifiers"/* * EBUSY can happen when mounting a filesystem that * is already mounted or when the context= are
utils/mountd/cache.c +1 -1
@@ -57,7 +57,7 @@ enum nfsd_fsid { };#undef is_mountpoint -static int is_mountpoint (char *path) +static int is_mountpoint (const char *path) {return check_is_mountpoint (path, nfsd_path_lstat); }
Signature · 1 line
2.26.2
Hey Doug,
Quoted 5 lines · Doug Nazar
Most of this work centers around gssd, however a few items I did tree wide. It's been compile tested with both gcc & clang on
x86_64& arm32 and runtime tested onx86_64.
Quoted 10 lines
Doug Nazar (10):
gssd: Refcount structclnt_infoto protect multithread usage Update to libevent 2.x apis.
gssd: Cleanup on exit to support valgrind.
gssd:gssd_k5_err_msg()returns a strdup'd msg. Usefree()to release.
gssd: Fix locking for machine principal list
gssd: Add a few debug statements to help trackclient_infolifetimes.
gssd: Lookup local hostname when srchost is '*'
gssd: We never use the nocache param ofgssd_check_if_cc_exists()Fix various clang warnings.
I did commit all of the above... (tag: nfs-utils-2-5-2-rc1)
I did not commit the following
Cleanup printf format attribute handling and fix format strings
because 3 different version were posted
Cleanup printf format attribute handling and fix various format strings Cleanup printf format attribute handling and fix format strings Consolidate printf format attribute handling and fix various format strings
I was not sure which one you wanted and I was wondering what exactly is being cleaned up? What problems is this solving?
Finally, being this is a whole tree commit and I have a number of patches in the queue.. I would like to hold off on this one.
A patch like this will cause all those patches in the queue not to apply... So once I drain the queue, hopefully you would not mind rebasing... after we talk about what you are trying to do.
I do appreciate the hard work... esp with gssd... I did test it every step of the way... and it seems to be fairly solid... nice work!
steved.
Quoted 39 lines
aclocal/libevent.m4 | 6 +- configure.ac | 6 +- support/include/compiler.h | 14 + support/include/xcommon.h | 12 +- support/include/xlog.h | 20 +- support/nfs/xcommon.c | 2 + support/nfsidmap/gums.c | 2 + support/nfsidmap/libnfsidmap.c | 8 +- support/nfsidmap/nfsidmap.h | 10 +- support/nfsidmap/nfsidmap_common.c | 1 + support/nfsidmap/nss.c | 4 +- support/nfsidmap/regex.c | 6 +- support/nfsidmap/static.c | 1 + support/nfsidmap/umich_ldap.c | 10 +- tools/locktest/testlk.c | 6 +- utils/exportfs/exportfs.c | 5 +- utils/gssd/err_util.h | 4 +- utils/gssd/gss_names.c | 9 +- utils/gssd/gss_util.c | 2 +- utils/gssd/gssd.c | 165 ++++++++--- utils/gssd/gssd.h | 10 +- utils/gssd/gssd_proc.c | 14 +- utils/gssd/krb5_util.c | 422 +++++++++++++++++------------ utils/gssd/krb5_util.h | 16 +- utils/gssd/svcgssd.c | 4 +- utils/gssd/svcgssd_proc.c | 9 +- utils/idmapd/idmapd.c | 65 +++-- utils/mount/network.c | 4 +- utils/mount/stropts.c | 2 - utils/mountd/cache.c | 2 +- utils/nfsdcld/cld-internal.h | 2 +- utils/nfsdcld/nfsdcld.c | 29 +- utils/nfsdcld/sqlite.c | 1 - utils/nfsdcltrack/sqlite.c | 2 +- utils/nfsidmap/nfsidmap.c | 3 +- 35 files changed, 536 insertions(+), 342 deletions(-) create mode 100644 support/include/compiler.h
Quoted 11 lines · Steve Dickson
Quoted 10 lines
gssd: Refcount struct
clnt_infoto protect multithread usage Update to libevent 2.x apis.
gssd: Cleanup on exit to support valgrind.
gssd:gssd_k5_err_msg()returns a strdup'd msg. Usefree()to release.
gssd: Fix locking for machine principal list
gssd: Add a few debug statements to help trackclient_infolifetimes.
gssd: Lookup local hostname when srchost is '*'
gssd: We never use the nocache param ofgssd_check_if_cc_exists()Fix various clang warnings.I did commit all of the above... (tag: nfs-utils-2-5-2-rc1)
Oops, I'd been working on an updated patch set. There's nothing really actively wrong in the above patches. I'd just gone back and added proper NULL checks and error messages for the libevent conversion. I'll rebase and send that as an update. Also "gssd: Lookup local hostname when srchost is '*'" I think is wrong. After the first day I couldn't get it to repeat, and think it was a mis-compile issue. However, the new code arrangement is better in that it shows the correct dns name transformation. Previously it would use the same buffer for input & output which made the log message very confusing. I'll just drop the '*' check.
Quoted 11 lines
I did not commit the following
Cleanup printf format attribute handling and fix format stringsbecause 3 different version were posted
Cleanup printf format attribute handling and fix various format strings Cleanup printf format attribute handling and fix format strings Consolidate printf format attribute handling and fix various format strings
I was not sure which one you wanted and I was wondering what exactly is being cleaned up? What problems is this solving?
They're all the same patch. The summary line was wrapping in the cover letter so I edited it a few times, not realizing that format-patch was creating another file even if I aborted.
So, it actually does a few things, all based around fixing printf style formats.
There were 2 different macros defined to add printf format attribute to functions, and several open codings. So it first consolidates them into one set of macros (although there is a second copy in nfsidmap.h since that's an installed file and can't depend on config.h.
Then, there were several functions that were not marked with the printf format attribute (nfsidmap plugins and gssd printerr()).
Finally, a cleanup of all the resulting gcc & clang warnings on both 32 & 64 bit. In several cases some real errors, not enough parameters, passing in various types for the dynamic length which requires an int, passing in a char** instead of char*, etc. Of course these are mainly debugging messages so rarely caused an issue but were in need of cleaning up.
Quoted 7 lines
Finally, being this is a whole tree commit and I have a number of patches in the queue.. I would like to hold off on this one.
A patch like this will cause all those patches in the queue not to apply... So once I drain the queue, hopefully you would not mind rebasing... after we talk about what you are trying to do.
Not a problem. I have it rebased here and can send it at any time, or split it up if you prefer.
Quoted 3 lines
I do appreciate the hard work... esp with gssd... I did test it every step of the way... and it seems to be fairly solid... nice work!
I've been chasing that threading bug for over a year. Trying to stress the number of simultaneous mounts, types, etc. never thinking the issue was external. I bet if I went back and correlated the crashes I saw, probably happened when I was upgrading or rebooting the kdc.
Doug