summaryrefslogtreecommitdiff
path: root/source3/utils
diff options
context:
space:
mode:
Diffstat (limited to 'source3/utils')
-rw-r--r--source3/utils/smbcacls.c34
-rw-r--r--source3/utils/smbcquotas.c32
-rw-r--r--source3/utils/smbtree.c22
3 files changed, 53 insertions, 35 deletions
diff --git a/source3/utils/smbcacls.c b/source3/utils/smbcacls.c
index f7f1272215..f07b5011c8 100644
--- a/source3/utils/smbcacls.c
+++ b/source3/utils/smbcacls.c
@@ -951,7 +951,8 @@ static int cacl_set(struct cli_state *cli, char *filename,
/*****************************************************
Return a connection to a server.
*******************************************************/
-static struct cli_state *connect_one(const char *server, const char *share)
+static struct cli_state *connect_one(struct user_auth_info *auth_info,
+ const char *server, const char *share)
{
struct cli_state *c = NULL;
struct sockaddr_storage ss;
@@ -960,41 +961,41 @@ static struct cli_state *connect_one(const char *server, const char *share)
zero_sockaddr(&ss);
- if (get_cmdline_auth_info_use_kerberos()) {
+ if (get_cmdline_auth_info_use_kerberos(auth_info)) {
flags |= CLI_FULL_CONNECTION_USE_KERBEROS |
CLI_FULL_CONNECTION_FALLBACK_AFTER_KERBEROS;
}
- if (get_cmdline_auth_info_use_machine_account() &&
- !set_cmdline_auth_info_machine_account_creds()) {
+ if (get_cmdline_auth_info_use_machine_account(auth_info) &&
+ !set_cmdline_auth_info_machine_account_creds(auth_info)) {
return NULL;
}
- if (!get_cmdline_auth_info_got_pass()) {
+ if (!get_cmdline_auth_info_got_pass(auth_info)) {
char *pass = getpass("Password: ");
if (pass) {
- set_cmdline_auth_info_password(pass);
+ set_cmdline_auth_info_password(auth_info, pass);
}
}
nt_status = cli_full_connection(&c, global_myname(), server,
&ss, 0,
share, "?????",
- get_cmdline_auth_info_username(),
+ get_cmdline_auth_info_username(auth_info),
lp_workgroup(),
- get_cmdline_auth_info_password(),
+ get_cmdline_auth_info_password(auth_info),
flags,
- get_cmdline_auth_info_signing_state(),
+ get_cmdline_auth_info_signing_state(auth_info),
NULL);
if (!NT_STATUS_IS_OK(nt_status)) {
DEBUG(0,("cli_full_connection failed! (%s)\n", nt_errstr(nt_status)));
return NULL;
}
- if (get_cmdline_auth_info_smb_encrypt()) {
+ if (get_cmdline_auth_info_smb_encrypt(auth_info)) {
nt_status = cli_cm_force_encryption(c,
- get_cmdline_auth_info_username(),
- get_cmdline_auth_info_password(),
+ get_cmdline_auth_info_username(auth_info),
+ get_cmdline_auth_info_password(auth_info),
lp_workgroup(),
share);
if (!NT_STATUS_IS_OK(nt_status)) {
@@ -1040,6 +1041,7 @@ static struct cli_state *connect_one(const char *server, const char *share)
TALLOC_CTX *frame = talloc_stackframe();
const char *owner_username = "";
char *server;
+ struct user_auth_info *auth_info;
load_case_tables();
@@ -1055,6 +1057,12 @@ static struct cli_state *connect_one(const char *server, const char *share)
lp_load(get_dyn_CONFIGFILE(),True,False,False,True);
load_interfaces();
+ auth_info = user_auth_info_init(frame);
+ if (auth_info == NULL) {
+ exit(1);
+ }
+ popt_common_set_auth_info(auth_info);
+
pc = poptGetContext("smbcacls", argc, argv, long_options, 0);
poptSetOtherOptionHelp(pc, "//server1/share1 filename\nACLs look like: "
@@ -1131,7 +1139,7 @@ static struct cli_state *connect_one(const char *server, const char *share)
share++;
if (!test_args) {
- cli = connect_one(server, share);
+ cli = connect_one(auth_info, server, share);
if (!cli) {
exit(EXIT_FAILED);
}
diff --git a/source3/utils/smbcquotas.c b/source3/utils/smbcquotas.c
index 8938cc5e65..a95394b125 100644
--- a/source3/utils/smbcquotas.c
+++ b/source3/utils/smbcquotas.c
@@ -37,6 +37,7 @@ static struct cli_state *cli_ipc;
static struct rpc_pipe_client *global_pipe_hnd;
static POLICY_HND pol;
static bool got_policy_hnd;
+static struct user_auth_info *smbcquotas_auth_info;
static struct cli_state *connect_one(const char *share);
@@ -373,42 +374,42 @@ static struct cli_state *connect_one(const char *share)
zero_sockaddr(&ss);
- if (get_cmdline_auth_info_use_machine_account() &&
- !set_cmdline_auth_info_machine_account_creds()) {
+ if (get_cmdline_auth_info_use_machine_account(smbcquotas_auth_info) &&
+ !set_cmdline_auth_info_machine_account_creds(smbcquotas_auth_info)) {
return NULL;
}
- if (get_cmdline_auth_info_use_kerberos()) {
+ if (get_cmdline_auth_info_use_kerberos(smbcquotas_auth_info)) {
flags |= CLI_FULL_CONNECTION_USE_KERBEROS |
CLI_FULL_CONNECTION_FALLBACK_AFTER_KERBEROS;
}
- if (!get_cmdline_auth_info_got_pass()) {
+ if (!get_cmdline_auth_info_got_pass(smbcquotas_auth_info)) {
char *pass = getpass("Password: ");
if (pass) {
- set_cmdline_auth_info_password(pass);
+ set_cmdline_auth_info_password(smbcquotas_auth_info, pass);
}
}
nt_status = cli_full_connection(&c, global_myname(), server,
&ss, 0,
share, "?????",
- get_cmdline_auth_info_username(),
+ get_cmdline_auth_info_username(smbcquotas_auth_info),
lp_workgroup(),
- get_cmdline_auth_info_password(),
+ get_cmdline_auth_info_password(smbcquotas_auth_info),
flags,
- get_cmdline_auth_info_signing_state(),
+ get_cmdline_auth_info_signing_state(smbcquotas_auth_info),
NULL);
if (!NT_STATUS_IS_OK(nt_status)) {
DEBUG(0,("cli_full_connection failed! (%s)\n", nt_errstr(nt_status)));
return NULL;
}
- if (get_cmdline_auth_info_smb_encrypt()) {
+ if (get_cmdline_auth_info_smb_encrypt(smbcquotas_auth_info)) {
nt_status = cli_cm_force_encryption(c,
- get_cmdline_auth_info_username(),
- get_cmdline_auth_info_password(),
+ get_cmdline_auth_info_username(smbcquotas_auth_info),
+ get_cmdline_auth_info_password(smbcquotas_auth_info),
lp_workgroup(),
share);
if (!NT_STATUS_IS_OK(nt_status)) {
@@ -475,6 +476,12 @@ FSQFLAGS:QUOTA_ENABLED/DENY_DISK/LOG_SOFTLIMIT/LOG_HARD_LIMIT", "SETSTRING" },
lp_load(get_dyn_CONFIGFILE(),True,False,False,True);
load_interfaces();
+ smbcquotas_auth_info = user_auth_info_init(frame);
+ if (smbcquotas_auth_info == NULL) {
+ exit(1);
+ }
+ popt_common_set_auth_info(smbcquotas_auth_info);
+
pc = poptGetContext("smbcquotas", argc, argv, long_options, 0);
poptSetOtherOptionHelp(pc, "//server1/share1");
@@ -537,7 +544,8 @@ FSQFLAGS:QUOTA_ENABLED/DENY_DISK/LOG_SOFTLIMIT/LOG_HARD_LIMIT", "SETSTRING" },
todo = USER_QUOTA;
if (!fix_user) {
- username_str = talloc_strdup(frame, get_cmdline_auth_info_username());
+ username_str = talloc_strdup(
+ frame, get_cmdline_auth_info_username(smbcquotas_auth_info));
if (!username_str) {
exit(EXIT_PARSE_ERROR);
}
diff --git a/source3/utils/smbtree.c b/source3/utils/smbtree.c
index 9fc02bac13..6c69300e85 100644
--- a/source3/utils/smbtree.c
+++ b/source3/utils/smbtree.c
@@ -272,7 +272,7 @@ static bool print_tree(struct user_auth_info *user_info)
int main(int argc,char *argv[])
{
TALLOC_CTX *frame = talloc_stackframe();
- struct user_auth_info local_auth_info;
+ struct user_auth_info *auth_info;
struct poptOption long_options[] = {
POPT_AUTOHELP
{ "broadcast", 'b', POPT_ARG_VAL, &use_bcast, True, "Use broadcast instead of using the master browser" },
@@ -293,6 +293,12 @@ static bool print_tree(struct user_auth_info *user_info)
setup_logging(argv[0],True);
+ auth_info = user_auth_info_init(frame);
+ if (auth_info == NULL) {
+ exit(1);
+ }
+ popt_common_set_auth_info(auth_info);
+
pc = poptGetContext("smbtree", argc, (const char **)argv, long_options,
POPT_CONTEXT_KEEP_FIRST);
while(poptGetNextOpt(pc) != -1);
@@ -303,26 +309,22 @@ static bool print_tree(struct user_auth_info *user_info)
/* Parse command line args */
- if (get_cmdline_auth_info_use_machine_account() &&
- !set_cmdline_auth_info_machine_account_creds()) {
+ if (get_cmdline_auth_info_use_machine_account(auth_info) &&
+ !set_cmdline_auth_info_machine_account_creds(auth_info)) {
TALLOC_FREE(frame);
return 1;
}
- if (!get_cmdline_auth_info_got_pass()) {
+ if (!get_cmdline_auth_info_got_pass(auth_info)) {
char *pass = getpass("Password: ");
if (pass) {
- set_cmdline_auth_info_password(pass);
+ set_cmdline_auth_info_password(auth_info, pass);
}
}
/* Now do our stuff */
- if (!get_cmdline_auth_info_copy(&local_auth_info)) {
- return 1;
- }
-
- if (!print_tree(&local_auth_info)) {
+ if (!print_tree(auth_info)) {
TALLOC_FREE(frame);
return 1;
}