From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:45815) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T3rum-0008BR-UL for qemu-devel@nongnu.org; Tue, 21 Aug 2012 13:06:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T3rug-0002qS-QU for qemu-devel@nongnu.org; Tue, 21 Aug 2012 13:06:52 -0400 Received: from mail-iy0-f173.google.com ([209.85.210.173]:45337) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T3rug-0002ef-8E for qemu-devel@nongnu.org; Tue, 21 Aug 2012 13:06:46 -0400 Received: by mail-iy0-f173.google.com with SMTP id x26so15891iak.4 for ; Tue, 21 Aug 2012 10:06:46 -0700 (PDT) Sender: fluxion From: Michael Roth Date: Tue, 21 Aug 2012 12:05:52 -0500 Message-Id: <1345568757-14365-19-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 18/23] slirp: Ensure smbd and shared directory exist when enable smb List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: aliguori@us.ibm.com From: Dunrong Huang Users may pass the following parameters to qemu: $ qemu-kvm -net nic -net user,smb= ... $ qemu-kvm -net nic -net user,smb ... $ qemu-kvm -net nic -net user,smb=bad_directory ... In these cases, qemu started successfully while samba server failed to start. Users will confuse since samba server failed silently without any indication of what it did wrong. To avoid it, we check whether the shared directory exist and if users have permission to access this directory when QEMU's "built-in" SMB server is enabled. Signed-off-by: Dunrong Huang Signed-off-by: Jan Kiszka (cherry picked from commit 927d811b282ffdf5386bd63f435c1507634ba49a) Signed-off-by: Michael Roth --- net/slirp.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/net/slirp.c b/net/slirp.c index c73610e..d3fcbf4 100644 --- a/net/slirp.c +++ b/net/slirp.c @@ -497,6 +497,18 @@ static int slirp_smb(SlirpState* s, const char *exported_dir, return -1; } + if (access(CONFIG_SMBD_COMMAND, F_OK)) { + error_report("could not find '%s', please install it", + CONFIG_SMBD_COMMAND); + return -1; + } + + if (access(exported_dir, R_OK | X_OK)) { + error_report("no such directory '%s', or you do not have permission " + "to access it, please check it", exported_dir); + 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) { -- 1.7.9.5