1 /* Copyright 2000-2005 The Apache Software Foundation or its licensors, as
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 #include "apr_errno.h"
22 #include "apr_strings.h"
23 #include "apr_file_io.h"
24 #include "apr_thread_proc.h"
33 passwords and hashes created with Apache's htpasswd utility like this:
35 htpasswd -c -b passwords pass1 pass1
36 htpasswd -b passwords pass2 pass2
37 htpasswd -b passwords pass3 pass3
38 htpasswd -b passwords pass4 pass4
39 htpasswd -b passwords pass5 pass5
40 htpasswd -b passwords pass6 pass6
41 htpasswd -b passwords pass7 pass7
42 htpasswd -b passwords pass8 pass8
43 (insert Perl one-liner to convert to initializer :) )
45 {"pass1", "1fWDc9QWYCWrQ"},
46 {"pass2", "1fiGx3u7QoXaM"},
47 {"pass3", "1fzijMylTiwCs"},
48 {"pass4", "nHUYc8U2UOP7s"},
49 {"pass5", "nHpETGLGPwAmA"},
50 {"pass6", "nHbsbWmJ3uyhc"},
51 {"pass7", "nHQ3BbF0Y9vpI"},
52 {"pass8", "nHZA1rViSldQk"}
54 static int num_passwords = sizeof(passwords) / sizeof(passwords[0]);
56 static void check_rv(apr_status_t rv)
58 if (rv != APR_SUCCESS) {
59 fprintf(stderr, "bailing\n");
64 static void test(void)
68 for (i = 0; i < num_passwords; i++) {
69 apr_status_t rv = apr_password_validate(passwords[i].password,
71 assert(rv == APR_SUCCESS);
77 static void * APR_THREAD_FUNC testing_thread(apr_thread_t *thd,
82 for (i = 0; i < 100; i++) {
88 static void thread_safe_test(apr_pool_t *p)
91 apr_thread_t *my_threads[NUM_THR];
95 for (i = 0; i < NUM_THR; i++) {
96 rv = apr_thread_create(&my_threads[i], NULL, testing_thread, NULL, p);
100 for (i = 0; i < NUM_THR; i++) {
101 apr_thread_join(&rv, my_threads[i]);
111 rv = apr_initialize();
113 rv = apr_pool_create(&p, NULL);
115 atexit(apr_terminate);
117 /* before creating any threads, test it first just to check
118 * for problems with the test driver
124 printf("thread-safe test\n");