set rdonly earlier for unveil, make open() error more clear - bmf - bmf (Bayesi… | |
git clone git://git.codemadness.org/bmf | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit 57c341a511e88733eedf95a443567f27198247e3 | |
parent da144ef21a75e5a1f78c1faf2d76d93c68f6180f | |
Author: Hiltjo Posthuma <[email protected]> | |
Date: Sat, 27 Oct 2018 20:02:06 +0200 | |
set rdonly earlier for unveil, make open() error more clear | |
Diffstat: | |
M bmf.c | 4 ++-- | |
M dbh.c | 2 +- | |
2 files changed, 3 insertions(+), 3 deletions(-) | |
--- | |
diff --git a/bmf.c b/bmf.c | |
@@ -154,6 +154,8 @@ main(int argc, char **argv) | |
} | |
stats.extrema = (discrim_t *) malloc(stats.keepers * sizeof(discrim_t)… | |
+ rdonly = (mode == mode_test) ? 1 : 0; | |
+ | |
/* create directory if it doesn't exist yet, when dbname is NULL or em… | |
pdb = dbtext_db_open(dbname, rdonly); | |
if (pdb == NULL) { | |
@@ -171,7 +173,6 @@ main(int argc, char **argv) | |
exit(2); | |
} | |
if (mode == mode_test) { | |
- rdonly = 1; | |
pblist = pdb->opentable(pdb, "spamlist", rdonly); | |
if (pblist == NULL) { | |
fprintf(stderr, "%s: cannot open spamlist\n", argv[0]); | |
@@ -191,7 +192,6 @@ main(int argc, char **argv) | |
exit(2); | |
} | |
if (mode != mode_test) { | |
- rdonly = 0; | |
pblist = pdb->opentable(pdb, "spamlist", rdonly); | |
if (pblist == NULL) { | |
fprintf(stderr, "%s: cannot open spamlist\n", … | |
diff --git a/dbh.c b/dbh.c | |
@@ -201,7 +201,7 @@ dbtext_db_opentable(dbhtext_t * pthis, cpchar table, bool_t… | |
flags = O_CREAT | (rdonly ? O_RDONLY : O_RDWR); | |
if ((ptable->fd = open(szpath, flags, 0644)) == -1) { | |
- perror("open()"); | |
+ fprintf(stderr, "open: '%s': %s\n", szpath, strerror(errno)); | |
goto bail; | |
} | |