From: Björn Baumbach Date: Mon, 25 Nov 2019 13:13:37 +0000 (+0100) Subject: samba-tool {user,group,computer,contact} show: avoid base64 encoded strings if possible X-Git-Tag: ldb-2.1.0~497 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6d1a0eb8d11dc0ad62500d977fafc7411d6f39ed;p=thirdparty%2Fsamba.git samba-tool {user,group,computer,contact} show: avoid base64 encoded strings if possible Be more user friendly and use clear text argument strings if possible. Signed-off-by: Björn Baumbach Reviewed-by: Andrew Bartlett --- diff --git a/python/samba/netcmd/computer.py b/python/samba/netcmd/computer.py index b66dcc4a7a5..11b2938464a 100644 --- a/python/samba/netcmd/computer.py +++ b/python/samba/netcmd/computer.py @@ -36,6 +36,7 @@ from samba.auth import system_session from samba.samdb import SamDB from samba.compat import get_bytes from subprocess import check_call, CalledProcessError +from . import common from samba import ( credentials, @@ -457,8 +458,6 @@ class cmd_computer_edit(Command): def run(self, computername, credopts=None, sambaopts=None, versionopts=None, H=None, editor=None): - from . import common - lp = sambaopts.get_loadparm() creds = credopts.get_credentials(lp, fallback_machine=True) samdb = SamDB(url=H, session_info=system_session(), @@ -639,7 +638,7 @@ attribute. samaccountname) for msg in res: - computer_ldif = samdb.write_ldif(msg, ldb.CHANGETYPE_NONE) + computer_ldif = common.get_ldif_for_editor(samdb, msg) self.outf.write(computer_ldif) diff --git a/python/samba/netcmd/contact.py b/python/samba/netcmd/contact.py index 506e644c3f8..b35f3f16a88 100644 --- a/python/samba/netcmd/contact.py +++ b/python/samba/netcmd/contact.py @@ -37,6 +37,7 @@ from samba.netcmd import ( Option, ) from samba.compat import get_bytes +from . import common class cmd_create(Command): @@ -365,8 +366,6 @@ class cmd_edit(Command): versionopts=None, H=None, editor=None): - from . import common - lp = sambaopts.get_loadparm() creds = credopts.get_credentials(lp, fallback_machine=True) samdb = SamDB(url=H, session_info=system_session(), @@ -548,7 +547,7 @@ class cmd_show(Command): contactname) for msg in res: - contact_ldif = samdb.write_ldif(msg, ldb.CHANGETYPE_NONE) + contact_ldif = common.get_ldif_for_editor(samdb, msg) self.outf.write(contact_ldif) diff --git a/python/samba/netcmd/group.py b/python/samba/netcmd/group.py index 3a01f8b96e9..95843eecea4 100644 --- a/python/samba/netcmd/group.py +++ b/python/samba/netcmd/group.py @@ -39,6 +39,7 @@ from subprocess import check_call, CalledProcessError from samba.compat import get_bytes import os import tempfile +from . import common security_group = dict({"Builtin": GTYPE_SECURITY_BUILTIN_LOCAL_GROUP, "Domain": GTYPE_SECURITY_DOMAIN_LOCAL_GROUP, @@ -589,7 +590,7 @@ Example3 shows how to display a groups objectGUID and member attributes. raise CommandError('Unable to find group "%s"' % (groupname)) for msg in res: - group_ldif = samdb.write_ldif(msg, ldb.CHANGETYPE_NONE) + group_ldif = common.get_ldif_for_editor(samdb, msg) self.outf.write(group_ldif) @@ -747,8 +748,6 @@ class cmd_group_edit(Command): def run(self, groupname, credopts=None, sambaopts=None, versionopts=None, H=None, editor=None): - from . import common - lp = sambaopts.get_loadparm() creds = credopts.get_credentials(lp, fallback_machine=True) samdb = SamDB(url=H, session_info=system_session(), diff --git a/python/samba/netcmd/user.py b/python/samba/netcmd/user.py index cadd80fd991..fb8da3d3d51 100644 --- a/python/samba/netcmd/user.py +++ b/python/samba/netcmd/user.py @@ -56,7 +56,7 @@ from samba.netcmd import ( from samba.compat import text_type from samba.compat import get_bytes from samba.compat import get_string - +from . import common # python[3]-gpgme is abandoned since ubuntu 1804 and debian 9 # have to use python[3]-gpg instead @@ -2389,8 +2389,6 @@ LDAP server using the 'nano' editor. def run(self, username, credopts=None, sambaopts=None, versionopts=None, H=None, editor=None): - from . import common - lp = sambaopts.get_loadparm() creds = credopts.get_credentials(lp, fallback_machine=True) samdb = SamDB(url=H, session_info=system_session(), @@ -2520,7 +2518,7 @@ Example3 shows how to display a users objectSid and memberOf attributes. raise CommandError('Unable to find user "%s"' % (username)) for msg in res: - user_ldif = samdb.write_ldif(msg, ldb.CHANGETYPE_NONE) + user_ldif = common.get_ldif_for_editor(samdb, msg) self.outf.write(user_ldif)