aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEvgeny Grin (Karlson2k) <k2k@narod.ru>2022-05-06 22:21:57 +0300
committerEvgeny Grin (Karlson2k) <k2k@narod.ru>2022-05-06 22:21:57 +0300
commitcd5ad7aaadd8f169f79ba3564d49d7f2889093b8 (patch)
treed5e3899cce349d35a68db02c1be9252f53eb81a1 /src
parentc658010707f6fc8a97b095584b55d842bc9faba9 (diff)
downloadlibmicrohttpd-cd5ad7aaadd8f169f79ba3564d49d7f2889093b8.tar.gz
libmicrohttpd-cd5ad7aaadd8f169f79ba3564d49d7f2889093b8.zip
digestauth: always use master daemon only
Diffstat (limited to 'src')
-rw-r--r--src/microhttpd/daemon.c9
-rw-r--r--src/microhttpd/digestauth.c14
2 files changed, 16 insertions, 7 deletions
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index f0708737..6b7d8355 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -7481,6 +7481,15 @@ MHD_start_daemon_va (unsigned int flags,
7481 MHD_mutex_destroy_chk_ (&d->new_connections_mutex); 7481 MHD_mutex_destroy_chk_ (&d->new_connections_mutex);
7482 goto thread_failed; 7482 goto thread_failed;
7483 } 7483 }
7484 /* Some members must be used only in master daemon */
7485#ifdef DAUTH_SUPPORT
7486 d->nnc = NULL;
7487 d->nonce_nc_size = 0;
7488#if defined(MHD_USE_THREADS)
7489 memset (d->nnc_lock, 1, sizeof(daemon->nnc_lock));
7490#endif /* MHD_USE_THREADS */
7491#endif /* DAUTH_SUPPORT */
7492
7484 7493
7485 /* Spawn the worker thread */ 7494 /* Spawn the worker thread */
7486 if (! MHD_create_named_thread_ (&d->pid, 7495 if (! MHD_create_named_thread_ (&d->pid,
diff --git a/src/microhttpd/digestauth.c b/src/microhttpd/digestauth.c
index a95455d3..a92d99ed 100644
--- a/src/microhttpd/digestauth.c
+++ b/src/microhttpd/digestauth.c
@@ -590,7 +590,7 @@ check_nonce_nc (struct MHD_Connection *connection,
590 size_t noncelen, 590 size_t noncelen,
591 uint64_t nc) 591 uint64_t nc)
592{ 592{
593 struct MHD_Daemon *daemon = connection->daemon; 593 struct MHD_Daemon *daemon = MHD_get_master (connection->daemon);
594 struct MHD_NonceNc *nn; 594 struct MHD_NonceNc *nn;
595 uint32_t mod; 595 uint32_t mod;
596 bool ret; 596 bool ret;
@@ -896,7 +896,7 @@ calculate_add_nonce (struct MHD_Connection *const connection,
896 struct DigestAlgorithm *da, 896 struct DigestAlgorithm *da,
897 char *nonce) 897 char *nonce)
898{ 898{
899 struct MHD_Daemon *const daemon = connection->daemon; 899 struct MHD_Daemon *const daemon = MHD_get_master (connection->daemon);
900 struct MHD_NonceNc *nn; 900 struct MHD_NonceNc *nn;
901 const size_t nonce_size = NONCE_STD_LEN (da->digest_size); 901 const size_t nonce_size = NONCE_STD_LEN (da->digest_size);
902 bool ret; 902 bool ret;
@@ -906,8 +906,8 @@ calculate_add_nonce (struct MHD_Connection *const connection,
906 906
907 calculate_nonce (timestamp, 907 calculate_nonce (timestamp,
908 connection->method, 908 connection->method,
909 connection->daemon->digest_auth_random, 909 daemon->digest_auth_random,
910 connection->daemon->digest_auth_rand_size, 910 daemon->digest_auth_rand_size,
911 connection->url, 911 connection->url,
912 realm, 912 realm,
913 da, 913 da,
@@ -969,7 +969,7 @@ calculate_add_nonce_with_retry (struct MHD_Connection *const connection,
969 const size_t digest_size = da->digest_size; 969 const size_t digest_size = da->digest_size;
970 char nonce2[NONCE_STD_LEN (VLA_ARRAY_LEN_DIGEST (digest_size)) + 1]; 970 char nonce2[NONCE_STD_LEN (VLA_ARRAY_LEN_DIGEST (digest_size)) + 1];
971 uint64_t timestamp2; 971 uint64_t timestamp2;
972 if (0 == connection->daemon->nonce_nc_size) 972 if (0 == MHD_get_master (connection->daemon)->nonce_nc_size)
973 return false; /* No need to re-try */ 973 return false; /* No need to re-try */
974 974
975 timestamp2 = MHD_monotonic_msec_counter (); 975 timestamp2 = MHD_monotonic_msec_counter ();
@@ -1142,7 +1142,7 @@ digest_auth_check_all (struct MHD_Connection *connection,
1142 const uint8_t *digest, 1142 const uint8_t *digest,
1143 unsigned int nonce_timeout) 1143 unsigned int nonce_timeout)
1144{ 1144{
1145 struct MHD_Daemon *daemon = connection->daemon; 1145 struct MHD_Daemon *daemon = MHD_get_master (connection->daemon);
1146 size_t len; 1146 size_t len;
1147 const char *header; 1147 const char *header;
1148 char nonce[MAX_NONCE_LENGTH]; 1148 char nonce[MAX_NONCE_LENGTH];
@@ -1655,7 +1655,7 @@ MHD_queue_auth_fail_response2 (struct MHD_Connection *connection,
1655 if (NULL == response) 1655 if (NULL == response)
1656 return MHD_NO; 1656 return MHD_NO;
1657 1657
1658 if (0 == connection->daemon->nonce_nc_size) 1658 if (0 == MHD_get_master (connection->daemon)->nonce_nc_size)
1659 { 1659 {
1660#ifdef HAVE_MESSAGES 1660#ifdef HAVE_MESSAGES
1661 MHD_DLOG (connection->daemon, 1661 MHD_DLOG (connection->daemon,