The branch, v4-15-test has been updated
       via  f15232d28ec auth:creds: Guess the username first via getpwuid(my_id)
      from  db4e342291f s3:winbindd: fix "allow trusted domains = no" regression

https://git.samba.org/?p=samba.git;a=shortlog;h=v4-15-test


- Log -----------------------------------------------------------------
commit f15232d28ecf37a0ad3c026c37c4b7a7d0898e66
Author: Andreas Schneider <a...@samba.org>
Date:   Wed Nov 10 12:06:51 2021 +0100

    auth:creds: Guess the username first via getpwuid(my_id)
    
    If we have a container, we often don't have USER or LOGNAME set.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14883
    
    Tested-by: Anoop C S <anoo...@samba.org>
    Signed-off-by: Andreas Schneider <a...@samba.org>
    Reviewed-by: Stefan Metzmacher <me...@samba.org>
    (cherry picked from commit c28be4067463e582e378df402f812e510883d606)
    
    Autobuild-User(v4-15-test): Jule Anger <jan...@samba.org>
    Autobuild-Date(v4-15-test): Mon Nov 15 11:34:06 UTC 2021 on sn-devel-184

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

Summary of changes:
 auth/credentials/credentials.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)


Changeset truncated at 500 lines:

diff --git a/auth/credentials/credentials.c b/auth/credentials/credentials.c
index 02a3cf3b354..c5a6ba6940c 100644
--- a/auth/credentials/credentials.c
+++ b/auth/credentials/credentials.c
@@ -30,6 +30,7 @@
 #include "tevent.h"
 #include "param/param.h"
 #include "system/filesys.h"
+#include "system/passwd.h"
 
 /**
  * Create a new credentials structure
@@ -1159,6 +1160,7 @@ _PUBLIC_ bool cli_credentials_guess(struct 
cli_credentials *cred,
 {
        const char *error_string;
        const char *env = NULL;
+       struct passwd *pwd = NULL;
        bool ok;
 
        if (lp_ctx != NULL) {
@@ -1168,6 +1170,17 @@ _PUBLIC_ bool cli_credentials_guess(struct 
cli_credentials *cred,
                }
        }
 
+       pwd = getpwuid(getuid());
+       if (pwd != NULL) {
+               size_t len = strlen(pwd->pw_name);
+
+               if (len > 0 && len <= 1024) {
+                       (void)cli_credentials_parse_string(cred,
+                                                          pwd->pw_name,
+                                                          CRED_GUESS_ENV);
+               }
+       }
+
        env = getenv("LOGNAME");
        if (env != NULL) {
                size_t len = strlen(env);


-- 
Samba Shared Repository

Reply via email to