/* Parse a boolean value and fill in *flag. Return 0 on error. */
static int parsebool(const char *pval, int *flag)
{
- if (strcmp(pval, "on") == 0
- || strcmp(pval, "true") == 0) {
+ if (strcasecmp(pval, "on") == 0
+ || strcasecmp(pval, "true") == 0) {
*flag = 1;
- } else if (strcmp(pval, "off") == 0
- || strcmp(pval, "false") == 0) {
+ } else if (strcasecmp(pval, "off") == 0
+ || strcasecmp(pval, "false") == 0) {
*flag = 0;
} else {
ERR_raise(ERR_LIB_CONF, CONF_R_INVALID_PRAGMA);
* Known pragmas:
*
* dollarid takes "on", "true or "off", "false"
+ * abspath takes "on", "true or "off", "false"
+ * includedir directory prefix
*/
if (strcmp(p, "dollarid") == 0) {
if (!parsebool(pval, &conf->flag_dollarid))
} else if (strcmp(p, "abspath") == 0) {
if (!parsebool(pval, &conf->flag_abspath))
goto err;
+ } else if (strcmp(p, "includedir") == 0) {
+ if ((conf->includedir = OPENSSL_strdup(pval)) == NULL) {
+ ERR_raise(ERR_LIB_CONF, ERR_R_MALLOC_FAILURE);
+ goto err;
+ }
}
+
/*
* We *ignore* any unknown pragma.
*/
const char *include_dir = ossl_safe_getenv("OPENSSL_CONF_INCLUDE");
char *include_path = NULL;
+ if (include_dir == NULL)
+ include_dir = conf->includedir;
+
if (*p == '=') {
p++;
p = eat_ws(conf, p);
if (!str_copy(conf, psection, &include, p))
goto err;
- if (conf->flag_abspath && !ossl_is_absolute_path(include)) {
- ERR_raise(ERR_LIB_CONF, CONF_R_RELATIVE_PATH);
- goto err;
- }
-
if (include_dir != NULL && !ossl_is_absolute_path(include)) {
size_t newlen = strlen(include_dir) + strlen(include) + 2;
include_path = include;
}
+ if (conf->flag_abspath
+ && !ossl_is_absolute_path(include_path)) {
+ ERR_raise(ERR_LIB_CONF, CONF_R_RELATIVE_PATH);
+ goto err;
+ }
+
/* get the BIO of the included file */
#ifndef OPENSSL_NO_POSIX_IO
next = process_include(include_path, &dirctx, &dirpath);
*/
sk_BIO_free(biosk);
return 1;
+
err:
BUF_MEM_free(buff);
OPENSSL_free(section);
that specifies a directory, that is also ignored.
As a general rule, the B<pathname> should be an absolute path; this can
-be enforced with the B<relpath> pragma, described below.
+be enforced with the B<abspath> and B<includedir> pragmas, described below.
The environment variable B<OPENSSL_CONF_INCLUDE>, if it exists,
is prepended to all relative pathnames.
If the pathname is still relative, it is interpreted based on the
To require all file inclusions to name absolute paths, use the following
directive:
- .progma [=] abspath:value
+ .pragma [=] abspath:value
The default behavior, where the B<value> is B<false> or B<off>, is to allow
relative paths. To require all B<.include> pathnames to be absolute paths,
B<true> or B<on>, then C<foo$bar> is a single seven-character name nad
variable expansions must be specified using braces or parentheses.
+ .pragma [=] includedir:value
+
+If a relative pathname is specified in the B<.include> directive, and
+the B<OPENSSL_CONF_INCLUDE> environment variable doesn't exist, then
+the value of the B<includedir> pragma, if it exists, is prepended to the
+pathname.
+
=head2 Settings
A configuration file is divided into a number of I<sections>. A section
delete $ENV{OPENSSL_CONF_INCLUDE};
plan tests => # The number of tests being performed
- 5
+ 6
+ ($^O eq "VMS" ? 2 : 0);
ok(run(test(["conf_include_test", data_file("includes.cnf")])), "test directory includes");
"test file includes, VMS syntax");
}
ok(run(test(["conf_include_test", "-f", data_file("includes-broken.cnf")])), "test broken includes");
+ok(run(test(["conf_include_test", "-f", data_file("incdir.cnf")])), "test includedir");