Resolve paths relative to XDG config. paths
This should make the programs an awful lot less painful to set up.
This commit is contained in:
@@ -277,12 +277,16 @@ irc_initialize_ssl (struct bot_context *ctx, struct error **e)
|
||||
goto error_ssl_2;
|
||||
|
||||
const char *ssl_cert = str_map_find (&ctx->config, "ssl_cert");
|
||||
if (ssl_cert
|
||||
&& !SSL_use_certificate_file (ctx->ssl, ssl_cert, SSL_FILETYPE_PEM))
|
||||
if (ssl_cert)
|
||||
{
|
||||
char *path = resolve_config_filename (ssl_cert);
|
||||
if (!path)
|
||||
print_error ("%s: %s", "cannot open file", ssl_cert);
|
||||
// XXX: perhaps we should read the file ourselves for better messages
|
||||
print_error ("%s: %s", "setting the SSL client certificate failed",
|
||||
ERR_error_string (ERR_get_error (), NULL));
|
||||
else if (!SSL_use_certificate_file (ctx->ssl, path, SSL_FILETYPE_PEM))
|
||||
print_error ("%s: %s", "setting the SSL client certificate failed",
|
||||
ERR_error_string (ERR_get_error (), NULL));
|
||||
free (path);
|
||||
}
|
||||
|
||||
SSL_set_connect_state (ctx->ssl);
|
||||
@@ -1686,25 +1690,6 @@ print_usage (const char *program_name)
|
||||
program_name);
|
||||
}
|
||||
|
||||
static void
|
||||
call_write_default_config (const char *hint)
|
||||
{
|
||||
static const char *prolog =
|
||||
"# " PROGRAM_NAME " " PROGRAM_VERSION " configuration file\n"
|
||||
"\n";
|
||||
|
||||
struct error *e = NULL;
|
||||
char *filename = write_default_config (hint, prolog, g_config_table, &e);
|
||||
if (!filename)
|
||||
{
|
||||
print_fatal ("%s", e->message);
|
||||
error_free (e);
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
print_status ("configuration written to `%s'", filename);
|
||||
free (filename);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
@@ -1741,7 +1726,7 @@ main (int argc, char *argv[])
|
||||
printf (PROGRAM_NAME " " PROGRAM_VERSION "\n");
|
||||
exit (EXIT_SUCCESS);
|
||||
case 'w':
|
||||
call_write_default_config (optarg);
|
||||
call_write_default_config (optarg, g_config_table);
|
||||
exit (EXIT_SUCCESS);
|
||||
default:
|
||||
print_fatal ("error in options");
|
||||
|
||||
Reference in New Issue
Block a user