summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorLars-Dominik Braun <lars@6xq.net>2011-11-10 10:07:40 +0100
committerLars-Dominik Braun <lars@6xq.net>2011-11-10 10:07:40 +0100
commit852e10d59bb6262de04593903981dec1e7ca85dc (patch)
treed5d31549a0d4cca8698e20fed2aa8f3cf1c53575 /src/main.c
parentbf397e4019acb60d90261247fd2850b849052ede (diff)
downloadpianobar-windows-852e10d59bb6262de04593903981dec1e7ca85dc.tar.gz
pianobar-windows-852e10d59bb6262de04593903981dec1e7ca85dc.tar.bz2
pianobar-windows-852e10d59bb6262de04593903981dec1e7ca85dc.zip
Die if trust file load fails
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/main.c b/src/main.c
index d4bf6fb..e14a88a 100644
--- a/src/main.c
+++ b/src/main.c
@@ -328,6 +328,7 @@ int main (int argc, char **argv) {
static BarApp_t app;
/* terminal attributes _before_ we started messing around with ~ECHO */
struct termios termOrig;
+ WaitressReturn_t wRet;
memset (&app, 0, sizeof (app));
@@ -344,10 +345,6 @@ int main (int argc, char **argv) {
BarSettingsInit (&app.settings);
BarSettingsRead (&app.settings);
- WaitressInit (&app.waith, app.settings.tlsCaPath);
- app.waith.url.host = strdup (PIANO_RPC_HOST);
- app.waith.url.tls = true;
-
BarUiMsg (&app.settings, MSG_NONE,
"Welcome to " PACKAGE " (" VERSION ")! ");
if (app.settings.keys[BAR_KS_HELP] == BAR_KS_DISABLED) {
@@ -358,6 +355,20 @@ int main (int argc, char **argv) {
app.settings.keys[BAR_KS_HELP]);
}
+ if ((wRet = WaitressInit (&app.waith, app.settings.tlsCaPath)) != WAITRESS_RET_OK) {
+ if (wRet == WAITRESS_RET_TLS_TRUSTFILE_ERR) {
+ BarUiMsg (&app.settings, MSG_ERR, "Can't load root certificates. "
+ "Please check the tls_ca_path setting in your config file.\n");
+ } else {
+ BarUiMsg (&app.settings, MSG_ERR, "Can't initialize HTTP library: "
+ "%s\n", WaitressErrorToStr (wRet));
+ }
+ goto die;
+ }
+
+ app.waith.url.host = strdup (PIANO_RPC_HOST);
+ app.waith.url.tls = true;
+
/* init fds */
FD_ZERO(&app.input.set);
app.input.fds[0] = STDIN_FILENO;
@@ -377,6 +388,7 @@ int main (int argc, char **argv) {
BarMainLoop (&app);
+die:
if (app.input.fds[1] != -1) {
close (app.input.fds[1]);
}