Make blank admin password disable the admin interface for all but localhost
This commit is contained in:
parent
b567d86d46
commit
ec00f049f1
|
@ -52,6 +52,7 @@
|
||||||
#include "configfile.h"
|
#include "configfile.h"
|
||||||
#include "db-generic.h"
|
#include "db-generic.h"
|
||||||
#include "err.h"
|
#include "err.h"
|
||||||
|
#include "os.h"
|
||||||
#include "restart.h"
|
#include "restart.h"
|
||||||
#include "xml-rpc.h"
|
#include "xml-rpc.h"
|
||||||
|
|
||||||
|
@ -384,13 +385,11 @@ int config_auth(WS_CONNINFO *pwsc, char *user, char *password) {
|
||||||
char *adminpassword;
|
char *adminpassword;
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
#ifdef WIN32
|
|
||||||
if((pwsc->hostname) && (os_islocaladdr(pwsc->hostname)))
|
if((pwsc->hostname) && (os_islocaladdr(pwsc->hostname)))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
#endif
|
|
||||||
|
|
||||||
if((!password) ||
|
adminpassword=conf_alloc_string("general","admin_pw",NULL);
|
||||||
((adminpassword=conf_alloc_string("general","admin_pw",NULL))==NULL))
|
if(!adminpassword)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
res = !strcmp(password,adminpassword);
|
res = !strcmp(password,adminpassword);
|
||||||
|
|
|
@ -450,3 +450,16 @@ int os_unload(void *handle) {
|
||||||
return dlclose(handle);
|
return dlclose(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if an address is local or not
|
||||||
|
*
|
||||||
|
* @param hostaddr the address to test for locality
|
||||||
|
*/
|
||||||
|
int os_islocaladdr(char *hostaddr) {
|
||||||
|
/* how can we check interfaces without something like libnet? */
|
||||||
|
|
||||||
|
if(strncmp(hostaddr,"127.",4) == 0)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
|
@ -50,7 +50,6 @@ typedef struct {
|
||||||
extern int os_register(void);
|
extern int os_register(void);
|
||||||
extern int os_unregister(void);
|
extern int os_unregister(void);
|
||||||
extern char *os_configpath(void);
|
extern char *os_configpath(void);
|
||||||
extern int os_islocaladdr(char *hostaddr);
|
|
||||||
|
|
||||||
/* replacements for socket functions */
|
/* replacements for socket functions */
|
||||||
extern int os_opensocket(unsigned short port);
|
extern int os_opensocket(unsigned short port);
|
||||||
|
|
4
src/os.h
4
src/os.h
|
@ -38,6 +38,10 @@ extern void *os_loadlib(char **pe, char *path);
|
||||||
extern void *os_libfunc(char **pe, void *handle, char *function);
|
extern void *os_libfunc(char **pe, void *handle, char *function);
|
||||||
extern int os_unload(void *handle);
|
extern int os_unload(void *handle);
|
||||||
|
|
||||||
|
/* misc */
|
||||||
|
extern int os_islocaladdr(char *hostaddr);
|
||||||
|
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
# include "os-win32.h"
|
# include "os-win32.h"
|
||||||
#else
|
#else
|
||||||
|
|
Loading…
Reference in New Issue