mirror of
https://github.com/samba-team/samba.git
synced 2025-07-27 07:42:04 +03:00
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 <mat@samba.org> Autobuild-Date: Sun Apr 17 13:12:27 CEST 2011 on sn-devel-104
This commit is contained in:
committed by
Matthieu Patou
parent
0bf7c96464
commit
7cc02cf870
@ -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)
|
||||
|
||||
|
Reference in New Issue
Block a user