diff options
Diffstat (limited to 'source3/utils')
33 files changed, 1880 insertions, 1059 deletions
diff --git a/source3/utils/net.c b/source3/utils/net.c index db7f6c090c..99e1e0c889 100644 --- a/source3/utils/net.c +++ b/source3/utils/net.c @@ -43,6 +43,10 @@ #include "includes.h" #include "utils/net.h" +#ifdef WITH_FAKE_KASERVER +#include "utils/net_afs.h" +#endif + /***********************************************************************/ /* Beginning of internationalization section. Translatable constants */ /* should be kept in this area and referenced in the rest of the code. */ @@ -125,478 +129,6 @@ int net_run_function2(struct net_context *c, int argc, const char **argv, return -1; } -/**************************************************************************** - Connect to \\server\service. -****************************************************************************/ - -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, - const char *service_type) -{ - NTSTATUS nt_status; - - 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(cli_ctx, NULL, server_name, - server_ss, c->opt_port, - service_name, service_type, - 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); - - /* Display a nicer message depending on the result */ - - if (NT_STATUS_V(nt_status) == - NT_STATUS_V(NT_STATUS_LOGON_FAILURE)) - d_fprintf(stderr, "The username or password was not correct.\n"); - - if (NT_STATUS_V(nt_status) == - NT_STATUS_V(NT_STATUS_ACCOUNT_LOCKED_OUT)) - d_fprintf(stderr, "The account was locked out.\n"); - - if (NT_STATUS_V(nt_status) == - NT_STATUS_V(NT_STATUS_ACCOUNT_DISABLED)) - d_fprintf(stderr, "The account was disabled.\n"); - return nt_status; - } - - 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 " - "server that doesn't support " - "UNIX extensions - failing connect\n"); - } else if (NT_STATUS_EQUAL(nt_status,NT_STATUS_UNKNOWN_REVISION)) { - d_printf("Encryption required and " - "can't get UNIX CIFS extensions " - "version from server.\n"); - } else if (NT_STATUS_EQUAL(nt_status,NT_STATUS_UNSUPPORTED_COMPRESSION)) { - d_printf("Encryption required and " - "share %s doesn't support " - "encryption.\n", service_name); - } else if (!NT_STATUS_IS_OK(nt_status)) { - d_printf("Encryption required and " - "setup failed with error %s.\n", - nt_errstr(nt_status)); - } - - if (!NT_STATUS_IS_OK(nt_status)) { - cli_shutdown(*cli_ctx); - *cli_ctx = NULL; - } - } - - return nt_status; -} - -/**************************************************************************** - Connect to \\server\ipc$. -****************************************************************************/ - -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, cli_ctx, server_ss, server_name, "IPC$", - "IPC"); -} - -/**************************************************************************** - Connect to \\server\ipc$ anonymously. -****************************************************************************/ - -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(cli_ctx, c->opt_requester_name, - server_name, server_ss, c->opt_port, - "IPC$", "IPC", - "", "", - "", 0, Undefined, NULL); - - if (NT_STATUS_IS_OK(nt_status)) { - return nt_status; - } else { - DEBUG(1,("Cannot connect to server (anonymously). Error was %s\n", nt_errstr(nt_status))); - return nt_status; - } -} - -/**************************************************************************** - Return malloced user@realm for krb5 login. -****************************************************************************/ - -static char *get_user_and_realm(const char *username) -{ - char *user_and_realm = NULL; - - if (!username) { - return NULL; - } - if (strchr_m(username, '@')) { - user_and_realm = SMB_STRDUP(username); - } else { - if (asprintf(&user_and_realm, "%s@%s", username, lp_realm()) == -1) { - user_and_realm = NULL; - } - } - return user_and_realm; -} - -/**************************************************************************** - Connect to \\server\ipc$ using KRB5. -****************************************************************************/ - -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; - - /* 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(c->opt_user_name); - if (!user_and_realm) { - return NT_STATUS_NO_MEMORY; - } - - nt_status = cli_full_connection(cli_ctx, NULL, server_name, - server_ss, c->opt_port, - "IPC$", "IPC", - user_and_realm, c->opt_workgroup, - c->opt_password, - CLI_FULL_CONNECTION_USE_KERBEROS, - Undefined, NULL); - - SAFE_FREE(user_and_realm); - - if (!NT_STATUS_IS_OK(nt_status)) { - DEBUG(1,("Cannot connect to server using kerberos. Error was %s\n", nt_errstr(nt_status))); - return nt_status; - } - - if (c->smb_encrypt) { - nt_status = cli_cm_force_encryption(*cli_ctx, - user_and_realm, - c->opt_password, - c->opt_workgroup, - "IPC$"); - if (!NT_STATUS_IS_OK(nt_status)) { - cli_shutdown(*cli_ctx); - *cli_ctx = NULL; - } - } - - return nt_status; -} - -/** - * Connect a server and open a given pipe - * - * @param cli_dst A cli_state - * @param pipe The pipe to open - * @param got_pipe boolean that stores if we got a pipe - * - * @return Normal NTSTATUS return. - **/ -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"); - struct cli_state *cli_tmp = NULL; - struct rpc_pipe_client *pipe_hnd = NULL; - - if (server_name == NULL) { - return NT_STATUS_NO_MEMORY; - } - - if (c->opt_destination) { - SAFE_FREE(server_name); - 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(c, &cli_tmp, NULL, server_name); - if (!NT_STATUS_IS_OK(nt_status)) { - SAFE_FREE(server_name); - return nt_status; - } - - pipe_hnd = cli_rpc_pipe_open_noauth(cli_tmp, pipe_num, &nt_status); - if (!pipe_hnd) { - DEBUG(0, ("couldn't not initialize pipe\n")); - cli_shutdown(cli_tmp); - SAFE_FREE(server_name); - return nt_status; - } - - *cli_dst = cli_tmp; - *pp_pipe_hnd = pipe_hnd; - SAFE_FREE(server_name); - - return nt_status; -} - -/**************************************************************************** - Use the local machine account (krb) and password for this session. -****************************************************************************/ - -int net_use_krb_machine_account(struct net_context *c) -{ - char *user_name = NULL; - - if (!secrets_init()) { - d_fprintf(stderr, "ERROR: Unable to open secrets database\n"); - exit(1); - } - - 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; - } - c->opt_user_name = user_name; - return 0; -} - -/**************************************************************************** - Use the machine account name and password for this session. -****************************************************************************/ - -int net_use_machine_account(struct net_context *c) -{ - char *user_name = NULL; - - if (!secrets_init()) { - d_fprintf(stderr, "ERROR: Unable to open secrets database\n"); - exit(1); - } - - c->opt_password = secrets_fetch_machine_password( - c->opt_target_workgroup, NULL, NULL); - if (asprintf(&user_name, "%s$", global_myname()) == -1) { - return -1; - } - c->opt_user_name = user_name; - return 0; -} - -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 : c->opt_target_workgroup; - - if (c->opt_host) { - *server_name = SMB_STRDUP(c->opt_host); - } - - if (c->opt_have_ip) { - *server_ss = c->opt_dest_ip; - if (!*server_name) { - char addr[INET6_ADDRSTRLEN]; - print_sockaddr(addr, sizeof(addr), &c->opt_dest_ip); - *server_name = SMB_STRDUP(addr); - } - } else if (*server_name) { - /* resolve the IP address */ - if (!resolve_name(*server_name, server_ss, 0x20)) { - DEBUG(1,("Unable to resolve server name\n")); - return false; - } - } else if (flags & NET_FLAGS_PDC) { - fstring dc_name; - struct sockaddr_storage pdc_ss; - - if (!get_pdc_ip(d, &pdc_ss)) { - DEBUG(1,("Unable to resolve PDC server address\n")); - return false; - } - - if (is_zero_addr(&pdc_ss)) { - return false; - } - - if (!name_status_find(d, 0x1b, 0x20, &pdc_ss, dc_name)) { - return False; - } - - *server_name = SMB_STRDUP(dc_name); - *server_ss = pdc_ss; - } else if (flags & NET_FLAGS_DMB) { - struct sockaddr_storage msbrow_ss; - char addr[INET6_ADDRSTRLEN]; - - /* if (!resolve_name(MSBROWSE, &msbrow_ip, 1)) */ - if (!resolve_name(d, &msbrow_ss, 0x1B)) { - DEBUG(1,("Unable to resolve domain browser via name lookup\n")); - return false; - } - *server_ss = msbrow_ss; - print_sockaddr(addr, sizeof(addr), server_ss); - *server_name = SMB_STRDUP(addr); - } else if (flags & NET_FLAGS_MASTER) { - struct sockaddr_storage brow_ss; - char addr[INET6_ADDRSTRLEN]; - if (!resolve_name(d, &brow_ss, 0x1D)) { - /* go looking for workgroups */ - DEBUG(1,("Unable to resolve master browser via name lookup\n")); - return false; - } - *server_ss = brow_ss; - print_sockaddr(addr, sizeof(addr), server_ss); - *server_name = SMB_STRDUP(addr); - } else if (!(flags & NET_FLAGS_LOCALHOST_DEFAULT_INSANE)) { - if (!interpret_string_addr(server_ss, - "127.0.0.1", AI_NUMERICHOST)) { - DEBUG(1,("Unable to resolve 127.0.0.1\n")); - return false; - } - *server_name = SMB_STRDUP("127.0.0.1"); - } - - if (!*server_name) { - DEBUG(1,("no server to connect to\n")); - return False; - } - - return True; -} - -bool net_find_pdc(struct sockaddr_storage *server_ss, - fstring server_name, - const char *domain_name) -{ - if (!get_pdc_ip(domain_name, server_ss)) { - return false; - } - if (is_zero_addr(server_ss)) { - return false; - } - - if (!name_status_find(domain_name, 0x1b, 0x20, server_ss, server_name)) { - return false; - } - - return true; -} - -NTSTATUS net_make_ipc_connection(struct net_context *c, unsigned flags, - struct cli_state **pcli) -{ - return net_make_ipc_connection_ex(c, NULL, NULL, NULL, flags, 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; - struct cli_state *cli = NULL; - NTSTATUS nt_status; - - if ( !server || !pss ) { - 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; - } - } else { - server_name = SMB_STRDUP( server ); - server_ss = *pss; - } - - if (flags & NET_FLAGS_ANONYMOUS) { - nt_status = connect_to_ipc_anonymous(c, &cli, &server_ss, - server_name); - } else { - nt_status = connect_to_ipc(c, &cli, &server_ss, - server_name); - } - - /* store the server in the affinity cache if it was a PDC */ - - if ( (flags & NET_FLAGS_PDC) && NT_STATUS_IS_OK(nt_status) ) - saf_store( cli->server_domain, cli->desthost ); - - SAFE_FREE(server_name); - if (!NT_STATUS_IS_OK(nt_status)) { - d_fprintf(stderr, "Connection failed: %s\n", - nt_errstr(nt_status)); - cli = NULL; - } - -done: - if (pcli != NULL) { - *pcli = cli; - } - return nt_status; -} - -static int net_user(struct net_context *c, int argc, const char **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(c, NET_FLAGS_PDC)) - return net_rpc_user(c, argc, argv); - - return net_rap_user(c, argc, argv); -} - -static int net_group(struct net_context *c, int argc, const char **argv) -{ - if (net_ads_check(c) == 0) - return net_ads_group(c, argc, argv); - - if (argc == 0 && net_rpc_check(c, NET_FLAGS_PDC)) - return net_rpc_group(c,argc, argv); - - return net_rap_group(c, argc, argv); -} - -static int net_join(struct net_context *c, int argc, const char **argv) -{ - 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(c, argc, argv); -} - static int net_changetrustpw(struct net_context *c, int argc, const char **argv) { if (net_ads_check_our_domain(c) == 0) @@ -642,20 +174,6 @@ static int net_changesecretpw(struct net_context *c, int argc, return 0; } -static int net_share(struct net_context *c, int argc, const char **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(struct net_context *c, int argc, const char **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 */ @@ -672,7 +190,7 @@ static int net_getlocalsid(struct net_context *c, int argc, const char **argv) name = global_myname(); } - if(!initialize_password_db(False, NULL)) { + if(!initialize_password_db(false, NULL)) { DEBUG(0, ("WARNING: Could not open passdb - local sid may not reflect passdb\n" "backend knowledge (such as the sid stored in LDAP)\n")); } @@ -747,7 +265,7 @@ static int net_getdomainsid(struct net_context *c, int argc, const char **argv) return 1; } - if(!initialize_password_db(False, NULL)) { + if(!initialize_password_db(false, NULL)) { DEBUG(0, ("WARNING: Could not open passdb - domain SID may " "not reflect passdb\n" "backend knowledge (such as the SID stored in " @@ -784,89 +302,6 @@ static int net_getdomainsid(struct net_context *c, int argc, const char **argv) return 0; } -#ifdef WITH_FAKE_KASERVER - -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"); - d_printf(" net afs impersonate <user> <cell>\n" - "\tCreates a token for user@cell\n\n"); - return -1; -} - -static int net_afs_key(struct net_context *c, int argc, const char **argv) -{ - int fd; - struct afs_keyfile keyfile; - - if (argc != 2) { - d_printf("usage: 'net afs key <keyfile> cell'\n"); - return -1; - } - - if (!secrets_init()) { - d_fprintf(stderr, "Could not open secrets.tdb\n"); - return -1; - } - - if ((fd = open(argv[0], O_RDONLY, 0)) < 0) { - d_fprintf(stderr, "Could not open %s\n", argv[0]); - return -1; - } - - if (read(fd, &keyfile, sizeof(keyfile)) != sizeof(keyfile)) { - d_fprintf(stderr, "Could not read keyfile\n"); - return -1; - } - - if (!secrets_store_afs_keyfile(argv[1], &keyfile)) { - d_fprintf(stderr, "Could not write keyfile to secrets.tdb\n"); - return -1; - } - - return 0; -} - -static int net_afs_impersonate(struct net_context *c, int argc, - const char **argv) -{ - char *token; - - if (argc != 2) { - fprintf(stderr, "Usage: net afs impersonate <user> <cell>\n"); - exit(1); - } - - token = afs_createtoken_str(argv[0], argv[1]); - - if (token == NULL) { - fprintf(stderr, "Could not create token\n"); - exit(1); - } - - if (!afs_settoken_str(token)) { - fprintf(stderr, "Could not set token into kernel\n"); - exit(1); - } - - printf("Success: %s@%s\n", argv[0], argv[1]); - return 0; -} - -static int net_afs(struct net_context *c, int argc, const char **argv) -{ - struct functable func[] = { - {"key", net_afs_key}, - {"impersonate", net_afs_impersonate}, - {"help", net_help_afs}, - {NULL, NULL} - }; - return net_run_function(c, argc, argv, func, net_help_afs); -} - -#endif /* WITH_FAKE_KASERVER */ - static bool search_maxrid(struct pdb_search *search, const char *type, uint32 *max_rid) { @@ -875,14 +310,14 @@ static bool search_maxrid(struct pdb_search *search, const char *type, if (search == NULL) { d_fprintf(stderr, "get_maxrid: Could not search %s\n", type); - return False; + return false; } num_entries = pdb_search_entries(search, 0, 0xffffffff, &entries); for (i=0; i<num_entries; i++) *max_rid = MAX(*max_rid, entries[i].rid); pdb_search_destroy(search); - return True; + return true; } static uint32 get_maxrid(void) @@ -921,33 +356,6 @@ static int net_maxrid(struct net_context *c, int argc, const char **argv) return 0; } -/**************************************************************************** -****************************************************************************/ - -const char *net_prompt_pass(struct net_context *c, const char *user) -{ - char *prompt = NULL; - const char *pass = NULL; - - if (c->opt_password) { - return c->opt_password; - } - - if (c->opt_machine_pass) { - return NULL; - } - - asprintf(&prompt, "Enter %s's password:", user); - if (!prompt) { - return NULL; - } - - pass = getpass(prompt); - SAFE_FREE(prompt); - - return pass; -} - /* main function table */ static struct functable net_func[] = { {"RPC", net_rpc}, @@ -1080,7 +488,7 @@ static struct functable net_func[] = { } break; case 'U': - c->opt_user_specified = True; + c->opt_user_specified = true; c->opt_user_name = SMB_STRDUP(c->opt_user_name); p = strchr(c->opt_user_name,'%'); if (p) { diff --git a/source3/utils/net.h b/source3/utils/net.h index 15b1dd402b..f40222ed71 100644 --- a/source3/utils/net.h +++ b/source3/utils/net.h @@ -113,6 +113,7 @@ struct net_context { /* INCLUDE FILES */ #include "utils/net_proto.h" +#include "utils/net_help_common.h" /* MACROS & DEFINES */ diff --git a/source3/utils/net_ads.c b/source3/utils/net_ads.c index 77d1629714..8053b24051 100644 --- a/source3/utils/net_ads.c +++ b/source3/utils/net_ads.c @@ -27,7 +27,7 @@ #ifdef HAVE_ADS -int net_ads_usage(struct net_context *c, int argc, const char **argv) +int net_ads_help(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"); @@ -219,11 +219,11 @@ static ADS_STATUS ads_startup_int(struct net_context *c, bool only_own_domain, { ADS_STRUCT *ads = NULL; ADS_STATUS status; - bool need_password = False; - bool second_time = False; + bool need_password = false; + bool second_time = false; char *cp; const char *realm = NULL; - bool tried_closest_dc = False; + bool tried_closest_dc = false; /* lp_realm() should be handled by a command line param, However, the join requires that realm be set in smb.conf @@ -246,7 +246,7 @@ retry_connect: } if (c->opt_user_specified) { - need_password = True; + need_password = true; } retry: @@ -292,8 +292,8 @@ retry: } if (!need_password && !second_time && !(auth_flags & ADS_AUTH_NO_BIND)) { - need_password = True; - second_time = True; + need_password = true; + second_time = true; goto retry; } else { ads_destroy(&ads); @@ -307,7 +307,7 @@ retry: if ((only_own_domain || !c->opt_host) && !tried_closest_dc) { - tried_closest_dc = True; /* avoid loop */ + tried_closest_dc = true; /* avoid loop */ if (!ads->config.tried_closest_dc) { @@ -420,21 +420,21 @@ static bool usergrp_display(ADS_STRUCT *ads, char *field, void **values, void *d } SAFE_FREE(disp_fields[0]); SAFE_FREE(disp_fields[1]); - return True; + return true; } if (!values) /* must be new field, indicate string field */ - return True; + return true; if (StrCaseCmp(field, "sAMAccountName") == 0) { disp_fields[0] = SMB_STRDUP((char *) values[0]); } if (StrCaseCmp(field, "description") == 0) disp_fields[1] = SMB_STRDUP((char *) values[0]); - return True; + return true; } static int net_ads_user_usage(struct net_context *c, int argc, const char **argv) { - return net_help_user(c, argc, argv); + return net_user_usage(c, argc, argv); } static int ads_user_add(struct net_context *c, int argc, const char **argv) @@ -647,7 +647,7 @@ int net_ads_user(struct net_context *c, int argc, const char **argv) static int net_ads_group_usage(struct net_context *c, int argc, const char **argv) { - return net_help_group(c, argc, argv); + return net_group_usage(c, argc, argv); } static int ads_group_add(struct net_context *c, int argc, const char **argv) @@ -1104,7 +1104,7 @@ int net_ads_join(struct net_context *c, int argc, const char **argv) struct libnet_JoinCtx *r = NULL; const char *domain = lp_realm(); WERROR werr = WERR_SETUP_NOT_JOINED; - bool createupn = False; + bool createupn = false; const char *machineupn = NULL; const char *create_in_ou = NULL; int i; @@ -1138,7 +1138,7 @@ int net_ads_join(struct net_context *c, int argc, const char **argv) for ( i=0; i<argc; i++ ) { if ( !StrnCaseCmp(argv[i], "createupn", strlen("createupn")) ) { - createupn = True; + createupn = true; machineupn = get_string_param(argv[i]); } else if ( !StrnCaseCmp(argv[i], "createcomputer", strlen("createcomputer")) ) { @@ -1296,7 +1296,7 @@ static int net_ads_dns_register(struct net_context *c, int argc, const char **ar return -1; } - status = ads_startup(c, True, &ads); + status = ads_startup(c, true, &ads); if ( !ADS_ERR_OK(status) ) { DEBUG(1, ("error on ads_startup: %s\n", ads_errstr(status))); TALLOC_FREE(ctx); @@ -2163,7 +2163,7 @@ int net_ads_kerberos(struct net_context *c, int argc, const char **argv) } -int net_ads_help(struct net_context *c, int argc, const char **argv) +int net_ads_usage(struct net_context *c, int argc, const char **argv) { struct functable func[] = { {"USER", net_ads_user_usage}, @@ -2180,7 +2180,7 @@ int net_ads_help(struct net_context *c, int argc, const char **argv) {NULL, NULL} }; - return net_run_function(c, argc, argv, func, net_ads_usage); + return net_run_function(c, argc, argv, func, net_ads_help); } int net_ads(struct net_context *c, int argc, const char **argv) @@ -2209,7 +2209,7 @@ int net_ads(struct net_context *c, int argc, const char **argv) {NULL, NULL} }; - return net_run_function(c, argc, argv, func, net_ads_usage); + return net_run_function(c, argc, argv, func, net_ads_help); } #else diff --git a/source3/utils/net_afs.c b/source3/utils/net_afs.c new file mode 100644 index 0000000000..f3f2976eb0 --- /dev/null +++ b/source3/utils/net_afs.c @@ -0,0 +1,101 @@ +/* + Samba Unix/Linux SMB client library + net afs commands + Copyright (C) 2003 Volker Lendecke (vl@samba.org) + + 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 + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + 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/>. +*/ + +#include "includes.h" +#include "utils/net.h" + +int net_afs_usage(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"); + d_printf(" net afs impersonate <user> <cell>\n" + "\tCreates a token for user@cell\n\n"); + return -1; +} + +int net_afs_key(struct net_context *c, int argc, const char **argv) +{ + int fd; + struct afs_keyfile keyfile; + + if (argc != 2) { + d_printf("usage: 'net afs key <keyfile> cell'\n"); + return -1; + } + + if (!secrets_init()) { + d_fprintf(stderr, "Could not open secrets.tdb\n"); + return -1; + } + + if ((fd = open(argv[0], O_RDONLY, 0)) < 0) { + d_fprintf(stderr, "Could not open %s\n", argv[0]); + return -1; + } + + if (read(fd, &keyfile, sizeof(keyfile)) != sizeof(keyfile)) { + d_fprintf(stderr, "Could not read keyfile\n"); + return -1; + } + + if (!secrets_store_afs_keyfile(argv[1], &keyfile)) { + d_fprintf(stderr, "Could not write keyfile to secrets.tdb\n"); + return -1; + } + + return 0; +} + +int net_afs_impersonate(struct net_context *c, int argc, + const char **argv) +{ + char *token; + + if (argc != 2) { + fprintf(stderr, "Usage: net afs impersonate <user> <cell>\n"); + exit(1); + } + + token = afs_createtoken_str(argv[0], argv[1]); + + if (token == NULL) { + fprintf(stderr, "Could not create token\n"); + exit(1); + } + + if (!afs_settoken_str(token)) { + fprintf(stderr, "Could not set token into kernel\n"); + exit(1); + } + + printf("Success: %s@%s\n", argv[0], argv[1]); + return 0; +} + +int net_afs(struct net_context *c, int argc, const char **argv) +{ + struct functable func[] = { + {"key", net_afs_key}, + {"impersonate", net_afs_impersonate}, + {"help", net_afs_usage}, + {NULL, NULL} + }; + return net_run_function(c, argc, argv, func, net_afs_usage); +} + diff --git a/source3/utils/net_afs.h b/source3/utils/net_afs.h new file mode 100644 index 0000000000..31606dd717 --- /dev/null +++ b/source3/utils/net_afs.h @@ -0,0 +1,29 @@ +/* + Samba Unix/Linux SMB client library + net afs commands + Copyright (C) 2008 Kai Blin (kai@samba.org) + + 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 + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + 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/>. +*/ + +#ifndef _NET_AFS_H_ +#define _NET_AFS_H_ + +int net_afs_usage(struct net_context *c, int argc, const char **argv); +int net_afs_key(struct net_context *c, int argc, const char **argv); +int net_afs_impersonate(struct net_context *c, int argc, + const char **argv); +int net_afs(struct net_context *c, int argc, const char **argv); + +#endif /*_NET_AFS_H_*/ diff --git a/source3/utils/net_dom.c b/source3/utils/net_dom.c index 1a876a7ba3..a0de818bff 100644 --- a/source3/utils/net_dom.c +++ b/source3/utils/net_dom.c @@ -20,22 +20,14 @@ #include "includes.h" #include "utils/net.h" -static int net_dom_usage(struct net_context *c, int argc, const char **argv) +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"); + "<domain=DOMAIN> <ou=OU> <account=ACCOUNT> "\ + "<password=PASSWORD> <reboot>\n Join a remote machine\n"); d_printf("usage: net dom unjoin " - "<account=ACCOUNT> <password=PASSWORD> <reboot>\n"); - - return -1; -} - -int net_help_dom(struct net_context *c, int argc, const char **argv) -{ - d_printf("net dom join"\ - "\n Join a remote machine\n"); - d_printf("net dom unjoin"\ - "\n Unjoin a remote machine\n"); + "<account=ACCOUNT> <password=PASSWORD> <reboot>\n"\ + " Unjoin a remote machine\n"); return -1; } @@ -238,7 +230,7 @@ int net_dom(struct net_context *c, int argc, const char **argv) struct functable func[] = { {"JOIN", net_dom_join}, {"UNJOIN", net_dom_unjoin}, - {"HELP", net_help_dom}, + {"HELP", net_dom_usage}, {NULL, NULL} }; diff --git a/source3/utils/net_file.c b/source3/utils/net_file.c new file mode 100644 index 0000000000..8aa1b0e443 --- /dev/null +++ b/source3/utils/net_file.c @@ -0,0 +1,57 @@ +/* + Samba Unix/Linux SMB client library + net file commands + Copyright (C) 2002 Jim McDonough (jmcd@us.ibm.com) + Copyright (C) 2002 Andrew Tridgell (tridge@samba.org) + Copyright (C) 2008 Kai Blin (kai@samba.org) + + 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 + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + 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/>. +*/ + +#include "includes.h" +#include "utils/net.h" + +int net_file_usage(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"); + d_printf("net [<method>] file USER <username> "\ + "[misc. options] [targets]"\ + "\n\tlists all files opened by username on file server\n\n"); + d_printf("net [<method>] file CLOSE <id> [misc. options] [targets]\n"\ + "\tcloses specified file on target server\n\n"); + d_printf("net [rap] file INFO <id> [misc. options] [targets]\n"\ + "\tdisplays information about the specified open file\n"); + + net_common_methods_usage(c, argc, argv); + net_common_flags_usage(c, argc, argv); + return -1; +} + +int net_file(struct net_context *c, int argc, const char **argv) +{ + if (argc < 1) + return net_file_usage(c, argc, argv); + + if (StrCaseCmp(argv[0], "HELP") == 0) { + net_file_usage(c, argc, argv); + return 0; + } + + if (net_rpc_check(c, 0)) + return net_rpc_file(c, argc, argv); + return net_rap_file(c, argc, argv); +} + + diff --git a/source3/utils/net_group.c b/source3/utils/net_group.c new file mode 100644 index 0000000000..2d5dba8b58 --- /dev/null +++ b/source3/utils/net_group.c @@ -0,0 +1,65 @@ +/* + Samba Unix/Linux SMB client library + net group commands + Copyright (C) 2002 Jim McDonough (jmcd@us.ibm.com) + Copyright (C) 2002 Andrew Tridgell (tridge@samba.org) + Copyright (C) 2008 Kai Blin (kai@samba.org) + + 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 + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + 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/>. +*/ + +#include "includes.h" +#include "utils/net.h" + +int net_group_usage(struct net_context *c, int argc, const char **argv) +{ + d_printf("net [<method>] group [misc. options] [targets]"\ + "\n\tList user groups\n\n"); + d_printf("net rpc group LIST [global|local|builtin]* [misc. options]"\ + "\n\tList specific user groups\n\n"); + d_printf("net [<method>] group DELETE <name> "\ + "[misc. options] [targets]"\ + "\n\tDelete specified group\n"); + d_printf("\nnet [<method>] group ADD <name> [-C comment] [-c container]"\ + " [misc. options] [targets]\n\tCreate specified group\n"); + 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(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_group(struct net_context *c, int argc, const char **argv) +{ + if (argc < 1) + return net_group_usage(c, argc, argv); + + if (StrCaseCmp(argv[0], "HELP") == 0) { + net_group_usage(c, argc, argv); + return 0; + } + + if (net_ads_check(c) == 0) + return net_ads_group(c, argc, argv); + + if (argc == 0 && net_rpc_check(c, NET_FLAGS_PDC)) + return net_rpc_group(c,argc, argv); + + return net_rap_group(c, argc, argv); +} + diff --git a/source3/utils/net_groupmap.c b/source3/utils/net_groupmap.c index 9f54bdaa08..4b4ec45dea 100644 --- a/source3/utils/net_groupmap.c +++ b/source3/utils/net_groupmap.c @@ -36,17 +36,17 @@ static bool get_sid_from_input(DOM_SID *sid, char *input) /* Perhaps its the NT group name? */ if (!pdb_getgrnam(&map, input)) { printf("NT Group %s doesn't exist in mapping DB\n", input); - return False; + return false; } else { *sid = map.sid; } } else { if (!string_to_sid(sid, input)) { printf("converting sid %s from a string failed!\n", input); - return False; + return false; } } - return True; + return true; } /********************************************************* @@ -75,18 +75,18 @@ static void print_map_entry ( GROUP_MAP map, bool long_list ) static int net_groupmap_list(struct net_context *c, int argc, const char **argv) { size_t entries; - bool long_list = False; + bool long_list = false; size_t i; fstring ntgroup = ""; fstring sid_string = ""; if (c->opt_verbose || c->opt_long_list_entries) - long_list = True; + long_list = true; /* get the options */ for ( i=0; i<argc; i++ ) { if ( !StrCaseCmp(argv[i], "verbose")) { - long_list = True; + long_list = true; } else if ( !StrnCaseCmp(argv[i], "ntgroup", strlen("ntgroup")) ) { fstrcpy( ntgroup, get_string_param( argv[i] ) ); @@ -494,7 +494,7 @@ static int net_groupmap_set(struct net_context *c, int argc, const char **argv) const char *ntgroup = NULL; struct group *grp = NULL; GROUP_MAP map; - bool have_map = False; + bool have_map = false; if ((argc < 1) || (argc > 2)) { d_printf("Usage: net groupmap set \"NT Group\" " @@ -712,7 +712,7 @@ static bool print_alias_memberships(TALLOC_CTX *mem_ctx, &alias_rids, &num_alias_rids))) { d_fprintf(stderr, "Could not list memberships for sid %s\n", sid_string_tos(member)); - return False; + return false; } for (i = 0; i < num_alias_rids; i++) { @@ -722,7 +722,7 @@ static bool print_alias_memberships(TALLOC_CTX *mem_ctx, printf("%s\n", sid_string_tos(&alias)); } - return True; + return true; } static int net_groupmap_memberships(struct net_context *c, int argc, const char **argv) @@ -758,7 +758,7 @@ static int net_groupmap_memberships(struct net_context *c, int argc, const char return 0; } -int net_help_groupmap(struct net_context *c, int argc, const char **argv) +int net_groupmap_usage(struct net_context *c, int argc, const char **argv) { d_printf("net groupmap add"\ "\n Create a new group mapping\n"); @@ -801,7 +801,7 @@ int net_groupmap(struct net_context *c, int argc, const char **argv) {"listmem", net_groupmap_listmem}, {"memberships", net_groupmap_memberships}, {"list", net_groupmap_list}, - {"help", net_help_groupmap}, + {"help", net_groupmap_usage}, {NULL, NULL} }; @@ -812,8 +812,8 @@ int net_groupmap(struct net_context *c, int argc, const char **argv) } if ( argc ) - return net_run_function(c, argc, argv, func, net_help_groupmap); + return net_run_function(c,argc, argv, func, net_groupmap_usage); - return net_help_groupmap(c, argc, argv ); + return net_groupmap_usage(c, argc, argv); } diff --git a/source3/utils/net_help.c b/source3/utils/net_help.c index 923475ffff..ddb8d76336 100644 --- a/source3/utils/net_help.c +++ b/source3/utils/net_help.c @@ -1,5 +1,5 @@ -/* - Samba Unix/Linux SMB client library +/* + Samba Unix/Linux SMB client library net help commands Copyright (C) 2002 Jim McDonough (jmcd@us.ibm.com) @@ -7,52 +7,20 @@ it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 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" -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"); - d_printf("\trpc\t\t\t\tDCE-RPC\n"); - d_printf("\trap\t\t\t\tRAP (older systems)\n"); - d_printf("\n"); - return 0; -} - -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"); - d_printf("\t-I or --ipaddress=<ipaddr>\taddress of target server\n"); - d_printf("\t-w or --workgroup=<wg>\t\ttarget workgroup or domain\n"); - - d_printf("\n"); - d_printf("Valid miscellaneous options are:\n"); /* misc options */ - d_printf("\t-p or --port=<port>\t\tconnection port on target\n"); - d_printf("\t-W or --myworkgroup=<wg>\tclient workgroup\n"); - d_printf("\t-d or --debuglevel=<level>\tdebug level (0-10)\n"); - d_printf("\t-n or --myname=<name>\t\tclient name\n"); - d_printf("\t-U or --user=<name>\t\tuser name\n"); - d_printf("\t-s or --configfile=<path>\tpathname of smb.conf file\n"); - d_printf("\t-l or --long\t\t\tDisplay full information\n"); - d_printf("\t-V or --version\t\t\tPrint samba version information\n"); - d_printf("\t-P or --machine-pass\t\tAuthenticate as machine account\n"); - d_printf("\t-e or --encrypt\t\tEncrypt SMB transport (UNIX extended servers only)\n"); - return -1; -} - -static int help_usage(struct net_context *c, int argc, const char **argv) +static int net_help_usage(struct net_context *c, int argc, const char **argv) { d_printf( "\n"\ @@ -65,158 +33,6 @@ static int help_usage(struct net_context *c, int argc, const char **argv) return -1; } -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"); - d_printf("net [<method>] user DELETE <name> [misc. options] [targets]"\ - "\n\tDelete specified user\n"); - d_printf("\nnet [<method>] user INFO <name> [misc. options] [targets]"\ - "\n\tList the domain groups of the specified user\n"); - d_printf("\nnet [<method>] user ADD <name> [password] [-c container] "\ - "[-F user flags] [misc. options]"\ - " [targets]\n\tAdd specified user\n"); - d_printf("\nnet [<method>] user RENAME <oldusername> <newusername>"\ - " [targets]\n\tRename specified user\n\n"); - - - 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(struct net_context *c, int argc, const char **argv) -{ - d_printf("net [<method>] group [misc. options] [targets]"\ - "\n\tList user groups\n\n"); - d_printf("net rpc group LIST [global|local|builtin]* [misc. options]"\ - "\n\tList specific user groups\n\n"); - d_printf("net [<method>] group DELETE <name> "\ - "[misc. options] [targets]"\ - "\n\tDelete specified group\n"); - d_printf("\nnet [<method>] group ADD <name> [-C comment] [-c container]"\ - " [misc. options] [targets]\n\tCreate specified group\n"); - 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(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(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(c, argc, argv); - return -1; -} - -int net_help_share(struct net_context *c, int argc, const char **argv) -{ - d_printf( - "\nnet [<method>] share [misc. options] [targets] \n" - "\tenumerates all exported resources (network shares) " - "on target server\n\n" - "net [<method>] share ADD <name=serverpath> [misc. options] [targets]" - "\n\tadds a share from a server (makes the export active)\n\n" - "net [<method>] share DELETE <sharename> [misc. options] [targets]" - "\n\tdeletes a share from a server (makes the export inactive)\n\n" - "net [<method>] share ALLOWEDUSERS [<filename>] " - "[misc. options] [targets]" - "\n\tshows a list of all shares together with all users allowed to" - "\n\taccess them. This needs the output of 'net usersidlist' on" - "\n\tstdin or in <filename>.\n\n" - "net [<method>] share MIGRATE FILES <sharename> [misc. options] [targets]" - "\n\tMigrates files from remote to local server\n\n" - "net [<method>] share MIGRATE SHARES <sharename> [misc. options] [targets]" - "\n\tMigrates shares from remote to local server\n\n" - "net [<method>] share MIGRATE SECURITY <sharename> [misc. options] [targets]" - "\n\tMigrates share-ACLs from remote to local server\n\n" - "net [<method>] share MIGRATE ALL <sharename> [misc. options] [targets]" - "\n\tMigrates shares (including directories, files) from remote\n" - "\tto local server\n\n" - ); - 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" - "\t --acls\t\t\tcopies ACLs as well\n" - "\t --attrs\t\t\tcopies DOS Attributes as well\n" - "\t --timestamps\t\tpreserve timestamps while copying files\n" - "\t --destination\t\tmigration target server (default: localhost)\n" - "\t-e or --exclude\t\t\tlist of shares to be excluded from mirroring\n" - "\t-v or --verbose\t\t\tgive verbose output\n"); - return -1; -} - -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"); - d_printf("net [<method>] file USER <username> "\ - "[misc. options] [targets]"\ - "\n\tlists all files opened by username on file server\n\n"); - d_printf("net [<method>] file CLOSE <id> [misc. options] [targets]\n"\ - "\tcloses specified file on target server\n\n"); - d_printf("net [rap] file INFO <id> [misc. options] [targets]\n"\ - "\tdisplays information about the specified open file\n"); - - net_common_methods_usage(c, argc, argv); - net_common_flags_usage(c, argc, argv); - return -1; -} - -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"); - d_printf("net rpc printer DRIVER [printer] [misc. options] [targets]\n"\ - "\tlists all printer-drivers on print-server\n\n"); - d_printf("net rpc printer PUBLISH action [printer] [misc. options] [targets]\n"\ - "\tpublishes printer settings in Active Directory\n" - "\taction can be one of PUBLISH, UPDATE, UNPUBLISH or LIST\n\n"); - d_printf("net rpc printer MIGRATE PRINTERS [printer] [misc. options] [targets]"\ - "\n\tmigrates printers from remote to local server\n\n"); - d_printf("net rpc printer MIGRATE SETTINGS [printer] [misc. options] [targets]"\ - "\n\tmigrates printer-settings from remote to local server\n\n"); - d_printf("net rpc printer MIGRATE DRIVERS [printer] [misc. options] [targets]"\ - "\n\tmigrates printer-drivers from remote to local server\n\n"); - d_printf("net rpc printer MIGRATE FORMS [printer] [misc. options] [targets]"\ - "\n\tmigrates printer-forms from remote to local server\n\n"); - d_printf("net rpc printer MIGRATE SECURITY [printer] [misc. options] [targets]"\ - "\n\tmigrates printer-ACLs from remote to local server\n\n"); - 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(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"); - - return -1; -} - - -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"); - d_printf(" net status shares [parseable] " - "Show list of open shares\n"); - return -1; -} - 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"\ @@ -253,21 +69,21 @@ static int net_usage(struct net_context *c, int argc, const char **argv) int net_help(struct net_context *c, int argc, const char **argv) { struct functable func[] = { - {"ADS", net_ads_help}, - {"RAP", net_rap_help}, - {"RPC", net_rpc_help}, + {"ADS", net_ads_usage}, + {"RAP", net_rap_usage}, + {"RPC", net_rpc_usage}, - {"FILE", net_help_file}, - {"SHARE", net_help_share}, + {"FILE", net_file_usage}, + {"SHARE", net_share_usage}, {"SESSION", net_rap_session_usage}, {"SERVER", net_rap_server_usage}, {"DOMAIN", net_rap_domain_usage}, {"PRINTQ", net_rap_printq_usage}, - {"USER", net_help_user}, - {"GROUP", net_help_group}, - {"GROUPMAP", net_help_groupmap}, - {"JOIN", net_help_join}, - {"DOM", net_help_dom}, + {"USER", net_user_usage}, + {"GROUP", net_group_usage}, + {"GROUPMAP", net_groupmap_usage}, + {"JOIN", net_join_usage}, + {"DOM", net_dom_usage}, {"VALIDATE", net_rap_validate_usage}, {"GROUPMEMBER", net_rap_groupmember_usage}, {"ADMIN", net_rap_admin_usage}, @@ -278,10 +94,10 @@ int net_help(struct net_context *c, int argc, const char **argv) {"USERSHARE", net_usershare_usage}, {"USERSIDLIST", net_usersidlist_usage}, #ifdef WITH_FAKE_KASERVER - {"AFS", net_help_afs}, + {"AFS", net_afs_usage}, #endif - {"HELP", help_usage}, + {"HELP", net_help_usage}, {NULL, NULL}}; return net_run_function(c, argc, argv, func, net_usage); diff --git a/source3/utils/net_help_common.c b/source3/utils/net_help_common.c new file mode 100644 index 0000000000..be06caa37e --- /dev/null +++ b/source3/utils/net_help_common.c @@ -0,0 +1,54 @@ +/* + Samba Unix/Linux SMB client library + net help commands + Copyright (C) 2002 Jim McDonough (jmcd@us.ibm.com) + + 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 + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + 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/>. +*/ + +#include "includes.h" +#include "utils/net.h" + +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"); + d_printf("\trpc\t\t\t\tDCE-RPC\n"); + d_printf("\trap\t\t\t\tRAP (older systems)\n"); + d_printf("\n"); + return 0; +} + +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"); + d_printf("\t-I or --ipaddress=<ipaddr>\taddress of target server\n"); + d_printf("\t-w or --workgroup=<wg>\t\ttarget workgroup or domain\n"); + + d_printf("\n"); + d_printf("Valid miscellaneous options are:\n"); /* misc options */ + d_printf("\t-p or --port=<port>\t\tconnection port on target\n"); + d_printf("\t-W or --myworkgroup=<wg>\tclient workgroup\n"); + d_printf("\t-d or --debuglevel=<level>\tdebug level (0-10)\n"); + d_printf("\t-n or --myname=<name>\t\tclient name\n"); + d_printf("\t-U or --user=<name>\t\tuser name\n"); + d_printf("\t-s or --configfile=<path>\tpathname of smb.conf file\n"); + d_printf("\t-l or --long\t\t\tDisplay full information\n"); + d_printf("\t-V or --version\t\t\tPrint samba version information\n"); + d_printf("\t-P or --machine-pass\t\tAuthenticate as machine account\n"); + d_printf("\t-e or --encrypt\t\tEncrypt SMB transport (UNIX extended servers only)\n"); + return -1; +} + diff --git a/source3/utils/net_help_common.h b/source3/utils/net_help_common.h new file mode 100644 index 0000000000..ed859936e4 --- /dev/null +++ b/source3/utils/net_help_common.h @@ -0,0 +1,49 @@ +/* + Samba Unix/Linux SMB client library + net help commands + Copyright (C) 2008 Kai Blin (kai@samba.org) + + 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 + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + 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/>. +*/ + +#ifndef _NET_HELP_COMMON_H_ +#define _NET_HELP_COMMON_H_ + +/** + * Get help for common methods. + * + * This will output some help for using the ADS/RPC/RAP transports. + * + * @param c A net_context structure + * @param argc Normal argc with previous parameters removed + * @param argv Normal argv with previous parameters removed + * @return 0 on success, nonzero on failure. + */ +int net_common_methods_usage(struct net_context *c, int argc, const char**argv); + +/** + * Get help for common flags. + * + * This will output some help for using common flags. + * + * @param c A net_context structure + * @param argc Normal argc with previous parameters removed + * @param argv Normal argv with previous parameters removed + * @return 0 on success, nonzero on failure. + */ +int net_common_flags_usage(struct net_context *c, int argc, const char **argv); + + +#endif /* _NET_HELP_COMMON_H_*/ + diff --git a/source3/utils/net_join.c b/source3/utils/net_join.c new file mode 100644 index 0000000000..98188aae5f --- /dev/null +++ b/source3/utils/net_join.c @@ -0,0 +1,54 @@ +/* + Samba Unix/Linux SMB client library + net join commands + Copyright (C) 2002 Jim McDonough (jmcd@us.ibm.com) + Copyright (C) 2008 Kai Blin (kai@samba.org) + + 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 + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + 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/>. +*/ + +#include "includes.h" +#include "utils/net.h" + +int net_join_usage(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(c, argc, argv); + return -1; +} + +int net_join(struct net_context *c, int argc, const char **argv) +{ + if (argc < 1) + return net_join_usage(c, argc, argv); + + if (StrCaseCmp(argv[0], "HELP") == 0) { + net_join_usage(c, argc, argv); + return 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(c, argc, argv); +} + + diff --git a/source3/utils/net_proto.h b/source3/utils/net_proto.h new file mode 100644 index 0000000000..7606ba7e08 --- /dev/null +++ b/source3/utils/net_proto.h @@ -0,0 +1,479 @@ +/* + * Unix SMB/CIFS implementation. + * collected prototypes header + * + * frozen from "make proto" in May 2008 + * + * Copyright (C) Michael Adam 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 + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * 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/>. + */ + +#ifndef _NET_PROTO_H_ +#define _NET_PROTO_H_ + + +/* The following definitions come from auth/token_util.c */ + +bool nt_token_check_sid ( const DOM_SID *sid, const NT_USER_TOKEN *token ); +bool nt_token_check_domain_rid( NT_USER_TOKEN *token, uint32 rid ); +NT_USER_TOKEN *get_root_nt_token( void ); +NTSTATUS add_aliases(const DOM_SID *domain_sid, + struct nt_user_token *token); +struct nt_user_token *create_local_nt_token(TALLOC_CTX *mem_ctx, + const DOM_SID *user_sid, + bool is_guest, + int num_groupsids, + const DOM_SID *groupsids); +void debug_nt_user_token(int dbg_class, int dbg_lev, NT_USER_TOKEN *token); +void debug_unix_user_token(int dbg_class, int dbg_lev, uid_t uid, gid_t gid, + int n_groups, gid_t *groups); + +/* The following definitions come from utils/net.c */ + +uint32 get_sec_channel_type(const char *param); +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 net_run_function2(struct net_context *c, int argc, const char **argv, + const char *whoami, struct functable2 *table); + +/* The following definitions come from utils/net_ads.c */ + +int net_ads_help(struct net_context *c, int argc, const char **argv); +ADS_STATUS ads_startup(struct net_context *c, bool only_own_domain, ADS_STRUCT **ads); +ADS_STATUS ads_startup_nobind(struct net_context *c, bool only_own_domain, ADS_STRUCT **ads); +int net_ads_check_our_domain(struct net_context *c); +int net_ads_check(struct net_context *c); +int net_ads_user(struct net_context *c, int argc, const char **argv); +int net_ads_group(struct net_context *c, int argc, const char **argv); +int net_ads_testjoin(struct net_context *c, int argc, const char **argv); +int net_ads_join(struct net_context *c, int argc, const char **argv); +int net_ads_printer_usage(struct net_context *c, int argc, const char **argv); +int net_ads_changetrustpw(struct net_context *c, int argc, const char **argv); +int net_ads_keytab(struct net_context *c, int argc, const char **argv); +int net_ads_kerberos(struct net_context *c, int argc, const char **argv); +int net_ads_usage(struct net_context *c, int argc, const char **argv); +int net_ads(struct net_context *c, int argc, const char **argv); + +/* The following definitions come from utils/net_ads_gpo.c */ + +int net_ads_gpo(struct net_context *c, int argc, const char **argv); + +/* The following definitions come from utils/net_cache.c */ + +int net_cache(struct net_context *c, int argc, const char **argv); + +/* The following definitions come from utils/net_conf.c */ + +int net_conf(struct net_context *c, int argc, const char **argv); + +/* The following definitions come from utils/net_dns.c */ + +int get_my_ip_address( struct sockaddr_storage **pp_ss ); + +/* The following definitions come from utils/net_dom.c */ + +int net_dom_usage(struct net_context *c, int argc, const char **argv); +int net_dom(struct net_context *c, int argc, const char **argv); + +/* The following definitions come from utils/net_file.c */ + +int net_file_usage(struct net_context *c, int argc, const char **argv); +int net_file(struct net_context *c, int argc, const char **argv); + +/* The following definitions come from utils/net_group.c */ + +int net_group_usage(struct net_context *c, int argc, const char **argv); +int net_group(struct net_context *c, int argc, const char **argv); + +/* The following definitions come from utils/net_groupmap.c */ + +int net_groupmap_usage(struct net_context *c, int argc, const char **argv); +int net_groupmap(struct net_context *c, int argc, const char **argv); + +/* The following definitions come from utils/net_help.c */ + +int net_help(struct net_context *c, int argc, const char **argv); + +/* The following definitions come from utils/net_idmap.c */ + +bool idmap_store_secret(const char *backend, bool alloc, + const char *domain, const char *identity, + const char *secret); +int net_help_idmap(struct net_context *c, int argc, const char **argv); +int net_idmap(struct net_context *c, int argc, const char **argv); + +/* The following definitions come from utils/net_join.c */ + +int net_join_usage(struct net_context *c, int argc, const char **argv); +int net_join(struct net_context *c, int argc, const char **argv); + +/* The following definitions come from utils/net_lookup.c */ + +int net_lookup_usage(struct net_context *c, int argc, const char **argv); +int net_lookup(struct net_context *c, int argc, const char **argv); + +/* The following definitions come from utils/net_rap.c */ + +int net_rap_file_usage(struct net_context *c, int argc, const char **argv); +int net_rap_file(struct net_context *c, int argc, const char **argv); +int net_rap_share_usage(struct net_context *c, int argc, const char **argv); +int net_rap_share(struct net_context *c, int argc, const char **argv); +int net_rap_session_usage(struct net_context *c, int argc, const char **argv); +int net_rap_session(struct net_context *c, int argc, const char **argv); +int net_rap_server_usage(struct net_context *c, int argc, const char **argv); +int net_rap_server(struct net_context *c, int argc, const char **argv); +int net_rap_domain_usage(struct net_context *c, int argc, const char **argv); +int net_rap_domain(struct net_context *c, int argc, const char **argv); +int net_rap_printq_usage(struct net_context *c, int argc, const char **argv); +int net_rap_printq(struct net_context *c, int argc, const char **argv); +int net_rap_user(struct net_context *c, int argc, const char **argv); +int net_rap_group_usage(struct net_context *c, int argc, const char **argv); +int net_rap_group(struct net_context *c, int argc, const char **argv); +int net_rap_groupmember_usage(struct net_context *c, int argc, const char **argv); +int net_rap_groupmember(struct net_context *c, int argc, const char **argv); +int net_rap_validate_usage(struct net_context *c, int argc, const char **argv); +int net_rap_validate(struct net_context *c, int argc, const char **argv); +int net_rap_service_usage(struct net_context *c, int argc, const char **argv); +int net_rap_service(struct net_context *c, int argc, const char **argv); +int net_rap_password_usage(struct net_context *c, int argc, const char **argv); +int net_rap_password(struct net_context *c, int argc, const char **argv); +int net_rap_admin_usage(struct net_context *c, int argc, const char **argv); +int net_rap_admin(struct net_context *c, int argc, const char **argv); +int net_rap_help(struct net_context *c, int argc, const char **argv); +int net_rap_usage(struct net_context *c, int argc, const char **argv); +int net_rap(struct net_context *c, int argc, const char **argv); + +/* The following definitions come from utils/net_registry.c */ + +int net_registry(struct net_context *c, int argc, const char **argv); + +/* The following definitions come from utils/net_rpc.c */ + +NTSTATUS net_get_remote_domain_sid(struct cli_state *cli, TALLOC_CTX *mem_ctx, + DOM_SID **domain_sid, + const char **domain_name); +int run_rpc_command(struct net_context *c, + struct cli_state *cli_arg, + const int pipe_idx, + int conn_flags, + rpc_command_fn fn, + int argc, + const char **argv); +int net_rpc_changetrustpw(struct net_context *c, int argc, const char **argv); +int net_rpc_join(struct net_context *c, int argc, const char **argv); +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, + TALLOC_CTX *mem_ctx, + int argc, + const char **argv); +int net_rpc_info(struct net_context *c, int argc, const char **argv); +int net_rpc_getsid(struct net_context *c, int argc, const char **argv); +int net_rpc_user(struct net_context *c, int argc, const char **argv); +struct rpc_sh_cmd *net_rpc_user_edit_cmds(struct net_context *c, + TALLOC_CTX *mem_ctx, + struct rpc_sh_ctx *ctx); +struct rpc_sh_cmd *net_rpc_user_cmds(struct net_context *c, + TALLOC_CTX *mem_ctx, + struct rpc_sh_ctx *ctx); +int net_rpc_group(struct net_context *c, int argc, const char **argv); +bool copy_top_level_perms(struct net_context *c, + struct copy_clistate *cp_clistate, + const char *sharename); +int net_usersidlist(struct net_context *c, int argc, const char **argv); +int net_usersidlist_usage(struct net_context *c, int argc, const char **argv); +int net_rpc_share(struct net_context *c, int argc, const char **argv); +struct rpc_sh_cmd *net_rpc_share_cmds(struct net_context *c, TALLOC_CTX *mem_ctx, + struct rpc_sh_ctx *ctx); +int net_rpc_file(struct net_context *c, int argc, const char **argv); +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, + TALLOC_CTX *mem_ctx, + int argc, + const char **argv); +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, + TALLOC_CTX *mem_ctx, + int argc, + const char **argv); +bool net_rpc_check(struct net_context *c, unsigned flags); +int rpc_printer_migrate(struct net_context *c, int argc, const char **argv); +int rpc_printer_usage(struct net_context *c, int argc, const char **argv); +int net_rpc_printer(struct net_context *c, int argc, const char **argv); +int net_rpc_help(struct net_context *c, int argc, const char **argv); +int net_rpc_usage(struct net_context *c, int argc, const char **argv); +int net_rpc(struct net_context *c, int argc, const char **argv); + +/* The following definitions come from utils/net_rpc_audit.c */ + +int net_rpc_audit(struct net_context *c, int argc, const char **argv); + +/* The following definitions come from utils/net_rpc_join.c */ + +NTSTATUS net_rpc_join_ok(struct net_context *c, const char *domain, + const char *server, struct sockaddr_storage *pss); +int net_rpc_join_newstyle(struct net_context *c, int argc, const char **argv); +int net_rpc_testjoin(struct net_context *c, int argc, const char **argv); + +/* The following definitions come from utils/net_rpc_printer.c */ + +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, + bool copy_acls, bool copy_attrs, + bool copy_timestamps, bool is_file); +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, + bool copy_acls, bool copy_attrs, + bool copy_timestamps, bool is_file); +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, + TALLOC_CTX *mem_ctx, + int argc, + const char **argv); +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, + TALLOC_CTX *mem_ctx, + int argc, + const char **argv); +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, + TALLOC_CTX *mem_ctx, + int argc, + const char **argv); +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, + TALLOC_CTX *mem_ctx, + int argc, + const char **argv); +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, + TALLOC_CTX *mem_ctx, + int argc, + const char **argv); +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, + TALLOC_CTX *mem_ctx, + int argc, + const char **argv); +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, + TALLOC_CTX *mem_ctx, + int argc, + const char **argv); +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, + TALLOC_CTX *mem_ctx, + int argc, + const char **argv); +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, + TALLOC_CTX *mem_ctx, + int argc, + const char **argv); +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, + TALLOC_CTX *mem_ctx, + int argc, + const char **argv); +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, + TALLOC_CTX *mem_ctx, + int argc, + const char **argv); + +/* The following definitions come from utils/net_rpc_registry.c */ + +int net_rpc_registry(struct net_context *c, int argc, const char **argv); + +/* The following definitions come from utils/net_rpc_rights.c */ + +int net_rpc_rights(struct net_context *c, int argc, const char **argv); +struct rpc_sh_cmd *net_rpc_rights_cmds(struct net_context *c, TALLOC_CTX *mem_ctx, + struct rpc_sh_ctx *ctx); + +/* The following definitions come from utils/net_rpc_samsync.c */ + +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, + TALLOC_CTX *mem_ctx, + int argc, + const char **argv); +int rpc_vampire_usage(struct net_context *c, int argc, const char **argv); +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, + TALLOC_CTX *mem_ctx, + int argc, + const char **argv); + +/* The following definitions come from utils/net_rpc_service.c */ + +const char *svc_status_string( uint32 state ); +int net_rpc_service(struct net_context *c, int argc, const char **argv); + +/* The following definitions come from utils/net_rpc_sh_acct.c */ + +struct rpc_sh_cmd *net_rpc_acct_cmds(struct net_context *c, TALLOC_CTX *mem_ctx, + struct rpc_sh_ctx *ctx); + +/* The following definitions come from utils/net_rpc_shell.c */ + +int net_rpc_shell(struct net_context *c, int argc, const char **argv); + +/* The following definitions come from utils/net_sam.c */ + +int net_sam(struct net_context *c, int argc, const char **argv); + +/* The following definitions come from utils/net_share.c */ + +int net_share_usage(struct net_context *c, int argc, const char **argv); +int net_share(struct net_context *c, int argc, const char **argv); + +/* The following definitions come from utils/net_status.c */ + +int net_status_usage(struct net_context *c, int argc, const char **argv); +int net_status(struct net_context *c, int argc, const char **argv); + +/* The following definitions come from utils/net_time.c */ + +int net_time_usage(struct net_context *c, int argc, const char **argv); +int net_time(struct net_context *c, int argc, const char **argv); + +/* The following definitions come from utils/net_user.c */ + +int net_user_usage(struct net_context *c, int argc, const char **argv); +int net_user(struct net_context *c, int argc, const char **argv); + +/* The following definitions come from utils/net_usershare.c */ + +int net_usershare_usage(struct net_context *c, int argc, const char **argv); +int net_usershare_help(struct net_context *c, int argc, const char **argv); +int net_usershare(struct net_context *c, int argc, const char **argv); + +/* The following definitions come from utils/net_util.c */ + +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); +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, + const char *service_type); +NTSTATUS connect_to_ipc(struct net_context *c, + struct cli_state **cli_ctx, + struct sockaddr_storage *server_ss, + const char *server_name); +NTSTATUS connect_to_ipc_anonymous(struct net_context *c, + struct cli_state **cli_ctx, + struct sockaddr_storage *server_ss, + const char *server_name); +NTSTATUS connect_to_ipc_krb5(struct net_context *c, + struct cli_state **cli_ctx, + struct sockaddr_storage *server_ss, + const char *server_name); +NTSTATUS connect_dst_pipe(struct net_context *c, struct cli_state **cli_dst, + struct rpc_pipe_client **pp_pipe_hnd, int pipe_num); +int net_use_krb_machine_account(struct net_context *c); +int net_use_machine_account(struct net_context *c); +bool net_find_server(struct net_context *c, + const char *domain, + unsigned flags, + struct sockaddr_storage *server_ss, + char **server_name); +bool net_find_pdc(struct sockaddr_storage *server_ss, + fstring server_name, + const char *domain_name); +NTSTATUS net_make_ipc_connection(struct net_context *c, 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); +const char *net_prompt_pass(struct net_context *c, const char *user); + +/* The following definitions come from utils/netlookup.c */ + +NTSTATUS net_lookup_name_from_sid(struct net_context *c, + TALLOC_CTX *ctx, + DOM_SID *psid, + const char **ppdomain, + const char **ppname); +NTSTATUS net_lookup_sid_from_name(struct net_context *c, TALLOC_CTX *ctx, + const char *full_name, DOM_SID *pret_sid); + +/* The following definitions come from utils/passwd_util.c */ + +char *stdin_new_passwd( void); +char *get_pass( const char *prompt, bool stdin_get); + +#endif /* _NET_PROTO_H_ */ diff --git a/source3/utils/net_rap.c b/source3/utils/net_rap.c index 552f0b667a..f50b579ac2 100644 --- a/source3/utils/net_rap.c +++ b/source3/utils/net_rap.c @@ -49,7 +49,7 @@ static int errmsg_not_implemented(void) int net_rap_file_usage(struct net_context *c, int argc, const char **argv) { - return net_help_file(c, argc, argv); + return net_file_usage(c, argc, argv); } /*************************************************************************** @@ -166,7 +166,7 @@ int net_rap_file(struct net_context *c, int argc, const char **argv) int net_rap_share_usage(struct net_context *c, int argc, const char **argv) { - return net_help_share(c, argc, argv); + return net_share_usage(c, argc, argv); } static void long_share_fn(const char *share_name, uint32 type, @@ -638,7 +638,7 @@ int net_rap_printq(struct net_context *c, int argc, const char **argv) static int net_rap_user_usage(struct net_context *c, int argc, const char **argv) { - return net_help_user(c, argc, argv); + return net_user_usage(c, argc, argv); } static void user_fn(const char *user_name, void *state) @@ -762,7 +762,7 @@ int net_rap_user(struct net_context *c, int argc, const char **argv) int net_rap_group_usage(struct net_context *c, int argc, const char **argv) { - return net_help_group(c, argc, argv); + return net_group_usage(c, argc, argv); } static void long_group_fn(const char *group_name, const char *comment, @@ -1039,7 +1039,7 @@ int net_rap_admin(struct net_context *c, int argc, const char **argv) /* The help subsystem for the RAP subcommand */ -int net_rap_usage(struct net_context *c, int argc, const char **argv) +int net_rap_help(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"\ @@ -1062,7 +1062,7 @@ int net_rap_usage(struct net_context *c, int argc, const char **argv) /* handle "net rap help *" subcommands */ -int net_rap_help(struct net_context *c, int argc, const char **argv) +int net_rap_usage(struct net_context *c, int argc, const char **argv) { struct functable func[] = { {"FILE", net_rap_file_usage}, @@ -1080,7 +1080,7 @@ int net_rap_help(struct net_context *c, int argc, const char **argv) {"PASSWORD", net_rap_password_usage}, {NULL, NULL}}; - return net_run_function(c, argc, argv, func, net_rap_usage); + return net_run_function(c, argc, argv, func, net_rap_help); } /* Entry-point for all the RAP functions. */ @@ -1101,10 +1101,10 @@ int net_rap(struct net_context *c, int argc, const char **argv) {"ADMIN", net_rap_admin}, {"SERVICE", net_rap_service}, {"PASSWORD", net_rap_password}, - {"HELP", net_rap_help}, + {"HELP", net_rap_usage}, {NULL, NULL} }; - return net_run_function(c, argc, argv, func, net_rap_usage); + return net_run_function(c, argc, argv, func, net_rap_help); } diff --git a/source3/utils/net_rpc.c b/source3/utils/net_rpc.c index 642a4baa45..3779611d01 100644 --- a/source3/utils/net_rpc.c +++ b/source3/utils/net_rpc.c @@ -65,7 +65,7 @@ NTSTATUS net_get_remote_domain_sid(struct cli_state *cli, TALLOC_CTX *mem_ctx, return result; } - result = rpccli_lsa_open_policy(lsa_pipe, mem_ctx, False, + result = rpccli_lsa_open_policy(lsa_pipe, mem_ctx, false, SEC_RIGHTS_MAXIMUM_ALLOWED, &pol); if (!NT_STATUS_IS_OK(result)) { @@ -571,7 +571,7 @@ int net_rpc_getsid(struct net_context *c, int argc, const char **argv) static int rpc_user_usage(struct net_context *c, int argc, const char **argv) { - return net_help_user(c, argc, argv); + return net_user_usage(c, argc, argv); } /** @@ -1586,7 +1586,7 @@ struct rpc_sh_cmd *net_rpc_user_cmds(struct net_context *c, static int rpc_group_usage(struct net_context *c, int argc, const char **argv) { - return net_help_group(c, argc, argv); + return net_group_usage(c, argc, argv); } /** @@ -1615,7 +1615,7 @@ static NTSTATUS rpc_group_delete_internals(struct net_context *c, const char **argv) { POLICY_HND connect_pol, domain_pol, group_pol, user_pol; - bool group_is_primary = False; + bool group_is_primary = false; NTSTATUS result = NT_STATUS_UNSUCCESSFUL; uint32_t group_rid; struct samr_RidTypeArray *rids = NULL; @@ -1727,7 +1727,7 @@ static NTSTATUS rpc_group_delete_internals(struct net_context *c, d_printf("Group is primary group of %s\n", info->info21.account_name.string); } - group_is_primary = True; + group_is_primary = true; } rpccli_samr_Close(pipe_hnd, mem_ctx, &user_pol); @@ -1978,7 +1978,7 @@ static NTSTATUS get_sid_from_name(struct cli_state *cli, goto done; } - result = rpccli_lsa_open_policy(pipe_hnd, mem_ctx, False, + result = rpccli_lsa_open_policy(pipe_hnd, mem_ctx, false, SEC_RIGHTS_MAXIMUM_ALLOWED, &lsa_pol); if (!NT_STATUS_IS_OK(result)) { @@ -2443,25 +2443,25 @@ static NTSTATUS rpc_group_list_internals(struct net_context *c, NTSTATUS result = NT_STATUS_UNSUCCESSFUL; uint32 start_idx=0, max_entries=250, num_entries, i, loop_count = 0; struct samr_SamArray *groups = NULL; - bool global = False; - bool local = False; - bool builtin = False; + bool global = false; + bool local = false; + bool builtin = false; if (argc == 0) { - global = True; - local = True; - builtin = True; + global = true; + local = true; + builtin = true; } for (i=0; i<argc; i++) { if (strequal(argv[i], "global")) - global = True; + global = true; if (strequal(argv[i], "local")) - local = True; + local = true; if (strequal(argv[i], "builtin")) - builtin = True; + builtin = true; } /* Get sam policy handle */ @@ -2774,7 +2774,7 @@ static NTSTATUS rpc_list_alias_members(struct net_context *c, return result; } - result = rpccli_lsa_open_policy(lsa_pipe, mem_ctx, True, + result = rpccli_lsa_open_policy(lsa_pipe, mem_ctx, true, SEC_RIGHTS_MAXIMUM_ALLOWED, &lsa_pol); if (!NT_STATUS_IS_OK(result)) { @@ -3059,7 +3059,7 @@ int net_rpc_group(struct net_context *c, int argc, const char **argv) static int rpc_share_usage(struct net_context *c, int argc, const char **argv) { - return net_help_share(c, argc, argv); + return net_share_usage(c, argc, argv); } /** @@ -3371,13 +3371,13 @@ static bool check_share_availability(struct cli_state *cli, const char *netname) { if (!cli_send_tconX(cli, netname, "A:", "", 0)) { d_printf("skipping [%s]: not a file share.\n", netname); - return False; + return false; } if (!cli_tdis(cli)) - return False; + return false; - return True; + return true; } static bool check_share_sanity(struct net_context *c, struct cli_state *cli, @@ -3386,18 +3386,18 @@ static bool check_share_sanity(struct net_context *c, struct cli_state *cli, /* only support disk shares */ if (! ( type == STYPE_DISKTREE || type == (STYPE_DISKTREE | STYPE_HIDDEN)) ) { printf("share [%s] is not a diskshare (type: %x)\n", netname, type); - return False; + return false; } /* skip builtin shares */ /* FIXME: should print$ be added too ? */ if (strequal(netname,"IPC$") || strequal(netname,"ADMIN$") || strequal(netname,"global")) - return False; + return false; - if (c->opt_exclude && in_list(netname, c->opt_exclude, False)) { + if (c->opt_exclude && in_list(netname, c->opt_exclude, false)) { printf("excluding [%s]\n", netname); - return False; + return false; } return check_share_availability(cli, netname); @@ -3644,16 +3644,16 @@ static bool sync_files(struct copy_clistate *cp_clistate, const char *mask) mask, &targetcli, &targetpath ) ) { d_fprintf(stderr, "cli_resolve_path %s failed with error: %s\n", mask, cli_errstr(cp_clistate->cli_share_src)); - return False; + return false; } if (cli_list(targetcli, targetpath, cp_clistate->attribute, copy_fn, cp_clistate) == -1) { d_fprintf(stderr, "listing %s failed with error: %s\n", mask, cli_errstr(targetcli)); - return False; + return false; } - return True; + return true; } @@ -3689,10 +3689,10 @@ bool copy_top_level_perms(struct net_context *c, if (!NT_STATUS_IS_OK(nt_status)) { printf("Could handle directory attributes for top level directory of share %s. Error %s\n", sharename, nt_errstr(nt_status)); - return False; + return false; } - return True; + return true; } /** @@ -3726,8 +3726,8 @@ static NTSTATUS rpc_share_migrate_files_internals(struct net_context *c, uint32 i; uint32 level = 502; struct copy_clistate cp_clistate; - bool got_src_share = False; - bool got_dst_share = False; + bool got_src_share = false; + bool got_dst_share = false; const char *mask = "\\*"; char *dst = NULL; @@ -3782,7 +3782,7 @@ static NTSTATUS rpc_share_migrate_files_internals(struct net_context *c, if (!NT_STATUS_IS_OK(nt_status)) goto done; - got_src_share = True; + got_src_share = true; if (net_mode_share == NET_MODE_SHARE_MIGRATE) { /* open share destination */ @@ -3791,7 +3791,7 @@ static NTSTATUS rpc_share_migrate_files_internals(struct net_context *c, if (!NT_STATUS_IS_OK(nt_status)) goto done; - got_dst_share = True; + got_dst_share = true; } if (!copy_top_level_perms(c, &cp_clistate, info502.name)) { @@ -4138,7 +4138,7 @@ static NTSTATUS rpc_aliaslist_dump(struct net_context *c, NTSTATUS result; POLICY_HND lsa_pol; - result = rpccli_lsa_open_policy(pipe_hnd, mem_ctx, True, + result = rpccli_lsa_open_policy(pipe_hnd, mem_ctx, true, SEC_RIGHTS_MAXIMUM_ALLOWED, &lsa_pol); if (!NT_STATUS_IS_OK(result)) @@ -4252,9 +4252,9 @@ static bool is_sid_in_token(NT_USER_TOKEN *token, DOM_SID *sid) for (i=0; i<token->num_sids; i++) { if (sid_compare(sid, &token->user_sids[i]) == 0) - return True; + return true; } - return False; + return false; } static void add_sid_to_token(NT_USER_TOKEN *token, DOM_SID *sid) @@ -4294,10 +4294,10 @@ static bool is_alias_member(DOM_SID *sid, struct full_alias *alias) for (i=0; i<alias->num_members; i++) { if (sid_compare(sid, &alias->members[i]) == 0) - return True; + return true; } - return False; + return false; } static void collect_sid_memberships(NT_USER_TOKEN *token, DOM_SID sid) @@ -4489,7 +4489,7 @@ static bool get_user_tokens_from_file(FILE *f, fstring line; if (fgets(line, sizeof(line)-1, f) == NULL) { - return True; + return true; } if (line[strlen(line)-1] == '\n') @@ -4503,7 +4503,7 @@ static bool get_user_tokens_from_file(FILE *f, if (token == NULL) { DEBUG(0, ("File does not begin with username")); - return False; + return false; } add_sid_to_token(&token->token, &sid); @@ -4516,7 +4516,7 @@ static bool get_user_tokens_from_file(FILE *f, *tokens = SMB_REALLOC_ARRAY(*tokens, struct user_token, *num_tokens); if (*tokens == NULL) { DEBUG(0, ("Could not realloc tokens\n")); - return False; + return false; } token = &((*tokens)[*num_tokens-1]); @@ -4527,7 +4527,7 @@ static bool get_user_tokens_from_file(FILE *f, continue; } - return False; + return false; } @@ -4968,7 +4968,7 @@ struct rpc_sh_cmd *net_rpc_share_cmds(struct net_context *c, TALLOC_CTX *mem_ctx static int rpc_file_usage(struct net_context *c, int argc, const char **argv) { - return net_help_file(c, argc, argv); + return net_file_usage(c, argc, argv); } /** @@ -5867,7 +5867,7 @@ static int rpc_trustdom_establish(struct net_context *c, int argc, return -1; } - nt_status = rpccli_lsa_open_policy2(pipe_hnd, mem_ctx, True, SEC_RIGHTS_QUERY_VALUE, + nt_status = rpccli_lsa_open_policy2(pipe_hnd, mem_ctx, true, SEC_RIGHTS_QUERY_VALUE, &connect_hnd); if (NT_STATUS_IS_ERR(nt_status)) { DEBUG(0, ("Couldn't open policy handle. Error was %s\n", @@ -6131,7 +6131,7 @@ static int rpc_trustdom_vampire(struct net_context *c, int argc, return -1; }; - nt_status = rpccli_lsa_open_policy2(pipe_hnd, mem_ctx, False, SEC_RIGHTS_QUERY_VALUE, + nt_status = rpccli_lsa_open_policy2(pipe_hnd, mem_ctx, false, SEC_RIGHTS_QUERY_VALUE, &connect_hnd); if (NT_STATUS_IS_ERR(nt_status)) { DEBUG(0, ("Couldn't open policy handle. Error was %s\n", @@ -6280,7 +6280,7 @@ static int rpc_trustdom_list(struct net_context *c, int argc, const char **argv) return -1; }; - nt_status = rpccli_lsa_open_policy2(pipe_hnd, mem_ctx, False, SEC_RIGHTS_QUERY_VALUE, + nt_status = rpccli_lsa_open_policy2(pipe_hnd, mem_ctx, false, SEC_RIGHTS_QUERY_VALUE, &connect_hnd); if (NT_STATUS_IS_ERR(nt_status)) { DEBUG(0, ("Couldn't open policy handle. Error was %s\n", @@ -6527,17 +6527,17 @@ static int rpc_trustdom(struct net_context *c, int argc, const char **argv) bool net_rpc_check(struct net_context *c, unsigned flags) { struct cli_state *cli; - bool ret = False; + bool ret = false; struct sockaddr_storage server_ss; char *server_name = NULL; NTSTATUS status; /* flags (i.e. server type) may depend on command */ if (!net_find_server(c, NULL, flags, &server_ss, &server_name)) - return False; + return false; if ((cli = cli_initialise()) == NULL) { - return False; + return false; } status = cli_connect(cli, server_name, &server_ss); @@ -6551,7 +6551,7 @@ bool net_rpc_check(struct net_context *c, unsigned flags) if (cli->protocol < PROTOCOL_NT1) goto done; - ret = True; + ret = true; done: cli_shutdown(cli); return ret; @@ -6925,7 +6925,33 @@ static int rpc_printer_publish(struct net_context *c, int argc, **/ int rpc_printer_usage(struct net_context *c, int argc, const char **argv) { - return net_help_printer(c, argc, argv); + d_printf("net rpc printer LIST [printer] [misc. options] [targets]\n"\ + "\tlists all printers on print-server\n\n"); + d_printf("net rpc printer DRIVER [printer] [misc. options] [targets]\n"\ + "\tlists all printer-drivers on print-server\n\n"); + d_printf("net rpc printer PUBLISH action [printer] [misc. options] [targets]\n"\ + "\tpublishes printer settings in Active Directory\n" + "\taction can be one of PUBLISH, UPDATE, UNPUBLISH or LIST\n\n"); + d_printf("net rpc printer MIGRATE PRINTERS [printer] [misc. options] [targets]"\ + "\n\tmigrates printers from remote to local server\n\n"); + d_printf("net rpc printer MIGRATE SETTINGS [printer] [misc. options] [targets]"\ + "\n\tmigrates printer-settings from remote to local server\n\n"); + d_printf("net rpc printer MIGRATE DRIVERS [printer] [misc. options] [targets]"\ + "\n\tmigrates printer-drivers from remote to local server\n\n"); + d_printf("net rpc printer MIGRATE FORMS [printer] [misc. options] [targets]"\ + "\n\tmigrates printer-forms from remote to local server\n\n"); + d_printf("net rpc printer MIGRATE SECURITY [printer] [misc. options] [targets]"\ + "\n\tmigrates printer-ACLs from remote to local server\n\n"); + 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(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"); + + return -1; } /** @@ -6958,7 +6984,7 @@ int net_rpc_printer(struct net_context *c, int argc, const char **argv) /** - * Basic usage function for 'net rpc' + * Basic help function for 'net rpc' * * @param c A net_context structure * @param argc Standard main() style argc @@ -6966,7 +6992,7 @@ int net_rpc_printer(struct net_context *c, int argc, const char **argv) * stripped **/ -int net_rpc_usage(struct net_context *c, int argc, const char **argv) +int net_rpc_help(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"); @@ -7010,7 +7036,7 @@ int net_rpc_usage(struct net_context *c, int argc, const char **argv) * stripped **/ -int net_rpc_help(struct net_context *c, int argc, const char **argv) +int net_rpc_usage(struct net_context *c, int argc, const char **argv) { struct functable func[] = { {"join", rpc_join_usage}, @@ -7022,15 +7048,16 @@ int net_rpc_help(struct net_context *c, int argc, const char **argv) /*{"abortshutdown", rpc_shutdown_abort_usage},*/ /*{"shutdown", rpc_shutdown_usage}, */ {"vampire", rpc_vampire_usage}, + {"help", net_rpc_help}, {NULL, NULL} }; if (argc == 0) { - net_rpc_usage(c, argc, argv); + net_rpc_help(c, argc, argv); return -1; } - return net_run_function(c, argc, argv, func, rpc_user_usage); + return net_run_function(c, argc, argv, func, net_rpc_help); } /** diff --git a/source3/utils/net_rpc_join.c b/source3/utils/net_rpc_join.c index 87a90550fa..b037e9c612 100644 --- a/source3/utils/net_rpc_join.c +++ b/source3/utils/net_rpc_join.c @@ -207,7 +207,7 @@ int net_rpc_join_newstyle(struct net_context *c, int argc, const char **argv) } - CHECK_RPC_ERR(rpccli_lsa_open_policy(pipe_hnd, mem_ctx, True, + CHECK_RPC_ERR(rpccli_lsa_open_policy(pipe_hnd, mem_ctx, true, SEC_RIGHTS_MAXIMUM_ALLOWED, &lsa_pol), "error opening lsa policy handle"); diff --git a/source3/utils/net_rpc_printer.c b/source3/utils/net_rpc_printer.c index 9fcbb2272c..fd938cbeaa 100644 --- a/source3/utils/net_rpc_printer.c +++ b/source3/utils/net_rpc_printer.c @@ -63,7 +63,7 @@ static void display_print_driver_3(DRIVER_INFO_3 *i1) fstring defaultdatatype = ""; int length=0; - bool valid = True; + bool valid = true; if (i1 == NULL) return; @@ -94,7 +94,7 @@ static void display_print_driver_3(DRIVER_INFO_3 *i1) if (strlen(dependentfiles) > 0) { d_printf ("\tDependentfiles: [%s]\n", dependentfiles); } else { - valid = False; + valid = false; } } @@ -621,7 +621,7 @@ static NTSTATUS copy_print_driver_3(struct net_context *c, { NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL; int length = 0; - bool valid = True; + bool valid = true; fstring name = ""; fstring driverpath = ""; @@ -677,7 +677,7 @@ static NTSTATUS copy_print_driver_3(struct net_context *c, if (!NT_STATUS_IS_OK(nt_status)) return nt_status; } else { - valid = False; + valid = false; } } @@ -712,10 +712,10 @@ static bool net_spoolss_enum_printers(struct rpc_pipe_client *pipe_hnd, if (!W_ERROR_IS_OK(result)) { printf("cannot enum printers: %s\n", dos_errstr(result)); - return False; + return false; } - return True; + return true; } static bool net_spoolss_open_printer_ex(struct rpc_pipe_client *pipe_hnd, @@ -747,19 +747,19 @@ static bool net_spoolss_open_printer_ex(struct rpc_pipe_client *pipe_hnd, if (W_ERROR_V(result) == W_ERROR_V(WERR_ACCESS_DENIED)) { d_fprintf(stderr, "no access to printer [%s] on [%s] for user [%s] granted\n", printername2, servername, username); - return False; + return false; } if (!W_ERROR_IS_OK(result)) { d_fprintf(stderr, "cannot open printer %s on server %s: %s\n", printername2, servername, dos_errstr(result)); - return False; + return false; } DEBUG(2,("got printer handle for printer: %s, server: %s\n", printername2, servername)); - return True; + return true; } static bool net_spoolss_getprinter(struct rpc_pipe_client *pipe_hnd, @@ -775,10 +775,10 @@ static bool net_spoolss_getprinter(struct rpc_pipe_client *pipe_hnd, if (!W_ERROR_IS_OK(result)) { printf("cannot get printer-info: %s\n", dos_errstr(result)); - return False; + return false; } - return True; + return true; } static bool net_spoolss_setprinter(struct rpc_pipe_client *pipe_hnd, @@ -794,10 +794,10 @@ static bool net_spoolss_setprinter(struct rpc_pipe_client *pipe_hnd, if (!W_ERROR_IS_OK(result)) { printf("cannot set printer-info: %s\n", dos_errstr(result)); - return False; + return false; } - return True; + return true; } @@ -813,10 +813,10 @@ static bool net_spoolss_setprinterdata(struct rpc_pipe_client *pipe_hnd, if (!W_ERROR_IS_OK(result)) { printf ("unable to set printerdata: %s\n", dos_errstr(result)); - return False; + return false; } - return True; + return true; } @@ -833,10 +833,10 @@ static bool net_spoolss_enumprinterkey(struct rpc_pipe_client *pipe_hnd, if (!W_ERROR_IS_OK(result)) { printf("enumprinterkey failed: %s\n", dos_errstr(result)); - return False; + return false; } - return True; + return true; } static bool net_spoolss_enumprinterdataex(struct rpc_pipe_client *pipe_hnd, @@ -853,10 +853,10 @@ static bool net_spoolss_enumprinterdataex(struct rpc_pipe_client *pipe_hnd, if (!W_ERROR_IS_OK(result)) { printf("enumprinterdataex failed: %s\n", dos_errstr(result)); - return False; + return false; } - return True; + return true; } @@ -874,10 +874,10 @@ static bool net_spoolss_setprinterdataex(struct rpc_pipe_client *pipe_hnd, if (!W_ERROR_IS_OK(result)) { printf("could not set printerdataex: %s\n", dos_errstr(result)); - return False; + return false; } - return True; + return true; } static bool net_spoolss_enumforms(struct rpc_pipe_client *pipe_hnd, @@ -894,10 +894,10 @@ static bool net_spoolss_enumforms(struct rpc_pipe_client *pipe_hnd, if (!W_ERROR_IS_OK(result)) { printf("could not enum forms: %s\n", dos_errstr(result)); - return False; + return false; } - return True; + return true; } static bool net_spoolss_enumprinterdrivers (struct rpc_pipe_client *pipe_hnd, @@ -915,10 +915,10 @@ static bool net_spoolss_enumprinterdrivers (struct rpc_pipe_client *pipe_hnd, if (!W_ERROR_IS_OK(result)) { printf("cannot enum drivers: %s\n", dos_errstr(result)); - return False; + return false; } - return True; + return true; } static bool net_spoolss_getprinterdriver(struct rpc_pipe_client *pipe_hnd, @@ -941,10 +941,10 @@ static bool net_spoolss_getprinterdriver(struct rpc_pipe_client *pipe_hnd, W_ERROR_V(result) != W_ERROR_V(WERR_INVALID_ENVIRONMENT)) { printf("cannot get driver: %s\n", dos_errstr(result)); } - return False; + return false; } - return True; + return true; } @@ -960,14 +960,14 @@ static bool net_spoolss_addprinterdriver(struct rpc_pipe_client *pipe_hnd, /* be more verbose */ if (W_ERROR_V(result) == W_ERROR_V(WERR_ACCESS_DENIED)) { printf("You are not allowed to add drivers\n"); - return False; + return false; } if (!W_ERROR_IS_OK(result)) { printf("cannot add driver: %s\n", dos_errstr(result)); - return False; + return false; } - return True; + return true; } /** @@ -992,7 +992,7 @@ static bool get_printer_info(struct rpc_pipe_client *pipe_hnd, if (!net_spoolss_enum_printers(pipe_hnd, mem_ctx, NULL, PRINTER_ENUM_LOCAL|PRINTER_ENUM_SHARED, level, num_printers, ctr)) - return False; + return false; goto out; } @@ -1003,11 +1003,11 @@ static bool get_printer_info(struct rpc_pipe_client *pipe_hnd, MAXIMUM_ALLOWED_ACCESS, pipe_hnd->auth->user_name, &hnd)) - return False; + return false; if (!net_spoolss_getprinter(pipe_hnd, mem_ctx, &hnd, level, ctr)) { rpccli_spoolss_close_printer(pipe_hnd, mem_ctx, &hnd); - return False; + return false; } rpccli_spoolss_close_printer(pipe_hnd, mem_ctx, &hnd); @@ -1017,7 +1017,7 @@ static bool get_printer_info(struct rpc_pipe_client *pipe_hnd, out: DEBUG(3,("got %d printers\n", *num_printers)); - return True; + return true; } @@ -1176,7 +1176,7 @@ static NTSTATUS rpc_printer_publish_internals_args(struct rpc_pipe_client *pipe_ char *printername, *sharename; PRINTER_INFO_CTR ctr, ctr_pub; POLICY_HND hnd; - bool got_hnd = False; + bool got_hnd = false; WERROR result; const char *action_str; @@ -1204,7 +1204,7 @@ static NTSTATUS rpc_printer_publish_internals_args(struct rpc_pipe_client *pipe_ PRINTER_ALL_ACCESS, pipe_hnd->auth->user_name, &hnd)) goto done; - got_hnd = True; + got_hnd = true; /* check for existing dst printer */ if (!net_spoolss_getprinter(pipe_hnd, mem_ctx, &hnd, level, &ctr_pub)) @@ -1316,7 +1316,7 @@ NTSTATUS rpc_printer_publish_list_internals(struct net_context *c, char *guid; PRINTER_INFO_CTR ctr, ctr_pub; POLICY_HND hnd; - bool got_hnd = False; + bool got_hnd = false; int state; if (!get_printer_info(pipe_hnd, mem_ctx, 2, argc, argv, &num_printers, &ctr)) @@ -1345,7 +1345,7 @@ NTSTATUS rpc_printer_publish_list_internals(struct net_context *c, PRINTER_ALL_ACCESS, cli->user_name, &hnd)) goto done; - got_hnd = True; + got_hnd = true; /* check for existing dst printer */ if (!net_spoolss_getprinter(pipe_hnd, mem_ctx, &hnd, level, &ctr_pub)) @@ -1422,8 +1422,8 @@ NTSTATUS rpc_printer_migrate_security_internals(struct net_context *c, uint32 num_printers; uint32 level = 2; char *printername, *sharename; - bool got_hnd_src = False; - bool got_hnd_dst = False; + bool got_hnd_src = false; + bool got_hnd_dst = false; struct rpc_pipe_client *pipe_hnd_dst = NULL; POLICY_HND hnd_src, hnd_dst; PRINTER_INFO_CTR ctr_src, ctr_dst, ctr_enum; @@ -1487,14 +1487,14 @@ NTSTATUS rpc_printer_migrate_security_internals(struct net_context *c, MAXIMUM_ALLOWED_ACCESS, cli->user_name, &hnd_src)) goto done; - got_hnd_src = True; + got_hnd_src = true; /* open dst printer handle */ if (!net_spoolss_open_printer_ex(pipe_hnd_dst, mem_ctx, sharename, PRINTER_ALL_ACCESS, cli_dst->user_name, &hnd_dst)) goto done; - got_hnd_dst = True; + got_hnd_dst = true; /* check for existing dst printer */ if (!net_spoolss_getprinter(pipe_hnd_dst, mem_ctx, &hnd_dst, level, &ctr_dst)) @@ -1522,12 +1522,12 @@ NTSTATUS rpc_printer_migrate_security_internals(struct net_context *c, /* close printer handles here */ if (got_hnd_src) { rpccli_spoolss_close_printer(pipe_hnd, mem_ctx, &hnd_src); - got_hnd_src = False; + got_hnd_src = false; } if (got_hnd_dst) { rpccli_spoolss_close_printer(pipe_hnd_dst, mem_ctx, &hnd_dst); - got_hnd_dst = False; + got_hnd_dst = false; } } @@ -1582,8 +1582,8 @@ NTSTATUS rpc_printer_migrate_forms_internals(struct net_context *c, uint32 num_printers; uint32 level = 1; char *printername, *sharename; - bool got_hnd_src = False; - bool got_hnd_dst = False; + bool got_hnd_src = false; + bool got_hnd_dst = false; struct rpc_pipe_client *pipe_hnd_dst = NULL; POLICY_HND hnd_src, hnd_dst; PRINTER_INFO_CTR ctr_enum, ctr_dst; @@ -1642,7 +1642,7 @@ NTSTATUS rpc_printer_migrate_forms_internals(struct net_context *c, MAXIMUM_ALLOWED_ACCESS, cli->user_name, &hnd_src)) goto done; - got_hnd_src = True; + got_hnd_src = true; /* open dst printer handle */ @@ -1650,7 +1650,7 @@ NTSTATUS rpc_printer_migrate_forms_internals(struct net_context *c, PRINTER_ALL_ACCESS, cli->user_name, &hnd_dst)) goto done; - got_hnd_dst = True; + got_hnd_dst = true; /* check for existing dst printer */ @@ -1710,12 +1710,12 @@ NTSTATUS rpc_printer_migrate_forms_internals(struct net_context *c, /* close printer handles here */ if (got_hnd_src) { rpccli_spoolss_close_printer(pipe_hnd, mem_ctx, &hnd_src); - got_hnd_src = False; + got_hnd_src = false; } if (got_hnd_dst) { rpccli_spoolss_close_printer(pipe_hnd_dst, mem_ctx, &hnd_dst); - got_hnd_dst = False; + got_hnd_dst = false; } } @@ -1766,10 +1766,10 @@ NTSTATUS rpc_printer_migrate_drivers_internals(struct net_context *c, uint32 num_printers; uint32 level = 3; char *printername, *sharename; - bool got_hnd_src = False; - bool got_hnd_dst = False; - bool got_src_driver_share = False; - bool got_dst_driver_share = False; + bool got_hnd_src = false; + bool got_hnd_dst = false; + bool got_src_driver_share = false; + bool got_dst_driver_share = false; struct rpc_pipe_client *pipe_hnd_dst = NULL; POLICY_HND hnd_src, hnd_dst; PRINTER_DRIVER_CTR drv_ctr_src, drv_ctr_dst; @@ -1796,7 +1796,7 @@ NTSTATUS rpc_printer_migrate_drivers_internals(struct net_context *c, if (!NT_STATUS_IS_OK(nt_status)) goto done; - got_src_driver_share = True; + got_src_driver_share = true; /* open print$-share on the dst server */ @@ -1805,7 +1805,7 @@ NTSTATUS rpc_printer_migrate_drivers_internals(struct net_context *c, if (!NT_STATUS_IS_OK(nt_status)) return nt_status; - got_dst_driver_share = True; + got_dst_driver_share = true; /* enum src printers */ @@ -1851,7 +1851,7 @@ NTSTATUS rpc_printer_migrate_drivers_internals(struct net_context *c, PRINTER_ALL_ACCESS, cli->user_name, &hnd_dst)) goto done; - got_hnd_dst = True; + got_hnd_dst = true; /* check for existing dst printer */ if (!net_spoolss_getprinter(pipe_hnd_dst, mem_ctx, &hnd_dst, 2, &info_ctr_dst)) @@ -1865,7 +1865,7 @@ NTSTATUS rpc_printer_migrate_drivers_internals(struct net_context *c, &hnd_src)) goto done; - got_hnd_src = True; + got_hnd_src = true; /* in a first step call getdriver for each shared printer (per arch) @@ -1931,13 +1931,13 @@ NTSTATUS rpc_printer_migrate_drivers_internals(struct net_context *c, /* close dst */ if (got_hnd_dst) { rpccli_spoolss_close_printer(pipe_hnd_dst, mem_ctx, &hnd_dst); - got_hnd_dst = False; + got_hnd_dst = false; } /* close src */ if (got_hnd_src) { rpccli_spoolss_close_printer(pipe_hnd, mem_ctx, &hnd_src); - got_hnd_src = False; + got_hnd_src = false; } } @@ -2000,8 +2000,8 @@ NTSTATUS rpc_printer_migrate_printers_internals(struct net_context *c, struct cli_state *cli_dst = NULL; POLICY_HND hnd_dst, hnd_src; char *printername, *sharename; - bool got_hnd_src = False; - bool got_hnd_dst = False; + bool got_hnd_src = false; + bool got_hnd_dst = false; struct rpc_pipe_client *pipe_hnd_dst = NULL; DEBUG(3,("copying printers\n")); @@ -2053,7 +2053,7 @@ NTSTATUS rpc_printer_migrate_printers_internals(struct net_context *c, DEBUG(1,("could not open printer: %s\n", sharename)); } else { - got_hnd_dst = True; + got_hnd_dst = true; } /* check for existing dst printer */ @@ -2064,7 +2064,7 @@ NTSTATUS rpc_printer_migrate_printers_internals(struct net_context *c, /* close printer handle here - dst only, not got src yet. */ if (got_hnd_dst) { rpccli_spoolss_close_printer(pipe_hnd_dst, mem_ctx, &hnd_dst); - got_hnd_dst = False; + got_hnd_dst = false; } continue; } @@ -2077,7 +2077,7 @@ NTSTATUS rpc_printer_migrate_printers_internals(struct net_context *c, MAXIMUM_ALLOWED_ACCESS, cli->user_name, &hnd_src)) goto done; - got_hnd_src = True; + got_hnd_src = true; /* getprinter on the src server */ if (!net_spoolss_getprinter(pipe_hnd, mem_ctx, &hnd_src, level, &ctr_src)) @@ -2100,12 +2100,12 @@ NTSTATUS rpc_printer_migrate_printers_internals(struct net_context *c, /* close printer handles here */ if (got_hnd_src) { rpccli_spoolss_close_printer(pipe_hnd, mem_ctx, &hnd_src); - got_hnd_src = False; + got_hnd_src = false; } if (got_hnd_dst) { rpccli_spoolss_close_printer(pipe_hnd_dst, mem_ctx, &hnd_dst); - got_hnd_dst = False; + got_hnd_dst = false; } } @@ -2160,8 +2160,8 @@ NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c, uint32 num_printers, val_needed, data_needed; uint32 level = 2; char *printername, *sharename; - bool got_hnd_src = False; - bool got_hnd_dst = False; + bool got_hnd_src = false; + bool got_hnd_dst = false; struct rpc_pipe_client *pipe_hnd_dst = NULL; POLICY_HND hnd_src, hnd_dst; PRINTER_INFO_CTR ctr_enum, ctr_dst, ctr_dst_publish; @@ -2231,7 +2231,7 @@ NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c, MAXIMUM_ALLOWED_ACCESS, cli->user_name, &hnd_src)) goto done; - got_hnd_src = True; + got_hnd_src = true; /* open dst printer handle */ @@ -2239,7 +2239,7 @@ NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c, PRINTER_ALL_ACCESS, cli_dst->user_name, &hnd_dst)) goto done; - got_hnd_dst = True; + got_hnd_dst = true; /* check for existing dst printer */ @@ -2267,7 +2267,7 @@ NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c, ctr_dst_publish.printers_7->action = SPOOL_DS_PUBLISH; - /* ignore False from setprinter due to WERR_IO_PENDING */ + /* ignore false from setprinter due to WERR_IO_PENDING */ net_spoolss_setprinter(pipe_hnd_dst, mem_ctx, &hnd_dst, 7, &ctr_dst_publish); DEBUG(3,("republished printer\n")); @@ -2482,12 +2482,12 @@ NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c, /* close printer handles here */ if (got_hnd_src) { rpccli_spoolss_close_printer(pipe_hnd, mem_ctx, &hnd_src); - got_hnd_src = False; + got_hnd_src = false; } if (got_hnd_dst) { rpccli_spoolss_close_printer(pipe_hnd_dst, mem_ctx, &hnd_dst); - got_hnd_dst = False; + got_hnd_dst = false; } } diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c index bc46fbb52e..accd731191 100644 --- a/source3/utils/net_rpc_registry.c +++ b/source3/utils/net_rpc_registry.c @@ -959,7 +959,7 @@ static bool dump_registry_tree( REGF_FILE *file, REGF_NK_REC *nk, const char *pa SAFE_FREE(regpath); } - return True; + return true; } /******************************************************************** @@ -977,13 +977,13 @@ static bool write_registry_tree( REGF_FILE *infile, REGF_NK_REC *nk, if ( !( subkeys = TALLOC_ZERO_P( infile->mem_ctx, REGSUBKEY_CTR )) ) { DEBUG(0,("write_registry_tree: talloc() failed!\n")); - return False; + return false; } if ( !(values = TALLOC_ZERO_P( subkeys, REGVAL_CTR )) ) { DEBUG(0,("write_registry_tree: talloc() failed!\n")); TALLOC_FREE(subkeys); - return False; + return false; } /* copy values into the REGVAL_CTR */ @@ -1021,7 +1021,7 @@ static bool write_registry_tree( REGF_FILE *infile, REGF_NK_REC *nk, d_printf("[%s]\n", path ); TALLOC_FREE(subkeys); - return True; + return true; } /******************************************************************** diff --git a/source3/utils/net_rpc_rights.c b/source3/utils/net_rpc_rights.c index 23ce467095..7a969a7a63 100644 --- a/source3/utils/net_rpc_rights.c +++ b/source3/utils/net_rpc_rights.c @@ -33,7 +33,7 @@ static NTSTATUS sid_to_name(struct rpc_pipe_client *pipe_hnd, NTSTATUS result; char **domains = NULL, **names = NULL; - result = rpccli_lsa_open_policy(pipe_hnd, mem_ctx, True, + result = rpccli_lsa_open_policy(pipe_hnd, mem_ctx, true, SEC_RIGHTS_MAXIMUM_ALLOWED, &pol); if ( !NT_STATUS_IS_OK(result) ) @@ -69,7 +69,7 @@ static NTSTATUS name_to_sid(struct rpc_pipe_client *pipe_hnd, return NT_STATUS_OK; } - result = rpccli_lsa_open_policy(pipe_hnd, mem_ctx, True, + result = rpccli_lsa_open_policy(pipe_hnd, mem_ctx, true, SEC_RIGHTS_MAXIMUM_ALLOWED, &pol); if ( !NT_STATUS_IS_OK(result) ) @@ -327,7 +327,7 @@ static NTSTATUS rpc_rights_list_internal(struct net_context *c, uint16 lang_id_sys = 0; uint16 lang_id_desc; - result = rpccli_lsa_open_policy(pipe_hnd, mem_ctx, True, + result = rpccli_lsa_open_policy(pipe_hnd, mem_ctx, true, SEC_RIGHTS_MAXIMUM_ALLOWED, &pol); if ( !NT_STATUS_IS_OK(result) ) @@ -452,7 +452,7 @@ static NTSTATUS rpc_rights_grant_internal(struct net_context *c, if (!NT_STATUS_IS_OK(result)) return result; - result = rpccli_lsa_open_policy2(pipe_hnd, mem_ctx, True, + result = rpccli_lsa_open_policy2(pipe_hnd, mem_ctx, true, SEC_RIGHTS_MAXIMUM_ALLOWED, &dom_pol); @@ -518,7 +518,7 @@ static NTSTATUS rpc_rights_revoke_internal(struct net_context *c, if (!NT_STATUS_IS_OK(result)) return result; - result = rpccli_lsa_open_policy2(pipe_hnd, mem_ctx, True, + result = rpccli_lsa_open_policy2(pipe_hnd, mem_ctx, true, SEC_RIGHTS_MAXIMUM_ALLOWED, &dom_pol); diff --git a/source3/utils/net_rpc_samsync.c b/source3/utils/net_rpc_samsync.c index bb09cc483b..bbba2c42e3 100644 --- a/source3/utils/net_rpc_samsync.c +++ b/source3/utils/net_rpc_samsync.c @@ -777,7 +777,7 @@ static NTSTATUS fetch_group_info(uint32_t rid, DOM_SID group_sid; fstring sid_string; GROUP_MAP map; - bool insert = True; + bool insert = true; fstrcpy(name, r->group_name.string); fstrcpy(comment, r->description.string); @@ -790,7 +790,7 @@ static NTSTATUS fetch_group_info(uint32_t rid, if (pdb_getgrsid(&map, group_sid)) { if ( map.gid != -1 ) grp = getgrgid(map.gid); - insert = False; + insert = false; } if (grp == NULL) { @@ -909,7 +909,7 @@ static NTSTATUS fetch_group_mem_info(uint32_t rid, unix_members = grp->gr_mem; while (*unix_members) { - bool is_nt_member = False; + bool is_nt_member = false; for (i=0; i < r->num_rids; i++) { if (nt_members[i] == NULL) { /* This was a primary group */ @@ -917,7 +917,7 @@ static NTSTATUS fetch_group_mem_info(uint32_t rid, } if (strcmp(*unix_members, nt_members[i]) == 0) { - is_nt_member = True; + is_nt_member = true; break; } } @@ -931,7 +931,7 @@ static NTSTATUS fetch_group_mem_info(uint32_t rid, } for (i=0; i < r->num_rids; i++) { - bool is_unix_member = False; + bool is_unix_member = false; if (nt_members[i] == NULL) { /* This was the primary group */ @@ -942,7 +942,7 @@ static NTSTATUS fetch_group_mem_info(uint32_t rid, while (*unix_members) { if (strcmp(*unix_members, nt_members[i]) == 0) { - is_unix_member = True; + is_unix_member = true; break; } unix_members += 1; @@ -970,7 +970,7 @@ static NTSTATUS fetch_alias_info(uint32_t rid, DOM_SID alias_sid; fstring sid_string; GROUP_MAP map; - bool insert = True; + bool insert = true; fstrcpy(name, r->alias_name.string); fstrcpy(comment, r->description.string); @@ -982,7 +982,7 @@ static NTSTATUS fetch_alias_info(uint32_t rid, if (pdb_getgrsid(&map, alias_sid)) { grp = getgrgid(map.gid); - insert = False; + insert = false; } if (grp == NULL) { @@ -1620,7 +1620,7 @@ static int fprintf_attr(FILE *add_fd, const char *attr_name, va_list ap; char *value, *p, *base64; DATA_BLOB base64_blob; - bool do_base64 = False; + bool do_base64 = false; int res; va_start(ap, fmt); @@ -1631,25 +1631,25 @@ static int fprintf_attr(FILE *add_fd, const char *attr_name, for (p=value; *p; p++) { if (*p & 0x80) { - do_base64 = True; + do_base64 = true; break; } } if (!do_base64) { - bool only_whitespace = True; + bool only_whitespace = true; for (p=value; *p; p++) { /* * I know that this not multibyte safe, but we break * on the first non-whitespace character anyway. */ if (!isspace(*p)) { - only_whitespace = False; + only_whitespace = false; break; } } if (only_whitespace) { - do_base64 = True; + do_base64 = true; } } diff --git a/source3/utils/net_rpc_shell.c b/source3/utils/net_rpc_shell.c index bfdfd4bf64..f2fa8b7e01 100644 --- a/source3/utils/net_rpc_shell.c +++ b/source3/utils/net_rpc_shell.c @@ -103,7 +103,7 @@ static bool net_sh_process(struct net_context *c, NTSTATUS status; if (argc == 0) { - return True; + return true; } if (ctx == this_ctx) { @@ -114,12 +114,12 @@ static bool net_sh_process(struct net_context *c, new_ctx = this_ctx->parent; TALLOC_FREE(this_ctx); this_ctx = new_ctx; - return True; + return true; } } if (strequal(argv[0], "exit") || strequal(argv[0], "quit")) { - return False; + return false; } if (strequal(argv[0], "help") || strequal(argv[0], "?")) { @@ -129,7 +129,7 @@ static bool net_sh_process(struct net_context *c, } d_printf("%-15s %s\n", cmd->name, cmd->help); } - return True; + return true; } for (cmd = ctx->cmds; cmd->name != NULL; cmd++) { @@ -141,13 +141,13 @@ static bool net_sh_process(struct net_context *c, if (cmd->name == NULL) { /* None found */ d_fprintf(stderr, "%s: unknown cmd\n", argv[0]); - return True; + return true; } new_ctx = TALLOC_P(ctx, struct rpc_sh_ctx); if (new_ctx == NULL) { d_fprintf(stderr, "talloc failed\n"); - return False; + return false; } new_ctx->cli = ctx->cli; new_ctx->whoami = talloc_asprintf(new_ctx, "%s %s", @@ -170,7 +170,7 @@ static bool net_sh_process(struct net_context *c, if (cmd->sub != NULL) { if (argc == 0) { this_ctx = new_ctx; - return True; + return true; } return net_sh_process(c, new_ctx, argc, argv); } @@ -182,7 +182,7 @@ static bool net_sh_process(struct net_context *c, nt_errstr(status)); } - return True; + return true; } static struct rpc_sh_cmd sh_cmds[6] = { @@ -268,7 +268,7 @@ int net_rpc_shell(struct net_context *c, int argc, const char **argv) d_fprintf(stderr, "cmdline invalid: %s\n", poptStrerror(ret)); SAFE_FREE(line); - return False; + return false; } if ((line[0] != '\n') && diff --git a/source3/utils/net_sam.c b/source3/utils/net_sam.c index 32656f0276..f603065f9c 100644 --- a/source3/utils/net_sam.c +++ b/source3/utils/net_sam.c @@ -1136,7 +1136,7 @@ static int net_sam_do_list(struct net_context *c, int argc, const char **argv, return -1; } - while (True) { + while (true) { struct samr_displayentry entry; if (!search->next_entry(search, &entry)) { break; @@ -1288,8 +1288,8 @@ static int net_sam_provision(struct net_context *c, int argc, const char **argv) goto failed; } - if (!lp_parm_bool(-1, "ldapsam", "trusted", False) || - !lp_parm_bool(-1, "ldapsam", "editposix", False)) { + if (!lp_parm_bool(-1, "ldapsam", "trusted", false) || + !lp_parm_bool(-1, "ldapsam", "editposix", false)) { d_fprintf(stderr, "Provisioning works only if ldapsam:trusted" " and ldapsam:editposix are enabled.\n"); diff --git a/source3/utils/net_share.c b/source3/utils/net_share.c new file mode 100644 index 0000000000..68fcd3b3bd --- /dev/null +++ b/source3/utils/net_share.c @@ -0,0 +1,77 @@ +/* + Samba Unix/Linux SMB client library + net share commands + Copyright (C) 2002 Andrew Tridgell (tridge@samba.org) + Copyright (C) 2008 Kai Blin (kai@samba.org) + + 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 + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + 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/>. +*/ + +#include "includes.h" +#include "utils/net.h" + +int net_share_usage(struct net_context *c, int argc, const char **argv) +{ + d_printf( + "\nnet [<method>] share [misc. options] [targets] \n" + "\tenumerates all exported resources (network shares) " + "on target server\n\n" + "net [<method>] share ADD <name=serverpath> [misc. options] [targets]" + "\n\tadds a share from a server (makes the export active)\n\n" + "net [<method>] share DELETE <sharename> [misc. options] [targets]" + "\n\tdeletes a share from a server (makes the export inactive)\n\n" + "net [<method>] share ALLOWEDUSERS [<filename>] " + "[misc. options] [targets]" + "\n\tshows a list of all shares together with all users allowed to" + "\n\taccess them. This needs the output of 'net usersidlist' on" + "\n\tstdin or in <filename>.\n\n" + "net [<method>] share MIGRATE FILES <sharename> [misc. options] [targets]" + "\n\tMigrates files from remote to local server\n\n" + "net [<method>] share MIGRATE SHARES <sharename> [misc. options] [targets]" + "\n\tMigrates shares from remote to local server\n\n" + "net [<method>] share MIGRATE SECURITY <sharename> [misc. options] [targets]" + "\n\tMigrates share-ACLs from remote to local server\n\n" + "net [<method>] share MIGRATE ALL <sharename> [misc. options] [targets]" + "\n\tMigrates shares (including directories, files) from remote\n" + "\tto local server\n\n" + ); + 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" + "\t --acls\t\t\tcopies ACLs as well\n" + "\t --attrs\t\t\tcopies DOS Attributes as well\n" + "\t --timestamps\t\tpreserve timestamps while copying files\n" + "\t --destination\t\tmigration target server (default: localhost)\n" + "\t-e or --exclude\t\t\tlist of shares to be excluded from mirroring\n" + "\t-v or --verbose\t\t\tgive verbose output\n"); + return -1; +} + +int net_share(struct net_context *c, int argc, const char **argv) +{ + if (argc < 1) + return net_share_usage(c, argc, argv); + + if (StrCaseCmp(argv[0], "HELP") == 0) { + net_share_usage(c, argc, argv); + return 0; + } + + if (net_rpc_check(c, 0)) + return net_rpc_share(c, argc, argv); + return net_rap_share(c, argc, argv); +} + diff --git a/source3/utils/net_status.c b/source3/utils/net_status.c index d4a95a7ca5..2835b2084d 100644 --- a/source3/utils/net_status.c +++ b/source3/utils/net_status.c @@ -19,6 +19,15 @@ #include "includes.h" #include "utils/net.h" +int net_status_usage(struct net_context *c, int argc, const char **argv) +{ + d_printf(" net status sessions [parseable] " + "Show list of open sessions\n"); + d_printf(" net status shares [parseable] " + "Show list of open shares\n"); + return -1; +} + static int show_session(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, void *state) { @@ -55,11 +64,11 @@ static int net_status_sessions(struct net_context *c, int argc, const char **arg bool parseable; if (argc == 0) { - parseable = False; + parseable = false; } else if ((argc == 1) && strequal(argv[0], "parseable")) { - parseable = True; + parseable = true; } else { - return net_help_status(c, argc, argv); + return net_status_usage(c, argc, argv); } if (!parseable) { @@ -140,7 +149,7 @@ static int show_share_parseable(struct db_record *rec, { struct sessionids *ids = (struct sessionids *)state; int i; - bool guest = True; + bool guest = true; if (crec->cnum == -1) return 0; @@ -152,7 +161,7 @@ static int show_share_parseable(struct db_record *rec, for (i=0; i<ids->num_entries; i++) { struct server_id id = ids->entries[i].pid; if (procid_equal(&id, &crec->pid)) { - guest = False; + guest = false; break; } } @@ -209,7 +218,7 @@ static int net_status_shares(struct net_context *c, int argc, const char **argv) } if ((argc != 1) || !strequal(argv[0], "parseable")) { - return net_help_status(c, argc, argv); + return net_status_usage(c, argc, argv); } return net_status_shares_parseable(c, argc, argv); @@ -220,7 +229,8 @@ int net_status(struct net_context *c, int argc, const char **argv) struct functable func[] = { {"sessions", net_status_sessions}, {"shares", net_status_shares}, + {"help", net_status_usage}, {NULL, NULL} }; - return net_run_function(c, argc, argv, func, net_help_status); + return net_run_function(c, argc, argv, func, net_status_usage); } diff --git a/source3/utils/net_user.c b/source3/utils/net_user.c new file mode 100644 index 0000000000..b98b6a13a7 --- /dev/null +++ b/source3/utils/net_user.c @@ -0,0 +1,67 @@ +/* + Samba Unix/Linux SMB client library + net user commands + Copyright (C) 2002 Jim McDonough (jmcd@us.ibm.com) + Copyright (C) 2002 Andrew Tridgell (tridge@samba.org) + Copyright (C) 2008 Kai Blin (kai@samba.org) + + 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 + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + 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/>. +*/ + +#include "includes.h" +#include "utils/net.h" + +int net_user_usage(struct net_context *c, int argc, const char **argv) +{ + d_printf("\nnet [<method>] user [misc. options] [targets]"\ + "\n\tList users\n\n"); + d_printf("net [<method>] user DELETE <name> [misc. options] [targets]"\ + "\n\tDelete specified user\n"); + d_printf("\nnet [<method>] user INFO <name> [misc. options] [targets]"\ + "\n\tList the domain groups of the specified user\n"); + d_printf("\nnet [<method>] user ADD <name> [password] [-c container] "\ + "[-F user flags] [misc. options]"\ + " [targets]\n\tAdd specified user\n"); + d_printf("\nnet [<method>] user RENAME <oldusername> <newusername>"\ + " [targets]\n\tRename specified user\n\n"); + + 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_user(struct net_context *c, int argc, const char **argv) +{ + if (argc < 1) + return net_user_usage(c, argc, argv); + + if (StrCaseCmp(argv[0], "HELP") == 0) { + net_user_usage(c, argc, argv); + return 0; + } + + 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(c, NET_FLAGS_PDC)) + return net_rpc_user(c, argc, argv); + + return net_rap_user(c, argc, argv); +} + diff --git a/source3/utils/net_usershare.c b/source3/utils/net_usershare.c index fe03cc615a..347107fb6e 100644 --- a/source3/utils/net_usershare.c +++ b/source3/utils/net_usershare.c @@ -328,7 +328,7 @@ static int info_fn(struct file_list *fl, void *priv) int num_aces; char sep_str[2]; enum usershare_err us_err; - bool guest_ok = False; + bool guest_ok = false; sep_str[0] = *lp_winbind_separator(); sep_str[1] = '\0'; @@ -479,7 +479,7 @@ static int info_fn(struct file_list *fl, void *priv) static int net_usershare_info(struct net_context *c, int argc, const char **argv) { fstring wcard; - bool only_ours = True; + bool only_ours = true; int ret = -1; struct us_priv_info pi; TALLOC_CTX *ctx; @@ -487,7 +487,7 @@ static int net_usershare_info(struct net_context *c, int argc, const char **argv fstrcpy(wcard, "*"); if (c->opt_long_list_entries) { - only_ours = False; + only_ours = false; } switch (argc) { @@ -606,7 +606,7 @@ static int net_usershare_add(struct net_context *c, int argc, const char **argv) const char *pacl; size_t to_write; uid_t myeuid = geteuid(); - bool guest_ok = False; + bool guest_ok = false; int num_usershares; us_comment = ""; @@ -647,11 +647,11 @@ static int net_usershare_add(struct net_context *c, int argc, const char **argv) switch (argv[4][9]) { case 'y': case 'Y': - guest_ok = True; + guest_ok = true; break; case 'n': case 'N': - guest_ok = False; + guest_ok = false; break; default: TALLOC_FREE(ctx); @@ -746,7 +746,7 @@ static int net_usershare_add(struct net_context *c, int argc, const char **argv) if ((myeuid != 0) && lp_usershare_owner_only() && (myeuid != sbuf.st_uid)) { d_fprintf(stderr, "net usershare add: cannot share path %s as " "we are restricted to only sharing directories we own.\n" - "\tAsk the administrator to add the line \"usershare owner only = False\" \n" + "\tAsk the administrator to add the line \"usershare owner only = false\" \n" "\tto the [global] section of the smb.conf to allow this.\n", us_path ); TALLOC_FREE(ctx); @@ -958,7 +958,7 @@ static int net_usershare_list(struct net_context *c, int argc, const char **argv) { fstring wcard; - bool only_ours = True; + bool only_ours = true; int ret = -1; struct us_priv_info pi; TALLOC_CTX *ctx; @@ -966,7 +966,7 @@ static int net_usershare_list(struct net_context *c, int argc, fstrcpy(wcard, "*"); if (c->opt_long_list_entries) { - only_ours = False; + only_ours = false; } switch (argc) { diff --git a/source3/utils/net_util.c b/source3/utils/net_util.c index db3e51b9b3..771c7e4f46 100644 --- a/source3/utils/net_util.c +++ b/source3/utils/net_util.c @@ -42,7 +42,7 @@ NTSTATUS net_rpc_lookup_name(struct net_context *c, return result; } - result = rpccli_lsa_open_policy(lsa_pipe, mem_ctx, False, + result = rpccli_lsa_open_policy(lsa_pipe, mem_ctx, false, SEC_RIGHTS_MAXIMUM_ALLOWED, &pol); if (!NT_STATUS_IS_OK(result)) { @@ -80,3 +80,469 @@ NTSTATUS net_rpc_lookup_name(struct net_context *c, return result; } + +/**************************************************************************** + Connect to \\server\service. +****************************************************************************/ + +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, + const char *service_type) +{ + NTSTATUS nt_status; + + 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(cli_ctx, NULL, server_name, + server_ss, c->opt_port, + service_name, service_type, + 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); + + /* Display a nicer message depending on the result */ + + if (NT_STATUS_V(nt_status) == + NT_STATUS_V(NT_STATUS_LOGON_FAILURE)) + d_fprintf(stderr, "The username or password was not correct.\n"); + + if (NT_STATUS_V(nt_status) == + NT_STATUS_V(NT_STATUS_ACCOUNT_LOCKED_OUT)) + d_fprintf(stderr, "The account was locked out.\n"); + + if (NT_STATUS_V(nt_status) == + NT_STATUS_V(NT_STATUS_ACCOUNT_DISABLED)) + d_fprintf(stderr, "The account was disabled.\n"); + return nt_status; + } + + 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 " + "server that doesn't support " + "UNIX extensions - failing connect\n"); + } else if (NT_STATUS_EQUAL(nt_status,NT_STATUS_UNKNOWN_REVISION)) { + d_printf("Encryption required and " + "can't get UNIX CIFS extensions " + "version from server.\n"); + } else if (NT_STATUS_EQUAL(nt_status,NT_STATUS_UNSUPPORTED_COMPRESSION)) { + d_printf("Encryption required and " + "share %s doesn't support " + "encryption.\n", service_name); + } else if (!NT_STATUS_IS_OK(nt_status)) { + d_printf("Encryption required and " + "setup failed with error %s.\n", + nt_errstr(nt_status)); + } + + if (!NT_STATUS_IS_OK(nt_status)) { + cli_shutdown(*cli_ctx); + *cli_ctx = NULL; + } + } + + return nt_status; +} + +/**************************************************************************** + Connect to \\server\ipc$. +****************************************************************************/ + +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, cli_ctx, server_ss, server_name, "IPC$", + "IPC"); +} + +/**************************************************************************** + Connect to \\server\ipc$ anonymously. +****************************************************************************/ + +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(cli_ctx, c->opt_requester_name, + server_name, server_ss, c->opt_port, + "IPC$", "IPC", + "", "", + "", 0, Undefined, NULL); + + if (NT_STATUS_IS_OK(nt_status)) { + return nt_status; + } else { + DEBUG(1,("Cannot connect to server (anonymously). Error was %s\n", nt_errstr(nt_status))); + return nt_status; + } +} + +/**************************************************************************** + Return malloced user@realm for krb5 login. +****************************************************************************/ + +static char *get_user_and_realm(const char *username) +{ + char *user_and_realm = NULL; + + if (!username) { + return NULL; + } + if (strchr_m(username, '@')) { + user_and_realm = SMB_STRDUP(username); + } else { + if (asprintf(&user_and_realm, "%s@%s", username, lp_realm()) == -1) { + user_and_realm = NULL; + } + } + return user_and_realm; +} + +/**************************************************************************** + Connect to \\server\ipc$ using KRB5. +****************************************************************************/ + +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; + + /* 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(c->opt_user_name); + if (!user_and_realm) { + return NT_STATUS_NO_MEMORY; + } + + nt_status = cli_full_connection(cli_ctx, NULL, server_name, + server_ss, c->opt_port, + "IPC$", "IPC", + user_and_realm, c->opt_workgroup, + c->opt_password, + CLI_FULL_CONNECTION_USE_KERBEROS, + Undefined, NULL); + + SAFE_FREE(user_and_realm); + + if (!NT_STATUS_IS_OK(nt_status)) { + DEBUG(1,("Cannot connect to server using kerberos. Error was %s\n", nt_errstr(nt_status))); + return nt_status; + } + + if (c->smb_encrypt) { + nt_status = cli_cm_force_encryption(*cli_ctx, + user_and_realm, + c->opt_password, + c->opt_workgroup, + "IPC$"); + if (!NT_STATUS_IS_OK(nt_status)) { + cli_shutdown(*cli_ctx); + *cli_ctx = NULL; + } + } + + return nt_status; +} + +/** + * Connect a server and open a given pipe + * + * @param cli_dst A cli_state + * @param pipe The pipe to open + * @param got_pipe boolean that stores if we got a pipe + * + * @return Normal NTSTATUS return. + **/ +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"); + struct cli_state *cli_tmp = NULL; + struct rpc_pipe_client *pipe_hnd = NULL; + + if (server_name == NULL) { + return NT_STATUS_NO_MEMORY; + } + + if (c->opt_destination) { + SAFE_FREE(server_name); + 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(c, &cli_tmp, NULL, server_name); + if (!NT_STATUS_IS_OK(nt_status)) { + SAFE_FREE(server_name); + return nt_status; + } + + pipe_hnd = cli_rpc_pipe_open_noauth(cli_tmp, pipe_num, &nt_status); + if (!pipe_hnd) { + DEBUG(0, ("couldn't not initialize pipe\n")); + cli_shutdown(cli_tmp); + SAFE_FREE(server_name); + return nt_status; + } + + *cli_dst = cli_tmp; + *pp_pipe_hnd = pipe_hnd; + SAFE_FREE(server_name); + + return nt_status; +} + +/**************************************************************************** + Use the local machine account (krb) and password for this session. +****************************************************************************/ + +int net_use_krb_machine_account(struct net_context *c) +{ + char *user_name = NULL; + + if (!secrets_init()) { + d_fprintf(stderr, "ERROR: Unable to open secrets database\n"); + exit(1); + } + + 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; + } + c->opt_user_name = user_name; + return 0; +} + +/**************************************************************************** + Use the machine account name and password for this session. +****************************************************************************/ + +int net_use_machine_account(struct net_context *c) +{ + char *user_name = NULL; + + if (!secrets_init()) { + d_fprintf(stderr, "ERROR: Unable to open secrets database\n"); + exit(1); + } + + c->opt_password = secrets_fetch_machine_password( + c->opt_target_workgroup, NULL, NULL); + if (asprintf(&user_name, "%s$", global_myname()) == -1) { + return -1; + } + c->opt_user_name = user_name; + return 0; +} + +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 : c->opt_target_workgroup; + + if (c->opt_host) { + *server_name = SMB_STRDUP(c->opt_host); + } + + if (c->opt_have_ip) { + *server_ss = c->opt_dest_ip; + if (!*server_name) { + char addr[INET6_ADDRSTRLEN]; + print_sockaddr(addr, sizeof(addr), &c->opt_dest_ip); + *server_name = SMB_STRDUP(addr); + } + } else if (*server_name) { + /* resolve the IP address */ + if (!resolve_name(*server_name, server_ss, 0x20)) { + DEBUG(1,("Unable to resolve server name\n")); + return false; + } + } else if (flags & NET_FLAGS_PDC) { + fstring dc_name; + struct sockaddr_storage pdc_ss; + + if (!get_pdc_ip(d, &pdc_ss)) { + DEBUG(1,("Unable to resolve PDC server address\n")); + return false; + } + + if (is_zero_addr(&pdc_ss)) { + return false; + } + + if (!name_status_find(d, 0x1b, 0x20, &pdc_ss, dc_name)) { + return false; + } + + *server_name = SMB_STRDUP(dc_name); + *server_ss = pdc_ss; + } else if (flags & NET_FLAGS_DMB) { + struct sockaddr_storage msbrow_ss; + char addr[INET6_ADDRSTRLEN]; + + /* if (!resolve_name(MSBROWSE, &msbrow_ip, 1)) */ + if (!resolve_name(d, &msbrow_ss, 0x1B)) { + DEBUG(1,("Unable to resolve domain browser via name lookup\n")); + return false; + } + *server_ss = msbrow_ss; + print_sockaddr(addr, sizeof(addr), server_ss); + *server_name = SMB_STRDUP(addr); + } else if (flags & NET_FLAGS_MASTER) { + struct sockaddr_storage brow_ss; + char addr[INET6_ADDRSTRLEN]; + if (!resolve_name(d, &brow_ss, 0x1D)) { + /* go looking for workgroups */ + DEBUG(1,("Unable to resolve master browser via name lookup\n")); + return false; + } + *server_ss = brow_ss; + print_sockaddr(addr, sizeof(addr), server_ss); + *server_name = SMB_STRDUP(addr); + } else if (!(flags & NET_FLAGS_LOCALHOST_DEFAULT_INSANE)) { + if (!interpret_string_addr(server_ss, + "127.0.0.1", AI_NUMERICHOST)) { + DEBUG(1,("Unable to resolve 127.0.0.1\n")); + return false; + } + *server_name = SMB_STRDUP("127.0.0.1"); + } + + if (!*server_name) { + DEBUG(1,("no server to connect to\n")); + return false; + } + + return true; +} + +bool net_find_pdc(struct sockaddr_storage *server_ss, + fstring server_name, + const char *domain_name) +{ + if (!get_pdc_ip(domain_name, server_ss)) { + return false; + } + if (is_zero_addr(server_ss)) { + return false; + } + + if (!name_status_find(domain_name, 0x1b, 0x20, server_ss, server_name)) { + return false; + } + + return true; +} + +NTSTATUS net_make_ipc_connection(struct net_context *c, unsigned flags, + struct cli_state **pcli) +{ + return net_make_ipc_connection_ex(c, NULL, NULL, NULL, flags, 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; + struct cli_state *cli = NULL; + NTSTATUS nt_status; + + if ( !server || !pss ) { + 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; + } + } else { + server_name = SMB_STRDUP( server ); + server_ss = *pss; + } + + if (flags & NET_FLAGS_ANONYMOUS) { + nt_status = connect_to_ipc_anonymous(c, &cli, &server_ss, + server_name); + } else { + nt_status = connect_to_ipc(c, &cli, &server_ss, + server_name); + } + + /* store the server in the affinity cache if it was a PDC */ + + if ( (flags & NET_FLAGS_PDC) && NT_STATUS_IS_OK(nt_status) ) + saf_store( cli->server_domain, cli->desthost ); + + SAFE_FREE(server_name); + if (!NT_STATUS_IS_OK(nt_status)) { + d_fprintf(stderr, "Connection failed: %s\n", + nt_errstr(nt_status)); + cli = NULL; + } + +done: + if (pcli != NULL) { + *pcli = cli; + } + return nt_status; +} + +/**************************************************************************** +****************************************************************************/ + +const char *net_prompt_pass(struct net_context *c, const char *user) +{ + char *prompt = NULL; + const char *pass = NULL; + + if (c->opt_password) { + return c->opt_password; + } + + if (c->opt_machine_pass) { + return NULL; + } + + asprintf(&prompt, "Enter %s's password:", user); + if (!prompt) { + return NULL; + } + + pass = getpass(prompt); + SAFE_FREE(prompt); + + return pass; +} + diff --git a/source3/utils/netlookup.c b/source3/utils/netlookup.c index 7d144cf624..844db51fc0 100644 --- a/source3/utils/netlookup.c +++ b/source3/utils/netlookup.c @@ -112,7 +112,7 @@ static struct con_struct *create_cs(struct net_context *c, if (!NT_STATUS_IS_OK(nt_status)) { DEBUG(2,("create_cs: Connect failed. Error was %s\n", nt_errstr(nt_status))); - cs->failed_connect = True; + cs->failed_connect = true; cs->err = nt_status; *perr = nt_status; return NULL; @@ -124,19 +124,19 @@ static struct con_struct *create_cs(struct net_context *c, if (cs->lsapipe == NULL) { DEBUG(2,("create_cs: open LSA pipe failed. Error was %s\n", nt_errstr(nt_status))); - cs->failed_connect = True; + cs->failed_connect = true; cs->err = nt_status; *perr = nt_status; return NULL; } - nt_status = rpccli_lsa_open_policy(cs->lsapipe, ctx, True, + nt_status = rpccli_lsa_open_policy(cs->lsapipe, ctx, true, SEC_RIGHTS_MAXIMUM_ALLOWED, &cs->pol); if (!NT_STATUS_IS_OK(nt_status)) { DEBUG(2,("create_cs: rpccli_lsa_open_policy failed. Error was %s\n", nt_errstr(nt_status))); - cs->failed_connect = True; + cs->failed_connect = true; cs->err = nt_status; *perr = nt_status; return NULL; diff --git a/source3/utils/ntlm_auth_diagnostics.c b/source3/utils/ntlm_auth_diagnostics.c index dfd05ad51c..dcdc8e9a40 100644 --- a/source3/utils/ntlm_auth_diagnostics.c +++ b/source3/utils/ntlm_auth_diagnostics.c @@ -445,6 +445,7 @@ static bool test_plaintext(enum ntlm_break break_which) DATA_BLOB lm_response = data_blob_null; char *password; smb_ucs2_t *nt_response_ucs2; + size_t converted_size; uchar user_session_key[16]; uchar lm_key[16]; @@ -457,7 +458,9 @@ static bool test_plaintext(enum ntlm_break break_which) flags |= WBFLAG_PAM_LMKEY; flags |= WBFLAG_PAM_USER_SESSION_KEY; - if ((push_ucs2_allocate(&nt_response_ucs2, opt_password)) == -1) { + if (!push_ucs2_allocate(&nt_response_ucs2, opt_password, + &converted_size)) + { DEBUG(0, ("push_ucs2_allocate failed!\n")); exit(1); } diff --git a/source3/utils/ntlm_auth_proto.h b/source3/utils/ntlm_auth_proto.h new file mode 100644 index 0000000000..e48a190ed6 --- /dev/null +++ b/source3/utils/ntlm_auth_proto.h @@ -0,0 +1,48 @@ +/* + * Unix SMB/CIFS implementation. + * collected prototypes header + * + * frozen from "make proto" in May 2008 + * + * Copyright (C) Michael Adam 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 + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * 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/>. + */ + +#ifndef _NTLM_AUTH_PROTO_H_ +#define _NTLM_AUTH_PROTO_H_ + + +/* The following definitions come from utils/ntlm_auth.c */ + +const char *get_winbind_domain(void); +const char *get_winbind_netbios_name(void); +DATA_BLOB get_challenge(void) ; +NTSTATUS contact_winbind_auth_crap(const char *username, + const char *domain, + const char *workstation, + const DATA_BLOB *challenge, + const DATA_BLOB *lm_response, + const DATA_BLOB *nt_response, + uint32 flags, + uint8 lm_key[8], + uint8 user_session_key[16], + char **error_string, + char **unix_name); + +/* The following definitions come from utils/ntlm_auth_diagnostics.c */ + +bool diagnose_ntlm_auth(void); + +#endif /* _NTLM_AUTH_PROTO_H_ */ diff --git a/source3/utils/passwd_proto.h b/source3/utils/passwd_proto.h new file mode 100644 index 0000000000..104e00a65c --- /dev/null +++ b/source3/utils/passwd_proto.h @@ -0,0 +1,32 @@ +/* + * Unix SMB/CIFS implementation. + * collected prototypes header + * + * frozen from "make proto" in May 2008 + * + * Copyright (C) Michael Adam 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 + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * 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/>. + */ + +#ifndef _PASSWD_PROTO_H_ +#define _PASSWD_PROTO_H_ + + +/* The following definitions come from utils/passwd_util.c */ + +char *stdin_new_passwd( void); +char *get_pass( const char *prompt, bool stdin_get); + +#endif /* _PASSWD_PROTO_H_ */ diff --git a/source3/utils/smbcontrol.c b/source3/utils/smbcontrol.c index db2eefe1e2..6699763cd2 100644 --- a/source3/utils/smbcontrol.c +++ b/source3/utils/smbcontrol.c @@ -865,13 +865,6 @@ static bool do_winbind_online(struct messaging_context *msg_ctx, return False; } - if (!lp_winbind_offline_logon()) { - fprintf(stderr, "The parameter \"winbind offline logon\" must " - "be set in the [global] section of smb.conf for this " - "command to be allowed.\n"); - return False; - } - /* Remove the entry in the winbindd_cache tdb to tell a later starting winbindd that we're online. */ @@ -901,13 +894,6 @@ static bool do_winbind_offline(struct messaging_context *msg_ctx, return False; } - if (!lp_winbind_offline_logon()) { - fprintf(stderr, "The parameter \"winbind offline logon\" must " - "be set in the [global] section of smb.conf for this " - "command to be allowed.\n"); - return False; - } - /* Create an entry in the winbindd_cache tdb to tell a later starting winbindd that we're offline. We may actually create it here... */ |