X-Git-Url: http://the.earth.li/gitweb/?a=blobdiff_plain;f=keydb_fs.c;h=277929734c633ab14bb2fd00b2fea1dfe19c7db6;hb=ced2e52d6466e53a9e7d1cc1d1b606e902ba592b;hp=26eb99e70ea98d70dd7a76becd6fca719078d016;hpb=23f086c85c5d2db35e9ce76cf0bbf72200b4dc42;p=onak.git diff --git a/keydb_fs.c b/keydb_fs.c index 26eb99e..2779297 100644 --- a/keydb_fs.c +++ b/keydb_fs.c @@ -648,7 +648,15 @@ struct onak_dbctx *keydb_fs_init(bool readonly) mkdir(config.db_dir, 0777); privctx->lockfile_fd = open(buffer, O_RDWR | O_CREAT, 0600); } - chdir(config.db_dir); + if (chdir(config.db_dir) == -1) { + /* Shouldn't happen after the above */ + logthing(LOGTHING_CRITICAL, + "Couldn't change to database directory: %s", + strerror(errno)); + free(dbctx->priv); + free(dbctx); + return NULL; + } privctx->lockfile_fd = open(buffer, (privctx->lockfile_readonly) ? O_RDONLY : O_RDWR);