]> Git Repo - qemu.git/commitdiff
slirp: Ensure smbd and shared directory exist when enable smb
authorDunrong Huang <[email protected]>
Fri, 6 Jul 2012 06:04:43 +0000 (14:04 +0800)
committerJan Kiszka <[email protected]>
Mon, 9 Jul 2012 15:38:13 +0000 (17:38 +0200)
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 <[email protected]>
Signed-off-by: Jan Kiszka <[email protected]>
net/slirp.c

index 180147e831b49007841112c7feffc3cf3ed929d9..eb80889572dbd61de0c18392fabecdb8c392561f 100644 (file)
@@ -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) {
This page took 0.024067 seconds and 4 git commands to generate.