summaryrefslogtreecommitdiff
path: root/source3/utils/net_rpc.c
diff options
context:
space:
mode:
authorKai Blin <kai@samba.org>2009-05-14 11:39:01 +0200
committerKai Blin <kai@samba.org>2009-05-25 23:35:38 +0200
commitfb262f79fab00374023e59476e8d05a1015a7041 (patch)
tree753bfbae96b66f237f53854b6fb12f6f16aad1e0 /source3/utils/net_rpc.c
parenta98ba0cbe9a05f1b681206cecb7558c24d89da49 (diff)
downloadsamba-fb262f79fab00374023e59476e8d05a1015a7041.tar.gz
samba-fb262f79fab00374023e59476e8d05a1015a7041.tar.bz2
samba-fb262f79fab00374023e59476e8d05a1015a7041.zip
net: Use samba default command line arguments.
Attention: The meaning of the -N flag changed. To get the old meaning for net groupmap set, use the long option --ntname The long option for using kerberos changed from --kerberos to --use-kerberos net rpc commands will now prompt for a password if none is given. As a benefit, net will now accept an authentication file like other samba command line tools. So no need to specify the password on the command line in scripts anymore. This should fix bug #6357 Signed-off-by: Kai Blin <kai@samba.org>
Diffstat (limited to 'source3/utils/net_rpc.c')
-rw-r--r--source3/utils/net_rpc.c74
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);
}