1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-27 22:50:26 +03:00

s3:client: Migrate smbclient to new cmdline option parser

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
Andreas Schneider 2020-08-18 16:58:19 +02:00 committed by Andrew Bartlett
parent c216e056b2
commit e4474ac0a5
6 changed files with 98 additions and 140 deletions

View File

@ -23,7 +23,6 @@
#include "includes.h"
#include "system/filesys.h"
#include "popt_common_cmdline.h"
#include "rpc_client/cli_pipe.h"
#include "client/client_proto.h"
#include "client/clitar_proto.h"
@ -41,6 +40,7 @@
#include "../libcli/smb/smbXcli_base.h"
#include "lib/util/time_basic.h"
#include "lib/util/string_wrappers.h"
#include "lib/cmdline/cmdline.h"
#ifndef REGISTER
#define REGISTER 0
@ -296,8 +296,7 @@ static int do_dskattr(void)
struct cli_state *targetcli = NULL;
char *targetpath = NULL;
TALLOC_CTX *ctx = talloc_tos();
struct cli_credentials *creds =
get_cmdline_auth_info_creds(popt_get_cmdline_auth_info());
struct cli_credentials *creds = samba_cmdline_get_creds();
NTSTATUS status;
status = cli_resolve_path(ctx,
@ -393,8 +392,7 @@ static int do_cd(const char *new_dir)
uint32_t attributes;
int ret = 1;
TALLOC_CTX *ctx = talloc_stackframe();
struct cli_credentials *creds =
get_cmdline_auth_info_creds(popt_get_cmdline_auth_info());
struct cli_credentials *creds = samba_cmdline_get_creds();
NTSTATUS status;
newdir = talloc_strdup(ctx, new_dir);
@ -589,6 +587,7 @@ static NTSTATUS display_finfo(struct cli_state *cli_state, struct file_info *fin
char *targetpath = NULL;
char *afname = NULL;
uint16_t fnum;
struct cli_credentials *creds = samba_cmdline_get_creds();
/* skip if this is . or .. */
if ( strequal(finfo->name,"..") || strequal(finfo->name,".") )
@ -611,8 +610,7 @@ static NTSTATUS display_finfo(struct cli_state *cli_state, struct file_info *fin
status = cli_resolve_path(
ctx,
"",
get_cmdline_auth_info_creds(
popt_get_cmdline_auth_info()),
creds,
cli_state,
afname,
&targetcli,
@ -827,8 +825,7 @@ NTSTATUS do_list(const char *mask,
struct do_list_helper_state state = { .cli = cli, };
static int in_do_list = 0;
TALLOC_CTX *ctx = talloc_tos();
struct cli_credentials *creds =
get_cmdline_auth_info_creds(popt_get_cmdline_auth_info());
struct cli_credentials *creds = samba_cmdline_get_creds();
NTSTATUS ret_status = NT_STATUS_OK;
NTSTATUS status = NT_STATUS_OK;
@ -1074,8 +1071,7 @@ static int do_get(const char *rname, const char *lname_in, bool reget)
struct cli_state *targetcli = NULL;
char *targetname = NULL;
char *lname = NULL;
struct cli_credentials *creds =
get_cmdline_auth_info_creds(popt_get_cmdline_auth_info());
struct cli_credentials *creds = samba_cmdline_get_creds();
NTSTATUS status;
lname = talloc_strdup(ctx, lname_in);
@ -1448,8 +1444,7 @@ static bool do_mkdir(const char *name)
TALLOC_CTX *ctx = talloc_tos();
struct cli_state *targetcli;
char *targetname = NULL;
struct cli_credentials *creds =
get_cmdline_auth_info_creds(popt_get_cmdline_auth_info());
struct cli_credentials *creds = samba_cmdline_get_creds();
NTSTATUS status;
status = cli_resolve_path(ctx, "",
@ -1497,7 +1492,6 @@ static bool do_altname(const char *name)
static int cmd_quit(void)
{
cli_shutdown(cli);
popt_free_cmdline_auth_info();
exit(0);
/* NOTREACHED */
return 0;
@ -1512,8 +1506,7 @@ static int cmd_mkdir(void)
TALLOC_CTX *ctx = talloc_tos();
char *mask = NULL;
char *buf = NULL;
struct cli_credentials *creds =
get_cmdline_auth_info_creds(popt_get_cmdline_auth_info());
struct cli_credentials *creds = samba_cmdline_get_creds();
NTSTATUS status;
mask = talloc_strdup(ctx, client_get_cur_dir());
@ -1865,8 +1858,7 @@ static int do_put(const char *rname, const char *lname, bool reput)
struct cli_state *targetcli;
char *targetname = NULL;
struct push_state state;
struct cli_credentials *creds =
get_cmdline_auth_info_creds(popt_get_cmdline_auth_info());
struct cli_credentials *creds = samba_cmdline_get_creds();
NTSTATUS status;
status = cli_resolve_path(ctx, "",
@ -1969,7 +1961,6 @@ static int do_put(const char *rname, const char *lname, bool reput)
if (f == stdin) {
cli_shutdown(cli);
popt_free_cmdline_auth_info();
exit(rc);
}
@ -2645,8 +2636,7 @@ static int cmd_wdel(void)
uint32_t attribute;
struct cli_state *targetcli;
char *targetname = NULL;
struct cli_credentials *creds =
get_cmdline_auth_info_creds(popt_get_cmdline_auth_info());
struct cli_credentials *creds = samba_cmdline_get_creds();
NTSTATUS status;
if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL)) {
@ -2699,8 +2689,7 @@ static int cmd_open(void)
char *targetname = NULL;
struct cli_state *targetcli;
uint16_t fnum = (uint16_t)-1;
struct cli_credentials *creds =
get_cmdline_auth_info_creds(popt_get_cmdline_auth_info());
struct cli_credentials *creds = samba_cmdline_get_creds();
NTSTATUS status;
if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL)) {
@ -2788,8 +2777,7 @@ static int cmd_posix_encrypt(void)
} else {
bool auth_requested = false;
creds = get_cmdline_auth_info_creds(
popt_get_cmdline_auth_info());
creds = samba_cmdline_get_creds();
auth_requested = cli_credentials_authentication_requested(creds);
if (!auth_requested) {
@ -2804,8 +2792,13 @@ static int cmd_posix_encrypt(void)
if (!NT_STATUS_IS_OK(status)) {
d_printf("posix_encrypt failed with error %s\n", nt_errstr(status));
} else {
bool ok;
d_printf("encryption on\n");
set_cmdline_auth_info_smb_encrypt(popt_get_cmdline_auth_info());
ok = cli_credentials_set_smb_encryption(creds,
SMB_ENCRYPTION_REQUIRED,
CRED_SPECIFIED);
SMB_ASSERT(ok);
}
return 0;
@ -2823,8 +2816,7 @@ static int cmd_posix_open(void)
struct cli_state *targetcli;
mode_t mode;
uint16_t fnum;
struct cli_credentials *creds =
get_cmdline_auth_info_creds(popt_get_cmdline_auth_info());
struct cli_credentials *creds = samba_cmdline_get_creds();
NTSTATUS status;
if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL)) {
@ -2885,8 +2877,7 @@ static int cmd_posix_mkdir(void)
char *targetname = NULL;
struct cli_state *targetcli;
mode_t mode;
struct cli_credentials *creds =
get_cmdline_auth_info_creds(popt_get_cmdline_auth_info());
struct cli_credentials *creds = samba_cmdline_get_creds();
NTSTATUS status;
if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL)) {
@ -2936,8 +2927,7 @@ static int cmd_posix_unlink(void)
char *buf = NULL;
char *targetname = NULL;
struct cli_state *targetcli;
struct cli_credentials *creds =
get_cmdline_auth_info_creds(popt_get_cmdline_auth_info());
struct cli_credentials *creds = samba_cmdline_get_creds();
NTSTATUS status;
if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL)) {
@ -2982,8 +2972,7 @@ static int cmd_posix_rmdir(void)
char *buf = NULL;
char *targetname = NULL;
struct cli_state *targetcli;
struct cli_credentials *creds =
get_cmdline_auth_info_creds(popt_get_cmdline_auth_info());
struct cli_credentials *creds = samba_cmdline_get_creds();
NTSTATUS status;
if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL)) {
@ -3292,8 +3281,7 @@ static int cmd_rmdir(void)
char *buf = NULL;
char *targetname = NULL;
struct cli_state *targetcli;
struct cli_credentials *creds =
get_cmdline_auth_info_creds(popt_get_cmdline_auth_info());
struct cli_credentials *creds = samba_cmdline_get_creds();
NTSTATUS status;
if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL)) {
@ -3342,8 +3330,7 @@ static int cmd_link(void)
char *buf2 = NULL;
char *targetname = NULL;
struct cli_state *targetcli;
struct cli_credentials *creds =
get_cmdline_auth_info_creds(popt_get_cmdline_auth_info());
struct cli_credentials *creds = samba_cmdline_get_creds();
NTSTATUS status;
if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL) ||
@ -3408,8 +3395,7 @@ static int cmd_readlink(void)
char *targetname = NULL;
char *linkname = NULL;
struct cli_state *targetcli;
struct cli_credentials *creds =
get_cmdline_auth_info_creds(popt_get_cmdline_auth_info());
struct cli_credentials *creds = samba_cmdline_get_creds();
NTSTATUS status;
if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL)) {
@ -3468,8 +3454,7 @@ static int cmd_symlink(void)
char *buf = NULL;
char *buf2 = NULL;
struct cli_state *newcli;
struct cli_credentials *creds =
get_cmdline_auth_info_creds(popt_get_cmdline_auth_info());
struct cli_credentials *creds = samba_cmdline_get_creds();
NTSTATUS status;
if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL) ||
@ -3529,8 +3514,7 @@ static int cmd_chmod(void)
char *targetname = NULL;
struct cli_state *targetcli;
mode_t mode;
struct cli_credentials *creds =
get_cmdline_auth_info_creds(popt_get_cmdline_auth_info());
struct cli_credentials *creds = samba_cmdline_get_creds();
NTSTATUS status;
if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL) ||
@ -3697,8 +3681,7 @@ static int cmd_getfacl(void)
size_t num_dir_acls = 0;
size_t expected_buflen;
uint16_t i;
struct cli_credentials *creds =
get_cmdline_auth_info_creds(popt_get_cmdline_auth_info());
struct cli_credentials *creds = samba_cmdline_get_creds();
NTSTATUS status;
if (!next_token_talloc(ctx, &cmd_ptr,&name,NULL)) {
@ -3883,8 +3866,7 @@ static int cmd_geteas(void)
NTSTATUS status;
size_t i, num_eas;
struct ea_struct *eas;
struct cli_credentials *creds =
get_cmdline_auth_info_creds(popt_get_cmdline_auth_info());
struct cli_credentials *creds = samba_cmdline_get_creds();
if (!next_token_talloc(ctx, &cmd_ptr,&name,NULL)) {
d_printf("geteas filename\n");
@ -3942,8 +3924,7 @@ static int cmd_setea(void)
char *eavalue = NULL;
char *targetname = NULL;
struct cli_state *targetcli;
struct cli_credentials *creds =
get_cmdline_auth_info_creds(popt_get_cmdline_auth_info());
struct cli_credentials *creds = samba_cmdline_get_creds();
NTSTATUS status;
if (!next_token_talloc(ctx, &cmd_ptr, &name, NULL)
@ -3999,8 +3980,7 @@ static int cmd_stat(void)
SMB_STRUCT_STAT sbuf;
struct tm *lt;
time_t tmp_time;
struct cli_credentials *creds =
get_cmdline_auth_info_creds(popt_get_cmdline_auth_info());
struct cli_credentials *creds = samba_cmdline_get_creds();
NTSTATUS status;
if (!next_token_talloc(ctx, &cmd_ptr,&name,NULL)) {
@ -4109,8 +4089,7 @@ static int cmd_chown(void)
char *buf, *buf2, *buf3;
struct cli_state *targetcli;
char *targetname = NULL;
struct cli_credentials *creds =
get_cmdline_auth_info_creds(popt_get_cmdline_auth_info());
struct cli_credentials *creds = samba_cmdline_get_creds();
NTSTATUS status;
if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL) ||
@ -4169,8 +4148,7 @@ static int cmd_rename(void)
struct cli_state *targetcli;
char *targetsrc;
char *targetdest;
struct cli_credentials *creds =
get_cmdline_auth_info_creds(popt_get_cmdline_auth_info());
struct cli_credentials *creds = samba_cmdline_get_creds();
NTSTATUS status;
bool replace = false;
@ -4275,8 +4253,7 @@ static int cmd_scopy(void)
off_t written = 0;
struct scopy_timing st;
int rc = 0;
struct cli_credentials *creds =
get_cmdline_auth_info_creds(popt_get_cmdline_auth_info());
struct cli_credentials *creds = samba_cmdline_get_creds();
NTSTATUS status;
if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL) ||
@ -4417,8 +4394,7 @@ static int cmd_hardlink(void)
char *buf, *buf2;
struct cli_state *targetcli;
char *targetname;
struct cli_credentials *creds =
get_cmdline_auth_info_creds(popt_get_cmdline_auth_info());
struct cli_credentials *creds = samba_cmdline_get_creds();
NTSTATUS status;
if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL) ||
@ -5126,8 +5102,7 @@ static int cmd_show_connect( void )
TALLOC_CTX *ctx = talloc_tos();
struct cli_state *targetcli;
char *targetpath;
struct cli_credentials *creds =
get_cmdline_auth_info_creds(popt_get_cmdline_auth_info());
struct cli_credentials *creds = samba_cmdline_get_creds();
NTSTATUS status;
status = cli_resolve_path(ctx, "",
@ -5387,9 +5362,10 @@ int cmd_iosize(void)
TALLOC_CTX *ctx = talloc_tos();
char *buf;
int iosize;
struct cli_credentials *creds = samba_cmdline_get_creds();
bool smb_encrypt =
get_cmdline_auth_info_smb_encrypt(
popt_get_cmdline_auth_info());
(cli_credentials_get_smb_encryption(creds) ==
SMB_ENCRYPTION_REQUIRED);
if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL)) {
if (smbXcli_conn_protocol(cli->conn) < PROTOCOL_SMB2_02) {
@ -5653,8 +5629,7 @@ static int process_command_string(const char *cmd_in)
TALLOC_CTX *ctx = talloc_tos();
char *cmd = talloc_strdup(ctx, cmd_in);
int rc = 0;
struct cli_credentials *creds =
get_cmdline_auth_info_creds(popt_get_cmdline_auth_info());
struct cli_credentials *creds = samba_cmdline_get_creds();
if (!cmd) {
return 1;
@ -5790,8 +5765,7 @@ static char **remote_completion(const char *text, int len)
struct cli_state *targetcli = NULL;
int i;
struct completion_remote info = { NULL, NULL, 1, 0, NULL, 0 };
struct cli_credentials *creds =
get_cmdline_auth_info_creds(popt_get_cmdline_auth_info());
struct cli_credentials *creds = samba_cmdline_get_creds();
NTSTATUS status;
/* can't have non-static initialisation on Sun CC, so do it
@ -6109,8 +6083,7 @@ static int process(const char *base_directory)
{
int rc = 0;
NTSTATUS status;
struct cli_credentials *creds =
get_cmdline_auth_info_creds(popt_get_cmdline_auth_info());
struct cli_credentials *creds = samba_cmdline_get_creds();
status = cli_cm_open(talloc_tos(), NULL,
desthost,
@ -6149,8 +6122,7 @@ static int process(const char *base_directory)
static int do_host_query(const char *query_host)
{
NTSTATUS status;
struct cli_credentials *creds =
get_cmdline_auth_info_creds(popt_get_cmdline_auth_info());
struct cli_credentials *creds = samba_cmdline_get_creds();
status = cli_cm_open(talloc_tos(), NULL,
query_host,
@ -6226,8 +6198,7 @@ static int do_tar_op(const char *base_directory)
{
struct tar *tar_ctx = tar_get_ctx();
int ret = 0;
struct cli_credentials *creds =
get_cmdline_auth_info_creds(popt_get_cmdline_auth_info());
struct cli_credentials *creds = samba_cmdline_get_creds();
/* do we already have a connection? */
if (!cli) {
@ -6267,7 +6238,7 @@ static int do_tar_op(const char *base_directory)
Handle a message operation.
****************************************************************************/
static int do_message_op(struct user_auth_info *a_info)
static int do_message_op(struct cli_credentials *creds)
{
NTSTATUS status;
@ -6288,7 +6259,7 @@ static int do_message_op(struct user_auth_info *a_info)
}
cli_set_timeout(cli, io_timeout*1000);
send_message(get_cmdline_auth_info_username(a_info));
send_message(cli_credentials_get_username(creds));
cli_shutdown(cli);
return 0;
@ -6312,6 +6283,7 @@ int main(int argc,char *argv[])
bool tar_opt = false;
bool service_opt = false;
struct tar *tar_ctx = tar_get_ctx();
bool ok;
struct poptOption long_options[] = {
POPT_AUTOHELP
@ -6360,15 +6332,6 @@ int main(int argc,char *argv[])
.descrip = "Get a list of shares available on a host",
.argDescrip = "HOST",
},
{
.longName = "max-protocol",
.shortName = 'm',
.argInfo = POPT_ARG_STRING,
.arg = NULL,
.val = 'm',
.descrip = "Set the max protocol level",
.argDescrip = "LEVEL",
},
{
.longName = "tar",
.shortName = 'T',
@ -6449,27 +6412,33 @@ int main(int argc,char *argv[])
POPT_COMMON_SAMBA
POPT_COMMON_CONNECTION
POPT_COMMON_CREDENTIALS
POPT_LEGACY_S3
POPT_COMMON_VERSION
POPT_TABLEEND
};
TALLOC_CTX *frame = talloc_stackframe();
struct cli_credentials *creds = NULL;
if (!client_set_cur_dir("\\")) {
exit(ENOMEM);
}
/* set default debug level to 1 regardless of what smb.conf sets */
setup_logging( "smbclient", DEBUG_DEFAULT_STDERR );
smb_init_locale();
ok = samba_cmdline_init(frame,
SAMBA_CMDLINE_CONFIG_CLIENT,
false /* require_smbconf */);
if (!ok) {
DBG_ERR("Failed to init cmdline parser!\n");
exit(ENOMEM);
}
lp_set_cmdline("log level", "1");
popt_common_credentials_set_ignore_missing_conf();
popt_common_credentials_set_delay_post();
/* skip argv(0) */
pc = poptGetContext("smbclient", argc, const_argv, long_options, 0);
poptSetOtherOptionHelp(pc, "service <password>");
poptSetOtherOptionHelp(pc, "[OPTIONS] service <password>");
creds = samba_cmdline_get_creds();
while ((opt = poptGetNextOpt(pc)) != -1) {
/*
@ -6494,12 +6463,12 @@ int main(int argc,char *argv[])
}
/* if the service has already been retrieved then check if we have also a password */
if (service_opt
&& (!get_cmdline_auth_info_got_pass(
popt_get_cmdline_auth_info()))
&& poptPeekArg(pc)) {
set_cmdline_auth_info_password(
popt_get_cmdline_auth_info(), poptGetArg(pc));
if (service_opt &&
cli_credentials_get_password(creds) == NULL &&
poptPeekArg(pc)) {
cli_credentials_set_password(creds,
poptGetArg(pc),
CRED_SPECIFIED);
}
@ -6527,20 +6496,12 @@ int main(int argc,char *argv[])
print_sockaddr(dest_ss_str, sizeof(dest_ss_str), &dest_ss);
}
break;
case 'E':
setup_logging("smbclient", DEBUG_STDERR );
display_set_stderr();
break;
case 'L':
query_host = talloc_strdup(frame, poptGetOptArg(pc));
if (!query_host) {
exit(ENOMEM);
}
break;
case 'm':
lp_set_cmdline("client max protocol", poptGetOptArg(pc));
break;
case 'T':
/* We must use old option processing for this. Find the
* position of the -T option in the raw argv[]. */
@ -6597,11 +6558,12 @@ int main(int argc,char *argv[])
}
/* if the service has already been retrieved then check if we have also a password */
if (service_opt
&& !get_cmdline_auth_info_got_pass(popt_get_cmdline_auth_info())
&& poptPeekArg(pc)) {
set_cmdline_auth_info_password(popt_get_cmdline_auth_info(),
poptGetArg(pc));
if (service_opt &&
cli_credentials_get_password(creds) == NULL &&
poptPeekArg(pc)) {
cli_credentials_set_password(creds,
poptGetArg(pc),
CRED_SPECIFIED);
}
if (service_opt && service) {
@ -6631,13 +6593,10 @@ int main(int argc,char *argv[])
}
poptFreeContext(pc);
popt_burn_cmdline_password(argc, argv);
samba_cmdline_burn(argc, argv);
DEBUG(3,("Client started (version %s).\n", samba_version_string()));
/* Ensure we have a password (or equivalent). */
popt_common_credentials_post();
if (tar_to_process(tar_ctx)) {
if (cmdstr)
process_command_string(cmdstr);
@ -6662,12 +6621,11 @@ int main(int argc,char *argv[])
rc = do_host_query(qhost);
} else if (message) {
rc = do_message_op(popt_get_cmdline_auth_info());
rc = do_message_op(creds);
} else if (process(base_directory)) {
rc = 1;
}
popt_free_cmdline_auth_info();
TALLOC_FREE(frame);
return rc;
}

View File

@ -42,24 +42,24 @@ testit "smbclient -m smb3_11 //$SERVER/tmp" $SMBCLIENT -m smb3_11 -U $USERNAME%$
# SMB1
testit_expect_failure "smbclient //$SERVER/tmpenc" $SMBCLIENT -U $USERNAME%$PASSWORD //$SERVER/tmpenc -c quit && failed=`expr $failed + 1`
testit_expect_failure "smbclient -e //$SERVER/tmpenc" $SMBCLIENT -e -U $USERNAME%$PASSWORD //$SERVER/tmpenc -c quit && failed=`expr $failed + 1`
testit_expect_failure "smbclient --client-protection=encrypt //$SERVER/tmpenc" $SMBCLIENT --client-protection=encrypt -U $USERNAME%$PASSWORD //$SERVER/tmpenc -c quit && failed=`expr $failed + 1`
# SMB3_02
testit_expect_failure "smbclient -m smb3_02 //$SERVER/tmpenc" $SMBCLIENT -m smb3_02 -U $USERNAME%$PASSWORD //$SERVER/tmpenc -c quit && failed=`expr $failed + 1`
testit_expect_failure "smbclient -e -m smb3_02 //$SERVER/tmpenc" $SMBCLIENT -e -m smb3_02 -U $USERNAME%$PASSWORD //$SERVER/tmpenc -c quit && failed=`expr $failed + 1`
testit_expect_failure "smbclient --client-protection=encrypt -m smb3_02 //$SERVER/tmpenc" $SMBCLIENT --client-protection=encrypt -m smb3_02 -U $USERNAME%$PASSWORD //$SERVER/tmpenc -c quit && failed=`expr $failed + 1`
# SMB3_11
testit_expect_failure "smbclient -m smb3_11 //$SERVER/tmpenc" $SMBCLIENT -m smb3_11 -U $USERNAME%$PASSWORD //$SERVER/tmpenc -c quit && failed=`expr $failed + 1`
testit_expect_failure "smbclient -e -m smb3_11 //$SERVER/tmpenc" $SMBCLIENT -e -m smb3_11 -U $USERNAME%$PASSWORD //$SERVER/tmpenc -c quit && failed=`expr $failed + 1`
testit_expect_failure "smbclient --client-protection=encrypt -m smb3_11 //$SERVER/tmpenc" $SMBCLIENT --client-protection=encrypt -m smb3_11 -U $USERNAME%$PASSWORD //$SERVER/tmpenc -c quit && failed=`expr $failed + 1`
# These tests must fail, as the client requires encryption and it's off on the server
# SMB1
testit_expect_failure "smbclient -e //$SERVER/enc_desired" $SMBCLIENT -e -U $USERNAME%$PASSWORD //$SERVER/enc_desired -c quit && failed=`expr $failed + 1`
testit_expect_failure "smbclient -e //$SERVER/tmp" $SMBCLIENT -e -U $USERNAME%$PASSWORD //$SERVER/tmp -c quit && failed=`expr $failed + 1`
testit_expect_failure "smbclient --client-protection=encrypt //$SERVER/enc_desired" $SMBCLIENT --client-protection=encrypt -U $USERNAME%$PASSWORD //$SERVER/enc_desired -c quit && failed=`expr $failed + 1`
testit_expect_failure "smbclient --client-protection=encrypt //$SERVER/tmp" $SMBCLIENT --client-protection=encrypt -U $USERNAME%$PASSWORD //$SERVER/tmp -c quit && failed=`expr $failed + 1`
# SMB3_02
testit_expect_failure "smbclient -e -m smb3_02 //$SERVER/enc_desired" $SMBCLIENT -e -m smb3_02 -U $USERNAME%$PASSWORD //$SERVER/enc_desired -c quit && failed=`expr $failed + 1`
testit_expect_failure "smbclient -e -m smb3_02 //$SERVER/tmp" $SMBCLIENT -e -m smb3_02 -U $USERNAME%$PASSWORD //$SERVER/tmp -c quit && failed=`expr $failed + 1`
testit_expect_failure "smbclient --client-protection=encrypt -m smb3_02 //$SERVER/enc_desired" $SMBCLIENT --client-protection=encrypt -m smb3_02 -U $USERNAME%$PASSWORD //$SERVER/enc_desired -c quit && failed=`expr $failed + 1`
testit_expect_failure "smbclient --client-protection=encrypt -m smb3_02 //$SERVER/tmp" $SMBCLIENT --client-protection=encrypt -m smb3_02 -U $USERNAME%$PASSWORD //$SERVER/tmp -c quit && failed=`expr $failed + 1`
# SMB3_11
testit_expect_failure "smbclient -e -m smb3_11 //$SERVER/enc_desired" $SMBCLIENT -e -m smb3_11 -U $USERNAME%$PASSWORD //$SERVER/enc_desired -c quit && failed=`expr $failed + 1`
testit_expect_failure "smbclient -e -m smb3_11 //$SERVER/tmp" $SMBCLIENT -e -m smb3_11 -U $USERNAME%$PASSWORD //$SERVER/tmp -c quit && failed=`expr $failed + 1`
testit_expect_failure "smbclient --client-protection=encrypt -m smb3_11 //$SERVER/enc_desired" $SMBCLIENT --client-protection=encrypt -m smb3_11 -U $USERNAME%$PASSWORD //$SERVER/enc_desired -c quit && failed=`expr $failed + 1`
testit_expect_failure "smbclient --client-protection=encrypt -m smb3_11 //$SERVER/tmp" $SMBCLIENT --client-protection=encrypt -m smb3_11 -U $USERNAME%$PASSWORD //$SERVER/tmp -c quit && failed=`expr $failed + 1`
testok $0 $failed

View File

@ -66,10 +66,10 @@ else
testit "smbclient baduser.badpassword.SMB3.guest" $SMBCLIENT //$SERVER/IPC\$ $CONFIGURATION -Ubaduser%badpassword -mSMB3 -c quit $ADDARGS
fi
if [ $PROTOCOL = "NT1" ]; then
testit_expect_failure "smbclient baduser.badpassword.NT1OLD.signfail" $SMBCLIENT //$SERVER/IPC\$ $CONFIGURATION -Ubaduser%badpassword -mNT1 --option=clientusespnego=no --option=clientntlmv2auth=no --signing=required -c quit $ADDARGS
testit_expect_failure "smbclient baduser.badpassword.NT1NEW.signfail" $SMBCLIENT //$SERVER/IPC\$ $CONFIGURATION -Ubaduser%badpassword -mNT1 --signing=required -c quit $ADDARGS
testit_expect_failure "smbclient baduser.badpassword.NT1OLD.signfail" $SMBCLIENT //$SERVER/IPC\$ $CONFIGURATION -Ubaduser%badpassword -mNT1 --option=clientusespnego=no --option=clientntlmv2auth=no --client-protection=sign -c quit $ADDARGS
testit_expect_failure "smbclient baduser.badpassword.NT1NEW.signfail" $SMBCLIENT //$SERVER/IPC\$ $CONFIGURATION -Ubaduser%badpassword -mNT1 --client-protection=sign -c quit $ADDARGS
fi
if [ $PROTOCOL = "SMB3" ]; then
testit_expect_failure "smbclient baduser.badpassword.SMB3.signfail" $SMBCLIENT //$SERVER/IPC\$ $CONFIGURATION -Ubaduser%badpassword -mSMB3 --signing=required -c quit $ADDARGS
testit_expect_failure "smbclient baduser.badpassword.SMB3.signfail" $SMBCLIENT //$SERVER/IPC\$ $CONFIGURATION -Ubaduser%badpassword -mSMB3 --client-protection=sign -c quit $ADDARGS
fi
fi

View File

@ -616,7 +616,7 @@ test_ccache_access()
return 1
fi
$SMBCLIENT //$SERVER_IP/tmp -C -U "${USERNAME}" $ADDARGS -c quit 2>&1
$SMBCLIENT //$SERVER_IP/tmp --use-winbind-ccache -U "${USERNAME}" $ADDARGS -c quit 2>&1
ret=$?
if [ $ret != 0 ] ; then
@ -632,7 +632,7 @@ test_ccache_access()
return 1
fi
$SMBCLIENT //$SERVER_IP/tmp -C -U "${USERNAME}" $ADDARGS -c quit 2>&1
$SMBCLIENT //$SERVER_IP/tmp --use-winbind-ccache -U "${USERNAME}" $ADDARGS -c quit 2>&1
ret=$?
if [ $ret -eq 0 ] ; then

View File

@ -446,19 +446,19 @@ for env in ["nt4_member", "ad_member"]:
plantestsuite("samba3.blackbox.smbclient_s3.SMB3.plain.member_creds", env, [os.path.join(samba3srcdir, "script/tests/test_smbclient_s3.sh"), '$SERVER', '$SERVER_IP', '$SERVER', '$SERVER/$USERNAME', '$PASSWORD', '$USERID', '$LOCAL_PATH', '$PREFIX', smbclient3, wbinfo, net, configuration, "SMB3"])
env = "nt4_dc_smb1_done"
plantestsuite("samba3.blackbox.smbclient_s3.NT1.sign", env, [os.path.join(samba3srcdir, "script/tests/test_smbclient_s3.sh"), '$SERVER', '$SERVER_IP', '$DOMAIN', '$DC_USERNAME', '$DC_PASSWORD', '$USERID', '$LOCAL_PATH', '$PREFIX', smbclient3, wbinfo, net, configuration, "NT1", "--signing=required"])
plantestsuite("samba3.blackbox.smbclient_s3.NT1.sign", env, [os.path.join(samba3srcdir, "script/tests/test_smbclient_s3.sh"), '$SERVER', '$SERVER_IP', '$DOMAIN', '$DC_USERNAME', '$DC_PASSWORD', '$USERID', '$LOCAL_PATH', '$PREFIX', smbclient3, wbinfo, net, configuration, "NT1", "--client-protection=sign"])
env = "nt4_dc"
plantestsuite("samba3.blackbox.smbclient_s3.SMB3.sign", env, [os.path.join(samba3srcdir, "script/tests/test_smbclient_s3.sh"), '$SERVER', '$SERVER_IP', '$DOMAIN', '$DC_USERNAME', '$DC_PASSWORD', '$USERID', '$LOCAL_PATH', '$PREFIX', smbclient3, wbinfo, net, configuration, "SMB3", "--signing=required"])
plantestsuite("samba3.blackbox.smbclient_s3.SMB3.sign", env, [os.path.join(samba3srcdir, "script/tests/test_smbclient_s3.sh"), '$SERVER', '$SERVER_IP', '$DOMAIN', '$DC_USERNAME', '$DC_PASSWORD', '$USERID', '$LOCAL_PATH', '$PREFIX', smbclient3, wbinfo, net, configuration, "SMB3", "--client-protection=sign"])
for env in ["nt4_member", "ad_member"]:
plantestsuite("samba3.blackbox.smbclient_s3.NT1.sign.member_creds", env, [os.path.join(samba3srcdir, "script/tests/test_smbclient_s3.sh"), '$SERVER', '$SERVER_IP', '$SERVER', '$SERVER/$USERNAME', '$PASSWORD', '$USERID', '$LOCAL_PATH', '$PREFIX', smbclient3, wbinfo, net, configuration, "NT1", "--signing=required"])
plantestsuite("samba3.blackbox.smbclient_s3.SMB3.sign.member_creds", env, [os.path.join(samba3srcdir, "script/tests/test_smbclient_s3.sh"), '$SERVER', '$SERVER_IP', '$SERVER', '$SERVER/$USERNAME', '$PASSWORD', '$USERID', '$LOCAL_PATH', '$PREFIX', smbclient3, wbinfo, net, configuration, "SMB3", "--signing=required"])
plantestsuite("samba3.blackbox.smbclient_s3.NT1.sign.member_creds", env, [os.path.join(samba3srcdir, "script/tests/test_smbclient_s3.sh"), '$SERVER', '$SERVER_IP', '$SERVER', '$SERVER/$USERNAME', '$PASSWORD', '$USERID', '$LOCAL_PATH', '$PREFIX', smbclient3, wbinfo, net, configuration, "NT1", "--client-protection=sign"])
plantestsuite("samba3.blackbox.smbclient_s3.SMB3.sign.member_creds", env, [os.path.join(samba3srcdir, "script/tests/test_smbclient_s3.sh"), '$SERVER', '$SERVER_IP', '$SERVER', '$SERVER/$USERNAME', '$PASSWORD', '$USERID', '$LOCAL_PATH', '$PREFIX', smbclient3, wbinfo, net, configuration, "SMB3", "--client-protection=sign"])
env = "nt4_dc_smb1_done"
# encrypted
plantestsuite("samba3.blackbox.smbclient_s3.NT1.crypt", env, [os.path.join(samba3srcdir, "script/tests/test_smbclient_s3.sh"), '$SERVER', '$SERVER_IP', '$DOMAIN', '$USERNAME', '$PASSWORD', '$USERID', '$LOCAL_PATH', '$PREFIX', smbclient3, wbinfo, net, configuration, "NT1", "-e"])
plantestsuite("samba3.blackbox.smbclient_s3.NT1.crypt", env, [os.path.join(samba3srcdir, "script/tests/test_smbclient_s3.sh"), '$SERVER', '$SERVER_IP', '$DOMAIN', '$USERNAME', '$PASSWORD', '$USERID', '$LOCAL_PATH', '$PREFIX', smbclient3, wbinfo, net, configuration, "NT1", "--client-protection=encrypt"])
env = "nt4_dc"
plantestsuite("samba3.blackbox.smbclient_s3.SMB3.crypt", env, [os.path.join(samba3srcdir, "script/tests/test_smbclient_s3.sh"), '$SERVER', '$SERVER_IP', '$DOMAIN', '$USERNAME', '$PASSWORD', '$USERID', '$LOCAL_PATH', '$PREFIX', smbclient3, wbinfo, net, configuration, "SMB3", "-e"])
plantestsuite("samba3.blackbox.smbclient_s3.SMB3.crypt", env, [os.path.join(samba3srcdir, "script/tests/test_smbclient_s3.sh"), '$SERVER', '$SERVER_IP', '$DOMAIN', '$USERNAME', '$PASSWORD', '$USERID', '$LOCAL_PATH', '$PREFIX', smbclient3, wbinfo, net, configuration, "SMB3", "--client-protection=encrypt"])
for env in ["fileserver"]:
plantestsuite("samba3.blackbox.preserve_case.NT1", env + "_smb1_done", [os.path.join(samba3srcdir, "script/tests/test_preserve_case.sh"), '$SERVER', '$DOMAIN', '$USERNAME', '$PASSWORD', '$PREFIX', smbclient3, "NT1"])
@ -1143,7 +1143,7 @@ plantestsuite("samba3.blackbox.rpcclient_netsessenum", "ad_member",
# The ktest environment uses:
# server min protocol = SMB3_00
# client max protocol = SMB3
options_list = ["", "-e"]
options_list = ["", "--client-protection=encrypt"]
for options in options_list:
plantestsuite("samba3.blackbox.smbclient_krb5 old ccache %s" % options, "ktest:local",
[os.path.join(samba3srcdir, "script/tests/test_smbclient_krb5.sh"),
@ -1158,9 +1158,9 @@ for options in options_list:
plantestsuite("samba3.blackbox.smbclient_large_file %s krb5" % options, "ktest:local",
[os.path.join(samba3srcdir, "script/tests/test_smbclient_large_file.sh"),
"$PREFIX/ktest/krb5_ccache-3",
smbclient3, "$SERVER", "$PREFIX", options, "-k " + configuration])
smbclient3, "$SERVER", "$PREFIX", options, "--use-krb5-ccache=$PREFIX/ktest/krb5_ccache-3 " + configuration])
options_list = ["-mNT1", "-mNT1 -e", "-mSMB3", "-mSMB3 -e"]
options_list = ["-mNT1", "-mNT1 --client-protection=encrypt", "-mSMB3", "-mSMB3 --client-protection=encrypt"]
for options in options_list:
env = "nt4_dc"
if "NT1" in options:

View File

@ -1135,7 +1135,7 @@ bld.SAMBA3_BINARY('client/smbclient',
''',
deps='''
talloc
popt_samba3_cmdline
CMDLINE_S3
smbconf
ndr-standard
SMBREADLINE