Blame SOURCES/nfs-utils-2.3.3-gssd-debug-cleanup.patch

4cb8ad
diff -up nfs-utils-2.3.3/utils/gssd/err_util.c.orig nfs-utils-2.3.3/utils/gssd/err_util.c
4cb8ad
--- nfs-utils-2.3.3/utils/gssd/err_util.c.orig	2018-09-06 14:09:08.000000000 -0400
4cb8ad
+++ nfs-utils-2.3.3/utils/gssd/err_util.c	2021-07-19 12:29:21.366829573 -0400
4cb8ad
@@ -70,3 +70,17 @@ int get_verbosity(void)
4cb8ad
 {
4cb8ad
 	return verbosity;
4cb8ad
 }
4cb8ad
+
4cb8ad
+char * 
4cb8ad
+sec2time(int value)
4cb8ad
+{
4cb8ad
+    static char buf[BUFSIZ];
4cb8ad
+    int hr, min, sec;
4cb8ad
+
4cb8ad
+    hr = (value / 3600);
4cb8ad
+    min = (value  - (3600*hr))/60;
4cb8ad
+    sec = (value  - (3600*hr) - (min*60));
4cb8ad
+    sprintf(buf, "%dh:%dm:%ds", hr, min, sec);
4cb8ad
+    return(buf);
4cb8ad
+}
4cb8ad
+
4cb8ad
diff -up nfs-utils-2.3.3/utils/gssd/err_util.h.orig nfs-utils-2.3.3/utils/gssd/err_util.h
4cb8ad
--- nfs-utils-2.3.3/utils/gssd/err_util.h.orig	2018-09-06 14:09:08.000000000 -0400
4cb8ad
+++ nfs-utils-2.3.3/utils/gssd/err_util.h	2021-07-19 12:29:21.367829599 -0400
4cb8ad
@@ -34,5 +34,6 @@
4cb8ad
 void initerr(char *progname, int verbosity, int fg);
4cb8ad
 void printerr(int priority, char *format, ...);
4cb8ad
 int get_verbosity(void);
4cb8ad
+char * sec2time(int);
4cb8ad
 
4cb8ad
 #endif /* _ERR_UTIL_H_ */
4cb8ad
diff -up nfs-utils-2.3.3/utils/gssd/gssd.c.orig nfs-utils-2.3.3/utils/gssd/gssd.c
4cb8ad
--- nfs-utils-2.3.3/utils/gssd/gssd.c.orig	2021-07-19 12:24:13.963644016 -0400
4cb8ad
+++ nfs-utils-2.3.3/utils/gssd/gssd.c	2021-07-19 12:29:21.368829626 -0400
4cb8ad
@@ -396,7 +396,7 @@ gssd_free_client(struct clnt_info *clp)
4cb8ad
 	if (refcnt > 0)
4cb8ad
 		return;
4cb8ad
 
4cb8ad
-	printerr(3, "freeing client %s\n", clp->relpath);
4cb8ad
+	printerr(4, "freeing client %s\n", clp->relpath);
4cb8ad
 
4cb8ad
 	if (clp->krb5_fd >= 0)
4cb8ad
 		close(clp->krb5_fd);
4cb8ad
@@ -417,7 +417,7 @@ gssd_free_client(struct clnt_info *clp)
4cb8ad
 static void
4cb8ad
 gssd_destroy_client(struct clnt_info *clp)
4cb8ad
 {
4cb8ad
-	printerr(3, "destroying client %s\n", clp->relpath);
4cb8ad
+	printerr(4, "destroying client %s\n", clp->relpath);
4cb8ad
 
4cb8ad
 	if (clp->krb5_ev) {
4cb8ad
 		event_del(clp->krb5_ev);
4cb8ad
@@ -494,7 +494,7 @@ scan_active_thread_list(void)
4cb8ad
 			 * upcall_thread_info from the list and free it.
4cb8ad
 			 */
4cb8ad
 			if (tret == PTHREAD_CANCELED)
4cb8ad
-				printerr(3, "watchdog: thread id 0x%lx cancelled successfully\n",
4cb8ad
+				printerr(2, "watchdog: thread id 0x%lx cancelled successfully\n",
4cb8ad
 						info->tid);
4cb8ad
 			saveprev = info->list.tqe_prev;
4cb8ad
 			TAILQ_REMOVE(&active_thread_list, info, list);
4cb8ad
@@ -783,7 +783,7 @@ gssd_scan(void)
4cb8ad
 {
4cb8ad
 	struct dirent *d;
4cb8ad
 
4cb8ad
-	printerr(3, "doing a full rescan\n");
4cb8ad
+	printerr(4, "doing a full rescan\n");
4cb8ad
 	rewinddir(pipefs_dir);
4cb8ad
 
4cb8ad
 	while ((d = readdir(pipefs_dir))) {
4cb8ad
diff -up nfs-utils-2.3.3/utils/gssd/gssd_proc.c.orig nfs-utils-2.3.3/utils/gssd/gssd_proc.c
4cb8ad
--- nfs-utils-2.3.3/utils/gssd/gssd_proc.c.orig	2021-07-19 12:24:13.964644043 -0400
4cb8ad
+++ nfs-utils-2.3.3/utils/gssd/gssd_proc.c	2021-07-19 12:29:21.368829626 -0400
4cb8ad
@@ -166,8 +166,9 @@ do_downcall(int k5_fd, uid_t uid, struct
4cb8ad
 	unsigned int buf_size = 0;
4cb8ad
 	pthread_t tid = pthread_self();
4cb8ad
 
4cb8ad
-	printerr(2, "do_downcall(0x%x): lifetime_rec=%u acceptor=%.*s\n",
4cb8ad
-		tid, lifetime_rec, acceptor->length, acceptor->value);
4cb8ad
+	if (get_verbosity() > 1)
4cb8ad
+		printerr(2, "do_downcall(0x%lx): lifetime_rec=%s acceptor=%.*s\n",
4cb8ad
+			tid, sec2time(lifetime_rec), acceptor->length, acceptor->value);
4cb8ad
 	buf_size = sizeof(uid) + sizeof(timeout) + sizeof(pd->pd_seq_win) +
4cb8ad
 		sizeof(pd->pd_ctx_hndl.length) + pd->pd_ctx_hndl.length +
4cb8ad
 		sizeof(context_token->length) + context_token->length +
4cb8ad
@@ -193,7 +194,7 @@ do_downcall(int k5_fd, uid_t uid, struct
4cb8ad
 	return;
4cb8ad
 out_err:
4cb8ad
 	free(buf);
4cb8ad
-	printerr(1, "do_downcall(0x%x): Failed to write downcall!\n", tid);
4cb8ad
+	printerr(1, "do_downcall(0x%lx): Failed to write downcall!\n", tid);
4cb8ad
 	return;
4cb8ad
 }
4cb8ad
 
4cb8ad
@@ -204,8 +205,9 @@ do_error_downcall(int k5_fd, uid_t uid,
4cb8ad
 	char	*p = buf, *end = buf + 1024;
4cb8ad
 	unsigned int timeout = 0;
4cb8ad
 	int	zero = 0;
4cb8ad
+	pthread_t tid = pthread_self();
4cb8ad
 
4cb8ad
-	printerr(2, "doing error downcall\n");
4cb8ad
+	printerr(2, "do_error_downcall(0x%lx): uid %d err %d\n", tid, uid, err);
4cb8ad
 
4cb8ad
 	if (WRITE_BYTES(&p, end, uid)) goto out_err;
4cb8ad
 	if (WRITE_BYTES(&p, end, timeout)) goto out_err;
4cb8ad
@@ -328,6 +330,7 @@ create_auth_rpc_client(struct clnt_info
4cb8ad
 	struct timeval	timeout;
4cb8ad
 	struct sockaddr		*addr = (struct sockaddr *) &clp->addr;
4cb8ad
 	socklen_t		salen;
4cb8ad
+	pthread_t tid = pthread_self();
4cb8ad
 
4cb8ad
 	sec.qop = GSS_C_QOP_DEFAULT;
4cb8ad
 	sec.svc = RPCSEC_GSS_SVC_NONE;
4cb8ad
@@ -361,8 +364,8 @@ create_auth_rpc_client(struct clnt_info
4cb8ad
 
4cb8ad
 	/* create an rpc connection to the nfs server */
4cb8ad
 
4cb8ad
-	printerr(2, "creating %s client for server %s\n", clp->protocol,
4cb8ad
-			clp->servername);
4cb8ad
+	printerr(3, "create_auth_rpc_client(0x%lx): creating %s client for server %s\n", 
4cb8ad
+		tid, clp->protocol, clp->servername);
4cb8ad
 
4cb8ad
 	protocol = IPPROTO_TCP;
4cb8ad
 	if ((strcmp(clp->protocol, "udp")) == 0)
4cb8ad
@@ -405,7 +408,8 @@ create_auth_rpc_client(struct clnt_info
4cb8ad
 	if (!tgtname)
4cb8ad
 		tgtname = clp->servicename;
4cb8ad
 
4cb8ad
-	printerr(2, "creating context with server %s\n", tgtname);
4cb8ad
+	printerr(3, "create_auth_rpc_client(0x%lx): creating context with server %s\n", 
4cb8ad
+		tid, tgtname);
4cb8ad
 	auth = authgss_create_default(rpc_clnt, tgtname, &sec);
4cb8ad
 	if (!auth) {
4cb8ad
 		/* Our caller should print appropriate message */
4cb8ad
@@ -507,9 +511,10 @@ krb5_not_machine_creds(struct clnt_info
4cb8ad
 	gss_cred_id_t	gss_cred;
4cb8ad
 	char		**dname;
4cb8ad
 	int		err, resp = -1;
4cb8ad
+	pthread_t tid = pthread_self();
4cb8ad
 
4cb8ad
-	printerr(2, "krb5_not_machine_creds: uid %d tgtname %s\n", 
4cb8ad
-		uid, tgtname);
4cb8ad
+	printerr(2, "krb5_not_machine_creds(0x%lx): uid %d tgtname %s\n", 
4cb8ad
+		tid, uid, tgtname);
4cb8ad
 
4cb8ad
 	*chg_err = change_identity(uid);
4cb8ad
 	if (*chg_err) {
4cb8ad
@@ -555,9 +560,10 @@ krb5_use_machine_creds(struct clnt_info
4cb8ad
 	char	**ccname;
4cb8ad
 	int	nocache = 0;
4cb8ad
 	int	success = 0;
4cb8ad
+	pthread_t tid = pthread_self();
4cb8ad
 
4cb8ad
-	printerr(2, "krb5_use_machine_creds: uid %d tgtname %s\n", 
4cb8ad
-		uid, tgtname);
4cb8ad
+	printerr(2, "krb5_use_machine_creds(0x%lx): uid %d tgtname %s\n", 
4cb8ad
+		tid, uid, tgtname);
4cb8ad
 
4cb8ad
 	do {
4cb8ad
 		gssd_refresh_krb5_machine_credential(clp->servername,
4cb8ad
@@ -874,6 +880,7 @@ start_upcall_thread(void (*func)(struct
4cb8ad
 	pthread_t th;
4cb8ad
 	struct upcall_thread_info *tinfo;
4cb8ad
 	int ret;
4cb8ad
+	pthread_t tid = pthread_self();
4cb8ad
 
4cb8ad
 	tinfo = alloc_upcall_thread_info();
4cb8ad
 	if (!tinfo)
4cb8ad
@@ -896,6 +903,9 @@ start_upcall_thread(void (*func)(struct
4cb8ad
 		free(tinfo);
4cb8ad
 		return ret;
4cb8ad
 	}
4cb8ad
+	printerr(2, "start_upcall_thread(0x%lx): created thread id 0x%lx\n", 
4cb8ad
+		tid, th);
4cb8ad
+
4cb8ad
 	tinfo->tid = th;
4cb8ad
 	pthread_mutex_lock(&active_thread_list_lock);
4cb8ad
 	clock_gettime(CLOCK_MONOTONIC, &tinfo->timeout);
4cb8ad
@@ -958,7 +968,7 @@ handle_gssd_upcall(struct clnt_info *clp
4cb8ad
 	}
4cb8ad
 	lbuf[lbuflen-1] = 0;
4cb8ad
 
4cb8ad
-	printerr(2, "\n%s(0x%x): '%s' (%s)\n", __func__, tid,
4cb8ad
+	printerr(2, "\n%s(0x%lx): '%s' (%s)\n", __func__, tid,
4cb8ad
 		 lbuf, clp->relpath);
4cb8ad
 
4cb8ad
 	for (p = strtok(lbuf, " "); p; p = strtok(NULL, " ")) {
4cb8ad
diff -up nfs-utils-2.3.3/utils/gssd/krb5_util.c.orig nfs-utils-2.3.3/utils/gssd/krb5_util.c
4cb8ad
--- nfs-utils-2.3.3/utils/gssd/krb5_util.c.orig	2021-07-19 12:24:13.951643697 -0400
4cb8ad
+++ nfs-utils-2.3.3/utils/gssd/krb5_util.c	2021-07-19 12:36:27.746223992 -0400
4cb8ad
@@ -375,6 +375,7 @@ gssd_get_single_krb5_cred(krb5_context c
4cb8ad
 	char *cache_type;
4cb8ad
 	char *pname = NULL;
4cb8ad
 	char *k5err = NULL;
4cb8ad
+	pthread_t tid = pthread_self();
4cb8ad
 
4cb8ad
 	memset(&my_creds, 0, sizeof(my_creds));
4cb8ad
 
4cb8ad
@@ -385,8 +386,8 @@ gssd_get_single_krb5_cred(krb5_context c
4cb8ad
 	now += 300;
4cb8ad
 	pthread_mutex_lock(&ple_lock);
4cb8ad
 	if (ple->ccname && ple->endtime > now && !nocache) {
4cb8ad
-		printerr(3, "INFO: Credentials in CC '%s' are good until %d\n",
4cb8ad
-			 ple->ccname, ple->endtime);
4cb8ad
+		printerr(3, "%s(0x%lx): Credentials in CC '%s' are good until %s",
4cb8ad
+			 __func__, tid, ple->ccname, ctime((time_t *)&ple->endtime));
4cb8ad
 		code = 0;
4cb8ad
 		pthread_mutex_unlock(&ple_lock);
4cb8ad
 		goto out;
4cb8ad
@@ -486,7 +487,8 @@ gssd_get_single_krb5_cred(krb5_context c
4cb8ad
 	}
4cb8ad
 
4cb8ad
 	code = 0;
4cb8ad
-	printerr(2, "%s: principal '%s' ccache:'%s'\n", __func__, pname, cc_name);
4cb8ad
+	printerr(2, "%s(0x%lx): principal '%s' ccache:'%s'\n", 
4cb8ad
+		__func__, tid, pname, cc_name);
4cb8ad
   out:
4cb8ad
 #ifdef HAVE_KRB5_GET_INIT_CREDS_OPT_SET_ADDRESSLESS
4cb8ad
 	if (init_opts)
4cb8ad
@@ -615,6 +617,7 @@ get_full_hostname(const char *inhost, ch
4cb8ad
 	struct addrinfo hints;
4cb8ad
 	int retval;
4cb8ad
 	char *c;
4cb8ad
+	pthread_t tid = pthread_self();
4cb8ad
 
4cb8ad
 	memset(&hints, 0, sizeof(hints));
4cb8ad
 	hints.ai_socktype = SOCK_STREAM;
4cb8ad
@@ -624,8 +627,8 @@ get_full_hostname(const char *inhost, ch
4cb8ad
 	/* Get full target hostname */
4cb8ad
 	retval = getaddrinfo(inhost, NULL, &hints, &addrs);
4cb8ad
 	if (retval) {
4cb8ad
-		printerr(1, "%s while getting full hostname for '%s'\n",
4cb8ad
-			 gai_strerror(retval), inhost);
4cb8ad
+		printerr(1, "%s(0x%lx): getaddrinfo(%s) failed: %s\n",
4cb8ad
+			 __func__, tid, inhost, gai_strerror(retval));
4cb8ad
 		goto out;
4cb8ad
 	}
4cb8ad
 	strncpy(outhost, addrs->ai_canonname, outhostlen);
4cb8ad
@@ -633,7 +636,10 @@ get_full_hostname(const char *inhost, ch
4cb8ad
 	for (c = outhost; *c != '\0'; c++)
4cb8ad
 	    *c = tolower(*c);
4cb8ad
 
4cb8ad
-	printerr(3, "Full hostname for '%s' is '%s'\n", inhost, outhost);
4cb8ad
+	if (get_verbosity() && strcmp(inhost, outhost))
4cb8ad
+		printerr(1, "%s(0x%0lx): inhost '%s' different than outhost'%s'\n", 
4cb8ad
+			inhost, outhost);
4cb8ad
+
4cb8ad
 	retval = 0;
4cb8ad
 out:
4cb8ad
 	return retval;
4cb8ad
@@ -819,6 +825,7 @@ find_keytab_entry(krb5_context context,
4cb8ad
 	krb5_principal princ;
4cb8ad
 	const char *notsetstr = "not set";
4cb8ad
 	char *adhostoverride = NULL;
4cb8ad
+	pthread_t tid = pthread_self();
4cb8ad
 
4cb8ad
 
4cb8ad
 	/* Get full target hostname */
4cb8ad
@@ -972,7 +979,7 @@ find_keytab_entry(krb5_context context,
4cb8ad
 					tried_upper = 1;
4cb8ad
 				}
4cb8ad
 			} else {
4cb8ad
-				printerr(2, "Success getting keytab entry for '%s'\n",spn);
4cb8ad
+				printerr(2, "find_keytab_entry(0x%lx): Success getting keytab entry for '%s'\n",tid, spn);
4cb8ad
 				retval = 0;
4cb8ad
 				goto out;
4cb8ad
 			}
4cb8ad
@@ -1113,9 +1120,6 @@ gssd_refresh_krb5_machine_credential_int
4cb8ad
 	char *k5err = NULL;
4cb8ad
 	const char *svcnames[] = { "$", "root", "nfs", "host", NULL };
4cb8ad
 
4cb8ad
-	printerr(2, "%s: hostname=%s ple=%p service=%s srchost=%s\n",
4cb8ad
-		__func__, hostname, ple, service, srchost);
4cb8ad
-
4cb8ad
 	/*
4cb8ad
 	 * If a specific service name was specified, use it.
4cb8ad
 	 * Otherwise, use the default list.
4cb8ad
@@ -1124,9 +1128,10 @@ gssd_refresh_krb5_machine_credential_int
4cb8ad
 		svcnames[0] = service;
4cb8ad
 		svcnames[1] = NULL;
4cb8ad
 	}
4cb8ad
-	if (hostname == NULL && ple == NULL)
4cb8ad
+	if (hostname == NULL && ple == NULL) {
4cb8ad
+		printerr(0, "ERROR: %s: Invalid args\n", __func__);
4cb8ad
 		return EINVAL;
4cb8ad
-
4cb8ad
+	}
4cb8ad
 	code = krb5_init_context(&context);
4cb8ad
 	if (code) {
4cb8ad
 		k5err = gssd_k5_err_msg(NULL, code);