From 0269bfa309f85aaf05f1451196ad2bd8c0b150ac Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Mon, 7 Jul 2008 22:03:24 +0200 Subject: SSL control proxy issue workaround Some proxies refuse SSL connections. Make them usable by adding an option which disables the usage of SSL for the login. --- libpiano/src/main.c | 9 ++++++--- libpiano/src/piano.h | 3 ++- src/main.c | 4 ++-- src/pianobar.1 | 8 ++++++++ src/settings.c | 6 ++++++ src/settings.h | 1 + 6 files changed, 25 insertions(+), 6 deletions(-) diff --git a/libpiano/src/main.c b/libpiano/src/main.c index 1839c0c..dcfa70f 100644 --- a/libpiano/src/main.c +++ b/libpiano/src/main.c @@ -171,8 +171,11 @@ void PianoDestroy (PianoHandle_t *ph) { * @param piano handle * @param username (utf-8 encoded) * @param password (plaintext, utf-8 encoded) + * @param use ssl when logging in (1 = on, 0 = off), note that the password + * is not hashed and will be sent as plain-text! */ -PianoReturn_t PianoConnect (PianoHandle_t *ph, char *user, char *password) { +PianoReturn_t PianoConnect (PianoHandle_t *ph, char *user, char *password, + char secureLogin) { char url[PIANO_URL_BUFFER_SIZE]; char *requestStr = PianoEncryptString ("" "misc.sync" @@ -200,8 +203,8 @@ PianoReturn_t PianoConnect (PianoHandle_t *ph, char *user, char *password) { "%s" "", time (NULL), user, password); requestStr = PianoEncryptString (requestStrPlain); - snprintf (url, sizeof (url), PIANO_SECURE_RPC_URL "rid=%s" - "&method=authenticateListener", ph->routeId); + snprintf (url, sizeof (url), "%srid=%s&method=authenticateListener", + secureLogin ? PIANO_SECURE_RPC_URL : PIANO_RPC_URL, ph->routeId); if ((ret = PianoHttpPost (ph->curlHandle, url, requestStr, &retStr)) == PIANO_RET_OK) { diff --git a/libpiano/src/piano.h b/libpiano/src/piano.h index ce68c48..9945839 100644 --- a/libpiano/src/piano.h +++ b/libpiano/src/piano.h @@ -151,7 +151,8 @@ void PianoDestroyPlaylist (PianoHandle_t *ph); void PianoDestroySearchResult (PianoSearchResult_t *searchResult); void PianoDestroyStation (PianoStation_t *station); void PianoDestroyStations (PianoHandle_t *ph); -PianoReturn_t PianoConnect (PianoHandle_t *, char *, char *); +PianoReturn_t PianoConnect (PianoHandle_t *ph, char *user, char *password, + char secureLogin); PianoReturn_t PianoGetStations (PianoHandle_t *ph); PianoReturn_t PianoGetPlaylist (PianoHandle_t *ph, char *stationId); diff --git a/src/main.c b/src/main.c index 49914ba..fb9e02d 100644 --- a/src/main.c +++ b/src/main.c @@ -267,8 +267,8 @@ int main (int argc, char **argv) { BarTermSetBuffer (0); BarUiMsg ("Login... "); - if (PianoConnect (&ph, bsettings.username, bsettings.password) != - PIANO_RET_OK) { + if (PianoConnect (&ph, bsettings.username, bsettings.password, + !bsettings.disableSecureLogin) != PIANO_RET_OK) { BarUiMsg ("Error.\n"); return 0; } else { diff --git a/src/pianobar.1 b/src/pianobar.1 index 99c04e7..500b7ae 100644 --- a/src/pianobar.1 +++ b/src/pianobar.1 @@ -98,6 +98,14 @@ use. Note that needs an IP address specified in .B control_proxy +.TP +.B disable_secure_login = {1,0} +If you have problems when loggin in and you know your control proxy definitively +works try setting this option to +.B 1. +It disables the SSL secured login. Beware! +.I Your password will be sent as plain-text! + .TP .B lastfm_user = your_username If you want to send your played song to last.fm set this to your last.fm diff --git a/src/settings.c b/src/settings.c index 3a0ed4a..a691607 100644 --- a/src/settings.c +++ b/src/settings.c @@ -113,6 +113,12 @@ void BarSettingsRead (BarSettings_t *settings) { settings->lastfmPassword = strdup (val); } else if (strcmp ("lastfm_scrobble_percent", key) == 0) { settings->lastfmScrobblePercent = atoi (val); + } else if (strcmp ("disable_secure_login", key) == 0) { + if (strcmp (val, "1") == 0) { + settings->disableSecureLogin = 1; + } else { + settings->disableSecureLogin = 0; + } } } diff --git a/src/settings.h b/src/settings.h index b3604fa..b9617c4 100644 --- a/src/settings.h +++ b/src/settings.h @@ -34,6 +34,7 @@ struct BarSettings { char *lastfmPassword; unsigned char lastfmScrobblePercent; char enableScrobbling; + char disableSecureLogin; }; typedef struct BarSettings BarSettings_t; -- cgit v1.2.3