0021-http-access-retain-auth-struct-for-the-runtime-of-th.patch 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. From a1a5a96fe411e385473dcbb695c27f0ffcead6fd Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?Felix=20Paul=20K=C3=BChne?= <felix@feepk.net>
  3. Date: Mon, 10 Sep 2018 20:55:11 +0200
  4. Subject: [PATCH 21/26] http access: retain auth struct for the runtime of the
  5. module
  6. Previously, it was retained for a given connection only, so all information needed for a digest login was lost as soon as the module was reconnecting due to the expected 401 on attempted basic login
  7. ---
  8. modules/access/http.c | 12 +++++++-----
  9. src/network/http_auth.c | 17 ++++++++++++++++-
  10. 2 files changed, 23 insertions(+), 6 deletions(-)
  11. diff --git a/modules/access/http.c b/modules/access/http.c
  12. index 1d58a034b8..9078c8019e 100644
  13. --- a/modules/access/http.c
  14. +++ b/modules/access/http.c
  15. @@ -269,6 +269,8 @@ static int Open( vlc_object_t *p_this )
  16. p_sys->url.psz_username = (char *) credential.psz_username;
  17. p_sys->url.psz_password = (char *) credential.psz_password;
  18. }
  19. + vlc_http_auth_Init( &p_sys->auth );
  20. + vlc_http_auth_Init( &p_sys->proxy_auth );
  21. connect:
  22. /* Connect */
  23. @@ -356,6 +358,8 @@ error:
  24. free( p_sys->psz_referrer );
  25. free( p_sys->psz_username );
  26. free( p_sys->psz_password );
  27. + vlc_http_auth_Deinit( &p_sys->auth );
  28. + vlc_http_auth_Deinit( &p_sys->proxy_auth );
  29. return ret;
  30. }
  31. @@ -384,6 +388,9 @@ static void Close( vlc_object_t *p_this )
  32. free( p_sys->psz_username );
  33. free( p_sys->psz_password );
  34. + vlc_http_auth_Deinit( &p_sys->auth );
  35. + vlc_http_auth_Deinit( &p_sys->proxy_auth );
  36. +
  37. Disconnect( p_access );
  38. }
  39. @@ -628,8 +635,6 @@ static int Connect( stream_t *p_access )
  40. free( p_sys->psz_icy_name );
  41. free( p_sys->psz_icy_title );
  42. - vlc_http_auth_Init( &p_sys->auth );
  43. - vlc_http_auth_Init( &p_sys->proxy_auth );
  44. p_sys->psz_location = NULL;
  45. p_sys->psz_mime = NULL;
  46. p_sys->i_icy_meta = 0;
  47. @@ -977,9 +982,6 @@ static void Disconnect( stream_t *p_access )
  48. if( p_sys->fd != -1)
  49. net_Close(p_sys->fd);
  50. p_sys->fd = -1;
  51. -
  52. - vlc_http_auth_Deinit( &p_sys->auth );
  53. - vlc_http_auth_Deinit( &p_sys->proxy_auth );
  54. }
  55. /*****************************************************************************
  56. diff --git a/src/network/http_auth.c b/src/network/http_auth.c
  57. index 07064ce226..2ad5c28970 100644
  58. --- a/src/network/http_auth.c
  59. +++ b/src/network/http_auth.c
  60. @@ -243,7 +243,10 @@ void vlc_http_auth_ParseWwwAuthenticateHeader(
  61. /* 2 Basic Authentication Scheme */
  62. msg_Dbg( p_this, "Using Basic Authentication" );
  63. psz_header += sizeof( psz_basic_prefix ) - 1;
  64. +
  65. + free( p_auth->psz_realm );
  66. p_auth->psz_realm = AuthGetParam( psz_header, "realm" );
  67. +
  68. if ( p_auth->psz_realm == NULL )
  69. msg_Warn( p_this, "Basic Authentication: "
  70. "Mandatory 'realm' parameter is missing" );
  71. @@ -259,12 +262,24 @@ void vlc_http_auth_ParseWwwAuthenticateHeader(
  72. return;
  73. psz_header += sizeof( psz_digest_prefix ) - 1;
  74. + p_auth->psz_nonce = AuthGetParam( psz_header, "nonce" );
  75. +
  76. + free( p_auth->psz_realm );
  77. p_auth->psz_realm = AuthGetParam( psz_header, "realm" );
  78. +
  79. + free( p_auth->psz_domain );
  80. p_auth->psz_domain = AuthGetParam( psz_header, "domain" );
  81. - p_auth->psz_nonce = AuthGetParam( psz_header, "nonce" );
  82. +
  83. + free( p_auth->psz_opaque );
  84. p_auth->psz_opaque = AuthGetParam( psz_header, "opaque" );
  85. +
  86. + free( p_auth->psz_stale );
  87. p_auth->psz_stale = AuthGetParamNoQuotes( psz_header, "stale" );
  88. +
  89. + free( p_auth->psz_algorithm );
  90. p_auth->psz_algorithm = AuthGetParamNoQuotes( psz_header, "algorithm" );
  91. +
  92. + free( p_auth->psz_qop );
  93. p_auth->psz_qop = AuthGetParam( psz_header, "qop" );
  94. p_auth->i_nonce = 0;
  95. --
  96. 2.20.1