From ef2e26c91b80556af033d3335e55f5dfa6fff31d Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 13 Aug 2003 01:53:07 +0000 Subject: first public release of samba4 code (This used to be commit b0510b5428b3461aeb9bbe3cc95f62fc73e2b97f) --- source4/utils/testparm.c | 338 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 338 insertions(+) create mode 100644 source4/utils/testparm.c (limited to 'source4/utils/testparm.c') diff --git a/source4/utils/testparm.c b/source4/utils/testparm.c new file mode 100644 index 0000000000..b68deaaa5d --- /dev/null +++ b/source4/utils/testparm.c @@ -0,0 +1,338 @@ +/* + Unix SMB/CIFS implementation. + Test validity of smb.conf + Copyright (C) Karl Auer 1993, 1994-1998 + + Extensively modified by Andrew Tridgell, 1995 + Converted to popt by Jelmer Vernooij (jelmer@nl.linux.org), 2002 + + 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. +*/ + +/* + * Testbed for loadparm.c/params.c + * + * This module simply loads a specified configuration file and + * if successful, dumps it's contents to stdout. Note that the + * operation is performed with DEBUGLEVEL at 3. + * + * Useful for a quick 'syntax check' of a configuration file. + * + */ + +#include "includes.h" + +extern BOOL AllowDebugChange; + +/*********************************************** + Here we do a set of 'hard coded' checks for bad + configuration settings. +************************************************/ + +static int do_global_checks(void) +{ + int ret = 0; + SMB_STRUCT_STAT st; + + if (lp_security() >= SEC_DOMAIN && !lp_encrypted_passwords()) { + printf("ERROR: in 'security=domain' mode the 'encrypt passwords' parameter must always be set to 'true'.\n"); + ret = 1; + } + + if (lp_wins_support() && lp_wins_server_list()) { + printf("ERROR: both 'wins support = true' and 'wins server = ' \ +cannot be set in the smb.conf file. nmbd will abort with this setting.\n"); + ret = 1; + } + + if (!directory_exist(lp_lockdir(), &st)) { + printf("ERROR: lock directory %s does not exist\n", + lp_lockdir()); + ret = 1; + } else if ((st.st_mode & 0777) != 0755) { + printf("WARNING: lock directory %s should have permissions 0755 for browsing to work\n", + lp_lockdir()); + ret = 1; + } + + if (!directory_exist(lp_piddir(), &st)) { + printf("ERROR: pid directory %s does not exist\n", + lp_piddir()); + ret = 1; + } + + /* + * Password server sanity checks. + */ + + if((lp_security() == SEC_SERVER || lp_security() >= SEC_DOMAIN) && !lp_passwordserver()) { + pstring sec_setting; + if(lp_security() == SEC_SERVER) + pstrcpy(sec_setting, "server"); + else if(lp_security() == SEC_DOMAIN) + pstrcpy(sec_setting, "domain"); + + printf("ERROR: The setting 'security=%s' requires the 'password server' parameter be set \ +to a valid password server.\n", sec_setting ); + ret = 1; + } + + + /* + * Check 'hosts equiv' and 'use rhosts' compatibility with 'hostname lookup' value. + */ + + if(*lp_hosts_equiv() && !lp_hostname_lookups()) { + printf("ERROR: The setting 'hosts equiv = %s' requires that 'hostname lookups = yes'.\n", lp_hosts_equiv()); + ret = 1; + } + + /* + * Password chat sanity checks. + */ + + if(lp_security() == SEC_USER && lp_unix_password_sync()) { + + /* + * Check that we have a valid lp_passwd_program() if not using pam. + */ + +#ifdef WITH_PAM + if (!lp_pam_password_change()) { +#endif + + if(lp_passwd_program() == NULL) { + printf("ERROR: the 'unix password sync' parameter is set and there is no valid 'passwd program' \ +parameter.\n" ); + ret = 1; + } else { + pstring passwd_prog; + pstring truncated_prog; + const char *p; + + pstrcpy( passwd_prog, lp_passwd_program()); + p = passwd_prog; + *truncated_prog = '\0'; + next_token(&p, truncated_prog, NULL, sizeof(pstring)); + + if(access(truncated_prog, F_OK) == -1) { + printf("ERROR: the 'unix password sync' parameter is set and the 'passwd program' (%s) \ +cannot be executed (error was %s).\n", truncated_prog, strerror(errno) ); + ret = 1; + } + } + +#ifdef WITH_PAM + } +#endif + + if(lp_passwd_chat() == NULL) { + printf("ERROR: the 'unix password sync' parameter is set and there is no valid 'passwd chat' \ +parameter.\n"); + ret = 1; + } + + /* + * Check that we have a valid script and that it hasn't + * been written to expect the old password. + */ + + if(lp_encrypted_passwords()) { + if(strstr( lp_passwd_chat(), "%o")!=NULL) { + printf("ERROR: the 'passwd chat' script [%s] expects to use the old plaintext password \ +via the %%o substitution. With encrypted passwords this is not possible.\n", lp_passwd_chat() ); + ret = 1; + } + } + } + + if (strlen(lp_winbind_separator()) != 1) { + printf("ERROR: the 'winbind separator' parameter must be a single character.\n"); + ret = 1; + } + + if (*lp_winbind_separator() == '+') { + printf("'winbind separator = +' might cause problems with group membership.\n"); + } + + if (lp_algorithmic_rid_base() < BASE_RID) { + /* Try to prevent admin foot-shooting, we can't put algorithmic + rids below 1000, that's the 'well known RIDs' on NT */ + printf("'algorithmic rid base' must be equal to or above %lu\n", BASE_RID); + } + + if (lp_algorithmic_rid_base() & 1) { + printf("'algorithmic rid base' must be even.\n"); + } + +#ifndef HAVE_DLOPEN + if (lp_preload_modules()) { + printf("WARNING: 'preload modules = ' set while loading plugins not supported.\n"); + } +#endif + + return ret; +} + +int main(int argc, const char *argv[]) +{ + extern char *optarg; + extern int optind; + const char *config_file = dyn_CONFIGFILE; + int s; + static BOOL silent_mode = False; + int ret = 0; + int opt; + poptContext pc; + static const char *term_code = ""; + static char *new_local_machine = NULL; + const char *cname; + const char *caddr; + static int show_defaults; + + struct poptOption long_options[] = { + POPT_AUTOHELP + {"suppress-prompt", 's', POPT_ARG_VAL, &silent_mode, 1, "Suppress prompt for enter"}, + {"verbose", 'v', POPT_ARG_NONE, &show_defaults, 1, "Show default options too"}, + {"server", 'L',POPT_ARG_STRING, &new_local_machine, 0, "Set %%L macro to servername\n"}, + {"encoding", 't', POPT_ARG_STRING, &term_code, 0, "Print parameters with encoding"}, + {NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_version}, + {0,0,0,0} + }; + + pc = poptGetContext(NULL, argc, argv, long_options, + POPT_CONTEXT_KEEP_FIRST); + poptSetOtherOptionHelp(pc, "[OPTION...] [host-name] [host-ip]"); + + while((opt = poptGetNextOpt(pc)) != -1); + + setup_logging(poptGetArg(pc), True); + + if (poptPeekArg(pc)) + config_file = poptGetArg(pc); + + cname = poptGetArg(pc); + caddr = poptGetArg(pc); + + if (new_local_machine) { + set_local_machine_name(new_local_machine); + } + + dbf = x_stdout; + DEBUGLEVEL = 2; + AllowDebugChange = False; + + printf("Load smb config files from %s\n",config_file); + + if (!lp_load(config_file,False,True,False)) { + printf("Error loading services.\n"); + return(1); + } + + printf("Loaded services file OK.\n"); + + ret = do_global_checks(); + + for (s=0;s<1000;s++) { + if (VALID_SNUM(s)) + if (strlen(lp_servicename(s)) > 8) { + printf("WARNING: You have some share names that are longer than 8 chars\n"); + printf("These may give errors while browsing or may not be accessible\nto some older clients\n"); + break; + } + } + + for (s=0;s<1000;s++) { + if (VALID_SNUM(s)) { + const char **deny_list = lp_hostsdeny(s); + const char **allow_list = lp_hostsallow(s); + int i; + if(deny_list) { + for (i=0; deny_list[i]; i++) { + char *hasstar = strchr_m(deny_list[i], '*'); + char *hasquery = strchr_m(deny_list[i], '?'); + if(hasstar || hasquery) { + printf("Invalid character %c in hosts deny list (%s) for service %s.\n", + hasstar ? *hasstar : *hasquery, deny_list[i], lp_servicename(s) ); + } + } + } + + if(allow_list) { + for (i=0; allow_list[i]; i++) { + char *hasstar = strchr_m(allow_list[i], '*'); + char *hasquery = strchr_m(allow_list[i], '?'); + if(hasstar || hasquery) { + printf("Invalid character %c in hosts allow list (%s) for service %s.\n", + hasstar ? *hasstar : *hasquery, allow_list[i], lp_servicename(s) ); + } + } + } + + if(lp_level2_oplocks(s) && !lp_oplocks(s)) { + printf("Invalid combination of parameters for service %s. \ + Level II oplocks can only be set if oplocks are also set.\n", + lp_servicename(s) ); + } + } + } + + + if (!silent_mode) { + printf("Server role: "); + switch(lp_server_role()) { + case ROLE_STANDALONE: + printf("ROLE_STANDALONE\n"); + break; + case ROLE_DOMAIN_MEMBER: + printf("ROLE_DOMAIN_MEMBER\n"); + break; + case ROLE_DOMAIN_BDC: + printf("ROLE_DOMAIN_BDC\n"); + break; + case ROLE_DOMAIN_PDC: + printf("ROLE_DOMAIN_PDC\n"); + break; + default: + printf("Unknown -- internal error?\n"); + break; + } + } + + if (!cname) { + if (!silent_mode) { + printf("Press enter to see a dump of your service definitions\n"); + fflush(stdout); + getc(stdin); + } + lp_dump(stdout, show_defaults, lp_numservices()); + } + + if(cname && caddr){ + /* this is totally ugly, a real `quick' hack */ + for (s=0;s<1000;s++) { + if (VALID_SNUM(s)) { + if (allow_access(lp_hostsdeny(s), lp_hostsallow(s), cname, caddr)) { + printf("Allow connection from %s (%s) to %s\n", + cname,caddr,lp_servicename(s)); + } else { + printf("Deny connection from %s (%s) to %s\n", + cname,caddr,lp_servicename(s)); + } + } + } + } + return(ret); +} -- cgit From 8e4ab747b02207671203d40cd2a78692da78faef Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 15 Aug 2003 18:33:43 +0000 Subject: more fixes from the IRIX compiler (thanks herb!) (This used to be commit 4cf3839b727c77a727abb558bd9473119a092913) --- source4/utils/testparm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/utils/testparm.c') diff --git a/source4/utils/testparm.c b/source4/utils/testparm.c index b68deaaa5d..fdfb6cb426 100644 --- a/source4/utils/testparm.c +++ b/source4/utils/testparm.c @@ -218,7 +218,7 @@ int main(int argc, const char *argv[]) while((opt = poptGetNextOpt(pc)) != -1); - setup_logging(poptGetArg(pc), True); + setup_logging(poptGetArg(pc), DEBUG_STDOUT); if (poptPeekArg(pc)) config_file = poptGetArg(pc); -- cgit From f1a8a690fcd9e8824dade9278e83902a6229b092 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 24 May 2004 17:28:29 +0000 Subject: r852: remove unused utility progs metze (This used to be commit 4ef0b3656abdebb698d93936ae6ca492a8d35ef8) --- source4/utils/testparm.c | 338 ----------------------------------------------- 1 file changed, 338 deletions(-) delete mode 100644 source4/utils/testparm.c (limited to 'source4/utils/testparm.c') diff --git a/source4/utils/testparm.c b/source4/utils/testparm.c deleted file mode 100644 index fdfb6cb426..0000000000 --- a/source4/utils/testparm.c +++ /dev/null @@ -1,338 +0,0 @@ -/* - Unix SMB/CIFS implementation. - Test validity of smb.conf - Copyright (C) Karl Auer 1993, 1994-1998 - - Extensively modified by Andrew Tridgell, 1995 - Converted to popt by Jelmer Vernooij (jelmer@nl.linux.org), 2002 - - 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. -*/ - -/* - * Testbed for loadparm.c/params.c - * - * This module simply loads a specified configuration file and - * if successful, dumps it's contents to stdout. Note that the - * operation is performed with DEBUGLEVEL at 3. - * - * Useful for a quick 'syntax check' of a configuration file. - * - */ - -#include "includes.h" - -extern BOOL AllowDebugChange; - -/*********************************************** - Here we do a set of 'hard coded' checks for bad - configuration settings. -************************************************/ - -static int do_global_checks(void) -{ - int ret = 0; - SMB_STRUCT_STAT st; - - if (lp_security() >= SEC_DOMAIN && !lp_encrypted_passwords()) { - printf("ERROR: in 'security=domain' mode the 'encrypt passwords' parameter must always be set to 'true'.\n"); - ret = 1; - } - - if (lp_wins_support() && lp_wins_server_list()) { - printf("ERROR: both 'wins support = true' and 'wins server = ' \ -cannot be set in the smb.conf file. nmbd will abort with this setting.\n"); - ret = 1; - } - - if (!directory_exist(lp_lockdir(), &st)) { - printf("ERROR: lock directory %s does not exist\n", - lp_lockdir()); - ret = 1; - } else if ((st.st_mode & 0777) != 0755) { - printf("WARNING: lock directory %s should have permissions 0755 for browsing to work\n", - lp_lockdir()); - ret = 1; - } - - if (!directory_exist(lp_piddir(), &st)) { - printf("ERROR: pid directory %s does not exist\n", - lp_piddir()); - ret = 1; - } - - /* - * Password server sanity checks. - */ - - if((lp_security() == SEC_SERVER || lp_security() >= SEC_DOMAIN) && !lp_passwordserver()) { - pstring sec_setting; - if(lp_security() == SEC_SERVER) - pstrcpy(sec_setting, "server"); - else if(lp_security() == SEC_DOMAIN) - pstrcpy(sec_setting, "domain"); - - printf("ERROR: The setting 'security=%s' requires the 'password server' parameter be set \ -to a valid password server.\n", sec_setting ); - ret = 1; - } - - - /* - * Check 'hosts equiv' and 'use rhosts' compatibility with 'hostname lookup' value. - */ - - if(*lp_hosts_equiv() && !lp_hostname_lookups()) { - printf("ERROR: The setting 'hosts equiv = %s' requires that 'hostname lookups = yes'.\n", lp_hosts_equiv()); - ret = 1; - } - - /* - * Password chat sanity checks. - */ - - if(lp_security() == SEC_USER && lp_unix_password_sync()) { - - /* - * Check that we have a valid lp_passwd_program() if not using pam. - */ - -#ifdef WITH_PAM - if (!lp_pam_password_change()) { -#endif - - if(lp_passwd_program() == NULL) { - printf("ERROR: the 'unix password sync' parameter is set and there is no valid 'passwd program' \ -parameter.\n" ); - ret = 1; - } else { - pstring passwd_prog; - pstring truncated_prog; - const char *p; - - pstrcpy( passwd_prog, lp_passwd_program()); - p = passwd_prog; - *truncated_prog = '\0'; - next_token(&p, truncated_prog, NULL, sizeof(pstring)); - - if(access(truncated_prog, F_OK) == -1) { - printf("ERROR: the 'unix password sync' parameter is set and the 'passwd program' (%s) \ -cannot be executed (error was %s).\n", truncated_prog, strerror(errno) ); - ret = 1; - } - } - -#ifdef WITH_PAM - } -#endif - - if(lp_passwd_chat() == NULL) { - printf("ERROR: the 'unix password sync' parameter is set and there is no valid 'passwd chat' \ -parameter.\n"); - ret = 1; - } - - /* - * Check that we have a valid script and that it hasn't - * been written to expect the old password. - */ - - if(lp_encrypted_passwords()) { - if(strstr( lp_passwd_chat(), "%o")!=NULL) { - printf("ERROR: the 'passwd chat' script [%s] expects to use the old plaintext password \ -via the %%o substitution. With encrypted passwords this is not possible.\n", lp_passwd_chat() ); - ret = 1; - } - } - } - - if (strlen(lp_winbind_separator()) != 1) { - printf("ERROR: the 'winbind separator' parameter must be a single character.\n"); - ret = 1; - } - - if (*lp_winbind_separator() == '+') { - printf("'winbind separator = +' might cause problems with group membership.\n"); - } - - if (lp_algorithmic_rid_base() < BASE_RID) { - /* Try to prevent admin foot-shooting, we can't put algorithmic - rids below 1000, that's the 'well known RIDs' on NT */ - printf("'algorithmic rid base' must be equal to or above %lu\n", BASE_RID); - } - - if (lp_algorithmic_rid_base() & 1) { - printf("'algorithmic rid base' must be even.\n"); - } - -#ifndef HAVE_DLOPEN - if (lp_preload_modules()) { - printf("WARNING: 'preload modules = ' set while loading plugins not supported.\n"); - } -#endif - - return ret; -} - -int main(int argc, const char *argv[]) -{ - extern char *optarg; - extern int optind; - const char *config_file = dyn_CONFIGFILE; - int s; - static BOOL silent_mode = False; - int ret = 0; - int opt; - poptContext pc; - static const char *term_code = ""; - static char *new_local_machine = NULL; - const char *cname; - const char *caddr; - static int show_defaults; - - struct poptOption long_options[] = { - POPT_AUTOHELP - {"suppress-prompt", 's', POPT_ARG_VAL, &silent_mode, 1, "Suppress prompt for enter"}, - {"verbose", 'v', POPT_ARG_NONE, &show_defaults, 1, "Show default options too"}, - {"server", 'L',POPT_ARG_STRING, &new_local_machine, 0, "Set %%L macro to servername\n"}, - {"encoding", 't', POPT_ARG_STRING, &term_code, 0, "Print parameters with encoding"}, - {NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_version}, - {0,0,0,0} - }; - - pc = poptGetContext(NULL, argc, argv, long_options, - POPT_CONTEXT_KEEP_FIRST); - poptSetOtherOptionHelp(pc, "[OPTION...] [host-name] [host-ip]"); - - while((opt = poptGetNextOpt(pc)) != -1); - - setup_logging(poptGetArg(pc), DEBUG_STDOUT); - - if (poptPeekArg(pc)) - config_file = poptGetArg(pc); - - cname = poptGetArg(pc); - caddr = poptGetArg(pc); - - if (new_local_machine) { - set_local_machine_name(new_local_machine); - } - - dbf = x_stdout; - DEBUGLEVEL = 2; - AllowDebugChange = False; - - printf("Load smb config files from %s\n",config_file); - - if (!lp_load(config_file,False,True,False)) { - printf("Error loading services.\n"); - return(1); - } - - printf("Loaded services file OK.\n"); - - ret = do_global_checks(); - - for (s=0;s<1000;s++) { - if (VALID_SNUM(s)) - if (strlen(lp_servicename(s)) > 8) { - printf("WARNING: You have some share names that are longer than 8 chars\n"); - printf("These may give errors while browsing or may not be accessible\nto some older clients\n"); - break; - } - } - - for (s=0;s<1000;s++) { - if (VALID_SNUM(s)) { - const char **deny_list = lp_hostsdeny(s); - const char **allow_list = lp_hostsallow(s); - int i; - if(deny_list) { - for (i=0; deny_list[i]; i++) { - char *hasstar = strchr_m(deny_list[i], '*'); - char *hasquery = strchr_m(deny_list[i], '?'); - if(hasstar || hasquery) { - printf("Invalid character %c in hosts deny list (%s) for service %s.\n", - hasstar ? *hasstar : *hasquery, deny_list[i], lp_servicename(s) ); - } - } - } - - if(allow_list) { - for (i=0; allow_list[i]; i++) { - char *hasstar = strchr_m(allow_list[i], '*'); - char *hasquery = strchr_m(allow_list[i], '?'); - if(hasstar || hasquery) { - printf("Invalid character %c in hosts allow list (%s) for service %s.\n", - hasstar ? *hasstar : *hasquery, allow_list[i], lp_servicename(s) ); - } - } - } - - if(lp_level2_oplocks(s) && !lp_oplocks(s)) { - printf("Invalid combination of parameters for service %s. \ - Level II oplocks can only be set if oplocks are also set.\n", - lp_servicename(s) ); - } - } - } - - - if (!silent_mode) { - printf("Server role: "); - switch(lp_server_role()) { - case ROLE_STANDALONE: - printf("ROLE_STANDALONE\n"); - break; - case ROLE_DOMAIN_MEMBER: - printf("ROLE_DOMAIN_MEMBER\n"); - break; - case ROLE_DOMAIN_BDC: - printf("ROLE_DOMAIN_BDC\n"); - break; - case ROLE_DOMAIN_PDC: - printf("ROLE_DOMAIN_PDC\n"); - break; - default: - printf("Unknown -- internal error?\n"); - break; - } - } - - if (!cname) { - if (!silent_mode) { - printf("Press enter to see a dump of your service definitions\n"); - fflush(stdout); - getc(stdin); - } - lp_dump(stdout, show_defaults, lp_numservices()); - } - - if(cname && caddr){ - /* this is totally ugly, a real `quick' hack */ - for (s=0;s<1000;s++) { - if (VALID_SNUM(s)) { - if (allow_access(lp_hostsdeny(s), lp_hostsallow(s), cname, caddr)) { - printf("Allow connection from %s (%s) to %s\n", - cname,caddr,lp_servicename(s)); - } else { - printf("Deny connection from %s (%s) to %s\n", - cname,caddr,lp_servicename(s)); - } - } - } - } - return(ret); -} -- cgit From 37bc6b5f813d5c2ace7486a38331748dd86f121d Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 6 Jan 2006 00:46:35 +0000 Subject: r12728: Revive testparm. It needs work to not dump defaults from loadparm.c, but otherwise it works. Andrew Bartlett (This used to be commit 1260fcf46579d708a406625f548add9be9fdc6fb) --- source4/utils/testparm.c | 219 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 219 insertions(+) create mode 100644 source4/utils/testparm.c (limited to 'source4/utils/testparm.c') diff --git a/source4/utils/testparm.c b/source4/utils/testparm.c new file mode 100644 index 0000000000..05aa5ff547 --- /dev/null +++ b/source4/utils/testparm.c @@ -0,0 +1,219 @@ +/* + Unix SMB/CIFS implementation. + Test validity of smb.conf + Copyright (C) Karl Auer 1993, 1994-1998 + + Extensively modified by Andrew Tridgell, 1995 + Converted to popt by Jelmer Vernooij (jelmer@nl.linux.org), 2002 + Updated for Samba4 by Andrew Bartlett 2006 + + 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. +*/ + +/* + * Testbed for loadparm.c/params.c + * + * This module simply loads a specified configuration file and + * if successful, dumps it's contents to stdout. Note that the + * operation is performed with DEBUGLEVEL at 3. + * + * Useful for a quick 'syntax check' of a configuration file. + * + */ + +#include "includes.h" +#include "system/filesys.h" +#include "lib/cmdline/popt_common.h" +#include "lib/socket/socket.h" + + +/*********************************************** + Here we do a set of 'hard coded' checks for bad + configuration settings. +************************************************/ + +static int do_global_checks(void) +{ + int ret = 0; + + if (!directory_exist(lp_lockdir())) { + fprintf(stderr, "ERROR: lock directory %s does not exist\n", + lp_lockdir()); + ret = 1; + } + + if (!directory_exist(lp_piddir())) { + fprintf(stderr, "ERROR: pid directory %s does not exist\n", + lp_piddir()); + ret = 1; + } + + if (strlen(lp_winbind_separator()) != 1) { + fprintf(stderr,"ERROR: the 'winbind separator' parameter must be a single character.\n"); + ret = 1; + } + + if (*lp_winbind_separator() == '+') { + fprintf(stderr,"'winbind separator = +' might cause problems with group membership.\n"); + } + + return ret; +} + + int main(int argc, const char *argv[]) +{ + int s; + static BOOL silent_mode = False; + int ret = 0; + poptContext pc; + static const char *term_code = ""; +/* + static BOOL show_all_parameters = False; + static char *parameter_name = NULL; + static const char *section_name = NULL; + static char *new_local_machine = NULL; +*/ + static const char *cname; + static const char *caddr; + static int show_defaults; + + struct poptOption long_options[] = { + POPT_AUTOHELP + {"suppress-prompt", 's', POPT_ARG_VAL, &silent_mode, 1, "Suppress prompt for enter"}, + {"verbose", 'v', POPT_ARG_NONE, &show_defaults, 1, "Show default options too"}, +/* + We need support for smb.conf macros before this will work again + {"server", 'L',POPT_ARG_STRING, &new_local_machine, 0, "Set %%L macro to servername\n"}, +*/ {"encoding", 't', POPT_ARG_STRING, &term_code, 0, "Print parameters with encoding"}, +/* + These are harder to do with the new code structure + {"show-all-parameters", '\0', POPT_ARG_VAL, &show_all_parameters, True, "Show the parameters, type, possible values" }, + {"parameter-name", '\0', POPT_ARG_STRING, ¶meter_name, 0, "Limit testparm to a named parameter" }, + {"section-name", '\0', POPT_ARG_STRING, §ion_name, 0, "Limit testparm to a named section" }, +*/ + {"client-name", '\0', POPT_ARG_STRING, &cname, 0, "Client DNS name for 'hosts allow' checking (should match reverse lookup)"}, + {"client-ip", '\0', POPT_ARG_STRING, &caddr, 0, "Client IP address for 'hosts allow' checking"}, + POPT_COMMON_VERSION + POPT_TABLEEND + }; + + setup_logging(NULL, DEBUG_STDERR); + + pc = poptGetContext(NULL, argc, argv, long_options, + POPT_CONTEXT_KEEP_FIRST); + poptSetOtherOptionHelp(pc, "[OPTION...] [host-name] [host-ip]"); + + while(poptGetNextOpt(pc) != -1); + +/* + if (show_all_parameters) { + show_parameter_list(); + exit(0); + } +*/ + + if ( cname && ! caddr ) { + printf ( "ERROR: For 'hosts allow' check you must specify both a DNS name and an IP address.\n" ); + return(1); + } +/* + We need support for smb.conf macros before this will work again + + if (new_local_machine) { + set_local_machine_name(new_local_machine, True); + } +*/ + + /* We need this to force the output */ + lp_set_cmdline("log level", "2"); + + fprintf(stderr,"Load smb config files from %s\n",lp_configfile()); + + if (!lp_load()) { + fprintf(stderr,"Error loading services.\n"); + return(1); + } + + fprintf(stderr,"Loaded services file OK.\n"); + + ret = do_global_checks(); + + for (s=0;s 12) { + fprintf(stderr, "WARNING: You have some share names that are longer than 12 characters.\n" ); + fprintf(stderr, "These may not be accessible to some older clients.\n" ); + fprintf(stderr, "(Eg. Windows9x, WindowsMe, and not listed in smbclient in Samba 3.0.)\n" ); + break; + } + } + + for (s=0;s Date: Fri, 6 Jan 2006 02:13:01 +0000 Subject: r12729: Implement the --section-name option, for dumping only one section. Andrew Bartlett (This used to be commit 3c49dd9219b12f5ed229ba108a02b85a18146df8) --- source4/utils/testparm.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'source4/utils/testparm.c') diff --git a/source4/utils/testparm.c b/source4/utils/testparm.c index 05aa5ff547..c4b7dd38d8 100644 --- a/source4/utils/testparm.c +++ b/source4/utils/testparm.c @@ -82,9 +82,9 @@ static int do_global_checks(void) /* static BOOL show_all_parameters = False; static char *parameter_name = NULL; - static const char *section_name = NULL; static char *new_local_machine = NULL; */ + static const char *section_name = NULL; static const char *cname; static const char *caddr; static int show_defaults; @@ -101,8 +101,8 @@ static int do_global_checks(void) These are harder to do with the new code structure {"show-all-parameters", '\0', POPT_ARG_VAL, &show_all_parameters, True, "Show the parameters, type, possible values" }, {"parameter-name", '\0', POPT_ARG_STRING, ¶meter_name, 0, "Limit testparm to a named parameter" }, - {"section-name", '\0', POPT_ARG_STRING, §ion_name, 0, "Limit testparm to a named section" }, */ + {"section-name", '\0', POPT_ARG_STRING, §ion_name, 0, "Limit testparm to a named section" }, {"client-name", '\0', POPT_ARG_STRING, &cname, 0, "Client DNS name for 'hosts allow' checking (should match reverse lookup)"}, {"client-ip", '\0', POPT_ARG_STRING, &caddr, 0, "Client IP address for 'hosts allow' checking"}, POPT_COMMON_VERSION @@ -196,7 +196,26 @@ static int do_global_checks(void) fflush(stdout); getc(stdin); } - lp_dump(stdout, show_defaults, lp_numservices()); + if (section_name) { + BOOL isGlobal = False; + if (!section_name) { + section_name = GLOBAL_NAME; + isGlobal = True; + } else if ((isGlobal=!strwicmp(section_name, GLOBAL_NAME)) == 0 && + (s=lp_servicenumber(section_name)) == -1) { + fprintf(stderr,"Unknown section %s\n", + section_name); + return(1); + } + if (isGlobal == True) { + lp_dump(stdout, show_defaults, 0); + } else { + lp_dump_one(stdout, show_defaults, s); + } + } else { + lp_dump(stdout, show_defaults, lp_numservices()); + } + return(ret); } if(cname && caddr){ -- cgit From 1b29552e70a78116337cf08a8d629170097427ad Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 6 Jan 2006 02:28:36 +0000 Subject: r12730: Reimplement --parameter-name, and bring in common samba options. This changes -s from meaning 'suppress prompt' to 'services file'. Andrew Bartlett (This used to be commit 0f78bd743b8bc415e47006a683c53bfdff1bc1e1) --- source4/utils/testparm.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'source4/utils/testparm.c') diff --git a/source4/utils/testparm.c b/source4/utils/testparm.c index c4b7dd38d8..fd990221ed 100644 --- a/source4/utils/testparm.c +++ b/source4/utils/testparm.c @@ -81,17 +81,17 @@ static int do_global_checks(void) static const char *term_code = ""; /* static BOOL show_all_parameters = False; - static char *parameter_name = NULL; static char *new_local_machine = NULL; */ static const char *section_name = NULL; + static char *parameter_name = NULL; static const char *cname; static const char *caddr; static int show_defaults; struct poptOption long_options[] = { POPT_AUTOHELP - {"suppress-prompt", 's', POPT_ARG_VAL, &silent_mode, 1, "Suppress prompt for enter"}, + {"suppress-prompt", '\0', POPT_ARG_VAL, &silent_mode, 1, "Suppress prompt for enter"}, {"verbose", 'v', POPT_ARG_NONE, &show_defaults, 1, "Show default options too"}, /* We need support for smb.conf macros before this will work again @@ -100,11 +100,12 @@ static int do_global_checks(void) /* These are harder to do with the new code structure {"show-all-parameters", '\0', POPT_ARG_VAL, &show_all_parameters, True, "Show the parameters, type, possible values" }, - {"parameter-name", '\0', POPT_ARG_STRING, ¶meter_name, 0, "Limit testparm to a named parameter" }, */ {"section-name", '\0', POPT_ARG_STRING, §ion_name, 0, "Limit testparm to a named section" }, + {"parameter-name", '\0', POPT_ARG_STRING, ¶meter_name, 0, "Limit testparm to a named parameter" }, {"client-name", '\0', POPT_ARG_STRING, &cname, 0, "Client DNS name for 'hosts allow' checking (should match reverse lookup)"}, {"client-ip", '\0', POPT_ARG_STRING, &caddr, 0, "Client IP address for 'hosts allow' checking"}, + POPT_COMMON_SAMBA POPT_COMMON_VERSION POPT_TABLEEND }; @@ -196,7 +197,7 @@ static int do_global_checks(void) fflush(stdout); getc(stdin); } - if (section_name) { + if (section_name || parameter_name) { BOOL isGlobal = False; if (!section_name) { section_name = GLOBAL_NAME; @@ -207,10 +208,14 @@ static int do_global_checks(void) section_name); return(1); } - if (isGlobal == True) { - lp_dump(stdout, show_defaults, 0); + if (!parameter_name) { + if (isGlobal == True) { + lp_dump(stdout, show_defaults, 0); + } else { + lp_dump_one(stdout, show_defaults, s); + } } else { - lp_dump_one(stdout, show_defaults, s); + ret = lp_dump_a_parameter(s, parameter_name, stdout, isGlobal); } } else { lp_dump(stdout, show_defaults, lp_numservices()); -- cgit From c66bc0dadbe7502f651fec53da488c838412f627 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 6 Jan 2006 02:50:46 +0000 Subject: r12731: Simplify and re-implemenet support for --parameter-name=foo --service-name=bar in testparm. Andrew Bartlett (This used to be commit be067e9a04a4dca02a9472ae7385dc0bf26735ea) --- source4/utils/testparm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/utils/testparm.c') diff --git a/source4/utils/testparm.c b/source4/utils/testparm.c index fd990221ed..d2f76960db 100644 --- a/source4/utils/testparm.c +++ b/source4/utils/testparm.c @@ -215,7 +215,7 @@ static int do_global_checks(void) lp_dump_one(stdout, show_defaults, s); } } else { - ret = lp_dump_a_parameter(s, parameter_name, stdout, isGlobal); + ret = !lp_dump_a_parameter(s, parameter_name, stdout, isGlobal); } } else { lp_dump(stdout, show_defaults, lp_numservices()); -- cgit From e011ab7e1d9d624b4fd926dc3f15df2ab5f756e6 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 6 Jan 2006 03:56:47 +0000 Subject: r12732: This option does nothing. Andrew Bartlett (This used to be commit 708ce7de3034cfef3c6d8c7d49df8851ad1e5827) --- source4/utils/testparm.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source4/utils/testparm.c') diff --git a/source4/utils/testparm.c b/source4/utils/testparm.c index d2f76960db..fece3466ff 100644 --- a/source4/utils/testparm.c +++ b/source4/utils/testparm.c @@ -78,7 +78,6 @@ static int do_global_checks(void) static BOOL silent_mode = False; int ret = 0; poptContext pc; - static const char *term_code = ""; /* static BOOL show_all_parameters = False; static char *new_local_machine = NULL; @@ -96,7 +95,7 @@ static int do_global_checks(void) /* We need support for smb.conf macros before this will work again {"server", 'L',POPT_ARG_STRING, &new_local_machine, 0, "Set %%L macro to servername\n"}, -*/ {"encoding", 't', POPT_ARG_STRING, &term_code, 0, "Print parameters with encoding"}, +*/ /* These are harder to do with the new code structure {"show-all-parameters", '\0', POPT_ARG_VAL, &show_all_parameters, True, "Show the parameters, type, possible values" }, -- 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/testparm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/utils/testparm.c') diff --git a/source4/utils/testparm.c b/source4/utils/testparm.c index fece3466ff..456baee301 100644 --- a/source4/utils/testparm.c +++ b/source4/utils/testparm.c @@ -106,7 +106,7 @@ static int do_global_checks(void) {"client-ip", '\0', POPT_ARG_STRING, &caddr, 0, "Client IP address for 'hosts allow' checking"}, POPT_COMMON_SAMBA POPT_COMMON_VERSION - POPT_TABLEEND + { NULL } }; setup_logging(NULL, DEBUG_STDERR); -- cgit From 3c3869cea6180fa9d6ff0d28059c9332ee1e3057 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 30 Apr 2007 13:13:49 +0000 Subject: r22607: work with the solaris version of popt metze (This used to be commit c992e882b53525fea995c68be668ba939671139c) --- source4/utils/testparm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source4/utils/testparm.c') diff --git a/source4/utils/testparm.c b/source4/utils/testparm.c index 456baee301..5802553844 100644 --- a/source4/utils/testparm.c +++ b/source4/utils/testparm.c @@ -75,11 +75,11 @@ static int do_global_checks(void) int main(int argc, const char *argv[]) { int s; - static BOOL silent_mode = False; + static int silent_mode = 0; int ret = 0; poptContext pc; /* - static BOOL show_all_parameters = False; + static int show_all_parameters = 0; static char *new_local_machine = NULL; */ static const char *section_name = NULL; @@ -90,7 +90,7 @@ static int do_global_checks(void) struct poptOption long_options[] = { POPT_AUTOHELP - {"suppress-prompt", '\0', POPT_ARG_VAL, &silent_mode, 1, "Suppress prompt for enter"}, + {"suppress-prompt", 0, POPT_ARG_NONE, &silent_mode, 1, "Suppress prompt for enter"}, {"verbose", 'v', POPT_ARG_NONE, &show_defaults, 1, "Show default options too"}, /* We need support for smb.conf macros before this will work again @@ -98,7 +98,7 @@ static int do_global_checks(void) */ /* These are harder to do with the new code structure - {"show-all-parameters", '\0', POPT_ARG_VAL, &show_all_parameters, True, "Show the parameters, type, possible values" }, + {"show-all-parameters", '\0', POPT_ARG_NONE, &show_all_parameters, 1, "Show the parameters, type, possible values" }, */ {"section-name", '\0', POPT_ARG_STRING, §ion_name, 0, "Limit testparm to a named section" }, {"parameter-name", '\0', POPT_ARG_STRING, ¶meter_name, 0, "Limit testparm to a named parameter" }, -- 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/testparm.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source4/utils/testparm.c') diff --git a/source4/utils/testparm.c b/source4/utils/testparm.c index 5802553844..886b51300f 100644 --- a/source4/utils/testparm.c +++ b/source4/utils/testparm.c @@ -9,7 +9,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, @@ -18,8 +18,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 . */ /* -- 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/testparm.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/utils/testparm.c') diff --git a/source4/utils/testparm.c b/source4/utils/testparm.c index 886b51300f..e0ebe48d63 100644 --- a/source4/utils/testparm.c +++ b/source4/utils/testparm.c @@ -36,6 +36,7 @@ #include "system/filesys.h" #include "lib/cmdline/popt_common.h" #include "lib/socket/socket.h" +#include "param/param.h" /*********************************************** -- cgit From 98b57d5eb61094a9c88e2f7d90d3e21b7e74e9d8 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 8 Sep 2007 16:46:30 +0000 Subject: r25035: Fix some more warnings, use service pointer rather than service number in more places. (This used to be commit df9cebcb97e20564359097148665bd519f31bc6f) --- source4/utils/testparm.c | 43 +++++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 22 deletions(-) (limited to 'source4/utils/testparm.c') diff --git a/source4/utils/testparm.c b/source4/utils/testparm.c index e0ebe48d63..08d4ecb1a7 100644 --- a/source4/utils/testparm.c +++ b/source4/utils/testparm.c @@ -151,8 +151,9 @@ static int do_global_checks(void) ret = do_global_checks(); for (s=0;s 12) { + struct service *service = lp_servicebynum(s); + if (service != NULL) + if (strlen(lp_servicename(lp_servicebynum(s))) > 12) { fprintf(stderr, "WARNING: You have some share names that are longer than 12 characters.\n" ); fprintf(stderr, "These may not be accessible to some older clients.\n" ); fprintf(stderr, "(Eg. Windows9x, WindowsMe, and not listed in smbclient in Samba 3.0.)\n" ); @@ -161,9 +162,10 @@ static int do_global_checks(void) } for (s=0;s Date: Sun, 9 Sep 2007 19:34:30 +0000 Subject: r25047: Fix more warnings. (This used to be commit 69de86d2d2e49439760fbc61901eb87fb7fc5d55) --- source4/utils/testparm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source4/utils/testparm.c') diff --git a/source4/utils/testparm.c b/source4/utils/testparm.c index 08d4ecb1a7..d884adc7f6 100644 --- a/source4/utils/testparm.c +++ b/source4/utils/testparm.c @@ -151,7 +151,7 @@ static int do_global_checks(void) ret = do_global_checks(); for (s=0;s 12) { fprintf(stderr, "WARNING: You have some share names that are longer than 12 characters.\n" ); @@ -162,7 +162,7 @@ static int do_global_checks(void) } for (s=0;s Date: Thu, 27 Sep 2007 19:49:53 +0000 Subject: r25379: Use loadparm context parameter in a lot more places. (This used to be commit 091961b13be665061c7e88ab4e2808c015bc403e) --- source4/utils/testparm.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'source4/utils/testparm.c') diff --git a/source4/utils/testparm.c b/source4/utils/testparm.c index d884adc7f6..160cf1cc0a 100644 --- a/source4/utils/testparm.c +++ b/source4/utils/testparm.c @@ -150,10 +150,10 @@ static int do_global_checks(void) ret = do_global_checks(); - for (s=0;s 12) { + if (strlen(lp_servicename(lp_servicebynum(global_loadparm, s))) > 12) { fprintf(stderr, "WARNING: You have some share names that are longer than 12 characters.\n" ); fprintf(stderr, "These may not be accessible to some older clients.\n" ); fprintf(stderr, "(Eg. Windows9x, WindowsMe, and not listed in smbclient in Samba 3.0.)\n" ); @@ -161,8 +161,8 @@ static int do_global_checks(void) } } - for (s=0;s Date: Thu, 27 Sep 2007 23:31:28 +0000 Subject: r25392: Add loadparm context as argument in a couple more places. (This used to be commit c62f51cc28a37959128e78a1f34cfd4c6d3ba069) --- source4/utils/testparm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/utils/testparm.c') diff --git a/source4/utils/testparm.c b/source4/utils/testparm.c index 160cf1cc0a..d8b6069791 100644 --- a/source4/utils/testparm.c +++ b/source4/utils/testparm.c @@ -137,7 +137,7 @@ static int do_global_checks(void) */ /* We need this to force the output */ - lp_set_cmdline("log level", "2"); + lp_set_cmdline(global_loadparm, "log level", "2"); fprintf(stderr,"Load smb config files from %s\n",lp_configfile()); @@ -212,7 +212,7 @@ static int do_global_checks(void) if (!parameter_name) { lp_dump_one(stdout, show_defaults, service); } else { - ret = !lp_dump_a_parameter(s, parameter_name, stdout, (service == NULL)); + ret = !lp_dump_a_parameter(global_loadparm, s, parameter_name, stdout, (service == NULL)); } } else { lp_dump(global_loadparm, stdout, show_defaults, lp_numservices(global_loadparm)); -- 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/testparm.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'source4/utils/testparm.c') diff --git a/source4/utils/testparm.c b/source4/utils/testparm.c index d8b6069791..71ff937a51 100644 --- a/source4/utils/testparm.c +++ b/source4/utils/testparm.c @@ -44,28 +44,28 @@ configuration settings. ************************************************/ -static int do_global_checks(void) +static int do_global_checks(struct loadparm_context *lp_ctx) { int ret = 0; - if (!directory_exist(lp_lockdir())) { + if (!directory_exist(lp_lockdir(lp_ctx))) { fprintf(stderr, "ERROR: lock directory %s does not exist\n", - lp_lockdir()); + lp_lockdir(lp_ctx)); ret = 1; } - if (!directory_exist(lp_piddir())) { + if (!directory_exist(lp_piddir(lp_ctx))) { fprintf(stderr, "ERROR: pid directory %s does not exist\n", - lp_piddir()); + lp_piddir(lp_ctx)); ret = 1; } - if (strlen(lp_winbind_separator()) != 1) { + if (strlen(lp_winbind_separator(lp_ctx)) != 1) { fprintf(stderr,"ERROR: the 'winbind separator' parameter must be a single character.\n"); ret = 1; } - if (*lp_winbind_separator() == '+') { + if (*lp_winbind_separator(lp_ctx) == '+') { fprintf(stderr,"'winbind separator = +' might cause problems with group membership.\n"); } @@ -139,16 +139,16 @@ static int do_global_checks(void) /* We need this to force the output */ lp_set_cmdline(global_loadparm, "log level", "2"); - fprintf(stderr,"Load smb config files from %s\n",lp_configfile()); + fprintf(stderr, "Loaded smb config files from %s\n", lp_configfile(global_loadparm)); - if (!lp_load()) { + if (!lp_load(lp_configfile(global_loadparm))) { fprintf(stderr,"Error loading services.\n"); return(1); } fprintf(stderr,"Loaded services file OK.\n"); - ret = do_global_checks(); + ret = do_global_checks(global_loadparm); for (s=0;s Date: Sun, 2 Dec 2007 17:09:52 +0100 Subject: r26227: Make loadparm_context part of a server task, move loadparm_contexts further up the call stack. (This used to be commit 0721a07aada6a1fae6dcbd610b8783df57d7bbad) --- source4/utils/testparm.c | 183 +++++++++++++++++++++++++---------------------- 1 file changed, 98 insertions(+), 85 deletions(-) (limited to 'source4/utils/testparm.c') diff --git a/source4/utils/testparm.c b/source4/utils/testparm.c index 71ff937a51..17e6a72746 100644 --- a/source4/utils/testparm.c +++ b/source4/utils/testparm.c @@ -72,88 +72,17 @@ static int do_global_checks(struct loadparm_context *lp_ctx) return ret; } - int main(int argc, const char *argv[]) + +static int do_share_checks(struct loadparm_context *lp_ctx, const char *cname, const char *caddr, bool silent_mode, + bool show_defaults, const char *section_name, const char *parameter_name) { - int s; - static int silent_mode = 0; int ret = 0; - poptContext pc; -/* - static int show_all_parameters = 0; - static char *new_local_machine = NULL; -*/ - static const char *section_name = NULL; - static char *parameter_name = NULL; - static const char *cname; - static const char *caddr; - static int show_defaults; - - struct poptOption long_options[] = { - POPT_AUTOHELP - {"suppress-prompt", 0, POPT_ARG_NONE, &silent_mode, 1, "Suppress prompt for enter"}, - {"verbose", 'v', POPT_ARG_NONE, &show_defaults, 1, "Show default options too"}, -/* - We need support for smb.conf macros before this will work again - {"server", 'L',POPT_ARG_STRING, &new_local_machine, 0, "Set %%L macro to servername\n"}, -*/ -/* - These are harder to do with the new code structure - {"show-all-parameters", '\0', POPT_ARG_NONE, &show_all_parameters, 1, "Show the parameters, type, possible values" }, -*/ - {"section-name", '\0', POPT_ARG_STRING, §ion_name, 0, "Limit testparm to a named section" }, - {"parameter-name", '\0', POPT_ARG_STRING, ¶meter_name, 0, "Limit testparm to a named parameter" }, - {"client-name", '\0', POPT_ARG_STRING, &cname, 0, "Client DNS name for 'hosts allow' checking (should match reverse lookup)"}, - {"client-ip", '\0', POPT_ARG_STRING, &caddr, 0, "Client IP address for 'hosts allow' checking"}, - POPT_COMMON_SAMBA - POPT_COMMON_VERSION - { NULL } - }; - - setup_logging(NULL, DEBUG_STDERR); - - pc = poptGetContext(NULL, argc, argv, long_options, - POPT_CONTEXT_KEEP_FIRST); - poptSetOtherOptionHelp(pc, "[OPTION...] [host-name] [host-ip]"); - - while(poptGetNextOpt(pc) != -1); - -/* - if (show_all_parameters) { - show_parameter_list(); - exit(0); - } -*/ - - if ( cname && ! caddr ) { - printf ( "ERROR: For 'hosts allow' check you must specify both a DNS name and an IP address.\n" ); - return(1); - } -/* - We need support for smb.conf macros before this will work again - - if (new_local_machine) { - set_local_machine_name(new_local_machine, True); - } -*/ - - /* We need this to force the output */ - lp_set_cmdline(global_loadparm, "log level", "2"); - - fprintf(stderr, "Loaded smb config files from %s\n", lp_configfile(global_loadparm)); - - if (!lp_load(lp_configfile(global_loadparm))) { - fprintf(stderr,"Error loading services.\n"); - return(1); - } - - fprintf(stderr,"Loaded services file OK.\n"); - - ret = do_global_checks(global_loadparm); + int s; - for (s=0;s 12) { + if (strlen(lp_servicename(lp_servicebynum(lp_ctx, s))) > 12) { fprintf(stderr, "WARNING: You have some share names that are longer than 12 characters.\n" ); fprintf(stderr, "These may not be accessible to some older clients.\n" ); fprintf(stderr, "(Eg. Windows9x, WindowsMe, and not listed in smbclient in Samba 3.0.)\n" ); @@ -161,8 +90,8 @@ static int do_global_checks(struct loadparm_context *lp_ctx) } } - for (s=0;s Date: Mon, 3 Dec 2007 21:25:17 +0100 Subject: r26268: Avoid more use of global_loadparm - put lp_ctx in smb_server and wbsrv_connection. (This used to be commit 7c008664238ed966cb82adf5b25b22157bb50730) --- source4/utils/testparm.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/utils/testparm.c') diff --git a/source4/utils/testparm.c b/source4/utils/testparm.c index 17e6a72746..665c649e73 100644 --- a/source4/utils/testparm.c +++ b/source4/utils/testparm.c @@ -246,7 +246,6 @@ static int do_share_checks(struct loadparm_context *lp_ctx, const char *cname, c fprintf(stderr,"Loaded services file OK.\n"); ret = do_global_checks(global_loadparm); - ret |= do_share_checks(global_loadparm, cname, caddr, silent_mode, show_defaults, section_name, parameter_name); return(ret); -- cgit From b038240ac72fa34a132eb52bda28bbb80f82c29e Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 4 Dec 2007 00:12:13 +0100 Subject: r26275: return loadparm context in lp_load. (This used to be commit d01f0f4c2037b531b3fd088060717f90e60471e9) --- source4/utils/testparm.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'source4/utils/testparm.c') diff --git a/source4/utils/testparm.c b/source4/utils/testparm.c index 665c649e73..b9e6bc0595 100644 --- a/source4/utils/testparm.c +++ b/source4/utils/testparm.c @@ -184,6 +184,7 @@ static int do_share_checks(struct loadparm_context *lp_ctx, const char *cname, c static const char *cname; static const char *caddr; static bool show_defaults = false; + struct loadparm_context *lp_ctx; struct poptOption long_options[] = { POPT_AUTOHELP @@ -238,15 +239,15 @@ static int do_share_checks(struct loadparm_context *lp_ctx, const char *cname, c fprintf(stderr, "Loaded smb config files from %s\n", lp_configfile(global_loadparm)); - if (!lp_load(lp_configfile(global_loadparm))) { + if (!lp_load(lp_configfile(global_loadparm), &lp_ctx)) { fprintf(stderr,"Error loading services.\n"); return(1); } fprintf(stderr,"Loaded services file OK.\n"); - ret = do_global_checks(global_loadparm); - ret |= do_share_checks(global_loadparm, cname, caddr, silent_mode, show_defaults, section_name, parameter_name); + ret = do_global_checks(lp_ctx); + ret |= do_share_checks(lp_ctx, cname, caddr, silent_mode, show_defaults, section_name, parameter_name); return(ret); } -- cgit From a48fdda5fec99649e29760c7a9c91246438c9579 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 8 Dec 2007 23:31:41 +0100 Subject: r26339: Make loadparm talloc-allocated. (This used to be commit 1e02cd8db1d65ff72b747833904a10b47749b1fb) --- source4/utils/testparm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/utils/testparm.c') diff --git a/source4/utils/testparm.c b/source4/utils/testparm.c index b9e6bc0595..381d2b3b59 100644 --- a/source4/utils/testparm.c +++ b/source4/utils/testparm.c @@ -239,7 +239,7 @@ static int do_share_checks(struct loadparm_context *lp_ctx, const char *cname, c fprintf(stderr, "Loaded smb config files from %s\n", lp_configfile(global_loadparm)); - if (!lp_load(lp_configfile(global_loadparm), &lp_ctx)) { + if (!lp_load(talloc_autofree_context(), lp_configfile(global_loadparm), &lp_ctx)) { fprintf(stderr,"Error loading services.\n"); return(1); } -- cgit From b0eec881310dddd23b0053399263972307448da7 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 8 Dec 2007 23:32:01 +0100 Subject: r26344: Fix memory access. (This used to be commit 966248108f97d237b41ff2d14ec1e592d61d8db3) --- source4/utils/testparm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/utils/testparm.c') diff --git a/source4/utils/testparm.c b/source4/utils/testparm.c index 381d2b3b59..bd4bc79240 100644 --- a/source4/utils/testparm.c +++ b/source4/utils/testparm.c @@ -127,7 +127,7 @@ static int do_share_checks(struct loadparm_context *lp_ctx, const char *cname, c fflush(stdout); getc(stdin); } - if (section_name || parameter_name) { + if (section_name != NULL || parameter_name != NULL) { struct loadparm_service *service = NULL; if (!section_name) { section_name = GLOBAL_NAME; @@ -141,7 +141,7 @@ static int do_share_checks(struct loadparm_context *lp_ctx, const char *cname, c if (!parameter_name) { lp_dump_one(stdout, show_defaults, service); } else { - ret = !lp_dump_a_parameter(lp_ctx, s, parameter_name, stdout, (service == NULL)); + ret = !lp_dump_a_parameter(lp_ctx, service, parameter_name, stdout, (service == NULL)); } } else { lp_dump(lp_ctx, stdout, show_defaults, lp_numservices(lp_ctx)); -- cgit From dd7e5ed88c48f4ee39e53be07c8839791e914e45 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 8 Dec 2007 23:32:37 +0100 Subject: r26352: Don't make lp_load create a new context. (This used to be commit d0d5c1a823a6601292c061dba2b6f4bde2b9e3dd) --- source4/utils/testparm.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'source4/utils/testparm.c') diff --git a/source4/utils/testparm.c b/source4/utils/testparm.c index bd4bc79240..fe8cc7124a 100644 --- a/source4/utils/testparm.c +++ b/source4/utils/testparm.c @@ -141,7 +141,7 @@ static int do_share_checks(struct loadparm_context *lp_ctx, const char *cname, c if (!parameter_name) { lp_dump_one(stdout, show_defaults, service); } else { - ret = !lp_dump_a_parameter(lp_ctx, service, parameter_name, stdout, (service == NULL)); + ret = !lp_dump_a_parameter(lp_ctx, service, parameter_name, stdout); } } else { lp_dump(lp_ctx, stdout, show_defaults, lp_numservices(lp_ctx)); @@ -233,13 +233,15 @@ static int do_share_checks(struct loadparm_context *lp_ctx, const char *cname, c set_local_machine_name(new_local_machine, True); } */ + + lp_ctx = global_loadparm; /* We need this to force the output */ - lp_set_cmdline(global_loadparm, "log level", "2"); + lp_set_cmdline(lp_ctx, "log level", "2"); - fprintf(stderr, "Loaded smb config files from %s\n", lp_configfile(global_loadparm)); + fprintf(stderr, "Loaded smb config files from %s\n", lp_configfile(lp_ctx)); - if (!lp_load(talloc_autofree_context(), lp_configfile(global_loadparm), &lp_ctx)) { + if (!lp_load(lp_ctx, lp_configfile(lp_ctx))) { fprintf(stderr,"Error loading services.\n"); 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/testparm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/utils/testparm.c') diff --git a/source4/utils/testparm.c b/source4/utils/testparm.c index fe8cc7124a..a4ff522186 100644 --- a/source4/utils/testparm.c +++ b/source4/utils/testparm.c @@ -234,7 +234,7 @@ static int do_share_checks(struct loadparm_context *lp_ctx, const char *cname, c } */ - lp_ctx = global_loadparm; + lp_ctx = cmdline_lp_ctx; /* We need this to force the output */ lp_set_cmdline(lp_ctx, "log level", "2"); -- cgit From 3e75f222bcdf114238cc4f2bcc61332dc059135f Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 19 Dec 2007 23:27:42 +0100 Subject: r26539: Remove unnecessary statics. (This used to be commit e53e79eebef3ece6978f0a2b4a1ee0a0814bb5d2) --- source4/utils/testparm.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'source4/utils/testparm.c') diff --git a/source4/utils/testparm.c b/source4/utils/testparm.c index a4ff522186..718daae908 100644 --- a/source4/utils/testparm.c +++ b/source4/utils/testparm.c @@ -172,18 +172,18 @@ static int do_share_checks(struct loadparm_context *lp_ctx, const char *cname, c int main(int argc, const char *argv[]) { - static bool silent_mode = false; + bool silent_mode = false; int ret = 0; poptContext pc; /* - static int show_all_parameters = 0; - static char *new_local_machine = NULL; + int show_all_parameters = 0; + char *new_local_machine = NULL; */ - static const char *section_name = NULL; - static char *parameter_name = NULL; - static const char *cname; - static const char *caddr; - static bool show_defaults = false; + const char *section_name = NULL; + char *parameter_name = NULL; + const char *cname = NULL; + const char *caddr = NULL; + bool show_defaults = false; struct loadparm_context *lp_ctx; struct poptOption long_options[] = { -- cgit From 0500b87092540d300b4e021a0fb95ce16a44fbd2 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 20 Dec 2007 00:02:15 +0100 Subject: r26540: Revert my previous commit after concerns raised by Andrew. (This used to be commit 6ac86f8be7d9a8c5ab396a93e6d1e6819e11f173) --- source4/utils/testparm.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'source4/utils/testparm.c') diff --git a/source4/utils/testparm.c b/source4/utils/testparm.c index 718daae908..a4ff522186 100644 --- a/source4/utils/testparm.c +++ b/source4/utils/testparm.c @@ -172,18 +172,18 @@ static int do_share_checks(struct loadparm_context *lp_ctx, const char *cname, c int main(int argc, const char *argv[]) { - bool silent_mode = false; + static bool silent_mode = false; int ret = 0; poptContext pc; /* - int show_all_parameters = 0; - char *new_local_machine = NULL; + static int show_all_parameters = 0; + static char *new_local_machine = NULL; */ - const char *section_name = NULL; - char *parameter_name = NULL; - const char *cname = NULL; - const char *caddr = NULL; - bool show_defaults = false; + static const char *section_name = NULL; + static char *parameter_name = NULL; + static const char *cname; + static const char *caddr; + static bool show_defaults = false; struct loadparm_context *lp_ctx; struct poptOption long_options[] = { -- cgit From 2ba62662f8e2578153be3125eb557b9349ccfd3b Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 28 Feb 2008 20:04:58 +0100 Subject: Remove sDefault as static variable. (This used to be commit 16f36ce499e93860dd535034a584ec2b93e7a172) --- source4/utils/testparm.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source4/utils/testparm.c') diff --git a/source4/utils/testparm.c b/source4/utils/testparm.c index a4ff522186..286a4a61fb 100644 --- a/source4/utils/testparm.c +++ b/source4/utils/testparm.c @@ -93,8 +93,8 @@ static int do_share_checks(struct loadparm_context *lp_ctx, const char *cname, c for (s=0;s