Commit bc3e363d authored by Marek Vavruša's avatar Marek Vavruša

daemon: check that keyfile is readable and use abspath

parent 1cac016b
......@@ -197,7 +197,8 @@ int main(int argc, char **argv)
int forks = 1;
array_t(char*) addr_set;
array_init(addr_set);
const char *keyfile = NULL;
char *keyfile = NULL;
static char keyfile_buf[PATH_MAX + 1];
/* Long options. */
int c = 0, li = 0, ret = 0;
......@@ -225,9 +226,9 @@ int main(int argc, char **argv)
}
break;
case 'k':
keyfile = optarg;
if (access(optarg, R_OK) != 0) {
log_error("[system] keyfile '%s': not readable\n", optarg);
keyfile = realpath(optarg, keyfile_buf);
if (!keyfile || access(optarg, R_OK|W_OK) != 0) {
log_error("[system] keyfile '%s': not readable/writeable\n", optarg);
return EXIT_FAILURE;
}
break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment