369 |
|
|
370 |
if (argc) { |
if (argc) { |
371 |
if (secure_mode) { |
if (secure_mode) { |
372 |
char buf[MAXPATHLEN+1], *path; |
char buf[MAXPATHLEN+1], *path; |
373 |
|
size_t rootlen; |
374 |
|
|
375 |
getdbpath(cwd, root, dbpath, 0); |
getdbpath(cwd, root, dbpath, 0); |
376 |
path = realpath(argv[0], buf); |
path = realpath(argv[0], buf); |
377 |
if (path == NULL) |
if (path == NULL) |
378 |
die("realpath(%s, buf) failed. (errno=%d).", argv[0], errno); |
die("realpath(%s, buf) failed. (errno=%d).", argv[0], errno); |
379 |
if (!isabspath(path)) |
if (!isabspath(path)) |
380 |
die("realpath(3) is not compatible with BSD version."); |
die("realpath(3) is not compatible with BSD version."); |
381 |
if (strncmp(path, root, strlen(root))) |
rootlen = strlen(root); |
382 |
|
if (strncmp(path, root, rootlen) || path[rootlen] != '/') |
383 |
die("'%s' is out of source tree.", path); |
die("'%s' is out of source tree.", path); |
384 |
} |
} |
385 |
ip = fopen(argv[0], "r"); |
ip = fopen(argv[0], "r"); |