[SCM] Samba Shared Repository - branch master updated

Andreas Schneider asn at samba.org
Mon Nov 12 12:45:04 UTC 2018


The branch, master has been updated
       via  c10d70c43c9 pam_winbind: Set the request type as client name
       via  ffc8b4ac8d4 nss_wins: Set client process name
       via  2a918a64f05 nss_winbind: Set the client process name
       via  6f257f958fe krb5_plugin: Set the wbclient process name
       via  1834513ebe3 wbclient: Add wbcSetClientProcessName()
       via  f49b62b44dd s3:winbind: Log client process name for PAM auth
       via  ec87ca8bdc1 s3:winbind: Log client process name in winbind_misc
       via  d26caa27e1c s3:winbind: Log client process name
       via  305f3bc492b s3:winbindd: Also log the process name in winbindd
       via  ba9ad126656 wbclient: Send the client process name talking to winbind
       via  c8e27b6f334 lib:replace: Add getprogname()
      from  899d00e6be5 s4-auth-tests: Fix test_kerberos with MIT krb

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit c10d70c43c935c5388654f78b3ac51ec43bbdf02
Author: Andreas Schneider <asn at samba.org>
Date:   Fri Nov 2 18:58:25 2018 +0100

    pam_winbind: Set the request type as client name
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Andreas Schneider <asn at cryptomilk.org>
    Autobuild-Date(master): Mon Nov 12 13:44:09 CET 2018 on sn-devel-144

commit ffc8b4ac8d418b44da7206469ae076398e12b7ac
Author: Andreas Schneider <asn at samba.org>
Date:   Mon Nov 5 08:16:23 2018 +0100

    nss_wins: Set client process name
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 2a918a64f055562db40cf34029f2216812b54281
Author: Andreas Schneider <asn at samba.org>
Date:   Mon Nov 5 08:14:48 2018 +0100

    nss_winbind: Set the client process name
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 6f257f958fe448f6cf12008ad8c380aeb748c657
Author: Andreas Schneider <asn at samba.org>
Date:   Mon Nov 5 08:11:27 2018 +0100

    krb5_plugin: Set the wbclient process name
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 1834513ebe394f4e5111665a21df652e59b3b0b6
Author: Andreas Schneider <asn at samba.org>
Date:   Fri Nov 2 18:57:05 2018 +0100

    wbclient: Add wbcSetClientProcessName()
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit f49b62b44dd5dceb537a5364b1ff107db9a7aea4
Author: Andreas Schneider <asn at samba.org>
Date:   Mon Nov 5 11:56:21 2018 +0100

    s3:winbind: Log client process name for PAM auth
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit ec87ca8bdc14a1ac0895f4333a2b00ef866edd66
Author: Andreas Schneider <asn at samba.org>
Date:   Mon Nov 5 11:55:46 2018 +0100

    s3:winbind: Log client process name in winbind_misc
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit d26caa27e1cf286475a0d09621cc38d2b4e4335d
Author: Andreas Schneider <asn at samba.org>
Date:   Fri Nov 2 18:56:29 2018 +0100

    s3:winbind: Log client process name
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 305f3bc492b2d0664cafbd805f3a668a37d4ebc1
Author: Andreas Schneider <asn at samba.org>
Date:   Fri Nov 2 18:45:26 2018 +0100

    s3:winbindd: Also log the process name in winbindd
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit ba9ad1266561d7003727dfb12915234d75a575f5
Author: Andreas Schneider <asn at samba.org>
Date:   Fri Nov 2 18:39:26 2018 +0100

    wbclient: Send the client process name talking to winbind
    
    This is for better debugging messages.
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit c8e27b6f334931d5a609af6b50c9e0756e88b672
Author: Andreas Schneider <asn at samba.org>
Date:   Fri Nov 2 18:04:28 2018 +0100

    lib:replace: Add getprogname()
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 lib/replace/replace.c                              | 71 ++++++++++++++++++++++
 lib/replace/replace.h                              |  5 ++
 lib/replace/wscript                                |  1 +
 nsswitch/krb5_plugin/winbind_krb5_localauth.c      |  2 +
 .../ABI/{wbclient-0.13.sigs => wbclient-0.15.sigs} |  1 +
 nsswitch/libwbclient/wbc_util.c                    |  5 ++
 nsswitch/libwbclient/wbclient.h                    | 16 ++++-
 nsswitch/libwbclient/wscript                       |  2 +-
 nsswitch/pam_winbind.c                             |  8 +++
 nsswitch/wb_common.c                               | 32 ++++++++++
 nsswitch/winbind_client.h                          |  2 +
 nsswitch/winbind_nss_linux.c                       | 11 ++++
 nsswitch/winbind_struct_protocol.h                 |  4 +-
 nsswitch/wins.c                                    |  2 +
 source3/torture/wbc_async.c                        |  4 ++
 source3/winbindd/winbindd.c                        | 19 ++++--
 source3/winbindd/winbindd.h                        |  1 +
 source3/winbindd/winbindd_getdcname.c              |  6 +-
 source3/winbindd/winbindd_getgrent.c               |  4 +-
 source3/winbindd/winbindd_getgrgid.c               |  5 +-
 source3/winbindd/winbindd_getgrnam.c               |  5 +-
 source3/winbindd/winbindd_getgroups.c              |  5 +-
 source3/winbindd/winbindd_getpwent.c               |  4 +-
 source3/winbindd/winbindd_getpwnam.c               |  5 +-
 source3/winbindd/winbindd_getpwsid.c               |  5 +-
 source3/winbindd/winbindd_getpwuid.c               |  5 +-
 source3/winbindd/winbindd_getsidaliases.c          |  5 +-
 source3/winbindd/winbindd_getuserdomgroups.c       |  5 +-
 source3/winbindd/winbindd_getusersids.c            |  5 +-
 source3/winbindd/winbindd_misc.c                   | 46 +++++++++-----
 source3/winbindd/winbindd_pam_auth.c               |  6 +-
 31 files changed, 258 insertions(+), 39 deletions(-)
 copy nsswitch/libwbclient/ABI/{wbclient-0.13.sigs => wbclient-0.15.sigs} (99%)


Changeset truncated at 500 lines:

diff --git a/lib/replace/replace.c b/lib/replace/replace.c
index 113137c2992..e38df98ea3a 100644
--- a/lib/replace/replace.c
+++ b/lib/replace/replace.c
@@ -978,3 +978,74 @@ int rep_memset_s(void *dest, size_t destsz, int ch, size_t count)
 	return 0;
 }
 #endif /* HAVE_MEMSET_S */
+
+#ifndef HAVE_GETPROGNAME
+# ifndef _GNU_SOURCE
+# define PROGNAME_SIZE 32
+static char rep_progname[PROGNAME_SIZE];
+# endif /* _GNU_SOURCE */
+
+const char *rep_getprogname(void)
+{
+#ifdef _GNU_SOURCE
+	return program_invocation_short_name;
+#else /* _GNU_SOURCE */
+	FILE *fp = NULL;
+	char cmdline[4096] = {0};
+	char *p = NULL;
+	pid_t pid;
+	size_t nread;
+	int len;
+
+	if (rep_progname[0] != '\0') {
+		return rep_progname;
+	}
+
+	len = snprintf(rep_progname, sizeof(rep_progname), "%s", "<unknown>");
+	if (len <= 0) {
+		return "<unknown>";
+	}
+
+	pid = getpid();
+	if (pid <= 1 || pid == (pid_t)-1) {
+		return rep_progname;
+	}
+
+	len = snprintf(cmdline,
+		       sizeof(cmdline),
+		       "/proc/%u/cmdline",
+		       (unsigned int)pid);
+	if (len <= 0 || len == sizeof(cmdline)) {
+		return rep_progname;
+	}
+
+	fp = fopen(cmdline, "r");
+	if (fp == NULL) {
+		return rep_progname;
+	}
+
+	nread = fread(cmdline, 1, sizeof(cmdline) - 1, fp);
+	if (nread == 0) {
+		return rep_progname;
+	}
+
+	cmdline[nread] = '\0';
+
+	p = strrchr(cmdline, '/');
+	if (p != NULL) {
+		p++;
+	} else {
+		p = cmdline;
+	}
+
+	len = strlen(p);
+	if (len > PROGNAME_SIZE) {
+		p[PROGNAME_SIZE - 1] = '\0';
+	}
+
+	(void)snprintf(rep_progname, sizeof(rep_progname), "%s", p);
+
+	return rep_progname;
+#endif /* _GNU_SOURCE */
+}
+#endif /* HAVE_GETPROGNAME */
diff --git a/lib/replace/replace.h b/lib/replace/replace.h
index de4e20c4454..732a8226858 100644
--- a/lib/replace/replace.h
+++ b/lib/replace/replace.h
@@ -933,6 +933,11 @@ void rep_setproctitle_init(int argc, char *argv[], char *envp[]);
 int rep_memset_s(void *dest, size_t destsz, int ch, size_t count);
 #endif
 
+#ifndef HAVE_GETPROGNAME
+#define getprogname rep_getprogname
+const char *rep_getprogname(void);
+#endif
+
 #ifndef FALL_THROUGH
 # ifdef HAVE_FALLTHROUGH_ATTRIBUTE
 #  define FALL_THROUGH __attribute__ ((fallthrough))
diff --git a/lib/replace/wscript b/lib/replace/wscript
index 8adfffe9584..c8693a3f2e1 100644
--- a/lib/replace/wscript
+++ b/lib/replace/wscript
@@ -426,6 +426,7 @@ def configure(conf):
     conf.CHECK_FUNCS('getgrent_r getgrgid_r getgrnam_r getgrouplist getpagesize')
     conf.CHECK_FUNCS('getpwent_r getpwnam_r getpwuid_r epoll_create')
     conf.CHECK_FUNCS('port_create')
+    conf.CHECK_FUNCS('getprogname')
 
     conf.SET_TARGET_TYPE('attr', 'EMPTY')
 
diff --git a/nsswitch/krb5_plugin/winbind_krb5_localauth.c b/nsswitch/krb5_plugin/winbind_krb5_localauth.c
index b412575e4fe..e27bd6c6c54 100644
--- a/nsswitch/krb5_plugin/winbind_krb5_localauth.c
+++ b/nsswitch/krb5_plugin/winbind_krb5_localauth.c
@@ -52,6 +52,8 @@ static krb5_error_code winbind_init(krb5_context context,
 		return ENOMEM;
 	}
 
+	wbcSetClientProcessName("krb5_localauth_plugin");
+
 	*data = d;
 
 	return 0;
diff --git a/nsswitch/libwbclient/ABI/wbclient-0.13.sigs b/nsswitch/libwbclient/ABI/wbclient-0.15.sigs
similarity index 99%
copy from nsswitch/libwbclient/ABI/wbclient-0.13.sigs
copy to nsswitch/libwbclient/ABI/wbclient-0.15.sigs
index b07a6a834e7..a3019b5c68a 100644
--- a/nsswitch/libwbclient/ABI/wbclient-0.13.sigs
+++ b/nsswitch/libwbclient/ABI/wbclient-0.15.sigs
@@ -113,6 +113,7 @@ wbcRequestResponse: wbcErr (struct wbcContext *, int, struct winbindd_request *,
 wbcRequestResponsePriv: wbcErr (struct wbcContext *, int, struct winbindd_request *, struct winbindd_response *)
 wbcResolveWinsByIP: wbcErr (const char *, char **)
 wbcResolveWinsByName: wbcErr (const char *, char **)
+wbcSetClientProcessName: void (const char *)
 wbcSetGidHwm: wbcErr (gid_t)
 wbcSetGidMapping: wbcErr (gid_t, const struct wbcDomainSid *)
 wbcSetUidHwm: wbcErr (uid_t)
diff --git a/nsswitch/libwbclient/wbc_util.c b/nsswitch/libwbclient/wbc_util.c
index fc6a840cc71..476ed50fa44 100644
--- a/nsswitch/libwbclient/wbc_util.c
+++ b/nsswitch/libwbclient/wbc_util.c
@@ -894,3 +894,8 @@ done:
 	wbcFreeMemory(blobs);
 	return wbc_status;
 }
+
+void wbcSetClientProcessName(const char *name)
+{
+	winbind_set_client_name(name);
+}
diff --git a/nsswitch/libwbclient/wbclient.h b/nsswitch/libwbclient/wbclient.h
index 81a6a6a069b..05cf8a14b80 100644
--- a/nsswitch/libwbclient/wbclient.h
+++ b/nsswitch/libwbclient/wbclient.h
@@ -76,9 +76,10 @@ const char *wbcErrorString(wbcErr error);
  *  0.13: Added wbcCtxUnixIdsToSids and wbcUnixIdsToSids
  *  0.14: Added "authoritative" to wbcAuthErrorInfo
  *        Added WBC_SID_NAME_LABEL
+ *  0.15: Added wbcSetClientProcessName()
  **/
 #define WBCLIENT_MAJOR_VERSION 0
-#define WBCLIENT_MINOR_VERSION 14
+#define WBCLIENT_MINOR_VERSION 15
 #define WBCLIENT_VENDOR_VERSION "Samba libwbclient"
 struct wbcLibraryDetails {
 	uint16_t major_version;
@@ -2051,4 +2052,17 @@ wbcErr wbcAddNamedBlob(size_t *num_blobs,
 		       uint8_t *data,
 		       size_t length);
 
+/**
+ * @brief Set the name of the process which call wbclient.
+ *
+ * By default wbclient will figure out the process name. This should just be
+ * used in special cases like pam modules or similar. Only alpha numeric
+ * chars in ASCII are allowed.
+ *
+ * This function should only be called once!
+ *
+ * @param[in]  name             The process name to set.
+ */
+void wbcSetClientProcessName(const char *name);
+
 #endif      /* _WBCLIENT_H */
diff --git a/nsswitch/libwbclient/wscript b/nsswitch/libwbclient/wscript
index 70fed6fc2ed..7bb612d670a 100644
--- a/nsswitch/libwbclient/wscript
+++ b/nsswitch/libwbclient/wscript
@@ -3,7 +3,7 @@
 from waflib import Options, Logs
 
 # Remember to also update wbclient.h
-VERSION="0.14"
+VERSION="0.15"
 
 # It may be useful at some point to allow Samba to build against a
 # system libwbclient, such as the one provided by Likewise.  To to
diff --git a/nsswitch/pam_winbind.c b/nsswitch/pam_winbind.c
index 1a58ba49c48..757fdae6e3c 100644
--- a/nsswitch/pam_winbind.c
+++ b/nsswitch/pam_winbind.c
@@ -564,6 +564,8 @@ static int _pam_winbind_init_context(pam_handle_t *pamh,
 				     struct pwb_context **ctx_p)
 {
 	struct pwb_context *r = NULL;
+	const char *service = NULL;
+	char service_name[32] = {0};
 	int ctrl_code;
 
 #ifdef HAVE_GETTEXT
@@ -594,6 +596,12 @@ static int _pam_winbind_init_context(pam_handle_t *pamh,
 		return PAM_SYSTEM_ERR;
 	}
 
+	pam_get_item(pamh, PAM_SERVICE, (const void **)&service);
+
+	snprintf(service_name, sizeof(service_name), "PAM_WINBIND[%s]", service);
+
+	wbcSetClientProcessName(service_name);
+
 	*ctx_p = r;
 
 	return PAM_SUCCESS;
diff --git a/nsswitch/wb_common.c b/nsswitch/wb_common.c
index 59370aa5bbc..6eea32c7e2a 100644
--- a/nsswitch/wb_common.c
+++ b/nsswitch/wb_common.c
@@ -31,6 +31,8 @@
 #include <pthread.h>
 #endif
 
+static char client_name[32];
+
 /* Global context */
 
 struct winbindd_context {
@@ -75,6 +77,32 @@ void winbindd_free_response(struct winbindd_response *response)
 		SAFE_FREE(response->extra_data.data);
 }
 
+void winbind_set_client_name(const char *name)
+{
+	if (name == NULL || strlen(name) == 0) {
+		return;
+	}
+
+	(void)snprintf(client_name, sizeof(client_name), "%s", name);
+}
+
+static const char *winbind_get_client_name(void)
+{
+	if (client_name[0] == '\0') {
+		int len;
+
+		len = snprintf(client_name,
+			       sizeof(client_name),
+			       "%s",
+			       getprogname());
+		if (len <= 0) {
+			return "<unkonwn>";
+		}
+	}
+
+	return client_name;
+}
+
 /* Initialise a request structure */
 
 static void winbindd_init_request(struct winbindd_request *request,
@@ -85,6 +113,10 @@ static void winbindd_init_request(struct winbindd_request *request,
 	request->cmd = (enum winbindd_cmd)request_type;
 	request->pid = getpid();
 
+	(void)snprintf(request->client_name,
+		       sizeof(request->client_name),
+		       "%s",
+		       winbind_get_client_name());
 }
 
 /* Initialise a response structure */
diff --git a/nsswitch/winbind_client.h b/nsswitch/winbind_client.h
index fd39ea39b4e..c0ee6c9391a 100644
--- a/nsswitch/winbind_client.h
+++ b/nsswitch/winbind_client.h
@@ -44,6 +44,8 @@ NSS_STATUS winbindd_priv_request_response(struct winbindd_context *ctx,
 					  struct winbindd_request *request,
 					  struct winbindd_response *response);
 
+void winbind_set_client_name(const char *name);
+
 #define winbind_env_set() \
 	(strcmp(getenv(WINBINDD_DONT_ENV)?getenv(WINBINDD_DONT_ENV):"0","1") == 0)
 
diff --git a/nsswitch/winbind_nss_linux.c b/nsswitch/winbind_nss_linux.c
index 442c06e612f..c7443e505bf 100644
--- a/nsswitch/winbind_nss_linux.c
+++ b/nsswitch/winbind_nss_linux.c
@@ -378,6 +378,7 @@ _nss_winbind_setpwent(void)
 		winbindd_free_response(&getpwent_response);
 	}
 
+	winbind_set_client_name("nss_winbind");
 	ret = winbindd_request_response(NULL, WINBINDD_SETPWENT, NULL, NULL);
 #ifdef DEBUG_NSS
 	fprintf(stderr, "[%5d]: setpwent returns %s (%d)\n", getpid(),
@@ -409,6 +410,7 @@ _nss_winbind_endpwent(void)
 		winbindd_free_response(&getpwent_response);
 	}
 
+	winbind_set_client_name("nss_winbind");
 	ret = winbindd_request_response(NULL, WINBINDD_ENDPWENT, NULL, NULL);
 #ifdef DEBUG_NSS
 	fprintf(stderr, "[%5d]: endpwent returns %s (%d)\n", getpid(),
@@ -458,6 +460,7 @@ _nss_winbind_getpwent_r(struct passwd *result, char *buffer,
 
 	request.data.num_entries = MAX_GETPWENT_USERS;
 
+	winbind_set_client_name("nss_winbind");
 	ret = winbindd_request_response(NULL, WINBINDD_GETPWENT, &request,
 			       &getpwent_response);
 
@@ -546,6 +549,7 @@ _nss_winbind_getpwuid_r(uid_t uid, struct passwd *result, char *buffer,
 
 		request.data.uid = uid;
 
+		winbind_set_client_name("nss_winbind");
 		ret = winbindd_request_response(NULL, WINBINDD_GETPWUID, &request, &response);
 
 		if (ret == NSS_STATUS_SUCCESS) {
@@ -622,6 +626,7 @@ _nss_winbind_getpwnam_r(const char *name, struct passwd *result, char *buffer,
 		request.data.username
 			[sizeof(request.data.username) - 1] = '\0';
 
+		winbind_set_client_name("nss_winbind");
 		ret = winbindd_request_response(NULL, WINBINDD_GETPWNAM, &request, &response);
 
 		if (ret == NSS_STATUS_SUCCESS) {
@@ -693,6 +698,7 @@ _nss_winbind_setgrent(void)
 		winbindd_free_response(&getgrent_response);
 	}
 
+	winbind_set_client_name("nss_winbind");
 	ret = winbindd_request_response(NULL, WINBINDD_SETGRENT, NULL, NULL);
 #ifdef DEBUG_NSS
 	fprintf(stderr, "[%5d]: setgrent returns %s (%d)\n", getpid(),
@@ -725,6 +731,7 @@ _nss_winbind_endgrent(void)
 		winbindd_free_response(&getgrent_response);
 	}
 
+	winbind_set_client_name("nss_winbind");
 	ret = winbindd_request_response(NULL, WINBINDD_ENDGRENT, NULL, NULL);
 #ifdef DEBUG_NSS
 	fprintf(stderr, "[%5d]: endgrent returns %s (%d)\n", getpid(),
@@ -776,6 +783,7 @@ winbind_getgrent(enum winbindd_cmd cmd,
 
 	request.data.num_entries = MAX_GETGRENT_USERS;
 
+	winbind_set_client_name("nss_winbind");
 	ret = winbindd_request_response(NULL, cmd, &request,
 			       &getgrent_response);
 
@@ -895,6 +903,7 @@ _nss_winbind_getgrnam_r(const char *name,
 		request.data.groupname
 			[sizeof(request.data.groupname) - 1] = '\0';
 
+		winbind_set_client_name("nss_winbind");
 		ret = winbindd_request_response(NULL, WINBINDD_GETGRNAM,
 						&request, &response);
 
@@ -974,6 +983,7 @@ _nss_winbind_getgrgid_r(gid_t gid,
 
 		request.data.gid = gid;
 
+		winbind_set_client_name("nss_winbind");
 		ret = winbindd_request_response(NULL, WINBINDD_GETGRGID,
 						&request, &response);
 
@@ -1048,6 +1058,7 @@ _nss_winbind_initgroups_dyn(const char *user, gid_t group, long int *start,
 	strncpy(request.data.username, user,
 		sizeof(request.data.username) - 1);
 
+	winbind_set_client_name("nss_winbind");
 	ret = winbindd_request_response(NULL, WINBINDD_GETGROUPS,
 					&request, &response);
 
diff --git a/nsswitch/winbind_struct_protocol.h b/nsswitch/winbind_struct_protocol.h
index 3f3ebd0b66d..f184c957ab8 100644
--- a/nsswitch/winbind_struct_protocol.h
+++ b/nsswitch/winbind_struct_protocol.h
@@ -60,8 +60,9 @@ typedef char fstring[FSTRING_LEN];
  *     removed WINBINDD_UID_TO_SID
  * 29: added "authoritative" to response.data.auth
  * 30: added "validation_level" and "info6" to response.data.auth
+ * 31: added "client_name" to the request
  */
-#define WINBIND_INTERFACE_VERSION 30
+#define WINBIND_INTERFACE_VERSION 31
 
 /* Have to deal with time_t being 4 or 8 bytes due to structure alignment.
    On a 64bit Linux box, we have to support a constant structure size
@@ -250,6 +251,7 @@ struct winbindd_request {
 	uint32_t wb_flags;       /* generic flags */
 	uint32_t flags;          /* flags relevant *only* to a given request */
 	fstring domain_name;	/* name of domain for which the request applies */
+	char client_name[32];	/* The client process sending the request */
 
 	union {
 		fstring winsreq;     /* WINS request */
diff --git a/nsswitch/wins.c b/nsswitch/wins.c
index 72055f099b6..ddbbb03d844 100644
--- a/nsswitch/wins.c
+++ b/nsswitch/wins.c
@@ -69,6 +69,7 @@ static char *lookup_byname_backend(const char *name)
 		return NULL;
 	}
 
+	wbcSetClientProcessName("nss_wins");
 	result = wbcResolveWinsByName(name, &ip);
 	if (result != WBC_ERR_SUCCESS) {
 		return NULL;
@@ -89,6 +90,7 @@ static char *lookup_byaddr_backend(const char *ip)
 	wbcErr result;
 	char *name = NULL;
 
+	wbcSetClientProcessName("nss_wins");
 	result = wbcResolveWinsByIP(ip, &name);
 	if (result != WBC_ERR_SUCCESS) {
 		return NULL;
diff --git a/source3/torture/wbc_async.c b/source3/torture/wbc_async.c
index a9020ddcda5..e45c01c50a0 100644
--- a/source3/torture/wbc_async.c
+++ b/source3/torture/wbc_async.c
@@ -402,6 +402,10 @@ static void wb_open_pipe_connect_nonpriv_done(struct tevent_req *subreq)
 	ZERO_STRUCT(state->wb_req);
 	state->wb_req.cmd = WINBINDD_INTERFACE_VERSION;
 	state->wb_req.pid = getpid();
+	(void)snprintf(state->wb_req.client_name,
+		       sizeof(state->wb_req.client_name),
+		       "%s",
+		       "TORTURE");
 
 	subreq = wb_simple_trans_send(state, state->ev, NULL,
 				      state->wb_ctx->fd, &state->wb_req);
diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c
index 07a81329358..86c3cd95244 100644
--- a/source3/winbindd/winbindd.c
+++ b/source3/winbindd/winbindd.c
@@ -708,6 +708,9 @@ static struct tevent_req *process_request_send(
 
 	/* Remember who asked us. */
 	cli_state->pid = cli_state->request->pid;
+	memcpy(cli_state->client_name,
+	       cli_state->request->client_name,
+	       sizeof(cli_state->client_name));
 
 	cli_state->cmd_name = "unknown request";
 	cli_state->recv_fn = NULL;
@@ -734,8 +737,11 @@ static struct tevent_req *process_request_send(
 		cli_state->cmd_name = atable->cmd_name;
 		cli_state->recv_fn = atable->recv_req;
 
-		DEBUG(10, ("process_request: Handling async request %d:%s\n",
-			   (int)cli_state->pid, cli_state->cmd_name));
+		DBG_DEBUG("process_request: "
+			  "Handling async request %s(%d):%s\n",
+			  cli_state->client_name,
+			  (int)cli_state->pid,
+			  cli_state->cmd_name);
 
 		subreq = atable->send_req(
 			state,
@@ -797,7 +803,8 @@ static void process_request_done(struct tevent_req *subreq)
 	status = cli_state->recv_fn(subreq, cli_state->response);
 	TALLOC_FREE(subreq);
 
-	DBG_DEBUG("[%d:%s]: %s\n",
+	DBG_DEBUG("[%s(%d):%s]: %s\n",
+		  cli_state->client_name,
 		  (int)cli_state->pid,
 		  cli_state->cmd_name,
 		  nt_errstr(status));
@@ -841,8 +848,10 @@ static void process_request_written(struct tevent_req *subreq)
 		return;
 	}
 
-	DBG_DEBUG("[%d:%s]: delivered response to client\n",
-		  (int)cli_state->pid, cli_state->cmd_name);
+	DBG_DEBUG("[%s(%d):%s]: delivered response to client\n",
+		  cli_state->client_name,
+		  (int)cli_state->pid,
+		  cli_state->cmd_name);
 
 	TALLOC_FREE(cli_state->mem_ctx);
 	cli_state->response = NULL;
diff --git a/source3/winbindd/winbindd.h b/source3/winbindd/winbindd.h
index 6d4b92f27cf..7490d62a705 100644
--- a/source3/winbindd/winbindd.h
+++ b/source3/winbindd/winbindd.h
@@ -47,6 +47,7 @@ struct winbindd_cli_state {
 	struct winbindd_cli_state *prev, *next;   /* Linked list pointers */
 	int sock;                                 /* Open socket from client */
 	pid_t pid;                                /* pid of client */


-- 
Samba Shared Repository



More information about the samba-cvs mailing list