From 964285cf41050f270d68b7da2e39ff4cc2cb6281 Mon Sep 17 00:00:00 2001 From: Ron Pedde Date: Mon, 10 Apr 2006 19:02:39 +0000 Subject: [PATCH] Minor win32 fixes, fix path parsing in conf validation to fix ticket #48 --- src/conf.c | 14 ++++++++------ src/os-unix.h | 3 +++ src/os-win32.h | 3 ++- src/win32.h | 2 +- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/conf.c b/src/conf.c index 6716e18c..309ae6f8 100644 --- a/src/conf.c +++ b/src/conf.c @@ -138,18 +138,20 @@ int _conf_makedir(char *path,char *user) { DPRINTF(E_FATAL,L_CONF,"Malloc error\n"); } - next_token=pathdup+1; + next_token=pathdup; + while(*next_token && (*next_token != PATHSEP)) + next_token++; + if(*next_token) + next_token++; + memset(path_buffer,0,sizeof(path_buffer)); - while((token=strsep(&next_token,"/"))) { + while((token=strsep(&next_token,PATHSEP_STR))) { if((strlen(path_buffer) + strlen(token)) < PATH_MAX) { - strcat(path_buffer,"/"); + strcat(path_buffer,PATHSEP_STR); strcat(path_buffer,token); if(!_conf_existdir(path_buffer)) { - /* FIXME: this is wrong -- it should really be 0700 owned by - * the runas user. That would require some os_ indirection - */ DPRINTF(E_DBG,L_CONF,"Making %s\n",path_buffer); if((mkdir(path_buffer,0700)) && (errno != EEXIST)) { free(pathdup); diff --git a/src/os-unix.h b/src/os-unix.h index 988dbbde..14c10d00 100644 --- a/src/os-unix.h +++ b/src/os-unix.h @@ -7,6 +7,9 @@ #ifndef _OS_UNIX_H_ #define _OS_UNIX_H_ +#define PATHSEP '/' +#define PATHSEP_STR "/" + /* unix-specific functions */ extern int os_drop_privs(char *user); void os_set_pidfile(char *file); diff --git a/src/os-win32.h b/src/os-win32.h index 5897c0e9..154e0456 100644 --- a/src/os-win32.h +++ b/src/os-win32.h @@ -12,7 +12,8 @@ #define MAXNAMLEN 255 #define DIRBLKSIZ 512 - +#define PATHSEP '\\' +#define PATHSEP_STR "\\" struct timezone { int tz_minuteswest; diff --git a/src/win32.h b/src/win32.h index 58217242..67bd21ce 100644 --- a/src/win32.h +++ b/src/win32.h @@ -71,7 +71,7 @@ #define HOST "unknown-windows-ick" #define SERVICENAME "Multithreaded DAAP Server" -#define DEFAULT_CONFIGFILE os_configpath() +#define CONFFILE os_configpath() extern char *os_configpath(void);