Jat/Q patch for checking permission on database before creating it
git-svn-id: https://svn.musicpd.org/mpd/trunk@4140 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:
parent
1071524ae7
commit
66e4379d69
@ -988,6 +988,18 @@ void sortDirectory(Directory * directory) {
|
||||
}
|
||||
}
|
||||
|
||||
int checkDirectoryDB() {
|
||||
char * dbFile = getDbFile();
|
||||
|
||||
if(access(dbFile, R_OK|W_OK)) {
|
||||
ERROR("db file \"%s\" cannot be opened for reading/writing: %s",
|
||||
dbFile, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int writeDirectoryDB() {
|
||||
FILE * fp;
|
||||
char * dbFile = getDbFile();
|
||||
|
@ -58,6 +58,8 @@ void closeMp3Directory();
|
||||
|
||||
int printDirectoryInfo(FILE * fp, char * dirname);
|
||||
|
||||
int checkDirectoryDB();
|
||||
|
||||
int writeDirectoryDB();
|
||||
|
||||
int readDirectoryDB();
|
||||
|
@ -320,6 +320,7 @@ void openDB(Options * options, char * argv0) {
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
flushWarningLog();
|
||||
if(checkDirectoryDB()<0) exit(EXIT_FAILURE);
|
||||
initMp3Directory();
|
||||
if(writeDirectoryDB()<0) exit(EXIT_FAILURE);
|
||||
if(options->createDB) exit(EXIT_SUCCESS);
|
||||
|
Loading…
Reference in New Issue
Block a user