From ec00f049f1932550e72da17de62d7f18009e52b4 Mon Sep 17 00:00:00 2001 From: Ron Pedde Date: Wed, 31 May 2006 04:24:48 +0000 Subject: [PATCH] Make blank admin password disable the admin interface for all but localhost --- src/configfile.c | 7 +++---- src/os-unix.c | 13 +++++++++++++ src/os-win32.h | 1 - src/os.h | 4 ++++ 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/configfile.c b/src/configfile.c index c468c416..af64e36d 100644 --- a/src/configfile.c +++ b/src/configfile.c @@ -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); diff --git a/src/os-unix.c b/src/os-unix.c index 3a0bf846..89ea1239 100644 --- a/src/os-unix.c +++ b/src/os-unix.c @@ -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; +} diff --git a/src/os-win32.h b/src/os-win32.h index 48d60971..32f9ff12 100644 --- a/src/os-win32.h +++ b/src/os-win32.h @@ -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); diff --git a/src/os.h b/src/os.h index 951603ef..5a229868 100644 --- a/src/os.h +++ b/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 int os_unload(void *handle); +/* misc */ +extern int os_islocaladdr(char *hostaddr); + + #ifdef WIN32 # include "os-win32.h" #else