Skip to content

Commit 6decb5b

Browse files
committed
sambacc: use tempfile as arg to net conf import
net conf import is unable to use the STDIN to import the configuration when the generated smb.conf is large. Use a tempfile instead as an argument to net conf import. Resolves: rhbz#2400102 Signed-off-by: Sachin Prabhu <[email protected]>
1 parent 135e58a commit 6decb5b

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

sambacc/netcmd_loader.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import subprocess
2020
import typing
21+
import tempfile
2122

2223
from sambacc import config
2324
from sambacc import samba_cmds
@@ -56,10 +57,11 @@ def _check(self, cli: typing.Any, proc: subprocess.Popen) -> None:
5657

5758
def import_config(self, iconfig: config.InstanceConfig) -> None:
5859
"""Import to entire instance config to samba config."""
59-
cli, proc = self._cmd("import", "/dev/stdin", stdin=subprocess.PIPE)
60-
template_config(proc.stdin, iconfig, enc=samba_cmds.encode)
61-
proc.stdin.close()
62-
self._check(cli, proc)
60+
with tempfile.NamedTemporaryFile() as tf:
61+
template_config(tf, iconfig, enc=samba_cmds.encode)
62+
tf.flush()
63+
cli, proc = self._cmd("import", tf.name)
64+
self._check(cli, proc)
6365

6466
def dump(self, out: typing.IO) -> None:
6567
"""Dump the current smb config in an smb.conf format.

0 commit comments

Comments
 (0)