diff options
author | Andrew Tridgell <tridge@samba.org> | 2009-05-26 09:26:47 +1000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2009-05-26 09:26:47 +1000 |
commit | ecdad56b6eedad4a4d8031477827c522cdf6d76e (patch) | |
tree | ee924581609a5ddfca9992630502a53f7540db87 /source3/utils/net_rpc.c | |
parent | e15027155d3d880abde83124e252b3dd10a9aae4 (diff) | |
parent | 714acfac013a46c3677c3eb72ad57db6d97c7d61 (diff) | |
download | samba-ecdad56b6eedad4a4d8031477827c522cdf6d76e.tar.gz samba-ecdad56b6eedad4a4d8031477827c522cdf6d76e.tar.bz2 samba-ecdad56b6eedad4a4d8031477827c522cdf6d76e.zip |
Merge branch 'master' of ssh://git.samba.org/data/git/samba
Diffstat (limited to 'source3/utils/net_rpc.c')
-rw-r--r-- | source3/utils/net_rpc.c | 74 |
1 files changed, 49 insertions, 25 deletions
diff --git a/source3/utils/net_rpc.c b/source3/utils/net_rpc.c index f6f90030fe..0118b4818a 100644 --- a/source3/utils/net_rpc.c +++ b/source3/utils/net_rpc.c @@ -25,7 +25,8 @@ #include "../libcli/auth/libcli_auth.h" static int net_mode_share; -static bool sync_files(struct copy_clistate *cp_clistate, const char *mask); +static bool sync_files(struct copy_clistate *cp_clistate, const char *mask, + const struct user_auth_info *auth_info); /** * @file net_rpc.c @@ -122,6 +123,7 @@ int run_rpc_command(struct net_context *c, DOM_SID *domain_sid; const char *domain_name; int ret = -1; + struct user_auth_info *ai = c->auth_info; /* make use of cli_state handed over as an argument, if possible */ if (!cli_arg) { @@ -171,8 +173,10 @@ int run_rpc_command(struct net_context *c, nt_status = cli_rpc_pipe_open_ntlmssp( cli, interface, PIPE_AUTH_LEVEL_PRIVACY, - lp_workgroup(), c->opt_user_name, - c->opt_password, &pipe_hnd); + lp_workgroup(), + get_cmdline_auth_info_username(ai), + get_cmdline_auth_info_password(ai), + &pipe_hnd); } else { nt_status = cli_rpc_pipe_open_noauth( cli, interface, @@ -940,9 +944,12 @@ int net_rpc_user(struct net_context *c, int argc, const char **argv) if (status != 0) { return -1; } - libnetapi_set_username(c->netapi_ctx, c->opt_user_name); - libnetapi_set_password(c->netapi_ctx, c->opt_password); - if (c->opt_kerberos) { + set_cmdline_auth_info_getpass(c->auth_info); + libnetapi_set_username(c->netapi_ctx, + get_cmdline_auth_info_username(c->auth_info)); + libnetapi_set_password(c->netapi_ctx, + get_cmdline_auth_info_password(c->auth_info)); + if (get_cmdline_auth_info_use_kerberos(c->auth_info)) { libnetapi_set_use_kerberos(c->netapi_ctx); } @@ -2756,9 +2763,12 @@ int net_rpc_group(struct net_context *c, int argc, const char **argv) if (status != 0) { return -1; } - libnetapi_set_username(c->netapi_ctx, c->opt_user_name); - libnetapi_set_password(c->netapi_ctx, c->opt_password); - if (c->opt_kerberos) { + set_cmdline_auth_info_getpass(c->auth_info); + libnetapi_set_username(c->netapi_ctx, + get_cmdline_auth_info_username(c->auth_info)); + libnetapi_set_password(c->netapi_ctx, + get_cmdline_auth_info_password(c->auth_info)); + if (get_cmdline_auth_info_use_kerberos(c->auth_info)) { libnetapi_set_use_kerberos(c->netapi_ctx); } @@ -3245,7 +3255,7 @@ static void copy_fn(const char *mnt, file_info *f, old_dir = local_state->cwd; local_state->cwd = dir; - if (!sync_files(local_state, new_mask)) + if (!sync_files(local_state, new_mask, c->auth_info)) printf("could not handle files\n"); local_state->cwd = old_dir; @@ -3292,15 +3302,18 @@ static void copy_fn(const char *mnt, file_info *f, * * @return Boolean result **/ -static bool sync_files(struct copy_clistate *cp_clistate, const char *mask) +static bool sync_files(struct copy_clistate *cp_clistate, const char *mask, + const struct user_auth_info *auth_info) { struct cli_state *targetcli; char *targetpath = NULL; DEBUG(3,("calling cli_list with mask: %s\n", mask)); - if ( !cli_resolve_path(talloc_tos(), "", NULL, cp_clistate->cli_share_src, - mask, &targetcli, &targetpath ) ) { + + if ( !cli_resolve_path(talloc_tos(), "", auth_info, + cp_clistate->cli_share_src, mask, &targetcli, + &targetpath ) ) { d_fprintf(stderr, "cli_resolve_path %s failed with error: %s\n", mask, cli_errstr(cp_clistate->cli_share_src)); return false; @@ -3463,7 +3476,7 @@ static NTSTATUS rpc_share_migrate_files_internals(struct net_context *c, goto done; } - if (!sync_files(&cp_clistate, mask)) { + if (!sync_files(&cp_clistate, mask, c->auth_info)) { d_fprintf(stderr, "could not handle files for share: %s\n", info502.name); nt_status = NT_STATUS_UNSUCCESSFUL; goto done; @@ -4564,9 +4577,12 @@ int net_rpc_share(struct net_context *c, int argc, const char **argv) if (status != 0) { return -1; } - libnetapi_set_username(c->netapi_ctx, c->opt_user_name); - libnetapi_set_password(c->netapi_ctx, c->opt_password); - if (c->opt_kerberos) { + set_cmdline_auth_info_getpass(c->auth_info); + libnetapi_set_username(c->netapi_ctx, + get_cmdline_auth_info_username(c->auth_info)); + libnetapi_set_password(c->netapi_ctx, + get_cmdline_auth_info_password(c->auth_info)); + if (get_cmdline_auth_info_use_kerberos(c->auth_info)) { libnetapi_set_use_kerberos(c->netapi_ctx); } @@ -4839,9 +4855,12 @@ int net_rpc_file(struct net_context *c, int argc, const char **argv) if (status != 0) { return -1; } - libnetapi_set_username(c->netapi_ctx, c->opt_user_name); - libnetapi_set_password(c->netapi_ctx, c->opt_password); - if (c->opt_kerberos) { + set_cmdline_auth_info_getpass(c->auth_info); + libnetapi_set_username(c->netapi_ctx, + get_cmdline_auth_info_username(c->auth_info)); + libnetapi_set_password(c->netapi_ctx, + get_cmdline_auth_info_password(c->auth_info)); + if (get_cmdline_auth_info_use_kerberos(c->auth_info)) { libnetapi_set_use_kerberos(c->netapi_ctx); } @@ -5531,7 +5550,7 @@ static int rpc_trustdom_establish(struct net_context *c, int argc, c->opt_workgroup = smb_xstrdup(domain_name); }; - c->opt_user_name = acct_name; + set_cmdline_auth_info_username(c->auth_info, acct_name); /* find the domain controller */ if (!net_find_pdc(&server_ss, pdc_name, domain_name)) { @@ -5628,7 +5647,9 @@ static int rpc_trustdom_establish(struct net_context *c, int argc, * Store the password in secrets db */ - if (!pdb_set_trusteddom_pw(domain_name, c->opt_password, domain_sid)) { + if (!pdb_set_trusteddom_pw(domain_name, + get_cmdline_auth_info_password(c->auth_info), + domain_sid)) { DEBUG(0, ("Storing password for trusted domain failed.\n")); cli_shutdown(cli); talloc_destroy(mem_ctx); @@ -7190,9 +7211,12 @@ int net_rpc(struct net_context *c, int argc, const char **argv) if (status != 0) { return -1; } - libnetapi_set_username(c->netapi_ctx, c->opt_user_name); - libnetapi_set_password(c->netapi_ctx, c->opt_password); - if (c->opt_kerberos) { + set_cmdline_auth_info_getpass(c->auth_info); + libnetapi_set_username(c->netapi_ctx, + get_cmdline_auth_info_username(c->auth_info)); + libnetapi_set_password(c->netapi_ctx, + get_cmdline_auth_info_password(c->auth_info)); + if (get_cmdline_auth_info_use_kerberos(c->auth_info)) { libnetapi_set_use_kerberos(c->netapi_ctx); } |