s3: smbd: Don't use getcwd() directly. We must always go through the VFS.
authorJeremy Allison <jra@samba.org>
Wed, 20 Jun 2018 21:49:33 +0000 (14:49 -0700)
committerAndreas Schneider <asn@cryptomilk.org>
Thu, 21 Jun 2018 11:08:17 +0000 (13:08 +0200)
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
source3/smbd/uid.c

index e021031a8b7576533968c42bbd81c3c5eb6ba3d6..623d3dec9d5cb49a2c01a062ae2b2c4655f5e892 100644 (file)
@@ -390,13 +390,17 @@ static bool change_to_user_internal(connection_struct *conn,
        }
 
        if (CHECK_DEBUGLVL(DBGLVL_INFO)) {
-               char cwdbuf[PATH_MAX+1] = { 0, };
+               struct smb_filename *cwdfname = vfs_GetWd(talloc_tos(), conn);
+               if (cwdfname == NULL) {
+                       return false;
+               }
                DBG_INFO("Impersonated user: uid=(%d,%d), gid=(%d,%d), cwd=[%s]\n",
                         (int)getuid(),
                         (int)geteuid(),
                         (int)getgid(),
                         (int)getegid(),
-                        getcwd(cwdbuf, sizeof(cwdbuf)));
+                        cwdfname->base_name);
+               TALLOC_FREE(cwdfname);
        }
 
        return true;