mirror of
https://github.com/owntone/owntone-server.git
synced 2025-01-15 00:35:03 -05:00
Fix problem with relative paths in config file
This commit is contained in:
parent
e53562943f
commit
90d5e1fa4c
24
src/conf.c
24
src/conf.c
@ -32,15 +32,18 @@
|
|||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <sys/param.h>
|
||||||
|
|
||||||
#include "conf.h"
|
#include "conf.h"
|
||||||
#include "err.h"
|
#include "err.h"
|
||||||
#include "ll.h"
|
#include "ll.h"
|
||||||
#include "daapd.h"
|
#include "daapd.h"
|
||||||
|
|
||||||
/** Globals */
|
/** Globals */
|
||||||
static int ecode;
|
//static int ecode;
|
||||||
static LL_HANDLE conf_main=NULL;
|
static LL_HANDLE conf_main=NULL;
|
||||||
static char *conf_main_file = NULL;
|
static char *conf_main_file = NULL;
|
||||||
static pthread_mutex_t conf_mutex = PTHREAD_MUTEX_INITIALIZER;
|
static pthread_mutex_t conf_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||||
@ -49,6 +52,7 @@ static pthread_mutex_t conf_mutex = PTHREAD_MUTEX_INITIALIZER;
|
|||||||
|
|
||||||
#define CONF_T_INT 0
|
#define CONF_T_INT 0
|
||||||
#define CONF_T_STRING 1
|
#define CONF_T_STRING 1
|
||||||
|
#define CONF_T_EXISTPATH 2
|
||||||
|
|
||||||
/** Forwards */
|
/** Forwards */
|
||||||
static int _conf_verify(LL_HANDLE pll);
|
static int _conf_verify(LL_HANDLE pll);
|
||||||
@ -68,11 +72,11 @@ typedef struct _CONF_ELEMENTS {
|
|||||||
|
|
||||||
static CONF_ELEMENTS conf_elements[] = {
|
static CONF_ELEMENTS conf_elements[] = {
|
||||||
{ 1, 0, CONF_T_STRING,"general","runas" },
|
{ 1, 0, CONF_T_STRING,"general","runas" },
|
||||||
{ 1, 0, CONF_T_STRING,"general","web_root" },
|
{ 1, 0, CONF_T_EXISTPATH,"general","web_root" },
|
||||||
{ 1, 0, CONF_T_INT,"general","port" },
|
{ 1, 0, CONF_T_INT,"general","port" },
|
||||||
{ 1, 0, CONF_T_STRING,"general","admin_pw" },
|
{ 1, 0, CONF_T_STRING,"general","admin_pw" },
|
||||||
{ 1, 0, CONF_T_STRING,"general","mp3_dir" },
|
{ 1, 0, CONF_T_STRING,"general","mp3_dir" },
|
||||||
{ 0, 1, CONF_T_STRING,"general","db_dir" },
|
{ 0, 1, CONF_T_EXISTPATH,"general","db_dir" },
|
||||||
{ 0, 0, CONF_T_STRING,"general","db_type" },
|
{ 0, 0, CONF_T_STRING,"general","db_type" },
|
||||||
{ 0, 0, CONF_T_STRING,"general","db_parms" },
|
{ 0, 0, CONF_T_STRING,"general","db_parms" },
|
||||||
{ 0, 0, CONF_T_INT,"general","debuglevel" },
|
{ 0, 0, CONF_T_INT,"general","debuglevel" },
|
||||||
@ -171,6 +175,7 @@ int _conf_verify(LL_HANDLE pll) {
|
|||||||
LL_ITEM *pi = NULL;
|
LL_ITEM *pi = NULL;
|
||||||
CONF_ELEMENTS *pce;
|
CONF_ELEMENTS *pce;
|
||||||
int is_valid=TRUE;
|
int is_valid=TRUE;
|
||||||
|
char resolved_path[PATH_MAX];
|
||||||
|
|
||||||
/* first, walk through the elements and make sure
|
/* first, walk through the elements and make sure
|
||||||
* all required elements are there */
|
* all required elements are there */
|
||||||
@ -189,6 +194,19 @@ int _conf_verify(LL_HANDLE pll) {
|
|||||||
"review the sample config\n",
|
"review the sample config\n",
|
||||||
pce->section, pce->term);
|
pce->section, pce->term);
|
||||||
}
|
}
|
||||||
|
if(pce->type == CONF_T_EXISTPATH) {
|
||||||
|
/* first, need to resolve */
|
||||||
|
pi = _conf_fetch_item(pll,pce->section, pce->term);
|
||||||
|
if(pi) {
|
||||||
|
memset(resolved_path,0,sizeof(resolved_path));
|
||||||
|
if(pi->value.as_string) {
|
||||||
|
realpath(pi->value.as_string,resolved_path);
|
||||||
|
free(pi->value.as_string);
|
||||||
|
pi->value.as_string = strdup(resolved_path);
|
||||||
|
}
|
||||||
|
/* now, should verify it exists */
|
||||||
|
}
|
||||||
|
}
|
||||||
pce++;
|
pce++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -426,9 +426,12 @@ int config_auth(char *user, char *password) {
|
|||||||
|
|
||||||
if(conf_get_string("general","admin_pw","",adminpassword,
|
if(conf_get_string("general","admin_pw","",adminpassword,
|
||||||
&size) != CONF_E_SUCCESS) {
|
&size) != CONF_E_SUCCESS) {
|
||||||
|
DPRINTF(E_LOG,L_CONF,"c_g_s: not success\n");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DPRINTF(E_LOG,L_CONF,"Admin pw: %s\n",adminpassword);
|
||||||
|
|
||||||
if(!password)
|
if(!password)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user