diff --git a/src/dbs-sqlite.c b/src/dbs-sqlite.c index 1af33b5d..1f80498e 100644 --- a/src/dbs-sqlite.c +++ b/src/dbs-sqlite.c @@ -161,6 +161,7 @@ int db_sqlite_free_table(char **resarray) { db_sqlite_lock(); sqlite_free_table(resarray); db_sqlite_unlock(); + return 0; } @@ -174,7 +175,7 @@ int db_sqlite_open(char *parameters) { snprintf(db_path,sizeof(db_path),"%s/songs.db",parameters); db_sqlite_lock(); - db_sqlite_songs=sqlite_open(db_path,0,&perr); + db_sqlite_songs=sqlite_open(db_path,0666,&perr); if(!db_sqlite_songs) DPRINTF(E_FATAL,L_DB,"db_sqlite_open: %s (%s)\n",perr,db_path); @@ -727,7 +728,7 @@ int db_sqlite_enum_fetch(DBQUERYINFO *pinfo, unsigned char **pdmap) { db_sqlite_unlock(); DPRINTF(E_FATAL,L_DB,"sqlite_step: %s\n",perr); - return NULL; + return 0; } /** diff --git a/src/main.c b/src/main.c index 3de8b156..01cee9ae 100644 --- a/src/main.c +++ b/src/main.c @@ -452,11 +452,6 @@ int main(int argc, char *argv[]) { daemon_start(); } - /* DWB: shouldn't this be done after dropping privs? */ - if(db_open(config.dbdir)) - DPRINTF(E_FATAL,L_MAIN|L_DB,"Error in db_open: %s\n",strerror(errno)); - - // Drop privs here if(drop_privs(config.runas)) { DPRINTF(E_FATAL,L_MAIN,"Error in drop_privs: %s\n",strerror(errno)); @@ -478,6 +473,11 @@ int main(int argc, char *argv[]) { fprintf(pid_fp,"%d\n",config.pid); fclose(pid_fp); } + + /* this will require that the db be readable by the runas user */ + if(db_open(config.dbdir)) + DPRINTF(E_FATAL,L_MAIN|L_DB,"Error in db_open: %s\n",strerror(errno)); + /* Initialize the database before starting */ DPRINTF(E_LOG,L_MAIN|L_DB,"Initializing database\n"); if(db_init(reload)) {