1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-12 09:18:10 +03:00

make SWAT obey the global "hosts allow" and "hosts deny" settings.

any attempt to run swat from a host that is disallowed will give an
error.
(This used to be commit fe4ef4bbef)
This commit is contained in:
Andrew Tridgell 1998-11-21 01:41:14 +00:00
parent 091a92e996
commit 42e96160d3
2 changed files with 29 additions and 13 deletions

View File

@ -46,6 +46,7 @@ static char *baseurl;
static char *pathinfo;
static char *C_user;
static BOOL inetd_server;
static BOOL got_request;
static void unescape(char *buf)
{
@ -253,7 +254,21 @@ tell a browser about a fatal error in the http processing
***************************************************************************/
static void cgi_setup_error(char *err, char *header, char *info)
{
printf("HTTP/1.0 %s\r\n%sConnection: close\r\nContent-Type: text/html\r\n\r\n<HTML><HEAD><TITLE>%s</TITLE></HEAD><BODY><H1>%s</H1>%s<p></BODY></HTML>\r\n", err, header, err, err, info);
if (!got_request) {
/* damn browsers don't like getting cut off before they give a request */
char line[1024];
while (fgets(line, sizeof(line)-1, stdin)) {
if (strncasecmp(line,"GET ", 4)==0 ||
strncasecmp(line,"POST ", 5)==0 ||
strncasecmp(line,"PUT ", 4)==0) {
break;
}
}
}
printf("HTTP/1.0 %s\r\n%sConnection: close\r\nContent-Type: text/html\r\n\r\n<HTML><HEAD><TITLE>%s</TITLE></HEAD><BODY><H1>%s</H1>%s<p></BODY></HTML>\r\n\r\n", err, header, err, err, info);
fclose(stdin);
fclose(stdout);
exit(0);
}
@ -492,6 +507,11 @@ void cgi_setup(char *rootdir, int auth_required)
inetd_server = True;
if (!check_access(1, lp_hostsallow(-1), lp_hostsdeny(-1))) {
cgi_setup_error("400 Server Error", "",
"Samba is configured to deny access from this client\n<br>Check your \"hosts allow\" and \"hosts deny\" options in smb.conf ");
}
#if CGI_LOGGING
f = sys_fopen("/tmp/cgi.log", "a");
if (f) fprintf(f,"\n[Date: %s %s (%s)]\n",
@ -507,11 +527,14 @@ void cgi_setup(char *rootdir, int auth_required)
#endif
if (line[0] == '\r' || line[0] == '\n') break;
if (strncasecmp(line,"GET ", 4)==0) {
got_request = True;
url = strdup(&line[4]);
} else if (strncasecmp(line,"POST ", 5)==0) {
got_request = True;
request_post = 1;
url = strdup(&line[5]);
} else if (strncasecmp(line,"PUT ", 4)==0) {
got_request = True;
cgi_setup_error("400 Bad Request", "",
"This server does not accept PUT requests");
} else if (strncasecmp(line,"Authorization: ", 15)==0) {

View File

@ -382,12 +382,9 @@ static void commit_parameters(int snum)
/****************************************************************************
load the smb.conf file into loadparm.
****************************************************************************/
static void load_config(void)
static BOOL load_config(void)
{
if (!lp_load(servicesf,False,True,False)) {
printf("<b>Can't load %s - using defaults</b><p>\n",
servicesf);
}
return lp_load(servicesf,False,True,False);
}
/****************************************************************************
@ -909,17 +906,13 @@ static void printers_page(void)
}
}
charset_initialise();
load_config();
cgi_setup(SWATDIR, !demo_mode);
print_header();
charset_initialise();
/* if this binary is setuid then run completely as root */
setuid(0);
load_config();
cgi_load_variables(NULL);
show_main_buttons();