From 8de0c24a08cf71058dd58004fe82ca2e8368ffbc Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 18 Aug 2004 07:56:35 +0000 Subject: r1875: - move 'net' code into a subdir - and remove all unneeded files we'll reimplement the stuff step by step using the functions from libnet/ which will do the hard work for us metze (This used to be commit 8b2d5ec973fde980389bfe03cbcd70274b98b2dc) --- source4/utils/net/net.c | 642 ++++++++++++++++++++++++++++++++++++++++++++++++ source4/utils/net/net.h | 59 +++++ 2 files changed, 701 insertions(+) create mode 100644 source4/utils/net/net.c create mode 100644 source4/utils/net/net.h (limited to 'source4/utils/net') diff --git a/source4/utils/net/net.c b/source4/utils/net/net.c new file mode 100644 index 0000000000..6db62ea6b0 --- /dev/null +++ b/source4/utils/net/net.c @@ -0,0 +1,642 @@ +/* + Samba Unix/Linux SMB client library + Distributed SMB/CIFS Server Management Utility + Copyright (C) 2001 Steve French (sfrench@us.ibm.com) + Copyright (C) 2001 Jim McDonough (jmcd@us.ibm.com) + Copyright (C) 2001 Andrew Tridgell (tridge@samba.org) + Copyright (C) 2001 Andrew Bartlett (abartlet@samba.org) + + Originally written by Steve and Jim. Largely rewritten by tridge in + November 2001. + + Reworked again by abartlet in December 2001 + + 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 2 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, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +/*****************************************************/ +/* */ +/* Distributed SMB/CIFS Server Management Utility */ +/* */ +/* The intent was to make the syntax similar */ +/* to the NET utility (first developed in DOS */ +/* with additional interesting & useful functions */ +/* added in later SMB server network operating */ +/* systems). */ +/* */ +/*****************************************************/ + +#include "includes.h" +#include "../utils/net.h" + +/***********************************************************************/ +/* Beginning of internationalization section. Translatable constants */ +/* should be kept in this area and referenced in the rest of the code. */ +/* */ +/* No functions, outside of Samba or LSB (Linux Standards Base) should */ +/* be used (if possible). */ +/***********************************************************************/ + +#define YES_STRING "Yes" +#define NO_STRING "No" + +/************************************************************************************/ +/* end of internationalization section */ +/************************************************************************************/ + +/* Yes, these buggers are globals.... */ +const char *opt_requester_name = NULL; +const char *opt_host = NULL; +const char *opt_password = NULL; +const char *opt_user_name = NULL; +BOOL opt_user_specified = False; +const char *opt_workgroup = NULL; +int opt_long_list_entries = 0; +int opt_reboot = 0; +int opt_force = 0; +int opt_port = 0; +int opt_maxusers = -1; +const char *opt_comment = ""; +char *opt_container = "cn=Users"; +int opt_flags = -1; +int opt_jobid = 0; +int opt_timeout = 0; +const char *opt_target_workgroup = NULL; +static int opt_machine_pass = 0; + +BOOL opt_have_ip = False; +struct in_addr opt_dest_ip; + +extern BOOL AllowDebugChange; + +/* + run a function from a function table. If not found then + call the specified usage function +*/ +int net_run_function(int argc, const char **argv, struct functable *table, + int (*usage_fn)(int argc, const char **argv)) +{ + int i; + + if (argc < 1) { + d_printf("\nUsage: \n"); + return usage_fn(argc, argv); + } + for (i=0; table[i].funcname; i++) { + if (StrCaseCmp(argv[0], table[i].funcname) == 0) + return table[i].fn(argc-1, argv+1); + } + d_printf("No command: %s\n", argv[0]); + return usage_fn(argc, argv); +} + + +/**************************************************************************** +connect to \\server\ipc$ +****************************************************************************/ +NTSTATUS connect_to_ipc(struct smbcli_state **c, struct in_addr *server_ip, + const char *server_name) +{ + NTSTATUS nt_status; + + if (!opt_password) { + char *pass = getpass("Password:"); + if (pass) { + opt_password = strdup(pass); + } + } + + nt_status = smbcli_full_connection(c, opt_requester_name, server_name, + server_ip, opt_port, + "IPC$", "IPC", + opt_user_name, opt_workgroup, + opt_password, 0, NULL); + + if (NT_STATUS_IS_OK(nt_status)) { + return nt_status; + } else { + DEBUG(1,("Cannot connect to server. Error was %s\n", + nt_errstr(nt_status))); + + /* Display a nicer message depending on the result */ + + if (NT_STATUS_V(nt_status) == + NT_STATUS_V(NT_STATUS_LOGON_FAILURE)) + d_printf("The username or password was not correct.\n"); + + return nt_status; + } +} + +/**************************************************************************** +connect to \\server\ipc$ anonymously +****************************************************************************/ +NTSTATUS connect_to_ipc_anonymous(struct smbcli_state **c, + struct in_addr *server_ip, const char *server_name) +{ + NTSTATUS nt_status; + + nt_status = smbcli_full_connection(c, opt_requester_name, server_name, + server_ip, opt_port, + "IPC$", "IPC", + "", "", + "", 0, 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; + } +} + +BOOL net_find_server(uint_t flags, struct in_addr *server_ip, char **server_name) +{ + + if (opt_host) { + *server_name = strdup(opt_host); + } + + if (opt_have_ip) { + *server_ip = opt_dest_ip; + if (!*server_name) { + *server_name = strdup(inet_ntoa(opt_dest_ip)); + } + } else if (*server_name) { + /* resolve the IP address */ + if (!resolve_name(*server_name, server_ip, 0x20)) { + DEBUG(1,("Unable to resolve server name\n")); + return False; + } + } else if (flags & NET_FLAGS_PDC) { + struct in_addr pdc_ip; + + if (get_pdc_ip(opt_target_workgroup, &pdc_ip)) { + fstring dc_name; + + if (is_zero_ip(pdc_ip)) + return False; + + if (!lookup_dc_name(lp_netbios_name(), opt_target_workgroup, &pdc_ip, dc_name)) + return False; + + *server_name = strdup(dc_name); + *server_ip = pdc_ip; + } + + } else if (flags & NET_FLAGS_DMB) { + struct in_addr msbrow_ip; + /* if (!resolve_name(MSBROWSE, &msbrow_ip, 1)) */ + if (!resolve_name(opt_target_workgroup, &msbrow_ip, 0x1B)) { + DEBUG(1,("Unable to resolve domain browser via name lookup\n")); + return False; + } else { + *server_ip = msbrow_ip; + } + *server_name = strdup(inet_ntoa(opt_dest_ip)); + } else if (flags & NET_FLAGS_MASTER) { + struct in_addr brow_ips; + if (!resolve_name(opt_target_workgroup, &brow_ips, 0x1D)) { + /* go looking for workgroups */ + DEBUG(1,("Unable to resolve master browser via name lookup\n")); + return False; + } else { + *server_ip = brow_ips; + } + *server_name = strdup(inet_ntoa(opt_dest_ip)); + } else if (!(flags & NET_FLAGS_LOCALHOST_DEFAULT_INSANE)) { + extern struct in_addr loopback_ip; + *server_ip = loopback_ip; + *server_name = strdup("127.0.0.1"); + } + + if (!server_name || !*server_name) { + DEBUG(1,("no server to connect to\n")); + return False; + } + + return True; +} + + +BOOL net_find_dc(struct in_addr *server_ip, fstring server_name, const char *domain_name) +{ + if (get_pdc_ip(domain_name, server_ip)) { + fstring dc_name; + + if (is_zero_ip(*server_ip)) + return False; + + if (!lookup_dc_name(lp_netbios_name(), domain_name, server_ip, dc_name)) + return False; + + safe_strcpy(server_name, dc_name, FSTRING_LEN); + return True; + } else + return False; +} + + +struct smbcli_state *net_make_ipc_connection(uint_t flags) +{ + char *server_name = NULL; + struct in_addr server_ip; + struct smbcli_state *cli = NULL; + NTSTATUS nt_status; + + if (!net_find_server(flags, &server_ip, &server_name)) { + d_printf("\nUnable to find a suitable server\n"); + return NULL; + } + + if (flags & NET_FLAGS_ANONYMOUS) { + nt_status = connect_to_ipc_anonymous(&cli, &server_ip, server_name); + } else { + nt_status = connect_to_ipc(&cli, &server_ip, server_name); + } + + SAFE_FREE(server_name); + if (NT_STATUS_IS_OK(nt_status)) { + return cli; + } else { + return NULL; + } +} + +static int net_user(int argc, const char **argv) +{ + if (net_ads_check() == 0) + return net_ads_user(argc, argv); + + /* if server is not specified, default to PDC? */ + if (net_rpc_check(NET_FLAGS_PDC)) + return net_rpc_user(argc, argv); + + return net_rap_user(argc, argv); +} + +static int net_group(int argc, const char **argv) +{ + if (net_ads_check() == 0) + return net_ads_group(argc, argv); + + if (argc == 0 && net_rpc_check(NET_FLAGS_PDC)) + return net_rpc_group(argc, argv); + + return net_rap_group(argc, argv); +} + +static int net_join(int argc, const char **argv) +{ + if (net_ads_check() == 0) { + if (net_ads_join(argc, argv) == 0) + return 0; + else + d_printf("ADS join did not work, trying RPC...\n"); + } + return net_rpc_join(argc, argv); +} + +static int net_share(int argc, const char **argv) +{ + if (net_rpc_check(0)) + return net_rpc_share(argc, argv); + return net_rap_share(argc, argv); +} + +static int net_file(int argc, const char **argv) +{ + if (net_rpc_check(0)) + return net_rpc_file(argc, argv); + return net_rap_file(argc, argv); +} + +/* + Retrieve our local SID or the SID for the specified name + */ +static int net_getlocalsid(int argc, const char **argv) +{ + DOM_SID sid; + const char *name; + fstring sid_str; + + if (argc >= 1) { + name = argv[0]; + } + else { + name = lp_netbios_name(); + } + + if (!secrets_fetch_domain_sid(name, &sid)) { + DEBUG(0, ("Can't fetch domain SID for name: %s\n", name)); + return 1; + } + sid_to_string(sid_str, &sid); + d_printf("SID for domain %s is: %s\n", name, sid_str); + return 0; +} + +static int net_setlocalsid(int argc, const char **argv) +{ + DOM_SID sid; + + if ( (argc != 1) + || (strncmp(argv[0], "S-1-5-21-", strlen("S-1-5-21-")) != 0) + || (!string_to_sid(&sid, argv[0])) + || (sid.num_auths != 4)) { + d_printf("usage: net setlocalsid S-1-5-21-x-y-z\n"); + return 1; + } + + if (!secrets_store_domain_sid(lp_netbios_name(), &sid)) { + DEBUG(0,("Can't store domain SID as a pdc/bdc.\n")); + return 1; + } + + return 0; +} + +static int net_getdomainsid(int argc, const char **argv) +{ + DOM_SID domain_sid; + fstring sid_str; + + if (!secrets_fetch_domain_sid(lp_netbios_name(), &domain_sid)) { + d_printf("Could not fetch local SID\n"); + return 1; + } + sid_to_string(sid_str, &domain_sid); + d_printf("SID for domain %s is: %s\n", lp_netbios_name(), sid_str); + + if (!secrets_fetch_domain_sid(lp_workgroup(), &domain_sid)) { + d_printf("Could not fetch domain SID\n"); + return 1; + } + + sid_to_string(sid_str, &domain_sid); + d_printf("SID for domain %s is: %s\n", lp_workgroup(), sid_str); + + return 0; +} + +static uint32_t get_maxrid(void) +{ + SAM_ACCOUNT *pwd = NULL; + uint32_t max_rid = 0; + GROUP_MAP *map = NULL; + int num_entries = 0; + int i; + + if (!pdb_setsampwent(False)) { + DEBUG(0, ("load_sampwd_entries: Unable to open passdb.\n")); + return 0; + } + + for (; (NT_STATUS_IS_OK(pdb_init_sam(&pwd))) + && pdb_getsampwent(pwd) == True; pwd=NULL) { + uint32_t rid; + + if (!sid_peek_rid(pdb_get_user_sid(pwd), &rid)) { + DEBUG(0, ("can't get RID for user '%s'\n", + pdb_get_username(pwd))); + pdb_free_sam(&pwd); + continue; + } + + if (rid > max_rid) + max_rid = rid; + + DEBUG(1,("%d is user '%s'\n", rid, pdb_get_username(pwd))); + pdb_free_sam(&pwd); + } + + pdb_endsampwent(); + pdb_free_sam(&pwd); + + if (!pdb_enum_group_mapping(SID_NAME_UNKNOWN, &map, &num_entries, + ENUM_ONLY_MAPPED, MAPPING_WITHOUT_PRIV)) + return max_rid; + + for (i = 0; i < num_entries; i++) { + uint32_t rid; + + if (!sid_peek_check_rid(get_global_sam_sid(), &map[i].sid, + &rid)) { + DEBUG(3, ("skipping map for group '%s', SID %s\n", + map[i].nt_name, + sid_string_static(&map[i].sid))); + continue; + } + DEBUG(1,("%d is group '%s'\n", rid, map[i].nt_name)); + + if (rid > max_rid) + max_rid = rid; + } + + SAFE_FREE(map); + + return max_rid; +} + +static int net_maxrid(int argc, const char **argv) +{ + uint32_t rid; + + if (argc != 0) { + DEBUG(0, ("usage: net initrid\n")); + return 1; + } + + if ((rid = get_maxrid()) == 0) { + DEBUG(0, ("can't get current maximum rid\n")); + return 1; + } + + d_printf("Currently used maximum rid: %d\n", rid); + + return 0; +} + +/* main function table */ +static struct functable net_func[] = { + {"RPC", net_rpc}, + {"RAP", net_rap}, + {"ADS", net_ads}, + + /* eventually these should auto-choose the transport ... */ + {"FILE", net_file}, + {"SHARE", net_share}, + {"SESSION", net_rap_session}, + {"SERVER", net_rap_server}, + {"DOMAIN", net_rap_domain}, + {"PRINTQ", net_rap_printq}, + {"USER", net_user}, + {"GROUP", net_group}, + {"VALIDATE", net_rap_validate}, + {"GROUPMEMBER", net_rap_groupmember}, + {"ADMIN", net_rap_admin}, + {"SERVICE", net_rap_service}, + {"PASSWORD", net_rap_password}, + {"TIME", net_time}, + {"LOOKUP", net_lookup}, + {"JOIN", net_join}, + {"CACHE", net_cache}, + {"GETLOCALSID", net_getlocalsid}, + {"SETLOCALSID", net_setlocalsid}, + {"GETDOMAINSID", net_getdomainsid}, + {"MAXRID", net_maxrid}, + + {"HELP", net_help}, + {NULL, NULL} +}; + + +/**************************************************************************** + main program +****************************************************************************/ + int main(int argc, const char **argv) +{ + int opt,i; + char *p; + int rc = 0; + int argc_new = 0; + const char ** argv_new; + poptContext pc; + static char *servicesf = dyn_CONFIGFILE; + static char *debuglevel = NULL; + + struct poptOption long_options[] = { + {"help", 'h', POPT_ARG_NONE, 0, 'h'}, + {"workgroup", 'w', POPT_ARG_STRING, &opt_target_workgroup}, + {"myworkgroup", 'W', POPT_ARG_STRING, &opt_workgroup}, + {"user", 'U', POPT_ARG_STRING, &opt_user_name, 'U'}, + {"ipaddress", 'I', POPT_ARG_STRING, 0,'I'}, + {"port", 'p', POPT_ARG_INT, &opt_port}, + {"myname", 'n', POPT_ARG_STRING, &opt_requester_name}, + {"conf", 's', POPT_ARG_STRING, &servicesf}, + {"server", 'S', POPT_ARG_STRING, &opt_host}, + {"container", 'c', POPT_ARG_STRING, &opt_container}, + {"comment", 'C', POPT_ARG_STRING, &opt_comment}, + {"maxusers", 'M', POPT_ARG_INT, &opt_maxusers}, + {"flags", 'F', POPT_ARG_INT, &opt_flags}, + {"jobid", 'j', POPT_ARG_INT, &opt_jobid}, + {"long", 'l', POPT_ARG_NONE, &opt_long_list_entries}, + {"reboot", 'r', POPT_ARG_NONE, &opt_reboot}, + {"force", 'f', POPT_ARG_NONE, &opt_force}, + {"timeout", 't', POPT_ARG_INT, &opt_timeout}, + {"machine-pass",'P', POPT_ARG_NONE, &opt_machine_pass}, + {"debuglevel", 'd', POPT_ARG_STRING, &debuglevel}, + {NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_version}, + { 0, 0, 0, 0} + }; + + zero_ip(&opt_dest_ip); + + dbf = x_stderr; + + pc = poptGetContext(NULL, argc, (const char **) argv, long_options, + POPT_CONTEXT_KEEP_FIRST); + + while((opt = poptGetNextOpt(pc)) != -1) { + switch (opt) { + case 'h': + net_help(argc, argv); + exit(0); + break; + case 'I': + opt_dest_ip = *interpret_addr2(poptGetOptArg(pc)); + if (is_zero_ip(opt_dest_ip)) + d_printf("\nInvalid ip address specified\n"); + else + opt_have_ip = True; + break; + case 'U': + opt_user_specified = True; + opt_user_name = strdup(opt_user_name); + p = strchr(opt_user_name,'%'); + if (p) { + *p = 0; + opt_password = p+1; + } + break; + default: + d_printf("\nInvalid option %s: %s\n", + poptBadOption(pc, 0), poptStrerror(opt)); + net_help(argc, argv); + exit(1); + } + } + + if (debuglevel) { + debug_parse_levels(debuglevel); + AllowDebugChange = False; + } + + lp_load(servicesf,True,False,False); + + argv_new = (const char **)poptGetArgs(pc); + + argc_new = argc; + for (i=0; i Date: Wed, 18 Aug 2004 09:33:54 +0000 Subject: r1876: rewrite net command completely and add it to the build metze (This used to be commit 14b9858800f6944bf78bee34338242cd3292b297) --- source4/utils/net/config.m4 | 3 + source4/utils/net/config.mk | 15 ++ source4/utils/net/net.c | 606 ++++++-------------------------------------- source4/utils/net/net.h | 52 +--- 4 files changed, 109 insertions(+), 567 deletions(-) create mode 100644 source4/utils/net/config.m4 create mode 100644 source4/utils/net/config.mk (limited to 'source4/utils/net') diff --git a/source4/utils/net/config.m4 b/source4/utils/net/config.m4 new file mode 100644 index 0000000000..a3e773c68d --- /dev/null +++ b/source4/utils/net/config.m4 @@ -0,0 +1,3 @@ +dnl # utils subsystem + +SMB_BINARY_MK(net, utils/net/config.mk) diff --git a/source4/utils/net/config.mk b/source4/utils/net/config.mk new file mode 100644 index 0000000000..8593aaec65 --- /dev/null +++ b/source4/utils/net/config.mk @@ -0,0 +1,15 @@ +# utils/net subsystem + +################################# +# Start BINARY net +[BINARY::net] +OBJ_FILES = \ + utils/net/net.o +REQUIRED_SUBSYSTEMS = \ + CONFIG \ + LIBCMDLINE \ + LIBBASIC \ + LIBSMB \ + LIBNET +# End BINARY net +################################# diff --git a/source4/utils/net/net.c b/source4/utils/net/net.c index 6db62ea6b0..ddca5662a2 100644 --- a/source4/utils/net/net.c +++ b/source4/utils/net/net.c @@ -5,6 +5,9 @@ Copyright (C) 2001 Jim McDonough (jmcd@us.ibm.com) Copyright (C) 2001 Andrew Tridgell (tridge@samba.org) Copyright (C) 2001 Andrew Bartlett (abartlet@samba.org) + Copyright (C) 2004 Stefan Metzmacher (metze@samba.org) + + Largely rewritten by metze in August 2004 Originally written by Steve and Jim. Largely rewritten by tridge in November 2001. @@ -23,7 +26,8 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ /*****************************************************/ /* */ @@ -38,552 +42,124 @@ /*****************************************************/ #include "includes.h" -#include "../utils/net.h" - -/***********************************************************************/ -/* Beginning of internationalization section. Translatable constants */ -/* should be kept in this area and referenced in the rest of the code. */ -/* */ -/* No functions, outside of Samba or LSB (Linux Standards Base) should */ -/* be used (if possible). */ -/***********************************************************************/ - -#define YES_STRING "Yes" -#define NO_STRING "No" - -/************************************************************************************/ -/* end of internationalization section */ -/************************************************************************************/ - -/* Yes, these buggers are globals.... */ -const char *opt_requester_name = NULL; -const char *opt_host = NULL; -const char *opt_password = NULL; -const char *opt_user_name = NULL; -BOOL opt_user_specified = False; -const char *opt_workgroup = NULL; -int opt_long_list_entries = 0; -int opt_reboot = 0; -int opt_force = 0; -int opt_port = 0; -int opt_maxusers = -1; -const char *opt_comment = ""; -char *opt_container = "cn=Users"; -int opt_flags = -1; -int opt_jobid = 0; -int opt_timeout = 0; -const char *opt_target_workgroup = NULL; -static int opt_machine_pass = 0; - -BOOL opt_have_ip = False; -struct in_addr opt_dest_ip; - -extern BOOL AllowDebugChange; +#include "utils/net/net.h" /* run a function from a function table. If not found then call the specified usage function */ -int net_run_function(int argc, const char **argv, struct functable *table, - int (*usage_fn)(int argc, const char **argv)) +int net_run_function(struct net_context *ctx, + int argc, const char **argv, + const struct net_functable *functable, + int (*help_fn)(struct net_context *ctx, int argc, const char **argv)) { int i; if (argc < 1) { - d_printf("\nUsage: \n"); - return usage_fn(argc, argv); + d_printf("Usage: \n"); + return help_fn(ctx, argc, argv); } - for (i=0; table[i].funcname; i++) { - if (StrCaseCmp(argv[0], table[i].funcname) == 0) - return table[i].fn(argc-1, argv+1); + for (i=0; functable[i].name; i++) { + if (StrCaseCmp(argv[0], functable[i].name) == 0) + return functable[i].fn(ctx, argc-1, argv+1); } d_printf("No command: %s\n", argv[0]); - return usage_fn(argc, argv); -} - - -/**************************************************************************** -connect to \\server\ipc$ -****************************************************************************/ -NTSTATUS connect_to_ipc(struct smbcli_state **c, struct in_addr *server_ip, - const char *server_name) -{ - NTSTATUS nt_status; - - if (!opt_password) { - char *pass = getpass("Password:"); - if (pass) { - opt_password = strdup(pass); - } - } - - nt_status = smbcli_full_connection(c, opt_requester_name, server_name, - server_ip, opt_port, - "IPC$", "IPC", - opt_user_name, opt_workgroup, - opt_password, 0, NULL); - - if (NT_STATUS_IS_OK(nt_status)) { - return nt_status; - } else { - DEBUG(1,("Cannot connect to server. Error was %s\n", - nt_errstr(nt_status))); - - /* Display a nicer message depending on the result */ - - if (NT_STATUS_V(nt_status) == - NT_STATUS_V(NT_STATUS_LOGON_FAILURE)) - d_printf("The username or password was not correct.\n"); - - return nt_status; - } -} - -/**************************************************************************** -connect to \\server\ipc$ anonymously -****************************************************************************/ -NTSTATUS connect_to_ipc_anonymous(struct smbcli_state **c, - struct in_addr *server_ip, const char *server_name) -{ - NTSTATUS nt_status; - - nt_status = smbcli_full_connection(c, opt_requester_name, server_name, - server_ip, opt_port, - "IPC$", "IPC", - "", "", - "", 0, 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; - } -} - -BOOL net_find_server(uint_t flags, struct in_addr *server_ip, char **server_name) -{ - - if (opt_host) { - *server_name = strdup(opt_host); - } - - if (opt_have_ip) { - *server_ip = opt_dest_ip; - if (!*server_name) { - *server_name = strdup(inet_ntoa(opt_dest_ip)); - } - } else if (*server_name) { - /* resolve the IP address */ - if (!resolve_name(*server_name, server_ip, 0x20)) { - DEBUG(1,("Unable to resolve server name\n")); - return False; - } - } else if (flags & NET_FLAGS_PDC) { - struct in_addr pdc_ip; - - if (get_pdc_ip(opt_target_workgroup, &pdc_ip)) { - fstring dc_name; - - if (is_zero_ip(pdc_ip)) - return False; - - if (!lookup_dc_name(lp_netbios_name(), opt_target_workgroup, &pdc_ip, dc_name)) - return False; - - *server_name = strdup(dc_name); - *server_ip = pdc_ip; - } - - } else if (flags & NET_FLAGS_DMB) { - struct in_addr msbrow_ip; - /* if (!resolve_name(MSBROWSE, &msbrow_ip, 1)) */ - if (!resolve_name(opt_target_workgroup, &msbrow_ip, 0x1B)) { - DEBUG(1,("Unable to resolve domain browser via name lookup\n")); - return False; - } else { - *server_ip = msbrow_ip; - } - *server_name = strdup(inet_ntoa(opt_dest_ip)); - } else if (flags & NET_FLAGS_MASTER) { - struct in_addr brow_ips; - if (!resolve_name(opt_target_workgroup, &brow_ips, 0x1D)) { - /* go looking for workgroups */ - DEBUG(1,("Unable to resolve master browser via name lookup\n")); - return False; - } else { - *server_ip = brow_ips; - } - *server_name = strdup(inet_ntoa(opt_dest_ip)); - } else if (!(flags & NET_FLAGS_LOCALHOST_DEFAULT_INSANE)) { - extern struct in_addr loopback_ip; - *server_ip = loopback_ip; - *server_name = strdup("127.0.0.1"); - } - - if (!server_name || !*server_name) { - DEBUG(1,("no server to connect to\n")); - return False; - } - - return True; -} - - -BOOL net_find_dc(struct in_addr *server_ip, fstring server_name, const char *domain_name) -{ - if (get_pdc_ip(domain_name, server_ip)) { - fstring dc_name; - - if (is_zero_ip(*server_ip)) - return False; - - if (!lookup_dc_name(lp_netbios_name(), domain_name, server_ip, dc_name)) - return False; - - safe_strcpy(server_name, dc_name, FSTRING_LEN); - return True; - } else - return False; -} - - -struct smbcli_state *net_make_ipc_connection(uint_t flags) -{ - char *server_name = NULL; - struct in_addr server_ip; - struct smbcli_state *cli = NULL; - NTSTATUS nt_status; - - if (!net_find_server(flags, &server_ip, &server_name)) { - d_printf("\nUnable to find a suitable server\n"); - return NULL; - } - - if (flags & NET_FLAGS_ANONYMOUS) { - nt_status = connect_to_ipc_anonymous(&cli, &server_ip, server_name); - } else { - nt_status = connect_to_ipc(&cli, &server_ip, server_name); - } - - SAFE_FREE(server_name); - if (NT_STATUS_IS_OK(nt_status)) { - return cli; - } else { - return NULL; - } -} - -static int net_user(int argc, const char **argv) -{ - if (net_ads_check() == 0) - return net_ads_user(argc, argv); - - /* if server is not specified, default to PDC? */ - if (net_rpc_check(NET_FLAGS_PDC)) - return net_rpc_user(argc, argv); - - return net_rap_user(argc, argv); -} - -static int net_group(int argc, const char **argv) -{ - if (net_ads_check() == 0) - return net_ads_group(argc, argv); - - if (argc == 0 && net_rpc_check(NET_FLAGS_PDC)) - return net_rpc_group(argc, argv); - - return net_rap_group(argc, argv); -} - -static int net_join(int argc, const char **argv) -{ - if (net_ads_check() == 0) { - if (net_ads_join(argc, argv) == 0) - return 0; - else - d_printf("ADS join did not work, trying RPC...\n"); - } - return net_rpc_join(argc, argv); -} - -static int net_share(int argc, const char **argv) -{ - if (net_rpc_check(0)) - return net_rpc_share(argc, argv); - return net_rap_share(argc, argv); -} - -static int net_file(int argc, const char **argv) -{ - if (net_rpc_check(0)) - return net_rpc_file(argc, argv); - return net_rap_file(argc, argv); + return help_fn(ctx, argc, argv); } /* - Retrieve our local SID or the SID for the specified name - */ -static int net_getlocalsid(int argc, const char **argv) -{ - DOM_SID sid; - const char *name; - fstring sid_str; - - if (argc >= 1) { - name = argv[0]; - } - else { - name = lp_netbios_name(); - } - - if (!secrets_fetch_domain_sid(name, &sid)) { - DEBUG(0, ("Can't fetch domain SID for name: %s\n", name)); - return 1; - } - sid_to_string(sid_str, &sid); - d_printf("SID for domain %s is: %s\n", name, sid_str); - return 0; -} - -static int net_setlocalsid(int argc, const char **argv) -{ - DOM_SID sid; - - if ( (argc != 1) - || (strncmp(argv[0], "S-1-5-21-", strlen("S-1-5-21-")) != 0) - || (!string_to_sid(&sid, argv[0])) - || (sid.num_auths != 4)) { - d_printf("usage: net setlocalsid S-1-5-21-x-y-z\n"); - return 1; - } - - if (!secrets_store_domain_sid(lp_netbios_name(), &sid)) { - DEBUG(0,("Can't store domain SID as a pdc/bdc.\n")); - return 1; - } - - return 0; -} - -static int net_getdomainsid(int argc, const char **argv) + run a help function from a function table. If not found then fail +*/ +int net_run_help(struct net_context *ctx, + int argc, const char **argv, + const struct net_functable *functable) { - DOM_SID domain_sid; - fstring sid_str; - - if (!secrets_fetch_domain_sid(lp_netbios_name(), &domain_sid)) { - d_printf("Could not fetch local SID\n"); + int i; + + if (argc < 1) { + d_printf("net_run_help: TODO (argc < 1)\n"); return 1; } - sid_to_string(sid_str, &domain_sid); - d_printf("SID for domain %s is: %s\n", lp_netbios_name(), sid_str); - - if (!secrets_fetch_domain_sid(lp_workgroup(), &domain_sid)) { - d_printf("Could not fetch domain SID\n"); - return 1; + for (i=0; functable[i].name; i++) { + if (StrCaseCmp(argv[0], functable[i].name) == 0) + if (functable[i].help) { + return functable[i].help(ctx, argc-1, argv+1); + } } - - sid_to_string(sid_str, &domain_sid); - d_printf("SID for domain %s is: %s\n", lp_workgroup(), sid_str); - - return 0; + d_printf("No help for command: %s\n", argv[0]); + return 1; } -static uint32_t get_maxrid(void) +static int net_help_msg(struct net_context *ctx, int argc, const char **argv) { - SAM_ACCOUNT *pwd = NULL; - uint32_t max_rid = 0; - GROUP_MAP *map = NULL; - int num_entries = 0; - int i; - - if (!pdb_setsampwent(False)) { - DEBUG(0, ("load_sampwd_entries: Unable to open passdb.\n")); - return 0; - } - - for (; (NT_STATUS_IS_OK(pdb_init_sam(&pwd))) - && pdb_getsampwent(pwd) == True; pwd=NULL) { - uint32_t rid; - - if (!sid_peek_rid(pdb_get_user_sid(pwd), &rid)) { - DEBUG(0, ("can't get RID for user '%s'\n", - pdb_get_username(pwd))); - pdb_free_sam(&pwd); - continue; - } - - if (rid > max_rid) - max_rid = rid; - - DEBUG(1,("%d is user '%s'\n", rid, pdb_get_username(pwd))); - pdb_free_sam(&pwd); - } - - pdb_endsampwent(); - pdb_free_sam(&pwd); - - if (!pdb_enum_group_mapping(SID_NAME_UNKNOWN, &map, &num_entries, - ENUM_ONLY_MAPPED, MAPPING_WITHOUT_PRIV)) - return max_rid; - - for (i = 0; i < num_entries; i++) { - uint32_t rid; - - if (!sid_peek_check_rid(get_global_sam_sid(), &map[i].sid, - &rid)) { - DEBUG(3, ("skipping map for group '%s', SID %s\n", - map[i].nt_name, - sid_string_static(&map[i].sid))); - continue; - } - DEBUG(1,("%d is group '%s'\n", rid, map[i].nt_name)); - - if (rid > max_rid) - max_rid = rid; - } - - SAFE_FREE(map); - - return max_rid; + d_printf("Help: TODO\n"); + return 0; } -static int net_maxrid(int argc, const char **argv) -{ - uint32_t rid; - - if (argc != 0) { - DEBUG(0, ("usage: net initrid\n")); - return 1; - } - - if ((rid = get_maxrid()) == 0) { - DEBUG(0, ("can't get current maximum rid\n")); - return 1; - } - - d_printf("Currently used maximum rid: %d\n", rid); - - return 0; -} +static int net_help(struct net_context *ctx, int argc, const char **argv); /* main function table */ -static struct functable net_func[] = { - {"RPC", net_rpc}, - {"RAP", net_rap}, - {"ADS", net_ads}, - - /* eventually these should auto-choose the transport ... */ - {"FILE", net_file}, - {"SHARE", net_share}, - {"SESSION", net_rap_session}, - {"SERVER", net_rap_server}, - {"DOMAIN", net_rap_domain}, - {"PRINTQ", net_rap_printq}, - {"USER", net_user}, - {"GROUP", net_group}, - {"VALIDATE", net_rap_validate}, - {"GROUPMEMBER", net_rap_groupmember}, - {"ADMIN", net_rap_admin}, - {"SERVICE", net_rap_service}, - {"PASSWORD", net_rap_password}, - {"TIME", net_time}, - {"LOOKUP", net_lookup}, - {"JOIN", net_join}, - {"CACHE", net_cache}, - {"GETLOCALSID", net_getlocalsid}, - {"SETLOCALSID", net_setlocalsid}, - {"GETDOMAINSID", net_getdomainsid}, - {"MAXRID", net_maxrid}, +static const struct net_functable net_functable[] = { +/* {"password", net_password, net_password_help},*/ - {"HELP", net_help}, + {"help", net_help_msg, net_help_msg}, {NULL, NULL} }; +static int net_help(struct net_context *ctx, int argc, const char **argv) +{ + return net_run_help(ctx, argc, argv, net_functable); +} /**************************************************************************** main program ****************************************************************************/ - int main(int argc, const char **argv) +static int binary_net(int argc, const char **argv) { int opt,i; - char *p; - int rc = 0; - int argc_new = 0; - const char ** argv_new; + int rc; + int argc_new; + const char **argv_new; + struct net_context ctx; poptContext pc; - static char *servicesf = dyn_CONFIGFILE; - static char *debuglevel = NULL; + + setup_logging("net", DEBUG_STDOUT); + +#ifdef HAVE_SETBUFFER + setbuffer(stdout, NULL, 0); +#endif + + ctx.mem_ctx = talloc_init("net_context"); + if (!ctx.mem_ctx) { + d_printf("talloc_init(net_context) failed\n"); + exit(1); + } struct poptOption long_options[] = { {"help", 'h', POPT_ARG_NONE, 0, 'h'}, - {"workgroup", 'w', POPT_ARG_STRING, &opt_target_workgroup}, - {"myworkgroup", 'W', POPT_ARG_STRING, &opt_workgroup}, - {"user", 'U', POPT_ARG_STRING, &opt_user_name, 'U'}, - {"ipaddress", 'I', POPT_ARG_STRING, 0,'I'}, - {"port", 'p', POPT_ARG_INT, &opt_port}, - {"myname", 'n', POPT_ARG_STRING, &opt_requester_name}, - {"conf", 's', POPT_ARG_STRING, &servicesf}, - {"server", 'S', POPT_ARG_STRING, &opt_host}, - {"container", 'c', POPT_ARG_STRING, &opt_container}, - {"comment", 'C', POPT_ARG_STRING, &opt_comment}, - {"maxusers", 'M', POPT_ARG_INT, &opt_maxusers}, - {"flags", 'F', POPT_ARG_INT, &opt_flags}, - {"jobid", 'j', POPT_ARG_INT, &opt_jobid}, - {"long", 'l', POPT_ARG_NONE, &opt_long_list_entries}, - {"reboot", 'r', POPT_ARG_NONE, &opt_reboot}, - {"force", 'f', POPT_ARG_NONE, &opt_force}, - {"timeout", 't', POPT_ARG_INT, &opt_timeout}, - {"machine-pass",'P', POPT_ARG_NONE, &opt_machine_pass}, - {"debuglevel", 'd', POPT_ARG_STRING, &debuglevel}, {NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_version}, { 0, 0, 0, 0} }; - zero_ip(&opt_dest_ip); - - dbf = x_stderr; - pc = poptGetContext(NULL, argc, (const char **) argv, long_options, POPT_CONTEXT_KEEP_FIRST); - + while((opt = poptGetNextOpt(pc)) != -1) { switch (opt) { case 'h': - net_help(argc, argv); + net_help(&ctx, argc, argv); exit(0); break; - case 'I': - opt_dest_ip = *interpret_addr2(poptGetOptArg(pc)); - if (is_zero_ip(opt_dest_ip)) - d_printf("\nInvalid ip address specified\n"); - else - opt_have_ip = True; - break; - case 'U': - opt_user_specified = True; - opt_user_name = strdup(opt_user_name); - p = strchr(opt_user_name,'%'); - if (p) { - *p = 0; - opt_password = p+1; - } - break; default: - d_printf("\nInvalid option %s: %s\n", + d_printf("Invalid option %s: %s\n", poptBadOption(pc, 0), poptStrerror(opt)); - net_help(argc, argv); + net_help(&ctx, argc, argv); exit(1); } } - if (debuglevel) { - debug_parse_levels(debuglevel); - AllowDebugChange = False; - } - - lp_load(servicesf,True,False,False); + lp_load(dyn_CONFIGFILE,True,False,False); + load_interfaces(); argv_new = (const char **)poptGetArgs(pc); @@ -595,48 +171,20 @@ static struct functable net_func[] = { } } - if (!opt_requester_name) { - opt_requester_name = get_myname(); - } - - if (!opt_user_name && getenv("LOGNAME")) { - opt_user_name = getenv("LOGNAME"); - } - - if (!opt_workgroup) { - opt_workgroup = lp_workgroup(); - } - - if (!opt_target_workgroup) { - opt_target_workgroup = strdup(lp_workgroup()); + if (argc_new < 2) { + d_printf("Usage: TODO\n"); + return 1; } - - if (!init_names()) - exit(1); - - load_interfaces(); - - if (opt_machine_pass) { - char *user; - /* it is very useful to be able to make ads queries as the - machine account for testing purposes and for domain leave */ - if (!secrets_init()) { - d_printf("ERROR: Unable to open secrets database\n"); - exit(1); - } + rc = net_run_function(&ctx, argc_new-1, argv_new+1, net_functable, net_help_msg); - asprintf(&user,"%s$", lp_netbios_name()); - opt_user_name = user; - opt_password = secrets_fetch_machine_password(); - if (!opt_password) { - d_printf("ERROR: Unable to fetch machine password\n"); - exit(1); - } + if (rc != 0) { + DEBUG(0,("return code = %d\n", rc)); } - - rc = net_run_function(argc_new-1, argv_new+1, net_func, net_help); - - DEBUG(2,("return code = %d\n", rc)); return rc; } + + int main(int argc, const char **argv) +{ + return binary_net(argc, argv); +} diff --git a/source4/utils/net/net.h b/source4/utils/net/net.h index 1d83a02635..f1ed93fbfb 100644 --- a/source4/utils/net/net.h +++ b/source4/utils/net/net.h @@ -1,7 +1,8 @@ /* Samba Unix/Linux SMB client library Distributed SMB/CIFS Server Management Utility - Copyright (C) 2001 Andrew Bartlett (abartlet@samba.org) + + Copyright (C) Stefan Metzmacher 2004 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 @@ -15,45 +16,20 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#define NET_FLAGS_MASTER 1 -#define NET_FLAGS_DMB 2 - -/* Would it be insane to set 'localhost' as the default - remote host for this operation? - - For example, localhost is insane for a 'join' operation. + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#define NET_FLAGS_LOCALHOST_DEFAULT_INSANE 4 - -/* We want to find the PDC only */ -#define NET_FLAGS_PDC 8 - -/* We want an anonymous connection */ -#define NET_FLAGS_ANONYMOUS 16 - - -extern int opt_maxusers; -extern const char *opt_comment; -extern char *opt_container; -extern int opt_flags; - -extern const char *opt_comment; -extern const char *opt_target_workgroup; -extern const char *opt_workgroup; -extern int opt_long_list_entries; -extern int opt_reboot; -extern int opt_force; -extern int opt_timeout; -extern const char *opt_host; -extern const char *opt_user_name; -extern const char *opt_password; -extern BOOL opt_user_specified; +#ifndef _UTIL_NET_H +#define _UTIL_NET_H -extern BOOL opt_have_ip; -extern struct in_addr opt_dest_ip; +struct net_context { + TALLOC_CTX *mem_ctx; +}; -extern const char *share_type[]; +struct net_functable { + const char *name; + int (*fn)(struct net_context *ctx, int argc, const char **argv); + int (*help)(struct net_context *ctx, int argc, const char **argv); +}; +#endif /* _UTIL_NET_H */ -- cgit From f7c842707afac05aebaba5c6868a73091a98bb3e Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 18 Aug 2004 10:35:46 +0000 Subject: r1877: since make proto catches all functions the inlcude has to move to includes.h metze (This used to be commit 97fe38183b6a03c01f6ac2d28a958d632eb4ff8a) --- source4/utils/net/net.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net.c b/source4/utils/net/net.c index ddca5662a2..a636e4cdaa 100644 --- a/source4/utils/net/net.c +++ b/source4/utils/net/net.c @@ -42,7 +42,6 @@ /*****************************************************/ #include "includes.h" -#include "utils/net/net.h" /* run a function from a function table. If not found then -- cgit From bc3a20e9d8cec0b0b402e922214fc5a7f08e785e Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 18 Aug 2004 12:47:08 +0000 Subject: r1879: - add a user sub struct in net_context - add 'net password change' command (it doesn'T work yet because libnet_rpc_connect() isn't implemented yet, and we don't fill in the net_context user substruct yet) metze (This used to be commit 939da063cdf18a5ab7e7f0490ac58d1f138cf0f0) --- source4/utils/net/config.mk | 3 +- source4/utils/net/net.c | 84 ++++++++++++++++++++++++-------- source4/utils/net/net.h | 8 +++- source4/utils/net/net_password.c | 100 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 172 insertions(+), 23 deletions(-) create mode 100644 source4/utils/net/net_password.c (limited to 'source4/utils/net') diff --git a/source4/utils/net/config.mk b/source4/utils/net/config.mk index 8593aaec65..ce90906fe6 100644 --- a/source4/utils/net/config.mk +++ b/source4/utils/net/config.mk @@ -4,7 +4,8 @@ # Start BINARY net [BINARY::net] OBJ_FILES = \ - utils/net/net.o + utils/net/net.o \ + utils/net/net_password.o REQUIRED_SUBSYSTEMS = \ CONFIG \ LIBCMDLINE \ diff --git a/source4/utils/net/net.c b/source4/utils/net/net.c index a636e4cdaa..f1bb4cef4c 100644 --- a/source4/utils/net/net.c +++ b/source4/utils/net/net.c @@ -50,64 +50,99 @@ int net_run_function(struct net_context *ctx, int argc, const char **argv, const struct net_functable *functable, - int (*help_fn)(struct net_context *ctx, int argc, const char **argv)) + int (*usage_fn)(struct net_context *ctx, int argc, const char **argv)) { int i; - + if (argc < 1) { d_printf("Usage: \n"); - return help_fn(ctx, argc, argv); + return usage_fn(ctx, argc, argv); } + for (i=0; functable[i].name; i++) { if (StrCaseCmp(argv[0], functable[i].name) == 0) return functable[i].fn(ctx, argc-1, argv+1); } + d_printf("No command: %s\n", argv[0]); - return help_fn(ctx, argc, argv); + return usage_fn(ctx, argc, argv); } /* - run a help function from a function table. If not found then fail + run a usage function from a function table. If not found then fail +*/ +int net_run_usage(struct net_context *ctx, + int argc, const char **argv, + const struct net_functable *functable) +{ + int i; + + if (argc < 1) { + d_printf("net_run_usage: TODO (argc < 1)\n"); + return 1; + } + + for (i=0; functable[i].name; i++) { + if (StrCaseCmp(argv[0], functable[i].name) == 0) + if (functable[i].usage) { + return functable[i].usage(ctx, argc-1, argv+1); + } + } + + d_printf("No usage for command: %s\n", argv[0]); + + return 1; +} + +/* + run a usage function from a function table. If not found then fail */ int net_run_help(struct net_context *ctx, int argc, const char **argv, const struct net_functable *functable) { int i; - + if (argc < 1) { d_printf("net_run_help: TODO (argc < 1)\n"); return 1; } + for (i=0; functable[i].name; i++) { if (StrCaseCmp(argv[0], functable[i].name) == 0) if (functable[i].help) { return functable[i].help(ctx, argc-1, argv+1); } } + d_printf("No help for command: %s\n", argv[0]); + return 1; } -static int net_help_msg(struct net_context *ctx, int argc, const char **argv) +static int net_help(struct net_context *ctx, int argc, const char **argv) { - d_printf("Help: TODO\n"); - return 0; + d_printf("net_help: TODO\n"); + return 0; } -static int net_help(struct net_context *ctx, int argc, const char **argv); +static int net_help_usage(struct net_context *ctx, int argc, const char **argv) +{ + d_printf("net_help_usage: TODO\n"); + return 0; +} /* main function table */ -static const struct net_functable net_functable[] = { -/* {"password", net_password, net_password_help},*/ +static const struct net_functable const net_functable[] = { + {"password", net_password, net_password_usage, net_password_help}, - {"help", net_help_msg, net_help_msg}, + {"help", net_help, net_help_usage, net_help}, {NULL, NULL} }; -static int net_help(struct net_context *ctx, int argc, const char **argv) +static int net_usage(struct net_context *ctx, int argc, const char **argv) { - return net_run_help(ctx, argc, argv, net_functable); + return net_run_usage(ctx, argc, argv, net_functable); } /**************************************************************************** @@ -119,7 +154,8 @@ static int binary_net(int argc, const char **argv) int rc; int argc_new; const char **argv_new; - struct net_context ctx; + TALLOC_CTX *mem_ctx; + struct net_context *ctx; poptContext pc; setup_logging("net", DEBUG_STDOUT); @@ -128,12 +164,16 @@ static int binary_net(int argc, const char **argv) setbuffer(stdout, NULL, 0); #endif - ctx.mem_ctx = talloc_init("net_context"); - if (!ctx.mem_ctx) { + mem_ctx = talloc_init("net_context"); + ctx = talloc_p(mem_ctx, struct net_context); + if (!ctx) { d_printf("talloc_init(net_context) failed\n"); exit(1); } + ZERO_STRUCTP(ctx); + ctx->mem_ctx = mem_ctx; + struct poptOption long_options[] = { {"help", 'h', POPT_ARG_NONE, 0, 'h'}, {NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_version}, @@ -146,13 +186,13 @@ static int binary_net(int argc, const char **argv) while((opt = poptGetNextOpt(pc)) != -1) { switch (opt) { case 'h': - net_help(&ctx, argc, argv); + net_help(ctx, argc, argv); exit(0); break; default: d_printf("Invalid option %s: %s\n", poptBadOption(pc, 0), poptStrerror(opt)); - net_help(&ctx, argc, argv); + net_help(ctx, argc, argv); exit(1); } } @@ -175,11 +215,13 @@ static int binary_net(int argc, const char **argv) return 1; } - rc = net_run_function(&ctx, argc_new-1, argv_new+1, net_functable, net_help_msg); + rc = net_run_function(ctx, argc_new-1, argv_new+1, net_functable, net_usage); if (rc != 0) { DEBUG(0,("return code = %d\n", rc)); } + + talloc_destroy(mem_ctx); return rc; } diff --git a/source4/utils/net/net.h b/source4/utils/net/net.h index f1ed93fbfb..ba8294c144 100644 --- a/source4/utils/net/net.h +++ b/source4/utils/net/net.h @@ -24,12 +24,18 @@ struct net_context { TALLOC_CTX *mem_ctx; + struct { + const char *account_name; + const char *domain_name; + const char *password; + } user; }; struct net_functable { const char *name; int (*fn)(struct net_context *ctx, int argc, const char **argv); - int (*help)(struct net_context *ctx, int argc, const char **argv); + int (*usage)(struct net_context *ctx, int argc, const char **argv); + int (*help)(struct net_context *ctx, int argc, const char **argv); }; #endif /* _UTIL_NET_H */ diff --git a/source4/utils/net/net_password.c b/source4/utils/net/net_password.c new file mode 100644 index 0000000000..90f26924a6 --- /dev/null +++ b/source4/utils/net/net_password.c @@ -0,0 +1,100 @@ +/* + Samba Unix/Linux SMB client library + Distributed SMB/CIFS Server Management Utility + + Copyright (C) 2004 Stefan Metzmacher (metze@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 2 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, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" + +/* + * Code for Changing and setting a password + */ + + +static int net_password_change(struct net_context *ctx, int argc, const char **argv) +{ + NTSTATUS status; + struct libnet_context *libnetctx; + union libnet_ChangePassword r; + char *password_prompt = NULL; + const char *new_password; + + if (argc > 0 && argv[0]) { + new_password = argv[0]; + } else { + password_prompt = talloc_asprintf(ctx->mem_ctx, "Enter new password for %s:", ctx->user.account_name); + new_password = getpass(password_prompt); + } + + libnetctx = libnet_context_init(); + if (!libnetctx) { + return -1; + } + + /* prepare password change */ + r.generic.level = LIBNET_CHANGE_PASSWORD_GENERIC; + r.generic.in.account_name = ctx->user.account_name; + r.generic.in.domain_name = ctx->user.domain_name; + r.generic.in.oldpassword = ctx->user.password; + r.generic.in.newpassword = new_password; + + /* do password change */ + status = libnet_ChangePassword(libnetctx, ctx->mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0,("net_password_change: %s\n",r.generic.out.error_string)); + return -1; + } + + libnet_context_destroy(&libnetctx); + + return 0; +} + +static int net_password_change_usage(struct net_context *ctx, int argc, const char **argv) +{ + d_printf("net_password_change_usage: TODO\n"); + return 0; +} + +static int net_password_change_help(struct net_context *ctx, int argc, const char **argv) +{ + d_printf("net_password_change_help: TODO\n"); + return 0; +} + +static const struct net_functable const net_password_functable[] = { + {"change", net_password_change, net_password_change_usage, net_password_change_help}, + {NULL, NULL} +}; + +int net_password(struct net_context *ctx, int argc, const char **argv) +{ + return net_run_function(ctx, argc, argv, net_password_functable, net_password_usage); +} + +int net_password_usage(struct net_context *ctx, int argc, const char **argv) +{ + d_printf("net_password_usage: TODO\n"); + return 0; +} + +int net_password_help(struct net_context *ctx, int argc, const char **argv) +{ + d_printf("net_password_help: TODO\n"); + return 0; +} -- cgit From 770fb6d22d4bfeb87a35cff49b2756ea94d0979d Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 18 Aug 2004 13:00:28 +0000 Subject: r1880: bugger, now I have used gcc 3.4.1 myself and have statements before declarations Does any knows if there are flags to let gcc 3.4.1 fail with that? metze (This used to be commit 6ad57a86c8583df90a93fdf36b7184010d2054bc) --- source4/utils/net/net.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net.c b/source4/utils/net/net.c index f1bb4cef4c..b6b3fb6fb9 100644 --- a/source4/utils/net/net.c +++ b/source4/utils/net/net.c @@ -157,6 +157,11 @@ static int binary_net(int argc, const char **argv) TALLOC_CTX *mem_ctx; struct net_context *ctx; poptContext pc; + struct poptOption long_options[] = { + {"help", 'h', POPT_ARG_NONE, 0, 'h'}, + {NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_version}, + { 0, 0, 0, 0} + }; setup_logging("net", DEBUG_STDOUT); @@ -172,13 +177,7 @@ static int binary_net(int argc, const char **argv) } ZERO_STRUCTP(ctx); - ctx->mem_ctx = mem_ctx; - - struct poptOption long_options[] = { - {"help", 'h', POPT_ARG_NONE, 0, 'h'}, - {NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_version}, - { 0, 0, 0, 0} - }; + ctx->mem_ctx = mem_ctx; pc = poptGetContext(NULL, argc, (const char **) argv, long_options, POPT_CONTEXT_KEEP_FIRST); -- cgit From 5c9c6b47412e93caab4c55086f679fb12fc9a9af Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 19 Aug 2004 12:24:58 +0000 Subject: r1914: use common popt stuff in net metze (This used to be commit 52b866c40332ab408c57a0eab415e0755e4b5081) --- source4/utils/net/net.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net.c b/source4/utils/net/net.c index b6b3fb6fb9..05dbb35f41 100644 --- a/source4/utils/net/net.c +++ b/source4/utils/net/net.c @@ -158,9 +158,12 @@ static int binary_net(int argc, const char **argv) struct net_context *ctx; poptContext pc; struct poptOption long_options[] = { - {"help", 'h', POPT_ARG_NONE, 0, 'h'}, - {NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_version}, - { 0, 0, 0, 0} + POPT_AUTOHELP + POPT_COMMON_SAMBA + POPT_COMMON_CONNECTION + POPT_COMMON_CREDENTIALS + POPT_COMMON_VERSION + POPT_TABLEEND }; setup_logging("net", DEBUG_STDOUT); @@ -179,15 +182,11 @@ static int binary_net(int argc, const char **argv) ZERO_STRUCTP(ctx); ctx->mem_ctx = mem_ctx; - pc = poptGetContext(NULL, argc, (const char **) argv, long_options, - POPT_CONTEXT_KEEP_FIRST); + pc = poptGetContext("net", argc, (const char **) argv, long_options, + POPT_CONTEXT_KEEP_FIRST); while((opt = poptGetNextOpt(pc)) != -1) { switch (opt) { - case 'h': - net_help(ctx, argc, argv); - exit(0); - break; default: d_printf("Invalid option %s: %s\n", poptBadOption(pc, 0), poptStrerror(opt)); -- cgit From 124e00068f2187e254f76cd82e913809870d799c Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 19 Aug 2004 12:36:05 +0000 Subject: r1915: use popt's cmdline_auth_info to fill the net_context and print the user domain when prompting for a new password metze (This used to be commit aedb2e9e1c418a7ac3cc18299707ae9146e4047a) --- source4/utils/net/net.c | 30 ++++++++++++++++++++---------- source4/utils/net/net_password.c | 3 ++- 2 files changed, 22 insertions(+), 11 deletions(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net.c b/source4/utils/net/net.c index 05dbb35f41..89f4e77735 100644 --- a/source4/utils/net/net.c +++ b/source4/utils/net/net.c @@ -156,6 +156,7 @@ static int binary_net(int argc, const char **argv) const char **argv_new; TALLOC_CTX *mem_ctx; struct net_context *ctx; + const char *domain; poptContext pc; struct poptOption long_options[] = { POPT_AUTOHELP @@ -172,16 +173,6 @@ static int binary_net(int argc, const char **argv) setbuffer(stdout, NULL, 0); #endif - mem_ctx = talloc_init("net_context"); - ctx = talloc_p(mem_ctx, struct net_context); - if (!ctx) { - d_printf("talloc_init(net_context) failed\n"); - exit(1); - } - - ZERO_STRUCTP(ctx); - ctx->mem_ctx = mem_ctx; - pc = poptGetContext("net", argc, (const char **) argv, long_options, POPT_CONTEXT_KEEP_FIRST); @@ -213,6 +204,25 @@ static int binary_net(int argc, const char **argv) return 1; } + if (cmdline_auth_info.domain[0]) { + domain = cmdline_auth_info.domain; + } else { + domain = lp_workgroup(); + } + + mem_ctx = talloc_init("net_context"); + ctx = talloc_p(mem_ctx, struct net_context); + if (!ctx) { + d_printf("talloc_init(net_context) failed\n"); + exit(1); + } + + ZERO_STRUCTP(ctx); + ctx->mem_ctx = mem_ctx; + ctx->user.account_name = talloc_strdup(ctx->mem_ctx, cmdline_auth_info.username); + ctx->user.domain_name = talloc_strdup(ctx->mem_ctx, domain); + ctx->user.password = talloc_strdup(ctx->mem_ctx, cmdline_auth_info.password); + rc = net_run_function(ctx, argc_new-1, argv_new+1, net_functable, net_usage); if (rc != 0) { diff --git a/source4/utils/net/net_password.c b/source4/utils/net/net_password.c index 90f26924a6..c9c549fcff 100644 --- a/source4/utils/net/net_password.c +++ b/source4/utils/net/net_password.c @@ -37,7 +37,8 @@ static int net_password_change(struct net_context *ctx, int argc, const char **a if (argc > 0 && argv[0]) { new_password = argv[0]; } else { - password_prompt = talloc_asprintf(ctx->mem_ctx, "Enter new password for %s:", ctx->user.account_name); + password_prompt = talloc_asprintf(ctx->mem_ctx, "Enter new password for account [%s\\%s]:", + ctx->user.domain_name, ctx->user.account_name); new_password = getpass(password_prompt); } -- cgit From 9d62046b0e09fa7a4a660859dd8651e6d60c8dc8 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 19 Aug 2004 13:32:06 +0000 Subject: r1919: paasword change basicly works now:-) but we need to find the real pdc for the users domain and fallback to other levels metze (This used to be commit f1b9c1f3dd0fb927c065541da900ae43e0018a62) --- source4/utils/net/net_password.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net_password.c b/source4/utils/net/net_password.c index c9c549fcff..9daa3f401f 100644 --- a/source4/utils/net/net_password.c +++ b/source4/utils/net/net_password.c @@ -46,6 +46,9 @@ static int net_password_change(struct net_context *ctx, int argc, const char **a if (!libnetctx) { return -1; } + libnetctx->user.account_name = ctx->user.account_name; + libnetctx->user.domain_name = ctx->user.domain_name; + libnetctx->user.password = ctx->user.password; /* prepare password change */ r.generic.level = LIBNET_CHANGE_PASSWORD_GENERIC; -- cgit From c2e2921bada17aae84e6c29f48401fa467e8ed9c Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 20 Aug 2004 09:48:25 +0000 Subject: r1949: provide functions to access the username, userdomain and userpassword now you're prompted when cmdline_get_userpassword() is called and the password is not yet known metze (This used to be commit d14a01533c5d465ff3709c48576b798b3be807e0) --- source4/utils/net/net.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net.c b/source4/utils/net/net.c index 89f4e77735..da64466869 100644 --- a/source4/utils/net/net.c +++ b/source4/utils/net/net.c @@ -156,7 +156,6 @@ static int binary_net(int argc, const char **argv) const char **argv_new; TALLOC_CTX *mem_ctx; struct net_context *ctx; - const char *domain; poptContext pc; struct poptOption long_options[] = { POPT_AUTOHELP @@ -204,12 +203,6 @@ static int binary_net(int argc, const char **argv) return 1; } - if (cmdline_auth_info.domain[0]) { - domain = cmdline_auth_info.domain; - } else { - domain = lp_workgroup(); - } - mem_ctx = talloc_init("net_context"); ctx = talloc_p(mem_ctx, struct net_context); if (!ctx) { @@ -219,9 +212,9 @@ static int binary_net(int argc, const char **argv) ZERO_STRUCTP(ctx); ctx->mem_ctx = mem_ctx; - ctx->user.account_name = talloc_strdup(ctx->mem_ctx, cmdline_auth_info.username); - ctx->user.domain_name = talloc_strdup(ctx->mem_ctx, domain); - ctx->user.password = talloc_strdup(ctx->mem_ctx, cmdline_auth_info.password); + ctx->user.account_name = talloc_strdup(ctx->mem_ctx, cmdline_get_username()); + ctx->user.domain_name = talloc_strdup(ctx->mem_ctx, cmdline_get_userdomain()); + ctx->user.password = talloc_strdup(ctx->mem_ctx, cmdline_get_userpassword()); rc = net_run_function(ctx, argc_new-1, argv_new+1, net_functable, net_usage); -- cgit From 32ec317c900efb104f7a7828898cbfdef0609c2a Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 20 Aug 2004 09:55:21 +0000 Subject: r1951: add 'net password set' call use it like: net password set user net password set DOM\\user net password set user pass net password set DOM\\user pass net password set -U DOM\\Administrator%admpass DOM\\user pass metze (This used to be commit b660e5b9e6236c996550973e9bde1e80a8eed775) --- source4/utils/net/net_password.c | 82 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net_password.c b/source4/utils/net/net_password.c index 9daa3f401f..5da18d94b5 100644 --- a/source4/utils/net/net_password.c +++ b/source4/utils/net/net_password.c @@ -81,8 +81,90 @@ static int net_password_change_help(struct net_context *ctx, int argc, const cha return 0; } +static int net_password_set(struct net_context *ctx, int argc, const char **argv) +{ + NTSTATUS status; + struct libnet_context *libnetctx; + union libnet_SetPassword r; + char *password_prompt = NULL; + char *p; + char *tmp; + const char *account_name; + const char *domain_name; + const char *new_password = NULL; + + switch (argc) { + case 0: /* no args -> fail */ + DEBUG(0,("net_password_set: no args\n")); + return -1; + case 1: /* only DOM\\user; prompt for password */ + tmp = talloc_strdup(ctx->mem_ctx, argv[0]); + break; + case 2: /* DOM\\USER and password */ + tmp = talloc_strdup(ctx->mem_ctx, argv[0]); + new_password = argv[1]; + break; + default: /* too mayn args -> fail */ + DEBUG(0,("net_password_set: too many args [%d]\n",argc)); + return -1; + } + + if ((p = strchr_m(tmp,'\\'))) { + *p = 0; + domain_name = tmp; + account_name = talloc_strdup(ctx->mem_ctx, p+1); + } else { + account_name = tmp; + domain_name = ctx->user.domain_name; + } + + if (!new_password) { + password_prompt = talloc_asprintf(ctx->mem_ctx, "Enter new password for account [%s\\%s]:", + domain_name, account_name); + new_password = getpass(password_prompt); + } + + libnetctx = libnet_context_init(); + if (!libnetctx) { + return -1; + } + libnetctx->user.account_name = ctx->user.account_name; + libnetctx->user.domain_name = ctx->user.domain_name; + libnetctx->user.password = ctx->user.password; + + /* prepare password change */ + r.generic.level = LIBNET_SET_PASSWORD_GENERIC; + r.generic.in.account_name = account_name; + r.generic.in.domain_name = domain_name; + r.generic.in.newpassword = new_password; + + /* do password change */ + status = libnet_SetPassword(libnetctx, ctx->mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0,("net_password_set: %s\n",r.generic.out.error_string)); + return -1; + } + + libnet_context_destroy(&libnetctx); + + return 0; +} + +static int net_password_set_usage(struct net_context *ctx, int argc, const char **argv) +{ + d_printf("net_password_set_usage: TODO\n"); + return 0; +} + +static int net_password_set_help(struct net_context *ctx, int argc, const char **argv) +{ + d_printf("net_password_set_help: TODO\n"); + return 0; +} + static const struct net_functable const net_password_functable[] = { {"change", net_password_change, net_password_change_usage, net_password_change_help}, + {"set", net_password_set, net_password_set_usage, net_password_set_help}, {NULL, NULL} }; -- cgit From 7eb820d31b39cda74b56c4c2dc66daa768f5216f Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 25 Aug 2004 12:14:06 +0000 Subject: r2066: add 'net time' command use it like: net time net time -U "" -N net time -U DOM\\user ... metze (This used to be commit ea14b2780f1cb6597ba4e71b83364e6a39e966fe) --- source4/utils/net/config.mk | 3 +- source4/utils/net/net.c | 1 + source4/utils/net/net_time.c | 85 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 source4/utils/net/net_time.c (limited to 'source4/utils/net') diff --git a/source4/utils/net/config.mk b/source4/utils/net/config.mk index ce90906fe6..f1f6646e9c 100644 --- a/source4/utils/net/config.mk +++ b/source4/utils/net/config.mk @@ -5,7 +5,8 @@ [BINARY::net] OBJ_FILES = \ utils/net/net.o \ - utils/net/net_password.o + utils/net/net_password.o \ + utils/net/net_time.o REQUIRED_SUBSYSTEMS = \ CONFIG \ LIBCMDLINE \ diff --git a/source4/utils/net/net.c b/source4/utils/net/net.c index da64466869..ce817309cc 100644 --- a/source4/utils/net/net.c +++ b/source4/utils/net/net.c @@ -135,6 +135,7 @@ static int net_help_usage(struct net_context *ctx, int argc, const char **argv) /* main function table */ static const struct net_functable const net_functable[] = { {"password", net_password, net_password_usage, net_password_help}, + {"time", net_time, net_time_usage, net_time_help}, {"help", net_help, net_help_usage, net_help}, {NULL, NULL} diff --git a/source4/utils/net/net_time.c b/source4/utils/net/net_time.c new file mode 100644 index 0000000000..c7d46d4d84 --- /dev/null +++ b/source4/utils/net/net_time.c @@ -0,0 +1,85 @@ +/* + Samba Unix/Linux SMB client library + Distributed SMB/CIFS Server Management Utility + + Copyright (C) 2004 Stefan Metzmacher (metze@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 2 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, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" + +/* + * Code for getting the remote time + */ + + +int net_time(struct net_context *ctx, int argc, const char **argv) +{ + NTSTATUS status; + struct libnet_context *libnetctx; + union libnet_RemoteTOD r; + const char *server_name; + struct tm *tm; + char timestr[64]; + + if (argc > 0 && argv[0]) { + server_name = argv[0]; + } else { + DEBUG(0,("net_time: server name needed!\n")); + return -1; + } + + libnetctx = libnet_context_init(); + if (!libnetctx) { + return -1; + } + libnetctx->user.account_name = ctx->user.account_name; + libnetctx->user.domain_name = ctx->user.domain_name; + libnetctx->user.password = ctx->user.password; + + /* prepare to get the time */ + r.generic.level = LIBNET_REMOTE_TOD_GENERIC; + r.generic.in.server_name = server_name; + + /* get the time */ + status = libnet_RemoteTOD(libnetctx, ctx->mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0,("net_password_change: %s\n",r.generic.out.error_string)); + return -1; + } + + ZERO_ARRAY(timestr); + tm = localtime(&r.generic.out.time); + strftime(timestr, sizeof(timestr)-1, "%c %Z",tm); + + printf("%s\n",timestr); + + libnet_context_destroy(&libnetctx); + + return 0; +} + +int net_time_usage(struct net_context *ctx, int argc, const char **argv) +{ + d_printf("net_time_usage: TODO\n"); + return 0; +} + +int net_time_help(struct net_context *ctx, int argc, const char **argv) +{ + d_printf("net_time_help: TODO\n"); + return 0; +} -- cgit From e36341a85ee444ba04c9738926835fdf366a6b6e Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 25 Aug 2004 23:10:30 +0000 Subject: r2074: fixed a typo (This used to be commit dce43a535c9f6135c162711bc12cee266fc46c4a) --- source4/utils/net/net_time.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net_time.c b/source4/utils/net/net_time.c index c7d46d4d84..befb406e87 100644 --- a/source4/utils/net/net_time.c +++ b/source4/utils/net/net_time.c @@ -57,7 +57,7 @@ int net_time(struct net_context *ctx, int argc, const char **argv) /* get the time */ status = libnet_RemoteTOD(libnetctx, ctx->mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { - DEBUG(0,("net_password_change: %s\n",r.generic.out.error_string)); + DEBUG(0,("net_time: %s\n",r.generic.out.error_string)); return -1; } -- cgit From a6ae640313a47ac2950c0948e4385fa934a5ef09 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 28 Oct 2004 13:19:39 +0000 Subject: r3323: more warning reductions (This used to be commit 5921587ec26e4892efc678421277e4969417d7f5) --- source4/utils/net/net_time.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net_time.c b/source4/utils/net/net_time.c index befb406e87..2efe8faffe 100644 --- a/source4/utils/net/net_time.c +++ b/source4/utils/net/net_time.c @@ -63,7 +63,7 @@ int net_time(struct net_context *ctx, int argc, const char **argv) ZERO_ARRAY(timestr); tm = localtime(&r.generic.out.time); - strftime(timestr, sizeof(timestr)-1, "%c %Z",tm); + sys_strftime(timestr, sizeof(timestr)-1, "%c %Z",tm); printf("%s\n",timestr); -- cgit From ead3508ac81ff3ed2a48753f3b5e23537ba6ec73 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 2 Nov 2004 00:24:21 +0000 Subject: r3447: more include/system/XXX.h include files (This used to be commit 264ce9181089922547e8f6f67116f2d7277a5105) --- source4/utils/net/net_time.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net_time.c b/source4/utils/net/net_time.c index 2efe8faffe..e32ec76293 100644 --- a/source4/utils/net/net_time.c +++ b/source4/utils/net/net_time.c @@ -20,6 +20,7 @@ */ #include "includes.h" +#include "system/time.h" /* * Code for getting the remote time -- cgit From edbfc0f6e70150e321822365bf0eead2821551bd Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 2 Nov 2004 02:57:18 +0000 Subject: r3453: - split out the auth and popt includes - tidied up some of the system includes - moved a few more structures back from misc.idl to netlogon.idl and samr.idl now that pidl knows about inter-IDL dependencies (This used to be commit 7b7477ac42d96faac1b0ff361525d2c63cedfc64) --- source4/utils/net/net.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net.c b/source4/utils/net/net.c index ce817309cc..5a4ececa5b 100644 --- a/source4/utils/net/net.c +++ b/source4/utils/net/net.c @@ -42,6 +42,7 @@ /*****************************************************/ #include "includes.h" +#include "lib/cmdline/popt_common.h" /* run a function from a function table. If not found then -- cgit From 6148deca663f7b6504b044120b166d6c9ae28750 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 2 Nov 2004 03:13:06 +0000 Subject: r3454: moved a few more things out if includes.h into the include/system/ include files. this brings us down to about 11k lines of headers included with includes.h, while still retaining the speed of building with pch (This used to be commit 10188869ef072309ca580b8b933e172571fcdda7) --- source4/utils/net/net_password.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net_password.c b/source4/utils/net/net_password.c index 5da18d94b5..01682bd506 100644 --- a/source4/utils/net/net_password.c +++ b/source4/utils/net/net_password.c @@ -20,6 +20,7 @@ */ #include "includes.h" +#include "system/passwd.h" /* * Code for Changing and setting a password -- cgit From 6bd02aa5046b606171a680e6f8aefba31b744af1 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 2 Nov 2004 11:42:35 +0000 Subject: r3478: split out some more pieces of includes.h (This used to be commit 8e9212ecfc61c509f686363d8ec412ce54bc1c8d) --- source4/utils/net/net.c | 1 + source4/utils/net/net_password.c | 2 ++ source4/utils/net/net_time.c | 2 ++ 3 files changed, 5 insertions(+) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net.c b/source4/utils/net/net.c index 5a4ececa5b..3409101b71 100644 --- a/source4/utils/net/net.c +++ b/source4/utils/net/net.c @@ -42,6 +42,7 @@ /*****************************************************/ #include "includes.h" +#include "utils/net/net.h" #include "lib/cmdline/popt_common.h" /* diff --git a/source4/utils/net/net_password.c b/source4/utils/net/net_password.c index 01682bd506..14b48e301e 100644 --- a/source4/utils/net/net_password.c +++ b/source4/utils/net/net_password.c @@ -20,6 +20,8 @@ */ #include "includes.h" +#include "utils/net/net.h" +#include "libnet/libnet.h" #include "system/passwd.h" /* diff --git a/source4/utils/net/net_time.c b/source4/utils/net/net_time.c index e32ec76293..7668a42b8c 100644 --- a/source4/utils/net/net_time.c +++ b/source4/utils/net/net_time.c @@ -20,6 +20,8 @@ */ #include "includes.h" +#include "libnet/libnet.h" +#include "utils/net/net.h" #include "system/time.h" /* -- cgit From 6f214cc510a59b7a65ee9d4486baf14a3e579f73 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 3 Nov 2004 00:17:12 +0000 Subject: r3494: got rid of include/rewrite.h, and split out the dynconfig.h header (This used to be commit 558de54ec6432a4ae90aa14a585f32c6cd03ced2) --- source4/utils/net/net.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net.c b/source4/utils/net/net.c index 3409101b71..380afd6120 100644 --- a/source4/utils/net/net.c +++ b/source4/utils/net/net.c @@ -42,6 +42,7 @@ /*****************************************************/ #include "includes.h" +#include "dynconfig.h" #include "utils/net/net.h" #include "lib/cmdline/popt_common.h" -- cgit From 481bba9e7f6ebfef11c7c7d778a1b465886abfa9 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 6 Nov 2004 12:14:14 +0000 Subject: r3579: with the gcc warning flag from abartlet we don't need sys_strftime() (This used to be commit 041f77b6a19c98599fe18d2eb4e86db00b40014e) --- source4/utils/net/net_time.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net_time.c b/source4/utils/net/net_time.c index 7668a42b8c..d2df76bc5d 100644 --- a/source4/utils/net/net_time.c +++ b/source4/utils/net/net_time.c @@ -66,7 +66,7 @@ int net_time(struct net_context *ctx, int argc, const char **argv) ZERO_ARRAY(timestr); tm = localtime(&r.generic.out.time); - sys_strftime(timestr, sizeof(timestr)-1, "%c %Z",tm); + strftime(timestr, sizeof(timestr)-1, "%c %Z",tm); printf("%s\n",timestr); -- cgit From 71db46ea665606384f2be1be708c74c97c9adfb2 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 6 Nov 2004 23:23:15 +0000 Subject: r3586: Fix some of the issues with the module init functions. Both subsystems and modules can now have init functions, which can be specified in .mk files (INIT_FUNCTION = ...) The build system will define : - SUBSYSTEM_init_static_modules that calls the init functions of all statically compiled modules. Failing to load will generate an error which is not fatal - BINARY_init_subsystems that calls the init functions (if defined) for the subsystems the binary depends on This removes the hack with the "static bool Initialised = " and the "lazy_init" functions (This used to be commit 7a8244761bfdfdfb48f8264d76951ebdfbf7bd8a) --- source4/utils/net/net.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net.c b/source4/utils/net/net.c index 380afd6120..dcd663d3fd 100644 --- a/source4/utils/net/net.c +++ b/source4/utils/net/net.c @@ -232,5 +232,6 @@ static int binary_net(int argc, const char **argv) int main(int argc, const char **argv) { + net_init_subsystems; return binary_net(argc, argv); } -- cgit From 4815480bb6ed44081076bac5471267609f7668cf Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 9 Nov 2004 09:26:47 +0000 Subject: r3633: - moved module init functions to after smb.conf and command line parsing, so that module init can take account of lp_ parms (thats why gensec:krb5=no wasn't working) - added a BASE-DISCONNECT torture test that tests server response to clients disconnecting with open lock and open requests pending (This used to be commit 5205f598b8c0be6985e61cc842cc5da109ba5b7e) --- source4/utils/net/net.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net.c b/source4/utils/net/net.c index dcd663d3fd..ac427c4935 100644 --- a/source4/utils/net/net.c +++ b/source4/utils/net/net.c @@ -207,6 +207,8 @@ static int binary_net(int argc, const char **argv) return 1; } + net_init_subsystems; + mem_ctx = talloc_init("net_context"); ctx = talloc_p(mem_ctx, struct net_context); if (!ctx) { @@ -232,6 +234,5 @@ static int binary_net(int argc, const char **argv) int main(int argc, const char **argv) { - net_init_subsystems; return binary_net(argc, argv); } -- cgit From 8e16d8a76f8a3b8ccc89eb317c8e5daa6cf43b71 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 14 Nov 2004 16:22:01 +0000 Subject: r3733: More build system fixes/features: - Use .mk files directly (no need for a SMB_*_MK() macro when adding a new SUBSYSTEM, MODULE or BINARY). This allows addition of new modules and subsystems without running configure - Add support for generating .dot files with the Samba4 dependency tree (as used by the graphviz and springgraph utilities) (This used to be commit 64826da834e26ee0488674e27a0eae36491ee179) --- source4/utils/net/config.m4 | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 source4/utils/net/config.m4 (limited to 'source4/utils/net') diff --git a/source4/utils/net/config.m4 b/source4/utils/net/config.m4 deleted file mode 100644 index a3e773c68d..0000000000 --- a/source4/utils/net/config.m4 +++ /dev/null @@ -1,3 +0,0 @@ -dnl # utils subsystem - -SMB_BINARY_MK(net, utils/net/config.mk) -- cgit From 4183b2ac3832cdc2055d7eb3ed7121a9ea91085c Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 2 Dec 2004 04:51:56 +0000 Subject: r4037: fixed a bunch of "might be uninitialised" warnings after enabling -O1 in my compile (This used to be commit 0928b1f5b68c858922c3ea6c27ed03b5091c6221) --- source4/utils/net/net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net.c b/source4/utils/net/net.c index ac427c4935..199f0429d6 100644 --- a/source4/utils/net/net.c +++ b/source4/utils/net/net.c @@ -159,7 +159,7 @@ static int binary_net(int argc, const char **argv) int argc_new; const char **argv_new; TALLOC_CTX *mem_ctx; - struct net_context *ctx; + struct net_context *ctx = NULL; poptContext pc; struct poptOption long_options[] = { POPT_AUTOHELP -- cgit From e07525eabdf9d6430a683dc809b453212e764fd5 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 14 Dec 2004 06:25:19 +0000 Subject: r4201: Remove duplicate const. (This used to be commit 1d96717843a9b60a757548a24967bbb553775fa3) --- source4/utils/net/net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net.c b/source4/utils/net/net.c index 199f0429d6..022bb9225e 100644 --- a/source4/utils/net/net.c +++ b/source4/utils/net/net.c @@ -136,7 +136,7 @@ static int net_help_usage(struct net_context *ctx, int argc, const char **argv) } /* main function table */ -static const struct net_functable const net_functable[] = { +static const struct net_functable net_functable[] = { {"password", net_password, net_password_usage, net_password_help}, {"time", net_time, net_time_usage, net_time_help}, -- cgit From a42bbe3cdffe8f0cfdf19583c981f1a18e4cc331 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Thu, 23 Dec 2004 04:09:25 +0000 Subject: r4341: Fix const warning. (This used to be commit d8b1ba93a8ed0d5d01cb05b1c14353a0eca4de3e) --- source4/utils/net/net_password.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net_password.c b/source4/utils/net/net_password.c index 14b48e301e..8828b960ee 100644 --- a/source4/utils/net/net_password.c +++ b/source4/utils/net/net_password.c @@ -165,7 +165,7 @@ static int net_password_set_help(struct net_context *ctx, int argc, const char * return 0; } -static const struct net_functable const net_password_functable[] = { +static const struct net_functable net_password_functable[] = { {"change", net_password_change, net_password_change_usage, net_password_change_help}, {"set", net_password_set, net_password_set_usage, net_password_set_help}, {NULL, NULL} -- cgit From 335a277662d28b935c9d84a3d7a98276afdffd3e Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 13 Jan 2005 07:50:09 +0000 Subject: r4722: Start to add 'net join' to Samba4. Andrew Bartlett (This used to be commit a9b960609142e15ba5950eb1b22944eb6df18d9c) --- source4/utils/net/config.mk | 3 +- source4/utils/net/net.c | 2 +- source4/utils/net/net_join.c | 108 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 111 insertions(+), 2 deletions(-) create mode 100644 source4/utils/net/net_join.c (limited to 'source4/utils/net') diff --git a/source4/utils/net/config.mk b/source4/utils/net/config.mk index f1f6646e9c..e1bc813bec 100644 --- a/source4/utils/net/config.mk +++ b/source4/utils/net/config.mk @@ -6,7 +6,8 @@ OBJ_FILES = \ utils/net/net.o \ utils/net/net_password.o \ - utils/net/net_time.o + utils/net/net_time.o \ + utils/net/net_join.o REQUIRED_SUBSYSTEMS = \ CONFIG \ LIBCMDLINE \ diff --git a/source4/utils/net/net.c b/source4/utils/net/net.c index 022bb9225e..350ec251d9 100644 --- a/source4/utils/net/net.c +++ b/source4/utils/net/net.c @@ -139,7 +139,7 @@ static int net_help_usage(struct net_context *ctx, int argc, const char **argv) static const struct net_functable net_functable[] = { {"password", net_password, net_password_usage, net_password_help}, {"time", net_time, net_time_usage, net_time_help}, - + {"join", net_join, net_join_usage, net_join_help}, {"help", net_help, net_help_usage, net_help}, {NULL, NULL} }; diff --git a/source4/utils/net/net_join.c b/source4/utils/net/net_join.c new file mode 100644 index 0000000000..81e795a3ce --- /dev/null +++ b/source4/utils/net/net_join.c @@ -0,0 +1,108 @@ +/* + Samba Unix/Linux SMB client library + Distributed SMB/CIFS Server Management Utility + + Copyright (C) 2004 Stefan Metzmacher (metze@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 2 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, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" +#include "utils/net/net.h" +#include "libnet/libnet.h" +#include "librpc/gen_ndr/ndr_samr.h" + +static int net_join_domain(struct net_context *ctx, int argc, const char **argv) +{ + NTSTATUS status; + struct libnet_context *libnetctx; + union libnet_JoinDomain r; + char *tmp; + const char *domain_name; + + switch (argc) { + case 0: /* no args -> fail */ + DEBUG(0,("net_join_domain: no args\n")); + return -1; + case 1: /* only DOMAIN */ + tmp = talloc_strdup(ctx->mem_ctx, argv[0]); + break; + default: /* too mayn args -> fail */ + DEBUG(0,("net_join_domain: too many args [%d]\n",argc)); + return -1; + } + + domain_name = tmp; + + libnetctx = libnet_context_init(); + if (!libnetctx) { + return -1; + } + libnetctx->user.account_name = ctx->user.account_name; + libnetctx->user.domain_name = ctx->user.domain_name; + libnetctx->user.password = ctx->user.password; + + /* prepare password change */ + r.generic.level = LIBNET_JOIN_DOMAIN_GENERIC; + r.generic.in.domain_name = domain_name; + r.generic.in.account_name = talloc_asprintf(ctx->mem_ctx, "%s$", lp_netbios_name()); + r.generic.in.acct_type = ACB_SVRTRUST; + + /* do the domain join */ + status = libnet_JoinDomain(libnetctx, ctx->mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0,("net_join_domain: %s\n",r.generic.out.error_string)); + return -1; + } + + libnet_context_destroy(&libnetctx); + + return 0; +} + +static int net_join_domain_usage(struct net_context *ctx, int argc, const char **argv) +{ + d_printf("net_join_domain_usage: TODO\n"); + return 0; +} + +static int net_join_domain_help(struct net_context *ctx, int argc, const char **argv) +{ + d_printf("net_join_domain_help: TODO\n"); + return 0; +} + +static const struct net_functable net_password_functable[] = { + {"domain", net_join_domain, net_join_domain_usage, net_join_domain_help}, + {NULL, NULL} +}; + +int net_join(struct net_context *ctx, int argc, const char **argv) +{ + + return net_run_function(ctx, argc, argv, net_password_functable, net_password_usage); +} + +int net_join_usage(struct net_context *ctx, int argc, const char **argv) +{ + d_printf("net_password_usage: TODO\n"); + return 0; +} + +int net_join_help(struct net_context *ctx, int argc, const char **argv) +{ + d_printf("net_password_help: TODO\n"); + return 0; +} -- cgit From 8799d6b44c15a5e11c1e3528092fbca236561253 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 15 Jan 2005 22:13:18 +0000 Subject: r4762: Store the results of a 'net join' in the LDB. Like Samba3, the storage of the primary domain password is keyed off the domain name, so we can join multiple domains, and just swap 'workgroup =' around. Andrew Bartlett (This used to be commit 54a231780e028c6433cac296f2fbc64e39632dfd) --- source4/utils/net/net_join.c | 61 ++++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 34 deletions(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net_join.c b/source4/utils/net/net_join.c index 81e795a3ce..b88c11023e 100644 --- a/source4/utils/net/net_join.c +++ b/source4/utils/net/net_join.c @@ -2,7 +2,8 @@ Samba Unix/Linux SMB client library Distributed SMB/CIFS Server Management Utility - Copyright (C) 2004 Stefan Metzmacher (metze@samba.org) + Copyright (C) 2004 Stefan Metzmacher + Copyright (C) 2005 Andrew Bartlett 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 @@ -24,13 +25,15 @@ #include "libnet/libnet.h" #include "librpc/gen_ndr/ndr_samr.h" -static int net_join_domain(struct net_context *ctx, int argc, const char **argv) +int net_join(struct net_context *ctx, int argc, const char **argv) { + NTSTATUS status; struct libnet_context *libnetctx; - union libnet_JoinDomain r; + union libnet_Join r; char *tmp; const char *domain_name; + enum netr_SchannelType secure_channel_type = SEC_CHAN_WKSTA; switch (argc) { case 0: /* no args -> fail */ @@ -39,8 +42,19 @@ static int net_join_domain(struct net_context *ctx, int argc, const char **argv) case 1: /* only DOMAIN */ tmp = talloc_strdup(ctx->mem_ctx, argv[0]); break; - default: /* too mayn args -> fail */ - DEBUG(0,("net_join_domain: too many args [%d]\n",argc)); + case 2: /* DOMAIN and role */ + tmp = talloc_strdup(ctx->mem_ctx, argv[0]); + if (strcasecmp(argv[1], "BDC") == 0) { + secure_channel_type = SEC_CHAN_BDC; + } else if (strcasecmp(argv[1], "MEMBER") == 0) { + secure_channel_type = SEC_CHAN_WKSTA; + } else { + DEBUG(0, ("net_join: 2nd argument must be MEMBER or BDC\n")); + return -1; + } + break; + default: /* too many args -> fail */ + DEBUG(0,("net_join: too many args [%d]\n",argc)); return -1; } @@ -55,15 +69,17 @@ static int net_join_domain(struct net_context *ctx, int argc, const char **argv) libnetctx->user.password = ctx->user.password; /* prepare password change */ - r.generic.level = LIBNET_JOIN_DOMAIN_GENERIC; - r.generic.in.domain_name = domain_name; - r.generic.in.account_name = talloc_asprintf(ctx->mem_ctx, "%s$", lp_netbios_name()); - r.generic.in.acct_type = ACB_SVRTRUST; + r.generic.level = LIBNET_JOIN_GENERIC; + r.generic.in.domain_name = domain_name; + r.generic.in.secure_channel_type = secure_channel_type; + r.generic.out.error_string = NULL; /* do the domain join */ - status = libnet_JoinDomain(libnetctx, ctx->mem_ctx, &r); + status = libnet_Join(libnetctx, ctx->mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { - DEBUG(0,("net_join_domain: %s\n",r.generic.out.error_string)); + DEBUG(0,("libnet_Join returned %s: %s\n", + nt_errstr(status), + r.generic.out.error_string)); return -1; } @@ -72,29 +88,6 @@ static int net_join_domain(struct net_context *ctx, int argc, const char **argv) return 0; } -static int net_join_domain_usage(struct net_context *ctx, int argc, const char **argv) -{ - d_printf("net_join_domain_usage: TODO\n"); - return 0; -} - -static int net_join_domain_help(struct net_context *ctx, int argc, const char **argv) -{ - d_printf("net_join_domain_help: TODO\n"); - return 0; -} - -static const struct net_functable net_password_functable[] = { - {"domain", net_join_domain, net_join_domain_usage, net_join_domain_help}, - {NULL, NULL} -}; - -int net_join(struct net_context *ctx, int argc, const char **argv) -{ - - return net_run_function(ctx, argc, argv, net_password_functable, net_password_usage); -} - int net_join_usage(struct net_context *ctx, int argc, const char **argv) { d_printf("net_password_usage: TODO\n"); -- cgit From 759da3b915e2006d4c87b5ace47f399accd9ce91 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 27 Jan 2005 07:08:20 +0000 Subject: r5037: got rid of all of the TALLOC_DEPRECATED stuff. My apologies for the large commit. I thought this was worthwhile to get done for consistency. (This used to be commit ec32b22ed5ec224f6324f5e069d15e92e38e15c0) --- source4/utils/net/net.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net.c b/source4/utils/net/net.c index 350ec251d9..7b716f0916 100644 --- a/source4/utils/net/net.c +++ b/source4/utils/net/net.c @@ -210,7 +210,7 @@ static int binary_net(int argc, const char **argv) net_init_subsystems; mem_ctx = talloc_init("net_context"); - ctx = talloc_p(mem_ctx, struct net_context); + ctx = talloc(mem_ctx, struct net_context); if (!ctx) { d_printf("talloc_init(net_context) failed\n"); exit(1); @@ -228,7 +228,7 @@ static int binary_net(int argc, const char **argv) DEBUG(0,("return code = %d\n", rc)); } - talloc_destroy(mem_ctx); + talloc_free(mem_ctx); return rc; } -- cgit From e82aad1ce39a6b7a2e51b9e2cb494d74ec70e158 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 10 Feb 2005 05:09:35 +0000 Subject: r5298: - got rid of pstring.h from includes.h. This at least makes it a bit less likely that anyone will use pstring for new code - got rid of winbind_client.h from includes.h. This one triggered a huge change, as winbind_client.h was including system/filesys.h and defining the old uint32 and uint16 types, as well as its own pstring and fstring. (This used to be commit 9db6c79e902ec538108d6b7d3324039aabe1704f) --- source4/utils/net/net_password.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net_password.c b/source4/utils/net/net_password.c index 8828b960ee..773e18d661 100644 --- a/source4/utils/net/net_password.c +++ b/source4/utils/net/net_password.c @@ -22,6 +22,7 @@ #include "includes.h" #include "utils/net/net.h" #include "libnet/libnet.h" +#include "system/filesys.h" #include "system/passwd.h" /* -- cgit From 75ddf59ea110117578acd3a7b889549bfb40473c Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 10 Feb 2005 07:39:14 +0000 Subject: r5308: trimmed back a lot of the old macros from smb_macros.h (This used to be commit bf43c9bdcf9e654d123f6a2b29feb9189ca9e561) --- source4/utils/net/net_time.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net_time.c b/source4/utils/net/net_time.c index d2df76bc5d..ec3bc0519f 100644 --- a/source4/utils/net/net_time.c +++ b/source4/utils/net/net_time.c @@ -64,7 +64,7 @@ int net_time(struct net_context *ctx, int argc, const char **argv) return -1; } - ZERO_ARRAY(timestr); + ZERO_STRUCT(timestr); tm = localtime(&r.generic.out.time); strftime(timestr, sizeof(timestr)-1, "%c %Z",tm); -- cgit From 1ad9bed79de62bc5a29fe4c3193b1cc0b78def0e Mon Sep 17 00:00:00 2001 From: Rafal Szczesniak Date: Mon, 14 Feb 2005 00:58:30 +0000 Subject: r5380: Removed extra newline. rafal (This used to be commit d8fa9baf24852d87fcffee8bf353604b4507683d) --- source4/utils/net/net_join.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net_join.c b/source4/utils/net/net_join.c index b88c11023e..cb093ef9ff 100644 --- a/source4/utils/net/net_join.c +++ b/source4/utils/net/net_join.c @@ -27,7 +27,6 @@ int net_join(struct net_context *ctx, int argc, const char **argv) { - NTSTATUS status; struct libnet_context *libnetctx; union libnet_Join r; -- cgit From 082a5684738e7b9fce7466d7e7519816605b0958 Mon Sep 17 00:00:00 2001 From: Rafal Szczesniak Date: Mon, 14 Feb 2005 00:59:52 +0000 Subject: r5381: Added net_user.c with net tool interface for managing user accounts. rafal (This used to be commit 3005f0408c647fcab65c11de9bf680f7f5831492) --- source4/utils/net/config.mk | 3 +- source4/utils/net/net.c | 1 + source4/utils/net/net_user.c | 95 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 source4/utils/net/net_user.c (limited to 'source4/utils/net') diff --git a/source4/utils/net/config.mk b/source4/utils/net/config.mk index e1bc813bec..14b4683b9f 100644 --- a/source4/utils/net/config.mk +++ b/source4/utils/net/config.mk @@ -7,7 +7,8 @@ OBJ_FILES = \ utils/net/net.o \ utils/net/net_password.o \ utils/net/net_time.o \ - utils/net/net_join.o + utils/net/net_join.o \ + utils/net/net_user.o REQUIRED_SUBSYSTEMS = \ CONFIG \ LIBCMDLINE \ diff --git a/source4/utils/net/net.c b/source4/utils/net/net.c index 7b716f0916..63f19624f0 100644 --- a/source4/utils/net/net.c +++ b/source4/utils/net/net.c @@ -140,6 +140,7 @@ static const struct net_functable net_functable[] = { {"password", net_password, net_password_usage, net_password_help}, {"time", net_time, net_time_usage, net_time_help}, {"join", net_join, net_join_usage, net_join_help}, + {"user", net_user, net_user_usage, net_user_help}, {"help", net_help, net_help_usage, net_help}, {NULL, NULL} }; diff --git a/source4/utils/net/net_user.c b/source4/utils/net/net_user.c new file mode 100644 index 0000000000..a28d774d36 --- /dev/null +++ b/source4/utils/net/net_user.c @@ -0,0 +1,95 @@ +/* + Samba Unix/Linux SMB client library + Distributed SMB/CIFS Server Management Utility + + Copyright (C) Rafal Szczesniak 2005 + + 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 2 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, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" +#include "utils/net/net.h" +#include "libnet/libnet.h" +#include "librpc/gen_ndr/ndr_samr.h" + +static int net_user_add(struct net_context *ctx, int argc, const char **argv) +{ + NTSTATUS status; + struct libnet_context *lnet_ctx; + union libnet_CreateUser r; + char *user_name; + + /* command line argument preparation */ + switch (argc) { + case 0: + return net_user_usage(ctx, argc, argv); + break; + case 1: + user_name = talloc_strdup(ctx->mem_ctx, argv[0]); + break; + default: + return net_user_usage(ctx, argc, argv); + } + + /* libnet context init and its params */ + lnet_ctx = libnet_context_init(); + if (!lnet_ctx) return -1; + + lnet_ctx->user.domain_name = ctx->user.domain_name; + lnet_ctx->user.account_name = ctx->user.account_name; + lnet_ctx->user.password = ctx->user.password; + + /* calling CreateUser function */ + r.generic.level = LIBNET_CREATE_USER_GENERIC; + r.generic.in.user_name = user_name; + r.generic.in.domain_name = lnet_ctx->user.domain_name; + + status = libnet_CreateUser(lnet_ctx, ctx->mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0, ("Failed to add user account: %s\n", + r.generic.out.error_string)); + return -1; + } + + libnet_context_destroy(&lnet_ctx); + return 0; +} + + +static const struct net_functable net_user_functable[] = { + { "add", net_user_add, net_user_usage, net_user_help }, + { NULL, NULL } +}; + + +int net_user(struct net_context *ctx, int argc, const char **argv) +{ + return net_run_function(ctx, argc, argv, net_user_functable, net_user_usage); +} + + +int net_user_help(struct net_context *ctx, int argc, const char **argv) +{ + d_printf("User accounts management:\n"); + d_printf("\t\tadd\t creates new account\n"); + return 0; +} + + +int net_user_usage(struct net_context *ctx, int argc, const char **argv) +{ + d_printf("net user [options]\n"); + return 0; +} -- cgit From 530d46f6748a17ca8500a861f53c0d4f451b2005 Mon Sep 17 00:00:00 2001 From: Rafal Szczesniak Date: Tue, 15 Feb 2005 01:11:20 +0000 Subject: r5400: Slightly better handling of help messages in net tool. rafal (This used to be commit 5cebb4feedf7d6542c497fe55763d66f51b1c989) --- source4/utils/net/net_join.c | 12 +++++------- source4/utils/net/net_password.c | 13 +++++++------ source4/utils/net/net_time.c | 8 +++----- source4/utils/net/net_user.c | 5 +++-- 4 files changed, 18 insertions(+), 20 deletions(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net_join.c b/source4/utils/net/net_join.c index cb093ef9ff..6183da87b5 100644 --- a/source4/utils/net/net_join.c +++ b/source4/utils/net/net_join.c @@ -36,8 +36,7 @@ int net_join(struct net_context *ctx, int argc, const char **argv) switch (argc) { case 0: /* no args -> fail */ - DEBUG(0,("net_join_domain: no args\n")); - return -1; + return net_join_usage(ctx, argc, argv); case 1: /* only DOMAIN */ tmp = talloc_strdup(ctx->mem_ctx, argv[0]); break; @@ -49,12 +48,11 @@ int net_join(struct net_context *ctx, int argc, const char **argv) secure_channel_type = SEC_CHAN_WKSTA; } else { DEBUG(0, ("net_join: 2nd argument must be MEMBER or BDC\n")); - return -1; + return net_join_usage(ctx, argc, argv); } break; default: /* too many args -> fail */ - DEBUG(0,("net_join: too many args [%d]\n",argc)); - return -1; + return net_join_usage(ctx, argc, argv); } domain_name = tmp; @@ -89,12 +87,12 @@ int net_join(struct net_context *ctx, int argc, const char **argv) int net_join_usage(struct net_context *ctx, int argc, const char **argv) { - d_printf("net_password_usage: TODO\n"); + d_printf("net join [BDC | MEMBER] [options]\n"); return 0; } int net_join_help(struct net_context *ctx, int argc, const char **argv) { - d_printf("net_password_help: TODO\n"); + d_printf("Joins domain as either member or backup domain controller.\n"); return 0; } diff --git a/source4/utils/net/net_password.c b/source4/utils/net/net_password.c index 773e18d661..fdc1a2e9a0 100644 --- a/source4/utils/net/net_password.c +++ b/source4/utils/net/net_password.c @@ -29,7 +29,6 @@ * Code for Changing and setting a password */ - static int net_password_change(struct net_context *ctx, int argc, const char **argv) { NTSTATUS status; @@ -99,8 +98,7 @@ static int net_password_set(struct net_context *ctx, int argc, const char **argv switch (argc) { case 0: /* no args -> fail */ - DEBUG(0,("net_password_set: no args\n")); - return -1; + return net_password_usage(ctx, argc, argv); case 1: /* only DOM\\user; prompt for password */ tmp = talloc_strdup(ctx->mem_ctx, argv[0]); break; @@ -110,7 +108,7 @@ static int net_password_set(struct net_context *ctx, int argc, const char **argv break; default: /* too mayn args -> fail */ DEBUG(0,("net_password_set: too many args [%d]\n",argc)); - return -1; + return net_password_usage(ctx, argc, argv); } if ((p = strchr_m(tmp,'\\'))) { @@ -169,6 +167,7 @@ static int net_password_set_help(struct net_context *ctx, int argc, const char * static const struct net_functable net_password_functable[] = { {"change", net_password_change, net_password_change_usage, net_password_change_help}, {"set", net_password_set, net_password_set_usage, net_password_set_help}, + {"help", net_password_help, net_password_help, net_password_help}, {NULL, NULL} }; @@ -179,12 +178,14 @@ int net_password(struct net_context *ctx, int argc, const char **argv) int net_password_usage(struct net_context *ctx, int argc, const char **argv) { - d_printf("net_password_usage: TODO\n"); + d_printf("net password [options]\n"); return 0; } int net_password_help(struct net_context *ctx, int argc, const char **argv) { - d_printf("net_password_help: TODO\n"); + d_printf("Account password handling:\n"); + d_printf("\tchange\t\tchanges password (old password required)\n"); + d_printf("\tset\t\tsets password\n"); return 0; } diff --git a/source4/utils/net/net_time.c b/source4/utils/net/net_time.c index ec3bc0519f..ce7db4ab5c 100644 --- a/source4/utils/net/net_time.c +++ b/source4/utils/net/net_time.c @@ -28,7 +28,6 @@ * Code for getting the remote time */ - int net_time(struct net_context *ctx, int argc, const char **argv) { NTSTATUS status; @@ -41,8 +40,7 @@ int net_time(struct net_context *ctx, int argc, const char **argv) if (argc > 0 && argv[0]) { server_name = argv[0]; } else { - DEBUG(0,("net_time: server name needed!\n")); - return -1; + return net_time_usage(ctx, argc, argv); } libnetctx = libnet_context_init(); @@ -77,12 +75,12 @@ int net_time(struct net_context *ctx, int argc, const char **argv) int net_time_usage(struct net_context *ctx, int argc, const char **argv) { - d_printf("net_time_usage: TODO\n"); + d_printf("net time [options]\n"); return 0; } int net_time_help(struct net_context *ctx, int argc, const char **argv) { - d_printf("net_time_help: TODO\n"); + d_printf("Displays remote server's time.\n"); return 0; } diff --git a/source4/utils/net/net_user.c b/source4/utils/net/net_user.c index a28d774d36..845eed0665 100644 --- a/source4/utils/net/net_user.c +++ b/source4/utils/net/net_user.c @@ -69,7 +69,8 @@ static int net_user_add(struct net_context *ctx, int argc, const char **argv) static const struct net_functable net_user_functable[] = { - { "add", net_user_add, net_user_usage, net_user_help }, + { "add", net_user_add, net_user_usage, net_user_help }, + { "help", net_user_help, net_user_usage, net_user_help }, { NULL, NULL } }; @@ -83,7 +84,7 @@ int net_user(struct net_context *ctx, int argc, const char **argv) int net_user_help(struct net_context *ctx, int argc, const char **argv) { d_printf("User accounts management:\n"); - d_printf("\t\tadd\t creates new account\n"); + d_printf("\tadd\t\tcreates new account\n"); return 0; } -- cgit From 16f64ae6d6a9ea0ec14ec124c097787ccb320864 Mon Sep 17 00:00:00 2001 From: Rafal Szczesniak Date: Wed, 16 Feb 2005 21:50:38 +0000 Subject: r5423: Change function table structure to allow short description of command groups. Also give up help function pointer in the structure since it's needed only in leaf nodes of command tree, and leaf nodes decide about help on their own. Usage function is still available on all levels. rafal (This used to be commit 48568959a86ee60c188b84078eb3872b8e185b6c) --- source4/utils/net/net.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net.h b/source4/utils/net/net.h index ba8294c144..2967063bde 100644 --- a/source4/utils/net/net.h +++ b/source4/utils/net/net.h @@ -33,9 +33,9 @@ struct net_context { struct net_functable { const char *name; + const char *desc; int (*fn)(struct net_context *ctx, int argc, const char **argv); int (*usage)(struct net_context *ctx, int argc, const char **argv); - int (*help)(struct net_context *ctx, int argc, const char **argv); }; #endif /* _UTIL_NET_H */ -- cgit From a19b2e84f81baaa24651a44076ce2c62056135e9 Mon Sep 17 00:00:00 2001 From: Rafal Szczesniak Date: Wed, 16 Feb 2005 21:51:37 +0000 Subject: r5424: Automatically generate basic help display on basis of name and description from function table. rafal (This used to be commit 24f7a3860e82bf632ebd6b3416e5e874e832be5f) --- source4/utils/net/net.c | 81 +++++++++++++++++++------------------------------ 1 file changed, 31 insertions(+), 50 deletions(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net.c b/source4/utils/net/net.c index 63f19624f0..fb87a5a6d9 100644 --- a/source4/utils/net/net.c +++ b/source4/utils/net/net.c @@ -57,9 +57,11 @@ int net_run_function(struct net_context *ctx, { int i; - if (argc < 1) { - d_printf("Usage: \n"); + if (argc == 0) { return usage_fn(ctx, argc, argv); + + } else if (argc == 1 && strequal(argv[0], "help")) { + return net_help(ctx, functable); } for (i=0; functable[i].name; i++) { @@ -79,12 +81,12 @@ int net_run_usage(struct net_context *ctx, const struct net_functable *functable) { int i; - +/* if (argc < 1) { d_printf("net_run_usage: TODO (argc < 1)\n"); return 1; } - +*/ for (i=0; functable[i].name; i++) { if (StrCaseCmp(argv[0], functable[i].name) == 0) if (functable[i].usage) { @@ -92,62 +94,42 @@ int net_run_usage(struct net_context *ctx, } } - d_printf("No usage for command: %s\n", argv[0]); + d_printf("No usage information for command: %s\n", argv[0]); return 1; } -/* - run a usage function from a function table. If not found then fail -*/ -int net_run_help(struct net_context *ctx, - int argc, const char **argv, - const struct net_functable *functable) -{ - int i; - if (argc < 1) { - d_printf("net_run_help: TODO (argc < 1)\n"); - return 1; - } +/* main function table */ +static const struct net_functable net_functable[] = { + {"password", "change password\n", net_password, net_password_usage}, + {"time", "get remote server's time\n", net_time, net_time_usage}, + {"join", "join a domain\n", net_join, net_join_usage}, + {"user", "manage user accounts\n", net_user, net_user_usage}, + {NULL, NULL, NULL, NULL} +}; - for (i=0; functable[i].name; i++) { - if (StrCaseCmp(argv[0], functable[i].name) == 0) - if (functable[i].help) { - return functable[i].help(ctx, argc-1, argv+1); - } +int net_help(struct net_context *ctx, const struct net_functable *ftable) +{ + int i = 0; + const char *name = ftable[i].name; + const char *desc = ftable[i].desc; + + d_printf("Available commands:\n"); + while (name && desc) { + d_printf("\t%s\t\t%s", name, desc); + name = ftable[++i].name; + desc = ftable[i].desc; } - d_printf("No help for command: %s\n", argv[0]); - - return 1; -} - -static int net_help(struct net_context *ctx, int argc, const char **argv) -{ - d_printf("net_help: TODO\n"); return 0; } -static int net_help_usage(struct net_context *ctx, int argc, const char **argv) -{ - d_printf("net_help_usage: TODO\n"); - return 0; -} - -/* main function table */ -static const struct net_functable net_functable[] = { - {"password", net_password, net_password_usage, net_password_help}, - {"time", net_time, net_time_usage, net_time_help}, - {"join", net_join, net_join_usage, net_join_help}, - {"user", net_user, net_user_usage, net_user_help}, - {"help", net_help, net_help_usage, net_help}, - {NULL, NULL} -}; - static int net_usage(struct net_context *ctx, int argc, const char **argv) { - return net_run_usage(ctx, argc, argv, net_functable); + d_printf("Usage:\n"); + d_printf("net [options]\n"); + return 0; } /**************************************************************************** @@ -185,7 +167,7 @@ static int binary_net(int argc, const char **argv) default: d_printf("Invalid option %s: %s\n", poptBadOption(pc, 0), poptStrerror(opt)); - net_help(ctx, argc, argv); + net_usage(ctx, argc, argv); exit(1); } } @@ -204,8 +186,7 @@ static int binary_net(int argc, const char **argv) } if (argc_new < 2) { - d_printf("Usage: TODO\n"); - return 1; + return net_usage(ctx, argc, argv); } net_init_subsystems; -- cgit From 308c7d26c1f9f91ff6667430a8a1a7b4cf4a3a7e Mon Sep 17 00:00:00 2001 From: Rafal Szczesniak Date: Wed, 16 Feb 2005 21:54:01 +0000 Subject: r5425: Convert function tables to new structure (with description) and remove unnecessary help functions as help is generated automatically. Usage functions with precise information about usage of each leaf node remain. rafal (This used to be commit eb66180d14a14cafbfc0df2b39eeaf4ad7bb43a9) --- source4/utils/net/net_password.c | 43 ++++++++++++---------------------------- source4/utils/net/net_time.c | 6 ------ source4/utils/net/net_user.c | 11 +--------- 3 files changed, 14 insertions(+), 46 deletions(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net_password.c b/source4/utils/net/net_password.c index fdc1a2e9a0..ee0376989d 100644 --- a/source4/utils/net/net_password.c +++ b/source4/utils/net/net_password.c @@ -29,6 +29,13 @@ * Code for Changing and setting a password */ +static int net_password_change_usage(struct net_context *ctx, int argc, const char **argv) +{ + d_printf("net_password_change_usage: TODO\n"); + return 0; +} + + static int net_password_change(struct net_context *ctx, int argc, const char **argv) { NTSTATUS status; @@ -72,18 +79,14 @@ static int net_password_change(struct net_context *ctx, int argc, const char **a return 0; } -static int net_password_change_usage(struct net_context *ctx, int argc, const char **argv) -{ - d_printf("net_password_change_usage: TODO\n"); - return 0; -} -static int net_password_change_help(struct net_context *ctx, int argc, const char **argv) +static int net_password_set_usage(struct net_context *ctx, int argc, const char **argv) { - d_printf("net_password_change_help: TODO\n"); + d_printf("net_password_set_usage: TODO\n"); return 0; } + static int net_password_set(struct net_context *ctx, int argc, const char **argv) { NTSTATUS status; @@ -98,7 +101,7 @@ static int net_password_set(struct net_context *ctx, int argc, const char **argv switch (argc) { case 0: /* no args -> fail */ - return net_password_usage(ctx, argc, argv); + return net_password_set_usage(ctx, argc, argv); case 1: /* only DOM\\user; prompt for password */ tmp = talloc_strdup(ctx->mem_ctx, argv[0]); break; @@ -152,22 +155,10 @@ static int net_password_set(struct net_context *ctx, int argc, const char **argv return 0; } -static int net_password_set_usage(struct net_context *ctx, int argc, const char **argv) -{ - d_printf("net_password_set_usage: TODO\n"); - return 0; -} - -static int net_password_set_help(struct net_context *ctx, int argc, const char **argv) -{ - d_printf("net_password_set_help: TODO\n"); - return 0; -} static const struct net_functable net_password_functable[] = { - {"change", net_password_change, net_password_change_usage, net_password_change_help}, - {"set", net_password_set, net_password_set_usage, net_password_set_help}, - {"help", net_password_help, net_password_help, net_password_help}, + {"change", "change password (old password required)\n", net_password_change, net_password_change_usage }, + {"set", "set password\n", net_password_set, net_password_set_usage }, {NULL, NULL} }; @@ -181,11 +172,3 @@ int net_password_usage(struct net_context *ctx, int argc, const char **argv) d_printf("net password [options]\n"); return 0; } - -int net_password_help(struct net_context *ctx, int argc, const char **argv) -{ - d_printf("Account password handling:\n"); - d_printf("\tchange\t\tchanges password (old password required)\n"); - d_printf("\tset\t\tsets password\n"); - return 0; -} diff --git a/source4/utils/net/net_time.c b/source4/utils/net/net_time.c index ce7db4ab5c..5f318ac4ea 100644 --- a/source4/utils/net/net_time.c +++ b/source4/utils/net/net_time.c @@ -78,9 +78,3 @@ int net_time_usage(struct net_context *ctx, int argc, const char **argv) d_printf("net time [options]\n"); return 0; } - -int net_time_help(struct net_context *ctx, int argc, const char **argv) -{ - d_printf("Displays remote server's time.\n"); - return 0; -} diff --git a/source4/utils/net/net_user.c b/source4/utils/net/net_user.c index 845eed0665..4a472e6997 100644 --- a/source4/utils/net/net_user.c +++ b/source4/utils/net/net_user.c @@ -69,8 +69,7 @@ static int net_user_add(struct net_context *ctx, int argc, const char **argv) static const struct net_functable net_user_functable[] = { - { "add", net_user_add, net_user_usage, net_user_help }, - { "help", net_user_help, net_user_usage, net_user_help }, + { "add", "create new user account\n", net_user_add, net_user_usage }, { NULL, NULL } }; @@ -81,14 +80,6 @@ int net_user(struct net_context *ctx, int argc, const char **argv) } -int net_user_help(struct net_context *ctx, int argc, const char **argv) -{ - d_printf("User accounts management:\n"); - d_printf("\tadd\t\tcreates new account\n"); - return 0; -} - - int net_user_usage(struct net_context *ctx, int argc, const char **argv) { d_printf("net user [options]\n"); -- cgit From 02075be0bbc2095073f8898350fded64a7c97c79 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 21 Mar 2005 02:08:38 +0000 Subject: r5917: First step in using the new cli_credentials structure. This patch puts support for it into popt_common, adds a few utility functions (in lib/credentials.c) and the callback functions for the command-line (lib/cmdline/credentials.c). Comments are welcome :-) (This used to be commit 1d49b57c50fe8c2683ea23e9df41ce8ad774db98) --- source4/utils/net/net.c | 4 +--- source4/utils/net/net.h | 6 +----- source4/utils/net/net_join.c | 6 +++--- source4/utils/net/net_password.c | 23 ++++++++++++----------- source4/utils/net/net_time.c | 6 +++--- source4/utils/net/net_user.c | 6 +++--- 6 files changed, 23 insertions(+), 28 deletions(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net.c b/source4/utils/net/net.c index fb87a5a6d9..96ae23c7e4 100644 --- a/source4/utils/net/net.c +++ b/source4/utils/net/net.c @@ -200,9 +200,7 @@ static int binary_net(int argc, const char **argv) ZERO_STRUCTP(ctx); ctx->mem_ctx = mem_ctx; - ctx->user.account_name = talloc_strdup(ctx->mem_ctx, cmdline_get_username()); - ctx->user.domain_name = talloc_strdup(ctx->mem_ctx, cmdline_get_userdomain()); - ctx->user.password = talloc_strdup(ctx->mem_ctx, cmdline_get_userpassword()); + ctx->credentials = cmdline_credentials; rc = net_run_function(ctx, argc_new-1, argv_new+1, net_functable, net_usage); diff --git a/source4/utils/net/net.h b/source4/utils/net/net.h index 2967063bde..6f3aa1086b 100644 --- a/source4/utils/net/net.h +++ b/source4/utils/net/net.h @@ -24,11 +24,7 @@ struct net_context { TALLOC_CTX *mem_ctx; - struct { - const char *account_name; - const char *domain_name; - const char *password; - } user; + struct cli_credentials *credentials; }; struct net_functable { diff --git a/source4/utils/net/net_join.c b/source4/utils/net/net_join.c index 6183da87b5..3a0a52cab5 100644 --- a/source4/utils/net/net_join.c +++ b/source4/utils/net/net_join.c @@ -61,9 +61,9 @@ int net_join(struct net_context *ctx, int argc, const char **argv) if (!libnetctx) { return -1; } - libnetctx->user.account_name = ctx->user.account_name; - libnetctx->user.domain_name = ctx->user.domain_name; - libnetctx->user.password = ctx->user.password; + libnetctx->user.account_name= cli_credentials_get_username(ctx->credentials); + libnetctx->user.domain_name = cli_credentials_get_domain(ctx->credentials); + libnetctx->user.password = cli_credentials_get_password(ctx->credentials); /* prepare password change */ r.generic.level = LIBNET_JOIN_GENERIC; diff --git a/source4/utils/net/net_password.c b/source4/utils/net/net_password.c index ee0376989d..a68c0b1c6a 100644 --- a/source4/utils/net/net_password.c +++ b/source4/utils/net/net_password.c @@ -48,7 +48,8 @@ static int net_password_change(struct net_context *ctx, int argc, const char **a new_password = argv[0]; } else { password_prompt = talloc_asprintf(ctx->mem_ctx, "Enter new password for account [%s\\%s]:", - ctx->user.domain_name, ctx->user.account_name); + cli_credentials_get_domain(ctx->credentials), + cli_credentials_get_username(ctx->credentials)); new_password = getpass(password_prompt); } @@ -56,15 +57,15 @@ static int net_password_change(struct net_context *ctx, int argc, const char **a if (!libnetctx) { return -1; } - libnetctx->user.account_name = ctx->user.account_name; - libnetctx->user.domain_name = ctx->user.domain_name; - libnetctx->user.password = ctx->user.password; + libnetctx->user.account_name= cli_credentials_get_username(ctx->credentials); + libnetctx->user.domain_name = cli_credentials_get_domain(ctx->credentials); + libnetctx->user.password = cli_credentials_get_password(ctx->credentials); /* prepare password change */ r.generic.level = LIBNET_CHANGE_PASSWORD_GENERIC; - r.generic.in.account_name = ctx->user.account_name; - r.generic.in.domain_name = ctx->user.domain_name; - r.generic.in.oldpassword = ctx->user.password; + r.generic.in.account_name = cli_credentials_get_username(ctx->credentials); + r.generic.in.domain_name = cli_credentials_get_domain(ctx->credentials); + r.generic.in.oldpassword = cli_credentials_get_password(ctx->credentials); r.generic.in.newpassword = new_password; /* do password change */ @@ -120,7 +121,7 @@ static int net_password_set(struct net_context *ctx, int argc, const char **argv account_name = talloc_strdup(ctx->mem_ctx, p+1); } else { account_name = tmp; - domain_name = ctx->user.domain_name; + domain_name = cli_credentials_get_domain(ctx->credentials); } if (!new_password) { @@ -133,9 +134,9 @@ static int net_password_set(struct net_context *ctx, int argc, const char **argv if (!libnetctx) { return -1; } - libnetctx->user.account_name = ctx->user.account_name; - libnetctx->user.domain_name = ctx->user.domain_name; - libnetctx->user.password = ctx->user.password; + libnetctx->user.account_name= cli_credentials_get_username(ctx->credentials); + libnetctx->user.domain_name = cli_credentials_get_domain(ctx->credentials); + libnetctx->user.password = cli_credentials_get_password(ctx->credentials); /* prepare password change */ r.generic.level = LIBNET_SET_PASSWORD_GENERIC; diff --git a/source4/utils/net/net_time.c b/source4/utils/net/net_time.c index 5f318ac4ea..df3b52a4ab 100644 --- a/source4/utils/net/net_time.c +++ b/source4/utils/net/net_time.c @@ -47,9 +47,9 @@ int net_time(struct net_context *ctx, int argc, const char **argv) if (!libnetctx) { return -1; } - libnetctx->user.account_name = ctx->user.account_name; - libnetctx->user.domain_name = ctx->user.domain_name; - libnetctx->user.password = ctx->user.password; + libnetctx->user.account_name= cli_credentials_get_username(ctx->credentials); + libnetctx->user.domain_name = cli_credentials_get_domain(ctx->credentials); + libnetctx->user.password = cli_credentials_get_password(ctx->credentials); /* prepare to get the time */ r.generic.level = LIBNET_REMOTE_TOD_GENERIC; diff --git a/source4/utils/net/net_user.c b/source4/utils/net/net_user.c index 4a472e6997..82f80b9e60 100644 --- a/source4/utils/net/net_user.c +++ b/source4/utils/net/net_user.c @@ -47,9 +47,9 @@ static int net_user_add(struct net_context *ctx, int argc, const char **argv) lnet_ctx = libnet_context_init(); if (!lnet_ctx) return -1; - lnet_ctx->user.domain_name = ctx->user.domain_name; - lnet_ctx->user.account_name = ctx->user.account_name; - lnet_ctx->user.password = ctx->user.password; + lnet_ctx->user.domain_name = cli_credentials_get_domain(ctx->credentials); + lnet_ctx->user.account_name = cli_credentials_get_username(ctx->credentials); + lnet_ctx->user.password = cli_credentials_get_password(ctx->credentials); /* calling CreateUser function */ r.generic.level = LIBNET_CREATE_USER_GENERIC; -- cgit From 34cde065139fdc76f6aa529426cfc1f68a394d54 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 21 Mar 2005 18:42:32 +0000 Subject: r5924: Use cli_credentials in libnet/. (This used to be commit e5bc6f4f1716568ae7022d61b5b35ee047b58414) --- source4/utils/net/net_join.c | 4 +--- source4/utils/net/net_password.c | 8 ++------ source4/utils/net/net_time.c | 4 +--- source4/utils/net/net_user.c | 6 ++---- 4 files changed, 6 insertions(+), 16 deletions(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net_join.c b/source4/utils/net/net_join.c index 3a0a52cab5..212b8270ff 100644 --- a/source4/utils/net/net_join.c +++ b/source4/utils/net/net_join.c @@ -61,9 +61,7 @@ int net_join(struct net_context *ctx, int argc, const char **argv) if (!libnetctx) { return -1; } - libnetctx->user.account_name= cli_credentials_get_username(ctx->credentials); - libnetctx->user.domain_name = cli_credentials_get_domain(ctx->credentials); - libnetctx->user.password = cli_credentials_get_password(ctx->credentials); + libnetctx->credentials = ctx->credentials; /* prepare password change */ r.generic.level = LIBNET_JOIN_GENERIC; diff --git a/source4/utils/net/net_password.c b/source4/utils/net/net_password.c index a68c0b1c6a..08660fe2a0 100644 --- a/source4/utils/net/net_password.c +++ b/source4/utils/net/net_password.c @@ -57,9 +57,7 @@ static int net_password_change(struct net_context *ctx, int argc, const char **a if (!libnetctx) { return -1; } - libnetctx->user.account_name= cli_credentials_get_username(ctx->credentials); - libnetctx->user.domain_name = cli_credentials_get_domain(ctx->credentials); - libnetctx->user.password = cli_credentials_get_password(ctx->credentials); + libnetctx->credentials = ctx->credentials; /* prepare password change */ r.generic.level = LIBNET_CHANGE_PASSWORD_GENERIC; @@ -134,9 +132,7 @@ static int net_password_set(struct net_context *ctx, int argc, const char **argv if (!libnetctx) { return -1; } - libnetctx->user.account_name= cli_credentials_get_username(ctx->credentials); - libnetctx->user.domain_name = cli_credentials_get_domain(ctx->credentials); - libnetctx->user.password = cli_credentials_get_password(ctx->credentials); + libnetctx->credentials = ctx->credentials; /* prepare password change */ r.generic.level = LIBNET_SET_PASSWORD_GENERIC; diff --git a/source4/utils/net/net_time.c b/source4/utils/net/net_time.c index df3b52a4ab..a89f80417c 100644 --- a/source4/utils/net/net_time.c +++ b/source4/utils/net/net_time.c @@ -47,9 +47,7 @@ int net_time(struct net_context *ctx, int argc, const char **argv) if (!libnetctx) { return -1; } - libnetctx->user.account_name= cli_credentials_get_username(ctx->credentials); - libnetctx->user.domain_name = cli_credentials_get_domain(ctx->credentials); - libnetctx->user.password = cli_credentials_get_password(ctx->credentials); + libnetctx->credentials = ctx->credentials; /* prepare to get the time */ r.generic.level = LIBNET_REMOTE_TOD_GENERIC; diff --git a/source4/utils/net/net_user.c b/source4/utils/net/net_user.c index 82f80b9e60..40e821bf83 100644 --- a/source4/utils/net/net_user.c +++ b/source4/utils/net/net_user.c @@ -47,14 +47,12 @@ static int net_user_add(struct net_context *ctx, int argc, const char **argv) lnet_ctx = libnet_context_init(); if (!lnet_ctx) return -1; - lnet_ctx->user.domain_name = cli_credentials_get_domain(ctx->credentials); - lnet_ctx->user.account_name = cli_credentials_get_username(ctx->credentials); - lnet_ctx->user.password = cli_credentials_get_password(ctx->credentials); + lnet_ctx->credentials = ctx->credentials; /* calling CreateUser function */ r.generic.level = LIBNET_CREATE_USER_GENERIC; r.generic.in.user_name = user_name; - r.generic.in.domain_name = lnet_ctx->user.domain_name; + r.generic.in.domain_name = cli_credentials_get_domain(lnet_ctx->credentials); status = libnet_CreateUser(lnet_ctx, ctx->mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { -- cgit From 8bf57cf8f57be28831023c2218d358b24b705256 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 2 May 2005 14:17:19 +0000 Subject: r6573: Start on my project to implement an NT4 compatible BDC in Samba4. This brings in a compatability layer for Samba3 in Samba4 - where we will start to define file formats and similar details. The 'net samdump' command uses 'password server = ' for now, and performs a similar task to Samba3's 'net rpc samsync'. Andrew Bartlett (This used to be commit 550f17f9924fe783917318753de7d1a388423908) --- source4/utils/net/config.mk | 1 + source4/utils/net/net.c | 1 + source4/utils/net/net_vampire.c | 68 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+) create mode 100644 source4/utils/net/net_vampire.c (limited to 'source4/utils/net') diff --git a/source4/utils/net/config.mk b/source4/utils/net/config.mk index 14b4683b9f..f68cf68c8c 100644 --- a/source4/utils/net/config.mk +++ b/source4/utils/net/config.mk @@ -8,6 +8,7 @@ OBJ_FILES = \ utils/net/net_password.o \ utils/net/net_time.o \ utils/net/net_join.o \ + utils/net/net_vampire.o \ utils/net/net_user.o REQUIRED_SUBSYSTEMS = \ CONFIG \ diff --git a/source4/utils/net/net.c b/source4/utils/net/net.c index 96ae23c7e4..c7c6f7dec9 100644 --- a/source4/utils/net/net.c +++ b/source4/utils/net/net.c @@ -105,6 +105,7 @@ static const struct net_functable net_functable[] = { {"password", "change password\n", net_password, net_password_usage}, {"time", "get remote server's time\n", net_time, net_time_usage}, {"join", "join a domain\n", net_join, net_join_usage}, + {"samdump", "dump the sam of a domain\n", net_samdump, net_samdump_usage}, {"user", "manage user accounts\n", net_user, net_user_usage}, {NULL, NULL, NULL, NULL} }; diff --git a/source4/utils/net/net_vampire.c b/source4/utils/net/net_vampire.c new file mode 100644 index 0000000000..df2d84746b --- /dev/null +++ b/source4/utils/net/net_vampire.c @@ -0,0 +1,68 @@ +/* + Samba Unix/Linux SMB client library + Distributed SMB/CIFS Server Management Utility + + Copyright (C) 2004 Stefan Metzmacher + Copyright (C) 2005 Andrew Bartlett + + 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 2 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, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" +#include "utils/net/net.h" +#include "libnet/libnet.h" +#include "librpc/gen_ndr/ndr_samr.h" + +int net_samdump(struct net_context *ctx, int argc, const char **argv) +{ + NTSTATUS status; + struct libnet_context *libnetctx; + union libnet_SamDump r; + + libnetctx = libnet_context_init(); + if (!libnetctx) { + return -1; + } + libnetctx->credentials = ctx->credentials; + + /* prepare password change */ + r.generic.level = LIBNET_SAMDUMP_GENERIC; + r.generic.error_string = NULL; + + /* do the domain join */ + status = libnet_SamDump(libnetctx, ctx->mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0,("libnet_SamDump returned %s: %s\n", + nt_errstr(status), + r.generic.error_string)); + return -1; + } + + libnet_context_destroy(&libnetctx); + + return 0; +} + +int net_samdump_usage(struct net_context *ctx, int argc, const char **argv) +{ + d_printf("net samdump\n"); + return 0; +} + +int net_samdump_help(struct net_context *ctx, int argc, const char **argv) +{ + d_printf("Dumps the sam of the domain we are joined to.\n"); + return 0; +} -- cgit From 0a40093ef39a46b9df82d6d0486b70b354d9dde5 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 3 Jun 2005 21:30:07 +0000 Subject: r7249: Cope with struct member rename (This used to be commit e7549f33f5fb06d8b2a8f31745545cc7b9c8d4f9) --- source4/utils/net/net_join.c | 2 +- source4/utils/net/net_password.c | 4 ++-- source4/utils/net/net_time.c | 2 +- source4/utils/net/net_user.c | 4 ++-- source4/utils/net/net_vampire.c | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net_join.c b/source4/utils/net/net_join.c index 212b8270ff..717a9364a5 100644 --- a/source4/utils/net/net_join.c +++ b/source4/utils/net/net_join.c @@ -61,7 +61,7 @@ int net_join(struct net_context *ctx, int argc, const char **argv) if (!libnetctx) { return -1; } - libnetctx->credentials = ctx->credentials; + libnetctx->cred = ctx->credentials; /* prepare password change */ r.generic.level = LIBNET_JOIN_GENERIC; diff --git a/source4/utils/net/net_password.c b/source4/utils/net/net_password.c index 08660fe2a0..68fe9223a1 100644 --- a/source4/utils/net/net_password.c +++ b/source4/utils/net/net_password.c @@ -57,7 +57,7 @@ static int net_password_change(struct net_context *ctx, int argc, const char **a if (!libnetctx) { return -1; } - libnetctx->credentials = ctx->credentials; + libnetctx->cred = ctx->credentials; /* prepare password change */ r.generic.level = LIBNET_CHANGE_PASSWORD_GENERIC; @@ -132,7 +132,7 @@ static int net_password_set(struct net_context *ctx, int argc, const char **argv if (!libnetctx) { return -1; } - libnetctx->credentials = ctx->credentials; + libnetctx->cred = ctx->credentials; /* prepare password change */ r.generic.level = LIBNET_SET_PASSWORD_GENERIC; diff --git a/source4/utils/net/net_time.c b/source4/utils/net/net_time.c index a89f80417c..507cfd5f6d 100644 --- a/source4/utils/net/net_time.c +++ b/source4/utils/net/net_time.c @@ -47,7 +47,7 @@ int net_time(struct net_context *ctx, int argc, const char **argv) if (!libnetctx) { return -1; } - libnetctx->credentials = ctx->credentials; + libnetctx->cred = ctx->credentials; /* prepare to get the time */ r.generic.level = LIBNET_REMOTE_TOD_GENERIC; diff --git a/source4/utils/net/net_user.c b/source4/utils/net/net_user.c index 40e821bf83..690b393e50 100644 --- a/source4/utils/net/net_user.c +++ b/source4/utils/net/net_user.c @@ -47,12 +47,12 @@ static int net_user_add(struct net_context *ctx, int argc, const char **argv) lnet_ctx = libnet_context_init(); if (!lnet_ctx) return -1; - lnet_ctx->credentials = ctx->credentials; + lnet_ctx->cred = ctx->credentials; /* calling CreateUser function */ r.generic.level = LIBNET_CREATE_USER_GENERIC; r.generic.in.user_name = user_name; - r.generic.in.domain_name = cli_credentials_get_domain(lnet_ctx->credentials); + r.generic.in.domain_name = cli_credentials_get_domain(lnet_ctx->cred); status = libnet_CreateUser(lnet_ctx, ctx->mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { diff --git a/source4/utils/net/net_vampire.c b/source4/utils/net/net_vampire.c index df2d84746b..5a17544e82 100644 --- a/source4/utils/net/net_vampire.c +++ b/source4/utils/net/net_vampire.c @@ -35,7 +35,7 @@ int net_samdump(struct net_context *ctx, int argc, const char **argv) if (!libnetctx) { return -1; } - libnetctx->credentials = ctx->credentials; + libnetctx->cred = ctx->credentials; /* prepare password change */ r.generic.level = LIBNET_SAMDUMP_GENERIC; -- cgit From 9bbfe84cb9a405e710a174b0ddac273d154fa861 Mon Sep 17 00:00:00 2001 From: Rafal Szczesniak Date: Tue, 7 Jun 2005 23:26:13 +0000 Subject: r7382: Convert net_user code so that is can be compiled against changed CreateUser call. Doesn't work yet, but the test passes. rafal (This used to be commit a50ebd4a16ac141214cc24b3390da78a209b4284) --- source4/utils/net/net_user.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net_user.c b/source4/utils/net/net_user.c index 690b393e50..b1bf85d6f2 100644 --- a/source4/utils/net/net_user.c +++ b/source4/utils/net/net_user.c @@ -28,7 +28,7 @@ static int net_user_add(struct net_context *ctx, int argc, const char **argv) { NTSTATUS status; struct libnet_context *lnet_ctx; - union libnet_CreateUser r; + struct libnet_CreateUser r; char *user_name; /* command line argument preparation */ @@ -50,14 +50,14 @@ static int net_user_add(struct net_context *ctx, int argc, const char **argv) lnet_ctx->cred = ctx->credentials; /* calling CreateUser function */ - r.generic.level = LIBNET_CREATE_USER_GENERIC; - r.generic.in.user_name = user_name; - r.generic.in.domain_name = cli_credentials_get_domain(lnet_ctx->cred); + r.level = LIBNET_CREATE_USER_GENERIC; + r.in.user_name = user_name; + r.in.domain_name = cli_credentials_get_domain(lnet_ctx->cred); status = libnet_CreateUser(lnet_ctx, ctx->mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { DEBUG(0, ("Failed to add user account: %s\n", - r.generic.out.error_string)); + r.out.error_string)); return -1; } -- cgit From 2b4791ae733488845b2c36bca64db695203de571 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 13 Jun 2005 08:12:39 +0000 Subject: r7525: Unify lp_load(), load_interfaces and logging setup into popt(). There is now a new --debug-stderr option to enable debug to STDERR. popt isn't perfect, but the callbacks are used in all the main Samba binaries, and should be used in the rest. This avoids duplicated code, and ensures every binary is setup correctly. This also ensures the setup happens early enough to have -s function, and have a correct impact on the credentials code. (Fixing a bug that frustrated tridge earlier today). The only 'subtle' aspect of all this is that I'm pretty sure that the SAMBA_COMMON popt code must be above the CREDENTIALS code, in the popt tables. Andrew Bartlett (This used to be commit 50f3c2b3a22971f40e0d3a88127b5120bfc47591) --- source4/utils/net/net.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net.c b/source4/utils/net/net.c index c7c6f7dec9..51b860234d 100644 --- a/source4/utils/net/net.c +++ b/source4/utils/net/net.c @@ -154,14 +154,12 @@ static int binary_net(int argc, const char **argv) POPT_TABLEEND }; - setup_logging("net", DEBUG_STDOUT); - #ifdef HAVE_SETBUFFER setbuffer(stdout, NULL, 0); #endif pc = poptGetContext("net", argc, (const char **) argv, long_options, - POPT_CONTEXT_KEEP_FIRST); + POPT_CONTEXT_KEEP_FIRST); while((opt = poptGetNextOpt(pc)) != -1) { switch (opt) { @@ -173,9 +171,6 @@ static int binary_net(int argc, const char **argv) } } - lp_load(dyn_CONFIGFILE,True,False,False); - load_interfaces(); - argv_new = (const char **)poptGetArgs(pc); argc_new = argc; -- cgit From af237084ecd4f9928c6c282b9c5c73598d5c73d6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 16 Jun 2005 11:36:09 +0000 Subject: r7633: this patch started as an attempt to make the dcerpc code use a given event_context for the socket_connect() call, so that when things that use dcerpc are running alongside anything else it doesn't block the whole process during a connect. Then of course I needed to change any code that created a dcerpc connection (such as the auth code) to also take an event context, and anything that called that and so on .... thus the size of the patch. There were 3 places where I punted: - abartlet wanted me to add a gensec_set_event_context() call instead of adding it to the gensec init calls. Andrew, my apologies for not doing this. I didn't do it as adding a new parameter allowed me to catch all the callers with the compiler. Now that its done, we could go back and use gensec_set_event_context() - the ejs code calls auth initialisation, which means it should pass in the event context from the web server. I punted on that. Needs fixing. - I used a NULL event context in dcom_get_pipe(). This is equivalent to what we did already, but should be fixed to use a callers event context. Jelmer, can you think of a clean way to do that? I also cleaned up a couple of things: - libnet_context_destroy() makes no sense. I removed it. - removed some unused vars in various places (This used to be commit 3a3025485bdb8f600ab528c0b4b4eef0c65e3fc9) --- source4/utils/net/net_join.c | 4 ++-- source4/utils/net/net_password.c | 8 ++++---- source4/utils/net/net_time.c | 4 ++-- source4/utils/net/net_user.c | 4 ++-- source4/utils/net/net_vampire.c | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net_join.c b/source4/utils/net/net_join.c index 717a9364a5..7f9ab0c635 100644 --- a/source4/utils/net/net_join.c +++ b/source4/utils/net/net_join.c @@ -57,7 +57,7 @@ int net_join(struct net_context *ctx, int argc, const char **argv) domain_name = tmp; - libnetctx = libnet_context_init(); + libnetctx = libnet_context_init(NULL); if (!libnetctx) { return -1; } @@ -78,7 +78,7 @@ int net_join(struct net_context *ctx, int argc, const char **argv) return -1; } - libnet_context_destroy(&libnetctx); + talloc_free(libnetctx); return 0; } diff --git a/source4/utils/net/net_password.c b/source4/utils/net/net_password.c index 68fe9223a1..1912beeb41 100644 --- a/source4/utils/net/net_password.c +++ b/source4/utils/net/net_password.c @@ -53,7 +53,7 @@ static int net_password_change(struct net_context *ctx, int argc, const char **a new_password = getpass(password_prompt); } - libnetctx = libnet_context_init(); + libnetctx = libnet_context_init(NULL); if (!libnetctx) { return -1; } @@ -73,7 +73,7 @@ static int net_password_change(struct net_context *ctx, int argc, const char **a return -1; } - libnet_context_destroy(&libnetctx); + talloc_free(libnetctx); return 0; } @@ -128,7 +128,7 @@ static int net_password_set(struct net_context *ctx, int argc, const char **argv new_password = getpass(password_prompt); } - libnetctx = libnet_context_init(); + libnetctx = libnet_context_init(NULL); if (!libnetctx) { return -1; } @@ -147,7 +147,7 @@ static int net_password_set(struct net_context *ctx, int argc, const char **argv return -1; } - libnet_context_destroy(&libnetctx); + talloc_free(libnetctx); return 0; } diff --git a/source4/utils/net/net_time.c b/source4/utils/net/net_time.c index 507cfd5f6d..8bdef1f762 100644 --- a/source4/utils/net/net_time.c +++ b/source4/utils/net/net_time.c @@ -43,7 +43,7 @@ int net_time(struct net_context *ctx, int argc, const char **argv) return net_time_usage(ctx, argc, argv); } - libnetctx = libnet_context_init(); + libnetctx = libnet_context_init(NULL); if (!libnetctx) { return -1; } @@ -66,7 +66,7 @@ int net_time(struct net_context *ctx, int argc, const char **argv) printf("%s\n",timestr); - libnet_context_destroy(&libnetctx); + talloc_free(libnetctx); return 0; } diff --git a/source4/utils/net/net_user.c b/source4/utils/net/net_user.c index b1bf85d6f2..dabb4a0d61 100644 --- a/source4/utils/net/net_user.c +++ b/source4/utils/net/net_user.c @@ -44,7 +44,7 @@ static int net_user_add(struct net_context *ctx, int argc, const char **argv) } /* libnet context init and its params */ - lnet_ctx = libnet_context_init(); + lnet_ctx = libnet_context_init(NULL); if (!lnet_ctx) return -1; lnet_ctx->cred = ctx->credentials; @@ -61,7 +61,7 @@ static int net_user_add(struct net_context *ctx, int argc, const char **argv) return -1; } - libnet_context_destroy(&lnet_ctx); + talloc_free(lnet_ctx); return 0; } diff --git a/source4/utils/net/net_vampire.c b/source4/utils/net/net_vampire.c index 5a17544e82..e60fd85a7d 100644 --- a/source4/utils/net/net_vampire.c +++ b/source4/utils/net/net_vampire.c @@ -31,7 +31,7 @@ int net_samdump(struct net_context *ctx, int argc, const char **argv) struct libnet_context *libnetctx; union libnet_SamDump r; - libnetctx = libnet_context_init(); + libnetctx = libnet_context_init(NULL); if (!libnetctx) { return -1; } @@ -50,7 +50,7 @@ int net_samdump(struct net_context *ctx, int argc, const char **argv) return -1; } - libnet_context_destroy(&libnetctx); + talloc_free(libnetctx); return 0; } -- cgit From 27ab60f5d406adee641d7a288822ba4c34eed416 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 25 Jul 2005 04:15:57 +0000 Subject: r8748: fixed build. Andrew, please check. (This used to be commit 9411bd4e5e7ac9fd0aacd1432de967eda45e64f4) --- source4/utils/net/net_vampire.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net_vampire.c b/source4/utils/net/net_vampire.c index e60fd85a7d..72f791db66 100644 --- a/source4/utils/net/net_vampire.c +++ b/source4/utils/net/net_vampire.c @@ -29,7 +29,7 @@ int net_samdump(struct net_context *ctx, int argc, const char **argv) { NTSTATUS status; struct libnet_context *libnetctx; - union libnet_SamDump r; + struct libnet_SamDump r; libnetctx = libnet_context_init(NULL); if (!libnetctx) { @@ -37,16 +37,14 @@ int net_samdump(struct net_context *ctx, int argc, const char **argv) } libnetctx->cred = ctx->credentials; - /* prepare password change */ - r.generic.level = LIBNET_SAMDUMP_GENERIC; - r.generic.error_string = NULL; + r.level = LIBNET_SAMDUMP_GENERIC; + r.error_string = NULL; - /* do the domain join */ status = libnet_SamDump(libnetctx, ctx->mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { DEBUG(0,("libnet_SamDump returned %s: %s\n", nt_errstr(status), - r.generic.error_string)); + r.error_string)); return -1; } -- cgit From 6d26a7114f233418b17b76c3e8dc73086a901ed7 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 25 Jul 2005 06:33:51 +0000 Subject: r8752: With all the infrustructure done, details like a SamSync migration into LDB are actually quite easy. This brings us the users, and sets basic domain information. You are expected to have provisioned with the settings for the target domain, and have joined the domain as a BDC. Then simply 'net samsync'. Now we just need to flesh out the delta types. Andrew Bartlett (This used to be commit 1e0f7792bb29b17c23197a5e42ee8cabb0cf17d0) --- source4/utils/net/net.c | 1 + source4/utils/net/net_vampire.c | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net.c b/source4/utils/net/net.c index 51b860234d..787f71705b 100644 --- a/source4/utils/net/net.c +++ b/source4/utils/net/net.c @@ -106,6 +106,7 @@ static const struct net_functable net_functable[] = { {"time", "get remote server's time\n", net_time, net_time_usage}, {"join", "join a domain\n", net_join, net_join_usage}, {"samdump", "dump the sam of a domain\n", net_samdump, net_samdump_usage}, + {"samsync", "syncrosnise into the local ldb the sam of a domain\n", net_samsync_ldb, net_samsync_ldb_usage}, {"user", "manage user accounts\n", net_user, net_user_usage}, {NULL, NULL, NULL, NULL} }; diff --git a/source4/utils/net/net_vampire.c b/source4/utils/net/net_vampire.c index 72f791db66..e898352cfc 100644 --- a/source4/utils/net/net_vampire.c +++ b/source4/utils/net/net_vampire.c @@ -64,3 +64,43 @@ int net_samdump_help(struct net_context *ctx, int argc, const char **argv) d_printf("Dumps the sam of the domain we are joined to.\n"); return 0; } + +int net_samsync_ldb(struct net_context *ctx, int argc, const char **argv) +{ + NTSTATUS status; + struct libnet_context *libnetctx; + struct libnet_samsync_ldb r; + + libnetctx = libnet_context_init(NULL); + if (!libnetctx) { + return -1; + } + libnetctx->cred = ctx->credentials; + + r.level = LIBNET_SAMSYNC_LDB_GENERIC; + r.error_string = NULL; + + status = libnet_samsync_ldb(libnetctx, ctx->mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0,("libnet_samsync_ldb returned %s: %s\n", + nt_errstr(status), + r.error_string)); + return -1; + } + + talloc_free(libnetctx); + + return 0; +} + +int net_samsync_ldb_usage(struct net_context *ctx, int argc, const char **argv) +{ + d_printf("net samsync_ldb\n"); + return 0; +} + +int net_samsync_ldb_help(struct net_context *ctx, int argc, const char **argv) +{ + d_printf("Syncrosnise into the local ldb the SAM of a domain.\n"); + return 0; +} -- cgit From 6cec8025b05595d60c23d70f34db9e65ca21b89d Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 29 Jul 2005 10:58:05 +0000 Subject: r8847: Rework the Samba4 'net join' code. I'm trying to get this closer to what WinXP does when joining an AD domain, but in the meantime this removes the excess unions, and uses the LSA pipe in same way XP does. Andrew Bartlett (This used to be commit d2789c426090c325f6535cdce380ac0f4e22c3c7) --- source4/utils/net/net_join.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net_join.c b/source4/utils/net/net_join.c index 7f9ab0c635..a1455ef036 100644 --- a/source4/utils/net/net_join.c +++ b/source4/utils/net/net_join.c @@ -29,7 +29,7 @@ int net_join(struct net_context *ctx, int argc, const char **argv) { NTSTATUS status; struct libnet_context *libnetctx; - union libnet_Join r; + struct libnet_Join r; char *tmp; const char *domain_name; enum netr_SchannelType secure_channel_type = SEC_CHAN_WKSTA; @@ -64,17 +64,16 @@ int net_join(struct net_context *ctx, int argc, const char **argv) libnetctx->cred = ctx->credentials; /* prepare password change */ - r.generic.level = LIBNET_JOIN_GENERIC; - r.generic.in.domain_name = domain_name; - r.generic.in.secure_channel_type = secure_channel_type; - r.generic.out.error_string = NULL; + r.in.domain_name = domain_name; + r.in.secure_channel_type = secure_channel_type; + r.out.error_string = NULL; /* do the domain join */ status = libnet_Join(libnetctx, ctx->mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { DEBUG(0,("libnet_Join returned %s: %s\n", nt_errstr(status), - r.generic.out.error_string)); + r.out.error_string)); return -1; } -- cgit From 9f611ffddeced5661b81fbe6264502a0d59f187b Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 3 Aug 2005 00:08:28 +0000 Subject: r8966: Simplify the makefile generation system a bit. Autogenerate list of binaries (rather then having them hardcoded in build/smb_build/makefile.pm) Add INSTALLDIR keyword to .mk files (This used to be commit ce0935112b846486cf705ec69f12350be9c4c89d) --- source4/utils/net/config.mk | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/utils/net') diff --git a/source4/utils/net/config.mk b/source4/utils/net/config.mk index f68cf68c8c..2f455d381f 100644 --- a/source4/utils/net/config.mk +++ b/source4/utils/net/config.mk @@ -3,6 +3,7 @@ ################################# # Start BINARY net [BINARY::net] +INSTALLDIR = BINDIR OBJ_FILES = \ utils/net/net.o \ utils/net/net_password.o \ -- cgit From 24186a80eb4887b5fb3e72e4b877b456cbe8e35f Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 29 Aug 2005 04:30:22 +0000 Subject: r9728: A *major* update to the credentials system, to incorporate the Kerberos CCACHE into the system. This again allows the use of the system ccache when no username is specified, and brings more code in common between gensec_krb5 and gensec_gssapi. It also has a side-effect that may (or may not) be expected: If there is a ccache, even if it is not used (perhaps the remote server didn't want kerberos), it will change the default username. Andrew Bartlett (This used to be commit 6202267f6ec1446d6bd11d1d37d05a977bc8d315) --- source4/utils/net/net_password.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net_password.c b/source4/utils/net/net_password.c index 1912beeb41..0bfb8a5be8 100644 --- a/source4/utils/net/net_password.c +++ b/source4/utils/net/net_password.c @@ -49,7 +49,7 @@ static int net_password_change(struct net_context *ctx, int argc, const char **a } else { password_prompt = talloc_asprintf(ctx->mem_ctx, "Enter new password for account [%s\\%s]:", cli_credentials_get_domain(ctx->credentials), - cli_credentials_get_username(ctx->credentials)); + cli_credentials_get_username(ctx->credentials, ctx->mem_ctx)); new_password = getpass(password_prompt); } @@ -61,7 +61,7 @@ static int net_password_change(struct net_context *ctx, int argc, const char **a /* prepare password change */ r.generic.level = LIBNET_CHANGE_PASSWORD_GENERIC; - r.generic.in.account_name = cli_credentials_get_username(ctx->credentials); + r.generic.in.account_name = cli_credentials_get_username(ctx->credentials, ctx->mem_ctx); r.generic.in.domain_name = cli_credentials_get_domain(ctx->credentials); r.generic.in.oldpassword = cli_credentials_get_password(ctx->credentials); r.generic.in.newpassword = new_password; -- cgit From b674411eb46c9e45f2740a1f9bac365e9a347e9c Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 30 Aug 2005 11:55:05 +0000 Subject: r9792: Rename StrCaseCmp -> strcasecmp_m. All these years I was thinking StrCaseCmp was sys_strcasecmp, while it is in fact strcasecmp_m! (This used to be commit 200a8f6652cb2de7a8037a7a4c2a204b50aee2b1) --- source4/utils/net/net.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net.c b/source4/utils/net/net.c index 787f71705b..b6f54a46ce 100644 --- a/source4/utils/net/net.c +++ b/source4/utils/net/net.c @@ -65,7 +65,7 @@ int net_run_function(struct net_context *ctx, } for (i=0; functable[i].name; i++) { - if (StrCaseCmp(argv[0], functable[i].name) == 0) + if (strcasecmp_m(argv[0], functable[i].name) == 0) return functable[i].fn(ctx, argc-1, argv+1); } @@ -88,7 +88,7 @@ int net_run_usage(struct net_context *ctx, } */ for (i=0; functable[i].name; i++) { - if (StrCaseCmp(argv[0], functable[i].name) == 0) + if (strcasecmp_m(argv[0], functable[i].name) == 0) if (functable[i].usage) { return functable[i].usage(ctx, argc-1, argv+1); } -- cgit From d2a666acbe04f741387ff4351e3971b24f1c3b14 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 19 Sep 2005 13:26:07 +0000 Subject: r10316: More dynconfig fixes (This used to be commit 0963ab9c148772b961f17ec779213b0eb861e1dd) --- source4/utils/net/net.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net.c b/source4/utils/net/net.c index b6f54a46ce..132b3a1c03 100644 --- a/source4/utils/net/net.c +++ b/source4/utils/net/net.c @@ -42,7 +42,6 @@ /*****************************************************/ #include "includes.h" -#include "dynconfig.h" #include "utils/net/net.h" #include "lib/cmdline/popt_common.h" -- cgit From 51cbc188df03f9ee38599fe5a87ec2608117a845 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 22 Sep 2005 01:50:58 +0000 Subject: r10402: Make the RPC-SAMLOGON test pass against Win2k3 SP0 again. I still have issues with Win2k3 SP1, and Samba4 doesn't pass it's own test for the moment, but I'm working on these issues :-) This required a change to the credentials API, so that the special case for NTLM logins using a principal was indeed handled as a special, not general case. Also don't set the realm from a ccache, as then it overrides --option=realm=. Andrew Bartlett (This used to be commit 194e8f07c0cb4685797c5a7a074577c62dfdebe3) --- source4/utils/net/net_password.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net_password.c b/source4/utils/net/net_password.c index 0bfb8a5be8..1912beeb41 100644 --- a/source4/utils/net/net_password.c +++ b/source4/utils/net/net_password.c @@ -49,7 +49,7 @@ static int net_password_change(struct net_context *ctx, int argc, const char **a } else { password_prompt = talloc_asprintf(ctx->mem_ctx, "Enter new password for account [%s\\%s]:", cli_credentials_get_domain(ctx->credentials), - cli_credentials_get_username(ctx->credentials, ctx->mem_ctx)); + cli_credentials_get_username(ctx->credentials)); new_password = getpass(password_prompt); } @@ -61,7 +61,7 @@ static int net_password_change(struct net_context *ctx, int argc, const char **a /* prepare password change */ r.generic.level = LIBNET_CHANGE_PASSWORD_GENERIC; - r.generic.in.account_name = cli_credentials_get_username(ctx->credentials, ctx->mem_ctx); + r.generic.in.account_name = cli_credentials_get_username(ctx->credentials); r.generic.in.domain_name = cli_credentials_get_domain(ctx->credentials); r.generic.in.oldpassword = cli_credentials_get_password(ctx->credentials); r.generic.in.newpassword = new_password; -- cgit From 5a522b31003d50cf476ead83fb322abeb1525957 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sun, 25 Sep 2005 12:26:07 +0000 Subject: r10486: This is a merge of Brad Henry's 'net join' rework, to better perform an ADS join, particularly as a DC. This represents the bulk of his Google SOC work, and I'm very pleased to intergrate it into the tree. (Metze will intergrate the DRSUAPI work later). Both metze and myself have also put a lot of time into this patch, and in mentoring Brad in general. In return, Brad has been a very good student, and has taken the comments well. Since it's last appearance on samba-technical@, I have made correctness and valgrind fixups, as well as adding a new 'BINDING' mode to the libnet_rpc routines. This allows the exact binding string to be passed down from the torture code, including options and exact target host. Andrew Bartlett (This used to be commit d6fa105fdabbeb83a9b0e50dad49d1649afdb2a4) --- source4/utils/net/net_join.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net_join.c b/source4/utils/net/net_join.c index a1455ef036..cb2ed3006b 100644 --- a/source4/utils/net/net_join.c +++ b/source4/utils/net/net_join.c @@ -29,7 +29,7 @@ int net_join(struct net_context *ctx, int argc, const char **argv) { NTSTATUS status; struct libnet_context *libnetctx; - struct libnet_Join r; + struct libnet_Join *r; char *tmp; const char *domain_name; enum netr_SchannelType secure_channel_type = SEC_CHAN_WKSTA; @@ -62,23 +62,29 @@ int net_join(struct net_context *ctx, int argc, const char **argv) return -1; } libnetctx->cred = ctx->credentials; - + r = talloc(ctx->mem_ctx, struct libnet_Join); + if (!r) { + return -1; + } /* prepare password change */ - r.in.domain_name = domain_name; - r.in.secure_channel_type = secure_channel_type; - r.out.error_string = NULL; + r->in.netbios_name = lp_netbios_name(); + r->in.domain_name = domain_name; + r->in.secure_channel_type = secure_channel_type; + r->in.level = LIBNET_JOIN_AUTOMATIC; + r->out.error_string = NULL; /* do the domain join */ - status = libnet_Join(libnetctx, ctx->mem_ctx, &r); + status = libnet_Join(libnetctx, r, r); + if (!NT_STATUS_IS_OK(status)) { DEBUG(0,("libnet_Join returned %s: %s\n", nt_errstr(status), - r.out.error_string)); + r->out.error_string)); + talloc_free(r); + talloc_free(libnetctx); return -1; } - talloc_free(libnetctx); - return 0; } -- cgit From c690be462d6dcfc8bdad6749ae055f11d810c89f Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 4 Oct 2005 12:02:52 +0000 Subject: r10711: An error of 'user exists' is not an error, just an indication of how the join was processed. Andrew Bartlett (This used to be commit 0d93f11c894927a9ab69f7a31b9fbedde9d698b6) --- source4/utils/net/net_join.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net_join.c b/source4/utils/net/net_join.c index cb2ed3006b..8e9eb4d93e 100644 --- a/source4/utils/net/net_join.c +++ b/source4/utils/net/net_join.c @@ -76,7 +76,7 @@ int net_join(struct net_context *ctx, int argc, const char **argv) /* do the domain join */ status = libnet_Join(libnetctx, r, r); - if (!NT_STATUS_IS_OK(status)) { + if (!NT_STATUS_IS_OK(status) && !NT_STATUS_EQUAL(status, NT_STATUS_USER_EXISTS)) { DEBUG(0,("libnet_Join returned %s: %s\n", nt_errstr(status), r->out.error_string)); -- cgit From 4c5a4a7e0288e9ac0b2f795befd5684059e4c429 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 21 Oct 2005 16:29:54 +0000 Subject: r11244: Relative path names in .mk files (This used to be commit 24e10300906c380919d2d631bfb3b8fd6b3f54ba) --- source4/utils/net/config.mk | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/config.mk b/source4/utils/net/config.mk index 2f455d381f..382906f349 100644 --- a/source4/utils/net/config.mk +++ b/source4/utils/net/config.mk @@ -5,12 +5,12 @@ [BINARY::net] INSTALLDIR = BINDIR OBJ_FILES = \ - utils/net/net.o \ - utils/net/net_password.o \ - utils/net/net_time.o \ - utils/net/net_join.o \ - utils/net/net_vampire.o \ - utils/net/net_user.o + net.o \ + net_password.o \ + net_time.o \ + net_join.o \ + net_vampire.o \ + net_user.o REQUIRED_SUBSYSTEMS = \ CONFIG \ LIBCMDLINE \ -- cgit From 221c1512a8b4de9a568c0a0cdafa97ab5c53368c Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 21 Dec 2005 22:02:52 +0000 Subject: r12411: Add 'net samdump keytab '. This extracts a remote windows domain into a keytab, suitable for use in ethereal for kerberos decryption. For the moment, like net samdump and net samsync, the 'password server' smb.conf option must be set to the binding string for the server. eg: password server = ncacn_np:mypdc Andrew Bartlett (This used to be commit 272013438f53bb168f74e09eb70fc96112b84772) --- source4/utils/net/net_vampire.c | 67 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net_vampire.c b/source4/utils/net/net_vampire.c index e898352cfc..75ad175c66 100644 --- a/source4/utils/net/net_vampire.c +++ b/source4/utils/net/net_vampire.c @@ -25,11 +25,77 @@ #include "libnet/libnet.h" #include "librpc/gen_ndr/ndr_samr.h" +static int net_samdump_keytab_usage(struct net_context *ctx, int argc, const char **argv) +{ + d_printf("net samdump keytab \n"); + return 0; +} + +static int net_samdump_keytab_help(struct net_context *ctx, int argc, const char **argv) +{ + d_printf("Dumps kerberos keys of a domain into a keytab.\n"); + return 0; +} + +static int net_samdump_keytab(struct net_context *ctx, int argc, const char **argv) +{ + NTSTATUS status; + struct libnet_context *libnetctx; + struct libnet_SamDump_keytab r; + + switch (argc) { + case 0: + return net_samdump_keytab_usage(ctx, argc, argv); + break; + case 1: + r.keytab_name = argv[0]; + break; + } + + libnetctx = libnet_context_init(NULL); + if (!libnetctx) { + return -1; + } + libnetctx->cred = ctx->credentials; + + r.level = LIBNET_SAMDUMP_GENERIC; + r.error_string = NULL; + + status = libnet_SamDump_keytab(libnetctx, ctx->mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0,("libnet_SamDump returned %s: %s\n", + nt_errstr(status), + r.error_string)); + return -1; + } + + talloc_free(libnetctx); + + return 0; +} + +/* main function table */ +static const struct net_functable net_samdump_functable[] = { + {"keytab", "dump keys into a keytab\n", net_samdump_keytab, net_samdump_keytab_usage}, + {NULL, NULL, NULL, NULL} +}; + int net_samdump(struct net_context *ctx, int argc, const char **argv) { NTSTATUS status; struct libnet_context *libnetctx; struct libnet_SamDump r; + int rc; + + switch (argc) { + case 0: + break; + case 1: + default: + rc = net_run_function(ctx, argc, argv, net_samdump_functable, + net_samdump_usage); + return rc; + } libnetctx = libnet_context_init(NULL); if (!libnetctx) { @@ -56,6 +122,7 @@ int net_samdump(struct net_context *ctx, int argc, const char **argv) int net_samdump_usage(struct net_context *ctx, int argc, const char **argv) { d_printf("net samdump\n"); + d_printf("net samdump keytab \n"); return 0; } -- cgit From 8e0948bbad959f8809a19e40e6777705013f866c Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 22 Dec 2005 06:47:00 +0000 Subject: r12421: Handle the case where we are a joining as different account types far better. Andrew Bartlett (This used to be commit 0ce82e8a41f0fdea9928e3e341680232cc640e18) --- source4/utils/net/net_join.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net_join.c b/source4/utils/net/net_join.c index 8e9eb4d93e..bec82c72d1 100644 --- a/source4/utils/net/net_join.c +++ b/source4/utils/net/net_join.c @@ -76,10 +76,9 @@ int net_join(struct net_context *ctx, int argc, const char **argv) /* do the domain join */ status = libnet_Join(libnetctx, r, r); - if (!NT_STATUS_IS_OK(status) && !NT_STATUS_EQUAL(status, NT_STATUS_USER_EXISTS)) { - DEBUG(0,("libnet_Join returned %s: %s\n", - nt_errstr(status), - r->out.error_string)); + if (!NT_STATUS_IS_OK(status)) { + d_printf("Joining domain failed: %s\n", + r->out.error_string ? r->out.error_string : nt_errstr(status)); talloc_free(r); talloc_free(libnetctx); return -1; -- cgit From 758873b9fb46c0c0059a95c6bdeb23b17f2c80c9 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 22 Dec 2005 06:58:26 +0000 Subject: r12423: Remove DEBUG(0) printouts in favor of more information to the caller. I assume this works better with SWAT and the like anyway. Andrew Bartlett (This used to be commit b11975703d5e32f6f3ad10079106b1345fa56b5c) --- source4/utils/net/net_join.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net_join.c b/source4/utils/net/net_join.c index bec82c72d1..8140108ceb 100644 --- a/source4/utils/net/net_join.c +++ b/source4/utils/net/net_join.c @@ -66,7 +66,7 @@ int net_join(struct net_context *ctx, int argc, const char **argv) if (!r) { return -1; } - /* prepare password change */ + /* prepare parameters for the join */ r->in.netbios_name = lp_netbios_name(); r->in.domain_name = domain_name; r->in.secure_channel_type = secure_channel_type; @@ -83,6 +83,8 @@ int net_join(struct net_context *ctx, int argc, const char **argv) talloc_free(libnetctx); return -1; } + d_printf("Joined domain %s (%s)\n", r->out.domain_name, dom_sid_string(ctx->mem_ctx, r->out.domain_sid)); + talloc_free(libnetctx); return 0; } -- cgit From 6aafed9600a3fa05932668c70fc0e20f3724dab6 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 26 Dec 2005 18:48:23 +0000 Subject: r12499: Move smb_build.h out of includes.h (This used to be commit c92ace494f92084ddf178626cdf392d151043bc7) --- source4/utils/net/net.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net.c b/source4/utils/net/net.c index 132b3a1c03..17b12b7103 100644 --- a/source4/utils/net/net.c +++ b/source4/utils/net/net.c @@ -44,6 +44,7 @@ #include "includes.h" #include "utils/net/net.h" #include "lib/cmdline/popt_common.h" +#include "smb_build.h" /* run a function from a function table. If not found then -- cgit From 2cd5ca7d25f12aa9198bf8c2deb6aea282f573ee Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 28 Dec 2005 15:38:36 +0000 Subject: r12542: Move some more prototypes out to seperate headers (This used to be commit 0aca5fd5130d980d07398f3291d294202aefe3c2) --- source4/utils/net/config.mk | 1 + source4/utils/net/net.h | 2 ++ 2 files changed, 3 insertions(+) (limited to 'source4/utils/net') diff --git a/source4/utils/net/config.mk b/source4/utils/net/config.mk index 382906f349..e9f7e6ef52 100644 --- a/source4/utils/net/config.mk +++ b/source4/utils/net/config.mk @@ -4,6 +4,7 @@ # Start BINARY net [BINARY::net] INSTALLDIR = BINDIR +PRIVATE_PROTO_HEADER = net_proto.h OBJ_FILES = \ net.o \ net_password.o \ diff --git a/source4/utils/net/net.h b/source4/utils/net/net.h index 6f3aa1086b..8d9c78c1a9 100644 --- a/source4/utils/net/net.h +++ b/source4/utils/net/net.h @@ -34,4 +34,6 @@ struct net_functable { int (*usage)(struct net_context *ctx, int argc, const char **argv); }; +#include "utils/net/net_proto.h" + #endif /* _UTIL_NET_H */ -- cgit From 46aa296cc94933082dbb4b9b2b1ed210a600ad2d Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 29 Dec 2005 23:14:33 +0000 Subject: r12592: Remove some useless dependencies (This used to be commit ca8db1a0cd77682ac2c6dc4718f5d753a4fcc4db) --- source4/utils/net/config.mk | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/config.mk b/source4/utils/net/config.mk index e9f7e6ef52..3d45bcec77 100644 --- a/source4/utils/net/config.mk +++ b/source4/utils/net/config.mk @@ -14,9 +14,10 @@ OBJ_FILES = \ net_user.o REQUIRED_SUBSYSTEMS = \ CONFIG \ - LIBCMDLINE \ LIBBASIC \ - LIBSMB \ - LIBNET + LIBNET \ + LIBPOPT \ + POPT_SAMBA \ + POPT_CREDENTIALS # End BINARY net ################################# -- cgit From d4de4c2d210d2e8c9b5aedf70695594809ad6a0b Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 30 Dec 2005 13:16:54 +0000 Subject: r12608: Remove some unused #include lines. (This used to be commit 70e7449318aa0e9d2639c76730a7d1683b2f4981) --- source4/utils/net/net_join.c | 1 - source4/utils/net/net_password.c | 1 - source4/utils/net/net_user.c | 1 - 3 files changed, 3 deletions(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net_join.c b/source4/utils/net/net_join.c index 8140108ceb..eaa53f4c7b 100644 --- a/source4/utils/net/net_join.c +++ b/source4/utils/net/net_join.c @@ -23,7 +23,6 @@ #include "includes.h" #include "utils/net/net.h" #include "libnet/libnet.h" -#include "librpc/gen_ndr/ndr_samr.h" int net_join(struct net_context *ctx, int argc, const char **argv) { diff --git a/source4/utils/net/net_password.c b/source4/utils/net/net_password.c index 1912beeb41..8f6b989a5d 100644 --- a/source4/utils/net/net_password.c +++ b/source4/utils/net/net_password.c @@ -23,7 +23,6 @@ #include "utils/net/net.h" #include "libnet/libnet.h" #include "system/filesys.h" -#include "system/passwd.h" /* * Code for Changing and setting a password diff --git a/source4/utils/net/net_user.c b/source4/utils/net/net_user.c index dabb4a0d61..82ee208534 100644 --- a/source4/utils/net/net_user.c +++ b/source4/utils/net/net_user.c @@ -22,7 +22,6 @@ #include "includes.h" #include "utils/net/net.h" #include "libnet/libnet.h" -#include "librpc/gen_ndr/ndr_samr.h" static int net_user_add(struct net_context *ctx, int argc, const char **argv) { -- cgit From aa9f67163cd2df2a815ef585edad1951343b82c8 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 30 Dec 2005 22:46:16 +0000 Subject: r12620: Get rid of automatically generated lists of init functions of subsystems. This allows Samba libraries to be used by other projects (and parts of Samba to be built as shared libraries). (This used to be commit 44f0aba715bfedc7e1ee3d07e9a101a91dbd84b3) --- source4/utils/net/net.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net.c b/source4/utils/net/net.c index 17b12b7103..f82eddb763 100644 --- a/source4/utils/net/net.c +++ b/source4/utils/net/net.c @@ -44,7 +44,6 @@ #include "includes.h" #include "utils/net/net.h" #include "lib/cmdline/popt_common.h" -#include "smb_build.h" /* run a function from a function table. If not found then @@ -186,7 +185,7 @@ static int binary_net(int argc, const char **argv) return net_usage(ctx, argc, argv); } - net_init_subsystems; + dcerpc_init(); mem_ctx = talloc_init("net_context"); ctx = talloc(mem_ctx, struct net_context); -- cgit From a5a79e8b8cbdf24d5c2db45ece4110ed5d85e58f Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 12 Jan 2006 09:33:49 +0000 Subject: r12865: Upgrade the librpc and libnet code. In librpc, always try SMB level authentication, even if trying schannel, but allow fallback to anonymous. This should better function with servers that set restrict anonymous. There are too many parts of Samba that get, parse and modify the binding parameters. Avoid the extra work, and add a binding element to the struct dcerpc_pipe The libnet vampire code has been refactored, to reduce extra layers and to better conform with the standard argument pattern. Also, take advantage of the new libnet_Lookup code, so we don't require the silly 'password server' smb.conf parameter. To better support forcing traffic to be sealed for the vampire operation, the dcerpc_bind_auth() function now takes an auth level parameter. Andrew Bartlett (This used to be commit d65b354959842326fdd4bd7eb7fbeea0390f4afa) --- source4/utils/net/net_vampire.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net_vampire.c b/source4/utils/net/net_vampire.c index 75ad175c66..f89739225d 100644 --- a/source4/utils/net/net_vampire.c +++ b/source4/utils/net/net_vampire.c @@ -48,7 +48,7 @@ static int net_samdump_keytab(struct net_context *ctx, int argc, const char **ar return net_samdump_keytab_usage(ctx, argc, argv); break; case 1: - r.keytab_name = argv[0]; + r.in.keytab_name = argv[0]; break; } @@ -58,14 +58,15 @@ static int net_samdump_keytab(struct net_context *ctx, int argc, const char **ar } libnetctx->cred = ctx->credentials; - r.level = LIBNET_SAMDUMP_GENERIC; - r.error_string = NULL; + r.out.error_string = NULL; + r.in.machine_account = NULL; + r.in.binding_string = NULL; status = libnet_SamDump_keytab(libnetctx, ctx->mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { DEBUG(0,("libnet_SamDump returned %s: %s\n", nt_errstr(status), - r.error_string)); + r.out.error_string)); return -1; } @@ -103,14 +104,15 @@ int net_samdump(struct net_context *ctx, int argc, const char **argv) } libnetctx->cred = ctx->credentials; - r.level = LIBNET_SAMDUMP_GENERIC; - r.error_string = NULL; + r.out.error_string = NULL; + r.in.machine_account = NULL; + r.in.binding_string = NULL; status = libnet_SamDump(libnetctx, ctx->mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { DEBUG(0,("libnet_SamDump returned %s: %s\n", nt_errstr(status), - r.error_string)); + r.out.error_string)); return -1; } @@ -144,14 +146,15 @@ int net_samsync_ldb(struct net_context *ctx, int argc, const char **argv) } libnetctx->cred = ctx->credentials; - r.level = LIBNET_SAMSYNC_LDB_GENERIC; - r.error_string = NULL; + r.out.error_string = NULL; + r.in.machine_account = NULL; + r.in.binding_string = NULL; status = libnet_samsync_ldb(libnetctx, ctx->mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { DEBUG(0,("libnet_samsync_ldb returned %s: %s\n", nt_errstr(status), - r.error_string)); + r.out.error_string)); return -1; } -- cgit From d790d8d6edbb7744cc6d3f7ca33e05a358038a42 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 13 Jan 2006 02:58:35 +0000 Subject: r12886: Rename 'secure_channel_type' parameter to domain join as 'join_type'. Andrew Bartlett (This used to be commit a3b3e09a9acc66dff7baf1a4ba0ea913bccdbd7d) --- source4/utils/net/net_join.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net_join.c b/source4/utils/net/net_join.c index eaa53f4c7b..407de6e89d 100644 --- a/source4/utils/net/net_join.c +++ b/source4/utils/net/net_join.c @@ -68,7 +68,7 @@ int net_join(struct net_context *ctx, int argc, const char **argv) /* prepare parameters for the join */ r->in.netbios_name = lp_netbios_name(); r->in.domain_name = domain_name; - r->in.secure_channel_type = secure_channel_type; + r->in.join_type = secure_channel_type; r->in.level = LIBNET_JOIN_AUTOMATIC; r->out.error_string = NULL; -- cgit From 58f78fa182c4b4a046b957c89988d34ea2125696 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 13 Jan 2006 03:39:49 +0000 Subject: r12892: Add a 'Migrate from Windows' page to our installation section in SWAT. Doing this required reworking ejsnet, particularly so it could take a set of credentials, not just a username and password argument. This required fixing the ejsnet.js test script, which now adds and deletes a user, and is run from 'make test'. This should prevent it being broken again. Deleting a user from ejsnet required that the matching backend be added to libnet, hooking fortunetly onto already existing code for the actual deletion. The js credentials interface now handles the 'set machine account' flag. New functions have been added to provision.js to wrap the basic operations (so we can write a command line version, as well as the web based version). Andrew Bartlett (This used to be commit a5e7c17c348c45e61699cc1626a0d5eae2df4636) --- source4/utils/net/net_user.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net_user.c b/source4/utils/net/net_user.c index 82ee208534..ecc1834fcf 100644 --- a/source4/utils/net/net_user.c +++ b/source4/utils/net/net_user.c @@ -64,9 +64,51 @@ static int net_user_add(struct net_context *ctx, int argc, const char **argv) return 0; } +static int net_user_delete(struct net_context *ctx, int argc, const char **argv) +{ + NTSTATUS status; + struct libnet_context *lnet_ctx; + struct libnet_DeleteUser r; + char *user_name; + + /* command line argument preparation */ + switch (argc) { + case 0: + return net_user_usage(ctx, argc, argv); + break; + case 1: + user_name = talloc_strdup(ctx->mem_ctx, argv[0]); + break; + default: + return net_user_usage(ctx, argc, argv); + } + + /* libnet context init and its params */ + lnet_ctx = libnet_context_init(NULL); + if (!lnet_ctx) return -1; + + lnet_ctx->cred = ctx->credentials; + + /* calling DeleteUser function */ + r.level = LIBNET_DELETE_USER_GENERIC; + r.in.user_name = user_name; + r.in.domain_name = cli_credentials_get_domain(lnet_ctx->cred); + + status = libnet_DeleteUser(lnet_ctx, ctx->mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0, ("Failed to delete user account: %s\n", + r.out.error_string)); + return -1; + } + + talloc_free(lnet_ctx); + return 0; +} + static const struct net_functable net_user_functable[] = { { "add", "create new user account\n", net_user_add, net_user_usage }, + { "delete", "delete an existing user account\n", net_user_delete, net_user_usage }, { NULL, NULL } }; -- cgit From f3db23ac75578198ee411b21a7ba2ec49dedafab Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 14 Jan 2006 06:17:24 +0000 Subject: r12928: This patch improves the interaction between the vampire and provsion code. Previously, we had to know (or guess) the host and domain guid at the provision stage. Now we query the database post-provision, to extract the values and fill in the zone file. This allows us to generate a correct zone file in the Windows migration case. In an effort to make SWAT easier to use, I have removed and renamed some of the provision options. I have also fixed a nasty issue in my js code. I had implictly declared a global variable of the name 'join', with disasterious results for any subsequent user of the string utility function: esp exception - ASSERT at lib/appweb/ejs/ejsParser.c:2064, 0 Backtrace: [ 0] substitute_var:20 -> list[i] = join("", list2) [ 1] setup_file:9 -> data = substitute_var(data, subobj) Andrew Bartlett (This used to be commit a38ceefd11f8b748f30383ef36a4752f178bfca1) --- source4/utils/net/net_vampire.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net_vampire.c b/source4/utils/net/net_vampire.c index f89739225d..00ae647016 100644 --- a/source4/utils/net/net_vampire.c +++ b/source4/utils/net/net_vampire.c @@ -24,6 +24,7 @@ #include "utils/net/net.h" #include "libnet/libnet.h" #include "librpc/gen_ndr/ndr_samr.h" +#include "auth/auth.h" static int net_samdump_keytab_usage(struct net_context *ctx, int argc, const char **argv) { @@ -150,7 +151,10 @@ int net_samsync_ldb(struct net_context *ctx, int argc, const char **argv) r.in.machine_account = NULL; r.in.binding_string = NULL; - status = libnet_samsync_ldb(libnetctx, ctx->mem_ctx, &r); + /* Needed to override the ACLs on ldb */ + r.in.session_info = system_session(libnetctx); + + status = libnet_samsync_ldb(libnetctx, libnetctx, &r); if (!NT_STATUS_IS_OK(status)) { DEBUG(0,("libnet_samsync_ldb returned %s: %s\n", nt_errstr(status), -- cgit From 05ea1558586438fb3a1865ce402cb4502de9dd49 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 26 Jan 2006 01:59:07 +0000 Subject: r13149: DEBUG is a bad choice for 'net', it should print to stderr Andrew Bartlett (This used to be commit 4dd6afa6d167fd04c1c3d4b4529b1cecf27eacaa) --- source4/utils/net/net_join.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net_join.c b/source4/utils/net/net_join.c index 407de6e89d..9463b88dd7 100644 --- a/source4/utils/net/net_join.c +++ b/source4/utils/net/net_join.c @@ -46,7 +46,7 @@ int net_join(struct net_context *ctx, int argc, const char **argv) } else if (strcasecmp(argv[1], "MEMBER") == 0) { secure_channel_type = SEC_CHAN_WKSTA; } else { - DEBUG(0, ("net_join: 2nd argument must be MEMBER or BDC\n")); + d_fprintf(stderr, "net_join: 2nd argument must be MEMBER or BDC\n"); return net_join_usage(ctx, argc, argv); } break; @@ -76,8 +76,8 @@ int net_join(struct net_context *ctx, int argc, const char **argv) status = libnet_Join(libnetctx, r, r); if (!NT_STATUS_IS_OK(status)) { - d_printf("Joining domain failed: %s\n", - r->out.error_string ? r->out.error_string : nt_errstr(status)); + d_fprintf(stderr, "Joining domain failed: %s\n", + r->out.error_string ? r->out.error_string : nt_errstr(status)); talloc_free(r); talloc_free(libnetctx); return -1; -- cgit From 49efc495417b5900c653f8d6453dcceed9c02239 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 6 Mar 2006 23:34:57 +0000 Subject: r13904: Make sure LDB gets initialized (This used to be commit 4339e3e7d746d2fcb16ce2662a22a880e426367b) --- source4/utils/net/net.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net.c b/source4/utils/net/net.c index f82eddb763..303449c742 100644 --- a/source4/utils/net/net.c +++ b/source4/utils/net/net.c @@ -44,6 +44,7 @@ #include "includes.h" #include "utils/net/net.h" #include "lib/cmdline/popt_common.h" +#include "lib/ldb/include/ldb.h" /* run a function from a function table. If not found then @@ -187,6 +188,8 @@ static int binary_net(int argc, const char **argv) dcerpc_init(); + ldb_global_init(); + mem_ctx = talloc_init("net_context"); ctx = talloc(mem_ctx, struct net_context); if (!ctx) { -- cgit From 3f16241a1d3243447d0244ebac05b447aec94df8 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 14 Mar 2006 01:29:56 +0000 Subject: r14363: Remove credentials.h from the global includes. (This used to be commit 98c4c3051391c6f89df5d133665f51bef66b1563) --- source4/utils/net/net_password.c | 1 + source4/utils/net/net_user.c | 1 + 2 files changed, 2 insertions(+) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net_password.c b/source4/utils/net/net_password.c index 8f6b989a5d..4c67f87b43 100644 --- a/source4/utils/net/net_password.c +++ b/source4/utils/net/net_password.c @@ -23,6 +23,7 @@ #include "utils/net/net.h" #include "libnet/libnet.h" #include "system/filesys.h" +#include "auth/credentials/credentials.h" /* * Code for Changing and setting a password diff --git a/source4/utils/net/net_user.c b/source4/utils/net/net_user.c index ecc1834fcf..75eec9716d 100644 --- a/source4/utils/net/net_user.c +++ b/source4/utils/net/net_user.c @@ -22,6 +22,7 @@ #include "includes.h" #include "utils/net/net.h" #include "libnet/libnet.h" +#include "auth/credentials/credentials.h" static int net_user_add(struct net_context *ctx, int argc, const char **argv) { -- cgit From 8528016978b084213ef53d66e1b6e831b1a01acc Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 16 Mar 2006 00:23:11 +0000 Subject: r14464: Don't include ndr_BASENAME.h files unless strictly required, instead try to include just the BASENAME.h files (containing only structs) (This used to be commit 3dd477ca5147f28a962b8437e2611a8222d706bd) --- source4/utils/net/net_join.c | 1 + source4/utils/net/net_vampire.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net_join.c b/source4/utils/net/net_join.c index 9463b88dd7..e94794db16 100644 --- a/source4/utils/net/net_join.c +++ b/source4/utils/net/net_join.c @@ -23,6 +23,7 @@ #include "includes.h" #include "utils/net/net.h" #include "libnet/libnet.h" +#include "librpc/gen_ndr/ndr_security.h" int net_join(struct net_context *ctx, int argc, const char **argv) { diff --git a/source4/utils/net/net_vampire.c b/source4/utils/net/net_vampire.c index 00ae647016..8649740777 100644 --- a/source4/utils/net/net_vampire.c +++ b/source4/utils/net/net_vampire.c @@ -23,7 +23,7 @@ #include "includes.h" #include "utils/net/net.h" #include "libnet/libnet.h" -#include "librpc/gen_ndr/ndr_samr.h" +#include "librpc/gen_ndr/samr.h" #include "auth/auth.h" static int net_samdump_keytab_usage(struct net_context *ctx, int argc, const char **argv) -- cgit From 35349a58df5b69446607fbd742a05f57f3515319 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 18 Mar 2006 15:42:57 +0000 Subject: r14542: Remove librpc, libndr and libnbt from includes.h (This used to be commit 51b4270513752d2eafbe77f9de598de16ef84a1f) --- source4/utils/net/net.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net.c b/source4/utils/net/net.c index 303449c742..a6015f7c34 100644 --- a/source4/utils/net/net.c +++ b/source4/utils/net/net.c @@ -45,6 +45,7 @@ #include "utils/net/net.h" #include "lib/cmdline/popt_common.h" #include "lib/ldb/include/ldb.h" +#include "librpc/rpc/dcerpc.h" /* run a function from a function table. If not found then -- cgit From 184955ffd711a5db8b1e1b7c179c232ce0e29145 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 19 Mar 2006 19:47:05 +0000 Subject: r14572: Give libraries saner names, remove some .pc files, make some things subsystems in case a library doesn't make sense. (This used to be commit ed382873fd01457a53e0a1e1f5ba6753dfbc0646) --- source4/utils/net/config.mk | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/config.mk b/source4/utils/net/config.mk index 3d45bcec77..19632b25ef 100644 --- a/source4/utils/net/config.mk +++ b/source4/utils/net/config.mk @@ -13,9 +13,9 @@ OBJ_FILES = \ net_vampire.o \ net_user.o REQUIRED_SUBSYSTEMS = \ - CONFIG \ - LIBBASIC \ - LIBNET \ + LIBSAMBA-CONFIG \ + LIBSAMBA-UTIL \ + LIBSAMBA-NET \ LIBPOPT \ POPT_SAMBA \ POPT_CREDENTIALS -- cgit From 69b51f702af1ded825d5c17bdb97014cac12e752 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 24 Apr 2006 15:47:59 +0000 Subject: r15207: Introduce PRIVATE_DEPENDENCIES and PUBLIC_DEPENDENCIES as replacement for REQUIRED_SUBSYSTEMS. (This used to be commit adc8a019b6da256f104abed1b82bfde6998a2ac9) --- source4/utils/net/config.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/config.mk b/source4/utils/net/config.mk index 19632b25ef..c07d6a67cb 100644 --- a/source4/utils/net/config.mk +++ b/source4/utils/net/config.mk @@ -12,7 +12,7 @@ OBJ_FILES = \ net_join.o \ net_vampire.o \ net_user.o -REQUIRED_SUBSYSTEMS = \ +PRIVATE_DEPENDENCIES = \ LIBSAMBA-CONFIG \ LIBSAMBA-UTIL \ LIBSAMBA-NET \ -- cgit From e002300f238dd0937dd9f768e366c006945e8baa Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 29 Apr 2006 17:34:49 +0000 Subject: r15328: Move some functions around, remove dependencies. Remove some autogenerated headers (which had prototypes now autogenerated by pidl) Remove ndr_security.h from a few places - it's no longer necessary (This used to be commit c19c2b51d3e1ad347120b06a22bda5ec586c22e8) --- source4/utils/net/net_join.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net_join.c b/source4/utils/net/net_join.c index e94794db16..2df57e63cc 100644 --- a/source4/utils/net/net_join.c +++ b/source4/utils/net/net_join.c @@ -23,7 +23,7 @@ #include "includes.h" #include "utils/net/net.h" #include "libnet/libnet.h" -#include "librpc/gen_ndr/ndr_security.h" +#include "libcli/security/security.h" int net_join(struct net_context *ctx, int argc, const char **argv) { -- cgit From ece95aad3da31809369e8867493bffb5cb749993 Mon Sep 17 00:00:00 2001 From: Rafal Szczesniak Date: Sun, 7 May 2006 13:40:56 +0000 Subject: r15490: Typo fixes and remove long forgotten commented piece. rafal (This used to be commit a2f6dc786031aa368b0398c21baf18cf82375c46) --- source4/utils/net/net.c | 9 ++------- source4/utils/net/net_vampire.c | 2 +- 2 files changed, 3 insertions(+), 8 deletions(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net.c b/source4/utils/net/net.c index a6015f7c34..f2223a03a3 100644 --- a/source4/utils/net/net.c +++ b/source4/utils/net/net.c @@ -82,12 +82,7 @@ int net_run_usage(struct net_context *ctx, const struct net_functable *functable) { int i; -/* - if (argc < 1) { - d_printf("net_run_usage: TODO (argc < 1)\n"); - return 1; - } -*/ + for (i=0; functable[i].name; i++) { if (strcasecmp_m(argv[0], functable[i].name) == 0) if (functable[i].usage) { @@ -107,7 +102,7 @@ static const struct net_functable net_functable[] = { {"time", "get remote server's time\n", net_time, net_time_usage}, {"join", "join a domain\n", net_join, net_join_usage}, {"samdump", "dump the sam of a domain\n", net_samdump, net_samdump_usage}, - {"samsync", "syncrosnise into the local ldb the sam of a domain\n", net_samsync_ldb, net_samsync_ldb_usage}, + {"samsync", "synchronise into the local ldb the sam of a domain\n", net_samsync_ldb, net_samsync_ldb_usage}, {"user", "manage user accounts\n", net_user, net_user_usage}, {NULL, NULL, NULL, NULL} }; diff --git a/source4/utils/net/net_vampire.c b/source4/utils/net/net_vampire.c index 8649740777..dba51ea1af 100644 --- a/source4/utils/net/net_vampire.c +++ b/source4/utils/net/net_vampire.c @@ -175,6 +175,6 @@ int net_samsync_ldb_usage(struct net_context *ctx, int argc, const char **argv) int net_samsync_ldb_help(struct net_context *ctx, int argc, const char **argv) { - d_printf("Syncrosnise into the local ldb the SAM of a domain.\n"); + d_printf("Synchronise into the local ldb the SAM of a domain.\n"); return 0; } -- cgit From 787d67c2cd780656cb5e6c0884c485f287b72c49 Mon Sep 17 00:00:00 2001 From: Rafal Szczesniak Date: Mon, 29 May 2006 22:01:31 +0000 Subject: r15941: We don't use call levels, at the moment. Remove them until we do. rafal (This used to be commit 592387a769521d221a89d374ef72c6123160cfed) --- source4/utils/net/net_user.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net_user.c b/source4/utils/net/net_user.c index 75eec9716d..7bb6fa3d61 100644 --- a/source4/utils/net/net_user.c +++ b/source4/utils/net/net_user.c @@ -50,7 +50,6 @@ static int net_user_add(struct net_context *ctx, int argc, const char **argv) lnet_ctx->cred = ctx->credentials; /* calling CreateUser function */ - r.level = LIBNET_CREATE_USER_GENERIC; r.in.user_name = user_name; r.in.domain_name = cli_credentials_get_domain(lnet_ctx->cred); @@ -91,7 +90,6 @@ static int net_user_delete(struct net_context *ctx, int argc, const char **argv) lnet_ctx->cred = ctx->credentials; /* calling DeleteUser function */ - r.level = LIBNET_DELETE_USER_GENERIC; r.in.user_name = user_name; r.in.domain_name = cli_credentials_get_domain(lnet_ctx->cred); -- cgit From b7477fb3881ac4490da040b054094a865128b951 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 6 Sep 2006 00:35:29 +0000 Subject: r18117: first steps in making samba4 use libreplace (This used to be commit c079cedb084d621c5a0aac59310b237ba375df20) --- source4/utils/net/config.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/config.mk b/source4/utils/net/config.mk index c07d6a67cb..6985f1475c 100644 --- a/source4/utils/net/config.mk +++ b/source4/utils/net/config.mk @@ -16,7 +16,7 @@ PRIVATE_DEPENDENCIES = \ LIBSAMBA-CONFIG \ LIBSAMBA-UTIL \ LIBSAMBA-NET \ - LIBPOPT \ + POPT_EXT \ POPT_SAMBA \ POPT_CREDENTIALS # End BINARY net -- cgit From a59706f721c70e9a4f78eb2296bb746b912ce9d0 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 6 Sep 2006 01:36:02 +0000 Subject: r18121: Simplify m4 code, hopefully fix Samba4 build problems. (This used to be commit 1adf65b4d7c5d2d4f65d4b28575bdf2368a42139) --- source4/utils/net/config.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/config.mk b/source4/utils/net/config.mk index 6985f1475c..c07d6a67cb 100644 --- a/source4/utils/net/config.mk +++ b/source4/utils/net/config.mk @@ -16,7 +16,7 @@ PRIVATE_DEPENDENCIES = \ LIBSAMBA-CONFIG \ LIBSAMBA-UTIL \ LIBSAMBA-NET \ - POPT_EXT \ + LIBPOPT \ POPT_SAMBA \ POPT_CREDENTIALS # End BINARY net -- cgit From 873749f2189ecf1fbfdc681df4dd304a17716279 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 6 Sep 2006 12:28:01 +0000 Subject: r18168: Use {NULL} rather than POPT_TABLEEND, which is not always available. (This used to be commit 8b622c5ded0732df0eaf9f6226f52a27b6eacd73) --- source4/utils/net/net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net.c b/source4/utils/net/net.c index f2223a03a3..70c1de922d 100644 --- a/source4/utils/net/net.c +++ b/source4/utils/net/net.c @@ -148,7 +148,7 @@ static int binary_net(int argc, const char **argv) POPT_COMMON_CONNECTION POPT_COMMON_CREDENTIALS POPT_COMMON_VERSION - POPT_TABLEEND + { NULL } }; #ifdef HAVE_SETBUFFER -- cgit From a8421e81078b91ae97ada3be352416eae26a9c7b Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 10 Sep 2006 14:19:38 +0000 Subject: r18343: fixed setlinebuf() prototype, added test for it, and use it in two places to avoid a #ifdef (This used to be commit 095b8057740a4bb207e24e4c63a2dcb53521a72f) --- source4/utils/net/net.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net.c b/source4/utils/net/net.c index 70c1de922d..7e885acfe8 100644 --- a/source4/utils/net/net.c +++ b/source4/utils/net/net.c @@ -151,9 +151,7 @@ static int binary_net(int argc, const char **argv) { NULL } }; -#ifdef HAVE_SETBUFFER - setbuffer(stdout, NULL, 0); -#endif + setlinebuf(stdout); pc = poptGetContext("net", argc, (const char **) argv, long_options, POPT_CONTEXT_KEEP_FIRST); -- cgit From 5bfc0d63170521ad8d451ffcfbb30ee5b140dfbb Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 23 Oct 2006 06:05:41 +0000 Subject: r19463: Make it clear what argument is incorrect Andrew Bartlett (This used to be commit a28a17c50853ccd4d7b2122497d3d18f0a6feed9) --- source4/utils/net/net_join.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net_join.c b/source4/utils/net/net_join.c index 2df57e63cc..0495e9850f 100644 --- a/source4/utils/net/net_join.c +++ b/source4/utils/net/net_join.c @@ -47,7 +47,7 @@ int net_join(struct net_context *ctx, int argc, const char **argv) } else if (strcasecmp(argv[1], "MEMBER") == 0) { secure_channel_type = SEC_CHAN_WKSTA; } else { - d_fprintf(stderr, "net_join: 2nd argument must be MEMBER or BDC\n"); + d_fprintf(stderr, "net_join: Invalid 2nd argument (%s) must be MEMBER or BDC\n", argv[1]); return net_join_usage(ctx, argc, argv); } break; -- cgit From 0479a2f1cbae51fcd8dbdc3c148c808421fb4d25 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 02:07:03 +0000 Subject: r23792: convert Samba4 to GPLv3 There are still a few tidyups of old FSF addresses to come (in both s3 and s4). More commits soon. (This used to be commit fcf38a38ac691abd0fa51b89dc951a08e89fdafa) --- source4/utils/net/net.c | 5 ++--- source4/utils/net/net.h | 5 ++--- source4/utils/net/net_join.c | 5 ++--- source4/utils/net/net_password.c | 5 ++--- source4/utils/net/net_time.c | 5 ++--- source4/utils/net/net_user.c | 5 ++--- source4/utils/net/net_vampire.c | 5 ++--- 7 files changed, 14 insertions(+), 21 deletions(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net.c b/source4/utils/net/net.c index 7e885acfe8..64e82e226a 100644 --- a/source4/utils/net/net.c +++ b/source4/utils/net/net.c @@ -16,7 +16,7 @@ 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 2 of the License, or + 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, @@ -25,8 +25,7 @@ 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, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ /*****************************************************/ diff --git a/source4/utils/net/net.h b/source4/utils/net/net.h index 8d9c78c1a9..d9b5923dad 100644 --- a/source4/utils/net/net.h +++ b/source4/utils/net/net.h @@ -6,7 +6,7 @@ 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 2 of the License, or + 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, @@ -15,8 +15,7 @@ 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, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ #ifndef _UTIL_NET_H diff --git a/source4/utils/net/net_join.c b/source4/utils/net/net_join.c index 0495e9850f..98bf19d234 100644 --- a/source4/utils/net/net_join.c +++ b/source4/utils/net/net_join.c @@ -7,7 +7,7 @@ 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 2 of the License, or + 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, @@ -16,8 +16,7 @@ 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, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ #include "includes.h" diff --git a/source4/utils/net/net_password.c b/source4/utils/net/net_password.c index 4c67f87b43..4547aac6fd 100644 --- a/source4/utils/net/net_password.c +++ b/source4/utils/net/net_password.c @@ -6,7 +6,7 @@ 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 2 of the License, or + 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, @@ -15,8 +15,7 @@ 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, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ #include "includes.h" diff --git a/source4/utils/net/net_time.c b/source4/utils/net/net_time.c index 8bdef1f762..e14b6e5759 100644 --- a/source4/utils/net/net_time.c +++ b/source4/utils/net/net_time.c @@ -6,7 +6,7 @@ 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 2 of the License, or + 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, @@ -15,8 +15,7 @@ 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, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ #include "includes.h" diff --git a/source4/utils/net/net_user.c b/source4/utils/net/net_user.c index 7bb6fa3d61..a8d13c0315 100644 --- a/source4/utils/net/net_user.c +++ b/source4/utils/net/net_user.c @@ -6,7 +6,7 @@ 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 2 of the License, or + 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, @@ -15,8 +15,7 @@ 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, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ #include "includes.h" diff --git a/source4/utils/net/net_vampire.c b/source4/utils/net/net_vampire.c index dba51ea1af..86c7c0115a 100644 --- a/source4/utils/net/net_vampire.c +++ b/source4/utils/net/net_vampire.c @@ -7,7 +7,7 @@ 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 2 of the License, or + 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, @@ -16,8 +16,7 @@ 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, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ #include "includes.h" -- cgit From ffeee68e4b72dd94fee57366bd8d38b8c284c3d4 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 8 Sep 2007 12:42:09 +0000 Subject: r25026: Move param/param.h out of includes.h (This used to be commit abe8349f9b4387961ff3665d8c589d61cd2edf31) --- source4/utils/net/net_join.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net_join.c b/source4/utils/net/net_join.c index 98bf19d234..59b35d70fa 100644 --- a/source4/utils/net/net_join.c +++ b/source4/utils/net/net_join.c @@ -23,6 +23,7 @@ #include "utils/net/net.h" #include "libnet/libnet.h" #include "libcli/security/security.h" +#include "param/param.h" int net_join(struct net_context *ctx, int argc, const char **argv) { -- cgit From 37d53832a4623653f706e77985a79d84bd7c6694 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 28 Sep 2007 01:17:46 +0000 Subject: r25398: Parse loadparm context to all lp_*() functions. (This used to be commit 3fcc960839c6e5ca4de2c3c042f12f369ac5f238) --- source4/utils/net/net_join.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net_join.c b/source4/utils/net/net_join.c index 59b35d70fa..1352fb7d9b 100644 --- a/source4/utils/net/net_join.c +++ b/source4/utils/net/net_join.c @@ -67,7 +67,7 @@ int net_join(struct net_context *ctx, int argc, const char **argv) return -1; } /* prepare parameters for the join */ - r->in.netbios_name = lp_netbios_name(); + r->in.netbios_name = lp_netbios_name(global_loadparm); r->in.domain_name = domain_name; r->in.join_type = secure_channel_type; r->in.level = LIBNET_JOIN_AUTOMATIC; -- cgit From 43696d2752e2faad34fb3ed2a7dbf01d40ffdc46 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 3 Dec 2007 15:53:28 +0100 Subject: r26252: Specify loadparm_context explicitly when creating sessions. (This used to be commit 7280c1e9415daabb2712db1372e23f9846272ede) --- source4/utils/net/net_vampire.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net_vampire.c b/source4/utils/net/net_vampire.c index 86c7c0115a..dc11917fa4 100644 --- a/source4/utils/net/net_vampire.c +++ b/source4/utils/net/net_vampire.c @@ -24,6 +24,7 @@ #include "libnet/libnet.h" #include "librpc/gen_ndr/samr.h" #include "auth/auth.h" +#include "param/param.h" static int net_samdump_keytab_usage(struct net_context *ctx, int argc, const char **argv) { @@ -151,7 +152,7 @@ int net_samsync_ldb(struct net_context *ctx, int argc, const char **argv) r.in.binding_string = NULL; /* Needed to override the ACLs on ldb */ - r.in.session_info = system_session(libnetctx); + r.in.session_info = system_session(libnetctx, global_loadparm); status = libnet_samsync_ldb(libnetctx, libnetctx, &r); if (!NT_STATUS_IS_OK(status)) { -- cgit From a693e6f1c71d9772b52cf40a85b0504cea837240 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 4 Dec 2007 19:33:00 +0100 Subject: r26295: Remove use of global_loadparm for net and wb_pam_auth. (This used to be commit 47696b42987ea67ae1c6c09a4bec5858e5db4542) --- source4/utils/net/net.c | 2 ++ source4/utils/net/net.h | 1 + source4/utils/net/net_join.c | 2 +- source4/utils/net/net_vampire.c | 2 +- 4 files changed, 5 insertions(+), 2 deletions(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net.c b/source4/utils/net/net.c index 64e82e226a..2741f485cc 100644 --- a/source4/utils/net/net.c +++ b/source4/utils/net/net.c @@ -45,6 +45,7 @@ #include "lib/cmdline/popt_common.h" #include "lib/ldb/include/ldb.h" #include "librpc/rpc/dcerpc.h" +#include "param/param.h" /* run a function from a function table. If not found then @@ -192,6 +193,7 @@ static int binary_net(int argc, const char **argv) ZERO_STRUCTP(ctx); ctx->mem_ctx = mem_ctx; + ctx->lp_ctx = global_loadparm; ctx->credentials = cmdline_credentials; rc = net_run_function(ctx, argc_new-1, argv_new+1, net_functable, net_usage); diff --git a/source4/utils/net/net.h b/source4/utils/net/net.h index d9b5923dad..8c4fbd7fdd 100644 --- a/source4/utils/net/net.h +++ b/source4/utils/net/net.h @@ -24,6 +24,7 @@ struct net_context { TALLOC_CTX *mem_ctx; struct cli_credentials *credentials; + struct loadparm_context *lp_ctx; }; struct net_functable { diff --git a/source4/utils/net/net_join.c b/source4/utils/net/net_join.c index 1352fb7d9b..6d833f8e93 100644 --- a/source4/utils/net/net_join.c +++ b/source4/utils/net/net_join.c @@ -67,7 +67,7 @@ int net_join(struct net_context *ctx, int argc, const char **argv) return -1; } /* prepare parameters for the join */ - r->in.netbios_name = lp_netbios_name(global_loadparm); + r->in.netbios_name = lp_netbios_name(ctx->lp_ctx); r->in.domain_name = domain_name; r->in.join_type = secure_channel_type; r->in.level = LIBNET_JOIN_AUTOMATIC; diff --git a/source4/utils/net/net_vampire.c b/source4/utils/net/net_vampire.c index dc11917fa4..4e0f1501d9 100644 --- a/source4/utils/net/net_vampire.c +++ b/source4/utils/net/net_vampire.c @@ -152,7 +152,7 @@ int net_samsync_ldb(struct net_context *ctx, int argc, const char **argv) r.in.binding_string = NULL; /* Needed to override the ACLs on ldb */ - r.in.session_info = system_session(libnetctx, global_loadparm); + r.in.session_info = system_session(libnetctx, ctx->lp_ctx); status = libnet_samsync_ldb(libnetctx, libnetctx, &r); if (!NT_STATUS_IS_OK(status)) { -- cgit From 4c4323009fa83f00ed319de59a3aad48fcd65994 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 7 Dec 2007 02:37:04 +0100 Subject: r26327: Explicit loadparm_context for RPC client functions. (This used to be commit eeb2251d22b3d6e0379444a73af69d1014692b07) --- source4/utils/net/net_join.c | 2 +- source4/utils/net/net_password.c | 4 ++-- source4/utils/net/net_time.c | 2 +- source4/utils/net/net_user.c | 4 ++-- source4/utils/net/net_vampire.c | 6 +++--- 5 files changed, 9 insertions(+), 9 deletions(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net_join.c b/source4/utils/net/net_join.c index 6d833f8e93..08a4fbd4a1 100644 --- a/source4/utils/net/net_join.c +++ b/source4/utils/net/net_join.c @@ -57,7 +57,7 @@ int net_join(struct net_context *ctx, int argc, const char **argv) domain_name = tmp; - libnetctx = libnet_context_init(NULL); + libnetctx = libnet_context_init(NULL, ctx->lp_ctx); if (!libnetctx) { return -1; } diff --git a/source4/utils/net/net_password.c b/source4/utils/net/net_password.c index 4547aac6fd..1fcb772e4c 100644 --- a/source4/utils/net/net_password.c +++ b/source4/utils/net/net_password.c @@ -52,7 +52,7 @@ static int net_password_change(struct net_context *ctx, int argc, const char **a new_password = getpass(password_prompt); } - libnetctx = libnet_context_init(NULL); + libnetctx = libnet_context_init(NULL, ctx->lp_ctx); if (!libnetctx) { return -1; } @@ -127,7 +127,7 @@ static int net_password_set(struct net_context *ctx, int argc, const char **argv new_password = getpass(password_prompt); } - libnetctx = libnet_context_init(NULL); + libnetctx = libnet_context_init(NULL, ctx->lp_ctx); if (!libnetctx) { return -1; } diff --git a/source4/utils/net/net_time.c b/source4/utils/net/net_time.c index e14b6e5759..1f4bb3ed71 100644 --- a/source4/utils/net/net_time.c +++ b/source4/utils/net/net_time.c @@ -42,7 +42,7 @@ int net_time(struct net_context *ctx, int argc, const char **argv) return net_time_usage(ctx, argc, argv); } - libnetctx = libnet_context_init(NULL); + libnetctx = libnet_context_init(NULL, ctx->lp_ctx); if (!libnetctx) { return -1; } diff --git a/source4/utils/net/net_user.c b/source4/utils/net/net_user.c index a8d13c0315..39d50e7d8b 100644 --- a/source4/utils/net/net_user.c +++ b/source4/utils/net/net_user.c @@ -43,7 +43,7 @@ static int net_user_add(struct net_context *ctx, int argc, const char **argv) } /* libnet context init and its params */ - lnet_ctx = libnet_context_init(NULL); + lnet_ctx = libnet_context_init(NULL, ctx->lp_ctx); if (!lnet_ctx) return -1; lnet_ctx->cred = ctx->credentials; @@ -83,7 +83,7 @@ static int net_user_delete(struct net_context *ctx, int argc, const char **argv) } /* libnet context init and its params */ - lnet_ctx = libnet_context_init(NULL); + lnet_ctx = libnet_context_init(NULL, ctx->lp_ctx); if (!lnet_ctx) return -1; lnet_ctx->cred = ctx->credentials; diff --git a/source4/utils/net/net_vampire.c b/source4/utils/net/net_vampire.c index 4e0f1501d9..c798112d7b 100644 --- a/source4/utils/net/net_vampire.c +++ b/source4/utils/net/net_vampire.c @@ -53,7 +53,7 @@ static int net_samdump_keytab(struct net_context *ctx, int argc, const char **ar break; } - libnetctx = libnet_context_init(NULL); + libnetctx = libnet_context_init(NULL, ctx->lp_ctx); if (!libnetctx) { return -1; } @@ -99,7 +99,7 @@ int net_samdump(struct net_context *ctx, int argc, const char **argv) return rc; } - libnetctx = libnet_context_init(NULL); + libnetctx = libnet_context_init(NULL, ctx->lp_ctx); if (!libnetctx) { return -1; } @@ -141,7 +141,7 @@ int net_samsync_ldb(struct net_context *ctx, int argc, const char **argv) struct libnet_context *libnetctx; struct libnet_samsync_ldb r; - libnetctx = libnet_context_init(NULL); + libnetctx = libnet_context_init(NULL, ctx->lp_ctx); if (!libnetctx) { return -1; } -- cgit From b65dba2245bf382c47d65c95ac9b1efa43918fc0 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 10 Dec 2007 04:33:16 +0100 Subject: r26355: Eliminate global_loadparm in more places. (This used to be commit 5d589a0d94bd76a9b4c9fc748854e8098ea43c4d) --- source4/utils/net/net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net.c b/source4/utils/net/net.c index 2741f485cc..2c95e9033d 100644 --- a/source4/utils/net/net.c +++ b/source4/utils/net/net.c @@ -193,7 +193,7 @@ static int binary_net(int argc, const char **argv) ZERO_STRUCTP(ctx); ctx->mem_ctx = mem_ctx; - ctx->lp_ctx = global_loadparm; + ctx->lp_ctx = cmdline_lp_ctx; ctx->credentials = cmdline_credentials; rc = net_run_function(ctx, argc_new-1, argv_new+1, net_functable, net_usage); -- cgit From 0020793515ade04f3ef5754717490e2eb2ca6bb9 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 20 Feb 2008 03:40:44 +0100 Subject: Fix static module list generation for ldb. (This used to be commit 92c1c0e9137f0845cac6cc96bf78711b6aaffe21) --- source4/utils/net/net.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net.c b/source4/utils/net/net.c index 2c95e9033d..e0865c4416 100644 --- a/source4/utils/net/net.c +++ b/source4/utils/net/net.c @@ -182,8 +182,6 @@ static int binary_net(int argc, const char **argv) dcerpc_init(); - ldb_global_init(); - mem_ctx = talloc_init("net_context"); ctx = talloc(mem_ctx, struct net_context); if (!ctx) { -- cgit From f41b9a9dde0dcad17e3a137537548f9bd9ab3901 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 1 Apr 2008 15:08:30 +0200 Subject: Rename libsamba-config to libsamba-hostconfig. (This used to be commit c46b7e90e347da76156ddcae4866adb88e9fec21) --- source4/utils/net/config.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/config.mk b/source4/utils/net/config.mk index c07d6a67cb..ced0710ae0 100644 --- a/source4/utils/net/config.mk +++ b/source4/utils/net/config.mk @@ -13,7 +13,7 @@ OBJ_FILES = \ net_vampire.o \ net_user.o PRIVATE_DEPENDENCIES = \ - LIBSAMBA-CONFIG \ + LIBSAMBA-HOSTCONFIG \ LIBSAMBA-UTIL \ LIBSAMBA-NET \ LIBPOPT \ -- cgit From 8a982108a4f115e350c4246276f2ec886934c7fe Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 9 Apr 2008 14:59:32 +1000 Subject: Link the new vampire code togeather. This adds in the newly attached secrets handling, as well as an interface to the command line 'net' tool. Andrew Bartlett (This used to be commit 1282e3c39479aa580124206814b493370d10690a) --- source4/utils/net/net.c | 3 +- source4/utils/net/net_join.c | 67 +++++++++++++++++++++++++++++++++++++++++ source4/utils/net/net_vampire.c | 2 +- 3 files changed, 70 insertions(+), 2 deletions(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net.c b/source4/utils/net/net.c index e0865c4416..c908ea6279 100644 --- a/source4/utils/net/net.c +++ b/source4/utils/net/net.c @@ -102,7 +102,8 @@ static const struct net_functable net_functable[] = { {"time", "get remote server's time\n", net_time, net_time_usage}, {"join", "join a domain\n", net_join, net_join_usage}, {"samdump", "dump the sam of a domain\n", net_samdump, net_samdump_usage}, - {"samsync", "synchronise into the local ldb the sam of a domain\n", net_samsync_ldb, net_samsync_ldb_usage}, + {"vampire", "join and syncronise an AD domain onto the local server\n", net_vampire, net_vampire_usage}, + {"samsync", "synchronise into the local ldb the sam of an NT4 domain\n", net_samsync_ldb, net_samsync_ldb_usage}, {"user", "manage user accounts\n", net_user, net_user_usage}, {NULL, NULL, NULL, NULL} }; diff --git a/source4/utils/net/net_join.c b/source4/utils/net/net_join.c index 08a4fbd4a1..abdcbf6027 100644 --- a/source4/utils/net/net_join.c +++ b/source4/utils/net/net_join.c @@ -100,3 +100,70 @@ int net_join_help(struct net_context *ctx, int argc, const char **argv) d_printf("Joins domain as either member or backup domain controller.\n"); return 0; } + +int net_vampire(struct net_context *ctx, int argc, const char **argv) +{ + NTSTATUS status; + struct libnet_context *libnetctx; + struct libnet_Vampire *r; + char *tmp, *targetdir = NULL; + const char *domain_name; + + switch (argc) { + case 0: /* no args -> fail */ + return net_vampire_usage(ctx, argc, argv); + case 1: /* only DOMAIN */ + tmp = talloc_strdup(ctx->mem_ctx, argv[0]); + break; + case 2: /* domain and target dir */ + tmp = talloc_strdup(ctx->mem_ctx, argv[0]); + targetdir = talloc_strdup(ctx->mem_ctx, argv[1]); + break; + default: /* too many args -> fail */ + return net_vampire_usage(ctx, argc, argv); + } + + domain_name = tmp; + + libnetctx = libnet_context_init(NULL, ctx->lp_ctx); + if (!libnetctx) { + return -1; + } + libnetctx->cred = ctx->credentials; + r = talloc(ctx->mem_ctx, struct libnet_Vampire); + if (!r) { + return -1; + } + /* prepare parameters for the vampire */ + r->in.netbios_name = lp_netbios_name(ctx->lp_ctx); + r->in.domain_name = domain_name; + r->in.targetdir = targetdir; + r->out.error_string = NULL; + + /* do the domain vampire */ + status = libnet_Vampire(libnetctx, r, r); + + if (!NT_STATUS_IS_OK(status)) { + d_fprintf(stderr, "Vampire of domain failed: %s\n", + r->out.error_string ? r->out.error_string : nt_errstr(status)); + talloc_free(r); + talloc_free(libnetctx); + return -1; + } + d_printf("Vampired domain %s (%s)\n", r->out.domain_name, dom_sid_string(ctx->mem_ctx, r->out.domain_sid)); + + talloc_free(libnetctx); + return 0; +} + +int net_vampire_usage(struct net_context *ctx, int argc, const char **argv) +{ + d_printf("net vampire [options]\n"); + return 0; +} + +int net_vampire_help(struct net_context *ctx, int argc, const char **argv) +{ + d_printf("Vampires domain as either member or backup domain controller.\n"); + return 0; +} diff --git a/source4/utils/net/net_vampire.c b/source4/utils/net/net_vampire.c index c798112d7b..4f6371d617 100644 --- a/source4/utils/net/net_vampire.c +++ b/source4/utils/net/net_vampire.c @@ -169,7 +169,7 @@ int net_samsync_ldb(struct net_context *ctx, int argc, const char **argv) int net_samsync_ldb_usage(struct net_context *ctx, int argc, const char **argv) { - d_printf("net samsync_ldb\n"); + d_printf("net samsync\n"); return 0; } -- cgit From e9017ba418202b4b191c5a9ad4a96857558ce606 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 14 Apr 2008 17:22:58 +0200 Subject: Use _OBJ_FILES variables in a couple more places. (This used to be commit 92856d5054106894b65cd1a1b5119c0facfc4cff) --- source4/utils/net/config.mk | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/config.mk b/source4/utils/net/config.mk index ced0710ae0..4423c44c15 100644 --- a/source4/utils/net/config.mk +++ b/source4/utils/net/config.mk @@ -5,13 +5,6 @@ [BINARY::net] INSTALLDIR = BINDIR PRIVATE_PROTO_HEADER = net_proto.h -OBJ_FILES = \ - net.o \ - net_password.o \ - net_time.o \ - net_join.o \ - net_vampire.o \ - net_user.o PRIVATE_DEPENDENCIES = \ LIBSAMBA-HOSTCONFIG \ LIBSAMBA-UTIL \ @@ -21,3 +14,12 @@ PRIVATE_DEPENDENCIES = \ POPT_CREDENTIALS # End BINARY net ################################# + +net_OBJ_FILES = $(addprefix utils/net/, \ + net.o \ + net_password.o \ + net_time.o \ + net_join.o \ + net_vampire.o \ + net_user.o) + -- cgit From 4f51b0246db3242ee02ee16905cba13a5dc5633a Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Mon, 14 Apr 2008 12:43:37 -0400 Subject: Fix problems with event context not being the parent. (This used to be commit 957c4d893acf9e6db06a3fc3a4687ab6bb238635) --- source4/utils/net/net.c | 18 ++++++++++++------ source4/utils/net/net.h | 1 - source4/utils/net/net_join.c | 11 ++++++----- source4/utils/net/net_password.c | 19 ++++++++++--------- source4/utils/net/net_time.c | 5 +++-- source4/utils/net/net_user.c | 13 +++++++------ source4/utils/net/net_vampire.c | 11 ++++++----- 7 files changed, 44 insertions(+), 34 deletions(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net.c b/source4/utils/net/net.c index c908ea6279..6086a4ce32 100644 --- a/source4/utils/net/net.c +++ b/source4/utils/net/net.c @@ -46,6 +46,8 @@ #include "lib/ldb/include/ldb.h" #include "librpc/rpc/dcerpc.h" #include "param/param.h" +#include "lib/events/events.h" +#include "auth/credentials/credentials.h" /* run a function from a function table. If not found then @@ -140,7 +142,7 @@ static int binary_net(int argc, const char **argv) int rc; int argc_new; const char **argv_new; - TALLOC_CTX *mem_ctx; + struct event_context *ev; struct net_context *ctx = NULL; poptContext pc; struct poptOption long_options[] = { @@ -183,17 +185,21 @@ static int binary_net(int argc, const char **argv) dcerpc_init(); - mem_ctx = talloc_init("net_context"); - ctx = talloc(mem_ctx, struct net_context); + ev = event_context_init(NULL); + if (!ev) { + d_printf("Failed to create an event context\n"); + exit(1); + } + ctx = talloc(ev, struct net_context); if (!ctx) { - d_printf("talloc_init(net_context) failed\n"); + d_printf("Failed to talloc a net_context\n"); exit(1); } ZERO_STRUCTP(ctx); - ctx->mem_ctx = mem_ctx; ctx->lp_ctx = cmdline_lp_ctx; ctx->credentials = cmdline_credentials; + cli_credentials_set_event_context(ctx->credentials, ev); rc = net_run_function(ctx, argc_new-1, argv_new+1, net_functable, net_usage); @@ -201,7 +207,7 @@ static int binary_net(int argc, const char **argv) DEBUG(0,("return code = %d\n", rc)); } - talloc_free(mem_ctx); + talloc_free(ev); return rc; } diff --git a/source4/utils/net/net.h b/source4/utils/net/net.h index 8c4fbd7fdd..17388079dd 100644 --- a/source4/utils/net/net.h +++ b/source4/utils/net/net.h @@ -22,7 +22,6 @@ #define _UTIL_NET_H struct net_context { - TALLOC_CTX *mem_ctx; struct cli_credentials *credentials; struct loadparm_context *lp_ctx; }; diff --git a/source4/utils/net/net_join.c b/source4/utils/net/net_join.c index abdcbf6027..2102257c6c 100644 --- a/source4/utils/net/net_join.c +++ b/source4/utils/net/net_join.c @@ -24,6 +24,7 @@ #include "libnet/libnet.h" #include "libcli/security/security.h" #include "param/param.h" +#include "lib/events/events.h" int net_join(struct net_context *ctx, int argc, const char **argv) { @@ -38,10 +39,10 @@ int net_join(struct net_context *ctx, int argc, const char **argv) case 0: /* no args -> fail */ return net_join_usage(ctx, argc, argv); case 1: /* only DOMAIN */ - tmp = talloc_strdup(ctx->mem_ctx, argv[0]); + tmp = talloc_strdup(ctx, argv[0]); break; case 2: /* DOMAIN and role */ - tmp = talloc_strdup(ctx->mem_ctx, argv[0]); + tmp = talloc_strdup(ctx, argv[0]); if (strcasecmp(argv[1], "BDC") == 0) { secure_channel_type = SEC_CHAN_BDC; } else if (strcasecmp(argv[1], "MEMBER") == 0) { @@ -57,12 +58,12 @@ int net_join(struct net_context *ctx, int argc, const char **argv) domain_name = tmp; - libnetctx = libnet_context_init(NULL, ctx->lp_ctx); + libnetctx = libnet_context_init(event_context_find(ctx), ctx->lp_ctx); if (!libnetctx) { return -1; } libnetctx->cred = ctx->credentials; - r = talloc(ctx->mem_ctx, struct libnet_Join); + r = talloc(ctx, struct libnet_Join); if (!r) { return -1; } @@ -83,7 +84,7 @@ int net_join(struct net_context *ctx, int argc, const char **argv) talloc_free(libnetctx); return -1; } - d_printf("Joined domain %s (%s)\n", r->out.domain_name, dom_sid_string(ctx->mem_ctx, r->out.domain_sid)); + d_printf("Joined domain %s (%s)\n", r->out.domain_name, dom_sid_string(ctx, r->out.domain_sid)); talloc_free(libnetctx); return 0; diff --git a/source4/utils/net/net_password.c b/source4/utils/net/net_password.c index 1fcb772e4c..97bb467fac 100644 --- a/source4/utils/net/net_password.c +++ b/source4/utils/net/net_password.c @@ -22,6 +22,7 @@ #include "utils/net/net.h" #include "libnet/libnet.h" #include "system/filesys.h" +#include "lib/events/events.h" #include "auth/credentials/credentials.h" /* @@ -46,13 +47,13 @@ static int net_password_change(struct net_context *ctx, int argc, const char **a if (argc > 0 && argv[0]) { new_password = argv[0]; } else { - password_prompt = talloc_asprintf(ctx->mem_ctx, "Enter new password for account [%s\\%s]:", + password_prompt = talloc_asprintf(ctx, "Enter new password for account [%s\\%s]:", cli_credentials_get_domain(ctx->credentials), cli_credentials_get_username(ctx->credentials)); new_password = getpass(password_prompt); } - libnetctx = libnet_context_init(NULL, ctx->lp_ctx); + libnetctx = libnet_context_init(event_context_find(ctx), ctx->lp_ctx); if (!libnetctx) { return -1; } @@ -66,7 +67,7 @@ static int net_password_change(struct net_context *ctx, int argc, const char **a r.generic.in.newpassword = new_password; /* do password change */ - status = libnet_ChangePassword(libnetctx, ctx->mem_ctx, &r); + status = libnet_ChangePassword(libnetctx, ctx, &r); if (!NT_STATUS_IS_OK(status)) { DEBUG(0,("net_password_change: %s\n",r.generic.out.error_string)); return -1; @@ -101,10 +102,10 @@ static int net_password_set(struct net_context *ctx, int argc, const char **argv case 0: /* no args -> fail */ return net_password_set_usage(ctx, argc, argv); case 1: /* only DOM\\user; prompt for password */ - tmp = talloc_strdup(ctx->mem_ctx, argv[0]); + tmp = talloc_strdup(ctx, argv[0]); break; case 2: /* DOM\\USER and password */ - tmp = talloc_strdup(ctx->mem_ctx, argv[0]); + tmp = talloc_strdup(ctx, argv[0]); new_password = argv[1]; break; default: /* too mayn args -> fail */ @@ -115,19 +116,19 @@ static int net_password_set(struct net_context *ctx, int argc, const char **argv if ((p = strchr_m(tmp,'\\'))) { *p = 0; domain_name = tmp; - account_name = talloc_strdup(ctx->mem_ctx, p+1); + account_name = talloc_strdup(ctx, p+1); } else { account_name = tmp; domain_name = cli_credentials_get_domain(ctx->credentials); } if (!new_password) { - password_prompt = talloc_asprintf(ctx->mem_ctx, "Enter new password for account [%s\\%s]:", + password_prompt = talloc_asprintf(ctx, "Enter new password for account [%s\\%s]:", domain_name, account_name); new_password = getpass(password_prompt); } - libnetctx = libnet_context_init(NULL, ctx->lp_ctx); + libnetctx = libnet_context_init(event_context_find(ctx), ctx->lp_ctx); if (!libnetctx) { return -1; } @@ -140,7 +141,7 @@ static int net_password_set(struct net_context *ctx, int argc, const char **argv r.generic.in.newpassword = new_password; /* do password change */ - status = libnet_SetPassword(libnetctx, ctx->mem_ctx, &r); + status = libnet_SetPassword(libnetctx, ctx, &r); if (!NT_STATUS_IS_OK(status)) { DEBUG(0,("net_password_set: %s\n",r.generic.out.error_string)); return -1; diff --git a/source4/utils/net/net_time.c b/source4/utils/net/net_time.c index 1f4bb3ed71..12a8132cea 100644 --- a/source4/utils/net/net_time.c +++ b/source4/utils/net/net_time.c @@ -22,6 +22,7 @@ #include "libnet/libnet.h" #include "utils/net/net.h" #include "system/time.h" +#include "lib/events/events.h" /* * Code for getting the remote time @@ -42,7 +43,7 @@ int net_time(struct net_context *ctx, int argc, const char **argv) return net_time_usage(ctx, argc, argv); } - libnetctx = libnet_context_init(NULL, ctx->lp_ctx); + libnetctx = libnet_context_init(event_context_find(ctx), ctx->lp_ctx); if (!libnetctx) { return -1; } @@ -53,7 +54,7 @@ int net_time(struct net_context *ctx, int argc, const char **argv) r.generic.in.server_name = server_name; /* get the time */ - status = libnet_RemoteTOD(libnetctx, ctx->mem_ctx, &r); + status = libnet_RemoteTOD(libnetctx, ctx, &r); if (!NT_STATUS_IS_OK(status)) { DEBUG(0,("net_time: %s\n",r.generic.out.error_string)); return -1; diff --git a/source4/utils/net/net_user.c b/source4/utils/net/net_user.c index 39d50e7d8b..57cef6b383 100644 --- a/source4/utils/net/net_user.c +++ b/source4/utils/net/net_user.c @@ -21,6 +21,7 @@ #include "includes.h" #include "utils/net/net.h" #include "libnet/libnet.h" +#include "lib/events/events.h" #include "auth/credentials/credentials.h" static int net_user_add(struct net_context *ctx, int argc, const char **argv) @@ -36,14 +37,14 @@ static int net_user_add(struct net_context *ctx, int argc, const char **argv) return net_user_usage(ctx, argc, argv); break; case 1: - user_name = talloc_strdup(ctx->mem_ctx, argv[0]); + user_name = talloc_strdup(ctx, argv[0]); break; default: return net_user_usage(ctx, argc, argv); } /* libnet context init and its params */ - lnet_ctx = libnet_context_init(NULL, ctx->lp_ctx); + lnet_ctx = libnet_context_init(event_context_find(ctx), ctx->lp_ctx); if (!lnet_ctx) return -1; lnet_ctx->cred = ctx->credentials; @@ -52,7 +53,7 @@ static int net_user_add(struct net_context *ctx, int argc, const char **argv) r.in.user_name = user_name; r.in.domain_name = cli_credentials_get_domain(lnet_ctx->cred); - status = libnet_CreateUser(lnet_ctx, ctx->mem_ctx, &r); + status = libnet_CreateUser(lnet_ctx, ctx, &r); if (!NT_STATUS_IS_OK(status)) { DEBUG(0, ("Failed to add user account: %s\n", r.out.error_string)); @@ -76,14 +77,14 @@ static int net_user_delete(struct net_context *ctx, int argc, const char **argv) return net_user_usage(ctx, argc, argv); break; case 1: - user_name = talloc_strdup(ctx->mem_ctx, argv[0]); + user_name = talloc_strdup(ctx, argv[0]); break; default: return net_user_usage(ctx, argc, argv); } /* libnet context init and its params */ - lnet_ctx = libnet_context_init(NULL, ctx->lp_ctx); + lnet_ctx = libnet_context_init(event_context_find(ctx), ctx->lp_ctx); if (!lnet_ctx) return -1; lnet_ctx->cred = ctx->credentials; @@ -92,7 +93,7 @@ static int net_user_delete(struct net_context *ctx, int argc, const char **argv) r.in.user_name = user_name; r.in.domain_name = cli_credentials_get_domain(lnet_ctx->cred); - status = libnet_DeleteUser(lnet_ctx, ctx->mem_ctx, &r); + status = libnet_DeleteUser(lnet_ctx, ctx, &r); if (!NT_STATUS_IS_OK(status)) { DEBUG(0, ("Failed to delete user account: %s\n", r.out.error_string)); diff --git a/source4/utils/net/net_vampire.c b/source4/utils/net/net_vampire.c index 4f6371d617..38f05353ed 100644 --- a/source4/utils/net/net_vampire.c +++ b/source4/utils/net/net_vampire.c @@ -25,6 +25,7 @@ #include "librpc/gen_ndr/samr.h" #include "auth/auth.h" #include "param/param.h" +#include "lib/events/events.h" static int net_samdump_keytab_usage(struct net_context *ctx, int argc, const char **argv) { @@ -53,7 +54,7 @@ static int net_samdump_keytab(struct net_context *ctx, int argc, const char **ar break; } - libnetctx = libnet_context_init(NULL, ctx->lp_ctx); + libnetctx = libnet_context_init(event_context_find(ctx), ctx->lp_ctx); if (!libnetctx) { return -1; } @@ -63,7 +64,7 @@ static int net_samdump_keytab(struct net_context *ctx, int argc, const char **ar r.in.machine_account = NULL; r.in.binding_string = NULL; - status = libnet_SamDump_keytab(libnetctx, ctx->mem_ctx, &r); + status = libnet_SamDump_keytab(libnetctx, ctx, &r); if (!NT_STATUS_IS_OK(status)) { DEBUG(0,("libnet_SamDump returned %s: %s\n", nt_errstr(status), @@ -99,7 +100,7 @@ int net_samdump(struct net_context *ctx, int argc, const char **argv) return rc; } - libnetctx = libnet_context_init(NULL, ctx->lp_ctx); + libnetctx = libnet_context_init(event_context_find(ctx), ctx->lp_ctx); if (!libnetctx) { return -1; } @@ -109,7 +110,7 @@ int net_samdump(struct net_context *ctx, int argc, const char **argv) r.in.machine_account = NULL; r.in.binding_string = NULL; - status = libnet_SamDump(libnetctx, ctx->mem_ctx, &r); + status = libnet_SamDump(libnetctx, ctx, &r); if (!NT_STATUS_IS_OK(status)) { DEBUG(0,("libnet_SamDump returned %s: %s\n", nt_errstr(status), @@ -141,7 +142,7 @@ int net_samsync_ldb(struct net_context *ctx, int argc, const char **argv) struct libnet_context *libnetctx; struct libnet_samsync_ldb r; - libnetctx = libnet_context_init(NULL, ctx->lp_ctx); + libnetctx = libnet_context_init(event_context_find(ctx), ctx->lp_ctx); if (!libnetctx) { return -1; } -- cgit From 2bc26db97fea4562415956269d05ea65e5710045 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 14 Apr 2008 20:39:12 +0200 Subject: Fix the build. (This used to be commit a70cbd63d9c398ddcbbaa595ee29343335e89aa7) --- source4/utils/net/net_join.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net_join.c b/source4/utils/net/net_join.c index 2102257c6c..37b3c21fcf 100644 --- a/source4/utils/net/net_join.c +++ b/source4/utils/net/net_join.c @@ -114,11 +114,11 @@ int net_vampire(struct net_context *ctx, int argc, const char **argv) case 0: /* no args -> fail */ return net_vampire_usage(ctx, argc, argv); case 1: /* only DOMAIN */ - tmp = talloc_strdup(ctx->mem_ctx, argv[0]); + tmp = talloc_strdup(ctx, argv[0]); break; case 2: /* domain and target dir */ - tmp = talloc_strdup(ctx->mem_ctx, argv[0]); - targetdir = talloc_strdup(ctx->mem_ctx, argv[1]); + tmp = talloc_strdup(ctx, argv[0]); + targetdir = talloc_strdup(ctx, argv[1]); break; default: /* too many args -> fail */ return net_vampire_usage(ctx, argc, argv); @@ -131,7 +131,7 @@ int net_vampire(struct net_context *ctx, int argc, const char **argv) return -1; } libnetctx->cred = ctx->credentials; - r = talloc(ctx->mem_ctx, struct libnet_Vampire); + r = talloc(ctx, struct libnet_Vampire); if (!r) { return -1; } @@ -151,7 +151,7 @@ int net_vampire(struct net_context *ctx, int argc, const char **argv) talloc_free(libnetctx); return -1; } - d_printf("Vampired domain %s (%s)\n", r->out.domain_name, dom_sid_string(ctx->mem_ctx, r->out.domain_sid)); + d_printf("Vampired domain %s (%s)\n", r->out.domain_name, dom_sid_string(ctx, r->out.domain_sid)); talloc_free(libnetctx); return 0; -- cgit From a5d52174bd993b32d01d26a795a56df4a92eba45 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 16 Apr 2008 22:30:15 +0200 Subject: Avoid event_find_context() when the event context is already available in the net utility. (This used to be commit d40804777edf41889bd461f63f7a07cc1cc60e27) --- source4/utils/net/net.c | 1 + source4/utils/net/net.h | 1 + source4/utils/net/net_join.c | 2 +- source4/utils/net/net_password.c | 4 ++-- source4/utils/net/net_time.c | 2 +- source4/utils/net/net_user.c | 4 ++-- source4/utils/net/net_vampire.c | 6 +++--- 7 files changed, 11 insertions(+), 9 deletions(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net.c b/source4/utils/net/net.c index 6086a4ce32..ab81f07225 100644 --- a/source4/utils/net/net.c +++ b/source4/utils/net/net.c @@ -199,6 +199,7 @@ static int binary_net(int argc, const char **argv) ZERO_STRUCTP(ctx); ctx->lp_ctx = cmdline_lp_ctx; ctx->credentials = cmdline_credentials; + ctx->event_ctx = ev; cli_credentials_set_event_context(ctx->credentials, ev); rc = net_run_function(ctx, argc_new-1, argv_new+1, net_functable, net_usage); diff --git a/source4/utils/net/net.h b/source4/utils/net/net.h index 17388079dd..309bee277c 100644 --- a/source4/utils/net/net.h +++ b/source4/utils/net/net.h @@ -24,6 +24,7 @@ struct net_context { struct cli_credentials *credentials; struct loadparm_context *lp_ctx; + struct event_context *event_ctx; }; struct net_functable { diff --git a/source4/utils/net/net_join.c b/source4/utils/net/net_join.c index 37b3c21fcf..ad63340089 100644 --- a/source4/utils/net/net_join.c +++ b/source4/utils/net/net_join.c @@ -58,7 +58,7 @@ int net_join(struct net_context *ctx, int argc, const char **argv) domain_name = tmp; - libnetctx = libnet_context_init(event_context_find(ctx), ctx->lp_ctx); + libnetctx = libnet_context_init(ctx->event_ctx, ctx->lp_ctx); if (!libnetctx) { return -1; } diff --git a/source4/utils/net/net_password.c b/source4/utils/net/net_password.c index 97bb467fac..55f7c3c31d 100644 --- a/source4/utils/net/net_password.c +++ b/source4/utils/net/net_password.c @@ -53,7 +53,7 @@ static int net_password_change(struct net_context *ctx, int argc, const char **a new_password = getpass(password_prompt); } - libnetctx = libnet_context_init(event_context_find(ctx), ctx->lp_ctx); + libnetctx = libnet_context_init(ctx->event_ctx, ctx->lp_ctx); if (!libnetctx) { return -1; } @@ -128,7 +128,7 @@ static int net_password_set(struct net_context *ctx, int argc, const char **argv new_password = getpass(password_prompt); } - libnetctx = libnet_context_init(event_context_find(ctx), ctx->lp_ctx); + libnetctx = libnet_context_init(ctx->event_ctx, ctx->lp_ctx); if (!libnetctx) { return -1; } diff --git a/source4/utils/net/net_time.c b/source4/utils/net/net_time.c index 12a8132cea..92e6e77481 100644 --- a/source4/utils/net/net_time.c +++ b/source4/utils/net/net_time.c @@ -43,7 +43,7 @@ int net_time(struct net_context *ctx, int argc, const char **argv) return net_time_usage(ctx, argc, argv); } - libnetctx = libnet_context_init(event_context_find(ctx), ctx->lp_ctx); + libnetctx = libnet_context_init(ctx->event_ctx, ctx->lp_ctx); if (!libnetctx) { return -1; } diff --git a/source4/utils/net/net_user.c b/source4/utils/net/net_user.c index 57cef6b383..c4b8ecb0c2 100644 --- a/source4/utils/net/net_user.c +++ b/source4/utils/net/net_user.c @@ -44,7 +44,7 @@ static int net_user_add(struct net_context *ctx, int argc, const char **argv) } /* libnet context init and its params */ - lnet_ctx = libnet_context_init(event_context_find(ctx), ctx->lp_ctx); + lnet_ctx = libnet_context_init(ctx->event_ctx, ctx->lp_ctx); if (!lnet_ctx) return -1; lnet_ctx->cred = ctx->credentials; @@ -84,7 +84,7 @@ static int net_user_delete(struct net_context *ctx, int argc, const char **argv) } /* libnet context init and its params */ - lnet_ctx = libnet_context_init(event_context_find(ctx), ctx->lp_ctx); + lnet_ctx = libnet_context_init(ctx->event_ctx, ctx->lp_ctx); if (!lnet_ctx) return -1; lnet_ctx->cred = ctx->credentials; diff --git a/source4/utils/net/net_vampire.c b/source4/utils/net/net_vampire.c index 38f05353ed..14f6a07e4b 100644 --- a/source4/utils/net/net_vampire.c +++ b/source4/utils/net/net_vampire.c @@ -54,7 +54,7 @@ static int net_samdump_keytab(struct net_context *ctx, int argc, const char **ar break; } - libnetctx = libnet_context_init(event_context_find(ctx), ctx->lp_ctx); + libnetctx = libnet_context_init(ctx->event_ctx, ctx->lp_ctx); if (!libnetctx) { return -1; } @@ -100,7 +100,7 @@ int net_samdump(struct net_context *ctx, int argc, const char **argv) return rc; } - libnetctx = libnet_context_init(event_context_find(ctx), ctx->lp_ctx); + libnetctx = libnet_context_init(ctx->event_ctx, ctx->lp_ctx); if (!libnetctx) { return -1; } @@ -142,7 +142,7 @@ int net_samsync_ldb(struct net_context *ctx, int argc, const char **argv) struct libnet_context *libnetctx; struct libnet_samsync_ldb r; - libnetctx = libnet_context_init(event_context_find(ctx), ctx->lp_ctx); + libnetctx = libnet_context_init(ctx->event_ctx, ctx->lp_ctx); if (!libnetctx) { return -1; } -- cgit From 1efbd5fbf6b0f606ed29a763e2adfa6f99c6beac Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 17 Apr 2008 01:03:18 +0200 Subject: Remove event context tracking from the credentials struct. (This used to be commit 4d7fc946b2ec50e774689c9036423b6feef99b8e) --- source4/utils/net/net.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net.c b/source4/utils/net/net.c index ab81f07225..a87b266568 100644 --- a/source4/utils/net/net.c +++ b/source4/utils/net/net.c @@ -200,7 +200,6 @@ static int binary_net(int argc, const char **argv) ctx->lp_ctx = cmdline_lp_ctx; ctx->credentials = cmdline_credentials; ctx->event_ctx = ev; - cli_credentials_set_event_context(ctx->credentials, ev); rc = net_run_function(ctx, argc_new-1, argv_new+1, net_functable, net_usage); -- cgit From 03643aec88244d976da394521adbd29a31339569 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 18 May 2008 19:54:27 +0200 Subject: Use variables for source directory in a couple more places. (This used to be commit c41bd3005f5f0b9cfd3709fc9217b4a401d265b4) --- source4/utils/net/config.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/config.mk b/source4/utils/net/config.mk index 4423c44c15..e6fa9617a2 100644 --- a/source4/utils/net/config.mk +++ b/source4/utils/net/config.mk @@ -1,4 +1,4 @@ -# utils/net subsystem +# $(utilssrcdir)/net subsystem ################################# # Start BINARY net @@ -15,7 +15,7 @@ PRIVATE_DEPENDENCIES = \ # End BINARY net ################################# -net_OBJ_FILES = $(addprefix utils/net/, \ +net_OBJ_FILES = $(addprefix $(utilssrcdir)/net/, \ net.o \ net_password.o \ net_time.o \ -- cgit From 4c8756f147f8b9a2806fd76e4cb06bb99d391516 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 18 May 2008 22:30:08 +0200 Subject: Create prototype headers from Makefile directory, without smb_build in the middle. (This used to be commit f4a77b96f9c17d853348b70794026e5b9e384942) --- source4/utils/net/config.mk | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/config.mk b/source4/utils/net/config.mk index e6fa9617a2..13c3631b54 100644 --- a/source4/utils/net/config.mk +++ b/source4/utils/net/config.mk @@ -4,7 +4,6 @@ # Start BINARY net [BINARY::net] INSTALLDIR = BINDIR -PRIVATE_PROTO_HEADER = net_proto.h PRIVATE_DEPENDENCIES = \ LIBSAMBA-HOSTCONFIG \ LIBSAMBA-UTIL \ @@ -23,3 +22,5 @@ net_OBJ_FILES = $(addprefix $(utilssrcdir)/net/, \ net_vampire.o \ net_user.o) + +$(call proto_header_template,$(utilssrcdir)/net/net_proto.h,$(net_OBJ_FILES:.o=.c)) -- cgit From 4c70cda986c86fe536327321d04c29eca81b6409 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 18 May 2008 23:02:47 +0200 Subject: Fix a couple (well, little more than that..) of typos. (This used to be commit a6b52119940a900fb0de3864b8bca94e2965cc24) --- source4/utils/net/config.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/config.mk b/source4/utils/net/config.mk index 13c3631b54..93b51e1e28 100644 --- a/source4/utils/net/config.mk +++ b/source4/utils/net/config.mk @@ -23,4 +23,4 @@ net_OBJ_FILES = $(addprefix $(utilssrcdir)/net/, \ net_user.o) -$(call proto_header_template,$(utilssrcdir)/net/net_proto.h,$(net_OBJ_FILES:.o=.c)) +$(eval $(call proto_header_template,$(utilssrcdir)/net/net_proto.h,$(net_OBJ_FILES:.o=.c))) -- cgit From 2daf2897d5c70c0efbeba9b827c62700b9a9537c Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 14 Jun 2008 13:00:53 -0400 Subject: Use a custom init function for samba4 that sets a samba4 specific debug function. By default do not debug, this is the most appropriate action for a library as we cannot assume what stderr is use for in the main app. The main app is responsible to set ev_debug_stderr if they so desire. (This used to be commit e566a2f308ac6fb4b526a744f7059b565670aea5) --- source4/utils/net/net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/utils/net') diff --git a/source4/utils/net/net.c b/source4/utils/net/net.c index a87b266568..1c834fe4f0 100644 --- a/source4/utils/net/net.c +++ b/source4/utils/net/net.c @@ -185,7 +185,7 @@ static int binary_net(int argc, const char **argv) dcerpc_init(); - ev = event_context_init(NULL); + ev = s4_event_context_init(NULL); if (!ev) { d_printf("Failed to create an event context\n"); exit(1); -- cgit