summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
Diffstat (limited to 'source3')
-rw-r--r--source3/include/includes.h6
-rw-r--r--source3/utils/net.c404
-rw-r--r--source3/utils/net.h88
-rw-r--r--source3/utils/net_ads.c351
-rw-r--r--source3/utils/net_ads_gpo.c42
-rw-r--r--source3/utils/net_cache.c30
-rw-r--r--source3/utils/net_conf.c147
-rw-r--r--source3/utils/net_dom.c66
-rw-r--r--source3/utils/net_groupmap.c55
-rw-r--r--source3/utils/net_help.c50
-rw-r--r--source3/utils/net_idmap.c25
-rw-r--r--source3/utils/net_lookup.c38
-rw-r--r--source3/utils/net_rap.c265
-rw-r--r--source3/utils/net_registry.c25
-rw-r--r--source3/utils/net_rpc.c880
-rw-r--r--source3/utils/net_rpc_audit.c47
-rw-r--r--source3/utils/net_rpc_join.c21
-rw-r--r--source3/utils/net_rpc_printer.c116
-rw-r--r--source3/utils/net_rpc_registry.c69
-rw-r--r--source3/utils/net_rpc_rights.c52
-rw-r--r--source3/utils/net_rpc_samsync.c12
-rw-r--r--source3/utils/net_rpc_service.c50
-rw-r--r--source3/utils/net_rpc_sh_acct.c78
-rw-r--r--source3/utils/net_rpc_shell.c45
-rw-r--r--source3/utils/net_sam.c145
-rw-r--r--source3/utils/net_status.c16
-rw-r--r--source3/utils/net_time.c38
-rw-r--r--source3/utils/net_usershare.c65
-rw-r--r--source3/utils/net_util.c3
-rw-r--r--source3/utils/netlookup.c21
30 files changed, 1772 insertions, 1478 deletions
diff --git a/source3/include/includes.h b/source3/include/includes.h
index 70e1b48fa17..d9c699a4391 100644
--- a/source3/include/includes.h
+++ b/source3/include/includes.h
@@ -727,14 +727,16 @@ typedef char fstring[FSTRING_LEN];
#include "lib/smbconf/smbconf.h"
/* used in net.c */
+struct net_context;
+
struct functable {
const char *funcname;
- int (*fn)(int argc, const char **argv);
+ int (*fn)(struct net_context *c, int argc, const char **argv);
};
struct functable2 {
const char *funcname;
- int (*fn)(int argc, const char **argv);
+ int (*fn)(struct net_context *c, int argc, const char **argv);
const char *helptext;
};
diff --git a/source3/utils/net.c b/source3/utils/net.c
index 19ba4f0e8a7..db7f6c090c0 100644
--- a/source3/utils/net.c
+++ b/source3/utils/net.c
@@ -5,12 +5,16 @@
Copyright (C) 2001 Jim McDonough (jmcd@us.ibm.com)
Copyright (C) 2001 Andrew Tridgell (tridge@samba.org)
Copyright (C) 2001 Andrew Bartlett (abartlet@samba.org)
+ Copyright (C) 2008 Kai Blin (kai@samba.org)
Originally written by Steve and Jim. Largely rewritten by tridge in
November 2001.
Reworked again by abartlet in December 2001
+ Another overhaul, moving functionality into plug-ins loaded on demand by Kai
+ in May 2008.
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
@@ -54,45 +58,6 @@
/* end of internationalization section */
/***********************************************************************/
-/* Yes, these buggers are globals.... */
-const char *opt_requester_name = NULL;
-const char *opt_host = NULL;
-const char *opt_password = NULL;
-const char *opt_user_name = NULL;
-bool opt_user_specified = False;
-const char *opt_workgroup = NULL;
-int opt_long_list_entries = 0;
-int opt_reboot = 0;
-int opt_force = 0;
-int opt_stdin = 0;
-int opt_port = 0;
-int opt_verbose = 0;
-int opt_maxusers = -1;
-const char *opt_comment = "";
-const char *opt_container = NULL;
-int opt_flags = -1;
-int opt_timeout = 0;
-const char *opt_target_workgroup = NULL;
-int opt_machine_pass = 0;
-int opt_localgroup = False;
-int opt_domaingroup = False;
-static int do_talloc_report=False;
-const char *opt_newntname = "";
-int opt_rid = 0;
-int opt_acls = 0;
-int opt_attrs = 0;
-int opt_timestamps = 0;
-const char *opt_exclude = NULL;
-const char *opt_destination = NULL;
-int opt_testmode = False;
-
-int opt_have_ip = False;
-struct sockaddr_storage opt_dest_ip;
-bool smb_encrypt;
-struct libnetapi_ctx *netapi_ctx = NULL;
-
-extern bool AllowDebugChange;
-
uint32 get_sec_channel_type(const char *param)
{
if (!(param && *param)) {
@@ -118,35 +83,37 @@ uint32 get_sec_channel_type(const char *param)
run a function from a function table. If not found then
call the specified usage function
*/
-int net_run_function(int argc, const char **argv, struct functable *table,
- int (*usage_fn)(int argc, const char **argv))
+int net_run_function(struct net_context *c, int argc, const char **argv,
+ struct functable *table,
+ int (*usage_fn)(struct net_context *c,
+ int argc, const char **argv))
{
int i;
if (argc < 1) {
d_printf("\nUsage: \n");
- return usage_fn(argc, argv);
+ return usage_fn(c, argc, argv);
}
for (i=0; table[i].funcname; i++) {
if (StrCaseCmp(argv[0], table[i].funcname) == 0)
- return table[i].fn(argc-1, argv+1);
+ return table[i].fn(c, argc-1, argv+1);
}
d_fprintf(stderr, "No command: %s\n", argv[0]);
- return usage_fn(argc, argv);
+ return usage_fn(c, argc, argv);
}
/*
* run a function from a function table.
*/
-int net_run_function2(int argc, const char **argv, const char *whoami,
- struct functable2 *table)
+int net_run_function2(struct net_context *c, int argc, const char **argv,
+ const char *whoami, struct functable2 *table)
{
int i;
if (argc != 0) {
for (i=0; table[i].funcname; i++) {
if (StrCaseCmp(argv[0], table[i].funcname) == 0)
- return table[i].fn(argc-1, argv+1);
+ return table[i].fn(c, argc-1, argv+1);
}
}
@@ -162,7 +129,8 @@ int net_run_function2(int argc, const char **argv, const char *whoami,
Connect to \\server\service.
****************************************************************************/
-NTSTATUS connect_to_service(struct cli_state **c,
+NTSTATUS connect_to_service(struct net_context *c,
+ struct cli_state **cli_ctx,
struct sockaddr_storage *server_ss,
const char *server_name,
const char *service_name,
@@ -170,16 +138,16 @@ NTSTATUS connect_to_service(struct cli_state **c,
{
NTSTATUS nt_status;
- opt_password = net_prompt_pass(opt_user_name);
- if (!opt_password) {
+ c->opt_password = net_prompt_pass(c, c->opt_user_name);
+ if (!c->opt_password) {
return NT_STATUS_NO_MEMORY;
}
- nt_status = cli_full_connection(c, NULL, server_name,
- server_ss, opt_port,
+ nt_status = cli_full_connection(cli_ctx, NULL, server_name,
+ server_ss, c->opt_port,
service_name, service_type,
- opt_user_name, opt_workgroup,
- opt_password, 0, Undefined, NULL);
+ c->opt_user_name, c->opt_workgroup,
+ c->opt_password, 0, Undefined, NULL);
if (!NT_STATUS_IS_OK(nt_status)) {
d_fprintf(stderr, "Could not connect to server %s\n", server_name);
@@ -199,11 +167,11 @@ NTSTATUS connect_to_service(struct cli_state **c,
return nt_status;
}
- if (smb_encrypt) {
- nt_status = cli_force_encryption(*c,
- opt_user_name,
- opt_password,
- opt_workgroup);
+ if (c->smb_encrypt) {
+ nt_status = cli_force_encryption(*cli_ctx,
+ c->opt_user_name,
+ c->opt_password,
+ c->opt_workgroup);
if (NT_STATUS_EQUAL(nt_status,NT_STATUS_NOT_SUPPORTED)) {
d_printf("Encryption required and "
@@ -224,8 +192,8 @@ NTSTATUS connect_to_service(struct cli_state **c,
}
if (!NT_STATUS_IS_OK(nt_status)) {
- cli_shutdown(*c);
- *c = NULL;
+ cli_shutdown(*cli_ctx);
+ *cli_ctx = NULL;
}
}
@@ -236,25 +204,28 @@ NTSTATUS connect_to_service(struct cli_state **c,
Connect to \\server\ipc$.
****************************************************************************/
-NTSTATUS connect_to_ipc(struct cli_state **c,
+NTSTATUS connect_to_ipc(struct net_context *c,
+ struct cli_state **cli_ctx,
struct sockaddr_storage *server_ss,
const char *server_name)
{
- return connect_to_service(c, server_ss, server_name, "IPC$", "IPC");
+ return connect_to_service(c, cli_ctx, server_ss, server_name, "IPC$",
+ "IPC");
}
/****************************************************************************
Connect to \\server\ipc$ anonymously.
****************************************************************************/
-NTSTATUS connect_to_ipc_anonymous(struct cli_state **c,
+NTSTATUS connect_to_ipc_anonymous(struct net_context *c,
+ struct cli_state **cli_ctx,
struct sockaddr_storage *server_ss,
const char *server_name)
{
NTSTATUS nt_status;
- nt_status = cli_full_connection(c, opt_requester_name, server_name,
- server_ss, opt_port,
+ nt_status = cli_full_connection(cli_ctx, c->opt_requester_name,
+ server_name, server_ss, c->opt_port,
"IPC$", "IPC",
"", "",
"", 0, Undefined, NULL);
@@ -292,28 +263,31 @@ static char *get_user_and_realm(const char *username)
Connect to \\server\ipc$ using KRB5.
****************************************************************************/
-NTSTATUS connect_to_ipc_krb5(struct cli_state **c,
+NTSTATUS connect_to_ipc_krb5(struct net_context *c,
+ struct cli_state **cli_ctx,
struct sockaddr_storage *server_ss,
const char *server_name)
{
NTSTATUS nt_status;
char *user_and_realm = NULL;
- opt_password = net_prompt_pass(opt_user_name);
- if (!opt_password) {
+ /* FIXME: Should get existing kerberos ticket if possible. */
+ c->opt_password = net_prompt_pass(c, c->opt_user_name);
+ if (!c->opt_password) {
return NT_STATUS_NO_MEMORY;
}
- user_and_realm = get_user_and_realm(opt_user_name);
+ user_and_realm = get_user_and_realm(c->opt_user_name);
if (!user_and_realm) {
return NT_STATUS_NO_MEMORY;
}
- nt_status = cli_full_connection(c, NULL, server_name,
- server_ss, opt_port,
+ nt_status = cli_full_connection(cli_ctx, NULL, server_name,
+ server_ss, c->opt_port,
"IPC$", "IPC",
- user_and_realm, opt_workgroup,
- opt_password, CLI_FULL_CONNECTION_USE_KERBEROS,
+ user_and_realm, c->opt_workgroup,
+ c->opt_password,
+ CLI_FULL_CONNECTION_USE_KERBEROS,
Undefined, NULL);
SAFE_FREE(user_and_realm);
@@ -323,15 +297,15 @@ NTSTATUS connect_to_ipc_krb5(struct cli_state **c,
return nt_status;
}
- if (smb_encrypt) {
- nt_status = cli_cm_force_encryption(*c,
+ if (c->smb_encrypt) {
+ nt_status = cli_cm_force_encryption(*cli_ctx,
user_and_realm,
- opt_password,
- opt_workgroup,
+ c->opt_password,
+ c->opt_workgroup,
"IPC$");
if (!NT_STATUS_IS_OK(nt_status)) {
- cli_shutdown(*c);
- *c = NULL;
+ cli_shutdown(*cli_ctx);
+ *cli_ctx = NULL;
}
}
@@ -347,7 +321,8 @@ NTSTATUS connect_to_ipc_krb5(struct cli_state **c,
*
* @return Normal NTSTATUS return.
**/
-NTSTATUS connect_dst_pipe(struct cli_state **cli_dst, struct rpc_pipe_client **pp_pipe_hnd, int pipe_num)
+NTSTATUS connect_dst_pipe(struct net_context *c, struct cli_state **cli_dst,
+ struct rpc_pipe_client **pp_pipe_hnd, int pipe_num)
{
NTSTATUS nt_status;
char *server_name = SMB_STRDUP("127.0.0.1");
@@ -358,15 +333,15 @@ NTSTATUS connect_dst_pipe(struct cli_state **cli_dst, struct rpc_pipe_client **p
return NT_STATUS_NO_MEMORY;
}
- if (opt_destination) {
+ if (c->opt_destination) {
SAFE_FREE(server_name);
- if ((server_name = SMB_STRDUP(opt_destination)) == NULL) {
+ if ((server_name = SMB_STRDUP(c->opt_destination)) == NULL) {
return NT_STATUS_NO_MEMORY;
}
}
/* make a connection to a named pipe */
- nt_status = connect_to_ipc(&cli_tmp, NULL, server_name);
+ nt_status = connect_to_ipc(c, &cli_tmp, NULL, server_name);
if (!NT_STATUS_IS_OK(nt_status)) {
SAFE_FREE(server_name);
return nt_status;
@@ -391,7 +366,7 @@ NTSTATUS connect_dst_pipe(struct cli_state **cli_dst, struct rpc_pipe_client **p
Use the local machine account (krb) and password for this session.
****************************************************************************/
-int net_use_krb_machine_account(void)
+int net_use_krb_machine_account(struct net_context *c)
{
char *user_name = NULL;
@@ -400,11 +375,12 @@ int net_use_krb_machine_account(void)
exit(1);
}
- opt_password = secrets_fetch_machine_password(opt_target_workgroup, NULL, NULL);
+ c->opt_password = secrets_fetch_machine_password(
+ c->opt_target_workgroup, NULL, NULL);
if (asprintf(&user_name, "%s$@%s", global_myname(), lp_realm()) == -1) {
return -1;
}
- opt_user_name = user_name;
+ c->opt_user_name = user_name;
return 0;
}
@@ -412,7 +388,7 @@ int net_use_krb_machine_account(void)
Use the machine account name and password for this session.
****************************************************************************/
-int net_use_machine_account(void)
+int net_use_machine_account(struct net_context *c)
{
char *user_name = NULL;
@@ -421,30 +397,32 @@ int net_use_machine_account(void)
exit(1);
}
- opt_password = secrets_fetch_machine_password(opt_target_workgroup, NULL, NULL);
+ c->opt_password = secrets_fetch_machine_password(
+ c->opt_target_workgroup, NULL, NULL);
if (asprintf(&user_name, "%s$", global_myname()) == -1) {
return -1;
}
- opt_user_name = user_name;
+ c->opt_user_name = user_name;
return 0;
}
-bool net_find_server(const char *domain,
+bool net_find_server(struct net_context *c,
+ const char *domain,
unsigned flags,
struct sockaddr_storage *server_ss,
char **server_name)
{
- const char *d = domain ? domain : opt_target_workgroup;
+ const char *d = domain ? domain : c->opt_target_workgroup;
- if (opt_host) {
- *server_name = SMB_STRDUP(opt_host);
+ if (c->opt_host) {
+ *server_name = SMB_STRDUP(c->opt_host);
}
- if (opt_have_ip) {
- *server_ss = opt_dest_ip;
+ if (c->opt_have_ip) {
+ *server_ss = c->opt_dest_ip;
if (!*server_name) {
char addr[INET6_ADDRSTRLEN];
- print_sockaddr(addr, sizeof(addr), &opt_dest_ip);
+ print_sockaddr(addr, sizeof(addr), &c->opt_dest_ip);
*server_name = SMB_STRDUP(addr);
}
} else if (*server_name) {
@@ -530,14 +508,16 @@ bool net_find_pdc(struct sockaddr_storage *server_ss,
return true;
}
-NTSTATUS net_make_ipc_connection(unsigned flags, struct cli_state **pcli)
+NTSTATUS net_make_ipc_connection(struct net_context *c, unsigned flags,
+ struct cli_state **pcli)
{
- return net_make_ipc_connection_ex(NULL, NULL, NULL, flags, pcli);
+ return net_make_ipc_connection_ex(c, NULL, NULL, NULL, flags, pcli);
}
-NTSTATUS net_make_ipc_connection_ex(const char *domain, const char *server,
- struct sockaddr_storage *pss, unsigned flags,
- struct cli_state **pcli)
+NTSTATUS net_make_ipc_connection_ex(struct net_context *c ,const char *domain,
+ const char *server,
+ struct sockaddr_storage *pss,
+ unsigned flags, struct cli_state **pcli)
{
char *server_name = NULL;
struct sockaddr_storage server_ss;
@@ -545,7 +525,8 @@ NTSTATUS net_make_ipc_connection_ex(const char *domain, const char *server,
NTSTATUS nt_status;
if ( !server || !pss ) {
- if (!net_find_server(domain, flags, &server_ss, &server_name)) {
+ if (!net_find_server(c, domain, flags, &server_ss,
+ &server_name)) {
d_fprintf(stderr, "Unable to find a suitable server\n");
nt_status = NT_STATUS_UNSUCCESSFUL;
goto done;
@@ -556,9 +537,11 @@ NTSTATUS net_make_ipc_connection_ex(const char *domain, const char *server,
}
if (flags & NET_FLAGS_ANONYMOUS) {
- nt_status = connect_to_ipc_anonymous(&cli, &server_ss, server_name);
+ nt_status = connect_to_ipc_anonymous(c, &cli, &server_ss,
+ server_name);
} else {
- nt_status = connect_to_ipc(&cli, &server_ss, server_name);
+ nt_status = connect_to_ipc(c, &cli, &server_ss,
+ server_name);
}
/* store the server in the affinity cache if it was a PDC */
@@ -580,46 +563,46 @@ done:
return nt_status;
}
-static int net_user(int argc, const char **argv)
+static int net_user(struct net_context *c, int argc, const char **argv)
{
- if (net_ads_check() == 0)
- return net_ads_user(argc, argv);
+ if (net_ads_check(c) == 0)
+ return net_ads_user(c, argc, argv);
/* if server is not specified, default to PDC? */
- if (net_rpc_check(NET_FLAGS_PDC))
- return net_rpc_user(argc, argv);
+ if (net_rpc_check(c, NET_FLAGS_PDC))
+ return net_rpc_user(c, argc, argv);
- return net_rap_user(argc, argv);
+ return net_rap_user(c, argc, argv);
}
-static int net_group(int argc, const char **argv)
+static int net_group(struct net_context *c, int argc, const char **argv)
{
- if (net_ads_check() == 0)
- return net_ads_group(argc, argv);
+ if (net_ads_check(c) == 0)
+ return net_ads_group(c, argc, argv);
- if (argc == 0 && net_rpc_check(NET_FLAGS_PDC))
- return net_rpc_group(argc, argv);
+ if (argc == 0 && net_rpc_check(c, NET_FLAGS_PDC))
+ return net_rpc_group(c,argc, argv);
- return net_rap_group(argc, argv);
+ return net_rap_group(c, argc, argv);
}
-static int net_join(int argc, const char **argv)
+static int net_join(struct net_context *c, int argc, const char **argv)
{
- if (net_ads_check_our_domain() == 0) {
- if (net_ads_join(argc, argv) == 0)
+ if (net_ads_check_our_domain(c) == 0) {
+ if (net_ads_join(c, argc, argv) == 0)
return 0;
else
d_fprintf(stderr, "ADS join did not work, falling back to RPC...\n");
}
- return net_rpc_join(argc, argv);
+ return net_rpc_join(c, argc, argv);
}
-static int net_changetrustpw(int argc, const char **argv)
+static int net_changetrustpw(struct net_context *c, int argc, const char **argv)
{
- if (net_ads_check_our_domain() == 0)
- return net_ads_changetrustpw(argc, argv);
+ if (net_ads_check_our_domain(c) == 0)
+ return net_ads_changetrustpw(c, argc, argv);
- return net_rpc_changetrustpw(argc, argv);
+ return net_rpc_changetrustpw(c, argc, argv);
}
static void set_line_buffering(FILE *f)
@@ -627,19 +610,20 @@ static void set_line_buffering(FILE *f)
setvbuf(f, NULL, _IOLBF, 0);
}
-static int net_changesecretpw(int argc, const char **argv)
+static int net_changesecretpw(struct net_context *c, int argc,
+ const char **argv)
{
char *trust_pw;
uint32 sec_channel_type = SEC_CHAN_WKSTA;
- if(opt_force) {
- if (opt_stdin) {
+ if(c->opt_force) {
+ if (c->opt_stdin) {
set_line_buffering(stdin);
set_line_buffering(stdout);
set_line_buffering(stderr);
}
- trust_pw = get_pass("Enter machine password: ", opt_stdin);
+ trust_pw = get_pass("Enter machine password: ", c->opt_stdin);
if (!secrets_store_machine_password(trust_pw, lp_workgroup(), sec_channel_type)) {
d_fprintf(stderr, "Unable to write the machine account password in the secrets database");
@@ -658,24 +642,24 @@ static int net_changesecretpw(int argc, const char **argv)
return 0;
}
-static int net_share(int argc, const char **argv)
+static int net_share(struct net_context *c, int argc, const char **argv)
{
- if (net_rpc_check(0))
- return net_rpc_share(argc, argv);
- return net_rap_share(argc, argv);
+ if (net_rpc_check(c, 0))
+ return net_rpc_share(c, argc, argv);
+ return net_rap_share(c, argc, argv);
}
-static int net_file(int argc, const char **argv)
+static int net_file(struct net_context *c, int argc, const char **argv)
{
- if (net_rpc_check(0))
- return net_rpc_file(argc, argv);
- return net_rap_file(argc, argv);
+ if (net_rpc_check(c, 0))
+ return net_rpc_file(c, argc, argv);
+ return net_rap_file(c, argc, argv);
}
/*
Retrieve our local SID or the SID for the specified name
*/
-static int net_getlocalsid(int argc, const char **argv)
+static int net_getlocalsid(struct net_context *c, int argc, const char **argv)
{
DOM_SID sid;
const char *name;
@@ -713,7 +697,7 @@ static int net_getlocalsid(int argc, const char **argv)
return 0;
}
-static int net_setlocalsid(int argc, const char **argv)
+static int net_setlocalsid(struct net_context *c, int argc, const char **argv)
{
DOM_SID sid;
@@ -733,7 +717,7 @@ static int net_setlocalsid(int argc, const char **argv)
return 0;
}
-static int net_setdomainsid(int argc, const char **argv)
+static int net_setdomainsid(struct net_context *c, int argc, const char **argv)
{
DOM_SID sid;
@@ -753,7 +737,7 @@ static int net_setdomainsid(int argc, const char **argv)
return 0;
}
-static int net_getdomainsid(int argc, const char **argv)
+static int net_getdomainsid(struct net_context *c, int argc, const char **argv)
{
DOM_SID domain_sid;
fstring sid_str;
@@ -789,20 +773,20 @@ static int net_getdomainsid(int argc, const char **argv)
sid_to_fstring(sid_str, &domain_sid);
d_printf("SID for local machine %s is: %s\n", global_myname(), sid_str);
- if (!secrets_fetch_domain_sid(opt_workgroup, &domain_sid)) {
+ if (!secrets_fetch_domain_sid(c->opt_workgroup, &domain_sid)) {
d_fprintf(stderr, "Could not fetch domain SID\n");
return 1;
}
sid_to_fstring(sid_str, &domain_sid);
- d_printf("SID for domain %s is: %s\n", opt_workgroup, sid_str);
+ d_printf("SID for domain %s is: %s\n", c->opt_workgroup, sid_str);
return 0;
}
#ifdef WITH_FAKE_KASERVER
-int net_help_afs(int argc, const char **argv)
+int net_help_afs(struct net_context *c, int argc, const char **argv)
{
d_printf(" net afs key filename\n"
"\tImports a OpenAFS KeyFile into our secrets.tdb\n\n");
@@ -811,7 +795,7 @@ int net_help_afs(int argc, const char **argv)
return -1;
}
-static int net_afs_key(int argc, const char **argv)
+static int net_afs_key(struct net_context *c, int argc, const char **argv)
{
int fd;
struct afs_keyfile keyfile;
@@ -844,7 +828,8 @@ static int net_afs_key(int argc, const char **argv)
return 0;
}
-static int net_afs_impersonate(int argc, const char **argv)
+static int net_afs_impersonate(struct net_context *c, int argc,
+ const char **argv)
{
char *token;
@@ -869,7 +854,7 @@ static int net_afs_impersonate(int argc, const char **argv)
return 0;
}
-static int net_afs(int argc, const char **argv)
+static int net_afs(struct net_context *c, int argc, const char **argv)
{
struct functable func[] = {
{"key", net_afs_key},
@@ -877,7 +862,7 @@ static int net_afs(int argc, const char **argv)
{"help", net_help_afs},
{NULL, NULL}
};
- return net_run_function(argc, argv, func, net_help_afs);
+ return net_run_function(c, argc, argv, func, net_help_afs);
}
#endif /* WITH_FAKE_KASERVER */
@@ -917,7 +902,7 @@ static uint32 get_maxrid(void)
return max_rid;
}
-static int net_maxrid(int argc, const char **argv)
+static int net_maxrid(struct net_context *c, int argc, const char **argv)
{
uint32 rid;
@@ -939,16 +924,16 @@ static int net_maxrid(int argc, const char **argv)
/****************************************************************************
****************************************************************************/
-const char *net_prompt_pass(const char *user)
+const char *net_prompt_pass(struct net_context *c, const char *user)
{
char *prompt = NULL;
const char *pass = NULL;
- if (opt_password) {
- return opt_password;
+ if (c->opt_password) {
+ return c->opt_password;
}
- if (opt_machine_pass) {
+ if (c->opt_machine_pass) {
return NULL;
}
@@ -1023,49 +1008,50 @@ static struct functable net_func[] = {
int argc_new = 0;
const char ** argv_new;
poptContext pc;
+ TALLOC_CTX *frame = talloc_stackframe();
+ struct net_context *c = talloc_zero(frame, struct net_context);
struct poptOption long_options[] = {
{"help", 'h', POPT_ARG_NONE, 0, 'h'},
- {"workgroup", 'w', POPT_ARG_STRING, &opt_target_workgroup},
- {"user", 'U', POPT_ARG_STRING, &opt_user_name, 'U'},
+ {"workgroup", 'w', POPT_ARG_STRING, &c->opt_target_workgroup},
+ {"user", 'U', POPT_ARG_STRING, &c->opt_user_name, 'U'},
{"ipaddress", 'I', POPT_ARG_STRING, 0,'I'},
- {"port", 'p', POPT_ARG_INT, &opt_port},
- {"myname", 'n', POPT_ARG_STRING, &opt_requester_name},
- {"server", 'S', POPT_ARG_STRING, &opt_host},
+ {"port", 'p', POPT_ARG_INT, &c->opt_port},
+ {"myname", 'n', POPT_ARG_STRING, &c->opt_requester_name},
+ {"server", 'S', POPT_ARG_STRING, &c->opt_host},
{"encrypt", 'e', POPT_ARG_NONE, NULL, 'e', "Encrypt SMB transport (UNIX extended servers only)" },
- {"container", 'c', POPT_ARG_STRING, &opt_container},
- {"comment", 'C', POPT_ARG_STRING, &opt_comment},
- {"maxusers", 'M', POPT_ARG_INT, &opt_maxusers},
- {"flags", 'F', POPT_ARG_INT, &opt_flags},
- {"long", 'l', POPT_ARG_NONE, &opt_long_list_entries},
- {"reboot", 'r', POPT_ARG_NONE, &opt_reboot},
- {"force", 'f', POPT_ARG_NONE, &opt_force},
- {"stdin", 'i', POPT_ARG_NONE, &opt_stdin},
- {"timeout", 't', POPT_ARG_INT, &opt_timeout},
- {"machine-pass",'P', POPT_ARG_NONE, &opt_machine_pass},
- {"myworkgroup", 'W', POPT_ARG_STRING, &opt_workgroup},
- {"verbose", 'v', POPT_ARG_NONE, &opt_verbose},
- {"test", 'T', POPT_ARG_NONE, &opt_testmode},
+ {"container", 'c', POPT_ARG_STRING, &c->opt_container},
+ {"comment", 'C', POPT_ARG_STRING, &c->opt_comment},
+ {"maxusers", 'M', POPT_ARG_INT, &c->opt_maxusers},
+ {"flags", 'F', POPT_ARG_INT, &c->opt_flags},
+ {"long", 'l', POPT_ARG_NONE, &c->opt_long_list_entries},
+ {"reboot", 'r', POPT_ARG_NONE, &c->opt_reboot},
+ {"force", 'f', POPT_ARG_NONE, &c->opt_force},
+ {"stdin", 'i', POPT_ARG_NONE, &c->opt_stdin},
+ {"timeout", 't', POPT_ARG_INT, &c->opt_timeout},
+ {"machine-pass",'P', POPT_ARG_NONE, &c->opt_machine_pass},
+ {"myworkgroup", 'W', POPT_ARG_STRING, &c->opt_workgroup},
+ {"verbose", 'v', POPT_ARG_NONE, &c->opt_verbose},
+ {"test", 'T', POPT_ARG_NONE, &c->opt_testmode},
/* Options for 'net groupmap set' */
- {"local", 'L', POPT_ARG_NONE, &opt_localgroup},
- {"domain", 'D', POPT_ARG_NONE, &opt_domaingroup},
- {"ntname", 'N', POPT_ARG_STRING, &opt_newntname},
- {"rid", 'R', POPT_ARG_INT, &opt_rid},
+ {"local", 'L', POPT_ARG_NONE, &c->opt_localgroup},
+ {"domain", 'D', POPT_ARG_NONE, &c->opt_domaingroup},
+ {"ntname", 'N', POPT_ARG_STRING, &c->opt_newntname},
+ {"rid", 'R', POPT_ARG_INT, &c->opt_rid},
/* Options for 'net rpc share migrate' */
- {"acls", 0, POPT_ARG_NONE, &opt_acls},
- {"attrs", 0, POPT_ARG_NONE, &opt_attrs},
- {"timestamps", 0, POPT_ARG_NONE, &opt_timestamps},
- {"exclude", 'X', POPT_ARG_STRING, &opt_exclude},
- {"destination", 0, POPT_ARG_STRING, &opt_destination},
- {"tallocreport", 0, POPT_ARG_NONE, &do_talloc_report},
+ {"acls", 0, POPT_ARG_NONE, &c->opt_acls},
+ {"attrs", 0, POPT_ARG_NONE, &c->opt_attrs},
+ {"timestamps", 0, POPT_ARG_NONE, &c->opt_timestamps},
+ {"exclude", 'X', POPT_ARG_STRING, &c->opt_exclude},
+ {"destination", 0, POPT_ARG_STRING, &c->opt_destination},
+ {"tallocreport", 0, POPT_ARG_NONE, &c->do_talloc_report},
POPT_COMMON_SAMBA
{ 0, 0, 0, 0}
};
- TALLOC_CTX *frame = talloc_stackframe();
- zero_addr(&opt_dest_ip);
+ zero_addr(&c->opt_dest_ip);
load_case_tables();
@@ -1079,33 +1065,33 @@ static struct functable net_func[] = {
while((opt = poptGetNextOpt(pc)) != -1) {
switch (opt) {
case 'h':
- net_help(argc, argv);
+ net_help(c, argc, argv);
exit(0);
break;
case 'e':
- smb_encrypt=true;
+ c->smb_encrypt = true;
break;
case 'I':
- if (!interpret_string_addr(&opt_dest_ip,
+ if (!interpret_string_addr(&c->opt_dest_ip,
poptGetOptArg(pc), 0)) {
d_fprintf(stderr, "\nInvalid ip address specified\n");
} else {
- opt_have_ip = True;
+ c->opt_have_ip = true;
}
break;
case 'U':
- opt_user_specified = True;
- opt_user_name = SMB_STRDUP(opt_user_name);
- p = strchr(opt_user_name,'%');
+ c->opt_user_specified = True;
+ c->opt_user_name = SMB_STRDUP(c->opt_user_name);
+ p = strchr(c->opt_user_name,'%');
if (p) {
*p = 0;
- opt_password = p+1;
+ c->opt_password = p+1;
}
break;
default:
d_fprintf(stderr, "\nInvalid option %s: %s\n",
poptBadOption(pc, 0), poptStrerror(opt));
- net_help(argc, argv);
+ net_help(c, argc, argv);
exit(1);
}
}
@@ -1114,8 +1100,8 @@ static struct functable net_func[] = {
* Don't load debug level from smb.conf. It should be
* set by cmdline arg or remain default (0)
*/
- AllowDebugChange = False;
- lp_load(get_dyn_CONFIGFILE(),True,False,False,True);
+ c->AllowDebugChange = false;
+ lp_load(get_dyn_CONFIGFILE(), true, false, false, true);
argv_new = (const char **)poptGetArgs(pc);
@@ -1127,24 +1113,24 @@ static struct functable net_func[] = {
}
}
- if (do_talloc_report) {
+ if (c->do_talloc_report) {
talloc_enable_leak_report();
}
- if (opt_requester_name) {
- set_global_myname(opt_requester_name);
+ if (c->opt_requester_name) {
+ set_global_myname(c->opt_requester_name);
}
- if (!opt_user_name && getenv("LOGNAME")) {
- opt_user_name = getenv("LOGNAME");
+ if (!c->opt_user_name && getenv("LOGNAME")) {
+ c->opt_user_name = getenv("LOGNAME");
}
- if (!opt_workgroup) {
- opt_workgroup = smb_xstrdup(lp_workgroup());
+ if (!c->opt_workgroup) {
+ c->opt_workgroup = smb_xstrdup(lp_workgroup());
}
- if (!opt_target_workgroup) {
- opt_target_workgroup = smb_xstrdup(lp_workgroup());
+ if (!c->opt_target_workgroup) {
+ c->opt_target_workgroup = smb_xstrdup(lp_workgroup());
}
if (!init_names())
@@ -1156,22 +1142,22 @@ static struct functable net_func[] = {
that it won't assert becouse we are not root */
sec_init();
- if (opt_machine_pass) {
+ if (c->opt_machine_pass) {
/* it is very useful to be able to make ads queries as the
machine account for testing purposes and for domain leave */
- net_use_krb_machine_account();
+ net_use_krb_machine_account(c);
}
- if (!opt_password) {
- opt_password = getenv("PASSWD");
+ if (!c->opt_password) {
+ c->opt_password = getenv("PASSWD");
}
- rc = net_run_function(argc_new-1, argv_new+1, net_func, net_help);
+ rc = net_run_function(c, argc_new-1, argv_new+1, net_func, net_help);
DEBUG(2,("return code = %d\n", rc));
- libnetapi_free(netapi_ctx);
+ libnetapi_free(c->netapi_ctx);
TALLOC_FREE(frame);
return rc;
diff --git a/source3/utils/net.h b/source3/utils/net.h
index 4f390bb128b..15b1dd402b0 100644
--- a/source3/utils/net.h
+++ b/source3/utils/net.h
@@ -24,7 +24,8 @@
#include "lib/netapi/netapi.h"
-typedef NTSTATUS (*rpc_command_fn)(const DOM_SID *,
+typedef NTSTATUS (*rpc_command_fn)(struct net_context *c,
+ const DOM_SID *,
const char *,
struct cli_state *cli,
struct rpc_pipe_client *,
@@ -38,6 +39,7 @@ typedef struct copy_clistate {
struct cli_state *cli_share_dst;
char *cwd;
uint16 attribute;
+ struct net_context *c;
}copy_clistate;
struct rpc_sh_ctx {
@@ -54,10 +56,12 @@ struct rpc_sh_ctx {
struct rpc_sh_cmd {
const char *name;
- struct rpc_sh_cmd *(*sub)(TALLOC_CTX *mem_ctx,
+ struct rpc_sh_cmd *(*sub)(struct net_context *c,
+ TALLOC_CTX *mem_ctx,
struct rpc_sh_ctx *ctx);
int pipe_idx;
- NTSTATUS (*fn)(TALLOC_CTX *mem_ctx, struct rpc_sh_ctx *ctx,
+ NTSTATUS (*fn)(struct net_context *c, TALLOC_CTX *mem_ctx,
+ struct rpc_sh_ctx *ctx,
struct rpc_pipe_client *pipe_hnd,
int argc, const char **argv);
const char *help;
@@ -65,6 +69,47 @@ struct rpc_sh_cmd {
enum netdom_domain_t { ND_TYPE_NT4, ND_TYPE_AD };
+struct net_context {
+ const char *opt_requester_name;
+ const char *opt_host;
+ const char *opt_password;
+ const char *opt_user_name;
+ bool opt_user_specified;
+ const char *opt_workgroup;
+ int opt_long_list_entries;
+ int opt_reboot;
+ int opt_force;
+ int opt_stdin;
+ int opt_port;
+ int opt_verbose;
+ int opt_maxusers;
+ const char *opt_comment;
+ const char *opt_container;
+ int opt_flags;
+ int opt_timeout;
+ const char *opt_target_workgroup;
+ int opt_machine_pass;
+ int opt_localgroup;
+ int opt_domaingroup;
+ int do_talloc_report;
+ const char *opt_newntname;
+ int opt_rid;
+ int opt_acls;
+ int opt_attrs;
+ int opt_timestamps;
+ const char *opt_exclude;
+ const char *opt_destination;
+ int opt_testmode;
+
+ int opt_have_ip;
+ struct sockaddr_storage opt_dest_ip;
+ bool smb_encrypt;
+ struct libnetapi_ctx *netapi_ctx;
+
+ bool AllowDebugChange;
+ const char *share_type[];
+};
+
/* INCLUDE FILES */
#include "utils/net_proto.h"
@@ -84,43 +129,6 @@ enum netdom_domain_t { ND_TYPE_NT4, ND_TYPE_AD };
/* net share operation modes */
#define NET_MODE_SHARE_MIGRATE 1
-extern int opt_maxusers;
-extern const char *opt_comment;
-extern const char *opt_container;
-extern int opt_flags;
-
-extern const char *opt_comment;
-
-extern const char *opt_target_workgroup;
-extern const char *opt_workgroup;
-extern int opt_long_list_entries;
-extern int opt_verbose;
-extern int opt_reboot;
-extern int opt_force;
-extern int opt_machine_pass;
-extern int opt_timeout;
-extern const char *opt_host;
-extern const char *opt_user_name;
-extern const char *opt_password;
-extern bool opt_user_specified;
-
-extern int opt_localgroup;
-extern int opt_domaingroup;
-extern const char *opt_newntname;
-extern int opt_rid;
-extern int opt_acls;
-extern int opt_attrs;
-extern int opt_timestamps;
-extern const char *opt_exclude;
-extern const char *opt_destination;
-extern int opt_testmode;
-
-extern int opt_have_ip;
-extern struct sockaddr_storage opt_dest_ip;
-extern struct libnetapi_ctx *netapi_ctx;
-
-extern const char *share_type[];
-
/* Structure for mapping accounts to groups */
/* Array element is the group rid */
typedef struct _groupmap {
diff --git a/source3/utils/net_ads.c b/source3/utils/net_ads.c
index bf348801776..5b84eb55226 100644
--- a/source3/utils/net_ads.c
+++ b/source3/utils/net_ads.c
@@ -27,7 +27,7 @@
#ifdef HAVE_ADS
-int net_ads_usage(int argc, const char **argv)
+int net_ads_usage(struct net_context *c, int argc, const char **argv)
{
d_printf("join [createupn[=principal]] [createcomputer=<org_unit>]\n");
d_printf(" Join the local machine to a ADS realm\n");
@@ -66,9 +66,9 @@ int net_ads_usage(int argc, const char **argv)
/* when we do not have sufficient input parameters to contact a remote domain
* we always fall back to our own realm - Guenther*/
-static const char *assume_own_realm(void)
+static const char *assume_own_realm(struct net_context *c)
{
- if (!opt_host && strequal(lp_workgroup(), opt_target_workgroup)) {
+ if (!c->opt_host && strequal(lp_workgroup(), c->opt_target_workgroup)) {
return lp_realm();
}
@@ -78,7 +78,7 @@ static const char *assume_own_realm(void)
/*
do a cldap netlogon query
*/
-static int net_ads_cldap_netlogon(ADS_STRUCT *ads)
+static int net_ads_cldap_netlogon(struct net_context *c, ADS_STRUCT *ads)
{
char addr[INET6_ADDRSTRLEN];
struct nbt_cldap_netlogon_5 reply;
@@ -152,31 +152,31 @@ static int net_ads_cldap_netlogon(ADS_STRUCT *ads)
this implements the CLDAP based netlogon lookup requests
for finding the domain controller of a ADS domain
*/
-static int net_ads_lookup(int argc, const char **argv)
+static int net_ads_lookup(struct net_context *c, int argc, const char **argv)
{
ADS_STRUCT *ads;
- if (!ADS_ERR_OK(ads_startup_nobind(False, &ads))) {
+ if (!ADS_ERR_OK(ads_startup_nobind(c, false, &ads))) {
d_fprintf(stderr, "Didn't find the cldap server!\n");
return -1;
}
if (!ads->config.realm) {
- ads->config.realm = CONST_DISCARD(char *, opt_target_workgroup);
+ ads->config.realm = CONST_DISCARD(char *, c->opt_target_workgroup);
ads->ldap.port = 389;
}
- return net_ads_cldap_netlogon(ads);
+ return net_ads_cldap_netlogon(c, ads);
}
-static int net_ads_info(int argc, const char **argv)
+static int net_ads_info(struct net_context *c, int argc, const char **argv)
{
ADS_STRUCT *ads;
char addr[INET6_ADDRSTRLEN];
- if (!ADS_ERR_OK(ads_startup_nobind(False, &ads))) {
+ if (!ADS_ERR_OK(ads_startup_nobind(c, false, &ads))) {
d_fprintf(stderr, "Didn't find the ldap server!\n");
return -1;
}
@@ -214,7 +214,8 @@ static void use_in_memory_ccache(void) {
setenv(KRB5_ENV_CCNAME, "MEMORY:net_ads", 1);
}
-static ADS_STATUS ads_startup_int(bool only_own_domain, uint32 auth_flags, ADS_STRUCT **ads_ret)
+static ADS_STATUS ads_startup_int(struct net_context *c, bool only_own_domain,
+ uint32 auth_flags, ADS_STRUCT **ads_ret)
{
ADS_STRUCT *ads = NULL;
ADS_STATUS status;
@@ -235,37 +236,37 @@ retry_connect:
if (only_own_domain) {
realm = lp_realm();
} else {
- realm = assume_own_realm();
+ realm = assume_own_realm(c);
}
- ads = ads_init(realm, opt_target_workgroup, opt_host);
+ ads = ads_init(realm, c->opt_target_workgroup, c->opt_host);
- if (!opt_user_name) {
- opt_user_name = "administrator";
+ if (!c->opt_user_name) {
+ c->opt_user_name = "administrator";
}
- if (opt_user_specified) {
+ if (c->opt_user_specified) {
need_password = True;
}
retry:
- if (!opt_password && need_password && !opt_machine_pass) {
- opt_password = net_prompt_pass(opt_user_name);
- if (!opt_password) {
+ if (!c->opt_password && need_password && !c->opt_machine_pass) {
+ c->opt_password = net_prompt_pass(c, c->opt_user_name);
+ if (!c->opt_password) {
ads_destroy(&ads);
return ADS_ERROR(LDAP_NO_MEMORY);
}
}
- if (opt_password) {
+ if (c->opt_password) {
use_in_memory_ccache();
SAFE_FREE(ads->auth.password);
- ads->auth.password = smb_xstrdup(opt_password);
+ ads->auth.password = smb_xstrdup(c->opt_password);
}
ads->auth.flags |= auth_flags;
SAFE_FREE(ads->auth.user_name);
- ads->auth.user_name = smb_xstrdup(opt_user_name);
+ ads->auth.user_name = smb_xstrdup(c->opt_user_name);
/*
* If the username is of the form "name@realm",
@@ -304,7 +305,7 @@ retry:
* This is done by reconnecting to ADS because only the first call to
* ads_connect will give us our own sitename */
- if ((only_own_domain || !opt_host) && !tried_closest_dc) {
+ if ((only_own_domain || !c->opt_host) && !tried_closest_dc) {
tried_closest_dc = True; /* avoid loop */
@@ -324,14 +325,14 @@ retry:
return status;
}
-ADS_STATUS ads_startup(bool only_own_domain, ADS_STRUCT **ads)
+ADS_STATUS ads_startup(struct net_context *c, bool only_own_domain, ADS_STRUCT **ads)
{
- return ads_startup_int(only_own_domain, 0, ads);
+ return ads_startup_int(c, only_own_domain, 0, ads);
}
-ADS_STATUS ads_startup_nobind(bool only_own_domain, ADS_STRUCT **ads)
+ADS_STATUS ads_startup_nobind(struct net_context *c, bool only_own_domain, ADS_STRUCT **ads)
{
- return ads_startup_int(only_own_domain, ADS_AUTH_NO_BIND, ads);
+ return ads_startup_int(c, only_own_domain, ADS_AUTH_NO_BIND, ads);
}
/*
@@ -359,32 +360,32 @@ static int net_ads_check_int(const char *realm, const char *workgroup, const cha
return 0;
}
-int net_ads_check_our_domain(void)
+int net_ads_check_our_domain(struct net_context *c)
{
return net_ads_check_int(lp_realm(), lp_workgroup(), NULL);
}
-int net_ads_check(void)
+int net_ads_check(struct net_context *c)
{
- return net_ads_check_int(NULL, opt_workgroup, opt_host);
+ return net_ads_check_int(NULL, c->opt_workgroup, c->opt_host);
}
/*
determine the netbios workgroup name for a domain
*/
-static int net_ads_workgroup(int argc, const char **argv)
+static int net_ads_workgroup(struct net_context *c, int argc, const char **argv)
{
ADS_STRUCT *ads;
char addr[INET6_ADDRSTRLEN];
struct nbt_cldap_netlogon_5 reply;
- if (!ADS_ERR_OK(ads_startup_nobind(False, &ads))) {
+ if (!ADS_ERR_OK(ads_startup_nobind(c, false, &ads))) {
d_fprintf(stderr, "Didn't find the cldap server!\n");
return -1;
}
if (!ads->config.realm) {
- ads->config.realm = CONST_DISCARD(char *, opt_target_workgroup);
+ ads->config.realm = CONST_DISCARD(char *, c->opt_target_workgroup);
ads->ldap.port = 389;
}
@@ -431,12 +432,12 @@ static bool usergrp_display(ADS_STRUCT *ads, char *field, void **values, void *d
return True;
}
-static int net_ads_user_usage(int argc, const char **argv)
+static int net_ads_user_usage(struct net_context *c, int argc, const char **argv)
{
- return net_help_user(argc, argv);
+ return net_help_user(c, argc, argv);
}
-static int ads_user_add(int argc, const char **argv)
+static int ads_user_add(struct net_context *c, int argc, const char **argv)
{
ADS_STRUCT *ads;
ADS_STATUS status;
@@ -445,9 +446,9 @@ static int ads_user_add(int argc, const char **argv)
int rc = -1;
char *ou_str = NULL;
- if (argc < 1) return net_ads_user_usage(argc, argv);
+ if (argc < 1) return net_ads_user_usage(c, argc, argv);
- if (!ADS_ERR_OK(ads_startup(False, &ads))) {
+ if (!ADS_ERR_OK(ads_startup(c, false, &ads))) {
return -1;
}
@@ -463,13 +464,13 @@ static int ads_user_add(int argc, const char **argv)
goto done;
}
- if (opt_container) {
- ou_str = SMB_STRDUP(opt_container);
+ if (c->opt_container) {
+ ou_str = SMB_STRDUP(c->opt_container);
} else {
ou_str = ads_default_ou_string(ads, WELL_KNOWN_GUID_USERS);
}
- status = ads_add_user_acct(ads, argv[0], ou_str, opt_comment);
+ status = ads_add_user_acct(ads, argv[0], ou_str, c->opt_comment);
if (!ADS_ERR_OK(status)) {
d_fprintf(stderr, "Could not add user %s: %s\n", argv[0],
@@ -514,7 +515,7 @@ static int ads_user_add(int argc, const char **argv)
return rc;
}
-static int ads_user_info(int argc, const char **argv)
+static int ads_user_info(struct net_context *c, int argc, const char **argv)
{
ADS_STRUCT *ads;
ADS_STATUS rc;
@@ -525,7 +526,7 @@ static int ads_user_info(int argc, const char **argv)
char *escaped_user;
if (argc < 1) {
- return net_ads_user_usage(argc, argv);
+ return net_ads_user_usage(c, argc, argv);
}
escaped_user = escape_ldap_string_alloc(argv[0]);
@@ -535,7 +536,7 @@ static int ads_user_info(int argc, const char **argv)
return -1;
}
- if (!ADS_ERR_OK(ads_startup(False, &ads))) {
+ if (!ADS_ERR_OK(ads_startup(c, false, &ads))) {
SAFE_FREE(escaped_user);
return -1;
}
@@ -571,7 +572,7 @@ static int ads_user_info(int argc, const char **argv)
return 0;
}
-static int ads_user_delete(int argc, const char **argv)
+static int ads_user_delete(struct net_context *c, int argc, const char **argv)
{
ADS_STRUCT *ads;
ADS_STATUS rc;
@@ -579,10 +580,10 @@ static int ads_user_delete(int argc, const char **argv)
char *userdn;
if (argc < 1) {
- return net_ads_user_usage(argc, argv);
+ return net_ads_user_usage(c, argc, argv);
}
- if (!ADS_ERR_OK(ads_startup(False, &ads))) {
+ if (!ADS_ERR_OK(ads_startup(c, false, &ads))) {
return -1;
}
@@ -608,7 +609,7 @@ static int ads_user_delete(int argc, const char **argv)
return -1;
}
-int net_ads_user(int argc, const char **argv)
+int net_ads_user(struct net_context *c, int argc, const char **argv)
{
struct functable func[] = {
{"ADD", ads_user_add},
@@ -623,33 +624,33 @@ int net_ads_user(int argc, const char **argv)
char *disp_fields[2] = {NULL, NULL};
if (argc == 0) {
- if (!ADS_ERR_OK(ads_startup(False, &ads))) {
+ if (!ADS_ERR_OK(ads_startup(c, false, &ads))) {
return -1;
}
- if (opt_long_list_entries)
+ if (c->opt_long_list_entries)
d_printf("\nUser name Comment"\
"\n-----------------------------\n");
rc = ads_do_search_all_fn(ads, ads->config.bind_path,
LDAP_SCOPE_SUBTREE,
"(objectCategory=user)",
- opt_long_list_entries ? longattrs :
+ c->opt_long_list_entries ? longattrs :
shortattrs, usergrp_display,
disp_fields);
ads_destroy(&ads);
return ADS_ERR_OK(rc) ? 0 : -1;
}
- return net_run_function(argc, argv, func, net_ads_user_usage);
+ return net_run_function(c, argc, argv, func, net_ads_user_usage);
}
-static int net_ads_group_usage(int argc, const char **argv)
+static int net_ads_group_usage(struct net_context *c, int argc, const char **argv)
{
- return net_help_group(argc, argv);
+ return net_help_group(c, argc, argv);
}
-static int ads_group_add(int argc, const char **argv)
+static int ads_group_add(struct net_context *c, int argc, const char **argv)
{
ADS_STRUCT *ads;
ADS_STATUS status;
@@ -658,10 +659,10 @@ static int ads_group_add(int argc, const char **argv)
char *ou_str = NULL;
if (argc < 1) {
- return net_ads_group_usage(argc, argv);
+ return net_ads_group_usage(c, argc, argv);
}
- if (!ADS_ERR_OK(ads_startup(False, &ads))) {
+ if (!ADS_ERR_OK(ads_startup(c, false, &ads))) {
return -1;
}
@@ -677,13 +678,13 @@ static int ads_group_add(int argc, const char **argv)
goto done;
}
- if (opt_container) {
- ou_str = SMB_STRDUP(opt_container);
+ if (c->opt_container) {
+ ou_str = SMB_STRDUP(c->opt_container);
} else {
ou_str = ads_default_ou_string(ads, WELL_KNOWN_GUID_USERS);
}
- status = ads_add_group_acct(ads, argv[0], ou_str, opt_comment);
+ status = ads_add_group_acct(ads, argv[0], ou_str, c->opt_comment);
if (ADS_ERR_OK(status)) {
d_printf("Group %s added\n", argv[0]);
@@ -701,7 +702,7 @@ static int ads_group_add(int argc, const char **argv)
return rc;
}
-static int ads_group_delete(int argc, const char **argv)
+static int ads_group_delete(struct net_context *c, int argc, const char **argv)
{
ADS_STRUCT *ads;
ADS_STATUS rc;
@@ -709,10 +710,10 @@ static int ads_group_delete(int argc, const char **argv)
char *groupdn;
if (argc < 1) {
- return net_ads_group_usage(argc, argv);
+ return net_ads_group_usage(c, argc, argv);
}
- if (!ADS_ERR_OK(ads_startup(False, &ads))) {
+ if (!ADS_ERR_OK(ads_startup(c, false, &ads))) {
return -1;
}
@@ -738,7 +739,7 @@ static int ads_group_delete(int argc, const char **argv)
return -1;
}
-int net_ads_group(int argc, const char **argv)
+int net_ads_group(struct net_context *c, int argc, const char **argv)
{
struct functable func[] = {
{"ADD", ads_group_add},
@@ -752,33 +753,33 @@ int net_ads_group(int argc, const char **argv)
char *disp_fields[2] = {NULL, NULL};
if (argc == 0) {
- if (!ADS_ERR_OK(ads_startup(False, &ads))) {
+ if (!ADS_ERR_OK(ads_startup(c, false, &ads))) {
return -1;
}
- if (opt_long_list_entries)
+ if (c->opt_long_list_entries)
d_printf("\nGroup name Comment"\
"\n-----------------------------\n");
rc = ads_do_search_all_fn(ads, ads->config.bind_path,
LDAP_SCOPE_SUBTREE,
"(objectCategory=group)",
- opt_long_list_entries ? longattrs :
+ c->opt_long_list_entries ? longattrs :
shortattrs, usergrp_display,
disp_fields);
ads_destroy(&ads);
return ADS_ERR_OK(rc) ? 0 : -1;
}
- return net_run_function(argc, argv, func, net_ads_group_usage);
+ return net_run_function(c, argc, argv, func, net_ads_group_usage);
}
-static int net_ads_status(int argc, const char **argv)
+static int net_ads_status(struct net_context *c, int argc, const char **argv)
{
ADS_STRUCT *ads;
ADS_STATUS rc;
LDAPMessage *res;
- if (!ADS_ERR_OK(ads_startup(True, &ads))) {
+ if (!ADS_ERR_OK(ads_startup(c, true, &ads))) {
return -1;
}
@@ -807,7 +808,7 @@ static int net_ads_status(int argc, const char **argv)
with full control to the computer object's ACL.
*******************************************************************/
-static int net_ads_leave(int argc, const char **argv)
+static int net_ads_leave(struct net_context *c, int argc, const char **argv)
{
TALLOC_CTX *ctx;
struct libnet_UnjoinCtx *r = NULL;
@@ -832,10 +833,10 @@ static int net_ads_leave(int argc, const char **argv)
}
r->in.debug = true;
- r->in.dc_name = opt_host;
+ r->in.dc_name = c->opt_host;
r->in.domain_name = lp_realm();
- r->in.admin_account = opt_user_name;
- r->in.admin_password = net_prompt_pass(opt_user_name);
+ r->in.admin_account = c->opt_user_name;
+ r->in.admin_password = net_prompt_pass(c, c->opt_user_name);
r->in.modify_config = lp_config_backend_is_registry();
r->in.unjoin_flags = WKSSVC_JOIN_FLAGS_JOIN_TYPE |
WKSSVC_JOIN_FLAGS_ACCOUNT_DELETE;
@@ -876,7 +877,7 @@ static int net_ads_leave(int argc, const char **argv)
return -1;
}
-static NTSTATUS net_ads_join_ok(void)
+static NTSTATUS net_ads_join_ok(struct net_context *c)
{
ADS_STRUCT *ads = NULL;
ADS_STATUS status;
@@ -886,9 +887,9 @@ static NTSTATUS net_ads_join_ok(void)
return NT_STATUS_ACCESS_DENIED;
}
- net_use_krb_machine_account();
+ net_use_krb_machine_account(c);
- status = ads_startup(True, &ads);
+ status = ads_startup(c, true, &ads);
if (!ADS_ERR_OK(status)) {
return ads_ntstatus(status);
}
@@ -900,13 +901,13 @@ static NTSTATUS net_ads_join_ok(void)
/*
check that an existing join is OK
*/
-int net_ads_testjoin(int argc, const char **argv)
+int net_ads_testjoin(struct net_context *c, int argc, const char **argv)
{
NTSTATUS status;
use_in_memory_ccache();
/* Display success or failure */
- status = net_ads_join_ok();
+ status = net_ads_join_ok(c);
if (!NT_STATUS_IS_OK(status)) {
fprintf(stderr,"Join to domain is not valid: %s\n",
get_friendly_nt_error_msg(status));
@@ -1074,7 +1075,7 @@ static NTSTATUS net_update_dns(TALLOC_CTX *mem_ctx, ADS_STRUCT *ads)
/*******************************************************************
********************************************************************/
-static int net_ads_join_usage(int argc, const char **argv)
+static int net_ads_join_usage(struct net_context *c, int argc, const char **argv)
{
d_printf("net ads join [options]\n");
d_printf("Valid options:\n");
@@ -1097,7 +1098,7 @@ static int net_ads_join_usage(int argc, const char **argv)
/*******************************************************************
********************************************************************/
-int net_ads_join(int argc, const char **argv)
+int net_ads_join(struct net_context *c, int argc, const char **argv)
{
TALLOC_CTX *ctx = NULL;
struct libnet_JoinCtx *r = NULL;
@@ -1180,9 +1181,9 @@ int net_ads_join(int argc, const char **argv)
r->in.account_ou = create_in_ou;
r->in.os_name = os_name;
r->in.os_version = os_version;
- r->in.dc_name = opt_host;
- r->in.admin_account = opt_user_name;
- r->in.admin_password = net_prompt_pass(opt_user_name);
+ r->in.dc_name = c->opt_host;
+ r->in.admin_account = c->opt_user_name;
+ r->in.admin_password = net_prompt_pass(c, c->opt_user_name);
r->in.debug = true;
r->in.modify_config = modify_config;
r->in.join_flags = WKSSVC_JOIN_FLAGS_JOIN_TYPE |
@@ -1256,7 +1257,7 @@ fail:
/*******************************************************************
********************************************************************/
-static int net_ads_dns_usage(int argc, const char **argv)
+static int net_ads_dns_usage(struct net_context *c, int argc, const char **argv)
{
#if defined(WITH_DNS_UPDATES)
d_printf("net ads dns <command>\n");
@@ -1273,7 +1274,7 @@ static int net_ads_dns_usage(int argc, const char **argv)
/*******************************************************************
********************************************************************/
-static int net_ads_dns_register(int argc, const char **argv)
+static int net_ads_dns_register(struct net_context *c, int argc, const char **argv)
{
#if defined(WITH_DNS_UPDATES)
ADS_STRUCT *ads;
@@ -1324,7 +1325,7 @@ static int net_ads_dns_register(int argc, const char **argv)
DNS_ERROR do_gethostbyname(const char *server, const char *host);
#endif
-static int net_ads_dns_gethostbyname(int argc, const char **argv)
+static int net_ads_dns_gethostbyname(struct net_context *c, int argc, const char **argv)
{
#if defined(WITH_DNS_UPDATES)
DNS_ERROR err;
@@ -1346,7 +1347,7 @@ static int net_ads_dns_gethostbyname(int argc, const char **argv)
return 0;
}
-static int net_ads_dns(int argc, const char *argv[])
+static int net_ads_dns(struct net_context *c, int argc, const char *argv[])
{
struct functable func[] = {
{"REGISTER", net_ads_dns_register},
@@ -1354,13 +1355,13 @@ static int net_ads_dns(int argc, const char *argv[])
{NULL, NULL}
};
- return net_run_function(argc, argv, func, net_ads_dns_usage);
+ return net_run_function(c, argc, argv, func, net_ads_dns_usage);
}
/*******************************************************************
********************************************************************/
-int net_ads_printer_usage(int argc, const char **argv)
+int net_ads_printer_usage(struct net_context *c, int argc, const char **argv)
{
d_printf(
"\nnet ads printer search <printer>"
@@ -1380,13 +1381,13 @@ int net_ads_printer_usage(int argc, const char **argv)
/*******************************************************************
********************************************************************/
-static int net_ads_printer_search(int argc, const char **argv)
+static int net_ads_printer_search(struct net_context *c, int argc, const char **argv)
{
ADS_STRUCT *ads;
ADS_STATUS rc;
LDAPMessage *res = NULL;
- if (!ADS_ERR_OK(ads_startup(False, &ads))) {
+ if (!ADS_ERR_OK(ads_startup(c, false, &ads))) {
return -1;
}
@@ -1412,14 +1413,14 @@ static int net_ads_printer_search(int argc, const char **argv)
return 0;
}
-static int net_ads_printer_info(int argc, const char **argv)
+static int net_ads_printer_info(struct net_context *c, int argc, const char **argv)
{
ADS_STRUCT *ads;
ADS_STATUS rc;
const char *servername, *printername;
LDAPMessage *res = NULL;
- if (!ADS_ERR_OK(ads_startup(False, &ads))) {
+ if (!ADS_ERR_OK(ads_startup(c, false, &ads))) {
return -1;
}
@@ -1459,7 +1460,7 @@ static int net_ads_printer_info(int argc, const char **argv)
return 0;
}
-static int net_ads_printer_publish(int argc, const char **argv)
+static int net_ads_printer_publish(struct net_context *c, int argc, const char **argv)
{
ADS_STRUCT *ads;
ADS_STATUS rc;
@@ -1474,14 +1475,14 @@ static int net_ads_printer_publish(int argc, const char **argv)
char *srv_cn_escaped = NULL, *printername_escaped = NULL;
LDAPMessage *res = NULL;
- if (!ADS_ERR_OK(ads_startup(True, &ads))) {
+ if (!ADS_ERR_OK(ads_startup(c, true, &ads))) {
talloc_destroy(mem_ctx);
return -1;
}
if (argc < 1) {
talloc_destroy(mem_ctx);
- return net_ads_printer_usage(argc, argv);
+ return net_ads_printer_usage(c, argc, argv);
}
printername = argv[0];
@@ -1499,8 +1500,8 @@ static int net_ads_printer_publish(int argc, const char **argv)
nt_status = cli_full_connection(&cli, global_myname(), servername,
&server_ss, 0,
"IPC$", "IPC",
- opt_user_name, opt_workgroup,
- opt_password ? opt_password : "",
+ c->opt_user_name, c->opt_workgroup,
+ c->opt_password ? c->opt_password : "",
CLI_FULL_CONNECTION_USE_KERBEROS,
Undefined, NULL);
@@ -1578,7 +1579,7 @@ static int net_ads_printer_publish(int argc, const char **argv)
return 0;
}
-static int net_ads_printer_remove(int argc, const char **argv)
+static int net_ads_printer_remove(struct net_context *c, int argc, const char **argv)
{
ADS_STRUCT *ads;
ADS_STATUS rc;
@@ -1586,12 +1587,12 @@ static int net_ads_printer_remove(int argc, const char **argv)
char *prt_dn;
LDAPMessage *res = NULL;
- if (!ADS_ERR_OK(ads_startup(True, &ads))) {
+ if (!ADS_ERR_OK(ads_startup(c, true, &ads))) {
return -1;
}
if (argc < 1) {
- return net_ads_printer_usage(argc, argv);
+ return net_ads_printer_usage(c, argc, argv);
}
if (argc > 1) {
@@ -1631,7 +1632,7 @@ static int net_ads_printer_remove(int argc, const char **argv)
return 0;
}
-static int net_ads_printer(int argc, const char **argv)
+static int net_ads_printer(struct net_context *c, int argc, const char **argv)
{
struct functable func[] = {
{"SEARCH", net_ads_printer_search},
@@ -1641,22 +1642,22 @@ static int net_ads_printer(int argc, const char **argv)
{NULL, NULL}
};
- return net_run_function(argc, argv, func, net_ads_printer_usage);
+ return net_run_function(c, argc, argv, func, net_ads_printer_usage);
}
-static int net_ads_password(int argc, const char **argv)
+static int net_ads_password(struct net_context *c, int argc, const char **argv)
{
ADS_STRUCT *ads;
- const char *auth_principal = opt_user_name;
- const char *auth_password = opt_password;
+ const char *auth_principal = c->opt_user_name;
+ const char *auth_password = c->opt_password;
char *realm = NULL;
char *new_password = NULL;
- char *c, *prompt;
+ char *chr, *prompt;
const char *user;
ADS_STATUS ret;
- if (opt_user_name == NULL || opt_password == NULL) {
+ if (c->opt_user_name == NULL || c->opt_password == NULL) {
d_fprintf(stderr, "You must supply an administrator username/password\n");
return -1;
}
@@ -1668,21 +1669,21 @@ static int net_ads_password(int argc, const char **argv)
user = argv[0];
if (!strchr_m(user, '@')) {
- asprintf(&c, "%s@%s", argv[0], lp_realm());
- user = c;
+ asprintf(&chr, "%s@%s", argv[0], lp_realm());
+ user = chr;
}
use_in_memory_ccache();
- c = strchr_m(auth_principal, '@');
- if (c) {
- realm = ++c;
+ chr = strchr_m(auth_principal, '@');
+ if (chr) {
+ realm = ++chr;
} else {
realm = lp_realm();
}
/* use the realm so we can eventually change passwords for users
in realms other than default */
- if (!(ads = ads_init(realm, opt_workgroup, opt_host))) {
+ if (!(ads = ads_init(realm, c->opt_workgroup, c->opt_host))) {
return -1;
}
@@ -1717,7 +1718,7 @@ static int net_ads_password(int argc, const char **argv)
return 0;
}
-int net_ads_changetrustpw(int argc, const char **argv)
+int net_ads_changetrustpw(struct net_context *c, int argc, const char **argv)
{
ADS_STRUCT *ads;
char *host_principal;
@@ -1729,11 +1730,11 @@ int net_ads_changetrustpw(int argc, const char **argv)
return -1;
}
- net_use_krb_machine_account();
+ net_use_krb_machine_account(c);
use_in_memory_ccache();
- if (!ADS_ERR_OK(ads_startup(True, &ads))) {
+ if (!ADS_ERR_OK(ads_startup(c, true, &ads))) {
return -1;
}
@@ -1769,7 +1770,7 @@ int net_ads_changetrustpw(int argc, const char **argv)
/*
help for net ads search
*/
-static int net_ads_search_usage(int argc, const char **argv)
+static int net_ads_search_usage(struct net_context *c, int argc, const char **argv)
{
d_printf(
"\nnet ads search <expression> <attributes...>\n"\
@@ -1778,7 +1779,7 @@ static int net_ads_search_usage(int argc, const char **argv)
"attributes are a list of LDAP fields to show in the results\n\n"\
"Example: net ads search '(objectCategory=group)' sAMAccountName\n\n"
);
- net_common_flags_usage(argc, argv);
+ net_common_flags_usage(c, argc, argv);
return -1;
}
@@ -1786,7 +1787,7 @@ static int net_ads_search_usage(int argc, const char **argv)
/*
general ADS search function. Useful in diagnosing problems in ADS
*/
-static int net_ads_search(int argc, const char **argv)
+static int net_ads_search(struct net_context *c, int argc, const char **argv)
{
ADS_STRUCT *ads;
ADS_STATUS rc;
@@ -1795,10 +1796,10 @@ static int net_ads_search(int argc, const char **argv)
LDAPMessage *res = NULL;
if (argc < 1) {
- return net_ads_search_usage(argc, argv);
+ return net_ads_search_usage(c, argc, argv);
}
- if (!ADS_ERR_OK(ads_startup(False, &ads))) {
+ if (!ADS_ERR_OK(ads_startup(c, false, &ads))) {
return -1;
}
@@ -1829,7 +1830,7 @@ static int net_ads_search(int argc, const char **argv)
/*
help for net ads search
*/
-static int net_ads_dn_usage(int argc, const char **argv)
+static int net_ads_dn_usage(struct net_context *c, int argc, const char **argv)
{
d_printf(
"\nnet ads dn <dn> <attributes...>\n"\
@@ -1839,7 +1840,7 @@ static int net_ads_dn_usage(int argc, const char **argv)
"Example: net ads dn 'CN=administrator,CN=Users,DC=my,DC=domain' sAMAccountName\n\n"
"Note: the DN must be provided properly escaped. See RFC 4514 for details\n\n"
);
- net_common_flags_usage(argc, argv);
+ net_common_flags_usage(c, argc, argv);
return -1;
}
@@ -1847,7 +1848,7 @@ static int net_ads_dn_usage(int argc, const char **argv)
/*
general ADS search function. Useful in diagnosing problems in ADS
*/
-static int net_ads_dn(int argc, const char **argv)
+static int net_ads_dn(struct net_context *c, int argc, const char **argv)
{
ADS_STRUCT *ads;
ADS_STATUS rc;
@@ -1856,10 +1857,10 @@ static int net_ads_dn(int argc, const char **argv)
LDAPMessage *res = NULL;
if (argc < 1) {
- return net_ads_dn_usage(argc, argv);
+ return net_ads_dn_usage(c, argc, argv);
}
- if (!ADS_ERR_OK(ads_startup(False, &ads))) {
+ if (!ADS_ERR_OK(ads_startup(c, false, &ads))) {
return -1;
}
@@ -1889,7 +1890,7 @@ static int net_ads_dn(int argc, const char **argv)
/*
help for net ads sid search
*/
-static int net_ads_sid_usage(int argc, const char **argv)
+static int net_ads_sid_usage(struct net_context *c, int argc, const char **argv)
{
d_printf(
"\nnet ads sid <sid> <attributes...>\n"\
@@ -1898,7 +1899,7 @@ static int net_ads_sid_usage(int argc, const char **argv)
"to show in the results\n\n"\
"Example: net ads sid 'S-1-5-32' distinguishedName\n\n"
);
- net_common_flags_usage(argc, argv);
+ net_common_flags_usage(c, argc, argv);
return -1;
}
@@ -1906,7 +1907,7 @@ static int net_ads_sid_usage(int argc, const char **argv)
/*
general ADS search function. Useful in diagnosing problems in ADS
*/
-static int net_ads_sid(int argc, const char **argv)
+static int net_ads_sid(struct net_context *c, int argc, const char **argv)
{
ADS_STRUCT *ads;
ADS_STATUS rc;
@@ -1916,10 +1917,10 @@ static int net_ads_sid(int argc, const char **argv)
DOM_SID sid;
if (argc < 1) {
- return net_ads_sid_usage(argc, argv);
+ return net_ads_sid_usage(c, argc, argv);
}
- if (!ADS_ERR_OK(ads_startup(False, &ads))) {
+ if (!ADS_ERR_OK(ads_startup(c, false, &ads))) {
return -1;
}
@@ -1951,7 +1952,7 @@ static int net_ads_sid(int argc, const char **argv)
}
-static int net_ads_keytab_usage(int argc, const char **argv)
+static int net_ads_keytab_usage(struct net_context *c, int argc, const char **argv)
{
d_printf(
"net ads keytab <COMMAND>\n"\
@@ -1973,12 +1974,12 @@ static int net_ads_keytab_usage(int argc, const char **argv)
return -1;
}
-static int net_ads_keytab_flush(int argc, const char **argv)
+static int net_ads_keytab_flush(struct net_context *c, int argc, const char **argv)
{
int ret;
ADS_STRUCT *ads;
- if (!ADS_ERR_OK(ads_startup(True, &ads))) {
+ if (!ADS_ERR_OK(ads_startup(c, true, &ads))) {
return -1;
}
ret = ads_keytab_flush(ads);
@@ -1986,14 +1987,14 @@ static int net_ads_keytab_flush(int argc, const char **argv)
return ret;
}
-static int net_ads_keytab_add(int argc, const char **argv)
+static int net_ads_keytab_add(struct net_context *c, int argc, const char **argv)
{
int i;
int ret = 0;
ADS_STRUCT *ads;
d_printf("Processing principals to add...\n");
- if (!ADS_ERR_OK(ads_startup(True, &ads))) {
+ if (!ADS_ERR_OK(ads_startup(c, true, &ads))) {
return -1;
}
for (i = 0; i < argc; i++) {
@@ -2003,12 +2004,12 @@ static int net_ads_keytab_add(int argc, const char **argv)
return ret;
}
-static int net_ads_keytab_create(int argc, const char **argv)
+static int net_ads_keytab_create(struct net_context *c, int argc, const char **argv)
{
ADS_STRUCT *ads;
int ret;
- if (!ADS_ERR_OK(ads_startup(True, &ads))) {
+ if (!ADS_ERR_OK(ads_startup(c, true, &ads))) {
return -1;
}
ret = ads_keytab_create_default(ads);
@@ -2016,7 +2017,7 @@ static int net_ads_keytab_create(int argc, const char **argv)
return ret;
}
-static int net_ads_keytab_list(int argc, const char **argv)
+static int net_ads_keytab_list(struct net_context *c, int argc, const char **argv)
{
const char *keytab = NULL;
@@ -2028,7 +2029,7 @@ static int net_ads_keytab_list(int argc, const char **argv)
}
-int net_ads_keytab(int argc, const char **argv)
+int net_ads_keytab(struct net_context *c, int argc, const char **argv)
{
struct functable func[] = {
{"ADD", net_ads_keytab_add},
@@ -2044,10 +2045,10 @@ int net_ads_keytab(int argc, const char **argv)
use keytab functions.\n");
}
- return net_run_function(argc, argv, func, net_ads_keytab_usage);
+ return net_run_function(c, argc, argv, func, net_ads_keytab_usage);
}
-static int net_ads_kerberos_usage(int argc, const char **argv)
+static int net_ads_kerberos_usage(struct net_context *c, int argc, const char **argv)
{
d_printf(
"net ads kerberos <COMMAND>\n"\
@@ -2061,7 +2062,7 @@ static int net_ads_kerberos_usage(int argc, const char **argv)
return -1;
}
-static int net_ads_kerberos_renew(int argc, const char **argv)
+static int net_ads_kerberos_renew(struct net_context *c, int argc, const char **argv)
{
int ret = smb_krb5_renew_ticket(NULL, NULL, NULL, NULL);
if (ret) {
@@ -2071,7 +2072,7 @@ static int net_ads_kerberos_renew(int argc, const char **argv)
return ret;
}
-static int net_ads_kerberos_pac(int argc, const char **argv)
+static int net_ads_kerberos_pac(struct net_context *c, int argc, const char **argv)
{
struct PAC_DATA *pac = NULL;
struct PAC_LOGON_INFO *info = NULL;
@@ -2084,17 +2085,17 @@ static int net_ads_kerberos_pac(int argc, const char **argv)
goto out;
}
- opt_password = net_prompt_pass(opt_user_name);
+ c->opt_password = net_prompt_pass(c, c->opt_user_name);
status = kerberos_return_pac(mem_ctx,
- opt_user_name,
- opt_password,
+ c->opt_user_name,
+ c->opt_password,
0,
NULL,
NULL,
NULL,
- True,
- True,
+ true,
+ true,
2592000, /* one month */
&pac);
if (!NT_STATUS_IS_OK(status)) {
@@ -2116,7 +2117,7 @@ static int net_ads_kerberos_pac(int argc, const char **argv)
return ret;
}
-static int net_ads_kerberos_kinit(int argc, const char **argv)
+static int net_ads_kerberos_kinit(struct net_context *c, int argc, const char **argv)
{
TALLOC_CTX *mem_ctx = NULL;
int ret = -1;
@@ -2127,16 +2128,16 @@ static int net_ads_kerberos_kinit(int argc, const char **argv)
goto out;
}
- opt_password = net_prompt_pass(opt_user_name);
+ c->opt_password = net_prompt_pass(c, c->opt_user_name);
- ret = kerberos_kinit_password_ext(opt_user_name,
- opt_password,
+ ret = kerberos_kinit_password_ext(c->opt_user_name,
+ c->opt_password,
0,
NULL,
NULL,
NULL,
- True,
- True,
+ true,
+ true,
2592000, /* one month */
&status);
if (ret) {
@@ -2147,7 +2148,7 @@ static int net_ads_kerberos_kinit(int argc, const char **argv)
return ret;
}
-int net_ads_kerberos(int argc, const char **argv)
+int net_ads_kerberos(struct net_context *c, int argc, const char **argv)
{
struct functable func[] = {
{"KINIT", net_ads_kerberos_kinit},
@@ -2157,11 +2158,11 @@ int net_ads_kerberos(int argc, const char **argv)
{NULL, NULL}
};
- return net_run_function(argc, argv, func, net_ads_kerberos_usage);
+ return net_run_function(c, argc, argv, func, net_ads_kerberos_usage);
}
-int net_ads_help(int argc, const char **argv)
+int net_ads_help(struct net_context *c, int argc, const char **argv)
{
struct functable func[] = {
{"USER", net_ads_user_usage},
@@ -2178,10 +2179,10 @@ int net_ads_help(int argc, const char **argv)
{NULL, NULL}
};
- return net_run_function(argc, argv, func, net_ads_usage);
+ return net_run_function(c, argc, argv, func, net_ads_usage);
}
-int net_ads(int argc, const char **argv)
+int net_ads(struct net_context *c, int argc, const char **argv)
{
struct functable func[] = {
{"INFO", net_ads_info},
@@ -2207,7 +2208,7 @@ int net_ads(int argc, const char **argv)
{NULL, NULL}
};
- return net_run_function(argc, argv, func, net_ads_usage);
+ return net_run_function(c, argc, argv, func, net_ads_usage);
}
#else
@@ -2218,60 +2219,60 @@ static int net_ads_noads(void)
return -1;
}
-int net_ads_keytab(int argc, const char **argv)
+int net_ads_keytab(struct net_context *c, int argc, const char **argv)
{
return net_ads_noads();
}
-int net_ads_kerberos(int argc, const char **argv)
+int net_ads_kerberos(struct net_context *c, int argc, const char **argv)
{
return net_ads_noads();
}
-int net_ads_usage(int argc, const char **argv)
+int net_ads_usage(struct net_context *c, int argc, const char **argv)
{
return net_ads_noads();
}
-int net_ads_help(int argc, const char **argv)
+int net_ads_help(struct net_context *c, int argc, const char **argv)
{
return net_ads_noads();
}
-int net_ads_changetrustpw(int argc, const char **argv)
+int net_ads_changetrustpw(struct net_context *c, int argc, const char **argv)
{
return net_ads_noads();
}
-int net_ads_join(int argc, const char **argv)
+int net_ads_join(struct net_context *c, int argc, const char **argv)
{
return net_ads_noads();
}
-int net_ads_user(int argc, const char **argv)
+int net_ads_user(struct net_context *c, int argc, const char **argv)
{
return net_ads_noads();
}
-int net_ads_group(int argc, const char **argv)
+int net_ads_group(struct net_context *c, int argc, const char **argv)
{
return net_ads_noads();
}
/* this one shouldn't display a message */
-int net_ads_check(void)
+int net_ads_check(struct net_context *c)
{
return -1;
}
-int net_ads_check_our_domain(void)
+int net_ads_check_our_domain(struct net_context *c)
{
return -1;
}
-int net_ads(int argc, const char **argv)
+int net_ads(struct net_context *c, int argc, const char **argv)
{
- return net_ads_usage(argc, argv);
+ return net_ads_usage(c, argc, argv);
}
#endif /* WITH_ADS */
diff --git a/source3/utils/net_ads_gpo.c b/source3/utils/net_ads_gpo.c
index d71fa908e91..5ef96204f4b 100644
--- a/source3/utils/net_ads_gpo.c
+++ b/source3/utils/net_ads_gpo.c
@@ -22,7 +22,7 @@
#ifdef HAVE_ADS
-static int net_ads_gpo_usage(int argc, const char **argv)
+static int net_ads_gpo_usage(struct net_context *c, int argc, const char **argv)
{
d_printf(
"net ads gpo <COMMAND>\n"\
@@ -41,7 +41,7 @@ static int net_ads_gpo_usage(int argc, const char **argv)
return -1;
}
-static int net_ads_gpo_refresh(int argc, const char **argv)
+static int net_ads_gpo_refresh(struct net_context *c, int argc, const char **argv)
{
TALLOC_CTX *mem_ctx;
ADS_STRUCT *ads;
@@ -65,7 +65,7 @@ static int net_ads_gpo_refresh(int argc, const char **argv)
return -1;
}
- status = ads_startup(False, &ads);
+ status = ads_startup(c, false, &ads);
if (!ADS_ERR_OK(status)) {
printf("failed to connect AD server: %s\n", ads_errstr(status));
goto out;
@@ -128,7 +128,7 @@ static int net_ads_gpo_refresh(int argc, const char **argv)
printf("finished\n");
- if (opt_verbose) {
+ if (c->opt_verbose) {
printf("* dumping GPO list\n");
@@ -173,7 +173,7 @@ static int net_ads_gpo_refresh(int argc, const char **argv)
printf("finished\n");
- if (opt_verbose) {
+ if (c->opt_verbose) {
printf("* dumping GPO list from registry\n");
@@ -211,7 +211,7 @@ static int net_ads_gpo_refresh(int argc, const char **argv)
return 0;
}
-static int net_ads_gpo_list_all(int argc, const char **argv)
+static int net_ads_gpo_list_all(struct net_context *c, int argc, const char **argv)
{
ADS_STRUCT *ads;
ADS_STATUS status;
@@ -238,7 +238,7 @@ static int net_ads_gpo_list_all(int argc, const char **argv)
return -1;
}
- status = ads_startup(False, &ads);
+ status = ads_startup(c, false, &ads);
if (!ADS_ERR_OK(status)) {
goto out;
}
@@ -290,7 +290,7 @@ out:
return 0;
}
-static int net_ads_gpo_list(int argc, const char **argv)
+static int net_ads_gpo_list(struct net_context *c, int argc, const char **argv)
{
ADS_STRUCT *ads;
ADS_STATUS status;
@@ -312,7 +312,7 @@ static int net_ads_gpo_list(int argc, const char **argv)
goto out;
}
- status = ads_startup(False, &ads);
+ status = ads_startup(c, false, &ads);
if (!ADS_ERR_OK(status)) {
goto out;
}
@@ -357,7 +357,7 @@ out:
}
#if 0
-static int net_ads_gpo_apply(int argc, const char **argv)
+static int net_ads_gpo_apply(struct net_context *c, int argc, const char **argv)
{
TALLOC_CTX *mem_ctx;
ADS_STRUCT *ads;
@@ -383,7 +383,7 @@ static int net_ads_gpo_apply(int argc, const char **argv)
filter = cse_gpo_name_to_guid_string(argv[1]);
}
- status = ads_startup(False, &ads);
+ status = ads_startup(c, false, &ads);
if (!ADS_ERR_OK(status)) {
printf("got: %s\n", ads_errstr(status));
goto out;
@@ -438,7 +438,7 @@ out:
}
#endif
-static int net_ads_gpo_link_get(int argc, const char **argv)
+static int net_ads_gpo_link_get(struct net_context *c, int argc, const char **argv)
{
ADS_STRUCT *ads;
ADS_STATUS status;
@@ -455,7 +455,7 @@ static int net_ads_gpo_link_get(int argc, const char **argv)
return -1;
}
- status = ads_startup(False, &ads);
+ status = ads_startup(c, false, &ads);
if (!ADS_ERR_OK(status)) {
goto out;
}
@@ -476,7 +476,7 @@ out:
return 0;
}
-static int net_ads_gpo_link_add(int argc, const char **argv)
+static int net_ads_gpo_link_add(struct net_context *c, int argc, const char **argv)
{
ADS_STRUCT *ads;
ADS_STATUS status;
@@ -499,7 +499,7 @@ static int net_ads_gpo_link_add(int argc, const char **argv)
gpo_opt = atoi(argv[2]);
}
- status = ads_startup(False, &ads);
+ status = ads_startup(c, false, &ads);
if (!ADS_ERR_OK(status)) {
goto out;
}
@@ -519,7 +519,7 @@ out:
#if 0 /* broken */
-static int net_ads_gpo_link_delete(int argc, const char **argv)
+static int net_ads_gpo_link_delete(struct net_context *c, int argc, const char **argv)
{
ADS_STRUCT *ads;
ADS_STATUS status;
@@ -534,7 +534,7 @@ static int net_ads_gpo_link_delete(int argc, const char **argv)
return -1;
}
- status = ads_startup(False, &ads);
+ status = ads_startup(c, false, &ads);
if (!ADS_ERR_OK(status)) {
goto out;
}
@@ -554,7 +554,7 @@ out:
#endif
-static int net_ads_gpo_get_gpo(int argc, const char **argv)
+static int net_ads_gpo_get_gpo(struct net_context *c, int argc, const char **argv)
{
ADS_STRUCT *ads;
ADS_STATUS status;
@@ -571,7 +571,7 @@ static int net_ads_gpo_get_gpo(int argc, const char **argv)
return -1;
}
- status = ads_startup(False, &ads);
+ status = ads_startup(c, false, &ads);
if (!ADS_ERR_OK(status)) {
goto out;
}
@@ -597,7 +597,7 @@ out:
return 0;
}
-int net_ads_gpo(int argc, const char **argv)
+int net_ads_gpo(struct net_context *c, int argc, const char **argv)
{
struct functable func[] = {
/* {"APPLY", net_ads_gpo_apply}, */
@@ -612,7 +612,7 @@ int net_ads_gpo(int argc, const char **argv)
{NULL, NULL}
};
- return net_run_function(argc, argv, func, net_ads_gpo_usage);
+ return net_run_function(c, argc, argv, func, net_ads_gpo_usage);
}
#endif /* HAVE_ADS */
diff --git a/source3/utils/net_cache.c b/source3/utils/net_cache.c
index 8e0f98ef7ec..e59a534e4a2 100644
--- a/source3/utils/net_cache.c
+++ b/source3/utils/net_cache.c
@@ -14,8 +14,8 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
#include "includes.h"
#include "net.h"
@@ -145,10 +145,11 @@ static time_t parse_timeout(const char* timeout_str)
/**
* Add an entry to the cache. If it does exist, then set it.
*
+ * @param c A net_context structure
* @param argv key, value and timeout are passed in command line
* @return 0 on success, otherwise failure
**/
-static int net_cache_add(int argc, const char **argv)
+static int net_cache_add(struct net_context *c, int argc, const char **argv)
{
const char *keystr, *datastr, *timeout_str;
time_t timeout;
@@ -183,10 +184,11 @@ static int net_cache_add(int argc, const char **argv)
/**
* Delete an entry in the cache
*
+ * @param c A net_context structure
* @param argv key to delete an entry of
* @return 0 on success, otherwise failure
**/
-static int net_cache_del(int argc, const char **argv)
+static int net_cache_del(struct net_context *c, int argc, const char **argv)
{
const char *keystr = argv[0];
@@ -208,10 +210,11 @@ static int net_cache_del(int argc, const char **argv)
/**
* Get and display an entry from the cache
*
+ * @param c A net_context structure
* @param argv key to search an entry of
* @return 0 on success, otherwise failure
**/
-static int net_cache_get(int argc, const char **argv)
+static int net_cache_get(struct net_context *c, int argc, const char **argv)
{
const char* keystr = argv[0];
char* valuestr;
@@ -235,10 +238,11 @@ static int net_cache_get(int argc, const char **argv)
/**
* Search an entry/entries in the cache
*
+ * @param c A net_context structure
* @param argv key pattern to match the entries to
* @return 0 on success, otherwise failure
**/
-static int net_cache_search(int argc, const char **argv)
+static int net_cache_search(struct net_context *c, int argc, const char **argv)
{
const char* pattern;
@@ -256,10 +260,11 @@ static int net_cache_search(int argc, const char **argv)
/**
* List the contents of the cache
*
+ * @param c A net_context structure
* @param argv ignored in this functionailty
* @return always returns 0
**/
-static int net_cache_list(int argc, const char **argv)
+static int net_cache_list(struct net_context *c, int argc, const char **argv)
{
const char* pattern = "*";
gencache_iterate(print_cache_entry, NULL, pattern);
@@ -271,10 +276,11 @@ static int net_cache_list(int argc, const char **argv)
/**
* Flush the whole cache
*
+ * @param c A net_context structure
* @param argv ignored in this functionality
* @return always returns 0
**/
-static int net_cache_flush(int argc, const char **argv)
+static int net_cache_flush(struct net_context *c, int argc, const char **argv)
{
const char* pattern = "*";
gencache_iterate(delete_cache_entry, NULL, pattern);
@@ -286,10 +292,11 @@ static int net_cache_flush(int argc, const char **argv)
/**
* Short help
*
+ * @param c A net_context structure
* @param argv ignored in this functionality
* @return always returns -1
**/
-static int net_cache_usage(int argc, const char **argv)
+static int net_cache_usage(struct net_context *c, int argc, const char **argv)
{
d_printf(" net cache add \t add add new cache entry\n");
d_printf(" net cache del \t delete existing cache entry by key\n");
@@ -304,10 +311,11 @@ static int net_cache_usage(int argc, const char **argv)
/**
* Entry point to 'net cache' subfunctionality
*
+ * @param c A net_context structure
* @param argv arguments passed to further called functions
* @return whatever further functions return
**/
-int net_cache(int argc, const char **argv)
+int net_cache(struct net_context *c, int argc, const char **argv)
{
struct functable func[] = {
{"add", net_cache_add},
@@ -319,5 +327,5 @@ int net_cache(int argc, const char **argv)
{NULL, NULL}
};
- return net_run_function(argc, argv, func, net_cache_usage);
+ return net_run_function(c, argc, argv, func, net_cache_usage);
}
diff --git a/source3/utils/net_conf.c b/source3/utils/net_conf.c
index 08a06eabd41..a922e135833 100644
--- a/source3/utils/net_conf.c
+++ b/source3/utils/net_conf.c
@@ -36,13 +36,15 @@
*
**********************************************************************/
-static int net_conf_list_usage(int argc, const char **argv)
+static int net_conf_list_usage(struct net_context *c, int argc,
+ const char **argv)
{
d_printf("USAGE: net conf list\n");
return -1;
}
-static int net_conf_import_usage(int argc, const char**argv)
+static int net_conf_import_usage(struct net_context *c, int argc,
+ const char**argv)
{
d_printf("USAGE: net conf import [--test|-T] <filename> "
"[<servicename>]\n"
@@ -53,25 +55,29 @@ static int net_conf_import_usage(int argc, const char**argv)
return -1;
}
-static int net_conf_listshares_usage(int argc, const char **argv)
+static int net_conf_listshares_usage(struct net_context *c, int argc,
+ const char **argv)
{
d_printf("USAGE: net conf listshares\n");
return -1;
}
-static int net_conf_drop_usage(int argc, const char **argv)
+static int net_conf_drop_usage(struct net_context *c, int argc,
+ const char **argv)
{
d_printf("USAGE: net conf drop\n");
return -1;
}
-static int net_conf_showshare_usage(int argc, const char **argv)
+static int net_conf_showshare_usage(struct net_context *c, int argc,
+ const char **argv)
{
d_printf("USAGE: net conf showshare <sharename>\n");
return -1;
}
-static int net_conf_addshare_usage(int argc, const char **argv)
+static int net_conf_addshare_usage(struct net_context *c, int argc,
+ const char **argv)
{
d_printf("USAGE: net conf addshare <sharename> <path> "
"[writeable={y|N} [guest_ok={y|N} [<comment>]]\n"
@@ -85,43 +91,50 @@ static int net_conf_addshare_usage(int argc, const char **argv)
return -1;
}
-static int net_conf_delshare_usage(int argc, const char **argv)
+static int net_conf_delshare_usage(struct net_context *c, int argc,
+ const char **argv)
{
d_printf("USAGE: net conf delshare <sharename>\n");
return -1;
}
-static int net_conf_setparm_usage(int argc, const char **argv)
+static int net_conf_setparm_usage(struct net_context *c, int argc,
+ const char **argv)
{
d_printf("USAGE: net conf setparm <section> <param> <value>\n");
return -1;
}
-static int net_conf_getparm_usage(int argc, const char **argv)
+static int net_conf_getparm_usage(struct net_context *c, int argc,
+ const char **argv)
{
d_printf("USAGE: net conf getparm <section> <param>\n");
return -1;
}
-static int net_conf_delparm_usage(int argc, const char **argv)
+static int net_conf_delparm_usage(struct net_context *c, int argc,
+ const char **argv)
{
d_printf("USAGE: net conf delparm <section> <param>\n");
return -1;
}
-static int net_conf_getincludes_usage(int argc, const char **argv)
+static int net_conf_getincludes_usage(struct net_context *c, int argc,
+ const char **argv)
{
d_printf("USAGE: net conf getincludes <section>\n");
return -1;
}
-static int net_conf_setincludes_usage(int argc, const char **argv)
+static int net_conf_setincludes_usage(struct net_context *c, int argc,
+ const char **argv)
{
d_printf("USAGE: net conf setincludes <section> [<filename>]*\n");
return -1;
}
-static int net_conf_delincludes_usage(int argc, const char **argv)
+static int net_conf_delincludes_usage(struct net_context *c, int argc,
+ const char **argv)
{
d_printf("USAGE: net conf delincludes <section>\n");
return -1;
@@ -137,7 +150,8 @@ static int net_conf_delincludes_usage(int argc, const char **argv)
/**
* This functions process a service previously loaded with libsmbconf.
*/
-static WERROR import_process_service(struct smbconf_ctx *conf_ctx,
+static WERROR import_process_service(struct net_context *c,
+ struct smbconf_ctx *conf_ctx,
struct smbconf_service *service)
{
uint32_t idx;
@@ -146,7 +160,7 @@ static WERROR import_process_service(struct smbconf_ctx *conf_ctx,
char **includes = NULL;
TALLOC_CTX *mem_ctx = talloc_stackframe();
- if (opt_testmode) {
+ if (c->opt_testmode) {
const char *indent = "";
if (service->name != NULL) {
d_printf("[%s]\n", service->name);
@@ -215,7 +229,7 @@ done:
*
**********************************************************************/
-static int net_conf_list(struct smbconf_ctx *conf_ctx,
+static int net_conf_list(struct net_context *c, struct smbconf_ctx *conf_ctx,
int argc, const char **argv)
{
WERROR werr = WERR_OK;
@@ -228,7 +242,7 @@ static int net_conf_list(struct smbconf_ctx *conf_ctx,
mem_ctx = talloc_stackframe();
if (argc != 0) {
- net_conf_list_usage(argc, argv);
+ net_conf_list_usage(c, argc, argv);
goto done;
}
@@ -264,7 +278,7 @@ done:
return ret;
}
-static int net_conf_import(struct smbconf_ctx *conf_ctx,
+static int net_conf_import(struct net_context *c, struct smbconf_ctx *conf_ctx,
int argc, const char **argv)
{
int ret = -1;
@@ -280,7 +294,7 @@ static int net_conf_import(struct smbconf_ctx *conf_ctx,
switch (argc) {
case 0:
default:
- net_conf_import_usage(argc, argv);
+ net_conf_import_usage(c, argc, argv);
goto done;
case 2:
servicename = talloc_strdup_lower(mem_ctx, argv[1]);
@@ -309,7 +323,7 @@ static int net_conf_import(struct smbconf_ctx *conf_ctx,
goto done;
}
- if (opt_testmode) {
+ if (c->opt_testmode) {
d_printf("\nTEST MODE - "
"would import the following configuration:\n\n");
}
@@ -323,7 +337,7 @@ static int net_conf_import(struct smbconf_ctx *conf_ctx,
if (!W_ERROR_IS_OK(werr)) {
goto done;
}
- werr = import_process_service(conf_ctx, service);
+ werr = import_process_service(c, conf_ctx, service);
if (!W_ERROR_IS_OK(werr)) {
goto done;
}
@@ -337,14 +351,15 @@ static int net_conf_import(struct smbconf_ctx *conf_ctx,
if (!W_ERROR_IS_OK(werr)) {
goto done;
}
- if (!opt_testmode) {
+ if (!c->opt_testmode) {
werr = smbconf_drop(conf_ctx);
if (!W_ERROR_IS_OK(werr)) {
goto done;
}
}
for (sidx = 0; sidx < num_shares; sidx++) {
- werr = import_process_service(conf_ctx, services[sidx]);
+ werr = import_process_service(c, conf_ctx,
+ services[sidx]);
if (!W_ERROR_IS_OK(werr)) {
goto done;
}
@@ -358,8 +373,9 @@ done:
return ret;
}
-static int net_conf_listshares(struct smbconf_ctx *conf_ctx,
- int argc, const char **argv)
+static int net_conf_listshares(struct net_context *c,
+ struct smbconf_ctx *conf_ctx, int argc,
+ const char **argv)
{
WERROR werr = WERR_OK;
int ret = -1;
@@ -370,7 +386,7 @@ static int net_conf_listshares(struct smbconf_ctx *conf_ctx,
mem_ctx = talloc_stackframe();
if (argc != 0) {
- net_conf_listshares_usage(argc, argv);
+ net_conf_listshares_usage(c, argc, argv);
goto done;
}
@@ -392,14 +408,14 @@ done:
return ret;
}
-static int net_conf_drop(struct smbconf_ctx *conf_ctx,
+static int net_conf_drop(struct net_context *c, struct smbconf_ctx *conf_ctx,
int argc, const char **argv)
{
int ret = -1;
WERROR werr;
if (argc != 0) {
- net_conf_drop_usage(argc, argv);
+ net_conf_drop_usage(c, argc, argv);
goto done;
}
@@ -416,8 +432,9 @@ done:
return ret;
}
-static int net_conf_showshare(struct smbconf_ctx *conf_ctx,
- int argc, const char **argv)
+static int net_conf_showshare(struct net_context *c,
+ struct smbconf_ctx *conf_ctx, int argc,
+ const char **argv)
{
int ret = -1;
WERROR werr = WERR_OK;
@@ -429,7 +446,7 @@ static int net_conf_showshare(struct smbconf_ctx *conf_ctx,
mem_ctx = talloc_stackframe();
if (argc != 1) {
- net_conf_showshare_usage(argc, argv);
+ net_conf_showshare_usage(c, argc, argv);
goto done;
}
@@ -466,8 +483,9 @@ done:
* This is a high level utility function of the net conf utility,
* not a direct frontend to the smbconf API.
*/
-static int net_conf_addshare(struct smbconf_ctx *conf_ctx,
- int argc, const char **argv)
+static int net_conf_addshare(struct net_context *c,
+ struct smbconf_ctx *conf_ctx, int argc,
+ const char **argv)
{
int ret = -1;
WERROR werr = WERR_OK;
@@ -483,13 +501,13 @@ static int net_conf_addshare(struct smbconf_ctx *conf_ctx,
case 0:
case 1:
default:
- net_conf_addshare_usage(argc, argv);
+ net_conf_addshare_usage(c, argc, argv);
goto done;
case 5:
comment = argv[4];
case 4:
if (!strnequal(argv[3], "guest_ok=", 9)) {
- net_conf_addshare_usage(argc, argv);
+ net_conf_addshare_usage(c, argc, argv);
goto done;
}
switch (argv[3][9]) {
@@ -502,12 +520,12 @@ static int net_conf_addshare(struct smbconf_ctx *conf_ctx,
guest_ok = "no";
break;
default:
- net_conf_addshare_usage(argc, argv);
+ net_conf_addshare_usage(c, argc, argv);
goto done;
}
case 3:
if (!strnequal(argv[2], "writeable=", 10)) {
- net_conf_addshare_usage(argc, argv);
+ net_conf_addshare_usage(c, argc, argv);
goto done;
}
switch (argv[2][10]) {
@@ -520,7 +538,7 @@ static int net_conf_addshare(struct smbconf_ctx *conf_ctx,
writeable = "no";
break;
default:
- net_conf_addshare_usage(argc, argv);
+ net_conf_addshare_usage(c, argc, argv);
goto done;
}
case 2:
@@ -646,8 +664,9 @@ done:
return ret;
}
-static int net_conf_delshare(struct smbconf_ctx *conf_ctx,
- int argc, const char **argv)
+static int net_conf_delshare(struct net_context *c,
+ struct smbconf_ctx *conf_ctx, int argc,
+ const char **argv)
{
int ret = -1;
const char *sharename = NULL;
@@ -655,7 +674,7 @@ static int net_conf_delshare(struct smbconf_ctx *conf_ctx,
TALLOC_CTX *mem_ctx = talloc_stackframe();
if (argc != 1) {
- net_conf_delshare_usage(argc, argv);
+ net_conf_delshare_usage(c, argc, argv);
goto done;
}
sharename = talloc_strdup_lower(mem_ctx, argv[0]);
@@ -677,7 +696,7 @@ done:
return ret;
}
-static int net_conf_setparm(struct smbconf_ctx *conf_ctx,
+static int net_conf_setparm(struct net_context *c, struct smbconf_ctx *conf_ctx,
int argc, const char **argv)
{
int ret = -1;
@@ -688,7 +707,7 @@ static int net_conf_setparm(struct smbconf_ctx *conf_ctx,
TALLOC_CTX *mem_ctx = talloc_stackframe();
if (argc != 3) {
- net_conf_setparm_usage(argc, argv);
+ net_conf_setparm_usage(c, argc, argv);
goto done;
}
service = talloc_strdup_lower(mem_ctx, argv[0]);
@@ -727,7 +746,7 @@ done:
return ret;
}
-static int net_conf_getparm(struct smbconf_ctx *conf_ctx,
+static int net_conf_getparm(struct net_context *c, struct smbconf_ctx *conf_ctx,
int argc, const char **argv)
{
int ret = -1;
@@ -740,7 +759,7 @@ static int net_conf_getparm(struct smbconf_ctx *conf_ctx,
mem_ctx = talloc_stackframe();
if (argc != 2) {
- net_conf_getparm_usage(argc, argv);
+ net_conf_getparm_usage(c, argc, argv);
goto done;
}
service = talloc_strdup_lower(mem_ctx, argv[0]);
@@ -780,7 +799,7 @@ done:
return ret;
}
-static int net_conf_delparm(struct smbconf_ctx *conf_ctx,
+static int net_conf_delparm(struct net_context *c, struct smbconf_ctx *conf_ctx,
int argc, const char **argv)
{
int ret = -1;
@@ -790,7 +809,7 @@ static int net_conf_delparm(struct smbconf_ctx *conf_ctx,
TALLOC_CTX *mem_ctx = talloc_stackframe();
if (argc != 2) {
- net_conf_delparm_usage(argc, argv);
+ net_conf_delparm_usage(c, argc, argv);
goto done;
}
service = talloc_strdup_lower(mem_ctx, argv[0]);
@@ -829,7 +848,8 @@ done:
return ret;
}
-static int net_conf_getincludes(struct smbconf_ctx *conf_ctx,
+static int net_conf_getincludes(struct net_context *c,
+ struct smbconf_ctx *conf_ctx,
int argc, const char **argv)
{
WERROR werr;
@@ -841,7 +861,7 @@ static int net_conf_getincludes(struct smbconf_ctx *conf_ctx,
TALLOC_CTX *mem_ctx = talloc_stackframe();
if (argc != 1) {
- net_conf_getincludes_usage(argc, argv);
+ net_conf_getincludes_usage(c, argc, argv);
goto done;
}
@@ -869,7 +889,8 @@ done:
return ret;
}
-static int net_conf_setincludes(struct smbconf_ctx *conf_ctx,
+static int net_conf_setincludes(struct net_context *c,
+ struct smbconf_ctx *conf_ctx,
int argc, const char **argv)
{
WERROR werr;
@@ -880,7 +901,7 @@ static int net_conf_setincludes(struct smbconf_ctx *conf_ctx,
TALLOC_CTX *mem_ctx = talloc_stackframe();
if (argc < 1) {
- net_conf_setincludes_usage(argc, argv);
+ net_conf_setincludes_usage(c, argc, argv);
goto done;
}
@@ -910,7 +931,8 @@ done:
return ret;
}
-static int net_conf_delincludes(struct smbconf_ctx *conf_ctx,
+static int net_conf_delincludes(struct net_context *c,
+ struct smbconf_ctx *conf_ctx,
int argc, const char **argv)
{
WERROR werr;
@@ -919,7 +941,7 @@ static int net_conf_delincludes(struct smbconf_ctx *conf_ctx,
TALLOC_CTX *mem_ctx = talloc_stackframe();
if (argc != 1) {
- net_conf_delincludes_usage(argc, argv);
+ net_conf_delincludes_usage(c, argc, argv);
goto done;
}
@@ -954,7 +976,9 @@ done:
* The wrapper calls handles opening and closing of the
* configuration.
*/
-static int net_conf_wrap_function(int (*fn)(struct smbconf_ctx *,
+static int net_conf_wrap_function(struct net_context *c,
+ int (*fn)(struct net_context *,
+ struct smbconf_ctx *,
int, const char **),
int argc, const char **argv)
{
@@ -969,7 +993,7 @@ static int net_conf_wrap_function(int (*fn)(struct smbconf_ctx *,
return -1;
}
- ret = fn(conf_ctx, argc, argv);
+ ret = fn(c, conf_ctx, argc, argv);
smbconf_shutdown(conf_ctx);
@@ -983,7 +1007,8 @@ static int net_conf_wrap_function(int (*fn)(struct smbconf_ctx *,
*/
struct conf_functable {
const char *funcname;
- int (*fn)(struct smbconf_ctx *ctx, int argc, const char **argv);
+ int (*fn)(struct net_context *c, struct smbconf_ctx *ctx, int argc,
+ const char **argv);
const char *helptext;
};
@@ -991,8 +1016,8 @@ struct conf_functable {
* This imitates net_run_function2 but calls the main functions
* through the wrapper net_conf_wrap_function().
*/
-static int net_conf_run_function(int argc, const char **argv,
- const char *whoami,
+static int net_conf_run_function(struct net_context *c, int argc,
+ const char **argv, const char *whoami,
struct conf_functable *table)
{
int i;
@@ -1000,7 +1025,7 @@ static int net_conf_run_function(int argc, const char **argv,
if (argc != 0) {
for (i=0; table[i].funcname; i++) {
if (StrCaseCmp(argv[0], table[i].funcname) == 0)
- return net_conf_wrap_function(table[i].fn,
+ return net_conf_wrap_function(c, table[i].fn,
argc-1,
argv+1);
}
@@ -1018,7 +1043,7 @@ static int net_conf_run_function(int argc, const char **argv,
* Entry-point for all the CONF functions.
*/
-int net_conf(int argc, const char **argv)
+int net_conf(struct net_context *c, int argc, const char **argv)
{
int ret = -1;
struct conf_functable func_table[] = {
@@ -1051,7 +1076,7 @@ int net_conf(int argc, const char **argv)
{NULL, NULL, NULL}
};
- ret = net_conf_run_function(argc, argv, "net conf", func_table);
+ ret = net_conf_run_function(c, argc, argv, "net conf", func_table);
return ret;
}
diff --git a/source3/utils/net_dom.c b/source3/utils/net_dom.c
index 6e4bf14c84d..86dad658d62 100644
--- a/source3/utils/net_dom.c
+++ b/source3/utils/net_dom.c
@@ -20,7 +20,7 @@
#include "includes.h"
#include "utils/net.h"
-static int net_dom_usage(int argc, const char **argv)
+static int net_dom_usage(struct net_context *c, int argc, const char **argv)
{
d_printf("usage: net dom join "
"<domain=DOMAIN> <ou=OU> <account=ACCOUNT> <password=PASSWORD> <reboot>\n");
@@ -30,7 +30,7 @@ static int net_dom_usage(int argc, const char **argv)
return -1;
}
-int net_help_dom(int argc, const char **argv)
+int net_help_dom(struct net_context *c, int argc, const char **argv)
{
d_printf("net dom join"\
"\n Join a remote machine\n");
@@ -40,7 +40,7 @@ int net_help_dom(int argc, const char **argv)
return -1;
}
-static int net_dom_unjoin(int argc, const char **argv)
+static int net_dom_unjoin(struct net_context *c, int argc, const char **argv)
{
struct libnetapi_ctx *ctx = NULL;
const char *server_name = NULL;
@@ -56,11 +56,11 @@ static int net_dom_unjoin(int argc, const char **argv)
int i;
if (argc < 1) {
- return net_dom_usage(argc, argv);
+ return net_dom_usage(c, argc, argv);
}
- if (opt_host) {
- server_name = opt_host;
+ if (c->opt_host) {
+ server_name = c->opt_host;
}
for (i=0; i<argc; i++) {
@@ -82,8 +82,9 @@ static int net_dom_unjoin(int argc, const char **argv)
}
if (reboot) {
- ntstatus = net_make_ipc_connection_ex(opt_workgroup, server_name,
- NULL, 0, &cli);
+ ntstatus = net_make_ipc_connection_ex(c, c->opt_workgroup,
+ server_name, NULL, 0,
+ &cli);
if (!NT_STATUS_IS_OK(ntstatus)) {
return -1;
}
@@ -94,8 +95,8 @@ static int net_dom_unjoin(int argc, const char **argv)
return -1;
}
- libnetapi_set_username(ctx, opt_user_name);
- libnetapi_set_password(ctx, opt_password);
+ libnetapi_set_username(ctx, c->opt_user_name);
+ libnetapi_set_password(ctx, c->opt_password);
status = NetUnjoinDomain(server_name, account, password, unjoin_flags);
if (status != 0) {
@@ -105,18 +106,19 @@ static int net_dom_unjoin(int argc, const char **argv)
}
if (reboot) {
- opt_comment = "Shutting down due to a domain membership change";
- opt_reboot = true;
- opt_timeout = 30;
+ c->opt_comment = "Shutting down due to a domain membership "
+ "change";
+ c->opt_reboot = true;
+ c->opt_timeout = 30;
- ret = run_rpc_command(cli, PI_INITSHUTDOWN, 0,
+ ret = run_rpc_command(c, cli, PI_INITSHUTDOWN, 0,
rpc_init_shutdown_internals,
argc, argv);
if (ret == 0) {
goto done;
}
- ret = run_rpc_command(cli, PI_WINREG, 0,
+ ret = run_rpc_command(c, cli, PI_WINREG, 0,
rpc_reg_shutdown_internals,
argc, argv);
goto done;
@@ -132,7 +134,7 @@ static int net_dom_unjoin(int argc, const char **argv)
return ret;
}
-static int net_dom_join(int argc, const char **argv)
+static int net_dom_join(struct net_context *c, int argc, const char **argv)
{
struct libnetapi_ctx *ctx = NULL;
const char *server_name = NULL;
@@ -150,14 +152,14 @@ static int net_dom_join(int argc, const char **argv)
int i;
if (argc < 1) {
- return net_dom_usage(argc, argv);
+ return net_dom_usage(c, argc, argv);
}
- if (opt_host) {
- server_name = opt_host;
+ if (c->opt_host) {
+ server_name = c->opt_host;
}
- if (opt_force) {
+ if (c->opt_force) {
join_flags |= WKSSVC_JOIN_FLAGS_DOMAIN_JOIN_IF_JOINED;
}
@@ -192,8 +194,9 @@ static int net_dom_join(int argc, const char **argv)
}
if (reboot) {
- ntstatus = net_make_ipc_connection_ex(opt_workgroup, server_name,
- NULL, 0, &cli);
+ ntstatus = net_make_ipc_connection_ex(c, c->opt_workgroup,
+ server_name, NULL, 0,
+ &cli);
if (!NT_STATUS_IS_OK(ntstatus)) {
return -1;
}
@@ -206,8 +209,8 @@ static int net_dom_join(int argc, const char **argv)
return -1;
}
- libnetapi_set_username(ctx, opt_user_name);
- libnetapi_set_password(ctx, opt_password);
+ libnetapi_set_username(ctx, c->opt_user_name);
+ libnetapi_set_password(ctx, c->opt_password);
status = NetJoinDomain(server_name, domain_name, account_ou,
Account, password, join_flags);
@@ -218,18 +221,19 @@ static int net_dom_join(int argc, const char **argv)
}
if (reboot) {
- opt_comment = "Shutting down due to a domain membership change";
- opt_reboot = true;
- opt_timeout = 30;
+ c->opt_comment = "Shutting down due to a domain membership "
+ "change";
+ c->opt_reboot = true;
+ c->opt_timeout = 30;
- ret = run_rpc_command(cli, PI_INITSHUTDOWN, 0,
+ ret = run_rpc_command(c, cli, PI_INITSHUTDOWN, 0,
rpc_init_shutdown_internals,
argc, argv);
if (ret == 0) {
goto done;
}
- ret = run_rpc_command(cli, PI_WINREG, 0,
+ ret = run_rpc_command(c, cli, PI_WINREG, 0,
rpc_reg_shutdown_internals,
argc, argv);
goto done;
@@ -245,7 +249,7 @@ static int net_dom_join(int argc, const char **argv)
return ret;
}
-int net_dom(int argc, const char **argv)
+int net_dom(struct net_context *c, int argc, const char **argv)
{
struct functable func[] = {
{"JOIN", net_dom_join},
@@ -254,5 +258,5 @@ int net_dom(int argc, const char **argv)
{NULL, NULL}
};
- return net_run_function(argc, argv, func, net_dom_usage);
+ return net_run_function(c, argc, argv, func, net_dom_usage);
}
diff --git a/source3/utils/net_groupmap.c b/source3/utils/net_groupmap.c
index b0e3d60a24d..0fdebcc912a 100644
--- a/source3/utils/net_groupmap.c
+++ b/source3/utils/net_groupmap.c
@@ -72,7 +72,7 @@ static void print_map_entry ( GROUP_MAP map, bool long_list )
/*********************************************************
List the groups.
**********************************************************/
-static int net_groupmap_list(int argc, const char **argv)
+static int net_groupmap_list(struct net_context *c, int argc, const char **argv)
{
size_t entries;
bool long_list = False;
@@ -80,7 +80,7 @@ static int net_groupmap_list(int argc, const char **argv)
fstring ntgroup = "";
fstring sid_string = "";
- if (opt_verbose || opt_long_list_entries)
+ if (c->opt_verbose || c->opt_long_list_entries)
long_list = True;
/* get the options */
@@ -148,7 +148,7 @@ static int net_groupmap_list(int argc, const char **argv)
Add a new group mapping entry
**********************************************************/
-static int net_groupmap_add(int argc, const char **argv)
+static int net_groupmap_add(struct net_context *c, int argc, const char **argv)
{
DOM_SID sid;
fstring ntgroup = "";
@@ -293,7 +293,6 @@ static int net_groupmap_add(int argc, const char **argv)
if (!ntgroup[0] )
fstrcpy( ntgroup, unixgrp );
-
if (!NT_STATUS_IS_OK(add_initial_entry(gid, string_sid, sid_type, ntgroup, ntcomment))) {
d_fprintf(stderr, "adding entry for group %s failed!\n", ntgroup);
return -1;
@@ -304,7 +303,7 @@ static int net_groupmap_add(int argc, const char **argv)
return 0;
}
-static int net_groupmap_modify(int argc, const char **argv)
+static int net_groupmap_modify(struct net_context *c, int argc, const char **argv)
{
DOM_SID sid;
GROUP_MAP map;
@@ -436,7 +435,7 @@ static int net_groupmap_modify(int argc, const char **argv)
return 0;
}
-static int net_groupmap_delete(int argc, const char **argv)
+static int net_groupmap_delete(struct net_context *c, int argc, const char **argv)
{
DOM_SID sid;
fstring ntgroup = "";
@@ -490,7 +489,7 @@ static int net_groupmap_delete(int argc, const char **argv)
return 0;
}
-static int net_groupmap_set(int argc, const char **argv)
+static int net_groupmap_set(struct net_context *c, int argc, const char **argv)
{
const char *ntgroup = NULL;
struct group *grp = NULL;
@@ -503,7 +502,7 @@ static int net_groupmap_set(int argc, const char **argv)
return -1;
}
- if ( opt_localgroup && opt_domaingroup ) {
+ if ( c->opt_localgroup && c->opt_domaingroup ) {
d_printf("Can only specify -L or -D, not both\n");
return -1;
}
@@ -540,11 +539,11 @@ static int net_groupmap_set(int argc, const char **argv)
map.gid = grp->gr_gid;
- if (opt_rid == 0) {
+ if (c->opt_rid == 0) {
if ( pdb_rid_algorithm() )
- opt_rid = algorithmic_pdb_gid_to_group_rid(map.gid);
+ c->opt_rid = algorithmic_pdb_gid_to_group_rid(map.gid);
else {
- if ( !pdb_new_rid((uint32*)&opt_rid) ) {
+ if ( !pdb_new_rid((uint32*)&c->opt_rid) ) {
d_fprintf( stderr, "Could not allocate new RID\n");
return -1;
}
@@ -552,7 +551,7 @@ static int net_groupmap_set(int argc, const char **argv)
}
sid_copy(&map.sid, get_global_sam_sid());
- sid_append_rid(&map.sid, opt_rid);
+ sid_append_rid(&map.sid, c->opt_rid);
map.sid_name_use = SID_NAME_DOM_GRP;
fstrcpy(map.nt_name, ntgroup);
@@ -567,7 +566,7 @@ static int net_groupmap_set(int argc, const char **argv)
/* Now we have a mapping entry, update that stuff */
- if ( opt_localgroup || opt_domaingroup ) {
+ if ( c->opt_localgroup || c->opt_domaingroup ) {
if (map.sid_name_use == SID_NAME_WKN_GRP) {
d_fprintf(stderr, "Can't change type of the BUILTIN group %s\n",
map.nt_name);
@@ -575,19 +574,19 @@ static int net_groupmap_set(int argc, const char **argv)
}
}
- if (opt_localgroup)
+ if (c->opt_localgroup)
map.sid_name_use = SID_NAME_ALIAS;
- if (opt_domaingroup)
+ if (c->opt_domaingroup)
map.sid_name_use = SID_NAME_DOM_GRP;
/* The case (opt_domaingroup && opt_localgroup) was tested for above */
- if (strlen(opt_comment) > 0)
- fstrcpy(map.comment, opt_comment);
+ if (strlen(c->opt_comment) > 0)
+ fstrcpy(map.comment, c->opt_comment);
- if (strlen(opt_newntname) > 0)
- fstrcpy(map.nt_name, opt_newntname);
+ if (strlen(c->opt_newntname) > 0)
+ fstrcpy(map.nt_name, c->opt_newntname);
if (grp != NULL)
map.gid = grp->gr_gid;
@@ -600,7 +599,7 @@ static int net_groupmap_set(int argc, const char **argv)
return 0;
}
-static int net_groupmap_cleanup(int argc, const char **argv)
+static int net_groupmap_cleanup(struct net_context *c, int argc, const char **argv)
{
GROUP_MAP *map = NULL;
size_t i, entries;
@@ -629,7 +628,7 @@ static int net_groupmap_cleanup(int argc, const char **argv)
return 0;
}
-static int net_groupmap_addmem(int argc, const char **argv)
+static int net_groupmap_addmem(struct net_context *c, int argc, const char **argv)
{
DOM_SID alias, member;
@@ -649,7 +648,7 @@ static int net_groupmap_addmem(int argc, const char **argv)
return 0;
}
-static int net_groupmap_delmem(int argc, const char **argv)
+static int net_groupmap_delmem(struct net_context *c, int argc, const char **argv)
{
DOM_SID alias, member;
@@ -669,7 +668,7 @@ static int net_groupmap_delmem(int argc, const char **argv)
return 0;
}
-static int net_groupmap_listmem(int argc, const char **argv)
+static int net_groupmap_listmem(struct net_context *c, int argc, const char **argv)
{
DOM_SID alias;
DOM_SID *members;
@@ -726,7 +725,7 @@ static bool print_alias_memberships(TALLOC_CTX *mem_ctx,
return True;
}
-static int net_groupmap_memberships(int argc, const char **argv)
+static int net_groupmap_memberships(struct net_context *c, int argc, const char **argv)
{
TALLOC_CTX *mem_ctx;
DOM_SID *domain_sid, *builtin_sid, member;
@@ -759,7 +758,7 @@ static int net_groupmap_memberships(int argc, const char **argv)
return 0;
}
-int net_help_groupmap(int argc, const char **argv)
+int net_help_groupmap(struct net_context *c, int argc, const char **argv)
{
d_printf("net groupmap add"\
"\n Create a new group mapping\n");
@@ -789,7 +788,7 @@ int net_help_groupmap(int argc, const char **argv)
/***********************************************************
migrated functionality from smbgroupedit
**********************************************************/
-int net_groupmap(int argc, const char **argv)
+int net_groupmap(struct net_context *c, int argc, const char **argv)
{
struct functable func[] = {
{"add", net_groupmap_add},
@@ -813,8 +812,8 @@ int net_groupmap(int argc, const char **argv)
}
if ( argc )
- return net_run_function(argc, argv, func, net_help_groupmap);
+ return net_run_function(c, argc, argv, func, net_help_groupmap);
- return net_help_groupmap( argc, argv );
+ return net_help_groupmap(c, argc, argv );
}
diff --git a/source3/utils/net_help.c b/source3/utils/net_help.c
index 908be0512a1..61d4167019d 100644
--- a/source3/utils/net_help.c
+++ b/source3/utils/net_help.c
@@ -20,7 +20,7 @@
#include "includes.h"
#include "utils/net.h"
-int net_common_methods_usage(int argc, const char**argv)
+int net_common_methods_usage(struct net_context *c, int argc, const char**argv)
{
d_printf("Valid methods: (auto-detected if not specified)\n");
d_printf("\tads\t\t\t\tActive Directory (LDAP/Kerberos)\n");
@@ -30,7 +30,7 @@ int net_common_methods_usage(int argc, const char**argv)
return 0;
}
-int net_common_flags_usage(int argc, const char **argv)
+int net_common_flags_usage(struct net_context *c, int argc, const char **argv)
{
d_printf("Valid targets: choose one (none defaults to localhost)\n");
d_printf("\t-S or --server=<server>\t\tserver name\n");
@@ -52,7 +52,7 @@ int net_common_flags_usage(int argc, const char **argv)
return -1;
}
-static int help_usage(int argc, const char **argv)
+static int help_usage(struct net_context *c, int argc, const char **argv)
{
d_printf(
"\n"\
@@ -65,7 +65,7 @@ static int help_usage(int argc, const char **argv)
return -1;
}
-int net_help_user(int argc, const char **argv)
+int net_help_user(struct net_context *c, int argc, const char **argv)
{
d_printf("\nnet [<method>] user [misc. options] [targets]"\
"\n\tList users\n\n");
@@ -80,14 +80,14 @@ int net_help_user(int argc, const char **argv)
" [targets]\n\tRename specified user\n\n");
- net_common_methods_usage(argc, argv);
- net_common_flags_usage(argc, argv);
+ net_common_methods_usage(c, argc, argv);
+ net_common_flags_usage(c, argc, argv);
d_printf("\t-C or --comment=<comment>\tdescriptive comment (for add only)\n");
d_printf("\t-c or --container=<container>\tLDAP container, defaults to cn=Users (for add in ADS only)\n");
return -1;
}
-int net_help_group(int argc, const char **argv)
+int net_help_group(struct net_context *c, int argc, const char **argv)
{
d_printf("net [<method>] group [misc. options] [targets]"\
"\n\tList user groups\n\n");
@@ -101,26 +101,26 @@ int net_help_group(int argc, const char **argv)
d_printf("\nnet rpc group MEMBERS <name>\n\tList Group Members\n\n");
d_printf("\nnet rpc group ADDMEM <group> <member>\n\tAdd Group Members\n\n");
d_printf("\nnet rpc group DELMEM <group> <member>\n\tDelete Group Members\n\n");
- net_common_methods_usage(argc, argv);
- net_common_flags_usage(argc, argv);
+ net_common_methods_usage(c, argc, argv);
+ net_common_flags_usage(c, argc, argv);
d_printf("\t-C or --comment=<comment>\tdescriptive comment (for add only)\n");
d_printf("\t-c or --container=<container>\tLDAP container, defaults to cn=Users (for add in ADS only)\n");
d_printf("\t-L or --localgroup\t\tWhen adding groups, create a local group (alias)\n");
return -1;
}
-int net_help_join(int argc, const char **argv)
+int net_help_join(struct net_context *c, int argc, const char **argv)
{
d_printf("\nnet [<method>] join [misc. options]\n"
"\tjoins this server to a domain\n");
d_printf("Valid methods: (auto-detected if not specified)\n");
d_printf("\tads\t\t\t\tActive Directory (LDAP/Kerberos)\n");
d_printf("\trpc\t\t\t\tDCE-RPC\n");
- net_common_flags_usage(argc, argv);
+ net_common_flags_usage(c, argc, argv);
return -1;
}
-int net_help_share(int argc, const char **argv)
+int net_help_share(struct net_context *c, int argc, const char **argv)
{
d_printf(
"\nnet [<method>] share [misc. options] [targets] \n"
@@ -145,8 +145,8 @@ int net_help_share(int argc, const char **argv)
"\n\tMigrates shares (including directories, files) from remote\n"
"\tto local server\n\n"
);
- net_common_methods_usage(argc, argv);
- net_common_flags_usage(argc, argv);
+ net_common_methods_usage(c, argc, argv);
+ net_common_flags_usage(c, argc, argv);
d_printf(
"\t-C or --comment=<comment>\tdescriptive comment (for add only)\n"
"\t-M or --maxusers=<num>\t\tmax users allowed for share\n"
@@ -159,7 +159,7 @@ int net_help_share(int argc, const char **argv)
return -1;
}
-int net_help_file(int argc, const char **argv)
+int net_help_file(struct net_context *c, int argc, const char **argv)
{
d_printf("net [<method>] file [misc. options] [targets]\n"\
"\tlists all open files on file server\n\n");
@@ -171,12 +171,12 @@ int net_help_file(int argc, const char **argv)
d_printf("net [rap] file INFO <id> [misc. options] [targets]\n"\
"\tdisplays information about the specified open file\n");
- net_common_methods_usage(argc, argv);
- net_common_flags_usage(argc, argv);
+ net_common_methods_usage(c, argc, argv);
+ net_common_flags_usage(c, argc, argv);
return -1;
}
-int net_help_printer(int argc, const char **argv)
+int net_help_printer(struct net_context *c, int argc, const char **argv)
{
d_printf("net rpc printer LIST [printer] [misc. options] [targets]\n"\
"\tlists all printers on print-server\n\n");
@@ -198,8 +198,8 @@ int net_help_printer(int argc, const char **argv)
d_printf("net rpc printer MIGRATE ALL [printer] [misc. options] [targets]"\
"\n\tmigrates drivers, forms, queues, settings and acls from\n"\
"\tremote to local print-server\n\n");
- net_common_methods_usage(argc, argv);
- net_common_flags_usage(argc, argv);
+ net_common_methods_usage(c, argc, argv);
+ net_common_flags_usage(c, argc, argv);
d_printf(
"\t-v or --verbose\t\t\tgive verbose output\n"
"\t --destination\t\tmigration target server (default: localhost)\n");
@@ -208,7 +208,7 @@ int net_help_printer(int argc, const char **argv)
}
-int net_help_status(int argc, const char **argv)
+int net_help_status(struct net_context *c, int argc, const char **argv)
{
d_printf(" net status sessions [parseable] "
"Show list of open sessions\n");
@@ -217,7 +217,7 @@ int net_help_status(int argc, const char **argv)
return -1;
}
-static int net_usage(int argc, const char **argv)
+static int net_usage(struct net_context *c, int argc, const char **argv)
{
d_printf(" net time\t\tto view or set time information\n"\
" net lookup\t\tto lookup host name or ip address\n"\
@@ -243,14 +243,14 @@ static int net_usage(int argc, const char **argv)
" net rpc <command>\tto run RPC commands\n"\
"\n"\
"Type \"net help <option>\" to get more information on that option\n");
- net_common_flags_usage(argc, argv);
+ net_common_flags_usage(c, argc, argv);
return -1;
}
/*
handle "net help *" subcommands
*/
-int net_help(int argc, const char **argv)
+int net_help(struct net_context *c, int argc, const char **argv)
{
struct functable func[] = {
{"ADS", net_ads_help},
@@ -284,5 +284,5 @@ int net_help(int argc, const char **argv)
{"HELP", help_usage},
{NULL, NULL}};
- return net_run_function(argc, argv, func, net_usage);
+ return net_run_function(c, argc, argv, func, net_usage);
}
diff --git a/source3/utils/net_idmap.c b/source3/utils/net_idmap.c
index b0024895f73..74992933bad 100644
--- a/source3/utils/net_idmap.c
+++ b/source3/utils/net_idmap.c
@@ -14,7 +14,8 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
#include "includes.h"
#include "utils/net.h"
@@ -54,12 +55,12 @@ static int net_idmap_dump_one_entry(TDB_CONTEXT *tdb,
/***********************************************************
Dump the current idmap
**********************************************************/
-static int net_idmap_dump(int argc, const char **argv)
+static int net_idmap_dump(struct net_context *c, int argc, const char **argv)
{
TDB_CONTEXT *idmap_tdb;
if ( argc != 1 )
- return net_help_idmap( argc, argv );
+ return net_help_idmap(c, argc, argv );
idmap_tdb = tdb_open_log(argv[0], 0, TDB_DEFAULT, O_RDONLY, 0);
@@ -79,7 +80,7 @@ static int net_idmap_dump(int argc, const char **argv)
Write entries from stdin to current local idmap
**********************************************************/
-static int net_idmap_restore(int argc, const char **argv)
+static int net_idmap_restore(struct net_context *c, int argc, const char **argv)
{
TALLOC_CTX *ctx;
FILE *input;
@@ -171,13 +172,13 @@ static int net_idmap_restore(int argc, const char **argv)
/***********************************************************
Delete a SID mapping from a winbindd_idmap.tdb
**********************************************************/
-static int net_idmap_delete(int argc, const char **argv)
+static int net_idmap_delete(struct net_context *c, int argc, const char **argv)
{
d_printf("Not Implemented yet\n");
return -1;
}
-static int net_idmap_set(int argc, const char **argv)
+static int net_idmap_set(struct net_context *c, int argc, const char **argv)
{
d_printf("Not Implemented yet\n");
return -1;
@@ -206,7 +207,7 @@ bool idmap_store_secret(const char *backend, bool alloc,
}
-static int net_idmap_secret(int argc, const char **argv)
+static int net_idmap_secret(struct net_context *c, int argc, const char **argv)
{
TALLOC_CTX *ctx;
const char *secret;
@@ -217,7 +218,7 @@ static int net_idmap_secret(int argc, const char **argv)
bool ret;
if (argc != 2) {
- return net_help_idmap(argc, argv);
+ return net_help_idmap(c, argc, argv);
}
secret = argv[1];
@@ -276,7 +277,7 @@ static int net_idmap_secret(int argc, const char **argv)
return 0;
}
-int net_help_idmap(int argc, const char **argv)
+int net_help_idmap(struct net_context *c, int argc, const char **argv)
{
d_printf("net idmap dump <inputfile>\n"\
" Dump current id mapping\n");
@@ -292,7 +293,7 @@ int net_help_idmap(int argc, const char **argv)
return -1;
}
-static int net_idmap_aclmapset(int argc, const char **argv)
+static int net_idmap_aclmapset(struct net_context *c, int argc, const char **argv)
{
TALLOC_CTX *mem_ctx;
int result = -1;
@@ -359,7 +360,7 @@ fail:
/***********************************************************
Look at the current idmap
**********************************************************/
-int net_idmap(int argc, const char **argv)
+int net_idmap(struct net_context *c, int argc, const char **argv)
{
struct functable func[] = {
{"dump", net_idmap_dump},
@@ -372,7 +373,7 @@ int net_idmap(int argc, const char **argv)
{NULL, NULL}
};
- return net_run_function(argc, argv, func, net_help_idmap);
+ return net_run_function(c, argc, argv, func, net_help_idmap);
}
diff --git a/source3/utils/net_lookup.c b/source3/utils/net_lookup.c
index ba4e32ae84e..f8491a2a2ac 100644
--- a/source3/utils/net_lookup.c
+++ b/source3/utils/net_lookup.c
@@ -19,7 +19,7 @@
#include "includes.h"
#include "utils/net.h"
-int net_lookup_usage(int argc, const char **argv)
+int net_lookup_usage(struct net_context *c, int argc, const char **argv)
{
d_printf(
" net lookup [host] HOSTNAME[#<type>]\n\tgives IP for a hostname\n\n"
@@ -36,7 +36,7 @@ int net_lookup_usage(int argc, const char **argv)
}
/* lookup a hostname giving an IP */
-static int net_lookup_host(int argc, const char **argv)
+static int net_lookup_host(struct net_context *c, int argc, const char **argv)
{
struct sockaddr_storage ss;
int name_type = 0x20;
@@ -45,7 +45,7 @@ static int net_lookup_host(int argc, const char **argv)
char *p;
if (argc == 0)
- return net_lookup_usage(argc, argv);
+ return net_lookup_usage(c, argc, argv);
p = strchr_m(name,'#');
if (p) {
@@ -88,7 +88,7 @@ static void print_ldap_srvlist(struct dns_rr_srv *dclist, int numdcs )
}
#endif
-static int net_lookup_ldap(int argc, const char **argv)
+static int net_lookup_ldap(struct net_context *c, int argc, const char **argv)
{
#ifdef HAVE_ADS
const char *domain;
@@ -104,7 +104,7 @@ static int net_lookup_ldap(int argc, const char **argv)
if (argc > 0)
domain = argv[0];
else
- domain = opt_target_workgroup;
+ domain = c->opt_target_workgroup;
sitename = sitename_fetch(domain);
@@ -171,7 +171,7 @@ static int net_lookup_ldap(int argc, const char **argv)
return -1;
}
-static int net_lookup_dc(int argc, const char **argv)
+static int net_lookup_dc(struct net_context *c, int argc, const char **argv)
{
struct ip_service *ip_list;
struct sockaddr_storage ss;
@@ -185,7 +185,7 @@ static int net_lookup_dc(int argc, const char **argv)
if (sec_ads) {
domain = lp_realm();
} else {
- domain = opt_target_workgroup;
+ domain = c->opt_target_workgroup;
}
if (argc > 0)
@@ -216,7 +216,7 @@ static int net_lookup_dc(int argc, const char **argv)
return 0;
}
-static int net_lookup_pdc(int argc, const char **argv)
+static int net_lookup_pdc(struct net_context *c, int argc, const char **argv)
{
struct sockaddr_storage ss;
char *pdc_str = NULL;
@@ -226,7 +226,7 @@ static int net_lookup_pdc(int argc, const char **argv)
if (lp_security() == SEC_ADS) {
domain = lp_realm();
} else {
- domain = opt_target_workgroup;
+ domain = c->opt_target_workgroup;
}
if (argc > 0)
@@ -244,10 +244,10 @@ static int net_lookup_pdc(int argc, const char **argv)
}
-static int net_lookup_master(int argc, const char **argv)
+static int net_lookup_master(struct net_context *c, int argc, const char **argv)
{
struct sockaddr_storage master_ss;
- const char *domain=opt_target_workgroup;
+ const char *domain = c->opt_target_workgroup;
char addr[INET6_ADDRSTRLEN];
if (argc > 0)
@@ -260,7 +260,7 @@ static int net_lookup_master(int argc, const char **argv)
return 0;
}
-static int net_lookup_kdc(int argc, const char **argv)
+static int net_lookup_kdc(struct net_context *c, int argc, const char **argv)
{
#ifdef HAVE_KRB5
krb5_error_code rc;
@@ -311,7 +311,7 @@ static int net_lookup_kdc(int argc, const char **argv)
return -1;
}
-static int net_lookup_name(int argc, const char **argv)
+static int net_lookup_name(struct net_context *c, int argc, const char **argv)
{
const char *dom, *name;
DOM_SID sid;
@@ -333,7 +333,7 @@ static int net_lookup_name(int argc, const char **argv)
return 0;
}
-static int net_lookup_sid(int argc, const char **argv)
+static int net_lookup_sid(struct net_context *c, int argc, const char **argv)
{
const char *dom, *name;
DOM_SID sid;
@@ -360,7 +360,7 @@ static int net_lookup_sid(int argc, const char **argv)
return 0;
}
-static int net_lookup_dsgetdcname(int argc, const char **argv)
+static int net_lookup_dsgetdcname(struct net_context *c, int argc, const char **argv)
{
NTSTATUS status;
const char *domain_name = NULL;
@@ -422,7 +422,7 @@ static int net_lookup_dsgetdcname(int argc, const char **argv)
/* lookup hosts or IP addresses using internal samba lookup fns */
-int net_lookup(int argc, const char **argv)
+int net_lookup(struct net_context *c, int argc, const char **argv)
{
int i;
@@ -441,11 +441,11 @@ int net_lookup(int argc, const char **argv)
if (argc < 1) {
d_printf("\nUsage: \n");
- return net_lookup_usage(argc, argv);
+ return net_lookup_usage(c, argc, argv);
}
for (i=0; table[i].funcname; i++) {
if (StrCaseCmp(argv[0], table[i].funcname) == 0)
- return table[i].fn(argc-1, argv+1);
+ return table[i].fn(c, argc-1, argv+1);
}
/* Default to lookup a hostname so 'net lookup foo#1b' can be
@@ -453,5 +453,5 @@ int net_lookup(int argc, const char **argv)
is a bit confusing as non #00 names can't really be
considered hosts as such. */
- return net_lookup_host(argc, argv);
+ return net_lookup_host(c, argc, argv);
}
diff --git a/source3/utils/net_rap.c b/source3/utils/net_rap.c
index 3e53eb99a8d..cea3eaeca88 100644
--- a/source3/utils/net_rap.c
+++ b/source3/utils/net_rap.c
@@ -47,9 +47,9 @@ static int errmsg_not_implemented(void)
return 0;
}
-int net_rap_file_usage(int argc, const char **argv)
+int net_rap_file_usage(struct net_context *c, int argc, const char **argv)
{
- return net_help_file(argc, argv);
+ return net_help_file(c, argc, argv);
}
/***************************************************************************
@@ -74,16 +74,16 @@ static void one_file_fn(const char *pPath, const char *pUser, uint16 perms,
}
-static int rap_file_close(int argc, const char **argv)
+static int rap_file_close(struct net_context *c, int argc, const char **argv)
{
struct cli_state *cli;
int ret;
if (argc == 0) {
d_printf("\nMissing fileid of file to close\n\n");
- return net_rap_file_usage(argc, argv);
+ return net_rap_file_usage(c, argc, argv);
}
- if (!NT_STATUS_IS_OK(net_make_ipc_connection(0, &cli)))
+ if (!NT_STATUS_IS_OK(net_make_ipc_connection(c, 0, &cli)))
return -1;
ret = cli_NetFileClose(cli, atoi(argv[0]));
@@ -91,14 +91,14 @@ static int rap_file_close(int argc, const char **argv)
return ret;
}
-static int rap_file_info(int argc, const char **argv)
+static int rap_file_info(struct net_context *c, int argc, const char **argv)
{
struct cli_state *cli;
int ret;
if (argc == 0)
- return net_rap_file_usage(argc, argv);
+ return net_rap_file_usage(c, argc, argv);
- if (!NT_STATUS_IS_OK(net_make_ipc_connection(0, &cli)))
+ if (!NT_STATUS_IS_OK(net_make_ipc_connection(c, 0, &cli)))
return -1;
ret = cli_NetFileGetInfo(cli, atoi(argv[0]), one_file_fn);
@@ -106,15 +106,15 @@ static int rap_file_info(int argc, const char **argv)
return ret;
}
-static int rap_file_user(int argc, const char **argv)
+static int rap_file_user(struct net_context *c, int argc, const char **argv)
{
struct cli_state *cli;
int ret;
if (argc == 0)
- return net_rap_file_usage(argc, argv);
+ return net_rap_file_usage(c, argc, argv);
- if (!NT_STATUS_IS_OK(net_make_ipc_connection(0, &cli)))
+ if (!NT_STATUS_IS_OK(net_make_ipc_connection(c, 0, &cli)))
return -1;
/* list open files */
@@ -131,7 +131,7 @@ static int rap_file_user(int argc, const char **argv)
return ret;
}
-int net_rap_file(int argc, const char **argv)
+int net_rap_file(struct net_context *c, int argc, const char **argv)
{
struct functable func[] = {
{"CLOSE", rap_file_close},
@@ -144,7 +144,7 @@ int net_rap_file(int argc, const char **argv)
struct cli_state *cli;
int ret;
- if (!NT_STATUS_IS_OK(net_make_ipc_connection(0, &cli)))
+ if (!NT_STATUS_IS_OK(net_make_ipc_connection(c, 0, &cli)))
return -1;
/* list open files */
@@ -161,12 +161,12 @@ int net_rap_file(int argc, const char **argv)
return ret;
}
- return net_run_function(argc, argv, func, net_rap_file_usage);
+ return net_run_function(c, argc, argv, func, net_rap_file_usage);
}
-int net_rap_share_usage(int argc, const char **argv)
+int net_rap_share_usage(struct net_context *c, int argc, const char **argv)
{
- return net_help_share(argc, argv);
+ return net_help_share(c, argc, argv);
}
static void long_share_fn(const char *share_name, uint32 type,
@@ -182,17 +182,17 @@ static void share_fn(const char *share_name, uint32 type,
d_printf("%s\n", share_name);
}
-static int rap_share_delete(int argc, const char **argv)
+static int rap_share_delete(struct net_context *c, int argc, const char **argv)
{
struct cli_state *cli;
int ret;
if (argc == 0) {
d_printf("\n\nShare name not specified\n");
- return net_rap_share_usage(argc, argv);
+ return net_rap_share_usage(c, argc, argv);
}
- if (!NT_STATUS_IS_OK(net_make_ipc_connection(0, &cli)))
+ if (!NT_STATUS_IS_OK(net_make_ipc_connection(c, 0, &cli)))
return -1;
ret = cli_NetShareDelete(cli, argv[0]);
@@ -200,7 +200,7 @@ static int rap_share_delete(int argc, const char **argv)
return ret;
}
-static int rap_share_add(int argc, const char **argv)
+static int rap_share_add(struct net_context *c, int argc, const char **argv)
{
struct cli_state *cli;
int ret;
@@ -211,25 +211,25 @@ static int rap_share_add(int argc, const char **argv)
if (argc == 0) {
d_printf("\n\nShare name not specified\n");
- return net_rap_share_usage(argc, argv);
+ return net_rap_share_usage(c, argc, argv);
}
- if (!NT_STATUS_IS_OK(net_make_ipc_connection(0, &cli)))
+ if (!NT_STATUS_IS_OK(net_make_ipc_connection(c, 0, &cli)))
return -1;
sharename = SMB_STRDUP(argv[0]);
p = strchr(sharename, '=');
if (p == NULL) {
d_printf("Server path not specified\n");
- return net_rap_share_usage(argc, argv);
+ return net_rap_share_usage(c, argc, argv);
}
*p = 0;
strlcpy(sinfo.share_name, sharename, sizeof(sinfo.share_name));
sinfo.reserved1 = '\0';
sinfo.share_type = 0;
- sinfo.comment = smb_xstrdup(opt_comment);
+ sinfo.comment = smb_xstrdup(c->opt_comment);
sinfo.perms = 0;
- sinfo.maximum_users = opt_maxusers;
+ sinfo.maximum_users = c->opt_maxusers;
sinfo.active_users = 0;
sinfo.path = p+1;
memset(sinfo.password, '\0', sizeof(sinfo.password));
@@ -241,7 +241,7 @@ static int rap_share_add(int argc, const char **argv)
}
-int net_rap_share(int argc, const char **argv)
+int net_rap_share(struct net_context *c, int argc, const char **argv)
{
struct functable func[] = {
{"DELETE", rap_share_delete},
@@ -254,10 +254,10 @@ int net_rap_share(int argc, const char **argv)
struct cli_state *cli;
int ret;
- if (!NT_STATUS_IS_OK(net_make_ipc_connection(0, &cli)))
+ if (!NT_STATUS_IS_OK(net_make_ipc_connection(c, 0, &cli)))
return -1;
- if (opt_long_list_entries) {
+ if (c->opt_long_list_entries) {
d_printf(
"\nEnumerating shared resources (exports) on remote server:\n\n"\
"\nShare name Type Description\n"\
@@ -270,11 +270,10 @@ int net_rap_share(int argc, const char **argv)
return ret;
}
- return net_run_function(argc, argv, func, net_rap_share_usage);
+ return net_run_function(c, argc, argv, func, net_rap_share_usage);
}
-
-int net_rap_session_usage(int argc, const char **argv)
+int net_rap_session_usage(struct net_context *c, int argc, const char **argv)
{
d_printf(
"\nnet rap session [misc. options] [targets]"\
@@ -288,7 +287,7 @@ int net_rap_session_usage(int argc, const char **argv)
"\nnet rap session INFO <client_name>"\
"\n\tEnumerates all open files in specified session\n");
- net_common_flags_usage(argc, argv);
+ net_common_flags_usage(c, argc, argv);
return -1;
}
@@ -334,17 +333,17 @@ static void display_conns_func(uint16 conn_id, uint16 conn_type, uint16 opens,
netname, share_type[conn_type], opens);
}
-static int rap_session_info(int argc, const char **argv)
+static int rap_session_info(struct net_context *c, int argc, const char **argv)
{
const char *sessname;
struct cli_state *cli;
int ret;
- if (!NT_STATUS_IS_OK(net_make_ipc_connection(0, &cli)))
+ if (!NT_STATUS_IS_OK(net_make_ipc_connection(c, 0, &cli)))
return -1;
if (argc == 0)
- return net_rap_session_usage(argc, argv);
+ return net_rap_session_usage(c, argc, argv);
sessname = argv[0];
@@ -361,23 +360,23 @@ static int rap_session_info(int argc, const char **argv)
return ret;
}
-static int rap_session_delete(int argc, const char **argv)
+static int rap_session_delete(struct net_context *c, int argc, const char **argv)
{
struct cli_state *cli;
int ret;
- if (!NT_STATUS_IS_OK(net_make_ipc_connection(0, &cli)))
+ if (!NT_STATUS_IS_OK(net_make_ipc_connection(c, 0, &cli)))
return -1;
if (argc == 0)
- return net_rap_session_usage(argc, argv);
+ return net_rap_session_usage(c, argc, argv);
ret = cli_NetSessionDel(cli, argv[0]);
cli_shutdown(cli);
return ret;
}
-int net_rap_session(int argc, const char **argv)
+int net_rap_session(struct net_context *c, int argc, const char **argv)
{
struct functable func[] = {
{"INFO", rap_session_info},
@@ -390,7 +389,7 @@ int net_rap_session(int argc, const char **argv)
struct cli_state *cli;
int ret;
- if (!NT_STATUS_IS_OK(net_make_ipc_connection(0, &cli)))
+ if (!NT_STATUS_IS_OK(net_make_ipc_connection(c, 0, &cli)))
return -1;
d_printf("Computer User name "\
@@ -403,7 +402,7 @@ int net_rap_session(int argc, const char **argv)
return ret;
}
- return net_run_function(argc, argv, func, net_rap_session_usage);
+ return net_run_function(c, argc, argv, func, net_rap_session_usage);
}
/****************************************************************************
@@ -416,23 +415,23 @@ static void display_server_func(const char *name, uint32 m,
}
-int net_rap_server_usage(int argc, const char **argv)
+int net_rap_server_usage(struct net_context *c, int argc, const char **argv)
{
d_printf("net rap server [misc. options] [target]\n\t"\
"lists the servers in the specified domain or workgroup.\n");
d_printf("\n\tIf domain is not specified, it uses the current"\
" domain or workgroup as\n\tthe default.\n");
- net_common_flags_usage(argc, argv);
+ net_common_flags_usage(c, argc, argv);
return -1;
}
-static int net_rap_server_name(int argc, const char *argv[])
+static int net_rap_server_name(struct net_context *c, int argc, const char *argv[])
{
struct cli_state *cli;
char *name;
- if (!NT_STATUS_IS_OK(net_make_ipc_connection(0, &cli)))
+ if (!NT_STATUS_IS_OK(net_make_ipc_connection(c, 0, &cli)))
return -1;
if (!cli_get_server_name(NULL, cli, &name)) {
@@ -448,23 +447,23 @@ static int net_rap_server_name(int argc, const char *argv[])
return 0;
}
-int net_rap_server(int argc, const char **argv)
+int net_rap_server(struct net_context *c, int argc, const char **argv)
{
struct cli_state *cli;
int ret;
if (argc > 0) {
if (strequal(argv[0], "name")) {
- return net_rap_server_name(argc, argv);
+ return net_rap_server_name(c, argc, argv);
}
/* smb4k uses 'net [rap|rpc] server domain' to query servers in a domain */
/* Fall through for 'domain', any other forms will cause to show usage message */
if (!strequal(argv[0], "domain")) {
- return net_rap_server_usage(argc-1, argv+1);
+ return net_rap_server_usage(c, argc-1, argv+1);
}
}
- if (!NT_STATUS_IS_OK(net_make_ipc_connection(0, &cli)))
+ if (!NT_STATUS_IS_OK(net_make_ipc_connection(c, 0, &cli)))
return -1;
d_printf("\nEnumerating servers in this domain or workgroup: \n\n"\
@@ -477,22 +476,21 @@ int net_rap_server(int argc, const char **argv)
return ret;
}
-int net_rap_domain_usage(int argc, const char **argv)
+int net_rap_domain_usage(struct net_context *c, int argc, const char **argv)
{
d_printf("net rap domain [misc. options] [target]\n\tlists the"\
" domains or workgroups visible on the current network\n");
- net_common_flags_usage(argc, argv);
+ net_common_flags_usage(c, argc, argv);
return -1;
}
-
-int net_rap_domain(int argc, const char **argv)
+int net_rap_domain(struct net_context *c, int argc, const char **argv)
{
struct cli_state *cli;
int ret;
- if (!NT_STATUS_IS_OK(net_make_ipc_connection(0, &cli)))
+ if (!NT_STATUS_IS_OK(net_make_ipc_connection(c, 0, &cli)))
return -1;
d_printf("\nEnumerating domains:\n\n"\
@@ -505,7 +503,7 @@ int net_rap_domain(int argc, const char **argv)
return ret;
}
-int net_rap_printq_usage(int argc, const char **argv)
+int net_rap_printq_usage(struct net_context *c, int argc, const char **argv)
{
d_printf(
"net rap printq [misc. options] [targets]\n"\
@@ -518,7 +516,7 @@ int net_rap_printq_usage(int argc, const char **argv)
"\tdeletes the specified job number on the target server, or the\n"\
"\tprinter queue if no job number is specified\n");
- net_common_flags_usage(argc, argv);
+ net_common_flags_usage(c, argc, argv);
return -1;
}
@@ -581,15 +579,15 @@ static void enum_jobs(uint16 jobid, const char *ownername,
"------------------------------------------------------------------"\
"-------------\n"
-static int rap_printq_info(int argc, const char **argv)
+static int rap_printq_info(struct net_context *c, int argc, const char **argv)
{
struct cli_state *cli;
int ret;
if (argc == 0)
- return net_rap_printq_usage(argc, argv);
+ return net_rap_printq_usage(c, argc, argv);
- if (!NT_STATUS_IS_OK(net_make_ipc_connection(0, &cli)))
+ if (!NT_STATUS_IS_OK(net_make_ipc_connection(c, 0, &cli)))
return -1;
d_printf(PRINTQ_ENUM_DISPLAY, cli->desthost); /* list header */
@@ -598,15 +596,15 @@ static int rap_printq_info(int argc, const char **argv)
return ret;
}
-static int rap_printq_delete(int argc, const char **argv)
+static int rap_printq_delete(struct net_context *c, int argc, const char **argv)
{
struct cli_state *cli;
int ret;
if (argc == 0)
- return net_rap_printq_usage(argc, argv);
+ return net_rap_printq_usage(c, argc, argv);
- if (!NT_STATUS_IS_OK(net_make_ipc_connection(0, &cli)))
+ if (!NT_STATUS_IS_OK(net_make_ipc_connection(c, 0, &cli)))
return -1;
ret = cli_printjob_del(cli, atoi(argv[0]));
@@ -614,7 +612,7 @@ static int rap_printq_delete(int argc, const char **argv)
return ret;
}
-int net_rap_printq(int argc, const char **argv)
+int net_rap_printq(struct net_context *c, int argc, const char **argv)
{
struct cli_state *cli;
int ret;
@@ -626,7 +624,7 @@ int net_rap_printq(int argc, const char **argv)
};
if (argc == 0) {
- if (!NT_STATUS_IS_OK(net_make_ipc_connection(0, &cli)))
+ if (!NT_STATUS_IS_OK(net_make_ipc_connection(c, 0, &cli)))
return -1;
d_printf(PRINTQ_ENUM_DISPLAY, cli->desthost); /* list header */
@@ -635,13 +633,12 @@ int net_rap_printq(int argc, const char **argv)
return ret;
}
- return net_run_function(argc, argv, func, net_rap_printq_usage);
+ return net_run_function(c, argc, argv, func, net_rap_printq_usage);
}
-
-static int net_rap_user_usage(int argc, const char **argv)
+static int net_rap_user_usage(struct net_context *c, int argc, const char **argv)
{
- return net_help_user(argc, argv);
+ return net_help_user(c, argc, argv);
}
static void user_fn(const char *user_name, void *state)
@@ -662,17 +659,17 @@ static void group_member_fn(const char *user_name, void *state)
d_printf("%-21.21s\n", user_name);
}
-static int rap_user_delete(int argc, const char **argv)
+static int rap_user_delete(struct net_context *c, int argc, const char **argv)
{
struct cli_state *cli;
int ret;
if (argc == 0) {
d_printf("\n\nUser name not specified\n");
- return net_rap_user_usage(argc, argv);
+ return net_rap_user_usage(c, argc, argv);
}
- if (!NT_STATUS_IS_OK(net_make_ipc_connection(0, &cli)))
+ if (!NT_STATUS_IS_OK(net_make_ipc_connection(c, 0, &cli)))
return -1;
ret = cli_NetUserDelete(cli, argv[0]);
@@ -680,7 +677,7 @@ static int rap_user_delete(int argc, const char **argv)
return ret;
}
-static int rap_user_add(int argc, const char **argv)
+static int rap_user_add(struct net_context *c, int argc, const char **argv)
{
struct cli_state *cli;
int ret;
@@ -688,19 +685,19 @@ static int rap_user_add(int argc, const char **argv)
if (argc == 0) {
d_printf("\n\nUser name not specified\n");
- return net_rap_user_usage(argc, argv);
+ return net_rap_user_usage(c, argc, argv);
}
- if (!NT_STATUS_IS_OK(net_make_ipc_connection(0, &cli)))
+ if (!NT_STATUS_IS_OK(net_make_ipc_connection(c, 0, &cli)))
return -1;
safe_strcpy(userinfo.user_name, argv[0], sizeof(userinfo.user_name)-1);
- if (opt_flags == -1)
- opt_flags = 0x21;
+ if (c->opt_flags == -1)
+ c->opt_flags = 0x21;
- userinfo.userflags = opt_flags;
+ userinfo.userflags = c->opt_flags;
userinfo.reserved1 = '\0';
- userinfo.comment = smb_xstrdup(opt_comment);
+ userinfo.comment = smb_xstrdup(c->opt_comment);
userinfo.priv = 1;
userinfo.home_dir = NULL;
userinfo.logon_script = NULL;
@@ -711,16 +708,16 @@ static int rap_user_add(int argc, const char **argv)
return ret;
}
-static int rap_user_info(int argc, const char **argv)
+static int rap_user_info(struct net_context *c, int argc, const char **argv)
{
struct cli_state *cli;
int ret;
if (argc == 0) {
d_printf("\n\nUser name not specified\n");
- return net_rap_user_usage(argc, argv);
+ return net_rap_user_usage(c, argc, argv);
}
- if (!NT_STATUS_IS_OK(net_make_ipc_connection(0, &cli)))
+ if (!NT_STATUS_IS_OK(net_make_ipc_connection(c, 0, &cli)))
return -1;
ret = cli_NetUserGetGroups(cli, argv[0], group_member_fn, NULL);
@@ -728,7 +725,7 @@ static int rap_user_info(int argc, const char **argv)
return ret;
}
-int net_rap_user(int argc, const char **argv)
+int net_rap_user(struct net_context *c, int argc, const char **argv)
{
int ret = -1;
struct functable func[] = {
@@ -740,9 +737,9 @@ int net_rap_user(int argc, const char **argv)
if (argc == 0) {
struct cli_state *cli;
- if (!NT_STATUS_IS_OK(net_make_ipc_connection(0, &cli)))
+ if (!NT_STATUS_IS_OK(net_make_ipc_connection(c, 0, &cli)))
goto done;
- if (opt_long_list_entries) {
+ if (c->opt_long_list_entries) {
d_printf("\nUser name Comment"\
"\n-----------------------------\n");
ret = cli_RNetUserEnum(cli, long_user_fn, NULL);
@@ -754,7 +751,7 @@ int net_rap_user(int argc, const char **argv)
goto done;
}
- ret = net_run_function(argc, argv, func, net_rap_user_usage);
+ ret = net_run_function(c, argc, argv, func, net_rap_user_usage);
done:
if (ret != 0) {
DEBUG(1, ("Net user returned: %d\n", ret));
@@ -763,9 +760,9 @@ int net_rap_user(int argc, const char **argv)
}
-int net_rap_group_usage(int argc, const char **argv)
+int net_rap_group_usage(struct net_context *c, int argc, const char **argv)
{
- return net_help_group(argc, argv);
+ return net_help_group(c, argc, argv);
}
static void long_group_fn(const char *group_name, const char *comment,
@@ -779,16 +776,16 @@ static void group_fn(const char *group_name, void *state)
d_printf("%-21.21s\n", group_name);
}
-static int rap_group_delete(int argc, const char **argv)
+static int rap_group_delete(struct net_context *c, int argc, const char **argv)
{
struct cli_state *cli;
int ret;
if (argc == 0) {
d_printf("\n\nGroup name not specified\n");
- return net_rap_group_usage(argc, argv);
+ return net_rap_group_usage(c, argc, argv);
}
- if (!NT_STATUS_IS_OK(net_make_ipc_connection(0, &cli)))
+ if (!NT_STATUS_IS_OK(net_make_ipc_connection(c, 0, &cli)))
return -1;
ret = cli_NetGroupDelete(cli, argv[0]);
@@ -796,7 +793,7 @@ static int rap_group_delete(int argc, const char **argv)
return ret;
}
-static int rap_group_add(int argc, const char **argv)
+static int rap_group_add(struct net_context *c, int argc, const char **argv)
{
struct cli_state *cli;
int ret;
@@ -804,23 +801,23 @@ static int rap_group_add(int argc, const char **argv)
if (argc == 0) {
d_printf("\n\nGroup name not specified\n");
- return net_rap_group_usage(argc, argv);
+ return net_rap_group_usage(c, argc, argv);
}
- if (!NT_STATUS_IS_OK(net_make_ipc_connection(0, &cli)))
+ if (!NT_STATUS_IS_OK(net_make_ipc_connection(c, 0, &cli)))
return -1;
/* BB check for length 21 or smaller explicitly ? BB */
safe_strcpy(grinfo.group_name, argv[0], sizeof(grinfo.group_name)-1);
grinfo.reserved1 = '\0';
- grinfo.comment = smb_xstrdup(opt_comment);
+ grinfo.comment = smb_xstrdup(c->opt_comment);
ret = cli_NetGroupAdd(cli, &grinfo);
cli_shutdown(cli);
return ret;
}
-int net_rap_group(int argc, const char **argv)
+int net_rap_group(struct net_context *c, int argc, const char **argv)
{
struct functable func[] = {
{"ADD", rap_group_add},
@@ -831,9 +828,9 @@ int net_rap_group(int argc, const char **argv)
if (argc == 0) {
struct cli_state *cli;
int ret;
- if (!NT_STATUS_IS_OK(net_make_ipc_connection(0, &cli)))
+ if (!NT_STATUS_IS_OK(net_make_ipc_connection(c, 0, &cli)))
return -1;
- if (opt_long_list_entries) {
+ if (c->opt_long_list_entries) {
d_printf("Group name Comment\n");
d_printf("-----------------------------\n");
ret = cli_RNetGroupEnum(cli, long_group_fn, NULL);
@@ -845,10 +842,10 @@ int net_rap_group(int argc, const char **argv)
return ret;
}
- return net_run_function(argc, argv, func, net_rap_group_usage);
+ return net_run_function(c, argc, argv, func, net_rap_group_usage);
}
-int net_rap_groupmember_usage(int argc, const char **argv)
+int net_rap_groupmember_usage(struct net_context *c, int argc, const char **argv)
{
d_printf(
"net rap groupmember LIST <group> [misc. options] [targets]"\
@@ -858,21 +855,21 @@ int net_rap_groupmember_usage(int argc, const char **argv)
"\nnet rap groupmember ADD <group> <user> [misc. options] [targets]"\
"\n\t Add specified user to specified group\n");
- net_common_flags_usage(argc, argv);
+ net_common_flags_usage(c, argc, argv);
return -1;
}
-static int rap_groupmember_add(int argc, const char **argv)
+static int rap_groupmember_add(struct net_context *c, int argc, const char **argv)
{
struct cli_state *cli;
int ret;
if (argc != 2) {
d_printf("\n\nGroup or user name not specified\n");
- return net_rap_groupmember_usage(argc, argv);
+ return net_rap_groupmember_usage(c, argc, argv);
}
- if (!NT_STATUS_IS_OK(net_make_ipc_connection(0, &cli)))
+ if (!NT_STATUS_IS_OK(net_make_ipc_connection(c, 0, &cli)))
return -1;
ret = cli_NetGroupAddUser(cli, argv[0], argv[1]);
@@ -880,16 +877,16 @@ static int rap_groupmember_add(int argc, const char **argv)
return ret;
}
-static int rap_groupmember_delete(int argc, const char **argv)
+static int rap_groupmember_delete(struct net_context *c, int argc, const char **argv)
{
struct cli_state *cli;
int ret;
if (argc != 2) {
d_printf("\n\nGroup or user name not specified\n");
- return net_rap_groupmember_usage(argc, argv);
+ return net_rap_groupmember_usage(c, argc, argv);
}
- if (!NT_STATUS_IS_OK(net_make_ipc_connection(0, &cli)))
+ if (!NT_STATUS_IS_OK(net_make_ipc_connection(c, 0, &cli)))
return -1;
ret = cli_NetGroupDelUser(cli, argv[0], argv[1]);
@@ -897,16 +894,16 @@ static int rap_groupmember_delete(int argc, const char **argv)
return ret;
}
-static int rap_groupmember_list(int argc, const char **argv)
+static int rap_groupmember_list(struct net_context *c, int argc, const char **argv)
{
struct cli_state *cli;
int ret;
if (argc == 0) {
d_printf("\n\nGroup name not specified\n");
- return net_rap_groupmember_usage(argc, argv);
+ return net_rap_groupmember_usage(c, argc, argv);
}
- if (!NT_STATUS_IS_OK(net_make_ipc_connection(0, &cli)))
+ if (!NT_STATUS_IS_OK(net_make_ipc_connection(c, 0, &cli)))
return -1;
ret = cli_NetGroupGetUsers(cli, argv[0], group_member_fn, NULL );
@@ -914,7 +911,7 @@ static int rap_groupmember_list(int argc, const char **argv)
return ret;
}
-int net_rap_groupmember(int argc, const char **argv)
+int net_rap_groupmember(struct net_context *c, int argc, const char **argv)
{
struct functable func[] = {
{"ADD", rap_groupmember_add},
@@ -923,25 +920,25 @@ int net_rap_groupmember(int argc, const char **argv)
{NULL, NULL}
};
- return net_run_function(argc, argv, func, net_rap_groupmember_usage);
+ return net_run_function(c, argc, argv, func, net_rap_groupmember_usage);
}
-int net_rap_validate_usage(int argc, const char **argv)
+int net_rap_validate_usage(struct net_context *c, int argc, const char **argv)
{
d_printf("net rap validate <username> [password]\n"\
"\tValidate user and password to check whether they"\
" can access target server or domain\n");
- net_common_flags_usage(argc, argv);
+ net_common_flags_usage(c, argc, argv);
return -1;
}
-int net_rap_validate(int argc, const char **argv)
+int net_rap_validate(struct net_context *c, int argc, const char **argv)
{
return errmsg_not_implemented();
}
-int net_rap_service_usage(int argc, const char **argv)
+int net_rap_service_usage(struct net_context *c, int argc, const char **argv)
{
d_printf("net rap service [misc. options] [targets] \n"\
"\tlists all running service daemons on target server\n");
@@ -951,16 +948,16 @@ int net_rap_service_usage(int argc, const char **argv)
d_printf("\nnet rap service STOP <name> [misc. options] [targets]\n"\
"\n\tStop named service on remote server\n");
- net_common_flags_usage(argc, argv);
+ net_common_flags_usage(c, argc, argv);
return -1;
}
-static int rap_service_start(int argc, const char **argv)
+static int rap_service_start(struct net_context *c, int argc, const char **argv)
{
return errmsg_not_implemented();
}
-static int rap_service_stop(int argc, const char **argv)
+static int rap_service_stop(struct net_context *c, int argc, const char **argv)
{
return errmsg_not_implemented();
}
@@ -971,7 +968,7 @@ static void service_fn(const char *service_name, const char *dummy,
d_printf("%-21.21s\n", service_name);
}
-int net_rap_service(int argc, const char **argv)
+int net_rap_service(struct net_context *c, int argc, const char **argv)
{
struct functable func[] = {
{"START", rap_service_start},
@@ -982,10 +979,10 @@ int net_rap_service(int argc, const char **argv)
if (argc == 0) {
struct cli_state *cli;
int ret;
- if (!NT_STATUS_IS_OK(net_make_ipc_connection(0, &cli)))
+ if (!NT_STATUS_IS_OK(net_make_ipc_connection(c, 0, &cli)))
return -1;
- if (opt_long_list_entries) {
+ if (c->opt_long_list_entries) {
d_printf("Service name Comment\n");
d_printf("-----------------------------\n");
ret = cli_RNetServiceEnum(cli, long_group_fn, NULL);
@@ -995,10 +992,10 @@ int net_rap_service(int argc, const char **argv)
return ret;
}
- return net_run_function(argc, argv, func, net_rap_service_usage);
+ return net_run_function(c, argc, argv, func, net_rap_service_usage);
}
-int net_rap_password_usage(int argc, const char **argv)
+int net_rap_password_usage(struct net_context *c, int argc, const char **argv)
{
d_printf(
"net rap password <user> <oldpwo> <newpw> [misc. options] [target]\n"\
@@ -1008,15 +1005,15 @@ int net_rap_password_usage(int argc, const char **argv)
}
-int net_rap_password(int argc, const char **argv)
+int net_rap_password(struct net_context *c, int argc, const char **argv)
{
struct cli_state *cli;
int ret;
if (argc < 3)
- return net_rap_password_usage(argc, argv);
+ return net_rap_password_usage(c, argc, argv);
- if (!NT_STATUS_IS_OK(net_make_ipc_connection(0, &cli)))
+ if (!NT_STATUS_IS_OK(net_make_ipc_connection(c, 0, &cli)))
return -1;
/* BB Add check for password lengths? */
@@ -1025,7 +1022,7 @@ int net_rap_password(int argc, const char **argv)
return ret;
}
-int net_rap_admin_usage(int argc, const char **argv)
+int net_rap_admin_usage(struct net_context *c, int argc, const char **argv)
{
d_printf(
"net rap admin <remote command> [cmd args [env]] [misc. options] [targets]"\
@@ -1035,14 +1032,14 @@ int net_rap_admin_usage(int argc, const char **argv)
}
-int net_rap_admin(int argc, const char **argv)
+int net_rap_admin(struct net_context *c, int argc, const char **argv)
{
return errmsg_not_implemented();
}
/* The help subsystem for the RAP subcommand */
-int net_rap_usage(int argc, const char **argv)
+int net_rap_usage(struct net_context *c, int argc, const char **argv)
{
d_printf(" net rap domain \tto list domains \n"\
" net rap file \t\tto list open files on a server \n"\
@@ -1058,14 +1055,14 @@ int net_rap_usage(int argc, const char **argv)
" net rap help\n"\
"\nType \"net help <option>\" to get more information on that option\n\n");
- net_common_flags_usage(argc, argv);
+ net_common_flags_usage(c, argc, argv);
return -1;
}
/*
handle "net rap help *" subcommands
*/
-int net_rap_help(int argc, const char **argv)
+int net_rap_help(struct net_context *c, int argc, const char **argv)
{
struct functable func[] = {
{"FILE", net_rap_file_usage},
@@ -1083,12 +1080,12 @@ int net_rap_help(int argc, const char **argv)
{"PASSWORD", net_rap_password_usage},
{NULL, NULL}};
- return net_run_function(argc, argv, func, net_rap_usage);
+ return net_run_function(c, argc, argv, func, net_rap_usage);
}
/* Entry-point for all the RAP functions. */
-int net_rap(int argc, const char **argv)
+int net_rap(struct net_context *c, int argc, const char **argv)
{
struct functable func[] = {
{"FILE", net_rap_file},
@@ -1108,6 +1105,6 @@ int net_rap(int argc, const char **argv)
{NULL, NULL}
};
- return net_run_function(argc, argv, func, net_rap_usage);
+ return net_run_function(c, argc, argv, func, net_rap_usage);
}
diff --git a/source3/utils/net_registry.c b/source3/utils/net_registry.c
index 94a7d2d3594..89eadb50f97 100644
--- a/source3/utils/net_registry.c
+++ b/source3/utils/net_registry.c
@@ -115,7 +115,8 @@ done:
*
*/
-static int net_registry_enumerate(int argc, const char **argv)
+static int net_registry_enumerate(struct net_context *c, int argc,
+ const char **argv)
{
WERROR werr;
struct registry_key *key = NULL;
@@ -168,7 +169,8 @@ done:
return ret;
}
-static int net_registry_createkey(int argc, const char **argv)
+static int net_registry_createkey(struct net_context *c, int argc,
+ const char **argv)
{
WERROR werr;
enum winreg_CreateAction action;
@@ -221,7 +223,8 @@ done:
return ret;
}
-static int net_registry_deletekey(int argc, const char **argv)
+static int net_registry_deletekey(struct net_context *c, int argc,
+ const char **argv)
{
WERROR werr;
char *subkeyname;
@@ -260,7 +263,8 @@ done:
return ret;
}
-static int net_registry_getvalue(int argc, const char **argv)
+static int net_registry_getvalue(struct net_context *c, int argc,
+ const char **argv)
{
WERROR werr;
int ret = -1;
@@ -296,7 +300,8 @@ done:
return ret;
}
-static int net_registry_setvalue(int argc, const char **argv)
+static int net_registry_setvalue(struct net_context *c, int argc,
+ const char **argv)
{
WERROR werr;
struct registry_value value;
@@ -347,7 +352,8 @@ done:
return ret;
}
-static int net_registry_deletevalue(int argc, const char **argv)
+static int net_registry_deletevalue(struct net_context *c, int argc,
+ const char **argv)
{
WERROR werr;
struct registry_key *key = NULL;
@@ -380,7 +386,8 @@ done:
return ret;
}
-static int net_registry_getsd(int argc, const char **argv)
+static int net_registry_getsd(struct net_context *c, int argc,
+ const char **argv)
{
WERROR werr;
int ret = -1;
@@ -430,7 +437,7 @@ done:
return ret;
}
-int net_registry(int argc, const char **argv)
+int net_registry(struct net_context *c, int argc, const char **argv)
{
int ret = -1;
@@ -477,7 +484,7 @@ int net_registry(int argc, const char **argv)
return -1;
}
- ret = net_run_function2(argc, argv, "net registry", func);
+ ret = net_run_function2(c, argc, argv, "net registry", func);
return ret;
}
diff --git a/source3/utils/net_rpc.c b/source3/utils/net_rpc.c
index 24965755fbb..be4440110c9 100644
--- a/source3/utils/net_rpc.c
+++ b/source3/utils/net_rpc.c
@@ -105,7 +105,8 @@ NTSTATUS net_get_remote_domain_sid(struct cli_state *cli, TALLOC_CTX *mem_ctx,
* @return A shell status integer (0 for success)
*/
-int run_rpc_command(struct cli_state *cli_arg,
+int run_rpc_command(struct net_context *c,
+ struct cli_state *cli_arg,
const int pipe_idx,
int conn_flags,
rpc_command_fn fn,
@@ -121,7 +122,7 @@ int run_rpc_command(struct cli_state *cli_arg,
/* make use of cli_state handed over as an argument, if possible */
if (!cli_arg) {
- nt_status = net_make_ipc_connection(conn_flags, &cli);
+ nt_status = net_make_ipc_connection(c, conn_flags, &cli);
if (!NT_STATUS_IS_OK(nt_status)) {
DEBUG(1, ("failed to make ipc connection: %s\n",
nt_errstr(nt_status)));
@@ -175,7 +176,7 @@ int run_rpc_command(struct cli_state *cli_arg,
}
}
- nt_status = fn(domain_sid, domain_name, cli, pipe_hnd, mem_ctx, argc, argv);
+ nt_status = fn(c, domain_sid, domain_name, cli, pipe_hnd, mem_ctx, argc, argv);
if (!NT_STATUS_IS_OK(nt_status)) {
DEBUG(1, ("rpc command function failed! (%s)\n", nt_errstr(nt_status)));
@@ -214,7 +215,8 @@ int run_rpc_command(struct cli_state *cli_arg,
* @return Normal NTSTATUS return.
**/
-static NTSTATUS rpc_changetrustpw_internals(const DOM_SID *domain_sid,
+static NTSTATUS rpc_changetrustpw_internals(struct net_context *c,
+ const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
@@ -223,7 +225,7 @@ static NTSTATUS rpc_changetrustpw_internals(const DOM_SID *domain_sid,
const char **argv)
{
- return trust_pw_find_change_and_store_it(pipe_hnd, mem_ctx, opt_target_workgroup);
+ return trust_pw_find_change_and_store_it(pipe_hnd, mem_ctx, c->opt_target_workgroup);
}
/**
@@ -236,9 +238,9 @@ static NTSTATUS rpc_changetrustpw_internals(const DOM_SID *domain_sid,
* @return A shell status integer (0 for success)
**/
-int net_rpc_changetrustpw(int argc, const char **argv)
+int net_rpc_changetrustpw(struct net_context *c, int argc, const char **argv)
{
- return run_rpc_command(NULL, PI_NETLOGON, NET_FLAGS_ANONYMOUS | NET_FLAGS_PDC,
+ return run_rpc_command(c, NULL, PI_NETLOGON, NET_FLAGS_ANONYMOUS | NET_FLAGS_PDC,
rpc_changetrustpw_internals,
argc, argv);
}
@@ -263,7 +265,8 @@ int net_rpc_changetrustpw(int argc, const char **argv)
* @return Normal NTSTATUS return.
**/
-static NTSTATUS rpc_oldjoin_internals(const DOM_SID *domain_sid,
+static NTSTATUS rpc_oldjoin_internals(struct net_context *c,
+ const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
@@ -308,16 +311,16 @@ static NTSTATUS rpc_oldjoin_internals(const DOM_SID *domain_sid,
E_md4hash(trust_passwd, orig_trust_passwd_hash);
- result = trust_pw_change_and_store_it(pipe_hnd, mem_ctx, opt_target_workgroup,
+ result = trust_pw_change_and_store_it(pipe_hnd, mem_ctx, c->opt_target_workgroup,
orig_trust_passwd_hash,
sec_channel_type);
if (NT_STATUS_IS_OK(result))
- printf("Joined domain %s.\n",opt_target_workgroup);
+ printf("Joined domain %s.\n", c->opt_target_workgroup);
- if (!secrets_store_domain_sid(opt_target_workgroup, domain_sid)) {
- DEBUG(0, ("error storing domain sid for %s\n", opt_target_workgroup));
+ if (!secrets_store_domain_sid(c->opt_target_workgroup, domain_sid)) {
+ DEBUG(0, ("error storing domain sid for %s\n", c->opt_target_workgroup));
result = NT_STATUS_UNSUCCESSFUL;
}
@@ -334,9 +337,9 @@ static NTSTATUS rpc_oldjoin_internals(const DOM_SID *domain_sid,
* @return A shell status integer (0 for success)
**/
-static int net_rpc_perform_oldjoin(int argc, const char **argv)
+static int net_rpc_perform_oldjoin(struct net_context *c, int argc, const char **argv)
{
- return run_rpc_command(NULL, PI_NETLOGON,
+ return run_rpc_command(c, NULL, PI_NETLOGON,
NET_FLAGS_NO_PIPE | NET_FLAGS_ANONYMOUS | NET_FLAGS_PDC,
rpc_oldjoin_internals,
argc, argv);
@@ -354,9 +357,9 @@ static int net_rpc_perform_oldjoin(int argc, const char **argv)
* @return A shell status integer (0 for success)
**/
-static int net_rpc_oldjoin(int argc, const char **argv)
+static int net_rpc_oldjoin(struct net_context *c, int argc, const char **argv)
{
- int rc = net_rpc_perform_oldjoin(argc, argv);
+ int rc = net_rpc_perform_oldjoin(c, argc, argv);
if (rc) {
d_fprintf(stderr, "Failed to join domain\n");
@@ -372,7 +375,7 @@ static int net_rpc_oldjoin(int argc, const char **argv)
* stripped
**/
-static int rpc_join_usage(int argc, const char **argv)
+static int rpc_join_usage(struct net_context *c, int argc, const char **argv)
{
d_printf("net rpc join -U <username>[%%password] <type>[options]\n"\
"\t to join a domain with admin username & password\n"\
@@ -382,7 +385,7 @@ static int rpc_join_usage(int argc, const char **argv)
"\t\t PDC - Join as a PDC\n"\
"\t\t MEMBER - Join as a MEMBER server\n");
- net_common_flags_usage(argc, argv);
+ net_common_flags_usage(c, argc, argv);
return -1;
}
@@ -398,7 +401,7 @@ static int rpc_join_usage(int argc, const char **argv)
* for a username/password.
**/
-int net_rpc_join(int argc, const char **argv)
+int net_rpc_join(struct net_context *c, int argc, const char **argv)
{
if (lp_server_role() == ROLE_STANDALONE) {
d_printf("cannot join as standalone machine\n");
@@ -412,10 +415,10 @@ int net_rpc_join(int argc, const char **argv)
return -1;
}
- if ((net_rpc_perform_oldjoin(argc, argv) == 0))
+ if ((net_rpc_perform_oldjoin(c, argc, argv) == 0))
return 0;
- return net_rpc_join_newstyle(argc, argv);
+ return net_rpc_join_newstyle(c, argc, argv);
}
/**
@@ -434,7 +437,8 @@ int net_rpc_join(int argc, const char **argv)
* @return Normal NTSTATUS return.
**/
-NTSTATUS rpc_info_internals(const DOM_SID *domain_sid,
+NTSTATUS rpc_info_internals(struct net_context *c,
+ const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
@@ -495,9 +499,9 @@ NTSTATUS rpc_info_internals(const DOM_SID *domain_sid,
* stripped
**/
-int net_rpc_info(int argc, const char **argv)
+int net_rpc_info(struct net_context *c, int argc, const char **argv)
{
- return run_rpc_command(NULL, PI_SAMR, NET_FLAGS_PDC,
+ return run_rpc_command(c, NULL, PI_SAMR, NET_FLAGS_PDC,
rpc_info_internals,
argc, argv);
}
@@ -510,7 +514,7 @@ int net_rpc_info(int argc, const char **argv)
*
* @param domain_sid The domain sid acquired from the remote server
* @param cli A cli_state connected to the server.
- * @param mem_ctx Talloc context, destoyed on completion of the function.
+ * @param mem_ctx Talloc context, destoyed on completion of thea function.
* @param argc Standard main() style argc
* @param argv Standard main() style argv. Initial components are already
* stripped
@@ -518,7 +522,8 @@ int net_rpc_info(int argc, const char **argv)
* @return Normal NTSTATUS return.
**/
-static NTSTATUS rpc_getsid_internals(const DOM_SID *domain_sid,
+static NTSTATUS rpc_getsid_internals(struct net_context *c,
+ const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
@@ -547,9 +552,10 @@ static NTSTATUS rpc_getsid_internals(const DOM_SID *domain_sid,
* stripped
**/
-int net_rpc_getsid(int argc, const char **argv)
+int net_rpc_getsid(struct net_context *c, int argc, const char **argv)
{
- return run_rpc_command(NULL, PI_SAMR, NET_FLAGS_ANONYMOUS | NET_FLAGS_PDC,
+ return run_rpc_command(c, NULL, PI_SAMR,
+ NET_FLAGS_ANONYMOUS | NET_FLAGS_PDC,
rpc_getsid_internals,
argc, argv);
}
@@ -563,9 +569,9 @@ int net_rpc_getsid(int argc, const char **argv)
* stripped.
**/
-static int rpc_user_usage(int argc, const char **argv)
+static int rpc_user_usage(struct net_context *c, int argc, const char **argv)
{
- return net_help_user(argc, argv);
+ return net_help_user(c, argc, argv);
}
/**
@@ -578,7 +584,7 @@ static int rpc_user_usage(int argc, const char **argv)
* @return A shell status integer (0 for success)
**/
-static int rpc_user_add(int argc, const char **argv)
+static int rpc_user_add(struct net_context *c, int argc, const char **argv)
{
NET_API_STATUS status;
struct USER_INFO_1 info1;
@@ -586,7 +592,7 @@ static int rpc_user_add(int argc, const char **argv)
if (argc < 1) {
d_printf("User must be specified\n");
- rpc_user_usage(argc, argv);
+ rpc_user_usage(c, argc, argv);
return 0;
}
@@ -597,11 +603,12 @@ static int rpc_user_add(int argc, const char **argv)
info1.usri1_password = argv[1];
}
- status = NetUserAdd(opt_host, 1, (uint8_t *)&info1, &parm_error);
+ status = NetUserAdd(c->opt_host, 1, (uint8_t *)&info1, &parm_error);
if (status != 0) {
d_fprintf(stderr, "Failed to add user '%s' with: %s.\n",
- argv[0], libnetapi_get_error_string(netapi_ctx, status));
+ argv[0], libnetapi_get_error_string(c->netapi_ctx,
+ status));
return -1;
} else {
d_printf("Added user '%s'.\n", argv[0]);
@@ -626,7 +633,8 @@ static int rpc_user_add(int argc, const char **argv)
* @return Normal NTSTATUS return.
**/
-static NTSTATUS rpc_user_rename_internals(const DOM_SID *domain_sid,
+static NTSTATUS rpc_user_rename_internals(struct net_context *c,
+ const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
@@ -644,7 +652,7 @@ static NTSTATUS rpc_user_rename_internals(const DOM_SID *domain_sid,
if (argc != 2) {
d_printf("Old and new username must be specified\n");
- rpc_user_usage(argc, argv);
+ rpc_user_usage(c, argc, argv);
return NT_STATUS_OK;
}
@@ -738,9 +746,9 @@ static NTSTATUS rpc_user_rename_internals(const DOM_SID *domain_sid,
* @return A shell status integer (0 for success)
**/
-static int rpc_user_rename(int argc, const char **argv)
+static int rpc_user_rename(struct net_context *c, int argc, const char **argv)
{
- return run_rpc_command(NULL, PI_SAMR, 0, rpc_user_rename_internals,
+ return run_rpc_command(c, NULL, PI_SAMR, 0, rpc_user_rename_internals,
argc, argv);
}
@@ -754,22 +762,22 @@ static int rpc_user_rename(int argc, const char **argv)
* @return A shell status integer (0 for success)
**/
-static int rpc_user_delete(int argc, const char **argv)
+static int rpc_user_delete(struct net_context *c, int argc, const char **argv)
{
NET_API_STATUS status;
if (argc < 1) {
d_printf("User must be specified\n");
- rpc_user_usage(argc, argv);
+ rpc_user_usage(c, argc, argv);
return 0;
}
- status = NetUserDel(opt_host, argv[0]);
+ status = NetUserDel(c->opt_host, argv[0]);
if (status != 0) {
d_fprintf(stderr, "Failed to delete user '%s' with: %s.\n",
argv[0],
- libnetapi_get_error_string(netapi_ctx, status));
+ libnetapi_get_error_string(c->netapi_ctx, status));
return -1;
} else {
d_printf("Deleted user '%s'.\n", argv[0]);
@@ -794,7 +802,8 @@ static int rpc_user_delete(int argc, const char **argv)
* @return Normal NTSTATUS return.
**/
-static NTSTATUS rpc_user_password_internals(const DOM_SID *domain_sid,
+static NTSTATUS rpc_user_password_internals(struct net_context *c,
+ const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
@@ -812,7 +821,7 @@ static NTSTATUS rpc_user_password_internals(const DOM_SID *domain_sid,
if (argc < 1) {
d_printf("User must be specified\n");
- rpc_user_usage(argc, argv);
+ rpc_user_usage(c, argc, argv);
return NT_STATUS_OK;
}
@@ -911,9 +920,9 @@ static NTSTATUS rpc_user_password_internals(const DOM_SID *domain_sid,
* @return A shell status integer (0 for success)
**/
-static int rpc_user_password(int argc, const char **argv)
+static int rpc_user_password(struct net_context *c, int argc, const char **argv)
{
- return run_rpc_command(NULL, PI_SAMR, 0, rpc_user_password_internals,
+ return run_rpc_command(c, NULL, PI_SAMR, 0, rpc_user_password_internals,
argc, argv);
}
@@ -933,7 +942,8 @@ static int rpc_user_password(int argc, const char **argv)
* @return Normal NTSTATUS return.
**/
-static NTSTATUS rpc_user_info_internals(const DOM_SID *domain_sid,
+static NTSTATUS rpc_user_info_internals(struct net_context *c,
+ const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
@@ -954,7 +964,7 @@ static NTSTATUS rpc_user_info_internals(const DOM_SID *domain_sid,
if (argc < 1) {
d_printf("User must be specified\n");
- rpc_user_usage(argc, argv);
+ rpc_user_usage(c, argc, argv);
return NT_STATUS_OK;
}
/* Get sam policy handle */
@@ -1041,9 +1051,9 @@ static NTSTATUS rpc_user_info_internals(const DOM_SID *domain_sid,
* @return A shell status integer (0 for success)
**/
-static int rpc_user_info(int argc, const char **argv)
+static int rpc_user_info(struct net_context *c, int argc, const char **argv)
{
- return run_rpc_command(NULL, PI_SAMR, 0, rpc_user_info_internals,
+ return run_rpc_command(c, NULL, PI_SAMR, 0, rpc_user_info_internals,
argc, argv);
}
@@ -1063,7 +1073,8 @@ static int rpc_user_info(int argc, const char **argv)
* @return Normal NTSTATUS return.
**/
-static NTSTATUS rpc_user_list_internals(const DOM_SID *domain_sid,
+static NTSTATUS rpc_user_list_internals(struct net_context *c,
+ const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
@@ -1097,7 +1108,7 @@ static NTSTATUS rpc_user_list_internals(const DOM_SID *domain_sid,
}
/* Query domain users */
- if (opt_long_list_entries)
+ if (c->opt_long_list_entries)
d_printf("\nUser name Comment"\
"\n-----------------------------\n");
do {
@@ -1125,9 +1136,9 @@ static NTSTATUS rpc_user_list_internals(const DOM_SID *domain_sid,
for (i = 0; i < num_entries; i++) {
user = info.info1.entries[i].account_name.string;
- if (opt_long_list_entries)
+ if (c->opt_long_list_entries)
desc = info.info1.entries[i].description.string;
- if (opt_long_list_entries)
+ if (c->opt_long_list_entries)
printf("%-21.21s %s\n", user, desc);
else
printf("%s\n", user);
@@ -1145,7 +1156,7 @@ static NTSTATUS rpc_user_list_internals(const DOM_SID *domain_sid,
* stripped
**/
-int net_rpc_user(int argc, const char **argv)
+int net_rpc_user(struct net_context *c, int argc, const char **argv)
{
NET_API_STATUS status;
@@ -1158,47 +1169,51 @@ int net_rpc_user(int argc, const char **argv)
{NULL, NULL}
};
- status = libnetapi_init(&netapi_ctx);
+ status = libnetapi_init(&c->netapi_ctx);
if (status != 0) {
return -1;
}
- libnetapi_set_username(netapi_ctx, opt_user_name);
- libnetapi_set_password(netapi_ctx, opt_password);
+ libnetapi_set_username(c->netapi_ctx, c->opt_user_name);
+ libnetapi_set_password(c->netapi_ctx, c->opt_password);
if (argc == 0) {
- return run_rpc_command(NULL,PI_SAMR, 0,
+ return run_rpc_command(c, NULL,PI_SAMR, 0,
rpc_user_list_internals,
argc, argv);
}
- return net_run_function(argc, argv, func, rpc_user_usage);
+ return net_run_function(c, argc, argv, func, rpc_user_usage);
}
-static NTSTATUS rpc_sh_user_list(TALLOC_CTX *mem_ctx,
+static NTSTATUS rpc_sh_user_list(struct net_context *c,
+ TALLOC_CTX *mem_ctx,
struct rpc_sh_ctx *ctx,
struct rpc_pipe_client *pipe_hnd,
int argc, const char **argv)
{
- return rpc_user_list_internals(ctx->domain_sid, ctx->domain_name,
+ return rpc_user_list_internals(c, ctx->domain_sid, ctx->domain_name,
ctx->cli, pipe_hnd, mem_ctx,
argc, argv);
}
-static NTSTATUS rpc_sh_user_info(TALLOC_CTX *mem_ctx,
+static NTSTATUS rpc_sh_user_info(struct net_context *c,
+ TALLOC_CTX *mem_ctx,
struct rpc_sh_ctx *ctx,
struct rpc_pipe_client *pipe_hnd,
int argc, const char **argv)
{
- return rpc_user_info_internals(ctx->domain_sid, ctx->domain_name,
+ return rpc_user_info_internals(c, ctx->domain_sid, ctx->domain_name,
ctx->cli, pipe_hnd, mem_ctx,
argc, argv);
}
-static NTSTATUS rpc_sh_handle_user(TALLOC_CTX *mem_ctx,
+static NTSTATUS rpc_sh_handle_user(struct net_context *c,
+ TALLOC_CTX *mem_ctx,
struct rpc_sh_ctx *ctx,
struct rpc_pipe_client *pipe_hnd,
int argc, const char **argv,
NTSTATUS (*fn)(
+ struct net_context *c,
TALLOC_CTX *mem_ctx,
struct rpc_sh_ctx *ctx,
struct rpc_pipe_client *pipe_hnd,
@@ -1220,7 +1235,7 @@ static NTSTATUS rpc_sh_handle_user(TALLOC_CTX *mem_ctx,
ZERO_STRUCT(domain_pol);
ZERO_STRUCT(user_pol);
- result = net_rpc_lookup_name(mem_ctx, rpc_pipe_np_smb_conn(pipe_hnd),
+ result = net_rpc_lookup_name(c, mem_ctx, rpc_pipe_np_smb_conn(pipe_hnd),
argv[0], NULL, NULL, &sid, &type);
if (!NT_STATUS_IS_OK(result)) {
d_fprintf(stderr, "Could not lookup %s: %s\n", argv[0],
@@ -1267,7 +1282,7 @@ static NTSTATUS rpc_sh_handle_user(TALLOC_CTX *mem_ctx,
goto done;
}
- result = fn(mem_ctx, ctx, pipe_hnd, &user_pol, argc-1, argv+1);
+ result = fn(c, mem_ctx, ctx, pipe_hnd, &user_pol, argc-1, argv+1);
done:
if (is_valid_policy_hnd(&user_pol)) {
@@ -1282,7 +1297,8 @@ static NTSTATUS rpc_sh_handle_user(TALLOC_CTX *mem_ctx,
return result;
}
-static NTSTATUS rpc_sh_user_show_internals(TALLOC_CTX *mem_ctx,
+static NTSTATUS rpc_sh_user_show_internals(struct net_context *c,
+ TALLOC_CTX *mem_ctx,
struct rpc_sh_ctx *ctx,
struct rpc_pipe_client *pipe_hnd,
POLICY_HND *user_hnd,
@@ -1311,12 +1327,13 @@ static NTSTATUS rpc_sh_user_show_internals(TALLOC_CTX *mem_ctx,
return result;
}
-static NTSTATUS rpc_sh_user_show(TALLOC_CTX *mem_ctx,
+static NTSTATUS rpc_sh_user_show(struct net_context *c,
+ TALLOC_CTX *mem_ctx,
struct rpc_sh_ctx *ctx,
struct rpc_pipe_client *pipe_hnd,
int argc, const char **argv)
{
- return rpc_sh_handle_user(mem_ctx, ctx, pipe_hnd, argc, argv,
+ return rpc_sh_handle_user(c, mem_ctx, ctx, pipe_hnd, argc, argv,
rpc_sh_user_show_internals);
}
@@ -1331,7 +1348,8 @@ do { if (strequal(ctx->thiscmd, name)) { \
info->info21.fields_present |= SAMR_FIELD_##flag; } \
} while (0);
-static NTSTATUS rpc_sh_user_str_edit_internals(TALLOC_CTX *mem_ctx,
+static NTSTATUS rpc_sh_user_str_edit_internals(struct net_context *c,
+ TALLOC_CTX *mem_ctx,
struct rpc_sh_ctx *ctx,
struct rpc_pipe_client *pipe_hnd,
POLICY_HND *user_hnd,
@@ -1405,16 +1423,18 @@ do { if (strequal(ctx->thiscmd, name)) { \
newflags = oldflags & ~ACB_##rec; \
} } } while (0);
-static NTSTATUS rpc_sh_user_str_edit(TALLOC_CTX *mem_ctx,
+static NTSTATUS rpc_sh_user_str_edit(struct net_context *c,
+ TALLOC_CTX *mem_ctx,
struct rpc_sh_ctx *ctx,
struct rpc_pipe_client *pipe_hnd,
int argc, const char **argv)
{
- return rpc_sh_handle_user(mem_ctx, ctx, pipe_hnd, argc, argv,
+ return rpc_sh_handle_user(c, mem_ctx, ctx, pipe_hnd, argc, argv,
rpc_sh_user_str_edit_internals);
}
-static NTSTATUS rpc_sh_user_flag_edit_internals(TALLOC_CTX *mem_ctx,
+static NTSTATUS rpc_sh_user_flag_edit_internals(struct net_context *c,
+ TALLOC_CTX *mem_ctx,
struct rpc_sh_ctx *ctx,
struct rpc_pipe_client *pipe_hnd,
POLICY_HND *user_hnd,
@@ -1479,16 +1499,18 @@ static NTSTATUS rpc_sh_user_flag_edit_internals(TALLOC_CTX *mem_ctx,
return result;
}
-static NTSTATUS rpc_sh_user_flag_edit(TALLOC_CTX *mem_ctx,
+static NTSTATUS rpc_sh_user_flag_edit(struct net_context *c,
+ TALLOC_CTX *mem_ctx,
struct rpc_sh_ctx *ctx,
struct rpc_pipe_client *pipe_hnd,
int argc, const char **argv)
{
- return rpc_sh_handle_user(mem_ctx, ctx, pipe_hnd, argc, argv,
+ return rpc_sh_handle_user(c, mem_ctx, ctx, pipe_hnd, argc, argv,
rpc_sh_user_flag_edit_internals);
}
-struct rpc_sh_cmd *net_rpc_user_edit_cmds(TALLOC_CTX *mem_ctx,
+struct rpc_sh_cmd *net_rpc_user_edit_cmds(struct net_context *c,
+ TALLOC_CTX *mem_ctx,
struct rpc_sh_ctx *ctx)
{
static struct rpc_sh_cmd cmds[] = {
@@ -1529,7 +1551,8 @@ struct rpc_sh_cmd *net_rpc_user_edit_cmds(TALLOC_CTX *mem_ctx,
return cmds;
}
-struct rpc_sh_cmd *net_rpc_user_cmds(TALLOC_CTX *mem_ctx,
+struct rpc_sh_cmd *net_rpc_user_cmds(struct net_context *c,
+ TALLOC_CTX *mem_ctx,
struct rpc_sh_ctx *ctx)
{
static struct rpc_sh_cmd cmds[] = {
@@ -1561,9 +1584,9 @@ struct rpc_sh_cmd *net_rpc_user_cmds(TALLOC_CTX *mem_ctx,
* stripped.
**/
-static int rpc_group_usage(int argc, const char **argv)
+static int rpc_group_usage(struct net_context *c, int argc, const char **argv)
{
- return net_help_group(argc, argv);
+ return net_help_group(c, argc, argv);
}
/**
@@ -1582,7 +1605,8 @@ static int rpc_group_usage(int argc, const char **argv)
* @return Normal NTSTATUS return.
**/
-static NTSTATUS rpc_group_delete_internals(const DOM_SID *domain_sid,
+static NTSTATUS rpc_group_delete_internals(struct net_context *c,
+ const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
@@ -1605,7 +1629,7 @@ static NTSTATUS rpc_group_delete_internals(const DOM_SID *domain_sid,
if (argc < 1) {
d_printf("specify group\n");
- rpc_group_usage(argc,argv);
+ rpc_group_usage(c, argc,argv);
return NT_STATUS_OK; /* ok? */
}
@@ -1667,7 +1691,7 @@ static NTSTATUS rpc_group_delete_internals(const DOM_SID *domain_sid,
goto done;
}
- if (opt_verbose) {
+ if (c->opt_verbose) {
d_printf("Domain Group %s (rid: %d) has %d members\n",
argv[0],group_rid, rids->count);
}
@@ -1699,7 +1723,7 @@ static NTSTATUS rpc_group_delete_internals(const DOM_SID *domain_sid,
}
if (info->info21.primary_gid == group_rid) {
- if (opt_verbose) {
+ if (c->opt_verbose) {
d_printf("Group is primary group of %s\n",
info->info21.account_name.string);
}
@@ -1719,7 +1743,7 @@ static NTSTATUS rpc_group_delete_internals(const DOM_SID *domain_sid,
/* remove all group members */
for (i = 0; i < rids->count; i++)
{
- if (opt_verbose)
+ if (c->opt_verbose)
d_printf("Remove group member %d...",
rids->rids[i]);
result = rpccli_samr_DeleteGroupMember(pipe_hnd, mem_ctx,
@@ -1727,10 +1751,10 @@ static NTSTATUS rpc_group_delete_internals(const DOM_SID *domain_sid,
rids->rids[i]);
if (NT_STATUS_IS_OK(result)) {
- if (opt_verbose)
+ if (c->opt_verbose)
d_printf("ok\n");
} else {
- if (opt_verbose)
+ if (c->opt_verbose)
d_printf("failed\n");
goto done;
}
@@ -1763,9 +1787,8 @@ static NTSTATUS rpc_group_delete_internals(const DOM_SID *domain_sid,
goto done;
}
-
if (NT_STATUS_IS_OK(result)) {
- if (opt_verbose)
+ if (c->opt_verbose)
d_printf("Deleted %s '%s'\n",sid_type_lookup(name_types.ids[0]),argv[0]);
} else {
d_fprintf(stderr, "Deleting of %s failed: %s\n",argv[0],
@@ -1777,13 +1800,14 @@ static NTSTATUS rpc_group_delete_internals(const DOM_SID *domain_sid,
}
-static int rpc_group_delete(int argc, const char **argv)
+static int rpc_group_delete(struct net_context *c, int argc, const char **argv)
{
- return run_rpc_command(NULL, PI_SAMR, 0, rpc_group_delete_internals,
+ return run_rpc_command(c, NULL, PI_SAMR, 0, rpc_group_delete_internals,
argc,argv);
}
-static NTSTATUS rpc_group_add_internals(const DOM_SID *domain_sid,
+static NTSTATUS rpc_group_add_internals(struct net_context *c,
+ const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
@@ -1799,7 +1823,7 @@ static NTSTATUS rpc_group_add_internals(const DOM_SID *domain_sid,
if (argc != 1) {
d_printf("Group name must be specified\n");
- rpc_group_usage(argc, argv);
+ rpc_group_usage(c, argc, argv);
return NT_STATUS_OK;
}
@@ -1832,11 +1856,11 @@ static NTSTATUS rpc_group_add_internals(const DOM_SID *domain_sid,
&rid);
if (!NT_STATUS_IS_OK(result)) goto done;
- if (strlen(opt_comment) == 0) goto done;
+ if (strlen(c->opt_comment) == 0) goto done;
/* We've got a comment to set */
- init_lsa_String(&group_info.description, opt_comment);
+ init_lsa_String(&group_info.description, c->opt_comment);
result = rpccli_samr_SetGroupInfo(pipe_hnd, mem_ctx,
&group_pol,
@@ -1853,7 +1877,8 @@ static NTSTATUS rpc_group_add_internals(const DOM_SID *domain_sid,
return result;
}
-static NTSTATUS rpc_alias_add_internals(const DOM_SID *domain_sid,
+static NTSTATUS rpc_alias_add_internals(struct net_context *c,
+ const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
@@ -1869,7 +1894,7 @@ static NTSTATUS rpc_alias_add_internals(const DOM_SID *domain_sid,
if (argc != 1) {
d_printf("Alias name must be specified\n");
- rpc_group_usage(argc, argv);
+ rpc_group_usage(c, argc, argv);
return NT_STATUS_OK;
}
@@ -1902,11 +1927,11 @@ static NTSTATUS rpc_alias_add_internals(const DOM_SID *domain_sid,
&rid);
if (!NT_STATUS_IS_OK(result)) goto done;
- if (strlen(opt_comment) == 0) goto done;
+ if (strlen(c->opt_comment) == 0) goto done;
/* We've got a comment to set */
- init_lsa_String(&alias_info.description, opt_comment);
+ init_lsa_String(&alias_info.description, c->opt_comment);
result = rpccli_samr_SetAliasInfo(pipe_hnd, mem_ctx,
&alias_pol,
@@ -1924,14 +1949,14 @@ static NTSTATUS rpc_alias_add_internals(const DOM_SID *domain_sid,
return result;
}
-static int rpc_group_add(int argc, const char **argv)
+static int rpc_group_add(struct net_context *c, int argc, const char **argv)
{
- if (opt_localgroup)
- return run_rpc_command(NULL, PI_SAMR, 0,
+ if (c->opt_localgroup)
+ return run_rpc_command(c, NULL, PI_SAMR, 0,
rpc_alias_add_internals,
argc, argv);
- return run_rpc_command(NULL, PI_SAMR, 0,
+ return run_rpc_command(c, NULL, PI_SAMR, 0,
rpc_group_add_internals,
argc, argv);
}
@@ -2136,7 +2161,8 @@ static NTSTATUS rpc_add_aliasmem(struct rpc_pipe_client *pipe_hnd,
return result;
}
-static NTSTATUS rpc_group_addmem_internals(const DOM_SID *domain_sid,
+static NTSTATUS rpc_group_addmem_internals(struct net_context *c,
+ const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
@@ -2186,14 +2212,15 @@ static NTSTATUS rpc_group_addmem_internals(const DOM_SID *domain_sid,
return NT_STATUS_UNSUCCESSFUL;
}
-static int rpc_group_addmem(int argc, const char **argv)
+static int rpc_group_addmem(struct net_context *c, int argc, const char **argv)
{
- return run_rpc_command(NULL, PI_SAMR, 0,
+ return run_rpc_command(c, NULL, PI_SAMR, 0,
rpc_group_addmem_internals,
argc, argv);
}
-static NTSTATUS rpc_del_groupmem(struct rpc_pipe_client *pipe_hnd,
+static NTSTATUS rpc_del_groupmem(struct net_context *c,
+ struct rpc_pipe_client *pipe_hnd,
TALLOC_CTX *mem_ctx,
const DOM_SID *group_sid,
const char *member)
@@ -2329,7 +2356,8 @@ static NTSTATUS rpc_del_aliasmem(struct rpc_pipe_client *pipe_hnd,
return result;
}
-static NTSTATUS rpc_group_delmem_internals(const DOM_SID *domain_sid,
+static NTSTATUS rpc_group_delmem_internals(struct net_context *c,
+ const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
@@ -2352,7 +2380,7 @@ static NTSTATUS rpc_group_delmem_internals(const DOM_SID *domain_sid,
}
if (group_type == SID_NAME_DOM_GRP) {
- NTSTATUS result = rpc_del_groupmem(pipe_hnd, mem_ctx,
+ NTSTATUS result = rpc_del_groupmem(c, pipe_hnd, mem_ctx,
&group_sid, argv[1]);
if (!NT_STATUS_IS_OK(result)) {
@@ -2379,9 +2407,9 @@ static NTSTATUS rpc_group_delmem_internals(const DOM_SID *domain_sid,
return NT_STATUS_UNSUCCESSFUL;
}
-static int rpc_group_delmem(int argc, const char **argv)
+static int rpc_group_delmem(struct net_context *c, int argc, const char **argv)
{
- return run_rpc_command(NULL, PI_SAMR, 0,
+ return run_rpc_command(c, NULL, PI_SAMR, 0,
rpc_group_delmem_internals,
argc, argv);
}
@@ -2402,7 +2430,8 @@ static int rpc_group_delmem(int argc, const char **argv)
* @return Normal NTSTATUS return.
**/
-static NTSTATUS rpc_group_list_internals(const DOM_SID *domain_sid,
+static NTSTATUS rpc_group_list_internals(struct net_context *c,
+ const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
@@ -2457,7 +2486,7 @@ static NTSTATUS rpc_group_list_internals(const DOM_SID *domain_sid,
}
/* Query domain groups */
- if (opt_long_list_entries)
+ if (c->opt_long_list_entries)
d_printf("\nGroup name Comment"\
"\n-----------------------------\n");
do {
@@ -2493,7 +2522,7 @@ static NTSTATUS rpc_group_list_internals(const DOM_SID *domain_sid,
group = info.info3.entries[i].account_name.string;
desc = info.info3.entries[i].description.string;
- if (opt_long_list_entries)
+ if (c->opt_long_list_entries)
printf("%-21.21s %-50.50s\n",
group, desc);
else
@@ -2519,7 +2548,7 @@ static NTSTATUS rpc_group_list_internals(const DOM_SID *domain_sid,
const char *description = NULL;
- if (opt_long_list_entries) {
+ if (c->opt_long_list_entries) {
POLICY_HND alias_pol;
union samr_AliasInfo *info = NULL;
@@ -2578,7 +2607,7 @@ static NTSTATUS rpc_group_list_internals(const DOM_SID *domain_sid,
const char *description = NULL;
- if (opt_long_list_entries) {
+ if (c->opt_long_list_entries) {
POLICY_HND alias_pol;
union samr_AliasInfo *info = NULL;
@@ -2612,14 +2641,15 @@ static NTSTATUS rpc_group_list_internals(const DOM_SID *domain_sid,
return result;
}
-static int rpc_group_list(int argc, const char **argv)
+static int rpc_group_list(struct net_context *c, int argc, const char **argv)
{
- return run_rpc_command(NULL, PI_SAMR, 0,
+ return run_rpc_command(c, NULL, PI_SAMR, 0,
rpc_group_list_internals,
argc, argv);
}
-static NTSTATUS rpc_list_group_members(struct rpc_pipe_client *pipe_hnd,
+static NTSTATUS rpc_list_group_members(struct net_context *c,
+ struct rpc_pipe_client *pipe_hnd,
TALLOC_CTX *mem_ctx,
const char *domain_name,
const DOM_SID *domain_sid,
@@ -2677,7 +2707,7 @@ static NTSTATUS rpc_list_group_members(struct rpc_pipe_client *pipe_hnd,
for (i = 0; i < this_time; i++) {
- if (opt_long_list_entries) {
+ if (c->opt_long_list_entries) {
printf("%s-%d %s\\%s %d\n", sid_str,
group_rids[i], domain_name,
names.names[i].string,
@@ -2695,7 +2725,8 @@ static NTSTATUS rpc_list_group_members(struct rpc_pipe_client *pipe_hnd,
return NT_STATUS_OK;
}
-static NTSTATUS rpc_list_alias_members(struct rpc_pipe_client *pipe_hnd,
+static NTSTATUS rpc_list_alias_members(struct net_context *c,
+ struct rpc_pipe_client *pipe_hnd,
TALLOC_CTX *mem_ctx,
POLICY_HND *domain_pol,
uint32 rid)
@@ -2763,8 +2794,8 @@ static NTSTATUS rpc_list_alias_members(struct rpc_pipe_client *pipe_hnd,
sid_copy(&alias_sids[i], sid_array.sids[i].sid);
}
- result = rpccli_lsa_lookup_sids(lsa_pipe, mem_ctx, &lsa_pol, num_members,
- alias_sids,
+ result = rpccli_lsa_lookup_sids(lsa_pipe, mem_ctx, &lsa_pol,
+ num_members, alias_sids,
&domains, &names, &types);
if (!NT_STATUS_IS_OK(result) &&
@@ -2778,7 +2809,7 @@ static NTSTATUS rpc_list_alias_members(struct rpc_pipe_client *pipe_hnd,
fstring sid_str;
sid_to_fstring(sid_str, &alias_sids[i]);
- if (opt_long_list_entries) {
+ if (c->opt_long_list_entries) {
printf("%s %s\\%s %d\n", sid_str,
domains[i] ? domains[i] : "*unknown*",
names[i] ? names[i] : "*unknown*", types[i]);
@@ -2794,7 +2825,8 @@ static NTSTATUS rpc_list_alias_members(struct rpc_pipe_client *pipe_hnd,
return NT_STATUS_OK;
}
-static NTSTATUS rpc_group_members_internals(const DOM_SID *domain_sid,
+static NTSTATUS rpc_group_members_internals(struct net_context *c,
+ const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
@@ -2877,31 +2909,32 @@ static NTSTATUS rpc_group_members_internals(const DOM_SID *domain_sid,
}
if (rid_types.ids[0] == SID_NAME_DOM_GRP) {
- return rpc_list_group_members(pipe_hnd, mem_ctx, domain_name,
+ return rpc_list_group_members(c, pipe_hnd, mem_ctx, domain_name,
domain_sid, &domain_pol,
rids.ids[0]);
}
if (rid_types.ids[0] == SID_NAME_ALIAS) {
- return rpc_list_alias_members(pipe_hnd, mem_ctx, &domain_pol,
+ return rpc_list_alias_members(c, pipe_hnd, mem_ctx, &domain_pol,
rids.ids[0]);
}
return NT_STATUS_NO_SUCH_GROUP;
}
-static int rpc_group_members(int argc, const char **argv)
+static int rpc_group_members(struct net_context *c, int argc, const char **argv)
{
if (argc != 1) {
- return rpc_group_usage(argc, argv);
+ return rpc_group_usage(c, argc, argv);
}
- return run_rpc_command(NULL, PI_SAMR, 0,
+ return run_rpc_command(c, NULL, PI_SAMR, 0,
rpc_group_members_internals,
argc, argv);
}
-static NTSTATUS rpc_group_rename_internals(const DOM_SID *domain_sid,
+static NTSTATUS rpc_group_rename_internals(struct net_context *c,
+ const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
@@ -2982,13 +3015,13 @@ static NTSTATUS rpc_group_rename_internals(const DOM_SID *domain_sid,
return NT_STATUS_NO_SUCH_GROUP;
}
-static int rpc_group_rename(int argc, const char **argv)
+static int rpc_group_rename(struct net_context *c, int argc, const char **argv)
{
if (argc != 2) {
- return rpc_group_usage(argc, argv);
+ return rpc_group_usage(c, argc, argv);
}
- return run_rpc_command(NULL, PI_SAMR, 0,
+ return run_rpc_command(c, NULL, PI_SAMR, 0,
rpc_group_rename_internals,
argc, argv);
}
@@ -3000,7 +3033,7 @@ static int rpc_group_rename(int argc, const char **argv)
* stripped
**/
-int net_rpc_group(int argc, const char **argv)
+int net_rpc_group(struct net_context *c, int argc, const char **argv)
{
struct functable func[] = {
{"add", rpc_group_add},
@@ -3014,19 +3047,19 @@ int net_rpc_group(int argc, const char **argv)
};
if (argc == 0) {
- return run_rpc_command(NULL, PI_SAMR, 0,
+ return run_rpc_command(c, NULL, PI_SAMR, 0,
rpc_group_list_internals,
argc, argv);
}
- return net_run_function(argc, argv, func, rpc_group_usage);
+ return net_run_function(c, argc, argv, func, rpc_group_usage);
}
/****************************************************************************/
-static int rpc_share_usage(int argc, const char **argv)
+static int rpc_share_usage(struct net_context *c, int argc, const char **argv)
{
- return net_help_share(argc, argv);
+ return net_help_share(c, argc, argv);
}
/**
@@ -3044,7 +3077,8 @@ static int rpc_share_usage(int argc, const char **argv)
*
* @return Normal NTSTATUS return.
**/
-static NTSTATUS rpc_share_add_internals(const DOM_SID *domain_sid,
+static NTSTATUS rpc_share_add_internals(struct net_context *c,
+ const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
@@ -3074,9 +3108,9 @@ static NTSTATUS rpc_share_add_internals(const DOM_SID *domain_sid,
info2.name = sharename;
info2.type = type;
- info2.comment = opt_comment;
+ info2.comment = c->opt_comment;
info2.permissions = perms;
- info2.max_users = opt_maxusers;
+ info2.max_users = c->opt_maxusers;
info2.current_users = num_users;
info2.path = path;
info2.password = password;
@@ -3092,13 +3126,13 @@ static NTSTATUS rpc_share_add_internals(const DOM_SID *domain_sid,
return status;
}
-static int rpc_share_add(int argc, const char **argv)
+static int rpc_share_add(struct net_context *c, int argc, const char **argv)
{
if ((argc < 1) || !strchr(argv[0], '=')) {
DEBUG(1,("Sharename or path not specified on add\n"));
- return rpc_share_usage(argc, argv);
+ return rpc_share_usage(c, argc, argv);
}
- return run_rpc_command(NULL, PI_SRVSVC, 0,
+ return run_rpc_command(c, NULL, PI_SRVSVC, 0,
rpc_share_add_internals,
argc, argv);
}
@@ -3118,7 +3152,8 @@ static int rpc_share_add(int argc, const char **argv)
*
* @return Normal NTSTATUS return.
**/
-static NTSTATUS rpc_share_del_internals(const DOM_SID *domain_sid,
+static NTSTATUS rpc_share_del_internals(struct net_context *c,
+ const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
@@ -3145,13 +3180,13 @@ static NTSTATUS rpc_share_del_internals(const DOM_SID *domain_sid,
*
* @return A shell status integer (0 for success)
**/
-static int rpc_share_delete(int argc, const char **argv)
+static int rpc_share_delete(struct net_context *c, int argc, const char **argv)
{
if (argc < 1) {
DEBUG(1,("Sharename not specified on delete\n"));
- return rpc_share_usage(argc, argv);
+ return rpc_share_usage(c, argc, argv);
}
- return run_rpc_command(NULL, PI_SRVSVC, 0,
+ return run_rpc_command(c, NULL, PI_SRVSVC, 0,
rpc_share_del_internals,
argc, argv);
}
@@ -3162,19 +3197,21 @@ static int rpc_share_delete(int argc, const char **argv)
* @param info1 pointer to SRV_SHARE_INFO_1 to format
**/
-static void display_share_info_1(struct srvsvc_NetShareInfo1 *r)
+static void display_share_info_1(struct net_context *c,
+ struct srvsvc_NetShareInfo1 *r)
{
- if (opt_long_list_entries) {
+ if (c->opt_long_list_entries) {
d_printf("%-12s %-8.8s %-50s\n",
r->name,
- share_type[r->type & ~(STYPE_TEMPORARY|STYPE_HIDDEN)],
+ c->share_type[r->type & ~(STYPE_TEMPORARY|STYPE_HIDDEN)],
r->comment);
} else {
d_printf("%s\n", r->name);
}
}
-static WERROR get_share_info(struct rpc_pipe_client *pipe_hnd,
+static WERROR get_share_info(struct net_context *c,
+ struct rpc_pipe_client *pipe_hnd,
TALLOC_CTX *mem_ctx,
uint32 level,
int argc,
@@ -3279,7 +3316,8 @@ done:
* @return Normal NTSTATUS return.
**/
-static NTSTATUS rpc_share_list_internals(const DOM_SID *domain_sid,
+static NTSTATUS rpc_share_list_internals(struct net_context *c,
+ const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
@@ -3298,20 +3336,21 @@ static NTSTATUS rpc_share_list_internals(const DOM_SID *domain_sid,
info_ctr.level = 1;
info_ctr.ctr.ctr1 = &ctr1;
- result = get_share_info(pipe_hnd, mem_ctx, level, argc, argv, &info_ctr);
+ result = get_share_info(c, pipe_hnd, mem_ctx, level, argc, argv,
+ &info_ctr);
if (!W_ERROR_IS_OK(result))
goto done;
/* Display results */
- if (opt_long_list_entries) {
+ if (c->opt_long_list_entries) {
d_printf(
"\nEnumerating shared resources (exports) on remote server:\n\n"\
"\nShare name Type Description\n"\
"---------- ---- -----------\n");
}
for (i = 0; i < info_ctr.ctr.ctr1->count; i++)
- display_share_info_1(&info_ctr.ctr.ctr1->array[i]);
+ display_share_info_1(c, &info_ctr.ctr.ctr1->array[i]);
done:
return W_ERROR_IS_OK(result) ? NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL;
}
@@ -3322,9 +3361,10 @@ static NTSTATUS rpc_share_list_internals(const DOM_SID *domain_sid,
* @param argv Standard main() style argv. Initial components are already
* stripped
**/
-static int rpc_share_list(int argc, const char **argv)
+static int rpc_share_list(struct net_context *c, int argc, const char **argv)
{
- return run_rpc_command(NULL, PI_SRVSVC, 0, rpc_share_list_internals, argc, argv);
+ return run_rpc_command(c, NULL, PI_SRVSVC, 0, rpc_share_list_internals,
+ argc, argv);
}
static bool check_share_availability(struct cli_state *cli, const char *netname)
@@ -3340,7 +3380,8 @@ static bool check_share_availability(struct cli_state *cli, const char *netname)
return True;
}
-static bool check_share_sanity(struct cli_state *cli, const char *netname, uint32 type)
+static bool check_share_sanity(struct net_context *c, struct cli_state *cli,
+ const char *netname, uint32 type)
{
/* only support disk shares */
if (! ( type == STYPE_DISKTREE || type == (STYPE_DISKTREE | STYPE_HIDDEN)) ) {
@@ -3354,7 +3395,7 @@ static bool check_share_sanity(struct cli_state *cli, const char *netname, uint3
strequal(netname,"global"))
return False;
- if (opt_exclude && in_list(netname, opt_exclude, False)) {
+ if (c->opt_exclude && in_list(netname, c->opt_exclude, False)) {
printf("excluding [%s]\n", netname);
return False;
}
@@ -3378,7 +3419,8 @@ static bool check_share_sanity(struct cli_state *cli, const char *netname, uint3
* @return Normal NTSTATUS return.
**/
-static NTSTATUS rpc_share_migrate_shares_internals(const DOM_SID *domain_sid,
+static NTSTATUS rpc_share_migrate_shares_internals(struct net_context *c,
+ const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
@@ -3395,12 +3437,13 @@ static NTSTATUS rpc_share_migrate_shares_internals(const DOM_SID *domain_sid,
uint32 level = 502; /* includes secdesc */
uint32_t parm_error = 0;
- result = get_share_info(pipe_hnd, mem_ctx, level, argc, argv, &ctr_src);
+ result = get_share_info(c, pipe_hnd, mem_ctx, level, argc, argv,
+ &ctr_src);
if (!W_ERROR_IS_OK(result))
goto done;
/* connect destination PI_SRVSVC */
- nt_status = connect_dst_pipe(&cli_dst, &srvsvc_pipe, PI_SRVSVC);
+ nt_status = connect_dst_pipe(c, &cli_dst, &srvsvc_pipe, PI_SRVSVC);
if (!NT_STATUS_IS_OK(nt_status))
return nt_status;
@@ -3414,7 +3457,7 @@ static NTSTATUS rpc_share_migrate_shares_internals(const DOM_SID *domain_sid,
/* reset error-code */
nt_status = NT_STATUS_UNSUCCESSFUL;
- if (!check_share_sanity(cli, info502.name, info502.type))
+ if (!check_share_sanity(c, cli, info502.name, info502.type))
continue;
/* finally add the share on the dst server */
@@ -3464,15 +3507,16 @@ done:
*
* @return A shell status integer (0 for success)
**/
-static int rpc_share_migrate_shares(int argc, const char **argv)
+static int rpc_share_migrate_shares(struct net_context *c, int argc,
+ const char **argv)
{
- if (!opt_host) {
+ if (!c->opt_host) {
printf("no server to migrate\n");
return -1;
}
- return run_rpc_command(NULL, PI_SRVSVC, 0,
+ return run_rpc_command(c, NULL, PI_SRVSVC, 0,
rpc_share_migrate_shares_internals,
argc, argv);
}
@@ -3485,17 +3529,21 @@ static int rpc_share_migrate_shares(int argc, const char **argv)
* @param state arg-pointer
*
**/
-static void copy_fn(const char *mnt, file_info *f, const char *mask, void *state)
+static void copy_fn(const char *mnt, file_info *f,
+ const char *mask, void *state)
{
static NTSTATUS nt_status;
static struct copy_clistate *local_state;
static fstring filename, new_mask;
fstring dir;
char *old_dir;
+ struct net_context *c;
local_state = (struct copy_clistate *)state;
nt_status = NT_STATUS_UNSUCCESSFUL;
+ c = local_state->c;
+
if (strequal(f->name, ".") || strequal(f->name, ".."))
return;
@@ -3514,14 +3562,14 @@ static void copy_fn(const char *mnt, file_info *f, const char *mask, void *state
{
case NET_MODE_SHARE_MIGRATE:
/* create that directory */
- nt_status = net_copy_file(local_state->mem_ctx,
+ nt_status = net_copy_file(c, local_state->mem_ctx,
local_state->cli_share_src,
local_state->cli_share_dst,
dir, dir,
- opt_acls? True : False,
- opt_attrs? True : False,
- opt_timestamps? True : False,
- False);
+ c->opt_acls? true : false,
+ c->opt_attrs? true : false,
+ c->opt_timestamps? true:false,
+ false);
break;
default:
d_fprintf(stderr, "Unsupported mode %d\n", net_mode_share);
@@ -3556,14 +3604,14 @@ static void copy_fn(const char *mnt, file_info *f, const char *mask, void *state
switch (net_mode_share)
{
case NET_MODE_SHARE_MIGRATE:
- nt_status = net_copy_file(local_state->mem_ctx,
+ nt_status = net_copy_file(c, local_state->mem_ctx,
local_state->cli_share_src,
local_state->cli_share_dst,
filename, filename,
- opt_acls? True : False,
- opt_attrs? True : False,
- opt_timestamps? True: False,
- True);
+ c->opt_acls? true : false,
+ c->opt_attrs? true : false,
+ c->opt_timestamps? true: false,
+ true);
break;
default:
d_fprintf(stderr, "Unsupported file mode %d\n", net_mode_share);
@@ -3614,7 +3662,8 @@ static bool sync_files(struct copy_clistate *cp_clistate, const char *mask)
* Should set up ACL inheritance.
**/
-bool copy_top_level_perms(struct copy_clistate *cp_clistate,
+bool copy_top_level_perms(struct net_context *c,
+ struct copy_clistate *cp_clistate,
const char *sharename)
{
NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
@@ -3622,14 +3671,15 @@ bool copy_top_level_perms(struct copy_clistate *cp_clistate,
switch (net_mode_share) {
case NET_MODE_SHARE_MIGRATE:
DEBUG(3,("calling net_copy_fileattr for '.' directory in share %s\n", sharename));
- nt_status = net_copy_fileattr(cp_clistate->mem_ctx,
+ nt_status = net_copy_fileattr(c,
+ cp_clistate->mem_ctx,
cp_clistate->cli_share_src,
cp_clistate->cli_share_dst,
"\\", "\\",
- opt_acls? True : False,
- opt_attrs? True : False,
- opt_timestamps? True: False,
- False);
+ c->opt_acls? true : false,
+ c->opt_attrs? true : false,
+ c->opt_timestamps? true: false,
+ false);
break;
default:
d_fprintf(stderr, "Unsupported mode %d\n", net_mode_share);
@@ -3661,7 +3711,8 @@ bool copy_top_level_perms(struct copy_clistate *cp_clistate,
* @return Normal NTSTATUS return.
**/
-static NTSTATUS rpc_share_migrate_files_internals(const DOM_SID *domain_sid,
+static NTSTATUS rpc_share_migrate_files_internals(struct net_context *c,
+ const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
@@ -3680,9 +3731,10 @@ static NTSTATUS rpc_share_migrate_files_internals(const DOM_SID *domain_sid,
const char *mask = "\\*";
char *dst = NULL;
- dst = SMB_STRDUP(opt_destination?opt_destination:"127.0.0.1");
+ dst = SMB_STRDUP(c->opt_destination?c->opt_destination:"127.0.0.1");
- result = get_share_info(pipe_hnd, mem_ctx, level, argc, argv, &ctr_src);
+ result = get_share_info(c, pipe_hnd, mem_ctx, level, argc, argv,
+ &ctr_src);
if (!W_ERROR_IS_OK(result))
goto done;
@@ -3692,7 +3744,7 @@ static NTSTATUS rpc_share_migrate_files_internals(const DOM_SID *domain_sid,
struct srvsvc_NetShareInfo502 info502 =
ctr_src.ctr.ctr502->array[i];
- if (!check_share_sanity(cli, info502.name, info502.type))
+ if (!check_share_sanity(c, cli, info502.name, info502.type))
continue;
/* one might not want to mirror whole discs :) */
@@ -3712,18 +3764,19 @@ static NTSTATUS rpc_share_migrate_files_internals(const DOM_SID *domain_sid,
}
printf(" [%s] files and directories %s ACLs, %s DOS Attributes %s\n",
info502.name,
- opt_acls ? "including" : "without",
- opt_attrs ? "including" : "without",
- opt_timestamps ? "(preserving timestamps)" : "");
+ c->opt_acls ? "including" : "without",
+ c->opt_attrs ? "including" : "without",
+ c->opt_timestamps ? "(preserving timestamps)" : "");
cp_clistate.mem_ctx = mem_ctx;
cp_clistate.cli_share_src = NULL;
cp_clistate.cli_share_dst = NULL;
cp_clistate.cwd = NULL;
cp_clistate.attribute = aSYSTEM | aHIDDEN | aDIR;
+ cp_clistate.c = c;
/* open share source */
- nt_status = connect_to_service(&cp_clistate.cli_share_src,
+ nt_status = connect_to_service(c, &cp_clistate.cli_share_src,
&cli->dest_ss, cli->desthost,
info502.name, "A:");
if (!NT_STATUS_IS_OK(nt_status))
@@ -3733,7 +3786,7 @@ static NTSTATUS rpc_share_migrate_files_internals(const DOM_SID *domain_sid,
if (net_mode_share == NET_MODE_SHARE_MIGRATE) {
/* open share destination */
- nt_status = connect_to_service(&cp_clistate.cli_share_dst,
+ nt_status = connect_to_service(c, &cp_clistate.cli_share_dst,
NULL, dst, info502.name, "A:");
if (!NT_STATUS_IS_OK(nt_status))
goto done;
@@ -3741,7 +3794,7 @@ static NTSTATUS rpc_share_migrate_files_internals(const DOM_SID *domain_sid,
got_dst_share = True;
}
- if (!copy_top_level_perms(&cp_clistate, info502.name)) {
+ if (!copy_top_level_perms(c, &cp_clistate, info502.name)) {
d_fprintf(stderr, "Could not handle the top level directory permissions for the share: %s\n", info502.name);
nt_status = NT_STATUS_UNSUCCESSFUL;
goto done;
@@ -3768,15 +3821,15 @@ done:
}
-static int rpc_share_migrate_files(int argc, const char **argv)
+static int rpc_share_migrate_files(struct net_context *c, int argc, const char **argv)
{
- if (!opt_host) {
+ if (!c->opt_host) {
printf("no server to migrate\n");
return -1;
}
- return run_rpc_command(NULL, PI_SRVSVC, 0,
+ return run_rpc_command(c, NULL, PI_SRVSVC, 0,
rpc_share_migrate_files_internals,
argc, argv);
}
@@ -3797,7 +3850,8 @@ static int rpc_share_migrate_files(int argc, const char **argv)
* @return Normal NTSTATUS return.
**/
-static NTSTATUS rpc_share_migrate_security_internals(const DOM_SID *domain_sid,
+static NTSTATUS rpc_share_migrate_security_internals(struct net_context *c,
+ const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
@@ -3815,13 +3869,14 @@ static NTSTATUS rpc_share_migrate_security_internals(const DOM_SID *domain_sid,
uint32 level = 502; /* includes secdesc */
uint32_t parm_error = 0;
- result = get_share_info(pipe_hnd, mem_ctx, level, argc, argv, &ctr_src);
+ result = get_share_info(c, pipe_hnd, mem_ctx, level, argc, argv,
+ &ctr_src);
if (!W_ERROR_IS_OK(result))
goto done;
/* connect destination PI_SRVSVC */
- nt_status = connect_dst_pipe(&cli_dst, &srvsvc_pipe, PI_SRVSVC);
+ nt_status = connect_dst_pipe(c, &cli_dst, &srvsvc_pipe, PI_SRVSVC);
if (!NT_STATUS_IS_OK(nt_status))
return nt_status;
@@ -3834,13 +3889,13 @@ static NTSTATUS rpc_share_migrate_security_internals(const DOM_SID *domain_sid,
/* reset error-code */
nt_status = NT_STATUS_UNSUCCESSFUL;
- if (!check_share_sanity(cli, info502.name, info502.type))
+ if (!check_share_sanity(c, cli, info502.name, info502.type))
continue;
printf("migrating: [%s], path: %s, comment: %s, including share-ACLs\n",
info502.name, info502.path, info502.comment);
- if (opt_verbose)
+ if (c->opt_verbose)
display_sec_desc(info502.sd_buf.sd);
/* FIXME: shouldn't we be able to just set the security descriptor ? */
@@ -3881,15 +3936,16 @@ done:
*
* @return A shell status integer (0 for success)
**/
-static int rpc_share_migrate_security(int argc, const char **argv)
+static int rpc_share_migrate_security(struct net_context *c, int argc,
+ const char **argv)
{
- if (!opt_host) {
+ if (!c->opt_host) {
printf("no server to migrate\n");
return -1;
}
- return run_rpc_command(NULL, PI_SRVSVC, 0,
+ return run_rpc_command(c, NULL, PI_SRVSVC, 0,
rpc_share_migrate_security_internals,
argc, argv);
}
@@ -3905,11 +3961,12 @@ static int rpc_share_migrate_security(int argc, const char **argv)
* @return A shell status integer (0 for success)
*
**/
-static int rpc_share_migrate_all(int argc, const char **argv)
+static int rpc_share_migrate_all(struct net_context *c, int argc,
+ const char **argv)
{
int ret;
- if (!opt_host) {
+ if (!c->opt_host) {
printf("no server to migrate\n");
return -1;
}
@@ -3917,15 +3974,19 @@ static int rpc_share_migrate_all(int argc, const char **argv)
/* order is important. we don't want to be locked out by the share-acl
* before copying files - gd */
- ret = run_rpc_command(NULL, PI_SRVSVC, 0, rpc_share_migrate_shares_internals, argc, argv);
+ ret = run_rpc_command(c, NULL, PI_SRVSVC, 0,
+ rpc_share_migrate_shares_internals, argc, argv);
if (ret)
return ret;
- ret = run_rpc_command(NULL, PI_SRVSVC, 0, rpc_share_migrate_files_internals, argc, argv);
+ ret = run_rpc_command(c, NULL, PI_SRVSVC, 0,
+ rpc_share_migrate_files_internals, argc, argv);
if (ret)
return ret;
- return run_rpc_command(NULL, PI_SRVSVC, 0, rpc_share_migrate_security_internals, argc, argv);
+ return run_rpc_command(c, NULL, PI_SRVSVC, 0,
+ rpc_share_migrate_security_internals, argc,
+ argv);
}
@@ -3935,7 +3996,7 @@ static int rpc_share_migrate_all(int argc, const char **argv)
* @param argv Standard main() style argv. Initial components are already
* stripped
**/
-static int rpc_share_migrate(int argc, const char **argv)
+static int rpc_share_migrate(struct net_context *c, int argc, const char **argv)
{
struct functable func[] = {
@@ -3949,7 +4010,7 @@ static int rpc_share_migrate(int argc, const char **argv)
net_mode_share = NET_MODE_SHARE_MIGRATE;
- return net_run_function(argc, argv, func, rpc_share_usage);
+ return net_run_function(c, argc, argv, func, rpc_share_usage);
}
struct full_alias {
@@ -4064,7 +4125,8 @@ static NTSTATUS rpc_fetch_domain_aliases(struct rpc_pipe_client *pipe_hnd,
* Dump server_aliases as names for debugging purposes.
*/
-static NTSTATUS rpc_aliaslist_dump(const DOM_SID *domain_sid,
+static NTSTATUS rpc_aliaslist_dump(struct net_context *c,
+ const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
@@ -4129,7 +4191,8 @@ static NTSTATUS rpc_aliaslist_dump(const DOM_SID *domain_sid,
* server_aliases.
*/
-static NTSTATUS rpc_aliaslist_internals(const DOM_SID *domain_sid,
+static NTSTATUS rpc_aliaslist_internals(struct net_context *c,
+ const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
@@ -4350,7 +4413,8 @@ static bool get_user_sids(const char *domain, const char *user, NT_USER_TOKEN *t
* Get a list of all user tokens we want to look at
**/
-static bool get_user_tokens(int *num_tokens, struct user_token **user_tokens)
+static bool get_user_tokens(struct net_context *c, int *num_tokens,
+ struct user_token **user_tokens)
{
wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
uint32_t i, num_users;
@@ -4359,7 +4423,7 @@ static bool get_user_tokens(int *num_tokens, struct user_token **user_tokens)
TALLOC_CTX *frame = NULL;
if (lp_winbind_use_default_domain() &&
- (opt_target_workgroup == NULL)) {
+ (c->opt_target_workgroup == NULL)) {
d_fprintf(stderr, "winbind use default domain = yes set, "
"please specify a workgroup\n");
return false;
@@ -4394,7 +4458,7 @@ static bool get_user_tokens(int *num_tokens, struct user_token **user_tokens)
DEBUG(3, ("%s\n", users[i]));
if (p == NULL) {
- fstrcpy(domain, opt_target_workgroup);
+ fstrcpy(domain, c->opt_target_workgroup);
fstrcpy(user, users[i]);
} else {
*p++ = '\0';
@@ -4603,7 +4667,8 @@ static void rpc_share_userlist_usage(void)
* @return Normal NTSTATUS return.
**/
-static NTSTATUS rpc_share_allowedusers_internals(const DOM_SID *domain_sid,
+static NTSTATUS rpc_share_allowedusers_internals(struct net_context *c,
+ const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
@@ -4685,39 +4750,40 @@ static NTSTATUS rpc_share_allowedusers_internals(const DOM_SID *domain_sid,
return NT_STATUS_OK;
}
-static int rpc_share_allowedusers(int argc, const char **argv)
+static int rpc_share_allowedusers(struct net_context *c, int argc,
+ const char **argv)
{
int result;
- result = run_rpc_command(NULL, PI_SAMR, 0,
+ result = run_rpc_command(c, NULL, PI_SAMR, 0,
rpc_aliaslist_internals,
argc, argv);
if (result != 0)
return result;
- result = run_rpc_command(NULL, PI_LSARPC, 0,
+ result = run_rpc_command(c, NULL, PI_LSARPC, 0,
rpc_aliaslist_dump,
argc, argv);
if (result != 0)
return result;
- return run_rpc_command(NULL, PI_SRVSVC, 0,
+ return run_rpc_command(c, NULL, PI_SRVSVC, 0,
rpc_share_allowedusers_internals,
argc, argv);
}
-int net_usersidlist(int argc, const char **argv)
+int net_usersidlist(struct net_context *c, int argc, const char **argv)
{
int num_tokens = 0;
struct user_token *tokens = NULL;
int i;
if (argc != 0) {
- net_usersidlist_usage(argc, argv);
+ net_usersidlist_usage(c, argc, argv);
return 0;
}
- if (!get_user_tokens(&num_tokens, &tokens)) {
+ if (!get_user_tokens(c, &num_tokens, &tokens)) {
DEBUG(0, ("Could not get the user/sid list\n"));
return 0;
}
@@ -4731,14 +4797,14 @@ int net_usersidlist(int argc, const char **argv)
return 1;
}
-int net_usersidlist_usage(int argc, const char **argv)
+int net_usersidlist_usage(struct net_context *c, int argc, const char **argv)
{
d_printf("net usersidlist\n"
"\tprints out a list of all users the running winbind knows\n"
"\tabout, together with all their SIDs. This is used as\n"
"\tinput to the 'net rpc share allowedusers' command.\n\n");
- net_common_flags_usage(argc, argv);
+ net_common_flags_usage(c, argc, argv);
return -1;
}
@@ -4749,7 +4815,7 @@ int net_usersidlist_usage(int argc, const char **argv)
* stripped
**/
-int net_rpc_share(int argc, const char **argv)
+int net_rpc_share(struct net_context *c, int argc, const char **argv)
{
struct functable func[] = {
{"add", rpc_share_add},
@@ -4761,24 +4827,26 @@ int net_rpc_share(int argc, const char **argv)
};
if (argc == 0)
- return run_rpc_command(NULL, PI_SRVSVC, 0,
+ return run_rpc_command(c, NULL, PI_SRVSVC, 0,
rpc_share_list_internals,
argc, argv);
- return net_run_function(argc, argv, func, rpc_share_usage);
+ return net_run_function(c, argc, argv, func, rpc_share_usage);
}
-static NTSTATUS rpc_sh_share_list(TALLOC_CTX *mem_ctx,
+static NTSTATUS rpc_sh_share_list(struct net_context *c,
+ TALLOC_CTX *mem_ctx,
struct rpc_sh_ctx *ctx,
struct rpc_pipe_client *pipe_hnd,
int argc, const char **argv)
{
- return rpc_share_list_internals(ctx->domain_sid, ctx->domain_name,
+ return rpc_share_list_internals(c, ctx->domain_sid, ctx->domain_name,
ctx->cli, pipe_hnd, mem_ctx,
argc, argv);
}
-static NTSTATUS rpc_sh_share_add(TALLOC_CTX *mem_ctx,
+static NTSTATUS rpc_sh_share_add(struct net_context *c,
+ TALLOC_CTX *mem_ctx,
struct rpc_sh_ctx *ctx,
struct rpc_pipe_client *pipe_hnd,
int argc, const char **argv)
@@ -4816,7 +4884,8 @@ static NTSTATUS rpc_sh_share_add(TALLOC_CTX *mem_ctx,
return status;
}
-static NTSTATUS rpc_sh_share_delete(TALLOC_CTX *mem_ctx,
+static NTSTATUS rpc_sh_share_delete(struct net_context *c,
+ TALLOC_CTX *mem_ctx,
struct rpc_sh_ctx *ctx,
struct rpc_pipe_client *pipe_hnd,
int argc, const char **argv)
@@ -4838,7 +4907,8 @@ static NTSTATUS rpc_sh_share_delete(TALLOC_CTX *mem_ctx,
return status;
}
-static NTSTATUS rpc_sh_share_info(TALLOC_CTX *mem_ctx,
+static NTSTATUS rpc_sh_share_info(struct net_context *c,
+ TALLOC_CTX *mem_ctx,
struct rpc_sh_ctx *ctx,
struct rpc_pipe_client *pipe_hnd,
int argc, const char **argv)
@@ -4871,7 +4941,7 @@ static NTSTATUS rpc_sh_share_info(TALLOC_CTX *mem_ctx,
return werror_to_ntstatus(result);
}
-struct rpc_sh_cmd *net_rpc_share_cmds(TALLOC_CTX *mem_ctx,
+struct rpc_sh_cmd *net_rpc_share_cmds(struct net_context *c, TALLOC_CTX *mem_ctx,
struct rpc_sh_ctx *ctx)
{
static struct rpc_sh_cmd cmds[] = {
@@ -4896,9 +4966,9 @@ struct rpc_sh_cmd *net_rpc_share_cmds(TALLOC_CTX *mem_ctx,
/****************************************************************************/
-static int rpc_file_usage(int argc, const char **argv)
+static int rpc_file_usage(struct net_context *c, int argc, const char **argv)
{
- return net_help_file(argc, argv);
+ return net_help_file(c, argc, argv);
}
/**
@@ -4907,6 +4977,7 @@ static int rpc_file_usage(int argc, const char **argv)
* All parameters are provided by the run_rpc_command function, except for
* argc, argv which are passes through.
*
+ * @param c A net_context structure
* @param domain_sid The domain sid acquired from the remote server
* @param cli A cli_state connected to the server.
* @param mem_ctx Talloc context, destoyed on completion of the function.
@@ -4916,7 +4987,8 @@ static int rpc_file_usage(int argc, const char **argv)
*
* @return Normal NTSTATUS return.
**/
-static NTSTATUS rpc_file_close_internals(const DOM_SID *domain_sid,
+static NTSTATUS rpc_file_close_internals(struct net_context *c,
+ const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
@@ -4938,14 +5010,14 @@ static NTSTATUS rpc_file_close_internals(const DOM_SID *domain_sid,
*
* @return A shell status integer (0 for success)
**/
-static int rpc_file_close(int argc, const char **argv)
+static int rpc_file_close(struct net_context *c, int argc, const char **argv)
{
if (argc < 1) {
DEBUG(1, ("No fileid given on close\n"));
- return(rpc_file_usage(argc, argv));
+ return rpc_file_usage(c, argc, argv);
}
- return run_rpc_command(NULL, PI_SRVSVC, 0,
+ return run_rpc_command(c, NULL, PI_SRVSVC, 0,
rpc_file_close_internals,
argc, argv);
}
@@ -4968,6 +5040,7 @@ static void display_file_info_3(struct srvsvc_NetFileInfo3 *r)
* All parameters are provided by the run_rpc_command function, except for
* argc, argv which are passes through.
*
+ * @param c A net_context structure
* @param domain_sid The domain sid acquired from the remote server
* @param cli A cli_state connected to the server.
* @param mem_ctx Talloc context, destoyed on completion of the function.
@@ -4978,7 +5051,8 @@ static void display_file_info_3(struct srvsvc_NetFileInfo3 *r)
* @return Normal NTSTATUS return.
**/
-static NTSTATUS rpc_file_list_internals(const DOM_SID *domain_sid,
+static NTSTATUS rpc_file_list_internals(struct net_context *c,
+ const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
@@ -5040,14 +5114,14 @@ static NTSTATUS rpc_file_list_internals(const DOM_SID *domain_sid,
* @return A shell status integer (0 for success)
**/
-static int rpc_file_user(int argc, const char **argv)
+static int rpc_file_user(struct net_context *c, int argc, const char **argv)
{
if (argc < 1) {
DEBUG(1, ("No username given\n"));
- return(rpc_file_usage(argc, argv));
+ return rpc_file_usage(c, argc, argv);
}
- return run_rpc_command(NULL, PI_SRVSVC, 0,
+ return run_rpc_command(c, NULL, PI_SRVSVC, 0,
rpc_file_list_internals,
argc, argv);
}
@@ -5059,7 +5133,7 @@ static int rpc_file_user(int argc, const char **argv)
* stripped
**/
-int net_rpc_file(int argc, const char **argv)
+int net_rpc_file(struct net_context *c, int argc, const char **argv)
{
struct functable func[] = {
{"close", rpc_file_close},
@@ -5071,11 +5145,11 @@ int net_rpc_file(int argc, const char **argv)
};
if (argc == 0)
- return run_rpc_command(NULL, PI_SRVSVC, 0,
+ return run_rpc_command(c, NULL, PI_SRVSVC, 0,
rpc_file_list_internals,
argc, argv);
- return net_run_function(argc, argv, func, rpc_file_usage);
+ return net_run_function(c, argc, argv, func, rpc_file_usage);
}
/**
@@ -5084,6 +5158,7 @@ int net_rpc_file(int argc, const char **argv)
* All parameters are provided by the run_rpc_command function, except for
* argc, argv which are passed through.
*
+ * @param c A net_context structure
* @param domain_sid The domain sid aquired from the remote server
* @param cli A cli_state connected to the server.
* @param mem_ctx Talloc context, destoyed on compleation of the function.
@@ -5094,7 +5169,8 @@ int net_rpc_file(int argc, const char **argv)
* @return Normal NTSTATUS return.
**/
-static NTSTATUS rpc_shutdown_abort_internals(const DOM_SID *domain_sid,
+static NTSTATUS rpc_shutdown_abort_internals(struct net_context *c,
+ const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
@@ -5121,6 +5197,7 @@ static NTSTATUS rpc_shutdown_abort_internals(const DOM_SID *domain_sid,
* All parameters are provided by the run_rpc_command function, except for
* argc, argv which are passed through.
*
+ * @param c A net_context structure
* @param domain_sid The domain sid aquired from the remote server
* @param cli A cli_state connected to the server.
* @param mem_ctx Talloc context, destoyed on compleation of the function.
@@ -5131,7 +5208,8 @@ static NTSTATUS rpc_shutdown_abort_internals(const DOM_SID *domain_sid,
* @return Normal NTSTATUS return.
**/
-static NTSTATUS rpc_reg_shutdown_abort_internals(const DOM_SID *domain_sid,
+static NTSTATUS rpc_reg_shutdown_abort_internals(struct net_context *c,
+ const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
@@ -5162,9 +5240,10 @@ static NTSTATUS rpc_reg_shutdown_abort_internals(const DOM_SID *domain_sid,
* @return A shell status integer (0 for success)
**/
-static int rpc_shutdown_abort(int argc, const char **argv)
+static int rpc_shutdown_abort(struct net_context *c, int argc,
+ const char **argv)
{
- int rc = run_rpc_command(NULL, PI_INITSHUTDOWN, 0,
+ int rc = run_rpc_command(c, NULL, PI_INITSHUTDOWN, 0,
rpc_shutdown_abort_internals,
argc, argv);
@@ -5173,7 +5252,7 @@ static int rpc_shutdown_abort(int argc, const char **argv)
DEBUG(1, ("initshutdown pipe didn't work, trying winreg pipe\n"));
- return run_rpc_command(NULL, PI_WINREG, 0,
+ return run_rpc_command(c, NULL, PI_WINREG, 0,
rpc_reg_shutdown_abort_internals,
argc, argv);
}
@@ -5184,6 +5263,7 @@ static int rpc_shutdown_abort(int argc, const char **argv)
* All parameters are provided by the run_rpc_command function, except for
* argc, argv which are passes through.
*
+ * @param c A net_context structure
* @param domain_sid The domain sid aquired from the remote server
* @param cli A cli_state connected to the server.
* @param mem_ctx Talloc context, destoyed on compleation of the function.
@@ -5194,7 +5274,8 @@ static int rpc_shutdown_abort(int argc, const char **argv)
* @return Normal NTSTATUS return.
**/
-NTSTATUS rpc_init_shutdown_internals(const DOM_SID *domain_sid,
+NTSTATUS rpc_init_shutdown_internals(struct net_context *c,
+ const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
@@ -5208,11 +5289,11 @@ NTSTATUS rpc_init_shutdown_internals(const DOM_SID *domain_sid,
struct initshutdown_String msg_string;
struct initshutdown_String_sub s;
- if (opt_comment) {
- msg = opt_comment;
+ if (c->opt_comment) {
+ msg = c->opt_comment;
}
- if (opt_timeout) {
- timeout = opt_timeout;
+ if (c->opt_timeout) {
+ timeout = c->opt_timeout;
}
s.name = msg;
@@ -5220,7 +5301,8 @@ NTSTATUS rpc_init_shutdown_internals(const DOM_SID *domain_sid,
/* create an entry */
result = rpccli_initshutdown_Init(pipe_hnd, mem_ctx, NULL,
- &msg_string, timeout, opt_force, opt_reboot, NULL);
+ &msg_string, timeout, c->opt_force, c->opt_reboot,
+ NULL);
if (NT_STATUS_IS_OK(result)) {
d_printf("\nShutdown of remote machine succeeded\n");
@@ -5237,6 +5319,7 @@ NTSTATUS rpc_init_shutdown_internals(const DOM_SID *domain_sid,
* All parameters are provided by the run_rpc_command function, except for
* argc, argv which are passes through.
*
+ * @param c A net_context structure
* @param domain_sid The domain sid aquired from the remote server
* @param cli A cli_state connected to the server.
* @param mem_ctx Talloc context, destoyed on compleation of the function.
@@ -5247,7 +5330,8 @@ NTSTATUS rpc_init_shutdown_internals(const DOM_SID *domain_sid,
* @return Normal NTSTATUS return.
**/
-NTSTATUS rpc_reg_shutdown_internals(const DOM_SID *domain_sid,
+NTSTATUS rpc_reg_shutdown_internals(struct net_context *c,
+ const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
@@ -5262,19 +5346,20 @@ NTSTATUS rpc_reg_shutdown_internals(const DOM_SID *domain_sid,
NTSTATUS result;
WERROR werr;
- if (opt_comment) {
- msg = opt_comment;
+ if (c->opt_comment) {
+ msg = c->opt_comment;
}
s.name = msg;
msg_string.name = &s;
- if (opt_timeout) {
- timeout = opt_timeout;
+ if (c->opt_timeout) {
+ timeout = c->opt_timeout;
}
/* create an entry */
result = rpccli_winreg_InitiateSystemShutdown(pipe_hnd, mem_ctx, NULL,
- &msg_string, timeout, opt_force, opt_reboot, &werr);
+ &msg_string, timeout, c->opt_force, c->opt_reboot,
+ &werr);
if (NT_STATUS_IS_OK(result)) {
d_printf("\nShutdown of remote machine succeeded\n");
@@ -5299,15 +5384,15 @@ NTSTATUS rpc_reg_shutdown_internals(const DOM_SID *domain_sid,
* @return A shell status integer (0 for success)
**/
-static int rpc_shutdown(int argc, const char **argv)
+static int rpc_shutdown(struct net_context *c, int argc, const char **argv)
{
- int rc = run_rpc_command(NULL, PI_INITSHUTDOWN, 0,
+ int rc = run_rpc_command(c, NULL, PI_INITSHUTDOWN, 0,
rpc_init_shutdown_internals,
argc, argv);
if (rc) {
DEBUG(1, ("initshutdown pipe failed, trying winreg pipe\n"));
- rc = run_rpc_command(NULL, PI_WINREG, 0,
+ rc = run_rpc_command(c, NULL, PI_WINREG, 0,
rpc_reg_shutdown_internals, argc, argv);
}
@@ -5316,7 +5401,6 @@ static int rpc_shutdown(int argc, const char **argv)
/***************************************************************************
NT Domain trusts code (i.e. 'net rpc trustdom' functionality)
-
***************************************************************************/
/**
@@ -5324,6 +5408,7 @@ static int rpc_shutdown(int argc, const char **argv)
* All parameters (except for argc and argv) are passed by run_rpc_command
* function.
*
+ * @param c A net_context structure
* @param domain_sid The domain sid acquired from the server
* @param cli A cli_state connected to the server.
* @param mem_ctx Talloc context, destoyed on completion of the function.
@@ -5334,7 +5419,8 @@ static int rpc_shutdown(int argc, const char **argv)
* @return normal NTSTATUS return code
*/
-static NTSTATUS rpc_trustdom_add_internals(const DOM_SID *domain_sid,
+static NTSTATUS rpc_trustdom_add_internals(struct net_context *c,
+ const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
@@ -5468,11 +5554,11 @@ static NTSTATUS rpc_trustdom_add_internals(const DOM_SID *domain_sid,
* @return Integer status (0 means success)
**/
-static int rpc_trustdom_add(int argc, const char **argv)
+static int rpc_trustdom_add(struct net_context *c, int argc, const char **argv)
{
if (argc > 0) {
- return run_rpc_command(NULL, PI_SAMR, 0, rpc_trustdom_add_internals,
- argc, argv);
+ return run_rpc_command(c, NULL, PI_SAMR, 0,
+ rpc_trustdom_add_internals, argc, argv);
} else {
d_printf("Usage: net rpc trustdom add <domain>\n");
return -1;
@@ -5485,6 +5571,7 @@ static int rpc_trustdom_add(int argc, const char **argv)
* All parameters (except for argc and argv) are passed by run_rpc_command
* function.
*
+ * @param c A net_context structure
* @param domain_sid The domain sid acquired from the server
* @param cli A cli_state connected to the server.
* @param mem_ctx Talloc context, destoyed on completion of the function.
@@ -5495,7 +5582,8 @@ static int rpc_trustdom_add(int argc, const char **argv)
* @return normal NTSTATUS return code
*/
-static NTSTATUS rpc_trustdom_del_internals(const DOM_SID *domain_sid,
+static NTSTATUS rpc_trustdom_del_internals(struct net_context *c,
+ const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
@@ -5610,18 +5698,19 @@ static NTSTATUS rpc_trustdom_del_internals(const DOM_SID *domain_sid,
* @return Integer status (0 means success)
**/
-static int rpc_trustdom_del(int argc, const char **argv)
+static int rpc_trustdom_del(struct net_context *c, int argc, const char **argv)
{
if (argc > 0) {
- return run_rpc_command(NULL, PI_SAMR, 0, rpc_trustdom_del_internals,
- argc, argv);
+ return run_rpc_command(c, NULL, PI_SAMR, 0,
+ rpc_trustdom_del_internals, argc, argv);
} else {
d_printf("Usage: net rpc trustdom del <domain>\n");
return -1;
}
}
-static NTSTATUS rpc_trustdom_get_pdc(struct cli_state *cli,
+static NTSTATUS rpc_trustdom_get_pdc(struct net_context *c,
+ struct cli_state *cli,
TALLOC_CTX *mem_ctx,
const char *domain_name)
{
@@ -5668,13 +5757,15 @@ static NTSTATUS rpc_trustdom_get_pdc(struct cli_state *cli,
* Establish trust relationship to a trusting domain.
* Interdomain account must already be created on remote PDC.
*
+ * @param c A net_context structure
* @param argc standard argc
* @param argv standard argv without initial components
*
* @return Integer status (0 means success)
**/
-static int rpc_trustdom_establish(int argc, const char **argv)
+static int rpc_trustdom_establish(struct net_context *c, int argc,
+ const char **argv)
{
struct cli_state *cli = NULL;
struct sockaddr_storage server_ss;
@@ -5709,11 +5800,11 @@ static int rpc_trustdom_establish(int argc, const char **argv)
* opt_workgroup will be used by connection functions further,
* hence it should be set to remote domain name instead of ours
*/
- if (opt_workgroup) {
- opt_workgroup = smb_xstrdup(domain_name);
+ if (c->opt_workgroup) {
+ c->opt_workgroup = smb_xstrdup(domain_name);
};
- opt_user_name = acct_name;
+ c->opt_user_name = acct_name;
/* find the domain controller */
if (!net_find_pdc(&server_ss, pdc_name, domain_name)) {
@@ -5722,7 +5813,7 @@ static int rpc_trustdom_establish(int argc, const char **argv)
}
/* connect to ipc$ as username/password */
- nt_status = connect_to_ipc(&cli, &server_ss, pdc_name);
+ nt_status = connect_to_ipc(c, &cli, &server_ss, pdc_name);
if (!NT_STATUS_EQUAL(nt_status, NT_STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT)) {
/* Is it trusting domain account for sure ? */
@@ -5739,7 +5830,8 @@ static int rpc_trustdom_establish(int argc, const char **argv)
* Connect to \\server\ipc$ again (this time anonymously)
*/
- nt_status = connect_to_ipc_anonymous(&cli, &server_ss, (char*)pdc_name);
+ nt_status = connect_to_ipc_anonymous(c, &cli, &server_ss,
+ (char*)pdc_name);
if (NT_STATUS_IS_ERR(nt_status)) {
DEBUG(0, ("Couldn't connect to domain %s controller. Error was %s.\n",
@@ -5756,7 +5848,7 @@ static int rpc_trustdom_establish(int argc, const char **argv)
/* Make sure we're talking to a proper server */
- nt_status = rpc_trustdom_get_pdc(cli, mem_ctx, domain_name);
+ nt_status = rpc_trustdom_get_pdc(c, cli, mem_ctx, domain_name);
if (!NT_STATUS_IS_OK(nt_status)) {
cli_shutdown(cli);
talloc_destroy(mem_ctx);
@@ -5808,7 +5900,7 @@ static int rpc_trustdom_establish(int argc, const char **argv)
* Store the password in secrets db
*/
- if (!pdb_set_trusteddom_pw(domain_name, opt_password, domain_sid)) {
+ if (!pdb_set_trusteddom_pw(domain_name, c->opt_password, domain_sid)) {
DEBUG(0, ("Storing password for trusted domain failed.\n"));
cli_shutdown(cli);
talloc_destroy(mem_ctx);
@@ -5839,13 +5931,15 @@ static int rpc_trustdom_establish(int argc, const char **argv)
/**
* Revoke trust relationship to the remote domain
*
+ * @param c A net_context structure
* @param argc standard argc
* @param argv standard argv without initial components
*
* @return Integer status (0 means success)
**/
-static int rpc_trustdom_revoke(int argc, const char **argv)
+static int rpc_trustdom_revoke(struct net_context *c, int argc,
+ const char **argv)
{
char* domain_name;
int rc = -1;
@@ -5878,7 +5972,8 @@ done:
* @return Integer status returned to shell
**/
-static int rpc_trustdom_usage(int argc, const char **argv)
+static int rpc_trustdom_usage(struct net_context *c, int argc,
+ const char **argv)
{
d_printf(" net rpc trustdom add \t\t add trusting domain's account\n");
d_printf(" net rpc trustdom del \t\t delete trusting domain's account\n");
@@ -5890,7 +5985,8 @@ static int rpc_trustdom_usage(int argc, const char **argv)
}
-static NTSTATUS rpc_query_domain_sid(const DOM_SID *domain_sid,
+static NTSTATUS rpc_query_domain_sid(struct net_context *c,
+ const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
@@ -5978,7 +6074,8 @@ done:
return nt_status;
}
-static int rpc_trustdom_vampire(int argc, const char **argv)
+static int rpc_trustdom_vampire(struct net_context *c, int argc,
+ const char **argv)
{
/* common variables */
TALLOC_CTX* mem_ctx;
@@ -6007,17 +6104,17 @@ static int rpc_trustdom_vampire(int argc, const char **argv)
* or to remote one given in command line
*/
- if (StrCaseCmp(opt_workgroup, lp_workgroup())) {
- domain_name = opt_workgroup;
- opt_target_workgroup = opt_workgroup;
+ if (StrCaseCmp(c->opt_workgroup, lp_workgroup())) {
+ domain_name = c->opt_workgroup;
+ c->opt_target_workgroup = c->opt_workgroup;
} else {
fstrcpy(pdc_name, global_myname());
domain_name = talloc_strdup(mem_ctx, lp_workgroup());
- opt_target_workgroup = domain_name;
+ c->opt_target_workgroup = domain_name;
};
/* open \PIPE\lsarpc and open policy handle */
- nt_status = net_make_ipc_connection(NET_FLAGS_PDC, &cli);
+ nt_status = net_make_ipc_connection(c, NET_FLAGS_PDC, &cli);
if (!NT_STATUS_IS_OK(nt_status)) {
DEBUG(0, ("Couldn't connect to domain controller: %s\n",
nt_errstr(nt_status)));
@@ -6121,7 +6218,7 @@ static int rpc_trustdom_vampire(int argc, const char **argv)
return 0;
}
-static int rpc_trustdom_list(int argc, const char **argv)
+static int rpc_trustdom_list(struct net_context *c, int argc, const char **argv)
{
/* common variables */
TALLOC_CTX* mem_ctx;
@@ -6156,17 +6253,17 @@ static int rpc_trustdom_list(int argc, const char **argv)
* or to remote one given in command line
*/
- if (StrCaseCmp(opt_workgroup, lp_workgroup())) {
- domain_name = opt_workgroup;
- opt_target_workgroup = opt_workgroup;
+ if (StrCaseCmp(c->opt_workgroup, lp_workgroup())) {
+ domain_name = c->opt_workgroup;
+ c->opt_target_workgroup = c->opt_workgroup;
} else {
fstrcpy(pdc_name, global_myname());
domain_name = talloc_strdup(mem_ctx, lp_workgroup());
- opt_target_workgroup = domain_name;
+ c->opt_target_workgroup = domain_name;
};
/* open \PIPE\lsarpc and open policy handle */
- nt_status = net_make_ipc_connection(NET_FLAGS_PDC, &cli);
+ nt_status = net_make_ipc_connection(c, NET_FLAGS_PDC, &cli);
if (!NT_STATUS_IS_OK(nt_status)) {
DEBUG(0, ("Couldn't connect to domain controller: %s\n",
nt_errstr(nt_status)));
@@ -6344,18 +6441,20 @@ static int rpc_trustdom_list(int argc, const char **argv)
/* set opt_* variables to remote domain */
strupper_m(str);
- opt_workgroup = talloc_strdup(mem_ctx, str);
- opt_target_workgroup = opt_workgroup;
+ c->opt_workgroup = talloc_strdup(mem_ctx, str);
+ c->opt_target_workgroup = c->opt_workgroup;
d_printf("%s%s", str, padding);
/* connect to remote domain controller */
- nt_status = net_make_ipc_connection(
+ nt_status = net_make_ipc_connection(c,
NET_FLAGS_PDC | NET_FLAGS_ANONYMOUS,
&remote_cli);
if (NT_STATUS_IS_OK(nt_status)) {
/* query for domain's sid */
- if (run_rpc_command(remote_cli, PI_LSARPC, 0, rpc_query_domain_sid, argc, argv))
+ if (run_rpc_command(c, remote_cli, PI_LSARPC, 0,
+ rpc_query_domain_sid, argc,
+ argv))
d_fprintf(stderr, "couldn't get domain's sid\n");
cli_shutdown(remote_cli);
@@ -6398,7 +6497,7 @@ static int rpc_trustdom_list(int argc, const char **argv)
* @return Integer status (0 means success)
*/
-static int rpc_trustdom(int argc, const char **argv)
+static int rpc_trustdom(struct net_context *c, int argc, const char **argv)
{
struct functable func[] = {
{"add", rpc_trustdom_add},
@@ -6412,11 +6511,11 @@ static int rpc_trustdom(int argc, const char **argv)
};
if (argc == 0) {
- rpc_trustdom_usage(argc, argv);
+ rpc_trustdom_usage(c, argc, argv);
return -1;
}
- return (net_run_function(argc, argv, func, rpc_user_usage));
+ return net_run_function(c, argc, argv, func, rpc_user_usage);
}
/**
@@ -6425,7 +6524,7 @@ static int rpc_trustdom(int argc, const char **argv)
* if the host is not explicitly specified
* @return bool (true means rpc supported)
*/
-bool net_rpc_check(unsigned flags)
+bool net_rpc_check(struct net_context *c, unsigned flags)
{
struct cli_state *cli;
bool ret = False;
@@ -6434,7 +6533,7 @@ bool net_rpc_check(unsigned flags)
NTSTATUS status;
/* flags (i.e. server type) may depend on command */
- if (!net_find_server(NULL, flags, &server_ss, &server_name))
+ if (!net_find_server(c, NULL, flags, &server_ss, &server_name))
return False;
if ((cli = cli_initialise()) == NULL) {
@@ -6459,20 +6558,21 @@ bool net_rpc_check(unsigned flags)
}
/* dump sam database via samsync rpc calls */
-static int rpc_samdump(int argc, const char **argv) {
- return run_rpc_command(NULL, PI_NETLOGON, NET_FLAGS_ANONYMOUS, rpc_samdump_internals,
- argc, argv);
+static int rpc_samdump(struct net_context *c, int argc, const char **argv) {
+ return run_rpc_command(c, NULL, PI_NETLOGON, NET_FLAGS_ANONYMOUS,
+ rpc_samdump_internals, argc, argv);
}
/* syncronise sam database via samsync rpc calls */
-static int rpc_vampire(int argc, const char **argv) {
- return run_rpc_command(NULL, PI_NETLOGON, NET_FLAGS_ANONYMOUS, rpc_vampire_internals,
- argc, argv);
+static int rpc_vampire(struct net_context *c, int argc, const char **argv) {
+ return run_rpc_command(c, NULL, PI_NETLOGON, NET_FLAGS_ANONYMOUS,
+ rpc_vampire_internals, argc, argv);
}
/**
* Migrate everything from a print-server
*
+ * @param c A net_context structure
* @param argc Standard main() style argc
* @param argv Standard main() style argv. Initial components are already
* stripped
@@ -6484,52 +6584,64 @@ static int rpc_vampire(int argc, const char **argv) {
* Applying ACLs should be the last step, because you're easily locked out
*
**/
-static int rpc_printer_migrate_all(int argc, const char **argv)
+static int rpc_printer_migrate_all(struct net_context *c, int argc,
+ const char **argv)
{
int ret;
- if (!opt_host) {
+ if (!c->opt_host) {
printf("no server to migrate\n");
return -1;
}
- ret = run_rpc_command(NULL, PI_SPOOLSS, 0, rpc_printer_migrate_printers_internals, argc, argv);
+ ret = run_rpc_command(c, NULL, PI_SPOOLSS, 0,
+ rpc_printer_migrate_printers_internals, argc,
+ argv);
if (ret)
return ret;
- ret = run_rpc_command(NULL, PI_SPOOLSS, 0, rpc_printer_migrate_drivers_internals, argc, argv);
+ ret = run_rpc_command(c, NULL, PI_SPOOLSS, 0,
+ rpc_printer_migrate_drivers_internals, argc,
+ argv);
if (ret)
return ret;
- ret = run_rpc_command(NULL, PI_SPOOLSS, 0, rpc_printer_migrate_forms_internals, argc, argv);
+ ret = run_rpc_command(c, NULL, PI_SPOOLSS, 0,
+ rpc_printer_migrate_forms_internals, argc, argv);
if (ret)
return ret;
- ret = run_rpc_command(NULL, PI_SPOOLSS, 0, rpc_printer_migrate_settings_internals, argc, argv);
+ ret = run_rpc_command(c, NULL, PI_SPOOLSS, 0,
+ rpc_printer_migrate_settings_internals, argc,
+ argv);
if (ret)
return ret;
- return run_rpc_command(NULL, PI_SPOOLSS, 0, rpc_printer_migrate_security_internals, argc, argv);
+ return run_rpc_command(c, NULL, PI_SPOOLSS, 0,
+ rpc_printer_migrate_security_internals, argc,
+ argv);
}
/**
* Migrate print-drivers from a print-server
*
+ * @param c A net_context structure
* @param argc Standard main() style argc
* @param argv Standard main() style argv. Initial components are already
* stripped
*
* @return A shell status integer (0 for success)
**/
-static int rpc_printer_migrate_drivers(int argc, const char **argv)
+static int rpc_printer_migrate_drivers(struct net_context *c, int argc,
+ const char **argv)
{
- if (!opt_host) {
+ if (!c->opt_host) {
printf("no server to migrate\n");
return -1;
}
- return run_rpc_command(NULL, PI_SPOOLSS, 0,
+ return run_rpc_command(c, NULL, PI_SPOOLSS, 0,
rpc_printer_migrate_drivers_internals,
argc, argv);
}
@@ -6537,20 +6649,22 @@ static int rpc_printer_migrate_drivers(int argc, const char **argv)
/**
* Migrate print-forms from a print-server
*
+ * @param c A net_context structure
* @param argc Standard main() style argc
* @param argv Standard main() style argv. Initial components are already
* stripped
*
* @return A shell status integer (0 for success)
**/
-static int rpc_printer_migrate_forms(int argc, const char **argv)
+static int rpc_printer_migrate_forms(struct net_context *c, int argc,
+ const char **argv)
{
- if (!opt_host) {
+ if (!c->opt_host) {
printf("no server to migrate\n");
return -1;
}
- return run_rpc_command(NULL, PI_SPOOLSS, 0,
+ return run_rpc_command(c, NULL, PI_SPOOLSS, 0,
rpc_printer_migrate_forms_internals,
argc, argv);
}
@@ -6558,20 +6672,22 @@ static int rpc_printer_migrate_forms(int argc, const char **argv)
/**
* Migrate printers from a print-server
*
+ * @param c A net_context structure
* @param argc Standard main() style argc
* @param argv Standard main() style argv. Initial components are already
* stripped
*
* @return A shell status integer (0 for success)
**/
-static int rpc_printer_migrate_printers(int argc, const char **argv)
+static int rpc_printer_migrate_printers(struct net_context *c, int argc,
+ const char **argv)
{
- if (!opt_host) {
+ if (!c->opt_host) {
printf("no server to migrate\n");
return -1;
}
- return run_rpc_command(NULL, PI_SPOOLSS, 0,
+ return run_rpc_command(c, NULL, PI_SPOOLSS, 0,
rpc_printer_migrate_printers_internals,
argc, argv);
}
@@ -6579,20 +6695,22 @@ static int rpc_printer_migrate_printers(int argc, const char **argv)
/**
* Migrate printer-ACLs from a print-server
*
+ * @param c A net_context structure
* @param argc Standard main() style argc
* @param argv Standard main() style argv. Initial components are already
* stripped
*
* @return A shell status integer (0 for success)
**/
-static int rpc_printer_migrate_security(int argc, const char **argv)
+static int rpc_printer_migrate_security(struct net_context *c, int argc,
+ const char **argv)
{
- if (!opt_host) {
+ if (!c->opt_host) {
printf("no server to migrate\n");
return -1;
}
- return run_rpc_command(NULL, PI_SPOOLSS, 0,
+ return run_rpc_command(c, NULL, PI_SPOOLSS, 0,
rpc_printer_migrate_security_internals,
argc, argv);
}
@@ -6600,32 +6718,36 @@ static int rpc_printer_migrate_security(int argc, const char **argv)
/**
* Migrate printer-settings from a print-server
*
+ * @param c A net_context structure
* @param argc Standard main() style argc
* @param argv Standard main() style argv. Initial components are already
* stripped
*
* @return A shell status integer (0 for success)
**/
-static int rpc_printer_migrate_settings(int argc, const char **argv)
+static int rpc_printer_migrate_settings(struct net_context *c, int argc,
+ const char **argv)
{
- if (!opt_host) {
+ if (!c->opt_host) {
printf("no server to migrate\n");
return -1;
}
- return run_rpc_command(NULL, PI_SPOOLSS, 0,
+ return run_rpc_command(c, NULL, PI_SPOOLSS, 0,
rpc_printer_migrate_settings_internals,
argc, argv);
}
/**
* 'net rpc printer' entrypoint.
+ *
+ * @param c A net_context structure
* @param argc Standard main() style argc
* @param argv Standard main() style argv. Initial components are already
* stripped
**/
-int rpc_printer_migrate(int argc, const char **argv)
+int rpc_printer_migrate(struct net_context *c, int argc, const char **argv)
{
/* ouch: when addriver and setdriver are called from within
@@ -6643,23 +6765,24 @@ int rpc_printer_migrate(int argc, const char **argv)
{NULL, NULL}
};
- return net_run_function(argc, argv, func, rpc_printer_usage);
+ return net_run_function(c, argc, argv, func, rpc_printer_usage);
}
/**
* List printers on a remote RPC server
*
+ * @param c A net_context structure
* @param argc Standard main() style argc
* @param argv Standard main() style argv. Initial components are already
* stripped
*
* @return A shell status integer (0 for success)
**/
-static int rpc_printer_list(int argc, const char **argv)
+static int rpc_printer_list(struct net_context *c, int argc, const char **argv)
{
- return run_rpc_command(NULL, PI_SPOOLSS, 0,
+ return run_rpc_command(c, NULL, PI_SPOOLSS, 0,
rpc_printer_list_internals,
argc, argv);
}
@@ -6667,16 +6790,18 @@ static int rpc_printer_list(int argc, const char **argv)
/**
* List printer-drivers on a remote RPC server
*
+ * @param c A net_context structure
* @param argc Standard main() style argc
* @param argv Standard main() style argv. Initial components are already
* stripped
*
* @return A shell status integer (0 for success)
**/
-static int rpc_printer_driver_list(int argc, const char **argv)
+static int rpc_printer_driver_list(struct net_context *c, int argc,
+ const char **argv)
{
- return run_rpc_command(NULL, PI_SPOOLSS, 0,
+ return run_rpc_command(c, NULL, PI_SPOOLSS, 0,
rpc_printer_driver_list_internals,
argc, argv);
}
@@ -6684,16 +6809,18 @@ static int rpc_printer_driver_list(int argc, const char **argv)
/**
* Publish printer in ADS via MSRPC
*
+ * @param c A net_context structure
* @param argc Standard main() style argc
* @param argv Standard main() style argv. Initial components are already
* stripped
*
* @return A shell status integer (0 for success)
**/
-static int rpc_printer_publish_publish(int argc, const char **argv)
+static int rpc_printer_publish_publish(struct net_context *c, int argc,
+ const char **argv)
{
- return run_rpc_command(NULL, PI_SPOOLSS, 0,
+ return run_rpc_command(c, NULL, PI_SPOOLSS, 0,
rpc_printer_publish_publish_internals,
argc, argv);
}
@@ -6701,16 +6828,17 @@ static int rpc_printer_publish_publish(int argc, const char **argv)
/**
* Update printer in ADS via MSRPC
*
+ * @param c A net_context structure
* @param argc Standard main() style argc
* @param argv Standard main() style argv. Initial components are already
* stripped
*
* @return A shell status integer (0 for success)
**/
-static int rpc_printer_publish_update(int argc, const char **argv)
+static int rpc_printer_publish_update(struct net_context *c, int argc, const char **argv)
{
- return run_rpc_command(NULL, PI_SPOOLSS, 0,
+ return run_rpc_command(c, NULL, PI_SPOOLSS, 0,
rpc_printer_publish_update_internals,
argc, argv);
}
@@ -6718,16 +6846,18 @@ static int rpc_printer_publish_update(int argc, const char **argv)
/**
* UnPublish printer in ADS via MSRPC
*
+ * @param c A net_context structure
* @param argc Standard main() style argc
* @param argv Standard main() style argv. Initial components are already
* stripped
*
* @return A shell status integer (0 for success)
**/
-static int rpc_printer_publish_unpublish(int argc, const char **argv)
+static int rpc_printer_publish_unpublish(struct net_context *c, int argc,
+ const char **argv)
{
- return run_rpc_command(NULL, PI_SPOOLSS, 0,
+ return run_rpc_command(c, NULL, PI_SPOOLSS, 0,
rpc_printer_publish_unpublish_internals,
argc, argv);
}
@@ -6735,16 +6865,18 @@ static int rpc_printer_publish_unpublish(int argc, const char **argv)
/**
* List published printers via MSRPC
*
+ * @param c A net_context structure
* @param argc Standard main() style argc
* @param argv Standard main() style argv. Initial components are already
* stripped
*
* @return A shell status integer (0 for success)
**/
-static int rpc_printer_publish_list(int argc, const char **argv)
+static int rpc_printer_publish_list(struct net_context *c, int argc,
+ const char **argv)
{
- return run_rpc_command(NULL, PI_SPOOLSS, 0,
+ return run_rpc_command(c, NULL, PI_SPOOLSS, 0,
rpc_printer_publish_list_internals,
argc, argv);
}
@@ -6753,13 +6885,15 @@ static int rpc_printer_publish_list(int argc, const char **argv)
/**
* Publish printer in ADS
*
+ * @param c A net_context structure
* @param argc Standard main() style argc
* @param argv Standard main() style argv. Initial components are already
* stripped
*
* @return A shell status integer (0 for success)
**/
-static int rpc_printer_publish(int argc, const char **argv)
+static int rpc_printer_publish(struct net_context *c, int argc,
+ const char **argv)
{
struct functable func[] = {
@@ -6772,33 +6906,37 @@ static int rpc_printer_publish(int argc, const char **argv)
};
if (argc == 0)
- return run_rpc_command(NULL, PI_SPOOLSS, 0,
+ return run_rpc_command(c, NULL, PI_SPOOLSS, 0,
rpc_printer_publish_list_internals,
argc, argv);
- return net_run_function(argc, argv, func, rpc_printer_usage);
+ return net_run_function(c, argc, argv, func, rpc_printer_usage);
}
/**
* Display rpc printer help page.
+ *
+ * @param c A net_context structure
* @param argc Standard main() style argc
* @param argv Standard main() style argv. Initial components are already
* stripped
**/
-int rpc_printer_usage(int argc, const char **argv)
+int rpc_printer_usage(struct net_context *c, int argc, const char **argv)
{
- return net_help_printer(argc, argv);
+ return net_help_printer(c, argc, argv);
}
/**
* 'net rpc printer' entrypoint.
+ *
+ * @param c A net_context structure
* @param argc Standard main() style argc
* @param argv Standard main() style argv. Initial components are already
* stripped
**/
-int net_rpc_printer(int argc, const char **argv)
+int net_rpc_printer(struct net_context *c, int argc, const char **argv)
{
struct functable func[] = {
{"list", rpc_printer_list},
@@ -6809,11 +6947,11 @@ int net_rpc_printer(int argc, const char **argv)
};
if (argc == 0)
- return run_rpc_command(NULL, PI_SPOOLSS, 0,
+ return run_rpc_command(c, NULL, PI_SPOOLSS, 0,
rpc_printer_list_internals,
argc, argv);
- return net_run_function(argc, argv, func, rpc_printer_usage);
+ return net_run_function(c, argc, argv, func, rpc_printer_usage);
}
/****************************************************************************/
@@ -6821,12 +6959,14 @@ int net_rpc_printer(int argc, const char **argv)
/**
* Basic usage function for 'net rpc'
+ *
+ * @param c A net_context structure
* @param argc Standard main() style argc
* @param argv Standard main() style argv. Initial components are already
* stripped
**/
-int net_rpc_usage(int argc, const char **argv)
+int net_rpc_usage(struct net_context *c, int argc, const char **argv)
{
d_printf(" net rpc info \t\t\tshow basic info about a domain \n");
d_printf(" net rpc join \t\t\tto join a domain \n");
@@ -6863,12 +7003,14 @@ int net_rpc_usage(int argc, const char **argv)
/**
* Help function for 'net rpc'. Calls command specific help if requested
* or displays usage of net rpc
+ *
+ * @param c A net_context structure
* @param argc Standard main() style argc
* @param argv Standard main() style argv. Initial components are already
* stripped
**/
-int net_rpc_help(int argc, const char **argv)
+int net_rpc_help(struct net_context *c, int argc, const char **argv)
{
struct functable func[] = {
{"join", rpc_join_usage},
@@ -6884,21 +7026,23 @@ int net_rpc_help(int argc, const char **argv)
};
if (argc == 0) {
- net_rpc_usage(argc, argv);
+ net_rpc_usage(c, argc, argv);
return -1;
}
- return (net_run_function(argc, argv, func, rpc_user_usage));
+ return net_run_function(c, argc, argv, func, rpc_user_usage);
}
/**
* 'net rpc' entrypoint.
+ *
+ * @param c A net_context structure
* @param argc Standard main() style argc
* @param argv Standard main() style argv. Initial components are already
* stripped
**/
-int net_rpc(int argc, const char **argv)
+int net_rpc(struct net_context *c, int argc, const char **argv)
{
struct functable func[] = {
{"audit", net_rpc_audit},
@@ -6926,5 +7070,5 @@ int net_rpc(int argc, const char **argv)
{"help", net_rpc_help},
{NULL, NULL}
};
- return net_run_function(argc, argv, func, net_rpc_usage);
+ return net_run_function(c, argc, argv, func, net_rpc_usage);
}
diff --git a/source3/utils/net_rpc_audit.c b/source3/utils/net_rpc_audit.c
index a846395bb8a..4ba986464e5 100644
--- a/source3/utils/net_rpc_audit.c
+++ b/source3/utils/net_rpc_audit.c
@@ -22,7 +22,7 @@
/********************************************************************
********************************************************************/
-static int net_help_audit(int argc, const char **argv)
+static int net_help_audit(struct net_context *c, int argc, const char **argv)
{
d_printf("net rpc audit list View configured Auditing policies\n");
d_printf("net rpc audit enable Enable Auditing\n");
@@ -61,7 +61,8 @@ static void print_auditing_category(const char *policy, const char *value)
/********************************************************************
********************************************************************/
-static NTSTATUS rpc_audit_get_internal(const DOM_SID *domain_sid,
+static NTSTATUS rpc_audit_get_internal(struct net_context *c,
+ const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
@@ -77,7 +78,7 @@ static NTSTATUS rpc_audit_get_internal(const DOM_SID *domain_sid,
if (argc < 1 || argc > 2) {
d_printf("insufficient arguments\n");
- net_help_audit(argc, argv);
+ net_help_audit(c, argc, argv);
return NT_STATUS_INVALID_PARAMETER;
}
@@ -128,7 +129,8 @@ static NTSTATUS rpc_audit_get_internal(const DOM_SID *domain_sid,
/********************************************************************
********************************************************************/
-static NTSTATUS rpc_audit_set_internal(const DOM_SID *domain_sid,
+static NTSTATUS rpc_audit_set_internal(struct net_context *c,
+ const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
@@ -143,7 +145,7 @@ static NTSTATUS rpc_audit_set_internal(const DOM_SID *domain_sid,
if (argc < 2 || argc > 3) {
d_printf("insufficient arguments\n");
- net_help_audit(argc, argv);
+ net_help_audit(c, argc, argv);
return NT_STATUS_INVALID_PARAMETER;
}
@@ -265,7 +267,8 @@ static NTSTATUS rpc_audit_enable_internal_ext(struct rpc_pipe_client *pipe_hnd,
/********************************************************************
********************************************************************/
-static NTSTATUS rpc_audit_disable_internal(const DOM_SID *domain_sid,
+static NTSTATUS rpc_audit_disable_internal(struct net_context *c,
+ const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
@@ -280,7 +283,8 @@ static NTSTATUS rpc_audit_disable_internal(const DOM_SID *domain_sid,
/********************************************************************
********************************************************************/
-static NTSTATUS rpc_audit_enable_internal(const DOM_SID *domain_sid,
+static NTSTATUS rpc_audit_enable_internal(struct net_context *c,
+ const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
@@ -295,7 +299,8 @@ static NTSTATUS rpc_audit_enable_internal(const DOM_SID *domain_sid,
/********************************************************************
********************************************************************/
-static NTSTATUS rpc_audit_list_internal(const DOM_SID *domain_sid,
+static NTSTATUS rpc_audit_list_internal(struct net_context *c,
+ const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
@@ -359,52 +364,52 @@ static NTSTATUS rpc_audit_list_internal(const DOM_SID *domain_sid,
/********************************************************************
********************************************************************/
-static int rpc_audit_get(int argc, const char **argv)
+static int rpc_audit_get(struct net_context *c, int argc, const char **argv)
{
- return run_rpc_command(NULL, PI_LSARPC, 0,
+ return run_rpc_command(c, NULL, PI_LSARPC, 0,
rpc_audit_get_internal, argc, argv);
}
/********************************************************************
********************************************************************/
-static int rpc_audit_set(int argc, const char **argv)
+static int rpc_audit_set(struct net_context *c, int argc, const char **argv)
{
- return run_rpc_command(NULL, PI_LSARPC, 0,
+ return run_rpc_command(c, NULL, PI_LSARPC, 0,
rpc_audit_set_internal, argc, argv);
}
/********************************************************************
********************************************************************/
-static int rpc_audit_enable(int argc, const char **argv)
+static int rpc_audit_enable(struct net_context *c, int argc, const char **argv)
{
- return run_rpc_command(NULL, PI_LSARPC, 0,
+ return run_rpc_command(c, NULL, PI_LSARPC, 0,
rpc_audit_enable_internal, argc, argv);
}
/********************************************************************
********************************************************************/
-static int rpc_audit_disable(int argc, const char **argv)
+static int rpc_audit_disable(struct net_context *c, int argc, const char **argv)
{
- return run_rpc_command(NULL, PI_LSARPC, 0,
+ return run_rpc_command(c, NULL, PI_LSARPC, 0,
rpc_audit_disable_internal, argc, argv);
}
/********************************************************************
********************************************************************/
-static int rpc_audit_list(int argc, const char **argv)
+static int rpc_audit_list(struct net_context *c, int argc, const char **argv)
{
- return run_rpc_command(NULL, PI_LSARPC, 0,
+ return run_rpc_command(c, NULL, PI_LSARPC, 0,
rpc_audit_list_internal, argc, argv);
}
/********************************************************************
********************************************************************/
-int net_rpc_audit(int argc, const char **argv)
+int net_rpc_audit(struct net_context *c, int argc, const char **argv)
{
struct functable func[] = {
{"get", rpc_audit_get},
@@ -416,7 +421,7 @@ int net_rpc_audit(int argc, const char **argv)
};
if (argc)
- return net_run_function(argc, argv, func, net_help_audit);
+ return net_run_function(c, argc, argv, func, net_help_audit);
- return net_help_audit(argc, argv);
+ return net_help_audit(c, argc, argv);
}
diff --git a/source3/utils/net_rpc_join.c b/source3/utils/net_rpc_join.c
index c94e9d1a408..2777324e81f 100644
--- a/source3/utils/net_rpc_join.c
+++ b/source3/utils/net_rpc_join.c
@@ -41,8 +41,8 @@
* @return A shell status integer (0 for success)
*
**/
-NTSTATUS net_rpc_join_ok(const char *domain, const char *server,
- struct sockaddr_storage *pss)
+NTSTATUS net_rpc_join_ok(struct net_context *c, const char *domain,
+ const char *server, struct sockaddr_storage *pss)
{
enum security_types sec;
unsigned int conn_flags = NET_FLAGS_PDC;
@@ -57,7 +57,7 @@ NTSTATUS net_rpc_join_ok(const char *domain, const char *server,
if (sec == SEC_ADS) {
/* Connect to IPC$ using machine account's credentials. We don't use anonymous
connection here, as it may be denied by server's local policy. */
- net_use_machine_account();
+ net_use_machine_account(c);
} else {
/* some servers (e.g. WinNT) don't accept machine-authenticated
@@ -66,7 +66,8 @@ NTSTATUS net_rpc_join_ok(const char *domain, const char *server,
}
/* Connect to remote machine */
- ntret = net_make_ipc_connection_ex(domain, server, pss, conn_flags, &cli);
+ ntret = net_make_ipc_connection_ex(c, domain, server, pss, conn_flags,
+ &cli);
if (!NT_STATUS_IS_OK(ntret)) {
return ntret;
}
@@ -125,7 +126,7 @@ NTSTATUS net_rpc_join_ok(const char *domain, const char *server,
*
**/
-int net_rpc_join_newstyle(int argc, const char **argv)
+int net_rpc_join_newstyle(struct net_context *c, int argc, const char **argv)
{
/* libsmb variables */
@@ -186,7 +187,7 @@ int net_rpc_join_newstyle(int argc, const char **argv)
/* Make authenticated connection to remote machine */
- result = net_make_ipc_connection(NET_FLAGS_PDC, &cli);
+ result = net_make_ipc_connection(c, NET_FLAGS_PDC, &cli);
if (!NT_STATUS_IS_OK(result)) {
return 1;
}
@@ -448,7 +449,7 @@ int net_rpc_join_newstyle(int argc, const char **argv)
}
/* double-check, connection from scratch */
- result = net_rpc_join_ok(domain, cli->desthost, &cli->dest_ss);
+ result = net_rpc_join_ok(c, domain, cli->desthost, &cli->dest_ss);
retval = NT_STATUS_IS_OK(result) ? 0 : -1;
done:
@@ -476,13 +477,13 @@ done:
* @return A shell status integer (0 for success)
*
**/
-int net_rpc_testjoin(int argc, const char **argv)
+int net_rpc_testjoin(struct net_context *c, int argc, const char **argv)
{
- char *domain = smb_xstrdup(opt_target_workgroup);
+ char *domain = smb_xstrdup(c->opt_target_workgroup);
NTSTATUS nt_status;
/* Display success or failure */
- nt_status = net_rpc_join_ok(domain, NULL, NULL);
+ nt_status = net_rpc_join_ok(c, domain, NULL, NULL);
if (!NT_STATUS_IS_OK(nt_status)) {
fprintf(stderr,"Join to domain '%s' is not valid: %s\n",
domain, nt_errstr(nt_status));
diff --git a/source3/utils/net_rpc_printer.c b/source3/utils/net_rpc_printer.c
index bdf5b09205e..4c1985a0af4 100644
--- a/source3/utils/net_rpc_printer.c
+++ b/source3/utils/net_rpc_printer.c
@@ -14,8 +14,8 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
#include "includes.h"
#include "utils/net.h"
@@ -161,6 +161,7 @@ static void display_reg_value(const char *subkey, REGISTRY_VALUE value)
* Copies ACLs, DOS-attributes and timestamps from one
* file or directory from one connected share to another connected share
*
+ * @param c A net_context structure
* @param mem_ctx A talloc-context
* @param cli_share_src A connected cli_state
* @param cli_share_dst A connected cli_state
@@ -174,7 +175,8 @@ static void display_reg_value(const char *subkey, REGISTRY_VALUE value)
* @return Normal NTSTATUS return.
**/
-NTSTATUS net_copy_fileattr(TALLOC_CTX *mem_ctx,
+NTSTATUS net_copy_fileattr(struct net_context *c,
+ TALLOC_CTX *mem_ctx,
struct cli_state *cli_share_src,
struct cli_state *cli_share_dst,
const char *src_name, const char *dst_name,
@@ -217,7 +219,7 @@ NTSTATUS net_copy_fileattr(TALLOC_CTX *mem_ctx,
goto out;
}
- if (opt_verbose && DEBUGLEVEL >= 3)
+ if (c->opt_verbose && DEBUGLEVEL >= 3)
display_sec_desc(sd);
}
@@ -313,6 +315,7 @@ out:
/**
* Copy a file or directory from a connected share to another connected share
*
+ * @param c A net_context structure
* @param mem_ctx A talloc-context
* @param cli_share_src A connected cli_state
* @param cli_share_dst A connected cli_state
@@ -326,7 +329,8 @@ out:
* @return Normal NTSTATUS return.
**/
-NTSTATUS net_copy_file(TALLOC_CTX *mem_ctx,
+NTSTATUS net_copy_file(struct net_context *c,
+ TALLOC_CTX *mem_ctx,
struct cli_state *cli_share_src,
struct cli_state *cli_share_dst,
const char *src_name, const char *dst_name,
@@ -348,7 +352,6 @@ NTSTATUS net_copy_file(TALLOC_CTX *mem_ctx,
if (cli_share_src == NULL || cli_share_dst == NULL)
goto out;
-
/* open on the originating server */
DEBUGADD(3,("opening %s %s on originating server\n",
is_file ? "file":"dir", src_name));
@@ -390,7 +393,7 @@ NTSTATUS net_copy_file(TALLOC_CTX *mem_ctx,
}
- if (opt_verbose) {
+ if (c->opt_verbose) {
d_printf("copying [\\\\%s\\%s%s] => [\\\\%s\\%s%s] "
"%s ACLs and %s DOS Attributes %s\n",
@@ -462,7 +465,7 @@ NTSTATUS net_copy_file(TALLOC_CTX *mem_ctx,
}
/* possibly we have to copy some file-attributes / acls / sd */
- nt_status = net_copy_fileattr(mem_ctx, cli_share_src, cli_share_dst,
+ nt_status = net_copy_fileattr(c, mem_ctx, cli_share_src, cli_share_dst,
src_name, dst_name, copy_acls,
copy_attrs, copy_timestamps, is_file);
if (!NT_STATUS_IS_OK(nt_status))
@@ -496,6 +499,7 @@ out:
* \\dst_server\print$\{arch}\file
*
* to be added via setdriver-calls later.
+ * @param c A net_context structure
* @param mem_ctx A talloc-context
* @param cli_share_src A cli_state connected to source print$-share
* @param cli_share_dst A cli_state connected to destination print$-share
@@ -505,7 +509,8 @@ out:
* @return Normal NTSTATUS return.
**/
-static NTSTATUS net_copy_driverfile(TALLOC_CTX *mem_ctx,
+static NTSTATUS net_copy_driverfile(struct net_context *c,
+ TALLOC_CTX *mem_ctx,
struct cli_state *cli_share_src,
struct cli_state *cli_share_dst,
char *file, const char *short_archi) {
@@ -539,8 +544,8 @@ static NTSTATUS net_copy_driverfile(TALLOC_CTX *mem_ctx,
/* finally copy the file */
- nt_status = net_copy_file(mem_ctx, cli_share_src, cli_share_dst,
- src_name, dst_name, False, False, False, True);
+ nt_status = net_copy_file(c, mem_ctx, cli_share_src, cli_share_dst,
+ src_name, dst_name, false, false, false, true);
if (!NT_STATUS_IS_OK(nt_status))
goto out;
@@ -598,6 +603,7 @@ out:
* Copy a print-driver (level 3) from one connected print$-share to another
* connected print$-share
*
+ * @param c A net_context structure
* @param mem_ctx A talloc-context
* @param cli_share_src A cli_state connected to a print$-share
* @param cli_share_dst A cli_state connected to a print$-share
@@ -607,7 +613,8 @@ out:
* @return Normal NTSTATUS return.
**/
-static NTSTATUS copy_print_driver_3(TALLOC_CTX *mem_ctx,
+static NTSTATUS copy_print_driver_3(struct net_context *c,
+ TALLOC_CTX *mem_ctx,
struct cli_state *cli_share_src,
struct cli_state *cli_share_dst,
const char *short_archi, DRIVER_INFO_3 *i1)
@@ -633,26 +640,26 @@ static NTSTATUS copy_print_driver_3(TALLOC_CTX *mem_ctx,
rpcstr_pull(helpfile, i1->helpfile.buffer, sizeof(helpfile), -1, STR_TERMINATE);
- if (opt_verbose)
+ if (c->opt_verbose)
d_printf("copying driver: [%s], for architecture: [%s], version: [%d]\n",
name, short_archi, i1->version);
- nt_status = net_copy_driverfile(mem_ctx, cli_share_src, cli_share_dst,
+ nt_status = net_copy_driverfile(c, mem_ctx, cli_share_src, cli_share_dst,
driverpath, short_archi);
if (!NT_STATUS_IS_OK(nt_status))
return nt_status;
- nt_status = net_copy_driverfile(mem_ctx, cli_share_src, cli_share_dst,
+ nt_status = net_copy_driverfile(c, mem_ctx, cli_share_src, cli_share_dst,
datafile, short_archi);
if (!NT_STATUS_IS_OK(nt_status))
return nt_status;
- nt_status = net_copy_driverfile(mem_ctx, cli_share_src, cli_share_dst,
+ nt_status = net_copy_driverfile(c, mem_ctx, cli_share_src, cli_share_dst,
configfile, short_archi);
if (!NT_STATUS_IS_OK(nt_status))
return nt_status;
- nt_status = net_copy_driverfile(mem_ctx, cli_share_src, cli_share_dst,
+ nt_status = net_copy_driverfile(c, mem_ctx, cli_share_src, cli_share_dst,
helpfile, short_archi);
if (!NT_STATUS_IS_OK(nt_status))
return nt_status;
@@ -664,7 +671,7 @@ static NTSTATUS copy_print_driver_3(TALLOC_CTX *mem_ctx,
if (strlen(dependentfiles) > 0) {
- nt_status = net_copy_driverfile(mem_ctx,
+ nt_status = net_copy_driverfile(c, mem_ctx,
cli_share_src, cli_share_dst,
dependentfiles, short_archi);
if (!NT_STATUS_IS_OK(nt_status))
@@ -879,7 +886,6 @@ static bool net_spoolss_enumforms(struct rpc_pipe_client *pipe_hnd,
int level,
uint32 *num_forms,
FORM_1 **forms)
-
{
WERROR result;
@@ -1021,6 +1027,7 @@ out:
* All parameters are provided by the run_rpc_command function, except for
* argc, argv which are passed through.
*
+ * @param c A net_context structure
* @param domain_sid The domain sid aquired from the remote server
* @param cli A cli_state connected to the server.
* @param mem_ctx Talloc context, destoyed on compleation of the function.
@@ -1031,7 +1038,8 @@ out:
* @return Normal NTSTATUS return.
**/
-NTSTATUS rpc_printer_list_internals(const DOM_SID *domain_sid,
+NTSTATUS rpc_printer_list_internals(struct net_context *c,
+ const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
@@ -1078,6 +1086,7 @@ NTSTATUS rpc_printer_list_internals(const DOM_SID *domain_sid,
* All parameters are provided by the run_rpc_command function, except for
* argc, argv which are passed through.
*
+ * @param c A net_context structure
* @param domain_sid The domain sid aquired from the remote server
* @param cli A cli_state connected to the server.
* @param mem_ctx Talloc context, destoyed on compleation of the function.
@@ -1088,7 +1097,8 @@ NTSTATUS rpc_printer_list_internals(const DOM_SID *domain_sid,
* @return Normal NTSTATUS return.
**/
-NTSTATUS rpc_printer_driver_list_internals(const DOM_SID *domain_sid,
+NTSTATUS rpc_printer_driver_list_internals(struct net_context *c,
+ const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
@@ -1114,7 +1124,6 @@ NTSTATUS rpc_printer_driver_list_internals(const DOM_SID *domain_sid,
if (!net_spoolss_enumprinterdrivers(pipe_hnd, mem_ctx, level,
archi_table[i].long_archi,
&num_drivers, &drv_ctr_enum)) {
-
nt_status = NT_STATUS_UNSUCCESSFUL;
goto done;
}
@@ -1238,7 +1247,8 @@ done:
return nt_status;
}
-NTSTATUS rpc_printer_publish_publish_internals(const DOM_SID *domain_sid,
+NTSTATUS rpc_printer_publish_publish_internals(struct net_context *c,
+ const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
@@ -1249,7 +1259,8 @@ NTSTATUS rpc_printer_publish_publish_internals(const DOM_SID *domain_sid,
return rpc_printer_publish_internals_args(pipe_hnd, mem_ctx, argc, argv, SPOOL_DS_PUBLISH);
}
-NTSTATUS rpc_printer_publish_unpublish_internals(const DOM_SID *domain_sid,
+NTSTATUS rpc_printer_publish_unpublish_internals(struct net_context *c,
+ const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
@@ -1260,7 +1271,8 @@ NTSTATUS rpc_printer_publish_unpublish_internals(const DOM_SID *domain_sid,
return rpc_printer_publish_internals_args(pipe_hnd, mem_ctx, argc, argv, SPOOL_DS_UNPUBLISH);
}
-NTSTATUS rpc_printer_publish_update_internals(const DOM_SID *domain_sid,
+NTSTATUS rpc_printer_publish_update_internals(struct net_context *c,
+ const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
@@ -1277,6 +1289,7 @@ NTSTATUS rpc_printer_publish_update_internals(const DOM_SID *domain_sid,
* All parameters are provided by the run_rpc_command function, except for
* argc, argv which are passed through.
*
+ * @param c A net_context structure
* @param domain_sid The domain sid aquired from the remote server
* @param cli A cli_state connected to the server.
* @param mem_ctx Talloc context, destoyed on compleation of the function.
@@ -1287,7 +1300,8 @@ NTSTATUS rpc_printer_publish_update_internals(const DOM_SID *domain_sid,
* @return Normal NTSTATUS return.
**/
-NTSTATUS rpc_printer_publish_list_internals(const DOM_SID *domain_sid,
+NTSTATUS rpc_printer_publish_list_internals(struct net_context *c,
+ const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
@@ -1349,7 +1363,7 @@ NTSTATUS rpc_printer_publish_list_internals(const DOM_SID *domain_sid,
switch (state) {
case SPOOL_DS_PUBLISH:
printf("printer [%s] is published", sharename);
- if (opt_verbose)
+ if (c->opt_verbose)
printf(", guid: %s", guid);
printf("\n");
break;
@@ -1380,6 +1394,7 @@ done:
* All parameters are provided by the run_rpc_command function, except for
* argc, argv which are passed through.
*
+ * @param c A net_context structure
* @param domain_sid The domain sid aquired from the remote server
* @param cli A cli_state connected to the server.
* @param mem_ctx Talloc context, destoyed on compleation of the function.
@@ -1390,7 +1405,8 @@ done:
* @return Normal NTSTATUS return.
**/
-NTSTATUS rpc_printer_migrate_security_internals(const DOM_SID *domain_sid,
+NTSTATUS rpc_printer_migrate_security_internals(struct net_context *c,
+ const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
@@ -1418,7 +1434,7 @@ NTSTATUS rpc_printer_migrate_security_internals(const DOM_SID *domain_sid,
DEBUG(3,("copying printer ACLs\n"));
/* connect destination PI_SPOOLSS */
- nt_status = connect_dst_pipe(&cli_dst, &pipe_hnd_dst, PI_SPOOLSS);
+ nt_status = connect_dst_pipe(c, &cli_dst, &pipe_hnd_dst, PI_SPOOLSS);
if (!NT_STATUS_IS_OK(nt_status))
return nt_status;
@@ -1494,7 +1510,7 @@ NTSTATUS rpc_printer_migrate_security_internals(const DOM_SID *domain_sid,
ctr_dst.printers_2->devmode = NULL;
ctr_dst.printers_2->secdesc = dup_sec_desc(mem_ctx, ctr_src.printers_3->secdesc);
- if (opt_verbose)
+ if (c->opt_verbose)
display_sec_desc(ctr_dst.printers_2->secdesc);
if (!net_spoolss_setprinter(pipe_hnd_dst, mem_ctx, &hnd_dst, 2, &ctr_dst))
@@ -1540,6 +1556,7 @@ done:
* All parameters are provided by the run_rpc_command function, except for
* argc, argv which are passed through.
*
+ * @param c A net_context structure
* @param domain_sid The domain sid aquired from the remote server
* @param cli A cli_state connected to the server.
* @param mem_ctx Talloc context, destoyed on compleation of the function.
@@ -1550,7 +1567,8 @@ done:
* @return Normal NTSTATUS return.
**/
-NTSTATUS rpc_printer_migrate_forms_internals(const DOM_SID *domain_sid,
+NTSTATUS rpc_printer_migrate_forms_internals(struct net_context *c,
+ const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
@@ -1578,7 +1596,7 @@ NTSTATUS rpc_printer_migrate_forms_internals(const DOM_SID *domain_sid,
DEBUG(3,("copying forms\n"));
/* connect destination PI_SPOOLSS */
- nt_status = connect_dst_pipe(&cli_dst, &pipe_hnd_dst, PI_SPOOLSS);
+ nt_status = connect_dst_pipe(c, &cli_dst, &pipe_hnd_dst, PI_SPOOLSS);
if (!NT_STATUS_IS_OK(nt_status))
return nt_status;
@@ -1660,7 +1678,7 @@ NTSTATUS rpc_printer_migrate_forms_internals(const DOM_SID *domain_sid,
rpcstr_pull(form_name, forms[f].name.buffer,
sizeof(form_name), -1, STR_TERMINATE);
- if (opt_verbose)
+ if (c->opt_verbose)
d_printf("\tmigrating form # %d [%s] of type [%d]\n",
f, form_name, forms[f].flag);
@@ -1723,6 +1741,7 @@ done:
* All parameters are provided by the run_rpc_command function, except for
* argc, argv which are passed through.
*
+ * @param c A net_context structure
* @param domain_sid The domain sid aquired from the remote server
* @param cli A cli_state connected to the server.
* @param mem_ctx Talloc context, destoyed on compleation of the function.
@@ -1733,7 +1752,8 @@ done:
* @return Normal NTSTATUS return.
**/
-NTSTATUS rpc_printer_migrate_drivers_internals(const DOM_SID *domain_sid,
+NTSTATUS rpc_printer_migrate_drivers_internals(struct net_context *c,
+ const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
@@ -1766,12 +1786,12 @@ NTSTATUS rpc_printer_migrate_drivers_internals(const DOM_SID *domain_sid,
DEBUG(3,("copying printer-drivers\n"));
- nt_status = connect_dst_pipe(&cli_dst, &pipe_hnd_dst, PI_SPOOLSS);
+ nt_status = connect_dst_pipe(c, &cli_dst, &pipe_hnd_dst, PI_SPOOLSS);
if (!NT_STATUS_IS_OK(nt_status))
return nt_status;
/* open print$-share on the src server */
- nt_status = connect_to_service(&cli_share_src, &cli->dest_ss,
+ nt_status = connect_to_service(c, &cli_share_src, &cli->dest_ss,
cli->desthost, "print$", "A:");
if (!NT_STATUS_IS_OK(nt_status))
goto done;
@@ -1780,7 +1800,7 @@ NTSTATUS rpc_printer_migrate_drivers_internals(const DOM_SID *domain_sid,
/* open print$-share on the dst server */
- nt_status = connect_to_service(&cli_share_dst, &cli_dst->dest_ss,
+ nt_status = connect_to_service(c, &cli_share_dst, &cli_dst->dest_ss,
cli_dst->desthost, "print$", "A:");
if (!NT_STATUS_IS_OK(nt_status))
return nt_status;
@@ -1862,7 +1882,7 @@ NTSTATUS rpc_printer_migrate_drivers_internals(const DOM_SID *domain_sid,
rpcstr_pull(drivername, drv_ctr_src.info3->name.buffer,
sizeof(drivername), -1, STR_TERMINATE);
- if (opt_verbose)
+ if (c->opt_verbose)
display_print_driver_3(drv_ctr_src.info3);
@@ -1873,7 +1893,7 @@ NTSTATUS rpc_printer_migrate_drivers_internals(const DOM_SID *domain_sid,
/* copy driver-files */
- nt_status = copy_print_driver_3(mem_ctx, cli_share_src, cli_share_dst,
+ nt_status = copy_print_driver_3(c, mem_ctx, cli_share_src, cli_share_dst,
archi_table[i].short_archi,
drv_ctr_src.info3);
if (!NT_STATUS_IS_OK(nt_status))
@@ -1952,6 +1972,7 @@ done:
* All parameters are provided by the run_rpc_command function, except for
* argc, argv which are passed through.
*
+ * @param c A net_context structure
* @param domain_sid The domain sid aquired from the remote server
* @param cli A cli_state connected to the server.
* @param mem_ctx Talloc context, destoyed on compleation of the function.
@@ -1962,7 +1983,8 @@ done:
* @return Normal NTSTATUS return.
**/
-NTSTATUS rpc_printer_migrate_printers_internals(const DOM_SID *domain_sid,
+NTSTATUS rpc_printer_migrate_printers_internals(struct net_context *c,
+ const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
@@ -1985,7 +2007,7 @@ NTSTATUS rpc_printer_migrate_printers_internals(const DOM_SID *domain_sid,
DEBUG(3,("copying printers\n"));
/* connect destination PI_SPOOLSS */
- nt_status = connect_dst_pipe(&cli_dst, &pipe_hnd_dst, PI_SPOOLSS);
+ nt_status = connect_dst_pipe(c, &cli_dst, &pipe_hnd_dst, PI_SPOOLSS);
if (!NT_STATUS_IS_OK(nt_status))
return nt_status;
@@ -2109,6 +2131,7 @@ done:
* All parameters are provided by the run_rpc_command function, except for
* argc, argv which are passed through.
*
+ * @param c A net_context structure
* @param domain_sid The domain sid aquired from the remote server
* @param cli A cli_state connected to the server.
* @param mem_ctx Talloc context, destoyed on compleation of the function.
@@ -2119,7 +2142,8 @@ done:
* @return Normal NTSTATUS return.
**/
-NTSTATUS rpc_printer_migrate_settings_internals(const DOM_SID *domain_sid,
+NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c,
+ const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
@@ -2153,7 +2177,7 @@ NTSTATUS rpc_printer_migrate_settings_internals(const DOM_SID *domain_sid,
DEBUG(3,("copying printer settings\n"));
/* connect destination PI_SPOOLSS */
- nt_status = connect_dst_pipe(&cli_dst, &pipe_hnd_dst, PI_SPOOLSS);
+ nt_status = connect_dst_pipe(c, &cli_dst, &pipe_hnd_dst, PI_SPOOLSS);
if (!NT_STATUS_IS_OK(nt_status))
return nt_status;
@@ -2303,7 +2327,7 @@ NTSTATUS rpc_printer_migrate_settings_internals(const DOM_SID *domain_sid,
if (W_ERROR_IS_OK(result)) {
/* display_value */
- if (opt_verbose)
+ if (c->opt_verbose)
display_reg_value(SPOOL_PRINTERDATA_KEY, value);
/* set_value */
@@ -2425,7 +2449,7 @@ NTSTATUS rpc_printer_migrate_settings_internals(const DOM_SID *domain_sid,
value.data_p = NULL;
}
- if (opt_verbose)
+ if (c->opt_verbose)
display_reg_value(subkey, value);
/* here we have to set all subkeys on the dst server */
@@ -2435,7 +2459,7 @@ NTSTATUS rpc_printer_migrate_settings_internals(const DOM_SID *domain_sid,
} else {
- if (opt_verbose)
+ if (c->opt_verbose)
display_reg_value(subkey, *(reg_ctr->values[j]));
/* here we have to set all subkeys on the dst server */
diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c
index 022f2ddfcdf..0dc53c3f6b0 100644
--- a/source3/utils/net_rpc_registry.c
+++ b/source3/utils/net_rpc_registry.c
@@ -369,7 +369,8 @@ static NTSTATUS registry_setvalue(TALLOC_CTX *mem_ctx,
return result;
}
-static NTSTATUS rpc_registry_setvalue_internal(const DOM_SID *domain_sid,
+static NTSTATUS rpc_registry_setvalue_internal(struct net_context *c,
+ const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
@@ -425,7 +426,8 @@ static NTSTATUS rpc_registry_setvalue_internal(const DOM_SID *domain_sid,
return NT_STATUS_OK;
}
-static int rpc_registry_setvalue( int argc, const char **argv )
+static int rpc_registry_setvalue(struct net_context *c, int argc,
+ const char **argv )
{
if (argc < 4) {
d_fprintf(stderr, "usage: net rpc registry setvalue <key> "
@@ -433,11 +435,12 @@ static int rpc_registry_setvalue( int argc, const char **argv )
return -1;
}
- return run_rpc_command( NULL, PI_WINREG, 0,
+ return run_rpc_command(c, NULL, PI_WINREG, 0,
rpc_registry_setvalue_internal, argc, argv );
}
-static NTSTATUS rpc_registry_deletevalue_internal(const DOM_SID *domain_sid,
+static NTSTATUS rpc_registry_deletevalue_internal(struct net_context *c,
+ const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
@@ -476,7 +479,8 @@ static NTSTATUS rpc_registry_deletevalue_internal(const DOM_SID *domain_sid,
return status;
}
-static int rpc_registry_deletevalue( int argc, const char **argv )
+static int rpc_registry_deletevalue(struct net_context *c, int argc,
+ const char **argv )
{
if (argc != 2) {
d_fprintf(stderr, "usage: net rpc registry deletevalue <key> "
@@ -484,11 +488,12 @@ static int rpc_registry_deletevalue( int argc, const char **argv )
return -1;
}
- return run_rpc_command( NULL, PI_WINREG, 0,
+ return run_rpc_command(c, NULL, PI_WINREG, 0,
rpc_registry_deletevalue_internal, argc, argv );
}
-static NTSTATUS rpc_registry_getvalue_internal(const DOM_SID *domain_sid,
+static NTSTATUS rpc_registry_getvalue_internal(struct net_context *c,
+ const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
@@ -574,7 +579,8 @@ done:
return status;
}
-static int rpc_registry_getvalue(int argc, const char **argv)
+static int rpc_registry_getvalue(struct net_context *c, int argc,
+ const char **argv)
{
if (argc != 2) {
d_fprintf(stderr, "usage: net rpc registry deletevalue <key> "
@@ -582,11 +588,12 @@ static int rpc_registry_getvalue(int argc, const char **argv)
return -1;
}
- return run_rpc_command(NULL, PI_WINREG, 0,
+ return run_rpc_command(c, NULL, PI_WINREG, 0,
rpc_registry_getvalue_internal, argc, argv);
}
-static NTSTATUS rpc_registry_createkey_internal(const DOM_SID *domain_sid,
+static NTSTATUS rpc_registry_createkey_internal(struct net_context *c,
+ const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
@@ -645,18 +652,20 @@ static NTSTATUS rpc_registry_createkey_internal(const DOM_SID *domain_sid,
return status;
}
-static int rpc_registry_createkey( int argc, const char **argv )
+static int rpc_registry_createkey(struct net_context *c, int argc,
+ const char **argv )
{
if (argc != 1) {
d_fprintf(stderr, "usage: net rpc registry createkey <key>\n");
return -1;
}
- return run_rpc_command( NULL, PI_WINREG, 0,
+ return run_rpc_command(c, NULL, PI_WINREG, 0,
rpc_registry_createkey_internal, argc, argv );
}
-static NTSTATUS rpc_registry_deletekey_internal(const DOM_SID *domain_sid,
+static NTSTATUS rpc_registry_deletekey_internal(struct net_context *c,
+ const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
@@ -693,21 +702,22 @@ static NTSTATUS rpc_registry_deletekey_internal(const DOM_SID *domain_sid,
return status;
}
-static int rpc_registry_deletekey( int argc, const char **argv )
+static int rpc_registry_deletekey(struct net_context *c, int argc, const char **argv )
{
if (argc != 1) {
d_fprintf(stderr, "usage: net rpc registry deletekey <key>\n");
return -1;
}
- return run_rpc_command( NULL, PI_WINREG, 0,
+ return run_rpc_command(c, NULL, PI_WINREG, 0,
rpc_registry_deletekey_internal, argc, argv );
}
/********************************************************************
********************************************************************/
-static NTSTATUS rpc_registry_enumerate_internal(const DOM_SID *domain_sid,
+static NTSTATUS rpc_registry_enumerate_internal(struct net_context *c,
+ const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
@@ -771,16 +781,18 @@ static NTSTATUS rpc_registry_enumerate_internal(const DOM_SID *domain_sid,
/********************************************************************
********************************************************************/
-static int rpc_registry_enumerate( int argc, const char **argv )
+static int rpc_registry_enumerate(struct net_context *c, int argc,
+ const char **argv )
{
- return run_rpc_command( NULL, PI_WINREG, 0,
+ return run_rpc_command(c, NULL, PI_WINREG, 0,
rpc_registry_enumerate_internal, argc, argv );
}
/********************************************************************
********************************************************************/
-static NTSTATUS rpc_registry_save_internal(const DOM_SID *domain_sid,
+static NTSTATUS rpc_registry_save_internal(struct net_context *c,
+ const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
@@ -823,9 +835,9 @@ static NTSTATUS rpc_registry_save_internal(const DOM_SID *domain_sid,
/********************************************************************
********************************************************************/
-static int rpc_registry_save( int argc, const char **argv )
+static int rpc_registry_save(struct net_context *c, int argc, const char **argv )
{
- return run_rpc_command( NULL, PI_WINREG, 0,
+ return run_rpc_command(c, NULL, PI_WINREG, 0,
rpc_registry_save_internal, argc, argv );
}
@@ -973,7 +985,7 @@ static bool write_registry_tree( REGF_FILE *infile, REGF_NK_REC *nk,
/********************************************************************
********************************************************************/
-static int rpc_registry_dump( int argc, const char **argv )
+static int rpc_registry_dump(struct net_context *c, int argc, const char **argv)
{
REGF_FILE *registry;
REGF_NK_REC *nk;
@@ -1016,7 +1028,7 @@ static int rpc_registry_dump( int argc, const char **argv )
/********************************************************************
********************************************************************/
-static int rpc_registry_copy( int argc, const char **argv )
+static int rpc_registry_copy(struct net_context *c, int argc, const char **argv )
{
REGF_FILE *infile = NULL, *outfile = NULL;
REGF_NK_REC *nk;
@@ -1073,7 +1085,8 @@ out:
/********************************************************************
********************************************************************/
-static NTSTATUS rpc_registry_getsd_internal(const DOM_SID *domain_sid,
+static NTSTATUS rpc_registry_getsd_internal(struct net_context *c,
+ const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
@@ -1149,16 +1162,16 @@ static NTSTATUS rpc_registry_getsd_internal(const DOM_SID *domain_sid,
}
-static int rpc_registry_getsd(int argc, const char **argv)
+static int rpc_registry_getsd(struct net_context *c, int argc, const char **argv)
{
- return run_rpc_command(NULL, PI_WINREG, 0,
+ return run_rpc_command(c, NULL, PI_WINREG, 0,
rpc_registry_getsd_internal, argc, argv);
}
/********************************************************************
********************************************************************/
-int net_rpc_registry(int argc, const char **argv)
+int net_rpc_registry(struct net_context *c, int argc, const char **argv)
{
struct functable2 func[] = {
{ "enumerate", rpc_registry_enumerate,
@@ -1184,5 +1197,5 @@ int net_rpc_registry(int argc, const char **argv)
{NULL, NULL, NULL}
};
- return net_run_function2(argc, argv, "net rpc registry", func);
+ return net_run_function2(c, argc, argv, "net rpc registry", func);
}
diff --git a/source3/utils/net_rpc_rights.c b/source3/utils/net_rpc_rights.c
index 7857dbcbafb..2824c550734 100644
--- a/source3/utils/net_rpc_rights.c
+++ b/source3/utils/net_rpc_rights.c
@@ -15,8 +15,8 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
#include "includes.h"
#include "utils/net.h"
@@ -308,7 +308,8 @@ static NTSTATUS enum_privileges_for_accounts(struct rpc_pipe_client *pipe_hnd,
/********************************************************************
********************************************************************/
-static NTSTATUS rpc_rights_list_internal(const DOM_SID *domain_sid,
+static NTSTATUS rpc_rights_list_internal(struct net_context *c,
+ const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
@@ -326,7 +327,6 @@ static NTSTATUS rpc_rights_list_internal(const DOM_SID *domain_sid,
uint16 lang_id_sys = 0;
uint16 lang_id_desc;
-
result = rpccli_lsa_open_policy(pipe_hnd, mem_ctx, True,
SEC_RIGHTS_MAXIMUM_ALLOWED, &pol);
@@ -427,7 +427,8 @@ done:
/********************************************************************
********************************************************************/
-static NTSTATUS rpc_rights_grant_internal(const DOM_SID *domain_sid,
+static NTSTATUS rpc_rights_grant_internal(struct net_context *c,
+ const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
@@ -493,7 +494,8 @@ static NTSTATUS rpc_rights_grant_internal(const DOM_SID *domain_sid,
/********************************************************************
********************************************************************/
-static NTSTATUS rpc_rights_revoke_internal(const DOM_SID *domain_sid,
+static NTSTATUS rpc_rights_revoke_internal(struct net_context *c,
+ const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
@@ -560,34 +562,34 @@ done:
/********************************************************************
********************************************************************/
-static int rpc_rights_list( int argc, const char **argv )
+static int rpc_rights_list(struct net_context *c, int argc, const char **argv )
{
- return run_rpc_command( NULL, PI_LSARPC, 0,
+ return run_rpc_command(c, NULL, PI_LSARPC, 0,
rpc_rights_list_internal, argc, argv );
}
/********************************************************************
********************************************************************/
-static int rpc_rights_grant( int argc, const char **argv )
+static int rpc_rights_grant(struct net_context *c, int argc, const char **argv )
{
- return run_rpc_command( NULL, PI_LSARPC, 0,
+ return run_rpc_command(c, NULL, PI_LSARPC, 0,
rpc_rights_grant_internal, argc, argv );
}
/********************************************************************
********************************************************************/
-static int rpc_rights_revoke( int argc, const char **argv )
+static int rpc_rights_revoke(struct net_context *c, int argc, const char **argv)
{
- return run_rpc_command( NULL, PI_LSARPC, 0,
+ return run_rpc_command(c, NULL, PI_LSARPC, 0,
rpc_rights_revoke_internal, argc, argv );
}
/********************************************************************
********************************************************************/
-static int net_help_rights( int argc, const char **argv )
+static int net_help_rights(struct net_context *c, int argc, const char **argv )
{
d_printf("net rpc rights list [{accounts|privileges} [name|SID]] View available or assigned privileges\n");
d_printf("net rpc rights grant <name|SID> <right> Assign privilege[s]\n");
@@ -598,14 +600,13 @@ static int net_help_rights( int argc, const char **argv )
d_printf("\n net rpc rights grant 'VALE\\biddle' SePrintOperatorPrivilege SeDiskOperatorPrivilege\n");
d_printf("\nwould grant the printer admin and disk manager rights to the user 'VALE\\biddle'\n\n");
-
return -1;
}
/********************************************************************
********************************************************************/
-int net_rpc_rights(int argc, const char **argv)
+int net_rpc_rights(struct net_context *c, int argc, const char **argv)
{
struct functable func[] = {
{"list", rpc_rights_list},
@@ -615,41 +616,44 @@ int net_rpc_rights(int argc, const char **argv)
};
if ( argc )
- return net_run_function( argc, argv, func, net_help_rights );
+ return net_run_function(c, argc, argv, func, net_help_rights );
- return net_help_rights( argc, argv );
+ return net_help_rights(c, argc, argv );
}
-static NTSTATUS rpc_sh_rights_list(TALLOC_CTX *mem_ctx, struct rpc_sh_ctx *ctx,
+static NTSTATUS rpc_sh_rights_list(struct net_context *c,
+ TALLOC_CTX *mem_ctx, struct rpc_sh_ctx *ctx,
struct rpc_pipe_client *pipe_hnd,
int argc, const char **argv)
{
- return rpc_rights_list_internal(ctx->domain_sid, ctx->domain_name,
+ return rpc_rights_list_internal(c, ctx->domain_sid, ctx->domain_name,
ctx->cli, pipe_hnd, mem_ctx,
argc, argv);
}
-static NTSTATUS rpc_sh_rights_grant(TALLOC_CTX *mem_ctx,
+static NTSTATUS rpc_sh_rights_grant(struct net_context *c,
+ TALLOC_CTX *mem_ctx,
struct rpc_sh_ctx *ctx,
struct rpc_pipe_client *pipe_hnd,
int argc, const char **argv)
{
- return rpc_rights_grant_internal(ctx->domain_sid, ctx->domain_name,
+ return rpc_rights_grant_internal(c, ctx->domain_sid, ctx->domain_name,
ctx->cli, pipe_hnd, mem_ctx,
argc, argv);
}
-static NTSTATUS rpc_sh_rights_revoke(TALLOC_CTX *mem_ctx,
+static NTSTATUS rpc_sh_rights_revoke(struct net_context *c,
+ TALLOC_CTX *mem_ctx,
struct rpc_sh_ctx *ctx,
struct rpc_pipe_client *pipe_hnd,
int argc, const char **argv)
{
- return rpc_rights_revoke_internal(ctx->domain_sid, ctx->domain_name,
+ return rpc_rights_revoke_internal(c, ctx->domain_sid, ctx->domain_name,
ctx->cli, pipe_hnd, mem_ctx,
argc, argv);
}
-struct rpc_sh_cmd *net_rpc_rights_cmds(TALLOC_CTX *mem_ctx,
+struct rpc_sh_cmd *net_rpc_rights_cmds(struct net_context *c, TALLOC_CTX *mem_ctx,
struct rpc_sh_ctx *ctx)
{
static struct rpc_sh_cmd cmds[] = {
diff --git a/source3/utils/net_rpc_samsync.c b/source3/utils/net_rpc_samsync.c
index 6ea0a2dcfc8..bb09cc483bc 100644
--- a/source3/utils/net_rpc_samsync.c
+++ b/source3/utils/net_rpc_samsync.c
@@ -399,7 +399,8 @@ static void dump_database(struct rpc_pipe_client *pipe_hnd,
}
/* dump sam database via samsync rpc calls */
-NTSTATUS rpc_samdump_internals(const DOM_SID *domain_sid,
+NTSTATUS rpc_samdump_internals(struct net_context *c,
+ const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
@@ -2309,12 +2310,14 @@ static NTSTATUS fetch_database_to_ldif(struct rpc_pipe_client *pipe_hnd,
/**
* Basic usage function for 'net rpc vampire'
+ *
+ * @param c A net_context structure
* @param argc Standard main() style argc
* @param argc Standard main() style argv. Initial components are already
* stripped
**/
-int rpc_vampire_usage(int argc, const char **argv)
+int rpc_vampire_usage(struct net_context *c, int argc, const char **argv)
{
d_printf("net rpc vampire [ldif [<ldif-filename>] [options]\n"
"\t to pull accounts from a remote PDC where we are a BDC\n"
@@ -2322,13 +2325,14 @@ int rpc_vampire_usage(int argc, const char **argv)
"\t\t ldif - put accounts in ldif format (file defaults to "
"/tmp/tmp.ldif\n");
- net_common_flags_usage(argc, argv);
+ net_common_flags_usage(c, argc, argv);
return -1;
}
/* dump sam database via samsync rpc calls */
-NTSTATUS rpc_vampire_internals(const DOM_SID *domain_sid,
+NTSTATUS rpc_vampire_internals(struct net_context *c,
+ const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
diff --git a/source3/utils/net_rpc_service.c b/source3/utils/net_rpc_service.c
index b886283adce..05279aea1ab 100644
--- a/source3/utils/net_rpc_service.c
+++ b/source3/utils/net_rpc_service.c
@@ -190,7 +190,8 @@ done:
/********************************************************************
********************************************************************/
-static NTSTATUS rpc_service_list_internal(const DOM_SID *domain_sid,
+static NTSTATUS rpc_service_list_internal(struct net_context *c,
+ const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
@@ -250,7 +251,8 @@ done:
/********************************************************************
********************************************************************/
-static NTSTATUS rpc_service_status_internal(const DOM_SID *domain_sid,
+static NTSTATUS rpc_service_status_internal(struct net_context *c,
+ const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
@@ -362,7 +364,8 @@ done:
/********************************************************************
********************************************************************/
-static NTSTATUS rpc_service_stop_internal(const DOM_SID *domain_sid,
+static NTSTATUS rpc_service_stop_internal(struct net_context *c,
+ const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
@@ -405,7 +408,8 @@ static NTSTATUS rpc_service_stop_internal(const DOM_SID *domain_sid,
/********************************************************************
********************************************************************/
-static NTSTATUS rpc_service_pause_internal(const DOM_SID *domain_sid,
+static NTSTATUS rpc_service_pause_internal(struct net_context *c,
+ const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
@@ -448,7 +452,8 @@ static NTSTATUS rpc_service_pause_internal(const DOM_SID *domain_sid,
/********************************************************************
********************************************************************/
-static NTSTATUS rpc_service_resume_internal(const DOM_SID *domain_sid,
+static NTSTATUS rpc_service_resume_internal(struct net_context *c,
+ const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
@@ -491,7 +496,8 @@ static NTSTATUS rpc_service_resume_internal(const DOM_SID *domain_sid,
/********************************************************************
********************************************************************/
-static NTSTATUS rpc_service_start_internal(const DOM_SID *domain_sid,
+static NTSTATUS rpc_service_start_internal(struct net_context *c,
+ const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
@@ -565,61 +571,61 @@ done:
/********************************************************************
********************************************************************/
-static int rpc_service_list( int argc, const char **argv )
+static int rpc_service_list(struct net_context *c, int argc, const char **argv )
{
- return run_rpc_command( NULL, PI_SVCCTL, 0,
+ return run_rpc_command(c, NULL, PI_SVCCTL, 0,
rpc_service_list_internal, argc, argv );
}
/********************************************************************
********************************************************************/
-static int rpc_service_start( int argc, const char **argv )
+static int rpc_service_start(struct net_context *c, int argc, const char **argv )
{
- return run_rpc_command( NULL, PI_SVCCTL, 0,
+ return run_rpc_command(c, NULL, PI_SVCCTL, 0,
rpc_service_start_internal, argc, argv );
}
/********************************************************************
********************************************************************/
-static int rpc_service_stop( int argc, const char **argv )
+static int rpc_service_stop(struct net_context *c, int argc, const char **argv )
{
- return run_rpc_command( NULL, PI_SVCCTL, 0,
+ return run_rpc_command(c, NULL, PI_SVCCTL, 0,
rpc_service_stop_internal, argc, argv );
}
/********************************************************************
********************************************************************/
-static int rpc_service_resume( int argc, const char **argv )
+static int rpc_service_resume(struct net_context *c, int argc, const char **argv )
{
- return run_rpc_command( NULL, PI_SVCCTL, 0,
+ return run_rpc_command(c, NULL, PI_SVCCTL, 0,
rpc_service_resume_internal, argc, argv );
}
/********************************************************************
********************************************************************/
-static int rpc_service_pause( int argc, const char **argv )
+static int rpc_service_pause(struct net_context *c, int argc, const char **argv )
{
- return run_rpc_command( NULL, PI_SVCCTL, 0,
+ return run_rpc_command(c, NULL, PI_SVCCTL, 0,
rpc_service_pause_internal, argc, argv );
}
/********************************************************************
********************************************************************/
-static int rpc_service_status( int argc, const char **argv )
+static int rpc_service_status(struct net_context *c, int argc, const char **argv )
{
- return run_rpc_command( NULL, PI_SVCCTL, 0,
+ return run_rpc_command(c, NULL, PI_SVCCTL, 0,
rpc_service_status_internal, argc, argv );
}
/********************************************************************
********************************************************************/
-static int net_help_service( int argc, const char **argv )
+static int net_help_service(struct net_context *c, int argc, const char **argv )
{
d_printf("net rpc service list View configured Win32 services\n");
d_printf("net rpc service start <service> Start a service\n");
@@ -634,7 +640,7 @@ static int net_help_service( int argc, const char **argv )
/********************************************************************
********************************************************************/
-int net_rpc_service(int argc, const char **argv)
+int net_rpc_service(struct net_context *c, int argc, const char **argv)
{
struct functable func[] = {
{"list", rpc_service_list},
@@ -647,7 +653,7 @@ int net_rpc_service(int argc, const char **argv)
};
if ( argc )
- return net_run_function( argc, argv, func, net_help_service );
+ return net_run_function(c, argc, argv, func, net_help_service );
- return net_help_service( argc, argv );
+ return net_help_service(c, argc, argv );
}
diff --git a/source3/utils/net_rpc_sh_acct.c b/source3/utils/net_rpc_sh_acct.c
index 00a7967f070..15a20891f29 100644
--- a/source3/utils/net_rpc_sh_acct.c
+++ b/source3/utils/net_rpc_sh_acct.c
@@ -14,8 +14,8 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
#include "includes.h"
#include "utils/net.h"
@@ -25,11 +25,13 @@
* it has modified, it can return 0 for no change.
*/
-static NTSTATUS rpc_sh_acct_do(TALLOC_CTX *mem_ctx,
+static NTSTATUS rpc_sh_acct_do(struct net_context *c,
+ TALLOC_CTX *mem_ctx,
struct rpc_sh_ctx *ctx,
struct rpc_pipe_client *pipe_hnd,
int argc, const char **argv,
- int (*fn)(TALLOC_CTX *mem_ctx,
+ int (*fn)(struct net_context *c,
+ TALLOC_CTX *mem_ctx,
struct rpc_sh_ctx *ctx,
struct samr_DomInfo1 *i1,
struct samr_DomInfo3 *i3,
@@ -100,7 +102,7 @@ static NTSTATUS rpc_sh_acct_do(TALLOC_CTX *mem_ctx,
goto done;
}
- store = fn(mem_ctx, ctx, &info1->info1, &info3->info3,
+ store = fn(c, mem_ctx, ctx, &info1->info1, &info3->info3,
&info12->info12, argc, argv);
if (store <= 0) {
@@ -144,7 +146,8 @@ static NTSTATUS rpc_sh_acct_do(TALLOC_CTX *mem_ctx,
return result;
}
-static int account_show(TALLOC_CTX *mem_ctx, struct rpc_sh_ctx *ctx,
+static int account_show(struct net_context *c,
+ TALLOC_CTX *mem_ctx, struct rpc_sh_ctx *ctx,
struct samr_DomInfo1 *i1,
struct samr_DomInfo3 *i3,
struct samr_DomInfo12 *i12,
@@ -204,15 +207,17 @@ static int account_show(TALLOC_CTX *mem_ctx, struct rpc_sh_ctx *ctx,
return 0; /* Don't save */
}
-static NTSTATUS rpc_sh_acct_pol_show(TALLOC_CTX *mem_ctx,
+static NTSTATUS rpc_sh_acct_pol_show(struct net_context *c,
+ TALLOC_CTX *mem_ctx,
struct rpc_sh_ctx *ctx,
struct rpc_pipe_client *pipe_hnd,
int argc, const char **argv) {
- return rpc_sh_acct_do(mem_ctx, ctx, pipe_hnd, argc, argv,
+ return rpc_sh_acct_do(c, mem_ctx, ctx, pipe_hnd, argc, argv,
account_show);
}
-static int account_set_badpw(TALLOC_CTX *mem_ctx, struct rpc_sh_ctx *ctx,
+static int account_set_badpw(struct net_context *c,
+ TALLOC_CTX *mem_ctx, struct rpc_sh_ctx *ctx,
struct samr_DomInfo1 *i1,
struct samr_DomInfo3 *i3,
struct samr_DomInfo12 *i12,
@@ -230,16 +235,18 @@ static int account_set_badpw(TALLOC_CTX *mem_ctx, struct rpc_sh_ctx *ctx,
return 12;
}
-static NTSTATUS rpc_sh_acct_set_badpw(TALLOC_CTX *mem_ctx,
+static NTSTATUS rpc_sh_acct_set_badpw(struct net_context *c,
+ TALLOC_CTX *mem_ctx,
struct rpc_sh_ctx *ctx,
struct rpc_pipe_client *pipe_hnd,
int argc, const char **argv)
{
- return rpc_sh_acct_do(mem_ctx, ctx, pipe_hnd, argc, argv,
+ return rpc_sh_acct_do(c, mem_ctx, ctx, pipe_hnd, argc, argv,
account_set_badpw);
}
-static int account_set_lockduration(TALLOC_CTX *mem_ctx,
+static int account_set_lockduration(struct net_context *c,
+ TALLOC_CTX *mem_ctx,
struct rpc_sh_ctx *ctx,
struct samr_DomInfo1 *i1,
struct samr_DomInfo3 *i3,
@@ -258,16 +265,18 @@ static int account_set_lockduration(TALLOC_CTX *mem_ctx,
return 12;
}
-static NTSTATUS rpc_sh_acct_set_lockduration(TALLOC_CTX *mem_ctx,
+static NTSTATUS rpc_sh_acct_set_lockduration(struct net_context *c,
+ TALLOC_CTX *mem_ctx,
struct rpc_sh_ctx *ctx,
struct rpc_pipe_client *pipe_hnd,
int argc, const char **argv)
{
- return rpc_sh_acct_do(mem_ctx, ctx, pipe_hnd, argc, argv,
+ return rpc_sh_acct_do(c, mem_ctx, ctx, pipe_hnd, argc, argv,
account_set_lockduration);
}
-static int account_set_resetduration(TALLOC_CTX *mem_ctx,
+static int account_set_resetduration(struct net_context *c,
+ TALLOC_CTX *mem_ctx,
struct rpc_sh_ctx *ctx,
struct samr_DomInfo1 *i1,
struct samr_DomInfo3 *i3,
@@ -286,16 +295,18 @@ static int account_set_resetduration(TALLOC_CTX *mem_ctx,
return 12;
}
-static NTSTATUS rpc_sh_acct_set_resetduration(TALLOC_CTX *mem_ctx,
+static NTSTATUS rpc_sh_acct_set_resetduration(struct net_context *c,
+ TALLOC_CTX *mem_ctx,
struct rpc_sh_ctx *ctx,
struct rpc_pipe_client *pipe_hnd,
int argc, const char **argv)
{
- return rpc_sh_acct_do(mem_ctx, ctx, pipe_hnd, argc, argv,
+ return rpc_sh_acct_do(c, mem_ctx, ctx, pipe_hnd, argc, argv,
account_set_resetduration);
}
-static int account_set_minpwage(TALLOC_CTX *mem_ctx,
+static int account_set_minpwage(struct net_context *c,
+ TALLOC_CTX *mem_ctx,
struct rpc_sh_ctx *ctx,
struct samr_DomInfo1 *i1,
struct samr_DomInfo3 *i3,
@@ -314,16 +325,18 @@ static int account_set_minpwage(TALLOC_CTX *mem_ctx,
return 1;
}
-static NTSTATUS rpc_sh_acct_set_minpwage(TALLOC_CTX *mem_ctx,
+static NTSTATUS rpc_sh_acct_set_minpwage(struct net_context *c,
+ TALLOC_CTX *mem_ctx,
struct rpc_sh_ctx *ctx,
struct rpc_pipe_client *pipe_hnd,
int argc, const char **argv)
{
- return rpc_sh_acct_do(mem_ctx, ctx, pipe_hnd, argc, argv,
+ return rpc_sh_acct_do(c, mem_ctx, ctx, pipe_hnd, argc, argv,
account_set_minpwage);
}
-static int account_set_maxpwage(TALLOC_CTX *mem_ctx,
+static int account_set_maxpwage(struct net_context *c,
+ TALLOC_CTX *mem_ctx,
struct rpc_sh_ctx *ctx,
struct samr_DomInfo1 *i1,
struct samr_DomInfo3 *i3,
@@ -342,16 +355,18 @@ static int account_set_maxpwage(TALLOC_CTX *mem_ctx,
return 1;
}
-static NTSTATUS rpc_sh_acct_set_maxpwage(TALLOC_CTX *mem_ctx,
+static NTSTATUS rpc_sh_acct_set_maxpwage(struct net_context *c,
+ TALLOC_CTX *mem_ctx,
struct rpc_sh_ctx *ctx,
struct rpc_pipe_client *pipe_hnd,
int argc, const char **argv)
{
- return rpc_sh_acct_do(mem_ctx, ctx, pipe_hnd, argc, argv,
+ return rpc_sh_acct_do(c, mem_ctx, ctx, pipe_hnd, argc, argv,
account_set_maxpwage);
}
-static int account_set_minpwlen(TALLOC_CTX *mem_ctx,
+static int account_set_minpwlen(struct net_context *c,
+ TALLOC_CTX *mem_ctx,
struct rpc_sh_ctx *ctx,
struct samr_DomInfo1 *i1,
struct samr_DomInfo3 *i3,
@@ -370,16 +385,18 @@ static int account_set_minpwlen(TALLOC_CTX *mem_ctx,
return 1;
}
-static NTSTATUS rpc_sh_acct_set_minpwlen(TALLOC_CTX *mem_ctx,
+static NTSTATUS rpc_sh_acct_set_minpwlen(struct net_context *c,
+ TALLOC_CTX *mem_ctx,
struct rpc_sh_ctx *ctx,
struct rpc_pipe_client *pipe_hnd,
int argc, const char **argv)
{
- return rpc_sh_acct_do(mem_ctx, ctx, pipe_hnd, argc, argv,
+ return rpc_sh_acct_do(c, mem_ctx, ctx, pipe_hnd, argc, argv,
account_set_minpwlen);
}
-static int account_set_pwhistlen(TALLOC_CTX *mem_ctx,
+static int account_set_pwhistlen(struct net_context *c,
+ TALLOC_CTX *mem_ctx,
struct rpc_sh_ctx *ctx,
struct samr_DomInfo1 *i1,
struct samr_DomInfo3 *i3,
@@ -398,16 +415,17 @@ static int account_set_pwhistlen(TALLOC_CTX *mem_ctx,
return 1;
}
-static NTSTATUS rpc_sh_acct_set_pwhistlen(TALLOC_CTX *mem_ctx,
+static NTSTATUS rpc_sh_acct_set_pwhistlen(struct net_context *c,
+ TALLOC_CTX *mem_ctx,
struct rpc_sh_ctx *ctx,
struct rpc_pipe_client *pipe_hnd,
int argc, const char **argv)
{
- return rpc_sh_acct_do(mem_ctx, ctx, pipe_hnd, argc, argv,
+ return rpc_sh_acct_do(c, mem_ctx, ctx, pipe_hnd, argc, argv,
account_set_pwhistlen);
}
-struct rpc_sh_cmd *net_rpc_acct_cmds(TALLOC_CTX *mem_ctx,
+struct rpc_sh_cmd *net_rpc_acct_cmds(struct net_context *c, TALLOC_CTX *mem_ctx,
struct rpc_sh_ctx *ctx)
{
static struct rpc_sh_cmd cmds[9] = {
diff --git a/source3/utils/net_rpc_shell.c b/source3/utils/net_rpc_shell.c
index 7bd726e614f..bfdfd4bf64a 100644
--- a/source3/utils/net_rpc_shell.c
+++ b/source3/utils/net_rpc_shell.c
@@ -21,11 +21,12 @@
#include "includes.h"
#include "utils/net.h"
-static NTSTATUS rpc_sh_info(TALLOC_CTX *mem_ctx, struct rpc_sh_ctx *ctx,
+static NTSTATUS rpc_sh_info(struct net_context *c,
+ TALLOC_CTX *mem_ctx, struct rpc_sh_ctx *ctx,
struct rpc_pipe_client *pipe_hnd,
int argc, const char **argv)
{
- return rpc_info_internals(ctx->domain_sid, ctx->domain_name,
+ return rpc_info_internals(c, ctx->domain_sid, ctx->domain_name,
ctx->cli, pipe_hnd, mem_ctx,
argc, argv);
}
@@ -63,7 +64,8 @@ static char **completion_fn(const char *text, int start, int end)
return cmds;
}
-static NTSTATUS net_sh_run(struct rpc_sh_ctx *ctx, struct rpc_sh_cmd *cmd,
+static NTSTATUS net_sh_run(struct net_context *c,
+ struct rpc_sh_ctx *ctx, struct rpc_sh_cmd *cmd,
int argc, const char **argv)
{
TALLOC_CTX *mem_ctx;
@@ -83,7 +85,7 @@ static NTSTATUS net_sh_run(struct rpc_sh_ctx *ctx, struct rpc_sh_cmd *cmd,
return status;
}
- status = cmd->fn(mem_ctx, ctx, pipe_hnd, argc, argv);
+ status = cmd->fn(c, mem_ctx, ctx, pipe_hnd, argc, argv);
TALLOC_FREE(pipe_hnd);
@@ -92,10 +94,11 @@ static NTSTATUS net_sh_run(struct rpc_sh_ctx *ctx, struct rpc_sh_cmd *cmd,
return status;
}
-static bool net_sh_process(struct rpc_sh_ctx *ctx,
+static bool net_sh_process(struct net_context *c,
+ struct rpc_sh_ctx *ctx,
int argc, const char **argv)
{
- struct rpc_sh_cmd *c;
+ struct rpc_sh_cmd *cmd;
struct rpc_sh_ctx *new_ctx;
NTSTATUS status;
@@ -120,22 +123,22 @@ static bool net_sh_process(struct rpc_sh_ctx *ctx,
}
if (strequal(argv[0], "help") || strequal(argv[0], "?")) {
- for (c = ctx->cmds; c->name != NULL; c++) {
+ for (cmd = ctx->cmds; cmd->name != NULL; cmd++) {
if (ctx != this_ctx) {
d_printf("%s ", ctx->whoami);
}
- d_printf("%-15s %s\n", c->name, c->help);
+ d_printf("%-15s %s\n", cmd->name, cmd->help);
}
return True;
}
- for (c = ctx->cmds; c->name != NULL; c++) {
- if (strequal(c->name, argv[0])) {
+ for (cmd = ctx->cmds; cmd->name != NULL; cmd++) {
+ if (strequal(cmd->name, argv[0])) {
break;
}
}
- if (c->name == NULL) {
+ if (cmd->name == NULL) {
/* None found */
d_fprintf(stderr, "%s: unknown cmd\n", argv[0]);
return True;
@@ -148,11 +151,11 @@ static bool net_sh_process(struct rpc_sh_ctx *ctx,
}
new_ctx->cli = ctx->cli;
new_ctx->whoami = talloc_asprintf(new_ctx, "%s %s",
- ctx->whoami, c->name);
- new_ctx->thiscmd = talloc_strdup(new_ctx, c->name);
+ ctx->whoami, cmd->name);
+ new_ctx->thiscmd = talloc_strdup(new_ctx, cmd->name);
- if (c->sub != NULL) {
- new_ctx->cmds = c->sub(new_ctx, ctx);
+ if (cmd->sub != NULL) {
+ new_ctx->cmds = cmd->sub(c, new_ctx, ctx);
} else {
new_ctx->cmds = NULL;
}
@@ -164,15 +167,15 @@ static bool net_sh_process(struct rpc_sh_ctx *ctx,
argc -= 1;
argv += 1;
- if (c->sub != NULL) {
+ if (cmd->sub != NULL) {
if (argc == 0) {
this_ctx = new_ctx;
return True;
}
- return net_sh_process(new_ctx, argc, argv);
+ return net_sh_process(c, new_ctx, argc, argv);
}
- status = net_sh_run(new_ctx, c, argc, argv);
+ status = net_sh_run(c, new_ctx, cmd, argc, argv);
if (!NT_STATUS_IS_OK(status)) {
d_fprintf(stderr, "%s failed: %s\n", new_ctx->whoami,
@@ -202,7 +205,7 @@ static struct rpc_sh_cmd sh_cmds[6] = {
{ NULL, NULL, 0, NULL, NULL }
};
-int net_rpc_shell(int argc, const char **argv)
+int net_rpc_shell(struct net_context *c, int argc, const char **argv)
{
NTSTATUS status;
struct rpc_sh_ctx *ctx;
@@ -218,7 +221,7 @@ int net_rpc_shell(int argc, const char **argv)
return -1;
}
- status = net_make_ipc_connection(0, &(ctx->cli));
+ status = net_make_ipc_connection(c, 0, &(ctx->cli));
if (!NT_STATUS_IS_OK(status)) {
d_fprintf(stderr, "Could not open connection: %s\n",
nt_errstr(status));
@@ -269,7 +272,7 @@ int net_rpc_shell(int argc, const char **argv)
}
if ((line[0] != '\n') &&
- (!net_sh_process(this_ctx, argc, argv))) {
+ (!net_sh_process(c, this_ctx, argc, argv))) {
SAFE_FREE(line);
break;
}
diff --git a/source3/utils/net_sam.c b/source3/utils/net_sam.c
index b5cd8e637ad..9199f70400f 100644
--- a/source3/utils/net_sam.c
+++ b/source3/utils/net_sam.c
@@ -25,7 +25,8 @@
* Set a user's data
*/
-static int net_sam_userset(int argc, const char **argv, const char *field,
+static int net_sam_userset(struct net_context *c, int argc, const char **argv,
+ const char *field,
bool (*fn)(struct samu *, const char *,
enum pdb_value_state))
{
@@ -81,39 +82,45 @@ static int net_sam_userset(int argc, const char **argv, const char *field,
return 0;
}
-static int net_sam_set_fullname(int argc, const char **argv)
+static int net_sam_set_fullname(struct net_context *c, int argc,
+ const char **argv)
{
- return net_sam_userset(argc, argv, "fullname",
+ return net_sam_userset(c, argc, argv, "fullname",
pdb_set_fullname);
}
-static int net_sam_set_logonscript(int argc, const char **argv)
+static int net_sam_set_logonscript(struct net_context *c, int argc,
+ const char **argv)
{
- return net_sam_userset(argc, argv, "logonscript",
+ return net_sam_userset(c, argc, argv, "logonscript",
pdb_set_logon_script);
}
-static int net_sam_set_profilepath(int argc, const char **argv)
+static int net_sam_set_profilepath(struct net_context *c, int argc,
+ const char **argv)
{
- return net_sam_userset(argc, argv, "profilepath",
+ return net_sam_userset(c, argc, argv, "profilepath",
pdb_set_profile_path);
}
-static int net_sam_set_homedrive(int argc, const char **argv)
+static int net_sam_set_homedrive(struct net_context *c, int argc,
+ const char **argv)
{
- return net_sam_userset(argc, argv, "homedrive",
+ return net_sam_userset(c, argc, argv, "homedrive",
pdb_set_dir_drive);
}
-static int net_sam_set_homedir(int argc, const char **argv)
+static int net_sam_set_homedir(struct net_context *c, int argc,
+ const char **argv)
{
- return net_sam_userset(argc, argv, "homedir",
+ return net_sam_userset(c, argc, argv, "homedir",
pdb_set_homedir);
}
-static int net_sam_set_workstations(int argc, const char **argv)
+static int net_sam_set_workstations(struct net_context *c, int argc,
+ const char **argv)
{
- return net_sam_userset(argc, argv, "workstations",
+ return net_sam_userset(c, argc, argv, "workstations",
pdb_set_workstations);
}
@@ -121,7 +128,8 @@ static int net_sam_set_workstations(int argc, const char **argv)
* Set account flags
*/
-static int net_sam_set_userflag(int argc, const char **argv, const char *field,
+static int net_sam_set_userflag(struct net_context *c, int argc,
+ const char **argv, const char *field,
uint16 flag)
{
struct samu *sam_acct = NULL;
@@ -184,31 +192,36 @@ static int net_sam_set_userflag(int argc, const char **argv, const char *field,
return 0;
}
-static int net_sam_set_disabled(int argc, const char **argv)
+static int net_sam_set_disabled(struct net_context *c, int argc,
+ const char **argv)
{
- return net_sam_set_userflag(argc, argv, "disabled", ACB_DISABLED);
+ return net_sam_set_userflag(c, argc, argv, "disabled", ACB_DISABLED);
}
-static int net_sam_set_pwnotreq(int argc, const char **argv)
+static int net_sam_set_pwnotreq(struct net_context *c, int argc,
+ const char **argv)
{
- return net_sam_set_userflag(argc, argv, "pwnotreq", ACB_PWNOTREQ);
+ return net_sam_set_userflag(c, argc, argv, "pwnotreq", ACB_PWNOTREQ);
}
-static int net_sam_set_autolock(int argc, const char **argv)
+static int net_sam_set_autolock(struct net_context *c, int argc,
+ const char **argv)
{
- return net_sam_set_userflag(argc, argv, "autolock", ACB_AUTOLOCK);
+ return net_sam_set_userflag(c, argc, argv, "autolock", ACB_AUTOLOCK);
}
-static int net_sam_set_pwnoexp(int argc, const char **argv)
+static int net_sam_set_pwnoexp(struct net_context *c, int argc,
+ const char **argv)
{
- return net_sam_set_userflag(argc, argv, "pwnoexp", ACB_PWNOEXP);
+ return net_sam_set_userflag(c, argc, argv, "pwnoexp", ACB_PWNOEXP);
}
/*
* Set pass last change time, based on force pass change now
*/
-static int net_sam_set_pwdmustchangenow(int argc, const char **argv)
+static int net_sam_set_pwdmustchangenow(struct net_context *c, int argc,
+ const char **argv)
{
struct samu *sam_acct = NULL;
DOM_SID sid;
@@ -269,7 +282,8 @@ static int net_sam_set_pwdmustchangenow(int argc, const char **argv)
* Set a user's or a group's comment
*/
-static int net_sam_set_comment(int argc, const char **argv)
+static int net_sam_set_comment(struct net_context *c, int argc,
+ const char **argv)
{
GROUP_MAP map;
DOM_SID sid;
@@ -290,7 +304,7 @@ static int net_sam_set_comment(int argc, const char **argv)
}
if (type == SID_NAME_USER) {
- return net_sam_userset(argc, argv, "comment",
+ return net_sam_userset(c, argc, argv, "comment",
pdb_set_acct_desc);
}
@@ -322,7 +336,7 @@ static int net_sam_set_comment(int argc, const char **argv)
return 0;
}
-static int net_sam_set(int argc, const char **argv)
+static int net_sam_set(struct net_context *c, int argc, const char **argv)
{
struct functable2 func[] = {
{ "homedir", net_sam_set_homedir,
@@ -352,14 +366,14 @@ static int net_sam_set(int argc, const char **argv)
{NULL, NULL}
};
- return net_run_function2(argc, argv, "net sam set", func);
+ return net_run_function2(c, argc, argv, "net sam set", func);
}
/*
* Manage account policies
*/
-static int net_sam_policy_set(int argc, const char **argv)
+static int net_sam_policy_set(struct net_context *c, int argc, const char **argv)
{
const char *account_policy = NULL;
uint32 value = 0;
@@ -427,7 +441,7 @@ static int net_sam_policy_set(int argc, const char **argv)
return 0;
}
-static int net_sam_policy_show(int argc, const char **argv)
+static int net_sam_policy_show(struct net_context *c, int argc, const char **argv)
{
const char *account_policy = NULL;
uint32 old_value;
@@ -472,7 +486,7 @@ static int net_sam_policy_show(int argc, const char **argv)
return 0;
}
-static int net_sam_policy_list(int argc, const char **argv)
+static int net_sam_policy_list(struct net_context *c, int argc, const char **argv)
{
const char **names;
int count;
@@ -489,7 +503,7 @@ static int net_sam_policy_list(int argc, const char **argv)
return -1;
}
-static int net_sam_policy(int argc, const char **argv)
+static int net_sam_policy(struct net_context *c, int argc, const char **argv)
{
struct functable2 func[] = {
{ "list", net_sam_policy_list,
@@ -501,12 +515,13 @@ static int net_sam_policy(int argc, const char **argv)
{NULL, NULL}
};
- return net_run_function2(argc, argv, "net sam policy", func);
+ return net_run_function2(c, argc, argv, "net sam policy", func);
}
extern PRIVS privs[];
-static int net_sam_rights_list(int argc, const char **argv)
+static int net_sam_rights_list(struct net_context *c, int argc,
+ const char **argv)
{
SE_PRIV mask;
@@ -556,7 +571,8 @@ static int net_sam_rights_list(int argc, const char **argv)
return -1;
}
-static int net_sam_rights_grant(int argc, const char **argv)
+static int net_sam_rights_grant(struct net_context *c, int argc,
+ const char **argv)
{
DOM_SID sid;
enum lsa_SidType type;
@@ -589,7 +605,7 @@ static int net_sam_rights_grant(int argc, const char **argv)
return 0;
}
-static int net_sam_rights_revoke(int argc, const char **argv)
+static int net_sam_rights_revoke(struct net_context *c, int argc, const char **argv)
{
DOM_SID sid;
enum lsa_SidType type;
@@ -622,7 +638,7 @@ static int net_sam_rights_revoke(int argc, const char **argv)
return 0;
}
-static int net_sam_rights(int argc, const char **argv)
+static int net_sam_rights(struct net_context *c, int argc, const char **argv)
{
struct functable2 func[] = {
{ "list", net_sam_rights_list,
@@ -633,7 +649,7 @@ static int net_sam_rights(int argc, const char **argv)
"Revoke a right" },
{ NULL }
};
- return net_run_function2(argc, argv, "net sam rights", func);
+ return net_run_function2(c, argc, argv, "net sam rights", func);
}
/*
@@ -695,7 +711,7 @@ static NTSTATUS map_unix_group(const struct group *grp, GROUP_MAP *pmap)
return status;
}
-static int net_sam_mapunixgroup(int argc, const char **argv)
+static int net_sam_mapunixgroup(struct net_context *c, int argc, const char **argv)
{
NTSTATUS status;
GROUP_MAP map;
@@ -757,7 +773,7 @@ static NTSTATUS unmap_unix_group(const struct group *grp, GROUP_MAP *pmap)
return status;
}
-static int net_sam_unmapunixgroup(int argc, const char **argv)
+static int net_sam_unmapunixgroup(struct net_context *c, int argc, const char **argv)
{
NTSTATUS status;
GROUP_MAP map;
@@ -791,7 +807,7 @@ static int net_sam_unmapunixgroup(int argc, const char **argv)
* Create a local group
*/
-static int net_sam_createlocalgroup(int argc, const char **argv)
+static int net_sam_createlocalgroup(struct net_context *c, int argc, const char **argv)
{
NTSTATUS status;
uint32 rid;
@@ -824,7 +840,7 @@ static int net_sam_createlocalgroup(int argc, const char **argv)
* Delete a local group
*/
-static int net_sam_deletelocalgroup(int argc, const char **argv)
+static int net_sam_deletelocalgroup(struct net_context *c, int argc, const char **argv)
{
DOM_SID sid;
enum lsa_SidType type;
@@ -865,7 +881,7 @@ static int net_sam_deletelocalgroup(int argc, const char **argv)
* Create a local group
*/
-static int net_sam_createbuiltingroup(int argc, const char **argv)
+static int net_sam_createbuiltingroup(struct net_context *c, int argc, const char **argv)
{
NTSTATUS status;
uint32 rid;
@@ -917,7 +933,7 @@ static int net_sam_createbuiltingroup(int argc, const char **argv)
* Add a group member
*/
-static int net_sam_addmem(int argc, const char **argv)
+static int net_sam_addmem(struct net_context *c, int argc, const char **argv)
{
const char *groupdomain, *groupname, *memberdomain, *membername;
DOM_SID group, member;
@@ -988,7 +1004,7 @@ static int net_sam_addmem(int argc, const char **argv)
* Delete a group member
*/
-static int net_sam_delmem(int argc, const char **argv)
+static int net_sam_delmem(struct net_context *c, int argc, const char **argv)
{
const char *groupdomain, *groupname;
const char *memberdomain = NULL;
@@ -1048,7 +1064,7 @@ static int net_sam_delmem(int argc, const char **argv)
* List group members
*/
-static int net_sam_listmem(int argc, const char **argv)
+static int net_sam_listmem(struct net_context *c, int argc, const char **argv)
{
const char *groupdomain, *groupname;
DOM_SID group;
@@ -1104,7 +1120,7 @@ static int net_sam_listmem(int argc, const char **argv)
/*
* Do the listing
*/
-static int net_sam_do_list(int argc, const char **argv,
+static int net_sam_do_list(struct net_context *c, int argc, const char **argv,
struct pdb_search *search, const char *what)
{
bool verbose = (argc == 1);
@@ -1139,34 +1155,39 @@ static int net_sam_do_list(int argc, const char **argv,
return 0;
}
-static int net_sam_list_users(int argc, const char **argv)
+static int net_sam_list_users(struct net_context *c, int argc,
+ const char **argv)
{
- return net_sam_do_list(argc, argv, pdb_search_users(ACB_NORMAL),
+ return net_sam_do_list(c, argc, argv, pdb_search_users(ACB_NORMAL),
"users");
}
-static int net_sam_list_groups(int argc, const char **argv)
+static int net_sam_list_groups(struct net_context *c, int argc,
+ const char **argv)
{
- return net_sam_do_list(argc, argv, pdb_search_groups(), "groups");
+ return net_sam_do_list(c, argc, argv, pdb_search_groups(), "groups");
}
-static int net_sam_list_localgroups(int argc, const char **argv)
+static int net_sam_list_localgroups(struct net_context *c, int argc,
+ const char **argv)
{
- return net_sam_do_list(argc, argv,
+ return net_sam_do_list(c, argc, argv,
pdb_search_aliases(get_global_sam_sid()),
"localgroups");
}
-static int net_sam_list_builtin(int argc, const char **argv)
+static int net_sam_list_builtin(struct net_context *c, int argc,
+ const char **argv)
{
- return net_sam_do_list(argc, argv,
+ return net_sam_do_list(c, argc, argv,
pdb_search_aliases(&global_sid_Builtin),
"builtin");
}
-static int net_sam_list_workstations(int argc, const char **argv)
+static int net_sam_list_workstations(struct net_context *c, int argc,
+ const char **argv)
{
- return net_sam_do_list(argc, argv,
+ return net_sam_do_list(c, argc, argv,
pdb_search_users(ACB_WSTRUST),
"workstations");
}
@@ -1175,7 +1196,7 @@ static int net_sam_list_workstations(int argc, const char **argv)
* List stuff
*/
-static int net_sam_list(int argc, const char **argv)
+static int net_sam_list(struct net_context *c, int argc, const char **argv)
{
struct functable2 func[] = {
{ "users", net_sam_list_users,
@@ -1191,14 +1212,14 @@ static int net_sam_list(int argc, const char **argv)
{NULL, NULL}
};
- return net_run_function2(argc, argv, "net sam list", func);
+ return net_run_function2(c, argc, argv, "net sam list", func);
}
/*
* Show details of SAM entries
*/
-static int net_sam_show(int argc, const char **argv)
+static int net_sam_show(struct net_context *c, int argc, const char **argv)
{
DOM_SID sid;
enum lsa_SidType type;
@@ -1228,7 +1249,7 @@ static int net_sam_show(int argc, const char **argv)
* if ldapsam:editposix is enabled
*/
-static int net_sam_provision(int argc, const char **argv)
+static int net_sam_provision(struct net_context *c, int argc, const char **argv)
{
TALLOC_CTX *tc;
char *ldap_bk;
@@ -1630,7 +1651,7 @@ failed:
/***********************************************************
migrated functionality from smbgroupedit
**********************************************************/
-int net_sam(int argc, const char **argv)
+int net_sam(struct net_context *c, int argc, const char **argv)
{
struct functable2 func[] = {
{ "createbuiltingroup", net_sam_createbuiltingroup,
@@ -1671,6 +1692,6 @@ int net_sam(int argc, const char **argv)
"work\n");
}
- return net_run_function2(argc, argv, "net sam", func);
+ return net_run_function2(c, argc, argv, "net sam", func);
}
diff --git a/source3/utils/net_status.c b/source3/utils/net_status.c
index 4a3c5895a7e..4166c9462b3 100644
--- a/source3/utils/net_status.c
+++ b/source3/utils/net_status.c
@@ -49,7 +49,7 @@ static int show_session(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf,
return 0;
}
-static int net_status_sessions(int argc, const char **argv)
+static int net_status_sessions(struct net_context *c, int argc, const char **argv)
{
TDB_CONTEXT *tdb;
bool parseable;
@@ -59,7 +59,7 @@ static int net_status_sessions(int argc, const char **argv)
} else if ((argc == 1) && strequal(argv[0], "parseable")) {
parseable = True;
} else {
- return net_help_status(argc, argv);
+ return net_help_status(c, argc, argv);
}
if (!parseable) {
@@ -168,7 +168,7 @@ static int show_share_parseable(struct db_record *rec,
return 0;
}
-static int net_status_shares_parseable(int argc, const char **argv)
+static int net_status_shares_parseable(struct net_context *c, int argc, const char **argv)
{
struct sessionids ids;
TDB_CONTEXT *tdb;
@@ -194,7 +194,7 @@ static int net_status_shares_parseable(int argc, const char **argv)
return 0;
}
-static int net_status_shares(int argc, const char **argv)
+static int net_status_shares(struct net_context *c, int argc, const char **argv)
{
if (argc == 0) {
@@ -209,18 +209,18 @@ static int net_status_shares(int argc, const char **argv)
}
if ((argc != 1) || !strequal(argv[0], "parseable")) {
- return net_help_status(argc, argv);
+ return net_help_status(c, argc, argv);
}
- return net_status_shares_parseable(argc, argv);
+ return net_status_shares_parseable(c, argc, argv);
}
-int net_status(int argc, const char **argv)
+int net_status(struct net_context *c, int argc, const char **argv)
{
struct functable func[] = {
{"sessions", net_status_sessions},
{"shares", net_status_shares},
{NULL, NULL}
};
- return net_run_function(argc, argv, func, net_help_status);
+ return net_run_function(c, argc, argv, func, net_help_status);
}
diff --git a/source3/utils/net_time.c b/source3/utils/net_time.c
index 7375206af63..48417fbc0f3 100644
--- a/source3/utils/net_time.c
+++ b/source3/utils/net_time.c
@@ -14,8 +14,8 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
#include "includes.h"
#include "utils/net.h"
@@ -68,9 +68,10 @@ done:
}
/* find the servers time on the opt_host host */
-static time_t nettime(int *zone)
+static time_t nettime(struct net_context *c, int *zone)
{
- return cli_servertime(opt_host, opt_have_ip? &opt_dest_ip : NULL, zone);
+ return cli_servertime(c->opt_host,
+ c->opt_have_ip? &c->opt_dest_ip : NULL, zone);
}
/* return a time as a string ready to be passed to /bin/date */
@@ -90,7 +91,7 @@ static const char *systime(time_t t)
return s;
}
-int net_time_usage(int argc, const char **argv)
+int net_time_usage(struct net_context *c, int argc, const char **argv)
{
d_printf(
"net time\n\tdisplays time on a server\n\n"\
@@ -98,14 +99,14 @@ int net_time_usage(int argc, const char **argv)
"net time set\n\truns /bin/date with the time from the server\n\n"\
"net time zone\n\tdisplays the timezone in hours from GMT on the remote computer\n\n"\
"\n");
- net_common_flags_usage(argc, argv);
+ net_common_flags_usage(c, argc, argv);
return -1;
}
/* try to set the system clock using /bin/date */
-static int net_time_set(int argc, const char **argv)
+static int net_time_set(struct net_context *c, int argc, const char **argv)
{
- time_t t = nettime(NULL);
+ time_t t = nettime(c, NULL);
char *cmd;
int result;
@@ -125,9 +126,9 @@ static int net_time_set(int argc, const char **argv)
}
/* display the time on a remote box in a format ready for /bin/date */
-static int net_time_system(int argc, const char **argv)
+static int net_time_system(struct net_context *c, int argc, const char **argv)
{
- time_t t = nettime(NULL);
+ time_t t = nettime(c, NULL);
if (t == 0) return -1;
@@ -137,14 +138,14 @@ static int net_time_system(int argc, const char **argv)
}
/* display the time on a remote box in a format ready for /bin/date */
-static int net_time_zone(int argc, const char **argv)
+static int net_time_zone(struct net_context *c, int argc, const char **argv)
{
int zone = 0;
int hours, mins;
char zsign;
time_t t;
- t = nettime(&zone);
+ t = nettime(c, &zone);
if (t == 0) return -1;
@@ -161,7 +162,7 @@ static int net_time_zone(int argc, const char **argv)
}
/* display or set the time on a host */
-int net_time(int argc, const char **argv)
+int net_time(struct net_context *c, int argc, const char **argv)
{
time_t t;
struct functable func[] = {
@@ -171,20 +172,21 @@ int net_time(int argc, const char **argv)
{NULL, NULL}
};
- if (!opt_host && !opt_have_ip &&
- !find_master_ip(opt_target_workgroup, &opt_dest_ip)) {
+ if (!c->opt_host && !c->opt_have_ip &&
+ !find_master_ip(c->opt_target_workgroup, &c->opt_dest_ip)) {
d_fprintf(stderr, "Could not locate a time server. Try "\
"specifying a target host.\n");
- net_time_usage(argc,argv);
+ net_time_usage(c, argc,argv);
return -1;
}
if (argc != 0) {
- return net_run_function(argc, argv, func, net_time_usage);
+ return net_run_function(c, argc, argv, func, net_time_usage);
}
/* default - print the time */
- t = cli_servertime(opt_host, opt_have_ip? &opt_dest_ip : NULL, NULL);
+ t = cli_servertime(c->opt_host, c->opt_have_ip? &c->opt_dest_ip : NULL,
+ NULL);
if (t == 0) return -1;
d_printf("%s", ctime(&t));
diff --git a/source3/utils/net_usershare.c b/source3/utils/net_usershare.c
index 550157a1037..02fa12a2721 100644
--- a/source3/utils/net_usershare.c
+++ b/source3/utils/net_usershare.c
@@ -15,7 +15,8 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
#include "includes.h"
#include "utils/net.h"
@@ -59,9 +60,9 @@ static const char *get_us_error_code(enum usershare_err us_err)
/* The help subsystem for the USERSHARE subcommand */
-static int net_usershare_add_usage(int argc, const char **argv)
+static int net_usershare_add_usage(struct net_context *c, int argc, const char **argv)
{
- char c = *lp_winbind_separator();
+ char chr = *lp_winbind_separator();
d_printf(
"net usershare add [-l|--long] <sharename> <path> [<comment>] [<acl>] [<guest_ok=[y|n]>]\n"
"\tAdds the specified share name for this user.\n"
@@ -76,11 +77,11 @@ static int net_usershare_add_usage(int argc, const char **argv)
"instead of \"DOMAIN\"\n"
"\t\tThe default acl is \"Everyone:r\" which allows everyone read-only access.\n"
"\tAdd -l or --long to print the info on the newly added share.\n",
- c, c );
+ chr, chr );
return -1;
}
-static int net_usershare_delete_usage(int argc, const char **argv)
+static int net_usershare_delete_usage(struct net_context *c, int argc, const char **argv)
{
d_printf(
"net usershare delete <sharename>\n"\
@@ -88,7 +89,7 @@ static int net_usershare_delete_usage(int argc, const char **argv)
return -1;
}
-static int net_usershare_info_usage(int argc, const char **argv)
+static int net_usershare_info_usage(struct net_context *c, int argc, const char **argv)
{
d_printf(
"net usershare info [-l|--long] [wildcard sharename]\n"\
@@ -99,7 +100,7 @@ static int net_usershare_info_usage(int argc, const char **argv)
return -1;
}
-static int net_usershare_list_usage(int argc, const char **argv)
+static int net_usershare_list_usage(struct net_context *c, int argc, const char **argv)
{
d_printf(
"net usershare list [-l|--long] [wildcard sharename]\n"\
@@ -110,7 +111,7 @@ static int net_usershare_list_usage(int argc, const char **argv)
return -1;
}
-int net_usershare_usage(int argc, const char **argv)
+int net_usershare_usage(struct net_context *c, int argc, const char **argv)
{
d_printf("net usershare add <sharename> <path> [<comment>] [<acl>] [<guest_ok=[y|n]>] to "
"add or change a user defined share.\n"
@@ -120,7 +121,7 @@ int net_usershare_usage(int argc, const char **argv)
"net usershare help\n"\
"\nType \"net usershare help <option>\" to get more information on that option\n\n");
- net_common_flags_usage(argc, argv);
+ net_common_flags_usage(c, argc, argv);
return -1;
}
@@ -144,13 +145,13 @@ static char *get_basepath(TALLOC_CTX *ctx)
Delete a single userlevel share.
***************************************************************************/
-static int net_usershare_delete(int argc, const char **argv)
+static int net_usershare_delete(struct net_context *c, int argc, const char **argv)
{
char *us_path;
char *sharename;
if (argc != 1) {
- return net_usershare_delete_usage(argc, argv);
+ return net_usershare_delete_usage(c, argc, argv);
}
if ((sharename = strdup_lower(argv[0])) == NULL) {
@@ -287,6 +288,7 @@ enum us_priv_op { US_LIST_OP, US_INFO_OP};
struct us_priv_info {
TALLOC_CTX *ctx;
enum us_priv_op op;
+ struct net_context *c;
};
/***************************************************************************
@@ -315,6 +317,7 @@ static int info_fn(struct file_list *fl, void *priv)
char **lines = NULL;
struct us_priv_info *pi = (struct us_priv_info *)priv;
TALLOC_CTX *ctx = pi->ctx;
+ struct net_context *c = pi->c;
int fd = -1;
int numlines = 0;
SEC_DESC *psd = NULL;
@@ -402,7 +405,9 @@ static int info_fn(struct file_list *fl, void *priv)
const char *name;
NTSTATUS ntstatus;
- ntstatus = net_lookup_name_from_sid(ctx, &psd->dacl->aces[num_aces].trustee, &domain, &name);
+ ntstatus = net_lookup_name_from_sid(c, ctx,
+ &psd->dacl->aces[num_aces].trustee,
+ &domain, &name);
if (NT_STATUS_IS_OK(ntstatus)) {
if (domain && *domain) {
@@ -471,7 +476,7 @@ static int info_fn(struct file_list *fl, void *priv)
Print out info (internal detail) on userlevel shares.
***************************************************************************/
-static int net_usershare_info(int argc, const char **argv)
+static int net_usershare_info(struct net_context *c, int argc, const char **argv)
{
fstring wcard;
bool only_ours = True;
@@ -481,7 +486,7 @@ static int net_usershare_info(int argc, const char **argv)
fstrcpy(wcard, "*");
- if (opt_long_list_entries) {
+ if (c->opt_long_list_entries) {
only_ours = False;
}
@@ -492,7 +497,7 @@ static int net_usershare_info(int argc, const char **argv)
fstrcpy(wcard, argv[0]);
break;
default:
- return net_usershare_info_usage(argc, argv);
+ return net_usershare_info_usage(c, argc, argv);
}
strlower_m(wcard);
@@ -505,6 +510,7 @@ static int net_usershare_info(int argc, const char **argv)
pi.ctx = ctx;
pi.op = US_INFO_OP;
+ pi.c = c;
ret = process_share_list(info_fn, &pi);
talloc_destroy(ctx);
@@ -581,7 +587,7 @@ static int count_num_usershares(void)
Add a single userlevel share.
***************************************************************************/
-static int net_usershare_add(int argc, const char **argv)
+static int net_usershare_add(struct net_context *c, int argc, const char **argv)
{
TALLOC_CTX *ctx = talloc_stackframe();
SMB_STRUCT_STAT sbuf;
@@ -610,7 +616,7 @@ static int net_usershare_add(int argc, const char **argv)
case 0:
case 1:
default:
- return net_usershare_add_usage(argc, argv);
+ return net_usershare_add_usage(c, argc, argv);
case 2:
sharename = strdup_lower(argv[0]);
us_path = argv[1];
@@ -636,7 +642,7 @@ static int net_usershare_add(int argc, const char **argv)
}
if (!strnequal(argv[4], "guest_ok=", 9)) {
TALLOC_FREE(ctx);
- return net_usershare_add_usage(argc, argv);
+ return net_usershare_add_usage(c, argc, argv);
}
switch (argv[4][9]) {
case 'y':
@@ -649,7 +655,7 @@ static int net_usershare_add(int argc, const char **argv)
break;
default:
TALLOC_FREE(ctx);
- return net_usershare_add_usage(argc, argv);
+ return net_usershare_add_usage(c, argc, argv);
}
break;
}
@@ -811,7 +817,7 @@ static int net_usershare_add(int argc, const char **argv)
}
if (!string_to_sid(&sid, name)) {
/* Convert to a SID */
- NTSTATUS ntstatus = net_lookup_sid_from_name(ctx, name, &sid);
+ NTSTATUS ntstatus = net_lookup_sid_from_name(c, ctx, name, &sid);
if (!NT_STATUS_IS_OK(ntstatus)) {
d_fprintf(stderr, "net usershare add: cannot convert name \"%s\" to a SID. %s.",
name, get_friendly_nt_error_msg(ntstatus) );
@@ -920,11 +926,11 @@ static int net_usershare_add(int argc, const char **argv)
close(tmpfd);
- if (opt_long_list_entries) {
+ if (c->opt_long_list_entries) {
const char *my_argv[2];
my_argv[0] = sharename;
my_argv[1] = NULL;
- net_usershare_info(1, my_argv);
+ net_usershare_info(c, 1, my_argv);
}
SAFE_FREE(sharename);
@@ -948,7 +954,8 @@ static int list_fn(struct file_list *fl, void *priv)
List userlevel shares.
***************************************************************************/
-static int net_usershare_list(int argc, const char **argv)
+static int net_usershare_list(struct net_context *c, int argc,
+ const char **argv)
{
fstring wcard;
bool only_ours = True;
@@ -958,7 +965,7 @@ static int net_usershare_list(int argc, const char **argv)
fstrcpy(wcard, "*");
- if (opt_long_list_entries) {
+ if (c->opt_long_list_entries) {
only_ours = False;
}
@@ -969,7 +976,7 @@ static int net_usershare_list(int argc, const char **argv)
fstrcpy(wcard, argv[0]);
break;
default:
- return net_usershare_list_usage(argc, argv);
+ return net_usershare_list_usage(c, argc, argv);
}
strlower_m(wcard);
@@ -992,7 +999,7 @@ static int net_usershare_list(int argc, const char **argv)
Handle "net usershare help *" subcommands.
***************************************************************************/
-int net_usershare_help(int argc, const char **argv)
+int net_usershare_help(struct net_context *c, int argc, const char **argv)
{
struct functable func[] = {
{"ADD", net_usershare_add_usage},
@@ -1001,14 +1008,14 @@ int net_usershare_help(int argc, const char **argv)
{"LIST", net_usershare_list_usage},
{NULL, NULL}};
- return net_run_function(argc, argv, func, net_usershare_usage);
+ return net_run_function(c, argc, argv, func, net_usershare_usage);
}
/***************************************************************************
Entry-point for all the USERSHARE functions.
***************************************************************************/
-int net_usershare(int argc, const char **argv)
+int net_usershare(struct net_context *c, int argc, const char **argv)
{
SMB_STRUCT_DIR *dp;
@@ -1042,5 +1049,5 @@ int net_usershare(int argc, const char **argv)
}
sys_closedir(dp);
- return net_run_function(argc, argv, func, net_usershare_usage);
+ return net_run_function(c, argc, argv, func, net_usershare_usage);
}
diff --git a/source3/utils/net_util.c b/source3/utils/net_util.c
index 576c2191b31..db3e51b9b3b 100644
--- a/source3/utils/net_util.c
+++ b/source3/utils/net_util.c
@@ -21,7 +21,8 @@
#include "includes.h"
#include "utils/net.h"
-NTSTATUS net_rpc_lookup_name(TALLOC_CTX *mem_ctx, struct cli_state *cli,
+NTSTATUS net_rpc_lookup_name(struct net_context *c,
+ TALLOC_CTX *mem_ctx, struct cli_state *cli,
const char *name, const char **ret_domain,
const char **ret_name, DOM_SID *ret_sid,
enum lsa_SidType *ret_type)
diff --git a/source3/utils/netlookup.c b/source3/utils/netlookup.c
index 90f99e4c8b0..7d144cf624e 100644
--- a/source3/utils/netlookup.c
+++ b/source3/utils/netlookup.c
@@ -53,7 +53,8 @@ static int cs_destructor(struct con_struct *p)
Create the connection to localhost.
********************************************************/
-static struct con_struct *create_cs(TALLOC_CTX *ctx, NTSTATUS *perr)
+static struct con_struct *create_cs(struct net_context *c,
+ TALLOC_CTX *ctx, NTSTATUS *perr)
{
NTSTATUS nt_status;
struct sockaddr_storage loopback_ss;
@@ -97,12 +98,12 @@ static struct con_struct *create_cs(TALLOC_CTX *ctx, NTSTATUS *perr)
&loopback_ss, 0,
"IPC$", "IPC",
#if 0
- opt_user_name,
- opt_workgroup,
- opt_password,
+ c->opt_user_name,
+ c->opt_workgroup,
+ c->opt_password,
#else
"",
- opt_workgroup,
+ c->opt_workgroup,
"",
#endif
0,
@@ -152,7 +153,8 @@ static struct con_struct *create_cs(TALLOC_CTX *ctx, NTSTATUS *perr)
The local smbd will also ask winbindd for us, so we don't have to.
********************************************************/
-NTSTATUS net_lookup_name_from_sid(TALLOC_CTX *ctx,
+NTSTATUS net_lookup_name_from_sid(struct net_context *c,
+ TALLOC_CTX *ctx,
DOM_SID *psid,
const char **ppdomain,
const char **ppname)
@@ -166,7 +168,7 @@ NTSTATUS net_lookup_name_from_sid(TALLOC_CTX *ctx,
*ppdomain = NULL;
*ppname = NULL;
- csp = create_cs(ctx, &nt_status);
+ csp = create_cs(c, ctx, &nt_status);
if (csp == NULL) {
return nt_status;
}
@@ -194,14 +196,15 @@ NTSTATUS net_lookup_name_from_sid(TALLOC_CTX *ctx,
Do a lookup_names call to localhost.
********************************************************/
-NTSTATUS net_lookup_sid_from_name(TALLOC_CTX *ctx, const char *full_name, DOM_SID *pret_sid)
+NTSTATUS net_lookup_sid_from_name(struct net_context *c, TALLOC_CTX *ctx,
+ const char *full_name, DOM_SID *pret_sid)
{
NTSTATUS nt_status;
struct con_struct *csp = NULL;
DOM_SID *sids = NULL;
enum lsa_SidType *types = NULL;
- csp = create_cs(ctx, &nt_status);
+ csp = create_cs(c, ctx, &nt_status);
if (csp == NULL) {
return nt_status;
}