diff options
author | Dunrong Huang <riegamaths@gmail.com> | 2012-07-06 14:04:43 +0800 |
---|---|---|
committer | Michael Roth <mdroth@linux.vnet.ibm.com> | 2012-08-21 15:36:35 -0500 |
commit | 1a933e48016db893c799775a897b2af88a879683 (patch) | |
tree | 23436122fcef3e7a21e80f9159ae495f689a033e | |
parent | 55e64b6dddfd71953f4eb7ad6d0bcfc8d92500e5 (diff) |
slirp: Ensure smbd and shared directory exist when enable smb
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 <riegamaths@gmail.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
(cherry picked from commit 927d811b282ffdf5386bd63f435c1507634ba49a)
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
-rw-r--r-- | net/slirp.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/net/slirp.c b/net/slirp.c index c73610e48..d3fcbf4a0 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) { |