All of lore.kernel.org
 help / color / mirror / Atom feed
* smb daemon get additional command line parameters from env variable
@ 2019-10-30  7:55 Jordi Pujol
  2019-10-31 12:47   ` Laurent Vivier
  0 siblings, 1 reply; 9+ messages in thread
From: Jordi Pujol @ 2019-10-30  7:55 UTC (permalink / raw)
  To: qemu-trivial

[-- Attachment #1: Type: text/plain, Size: 533 bytes --]

Hello,

The new version 4 of Samba disables version 1 SMB protocols, now to
run old Win clients we must modify the temporary configuration of the
samba daemon to enable protocols before starting the samba client.
This patch gets the value of the environment variable SMBDOPTIONS and
appends it to the smbd command line; it allows the user to specify
additional samba daemon parameters before starting qemu.
It also patches the fork_exec function in misc.c, to parse correctly
command lines that contain spaces.

Thanks,

Jordi Pujol

[-- Attachment #2: smbd_options.patch --]
[-- Type: text/x-patch, Size: 1910 bytes --]

From: Jordi Pujol Palomer <jordipujolp@gmail.com>
Date: Fri, 25 Oct 2019 09:24:14 +0200
Subject: [PATCH] QEMU samba daemon: additional command line options

The smbd daemon takes additional command line options
from environment variable SMBDOPTIONS.
Set the environment variable SMBDOPTIONS before executing qemu.

Example:

export SMBDOPTIONS="--option='server min protocol=CORE' -d 4"
---
--- qemu-4.1-a/net/slirp.c
+++ qemu_4.1-b/net/slirp.c
@@ -909,6 +909,12 @@ static int slirp_smb(SlirpState* s, cons
              CONFIG_SMBD_COMMAND, s->smb_dir, smb_conf);
     g_free(smb_conf);
 
+    char *options;
+    if ((options = g_strdup(g_getenv("SMBDOPTIONS"))) != NULL) {
+        smb_cmdline = g_strdup_printf("%s %s", smb_cmdline, options);
+    }
+    g_free(options);
+
     if (slirp_add_exec(s->slirp, smb_cmdline, &vserver_addr, 139) < 0 ||
         slirp_add_exec(s->slirp, smb_cmdline, &vserver_addr, 445) < 0) {
         slirp_smb_cleanup(s);

--- qemu-4.1-a/slirp/src/misc.c	2019-10-29 14:40:15.043120941 +0100
+++ qemu-4.1-b/slirp/src/misc.c	2019-10-29 14:41:04.440235684 +0100
@@ -168,7 +168,9 @@ g_spawn_async_with_fds_slirp(const gchar
 int fork_exec(struct socket *so, const char *ex)
 {
     GError *err = NULL;
-    char **argv;
+    gint argc = 0;
+    gchar **argv = NULL;
+    gboolean ret;
     int opt, sp[2];
 
     DEBUG_CALL("fork_exec");
@@ -179,7 +181,13 @@ int fork_exec(struct socket *so, const c
         return 0;
     }
 
-    argv = g_strsplit(ex, " ", -1);
+    ret = g_shell_parse_argv(ex, &argc, &argv, &err);
+    if (err) {
+        g_critical("fork_exec invalid command: %s", err->message);
+        g_error_free(err);
+        return 0;
+    }
+
     g_spawn_async_with_fds(NULL /* cwd */, argv, NULL /* env */,
                            G_SPAWN_SEARCH_PATH, fork_exec_child_setup,
                            NULL /* data */, NULL /* child_pid */, sp[1], sp[1],

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2019-11-02  8:34 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-10-30  7:55 smb daemon get additional command line parameters from env variable Jordi Pujol
2019-10-31 12:47 ` Laurent Vivier
2019-10-31 12:47   ` Laurent Vivier
2019-10-31 13:33   ` [PATCH v2] " Jordi Pujol
2019-10-31 16:15     ` Samuel Thibault
2019-11-01 14:38       ` [PATCH v3] " Jordi Pujol
2019-11-01 14:54         ` Samuel Thibault
2019-11-02  7:41           ` [PATCH v4] " Jordi Pujol
2019-11-02  8:33             ` Samuel Thibault

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.