summaryrefslogtreecommitdiff
path: root/nsswitch
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2018-11-02 18:39:26 +0100
committerAndreas Schneider <asn@cryptomilk.org>2018-11-12 09:50:25 +0100
commitba9ad1266561d7003727dfb12915234d75a575f5 (patch)
tree50050c3a223bd4c3c5b649be7ee9392a729417fd /nsswitch
parentc8e27b6f334931d5a609af6b50c9e0756e88b672 (diff)
downloadsamba-ba9ad1266561d7003727dfb12915234d75a575f5.tar.gz
wbclient: Send the client process name talking to winbind
This is for better debugging messages. Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'nsswitch')
-rw-r--r--nsswitch/wb_common.c23
-rw-r--r--nsswitch/winbind_struct_protocol.h4
2 files changed, 26 insertions, 1 deletions
diff --git a/nsswitch/wb_common.c b/nsswitch/wb_common.c
index 59370aa5bbc..13c38f213ba 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,23 @@ void winbindd_free_response(struct winbindd_response *response)
SAFE_FREE(response->extra_data.data);
}
+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 +104,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_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 */