mirror of
https://github.com/samba-team/samba.git
synced 2025-01-11 05:18:09 +03:00
s4:torture: Migrate masktest 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:
parent
caafb3cd4a
commit
ba32b542cd
@ -18,7 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "includes.h"
|
#include "includes.h"
|
||||||
#include "lib/cmdline/popt_common.h"
|
#include "lib/cmdline/cmdline.h"
|
||||||
#include "system/filesys.h"
|
#include "system/filesys.h"
|
||||||
#include "system/dir.h"
|
#include "system/dir.h"
|
||||||
#include "libcli/libcli.h"
|
#include "libcli/libcli.h"
|
||||||
@ -83,6 +83,7 @@ static struct smbcli_state *connect_one(struct resolve_context *resolve_ctx,
|
|||||||
struct smbcli_state *c;
|
struct smbcli_state *c;
|
||||||
char *server;
|
char *server;
|
||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
|
struct cli_credentials *creds = samba_cmdline_get_creds();
|
||||||
|
|
||||||
server = talloc_strdup(mem_ctx, share+2);
|
server = talloc_strdup(mem_ctx, share+2);
|
||||||
share = strchr_m(server,'\\');
|
share = strchr_m(server,'\\');
|
||||||
@ -90,7 +91,7 @@ static struct smbcli_state *connect_one(struct resolve_context *resolve_ctx,
|
|||||||
*share = 0;
|
*share = 0;
|
||||||
share++;
|
share++;
|
||||||
|
|
||||||
cli_credentials_set_workstation(popt_get_cmdline_credentials(),
|
cli_credentials_set_workstation(creds,
|
||||||
"masktest", CRED_SPECIFIED);
|
"masktest", CRED_SPECIFIED);
|
||||||
|
|
||||||
status = smbcli_full_connection(NULL, &c,
|
status = smbcli_full_connection(NULL, &c,
|
||||||
@ -98,7 +99,7 @@ static struct smbcli_state *connect_one(struct resolve_context *resolve_ctx,
|
|||||||
ports,
|
ports,
|
||||||
share, NULL,
|
share, NULL,
|
||||||
socket_options,
|
socket_options,
|
||||||
popt_get_cmdline_credentials(),
|
creds,
|
||||||
resolve_ctx, ev,
|
resolve_ctx, ev,
|
||||||
options, session_options,
|
options, session_options,
|
||||||
gensec_settings);
|
gensec_settings);
|
||||||
@ -317,8 +318,10 @@ int main(int argc, const char *argv[])
|
|||||||
POPT_COMMON_CONNECTION
|
POPT_COMMON_CONNECTION
|
||||||
POPT_COMMON_CREDENTIALS
|
POPT_COMMON_CREDENTIALS
|
||||||
POPT_COMMON_VERSION
|
POPT_COMMON_VERSION
|
||||||
{0}
|
POPT_LEGACY_S4
|
||||||
|
POPT_TABLEEND
|
||||||
};
|
};
|
||||||
|
bool ok;
|
||||||
|
|
||||||
setlinebuf(stdout);
|
setlinebuf(stdout);
|
||||||
seed = time(NULL);
|
seed = time(NULL);
|
||||||
@ -328,15 +331,34 @@ int main(int argc, const char *argv[])
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
pc = poptGetContext("locktest", argc, argv, long_options,
|
ok = samba_cmdline_init(mem_ctx,
|
||||||
POPT_CONTEXT_KEEP_FIRST);
|
SAMBA_CMDLINE_CONFIG_CLIENT,
|
||||||
|
false /* require_smbconf */);
|
||||||
|
if (!ok) {
|
||||||
|
DBG_ERR("Failed to init cmdline parser!\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
pc = samba_popt_get_context(getprogname(),
|
||||||
|
argc,
|
||||||
|
argv,
|
||||||
|
long_options,
|
||||||
|
POPT_CONTEXT_KEEP_FIRST);
|
||||||
|
if (pc == NULL) {
|
||||||
|
DBG_ERR("Failed to setup popt context!\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
poptSetOtherOptionHelp(pc, "<unc>");
|
poptSetOtherOptionHelp(pc, "<unc>");
|
||||||
|
|
||||||
|
lp_ctx = samba_cmdline_get_lp_ctx();
|
||||||
|
|
||||||
while((opt = poptGetNextOpt(pc)) != -1) {
|
while((opt = poptGetNextOpt(pc)) != -1) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case OPT_UNCLIST:
|
case OPT_UNCLIST:
|
||||||
lpcfg_set_cmdline(cmdline_lp_ctx, "torture:unclist", poptGetOptArg(pc));
|
lpcfg_set_cmdline(lp_ctx,
|
||||||
|
"torture:unclist",
|
||||||
|
poptGetOptArg(pc));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -362,8 +384,6 @@ int main(int argc, const char *argv[])
|
|||||||
|
|
||||||
all_string_sub(share,"/","\\",0);
|
all_string_sub(share,"/","\\",0);
|
||||||
|
|
||||||
lp_ctx = cmdline_lp_ctx;
|
|
||||||
|
|
||||||
ev = s4_event_context_init(mem_ctx);
|
ev = s4_event_context_init(mem_ctx);
|
||||||
|
|
||||||
gensec_init();
|
gensec_init();
|
||||||
|
@ -338,7 +338,7 @@ bld.SAMBA_BINARY('gentest',
|
|||||||
bld.SAMBA_BINARY('masktest',
|
bld.SAMBA_BINARY('masktest',
|
||||||
source='masktest.c',
|
source='masktest.c',
|
||||||
manpages='man/masktest.1',
|
manpages='man/masktest.1',
|
||||||
deps='samba-hostconfig samba-util popt POPT_SAMBA POPT_CREDENTIALS LIBCLI_SMB param_options'
|
deps='samba-hostconfig samba-util popt CMDLINE_S4 LIBCLI_SMB param_options'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user