mirror of
https://github.com/samba-team/samba.git
synced 2025-02-26 21:57:41 +03:00
samba-tool: replace use of os.popen
The netcmd/domain.py module uses os.popen() on user-supplied parameters. This opens up the way to code injection. BUG: https://bugzilla.samba.org/show_bug.cgi?id=11601 Signed-off-by: Uri Simchoni <uri@samba.org> Reviewed-by: Alexander Bokovoy <ab@samba.org> Autobuild-User(master): Uri Simchoni <uri@samba.org> Autobuild-Date(master): Mon Nov 23 22:19:34 CET 2015 on sn-devel-104
This commit is contained in:
parent
e6f88c1451
commit
22386dc396
@ -31,6 +31,7 @@ import ctypes
|
||||
import random
|
||||
import tempfile
|
||||
import logging
|
||||
import subprocess
|
||||
from getpass import getpass
|
||||
from samba.net import Net, LIBNET_JOIN_AUTOMATIC
|
||||
import samba.ntacls
|
||||
@ -87,9 +88,16 @@ from samba.provision.common import (
|
||||
)
|
||||
|
||||
def get_testparm_var(testparm, smbconf, varname):
|
||||
cmd = "%s -s -l --parameter-name='%s' %s 2>/dev/null" % (testparm, varname, smbconf)
|
||||
output = os.popen(cmd, 'r').readline()
|
||||
return output.strip()
|
||||
errfile = open(os.devnull, 'w')
|
||||
p = subprocess.Popen([testparm, '-s', '-l',
|
||||
'--parameter-name=%s' % varname, smbconf],
|
||||
stdout=subprocess.PIPE, stderr=errfile)
|
||||
(out,err) = p.communicate()
|
||||
errfile.close()
|
||||
lines = out.split('\n')
|
||||
if lines:
|
||||
return lines[0].strip()
|
||||
return ""
|
||||
|
||||
try:
|
||||
import samba.dckeytab
|
||||
|
Loading…
x
Reference in New Issue
Block a user