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 "db-generic.h"
|
||||
#include "err.h"
|
||||
#include "os.h"
|
||||
#include "restart.h"
|
||||
#include "xml-rpc.h"
|
||||
|
||||
|
@ -384,13 +385,11 @@ int config_auth(WS_CONNINFO *pwsc, char *user, char *password) {
|
|||
char *adminpassword;
|
||||
int res;
|
||||
|
||||
#ifdef WIN32
|
||||
if((pwsc->hostname) && (os_islocaladdr(pwsc->hostname)))
|
||||
return TRUE;
|
||||
#endif
|
||||
|
||||
if((!password) ||
|
||||
((adminpassword=conf_alloc_string("general","admin_pw",NULL))==NULL))
|
||||
adminpassword=conf_alloc_string("general","admin_pw",NULL);
|
||||
if(!adminpassword)
|
||||
return FALSE;
|
||||
|
||||
res = !strcmp(password,adminpassword);
|
||||
|
|
|
@ -450,3 +450,16 @@ int os_unload(void *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_unregister(void);
|
||||
extern char *os_configpath(void);
|
||||
extern int os_islocaladdr(char *hostaddr);
|
||||
|
||||
/* replacements for socket functions */
|
||||
extern int os_opensocket(unsigned short port);
|
||||
|
|
Loading…
Reference in New Issue