aboutsummaryrefslogtreecommitdiff
path: root/src/examples/digest_auth_example.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2010-09-01 13:43:14 +0000
committerChristian Grothoff <christian@grothoff.org>2010-09-01 13:43:14 +0000
commitac0043ff0ae833bcaea1b26440dfe6472f851486 (patch)
tree0938c9742bd9285edba240c5e84f06a2941a9b3a /src/examples/digest_auth_example.c
parenta2da1819c6be4fa6949b13b7156aa34c054d555b (diff)
downloadlibmicrohttpd-ac0043ff0ae833bcaea1b26440dfe6472f851486.tar.gz
libmicrohttpd-ac0043ff0ae833bcaea1b26440dfe6472f851486.zip
From:
Amr Ali <amr.ali.cc@gmail.com> To: Christian Grothoff <christian@grothoff.org> Date: Today 15:24:06 Attachments: http_dauth_r5.patch Attached is a patch for all points discussed below.
Diffstat (limited to 'src/examples/digest_auth_example.c')
-rw-r--r--src/examples/digest_auth_example.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/examples/digest_auth_example.c b/src/examples/digest_auth_example.c
index b83be227..98b50382 100644
--- a/src/examples/digest_auth_example.c
+++ b/src/examples/digest_auth_example.c
@@ -48,7 +48,6 @@ ahc_echo (void *cls,
48 48
49 if (username == NULL) { 49 if (username == NULL) {
50 ret = MHD_queue_auth_fail_response(connection, realm, 50 ret = MHD_queue_auth_fail_response(connection, realm,
51 password,
52 OPAQUE, 51 OPAQUE,
53 MHD_NO); 52 MHD_NO);
54 53
@@ -62,7 +61,6 @@ ahc_echo (void *cls,
62 61
63 if (ret == MHD_INVALID_NONCE) { 62 if (ret == MHD_INVALID_NONCE) {
64 ret = MHD_queue_auth_fail_response(connection, realm, 63 ret = MHD_queue_auth_fail_response(connection, realm,
65 password,
66 OPAQUE, MHD_YES); 64 OPAQUE, MHD_YES);
67 65
68 return ret; 66 return ret;
@@ -70,7 +68,7 @@ ahc_echo (void *cls,
70 68
71 if (ret == MHD_NO) { 69 if (ret == MHD_NO) {
72 ret = MHD_queue_auth_fail_response(connection, realm, 70 ret = MHD_queue_auth_fail_response(connection, realm,
73 password, OPAQUE, MHD_NO); 71 OPAQUE, MHD_NO);
74 72
75 return ret; 73 return ret;
76 } 74 }
@@ -87,6 +85,9 @@ ahc_echo (void *cls,
87int 85int
88main (int argc, char *const *argv) 86main (int argc, char *const *argv)
89{ 87{
88 int fd;
89 char rnd[9];
90 size_t len;
90 struct MHD_Daemon *d; 91 struct MHD_Daemon *d;
91 92
92 if (argc != 2) 93 if (argc != 2)
@@ -94,9 +95,18 @@ main (int argc, char *const *argv)
94 printf ("%s PORT\n", argv[0]); 95 printf ("%s PORT\n", argv[0]);
95 return 1; 96 return 1;
96 } 97 }
98
99 fd = open("/dev/urandom", O_RDONLY);
100 len = read(fd, rnd, 8);
101 close(fd);
102
103 rnd[8] = '\0';
104
97 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_DEBUG, 105 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_DEBUG,
98 atoi (argv[1]), 106 atoi (argv[1]),
99 NULL, NULL, &ahc_echo, PAGE, MHD_OPTION_END); 107 NULL, NULL, &ahc_echo, PAGE,
108 MHD_OPTION_DIGEST_AUTH_RANDOM, rnd,
109 MHD_OPTION_END);
100 if (d == NULL) 110 if (d == NULL)
101 return 1; 111 return 1;
102 (void) getc (stdin); 112 (void) getc (stdin);