Re: [PATCH v3] smb daemon get additional command line parameters from env variable

2019-11-01 Thread Samuel Thibault
Jordi Pujol, le ven. 01 nov. 2019 15:38:19 +0100, a ecrit:
> +options = g_getenv("SMBDOPTIONS");
> +if (options) {
> +smb_cmdline = g_strdup_printf("%s %s", smb_cmdline, options);
> +}
> +g_free(options);

But then do not free it :)

Samuel



Re: [PATCH v3] smb daemon get additional command line parameters from env variable

2019-11-01 Thread Jordi Pujol
On Thu, Oct 31, 2019 at 11:50 PM Samuel Thibault
 wrote:
> Why strduping it? you can just use g_getenv.

ACK, I have also placed the variable declaration after the others.
Here is the v3 of this patch.

**
From: Jordi Pujol Palomer 
Date: Fri, 1 Nov 2019 10:54:14 +0200
Subject: [PATCH v3] 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"

Signed-off-by: Jordi Pujol Palomer 
---
--- qemu-4.1-a/net/slirp.c
+++ qemu_4.1-b/net/slirp.c
@@ -834,6 +834,7 @@ static int slirp_smb(SlirpState* s, cons
 char *smb_cmdline;
 struct passwd *passwd;
 FILE *f;
+char *options;

 passwd = getpwuid(geteuid());
 if (!passwd) {
@@ -909,6 +910,12 @@ static int slirp_smb(SlirpState* s, cons
  CONFIG_SMBD_COMMAND, s->smb_dir, smb_conf);
 g_free(smb_conf);

+options = g_getenv("SMBDOPTIONS");
+if (options) {
+smb_cmdline = g_strdup_printf("%s %s", smb_cmdline, options);
+}
+g_free(options);
+
 if (slirp_add_exec(s->slirp, smb_cmdline, _addr, 139) < 0 ||
 slirp_add_exec(s->slirp, smb_cmdline, _addr, 445) < 0) {
 slirp_smb_cleanup(s);
**

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

I have forked the libslirp project and created a merge request,

Thanks,

Jordi Pujol