From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:45749) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T3rui-0007wf-Ga for qemu-devel@nongnu.org; Tue, 21 Aug 2012 13:06:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T3ruf-0002pQ-2h for qemu-devel@nongnu.org; Tue, 21 Aug 2012 13:06:48 -0400 Received: from mail-gh0-f173.google.com ([209.85.160.173]:61109) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T3rue-0002gN-US for qemu-devel@nongnu.org; Tue, 21 Aug 2012 13:06:44 -0400 Received: by mail-gh0-f173.google.com with SMTP id r17so31193ghr.4 for ; Tue, 21 Aug 2012 10:06:44 -0700 (PDT) Sender: fluxion From: Michael Roth Date: Tue, 21 Aug 2012 12:05:51 -0500 Message-Id: <1345568757-14365-18-git-send-email-mdroth@linux.vnet.ibm.com> In-Reply-To: <1345568757-14365-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1345568757-14365-1-git-send-email-mdroth@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 17/23] slirp: Enforce host-side user of smb share List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: aliguori@us.ibm.com From: Jan Kiszka Windows 7 (and possibly other versions) cannot connect to the samba share if the exported host directory is not world-readable. This can be resolved by forcing the username used for access checks to the one under which QEMU and smbd are running. Signed-off-by: Jan Kiszka (cherry picked from commit 1cb1c5d10bb9e180bd3f7be2c10b212ed86a97b4) Signed-off-by: Michael Roth --- net/slirp.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/net/slirp.c b/net/slirp.c index 96f5032..c73610e 100644 --- a/net/slirp.c +++ b/net/slirp.c @@ -26,6 +26,7 @@ #include "config-host.h" #ifndef _WIN32 +#include #include #endif #include "net.h" @@ -487,8 +488,15 @@ static int slirp_smb(SlirpState* s, const char *exported_dir, static int instance; char smb_conf[128]; char smb_cmdline[128]; + struct passwd *passwd; FILE *f; + passwd = getpwuid(geteuid()); + if (!passwd) { + error_report("failed to retrieve user name"); + return -1; + } + snprintf(s->smb_dir, sizeof(s->smb_dir), "/tmp/qemu-smb.%ld-%d", (long)getpid(), instance++); if (mkdir(s->smb_dir, 0700) < 0) { @@ -517,14 +525,16 @@ static int slirp_smb(SlirpState* s, const char *exported_dir, "[qemu]\n" "path=%s\n" "read only=no\n" - "guest ok=yes\n", + "guest ok=yes\n" + "force user=%s\n", s->smb_dir, s->smb_dir, s->smb_dir, s->smb_dir, s->smb_dir, s->smb_dir, - exported_dir + exported_dir, + passwd->pw_name ); fclose(f); -- 1.7.9.5