summaryrefslogtreecommitdiff
path: root/source4/utils/testparm.c
diff options
context:
space:
mode:
Diffstat (limited to 'source4/utils/testparm.c')
-rw-r--r--source4/utils/testparm.c74
1 files changed, 37 insertions, 37 deletions
diff --git a/source4/utils/testparm.c b/source4/utils/testparm.c
index 886b51300f..71ff937a51 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"
/***********************************************
@@ -43,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");
}
@@ -136,22 +137,23 @@ 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());
+ 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<lp_numservices();s++) {
- if (lp_snum_ok(s))
- if (strlen(lp_servicename(s)) > 12) {
+ for (s=0;s<lp_numservices(global_loadparm);s++) {
+ struct loadparm_service *service = lp_servicebynum(global_loadparm, s);
+ if (service != NULL)
+ 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" );
@@ -159,10 +161,11 @@ static int do_global_checks(void)
}
}
- for (s=0;s<lp_numservices();s++) {
- if (lp_snum_ok(s)) {
- const char **deny_list = lp_hostsdeny(s);
- const char **allow_list = lp_hostsallow(s);
+ for (s=0;s<lp_numservices(global_loadparm);s++) {
+ struct loadparm_service *service = lp_servicebynum(global_loadparm, s);
+ if (service != NULL) {
+ const char **deny_list = lp_hostsdeny(service);
+ const char **allow_list = lp_hostsallow(service);
int i;
if(deny_list) {
for (i=0; deny_list[i]; i++) {
@@ -170,7 +173,7 @@ static int do_global_checks(void)
char *hasquery = strchr_m(deny_list[i], '?');
if(hasstar || hasquery) {
fprintf(stderr,"Invalid character %c in hosts deny list (%s) for service %s.\n",
- hasstar ? *hasstar : *hasquery, deny_list[i], lp_servicename(s) );
+ hasstar ? *hasstar : *hasquery, deny_list[i], lp_servicename(service) );
}
}
}
@@ -181,7 +184,7 @@ static int do_global_checks(void)
char *hasquery = strchr_m(allow_list[i], '?');
if(hasstar || hasquery) {
fprintf(stderr,"Invalid character %c in hosts allow list (%s) for service %s.\n",
- hasstar ? *hasstar : *hasquery, allow_list[i], lp_servicename(s) );
+ hasstar ? *hasstar : *hasquery, allow_list[i], lp_servicename(service) );
}
}
}
@@ -196,42 +199,39 @@ static int do_global_checks(void)
getc(stdin);
}
if (section_name || parameter_name) {
- BOOL isGlobal = False;
+ struct loadparm_service *service = NULL;
if (!section_name) {
section_name = GLOBAL_NAME;
- isGlobal = True;
- } else if ((isGlobal=!strwicmp(section_name, GLOBAL_NAME)) == 0 &&
- (s=lp_servicenumber(section_name)) == -1) {
+ service = NULL;
+ } else if ((!strwicmp(section_name, GLOBAL_NAME)) == 0 &&
+ (service=lp_service(global_loadparm, section_name)) == NULL) {
fprintf(stderr,"Unknown section %s\n",
section_name);
return(1);
}
if (!parameter_name) {
- if (isGlobal == True) {
- lp_dump(stdout, show_defaults, 0);
- } else {
- lp_dump_one(stdout, show_defaults, s);
- }
+ lp_dump_one(stdout, show_defaults, service);
} else {
- ret = !lp_dump_a_parameter(s, parameter_name, stdout, isGlobal);
+ ret = !lp_dump_a_parameter(global_loadparm, s, parameter_name, stdout, (service == NULL));
}
} else {
- lp_dump(stdout, show_defaults, lp_numservices());
+ lp_dump(global_loadparm, stdout, show_defaults, lp_numservices(global_loadparm));
}
return(ret);
}
if(cname && caddr){
/* this is totally ugly, a real `quick' hack */
- for (s=0;s<lp_numservices();s++) {
- if (lp_snum_ok(s)) {
- if (allow_access(NULL, lp_hostsdeny(-1), lp_hostsallow(-1), cname, caddr)
- && allow_access(NULL, lp_hostsdeny(s), lp_hostsallow(s), cname, caddr)) {
+ for (s=0;s<lp_numservices(global_loadparm);s++) {
+ struct loadparm_service *service = lp_servicebynum(global_loadparm, s);
+ if (service != NULL) {
+ if (allow_access(NULL, lp_hostsdeny(NULL), lp_hostsallow(NULL), cname, caddr)
+ && allow_access(NULL, lp_hostsdeny(service), lp_hostsallow(service), cname, caddr)) {
fprintf(stderr,"Allow connection from %s (%s) to %s\n",
- cname,caddr,lp_servicename(s));
+ cname,caddr,lp_servicename(service));
} else {
fprintf(stderr,"Deny connection from %s (%s) to %s\n",
- cname,caddr,lp_servicename(s));
+ cname,caddr,lp_servicename(service));
}
}
}