From 8243e544aa19414a3516ed6cff861fa7d1253365 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 3073a12..732d9b8 100644 --- a/source3/modules/vfs_fake_perms.c +++ b/source3/modules/vfs_fake_perms.c @@ -26,6 +26,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) { @@ -38,8 +40,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->server_info->utok.uid; - smb_fname->st.st_ex_gid = handle->conn->server_info->utok.gid; + if (handle->conn->server_info != NULL) { + smb_fname->st.st_ex_uid = + handle->conn->server_info->utok.uid; + smb_fname->st.st_ex_gid = + handle->conn->server_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; @@ -56,8 +68,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->server_info->utok.uid; - sbuf->st_ex_gid = handle->conn->server_info->utok.gid; + if (handle->conn->server_info != NULL) { + sbuf->st_ex_uid = + handle->conn->server_info->utok.uid; + sbuf->st_ex_gid = + handle->conn->server_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