wbclient: Send the client process name talking to winbind
authorAndreas Schneider <asn@samba.org>
Fri, 2 Nov 2018 17:39:26 +0000 (18:39 +0100)
committerAndreas Schneider <asn@cryptomilk.org>
Mon, 12 Nov 2018 08:50:25 +0000 (09:50 +0100)
This is for better debugging messages.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
nsswitch/wb_common.c
nsswitch/winbind_struct_protocol.h
source3/torture/wbc_async.c

index 59370aa5bbc211b30ffd900b26ad7fdc2ecaa719..13c38f213bad15aa7887158f2ec06ebb03cba53c 100644 (file)
@@ -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 */
index 3f3ebd0b66dfecc8336dcefba796269a65d10e79..f184c957ab84409feac1fdb5deabbaad188f3c3b 100644 (file)
@@ -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 */
index a9020ddcda5a85cdf29ad9d12ed7eec3d9207b13..e45c01c50a0afa1bb1d535be747bb18182e3080e 100644 (file)
@@ -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);