mirror of
https://github.com/samba-team/samba.git
synced 2025-02-08 05:57:51 +03:00
net: Add support for a credentials file
Add support for the same -A authfile/--authentication-file authfile option that most of the other tools already do. Signed-off-by: Olly Betts <olly@survex.com> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
parent
e99402235d
commit
1cf84b6b99
@ -26,6 +26,7 @@
|
|||||||
<arg choice="opt">-w|--workgroup workgroup</arg>
|
<arg choice="opt">-w|--workgroup workgroup</arg>
|
||||||
<arg choice="opt">-W|--myworkgroup myworkgroup</arg>
|
<arg choice="opt">-W|--myworkgroup myworkgroup</arg>
|
||||||
<arg choice="opt">-U|--user user</arg>
|
<arg choice="opt">-U|--user user</arg>
|
||||||
|
<arg choice="opt">-A|--authentication-file authfile</arg>
|
||||||
<arg choice="opt">-I|--ipaddress ip-address</arg>
|
<arg choice="opt">-I|--ipaddress ip-address</arg>
|
||||||
<arg choice="opt">-p|--port port</arg>
|
<arg choice="opt">-p|--port port</arg>
|
||||||
<arg choice="opt">-n myname</arg>
|
<arg choice="opt">-n myname</arg>
|
||||||
|
@ -50,6 +50,7 @@
|
|||||||
#include "messages.h"
|
#include "messages.h"
|
||||||
#include "cmdline_contexts.h"
|
#include "cmdline_contexts.h"
|
||||||
#include "lib/gencache.h"
|
#include "lib/gencache.h"
|
||||||
|
#include "auth/credentials/credentials.h"
|
||||||
|
|
||||||
#ifdef WITH_FAKE_KASERVER
|
#ifdef WITH_FAKE_KASERVER
|
||||||
#include "utils/net_afs.h"
|
#include "utils/net_afs.h"
|
||||||
@ -904,6 +905,26 @@ static struct functable net_func[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static void get_credentials_file(struct net_context *c,
|
||||||
|
const char *file)
|
||||||
|
{
|
||||||
|
struct cli_credentials *cred = cli_credentials_init(c);
|
||||||
|
|
||||||
|
if (cred == NULL) {
|
||||||
|
d_printf("ERROR: Unable to allocate memory!\n");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!cli_credentials_parse_file(cred, file, CRED_GUESS_FILE)) {
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
c->opt_user_name = cli_credentials_get_username(cred);
|
||||||
|
c->opt_user_specified = (c->opt_user_name != NULL);
|
||||||
|
c->opt_password = cli_credentials_get_password(cred);
|
||||||
|
c->opt_target_workgroup = cli_credentials_get_domain(cred);
|
||||||
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
main program
|
main program
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -923,6 +944,7 @@ static struct functable net_func[] = {
|
|||||||
{"help", 'h', POPT_ARG_NONE, 0, 'h'},
|
{"help", 'h', POPT_ARG_NONE, 0, 'h'},
|
||||||
{"workgroup", 'w', POPT_ARG_STRING, &c->opt_target_workgroup},
|
{"workgroup", 'w', POPT_ARG_STRING, &c->opt_target_workgroup},
|
||||||
{"user", 'U', POPT_ARG_STRING, &c->opt_user_name, 'U'},
|
{"user", 'U', POPT_ARG_STRING, &c->opt_user_name, 'U'},
|
||||||
|
{"authentication-file", 'A', POPT_ARG_STRING, &c->opt_user_name, 'A', "Get the credentials from a file", "FILE"},
|
||||||
{"ipaddress", 'I', POPT_ARG_STRING, 0,'I'},
|
{"ipaddress", 'I', POPT_ARG_STRING, 0,'I'},
|
||||||
{"port", 'p', POPT_ARG_INT, &c->opt_port},
|
{"port", 'p', POPT_ARG_INT, &c->opt_port},
|
||||||
{"myname", 'n', POPT_ARG_STRING, &c->opt_requester_name},
|
{"myname", 'n', POPT_ARG_STRING, &c->opt_requester_name},
|
||||||
@ -1025,6 +1047,9 @@ static struct functable net_func[] = {
|
|||||||
c->opt_password = p+1;
|
c->opt_password = p+1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'A':
|
||||||
|
get_credentials_file(c, c->opt_user_name);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
d_fprintf(stderr, _("\nInvalid option %s: %s\n"),
|
d_fprintf(stderr, _("\nInvalid option %s: %s\n"),
|
||||||
poptBadOption(pc, 0), poptStrerror(opt));
|
poptBadOption(pc, 0), poptStrerror(opt));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user