From 3ccc7609476139bc6a906110a2623605f3802159 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 8 Jun 2011 15:42:22 +1000 Subject: s3-param Remove special case for lp_workgroup() There is no reason this can't be a normal constant string in the loadparm system, now that we have lp_set_cmdline() to handle overrides correctly. Andrew Bartlett --- source3/client/client.c | 15 +-------------- source3/include/proto.h | 2 +- source3/lib/popt_common.c | 4 ++-- source3/lib/util_names.c | 19 ------------------- source3/param/loadparm.c | 19 +++---------------- source3/rpcclient/rpcclient.c | 10 +--------- 6 files changed, 8 insertions(+), 61 deletions(-) diff --git a/source3/client/client.c b/source3/client/client.c index d25198bfb9..209c2cb1c9 100644 --- a/source3/client/client.c +++ b/source3/client/client.c @@ -5068,7 +5068,6 @@ static int do_message_op(struct user_auth_info *a_info) poptContext pc; char *p; int rc = 0; - fstring new_workgroup; bool tar_opt = false; bool service_opt = false; struct poptOption long_options[] = { @@ -5098,10 +5097,9 @@ static int do_message_op(struct user_auth_info *a_info) exit(ENOMEM); } - /* initialize the workgroup name so we can determine whether or + /* initialize the netbios name so we can determine whether or not it was set by a command line option */ - set_global_myworkgroup( "" ); set_global_myname( "" ); /* set default debug level to 1 regardless of what smb.conf sets */ @@ -5249,13 +5247,6 @@ static int do_message_op(struct user_auth_info *a_info) poptGetArg(pc)); } - /* save the workgroup... - - FIXME!! do we need to do this for other options as well - (or maybe a generic way to keep lp_load() from overwriting - everything)? */ - - fstrcpy( new_workgroup, lp_workgroup() ); calling_name = talloc_strdup(frame, global_myname() ); if (!calling_name) { exit(ENOMEM); @@ -5294,10 +5285,6 @@ static int do_message_op(struct user_auth_info *a_info) } } - if ( strlen(new_workgroup) != 0 ) { - set_global_myworkgroup( new_workgroup ); - } - if ( strlen(calling_name) != 0 ) { set_global_myname( calling_name ); } else { diff --git a/source3/include/proto.h b/source3/include/proto.h index 42c62d2f6f..2edd72e026 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -497,7 +497,6 @@ void gfree_netbios_names(void); bool set_global_myname(const char *myname); const char *global_myname(void); bool set_global_myworkgroup(const char *myworkgroup); -const char *lp_workgroup(void); const char *get_global_sam_name(void); /* The following definitions come from lib/util.c */ @@ -1199,6 +1198,7 @@ char *lp_passwd_program(void); char *lp_passwd_chat(void); const char *lp_passwordserver(void); const char *lp_name_resolve_order(void); +const char *lp_workgroup(void); const char *lp_realm(void); const char *lp_dnsdomain(void); const char *lp_afs_username_map(void); diff --git a/source3/lib/popt_common.c b/source3/lib/popt_common.c index 8416d70bc4..628ed65820 100644 --- a/source3/lib/popt_common.c +++ b/source3/lib/popt_common.c @@ -149,7 +149,7 @@ static void popt_common_callback(poptContext con, case 'W': if (arg) { - set_global_myworkgroup(arg); + lp_set_cmdline("workgroup", arg); } break; } @@ -473,7 +473,7 @@ static void get_credentials_file(struct user_auth_info *auth_info, } else if (strwicmp("username", param) == 0) { set_cmdline_auth_info_username(auth_info, val); } else if (strwicmp("domain", param) == 0) { - set_cmdline_auth_info_domain(val); + set_cmdline_auth_info_domain(auth_info, val); } memset(buf, 0, sizeof(buf)); } diff --git a/source3/lib/util_names.c b/source3/lib/util_names.c index 8170c8bb11..d8ebf213cf 100644 --- a/source3/lib/util_names.c +++ b/source3/lib/util_names.c @@ -207,25 +207,6 @@ const char *global_myname(void) return smb_myname; } -/*********************************************************************** - Allocate and set myworkgroup. Ensure upper case. -***********************************************************************/ - -bool set_global_myworkgroup(const char *myworkgroup) -{ - SAFE_FREE(smb_myworkgroup); - smb_myworkgroup = SMB_STRDUP(myworkgroup); - if (!smb_myworkgroup) - return False; - strupper_m(smb_myworkgroup); - return True; -} - -const char *lp_workgroup(void) -{ - return smb_myworkgroup; -} - /****************************************************************** get the default domain/netbios name to be used when dealing with our passdb list of accounts diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c index dc79c36f19..56f039f46e 100644 --- a/source3/param/loadparm.c +++ b/source3/param/loadparm.c @@ -706,7 +706,6 @@ static bool handle_idmap_backend(int snum, const char *pszParmValue, char **ptr) static bool handle_idmap_uid( int snum, const char *pszParmValue, char **ptr); static bool handle_idmap_gid( int snum, const char *pszParmValue, char **ptr); static bool handle_debug_list( int snum, const char *pszParmValue, char **ptr ); -static bool handle_workgroup( int snum, const char *pszParmValue, char **ptr ); static bool handle_realm( int snum, const char *pszParmValue, char **ptr ); static bool handle_netbios_aliases( int snum, const char *pszParmValue, char **ptr ); static bool handle_netbios_scope( int snum, const char *pszParmValue, char **ptr ); @@ -1013,7 +1012,7 @@ static struct parm_struct parm_table[] = { .type = P_USTRING, .p_class = P_GLOBAL, .ptr = &Globals.szWorkgroup, - .special = handle_workgroup, + .special = NULL, .enum_list = NULL, .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD, }, @@ -5213,8 +5212,7 @@ static void init_globals(bool reinit_globals) set_global_myname(myhostname()); string_set(&Globals.szNetbiosName,global_myname()); - set_global_myworkgroup(WORKGROUP); - string_set(&Globals.szWorkgroup, lp_workgroup()); + string_set(&Globals.szWorkgroup, WORKGROUP); string_set(&Globals.szPasswdProgram, ""); string_set(&Globals.szLockDir, get_dyn_LOCKDIR()); @@ -5619,6 +5617,7 @@ FN_GLOBAL_STRING(lp_passwd_program, &Globals.szPasswdProgram) FN_GLOBAL_STRING(lp_passwd_chat, &Globals.szPasswdChat) FN_GLOBAL_CONST_STRING(lp_passwordserver, &Globals.szPasswordServer) FN_GLOBAL_CONST_STRING(lp_name_resolve_order, &Globals.szNameResolveOrder) +FN_GLOBAL_CONST_STRING(lp_workgroup, &Globals.szWorkgroup) FN_GLOBAL_CONST_STRING(lp_realm, &Globals.szRealmUpper) FN_GLOBAL_CONST_STRING(lp_dnsdomain, &Globals.szDnsDomain) FN_GLOBAL_CONST_STRING(lp_afs_username_map, &Globals.szAfsUsernameMap) @@ -7585,18 +7584,6 @@ static bool handle_dos_charset(int snum, const char *pszParmValue, char **ptr) return true; } - - -static bool handle_workgroup(int snum, const char *pszParmValue, char **ptr) -{ - bool ret; - - ret = set_global_myworkgroup(pszParmValue); - string_set(&Globals.szWorkgroup,lp_workgroup()); - - return ret; -} - static bool handle_realm(int snum, const char *pszParmValue, char **ptr) { bool ret = true; diff --git a/source3/rpcclient/rpcclient.c b/source3/rpcclient/rpcclient.c index 466212b23a..5808f371f0 100644 --- a/source3/rpcclient/rpcclient.c +++ b/source3/rpcclient/rpcclient.c @@ -975,21 +975,13 @@ out_free: goto done; } - /* save the workgroup... - - FIXME!! do we need to do this for other options as well - (or maybe a generic way to keep lp_load() from overwriting - everything)? */ - - fstrcpy( new_workgroup, lp_workgroup() ); - /* Load smb.conf file */ if (!lp_load(get_dyn_CONFIGFILE(),True,False,False,True)) fprintf(stderr, "Can't load %s\n", get_dyn_CONFIGFILE()); if ( strlen(new_workgroup) != 0 ) - set_global_myworkgroup( new_workgroup ); + lp_set_cmdline("workgroup", new_workgroup ); /* * Get password -- cgit