Skip to content

Commit 0eae3ee

Browse files
committed
fcad: Migrated to libsmb
1 parent e7830b4 commit 0eae3ee

2 files changed

Lines changed: 34 additions & 6 deletions

File tree

admin/fleetcommander/fcad.py

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import uuid
2626
import getpass
2727
import tempfile
28+
import optparse
2829

2930
from functools import wraps
3031

@@ -35,11 +36,19 @@
3536
import ldap.modlist
3637

3738
import samba
38-
from samba import param, smb
39+
import samba.getopt as options
3940
from samba.credentials import Credentials, MUST_USE_KERBEROS
4041
from samba.ndr import ndr_unpack, ndr_pack
4142
from samba.dcerpc import security
4243
from samba.ntacls import dsacl2fsacl
44+
from samba.samba3 import param as s3param
45+
46+
try:
47+
from samba.samba3 import libsmb
48+
logging.debug('Using SAMBA 3 SMB connection')
49+
except ImportError:
50+
from samba.samba3 import libsmb_samba_internal as libsmb
51+
logging.debug('Using SAMBA 3 SMB connection (Internal)')
4352

4453

4554
GPO_SMB_PATH = '\\\\%s\\SysVol\\%s\\Policies\\%s'
@@ -144,13 +153,32 @@ def _get_server_name(self):
144153
def _generate_gpo_uuid(self):
145154
return '{%s}' % str(uuid.uuid4()).upper()
146155

156+
# def _get_smb_connection(self, service='SysVol'):
157+
# # Connect to SMB using kerberos
158+
# parm = param.LoadParm()
159+
# creds = Credentials()
160+
# creds.set_kerberos_state(MUST_USE_KERBEROS)
161+
# creds.guess(parm)
162+
# conn = SMBConn(self._get_server_name(), service, lp=parm, creds=creds)
163+
# return conn
164+
147165
def _get_smb_connection(self, service='SysVol'):
148-
# Connect to SMB using kerberos
149-
parm = param.LoadParm()
166+
# Create options like if we were using command line
167+
parser = optparse.OptionParser()
168+
sambaopts = options.SambaOptions(parser)
169+
# Samba options
170+
parm = sambaopts.get_loadparm()
171+
s3_lp = s3param.get_context()
172+
s3_lp.load(parm.configfile)
173+
# Build credentials from credential options
150174
creds = Credentials()
175+
# Credentials need username and realm to be not empty strings to work
176+
creds.set_username('NOTEMPTY')
177+
creds.set_realm('NOTEMPTY')
178+
# Connect to SMB using kerberos
151179
creds.set_kerberos_state(MUST_USE_KERBEROS)
152-
creds.guess(parm)
153-
conn = smb.SMB(self._get_server_name(), service, lp=parm, creds=creds)
180+
# Create connection
181+
conn = libsmb.Conn(self._get_server_name(), service, lp=parm, creds=creds, sign=False)
154182
return conn
155183

156184
def _load_smb_data(self, gpo_uuid):

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
AC_INIT(fleet-commander-admin, 0.15.0, aruiz@redhat.com)
1+
AC_INIT(fleet-commander-admin, 0.15.1, aruiz@redhat.com)
22
AC_COPYRIGHT([Copyright 2014,2015,2016,2017,2018 Red Hat, Inc.])
33

44
AC_PREREQ(2.64)

0 commit comments

Comments
 (0)