All of lore.kernel.org
 help / color / mirror / Atom feed
From: Samuel Thibault <samuel.thibault@gnu.org>
To: Jordi Pujol <jordipujolp@gmail.com>
Cc: Jan Kiszka <jan.kiszka@siemens.com>,
	Jason Wang <jasowang@redhat.com>,
	Laurent Vivier <laurent@vivier.eu>,
	qemu-devel qemu-devel <qemu-devel@nongnu.org>
Subject: Re: [PATCH v2] smb daemon get additional command line parameters from env variable
Date: Thu, 31 Oct 2019 17:15:47 +0100	[thread overview]
Message-ID: <20191031161547.pipit5hxzjnf6jmt@function> (raw)
In-Reply-To: <CACTE=goN=Nw8b5RN8sWhX9mRNWEU0fhuc=HnD3MJW59BET=hkA@mail.gmail.com>

Hello,

Jordi Pujol, le jeu. 31 oct. 2019 14:33:00 +0100, a ecrit:
> 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"
> 
> Signed-off-by: Jordi Pujol Palomer <jordipujolp@gmail.com>

> ---
> --- 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 = g_strdup(g_getenv("SMBDOPTIONS"));

Why strduping it? you can just use g_getenv.

> +    if (options) {
> +        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

Please submit this part to https://gitlab.freedesktop.org/slirp/libslirp/

Make sure to note in the changelog that g_shell_parse_argv does only
tokenization, and no replacement.

Samuel

> @@ -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],
> **************************************************
> 
> Thanks,
> 
> Jordi Pujol
> 


  reply	other threads:[~2019-10-31 16:29 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CACTE=gpFbUSxXeTwu6_tzSeoh_9Yp905aMdzCPCUz3h7kcgeyw@mail.gmail.com>
2019-10-31 12:47 ` smb daemon get additional command line parameters from env variable Laurent Vivier
2019-10-31 13:33   ` [PATCH v2] " Jordi Pujol
2019-10-31 16:15     ` Samuel Thibault [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191031161547.pipit5hxzjnf6jmt@function \
    --to=samuel.thibault@gnu.org \
    --cc=jan.kiszka@siemens.com \
    --cc=jasowang@redhat.com \
    --cc=jordipujolp@gmail.com \
    --cc=laurent@vivier.eu \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.