0008-http-access-retain-auth-struct-for-the-runtime-of-th.patch 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. From f72729af3b7015a5b98817ec1813b60ed5405663 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 08/17] 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 | 9 +++++++--
  9. src/network/http_auth.c | 17 ++++++++++++++++-
  10. 2 files changed, 23 insertions(+), 3 deletions(-)
  11. diff --git a/modules/access/http.c b/modules/access/http.c
  12. index 4384e2b0a3..1a112b9ec1 100644
  13. --- a/modules/access/http.c
  14. +++ b/modules/access/http.c
  15. @@ -271,6 +271,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. @@ -358,6 +360,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. @@ -386,6 +390,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. @@ -624,8 +631,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. diff --git a/src/network/http_auth.c b/src/network/http_auth.c
  48. index ff1796c25d..939e493b76 100644
  49. --- a/src/network/http_auth.c
  50. +++ b/src/network/http_auth.c
  51. @@ -242,7 +242,10 @@ void vlc_http_auth_ParseWwwAuthenticateHeader(
  52. /* 2 Basic Authentication Scheme */
  53. msg_Dbg( p_this, "Using Basic Authentication" );
  54. psz_header += sizeof( psz_basic_prefix ) - 1;
  55. +
  56. + free( p_auth->psz_realm );
  57. p_auth->psz_realm = AuthGetParam( psz_header, "realm" );
  58. +
  59. if ( p_auth->psz_realm == NULL )
  60. msg_Warn( p_this, "Basic Authentication: "
  61. "Mandatory 'realm' parameter is missing" );
  62. @@ -258,12 +261,24 @@ void vlc_http_auth_ParseWwwAuthenticateHeader(
  63. return;
  64. psz_header += sizeof( psz_digest_prefix ) - 1;
  65. + p_auth->psz_nonce = AuthGetParam( psz_header, "nonce" );
  66. +
  67. + free( p_auth->psz_realm );
  68. p_auth->psz_realm = AuthGetParam( psz_header, "realm" );
  69. +
  70. + free( p_auth->psz_domain );
  71. p_auth->psz_domain = AuthGetParam( psz_header, "domain" );
  72. - p_auth->psz_nonce = AuthGetParam( psz_header, "nonce" );
  73. +
  74. + free( p_auth->psz_opaque );
  75. p_auth->psz_opaque = AuthGetParam( psz_header, "opaque" );
  76. +
  77. + free( p_auth->psz_stale );
  78. p_auth->psz_stale = AuthGetParamNoQuotes( psz_header, "stale" );
  79. +
  80. + free( p_auth->psz_algorithm );
  81. p_auth->psz_algorithm = AuthGetParamNoQuotes( psz_header, "algorithm" );
  82. +
  83. + free( p_auth->psz_qop );
  84. p_auth->psz_qop = AuthGetParam( psz_header, "qop" );
  85. p_auth->i_nonce = 0;
  86. --
  87. 2.21.1 (Apple Git-122.3)