Skip to content

Commit

Permalink
Set up Samba logging within autoenroll script
Browse files Browse the repository at this point in the history
We can leverage Samba's logging system to get a better understanding as
to what's going on during the lifetime of the autoenroll script.

Mock has to be wrangled a bit to satisfy the actual `lp` object.
  • Loading branch information
GabrielNagy committed Aug 9, 2023
1 parent cf6240b commit f156b82
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
4 changes: 4 additions & 0 deletions internal/policies/certificate/cert-autoenroll
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ from samba.dcerpc import preg

from vendor_samba.gp.gpclass import GPOStorage
from vendor_samba.gp import gp_cert_auto_enroll_ext as cae
from vendor_samba.gp.util.logging import logger_init

class adsys_cert_auto_enroll(cae.gp_cert_auto_enroll_ext):
def enroll(self, guid, entries, trust_dir, private_dir, global_trust_dir):
Expand Down Expand Up @@ -74,6 +75,9 @@ def main():
username = c.get_username()
store = GPOStorage(os.path.join(samba_cache_dir, f'cert_gpo_state_{args.object_name}.tdb'))

# Set up logging
logger_init('cert-autoenroll', lp.log_level())

ext = adsys_cert_auto_enroll(lp, c, username, store)
guid = f'adsys-cert-autoenroll-{args.object_name}'
if args.action == 'enroll':
Expand Down
16 changes: 10 additions & 6 deletions internal/testutils/admock/samba/param/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
def LoadParm(smb_conf=None):
if smb_conf is None:
return
print('Loading smb.conf')
with open(smb_conf, 'r') as f:
print(f.read())
class LoadParm(object):
def __init__(self, smb_conf=None):
if smb_conf is None:
return
print('Loading smb.conf')
with open(smb_conf, 'r') as f:
print(f.read())

def log_level(self):
return 0
Empty file.
2 changes: 2 additions & 0 deletions internal/testutils/admock/vendor_samba/gp/util/logging.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def logger_init(_name, _level):
pass

0 comments on commit f156b82

Please sign in to comment.