The Samba-Bugzilla – Attachment 17237 Details for
Bug 15031
Use authentication file to pass credentials
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Authentication file patch
authfile.patch (text/plain), 2.37 KB, created by
Ni
on 2022-03-24 05:12:31 UTC
(
hide
)
Description:
Authentication file patch
Filename:
MIME Type:
Creator:
Ni
Created:
2022-03-24 05:12:31 UTC
Size:
2.37 KB
patch
obsolete
>diff --git a/docs-xml/manpages/samba-tool.8.xml b/docs-xml/manpages/samba-tool.8.xml >index 9a40bb1bec4..220c42856ec 100644 >--- a/docs-xml/manpages/samba-tool.8.xml >+++ b/docs-xml/manpages/samba-tool.8.xml >@@ -69,6 +69,13 @@ > </para></listitem> > </varlistentry> > >+ <varlistentry> >+ <term>-A AUTHFILE|--authentication-file=AUTHFILE</term> >+ <listitem><para> >+ Authentication file >+ </para></listitem> >+ </varlistentry> >+ > &cmdline.common.debug.client; > > </variablelist> >diff --git a/python/samba/getopt.py b/python/samba/getopt.py >index 7b8d2ef46c5..a22d0139e44 100644 >--- a/python/samba/getopt.py >+++ b/python/samba/getopt.py >@@ -174,6 +174,10 @@ class CredentialsOptions(optparse.OptionGroup): > action="callback", type=str, > help="Kerberos Credentials cache", > callback=self._set_krb5_ccache) >+ self._add_option("-A", "--authentication-file", metavar="AUTHFILE", >+ action="callback", type=str, >+ help="Authentication file", >+ callback=self._set_auth_file) > > # LEGACY > self._add_option("-k", "--kerberos", metavar="KERBEROS", >@@ -275,6 +279,29 @@ class CredentialsOptions(optparse.OptionGroup): > self.creds.set_kerberos_state(MUST_USE_KERBEROS) > self.creds.set_named_ccache(arg) > >+ def _set_auth_file(self, option, opt_str, arg, parser): >+ auth_data = {} >+ try: >+ actions = { >+ 'username': self.creds.parse_string, >+ 'password': self.creds.set_password, >+ 'domain': self.creds.set_domain >+ } >+ with open(arg, mode='r') as fd: >+ for line in fd.readlines(): >+ key, val = map(str.strip, line.partition('=')[::2]) >+ if key in actions and val: >+ actions[key](val) >+ actions.pop(key, None) >+ >+ self.ask_for_password = False >+ self.machine_pass = False >+ except FileNotFoundError: >+ raise optparse.OptionValueError("file %r not found" % (arg,)) >+ except PermissionError: >+ raise optparse.OptionValueError("no permissions to read %r" % (arg,)) >+ >+ > def get_credentials(self, lp, fallback_machine=False): > """Obtain the credentials set on the command-line. >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 15031
: 17237