Move db_open after priv drop

This commit is contained in:
Ron Pedde 2005-03-20 04:13:34 +00:00
parent 5a435bc6e9
commit f8f442bc3c
2 changed files with 8 additions and 7 deletions

View File

@ -161,6 +161,7 @@ int db_sqlite_free_table(char **resarray) {
db_sqlite_lock(); db_sqlite_lock();
sqlite_free_table(resarray); sqlite_free_table(resarray);
db_sqlite_unlock(); 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); snprintf(db_path,sizeof(db_path),"%s/songs.db",parameters);
db_sqlite_lock(); 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) if(!db_sqlite_songs)
DPRINTF(E_FATAL,L_DB,"db_sqlite_open: %s (%s)\n",perr,db_path); 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(); db_sqlite_unlock();
DPRINTF(E_FATAL,L_DB,"sqlite_step: %s\n",perr); DPRINTF(E_FATAL,L_DB,"sqlite_step: %s\n",perr);
return NULL; return 0;
} }
/** /**

View File

@ -452,11 +452,6 @@ int main(int argc, char *argv[]) {
daemon_start(); 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 // Drop privs here
if(drop_privs(config.runas)) { if(drop_privs(config.runas)) {
DPRINTF(E_FATAL,L_MAIN,"Error in drop_privs: %s\n",strerror(errno)); 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); fprintf(pid_fp,"%d\n",config.pid);
fclose(pid_fp); 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 */ /* Initialize the database before starting */
DPRINTF(E_LOG,L_MAIN|L_DB,"Initializing database\n"); DPRINTF(E_LOG,L_MAIN|L_DB,"Initializing database\n");
if(db_init(reload)) { if(db_init(reload)) {