If /var/lib/hts/tvheadend does not exist and we're thinking of storing
settings there, try to create it.
This commit is contained in:
parent
91cfbe96d8
commit
d133982144
1 changed files with 15 additions and 1 deletions
16
main.c
16
main.c
|
@ -194,6 +194,7 @@ main(int argc, char **argv)
|
|||
int logfacility = LOG_DAEMON;
|
||||
sigset_t set;
|
||||
const char *settingspath = NULL;
|
||||
struct stat st;
|
||||
|
||||
signal(SIGPIPE, handle_sigpipe);
|
||||
|
||||
|
@ -227,7 +228,20 @@ main(int argc, char **argv)
|
|||
if(settingspath == NULL) {
|
||||
settingspath = "/var/lib/hts/tvheadend";
|
||||
|
||||
if(chown(settingspath, pw ? pw->pw_uid : 1, grp ? grp->gr_gid : 1))
|
||||
if(stat(settingspath, &st)) {
|
||||
/* Path does not exist */
|
||||
|
||||
if(mkdir("/var/lib/hts", 0777) && errno != EEXIST) {
|
||||
settingspath = NULL;
|
||||
} else if(mkdir("/var/lib/hts/tvheadend", 0777) && errno != EEXIST) {
|
||||
settingspath = NULL;
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if(settingspath != NULL &&
|
||||
chown(settingspath, pw ? pw->pw_uid : 1, grp ? grp->gr_gid : 1))
|
||||
settingspath = NULL;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue