From 3e1f50e853d0f4ea06380d912ab599925c006e2b Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 9 Apr 2013 21:43:28 +0200 Subject: [PATCH] vfs_fake_perms: Fix bug 9775, segfault for "artificial" conn_structs --- source3/modules/vfs_fake_perms.c | 30 ++++++++++++++++++++++++++---- 1 files changed, 26 insertions(+), 4 deletions(-) diff --git a/source3/modules/vfs_fake_perms.c b/source3/modules/vfs_fake_perms.c index ade2407..9956a3d 100644 --- a/source3/modules/vfs_fake_perms.c +++ b/source3/modules/vfs_fake_perms.c @@ -29,6 +29,8 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_VFS +extern struct current_user current_user; + static int fake_perms_stat(vfs_handle_struct *handle, struct smb_filename *smb_fname) { @@ -41,8 +43,18 @@ static int fake_perms_stat(vfs_handle_struct *handle, } else { smb_fname->st.st_ex_mode = S_IRWXU; } - smb_fname->st.st_ex_uid = handle->conn->session_info->utok.uid; - smb_fname->st.st_ex_gid = handle->conn->session_info->utok.gid; + if (handle->conn->session_info != NULL) { + smb_fname->st.st_ex_uid = + handle->conn->session_info->utok.uid; + smb_fname->st.st_ex_gid = + handle->conn->session_info->utok.gid; + } else { + /* + * Sucks, but current_user is the best we can do here. + */ + smb_fname->st.st_ex_uid = current_user.ut.uid; + smb_fname->st.st_ex_gid = current_user.ut.gid; + } } return ret; @@ -59,8 +71,18 @@ static int fake_perms_fstat(vfs_handle_struct *handle, files_struct *fsp, SMB_ST } else { sbuf->st_ex_mode = S_IRWXU; } - sbuf->st_ex_uid = handle->conn->session_info->utok.uid; - sbuf->st_ex_gid = handle->conn->session_info->utok.gid; + if (handle->conn->session_info != NULL) { + sbuf->st_ex_uid = + handle->conn->session_info->utok.uid; + sbuf->st_ex_gid = + handle->conn->session_info->utok.gid; + } else { + /* + * Sucks, but current_user is the best we can do here. + */ + sbuf->st_ex_uid = current_user.ut.uid; + sbuf->st_ex_gid = current_user.ut.gid; + } } return ret; } -- 1.7.3.4