From patchwork Mon Jul 9 15:44:05 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 169890 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 9407B2C0201 for ; Tue, 10 Jul 2012 01:45:00 +1000 (EST) Received: from localhost ([::1]:43184 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SoG8w-00005t-F3 for incoming@patchwork.ozlabs.org; Mon, 09 Jul 2012 11:44:58 -0400 Received: from eggs.gnu.org ([208.118.235.92]:45624) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SoG8J-0006qm-Ka for qemu-devel@nongnu.org; Mon, 09 Jul 2012 11:44:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SoG8D-0002Mp-U8 for qemu-devel@nongnu.org; Mon, 09 Jul 2012 11:44:19 -0400 Received: from thoth.sbs.de ([192.35.17.2]:16065) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SoG8D-0002M9-Jh for qemu-devel@nongnu.org; Mon, 09 Jul 2012 11:44:13 -0400 Received: from mail1.siemens.de (localhost [127.0.0.1]) by thoth.sbs.de (8.13.6/8.13.6) with ESMTP id q69FiAAD010746; Mon, 9 Jul 2012 17:44:10 +0200 Received: from mchn199C.mchp.siemens.de ([139.25.109.49]) by mail1.siemens.de (8.13.6/8.13.6) with ESMTP id q69Fi96i014588; Mon, 9 Jul 2012 17:44:10 +0200 From: Jan Kiszka To: Anthony Liguori , qemu-devel Date: Mon, 9 Jul 2012 17:44:05 +0200 Message-Id: <1cb1c5d10bb9e180bd3f7be2c10b212ed86a97b4.1341848645.git.jan.kiszka@siemens.com> X-Mailer: git-send-email 1.7.3.4 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Received-From: 192.35.17.2 Subject: [Qemu-devel] [PATCH 1/4] slirp: Enforce host-side user of smb share X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- net/slirp.c | 14 ++++++++++++-- 1 files changed, 12 insertions(+), 2 deletions(-) diff --git a/net/slirp.c b/net/slirp.c index 37b6ccf..a43b576 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);