From 7cc02cf870aa6301c55a78cff630d46d86abf434 Mon Sep 17 00:00:00 2001 From: Matthieu Patou Date: Sun, 17 Apr 2011 14:15:40 +0400 Subject: samba-tool: fix machinepw command so that we use the full path to the secret database and raise an error if secret can't be found Autobuild-User: Matthieu Patou Autobuild-Date: Sun Apr 17 13:12:27 CEST 2011 on sn-devel-104 --- source4/scripting/python/samba/netcmd/machinepw.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/source4/scripting/python/samba/netcmd/machinepw.py b/source4/scripting/python/samba/netcmd/machinepw.py index d822b22794..75338d95ef 100644 --- a/source4/scripting/python/samba/netcmd/machinepw.py +++ b/source4/scripting/python/samba/netcmd/machinepw.py @@ -18,7 +18,7 @@ # import samba.getopt as options - +import os from samba import Ldb from samba.auth import system_session from samba.netcmd import Command, CommandError @@ -40,10 +40,13 @@ class cmd_machinepw(Command): def run(self, secret, sambaopts=None, credopts=None, versionopts=None): lp = sambaopts.get_loadparm() creds = credopts.get_credentials(lp, fallback_machine=True) - url = lp.get("secrets database") + name = lp.get("secrets database") + path = lp.get("private dir") + url = os.path.join(path, name) + if not os.path.exists(url): + raise CommandError("secret database not found at %s " % url) secretsdb = Ldb(url=url, session_info=system_session(), credentials=creds, lp=lp) - result = secretsdb.search(attrs=["secret"], expression="(&(objectclass=primaryDomain)(samaccountname=%s))" % secret) -- cgit