r3570: Export the user's group list from ntlm_auth, via a new command 'UG'
authorAndrew Bartlett <abartlet@samba.org>
Sat, 6 Nov 2004 01:20:28 +0000 (01:20 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:05:32 +0000 (13:05 -0500)
(user groups).  The form of this is not final, but is this should be a
discussion point with the squid team.

Andrew Bartlett

source/utils/ntlm_auth.c

index feaae17abb26cf9f8db0f12fbcfc71c6f0999309..8d7f750af6e53ec93f78994507be2ec70247c7ec 100644 (file)
@@ -332,6 +332,7 @@ static void manage_gensec_request(enum stdio_helper_mode stdio_helper_mode,
                    (strncmp(buf, "KK ", 3) != 0) &&
                    (strncmp(buf, "AF ", 3) != 0) &&
                    (strncmp(buf, "NA ", 3) != 0) && 
+                   (strncmp(buf, "UG", 2) != 0) && 
                    (strncmp(buf, "PW ", 3) != 0)) {
                DEBUG(1, ("SPNEGO request [%s] invalid\n", buf));
                mux_printf(mux_id, "BH\n");
@@ -405,8 +406,8 @@ static void manage_gensec_request(enum stdio_helper_mode stdio_helper_mode,
                                                         talloc_strndup((*gensec_state), 
                                                                        (const char *)in.data, 
                                                                        in.length)))) {
-                       DEBUG(1, ("Out of memory\n"));
-                       mux_printf(mux_id, "BH\n");
+                       DEBUG(1, ("gensec_set_password failed: %s\n", nt_errstr(nt_status)));
+                       mux_printf(mux_id, "BH %s\n", nt_errstr(nt_status));
                        data_blob_free(&in);
                        return;
                }
@@ -416,6 +417,33 @@ static void manage_gensec_request(enum stdio_helper_mode stdio_helper_mode,
                return;
        }
 
+       if (strncmp(buf, "UG", 2) == 0) {
+               int i;
+               char *grouplist = NULL;
+               struct auth_session_info *session_info;
+
+               if (!NT_STATUS_IS_OK(gensec_session_info(*gensec_state, &session_info))) { 
+                       DEBUG(1, ("gensec_session_info failed: %s\n", nt_errstr(nt_status)));
+                       mux_printf(mux_id, "BH %s\n", nt_errstr(nt_status));
+                       data_blob_free(&in);
+                       return;
+               }
+               
+               /* get the string onto the context */
+               grouplist = talloc_strdup(session_info, "");
+               
+               for (i=0; i< session_info->nt_user_token->num_sids; i++) {
+                       grouplist = talloc_asprintf_append(grouplist, "%s,", 
+                                                          dom_sid_string(session_info, 
+                                                                         session_info->nt_user_token->user_sids[i]));
+               }
+
+               mux_printf(mux_id, "GL %s\n", grouplist);
+               free_session_info(&session_info);
+               data_blob_free(&in);
+               return;
+       }
+
        /* update */
 
        nt_status = gensec_update(*gensec_state, NULL, in, &out);