Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 143 lines (117 sloc) 3.794 kb
116620d @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@2337 5dc97367-9…
alobbs authored
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2
3 /* Cherokee
4 *
5 * Authors:
6 * Alvaro Lopez Ortega <alvaro@alobbs.com>
7 *
920e20b @alobbs Happy new year!
alobbs authored
8 * Copyright (C) 2001-2011 Alvaro Lopez Ortega
116620d @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@2337 5dc97367-9…
alobbs authored
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of version 2 of the GNU General Public
12 * License as published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
2c39092 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@2660 5dc97367-9…
alobbs authored
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 * 02110-1301, USA.
72f6444 @alobbs Clean up: Trims trailing spaces.
alobbs authored
23 */
116620d @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@2337 5dc97367-9…
alobbs authored
24
25 #include "common-internal.h"
26 #include "validator_file.h"
12a060c @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@2338 5dc97367-9…
alobbs authored
27 #include "connection-protected.h"
116620d @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@2337 5dc97367-9…
alobbs authored
28
29 /* Properties
30 */
31
32 ret_t
33 cherokee_validator_file_props_init_base (cherokee_validator_file_props_t *props,
34 module_func_props_free_t free_func)
35 {
36 props->password_path_type = val_path_full;
37 cherokee_buffer_init (&props->password_file);
38
39 return cherokee_validator_props_init_base (VALIDATOR_PROPS(props), free_func);
72f6444 @alobbs Clean up: Trims trailing spaces.
alobbs authored
40 }
116620d @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@2337 5dc97367-9…
alobbs authored
41
42 ret_t
43 cherokee_validator_file_props_free_base (cherokee_validator_file_props_t *props)
44 {
45 cherokee_buffer_mrproper (&props->password_file);
46
47 return cherokee_validator_props_free_base (VALIDATOR_PROPS(props));
48 }
49
50 ret_t
51 cherokee_validator_file_configure (cherokee_config_node_t *conf,
52 cherokee_server_t *srv,
53 cherokee_module_props_t **_props)
54 {
55 ret_t ret;
56 cherokee_config_node_t *subconf;
57 cherokee_validator_file_props_t *props = PROP_VFILE(*_props);
58
1e47304 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@2701 5dc97367-9…
alobbs authored
59 UNUSED (srv);
60
116620d @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@2337 5dc97367-9…
alobbs authored
61 /* Password file
62 */
63 ret = cherokee_config_node_get (conf, "passwdfile", &subconf);
64 if (ret == ret_ok) {
65 cherokee_buffer_add_buffer (&props->password_file, &subconf->val);
66 }
67
68 /* Path type
69 */
70 ret = cherokee_config_node_get (conf, "passwdfile_path", &subconf);
71 if (ret == ret_ok) {
72 if (equal_buf_str (&subconf->val, "full")) {
73 props->password_path_type = val_path_full;
12a060c @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@2338 5dc97367-9…
alobbs authored
74 } else if (equal_buf_str (&subconf->val, "local_dir")) {
75 props->password_path_type = val_path_local_dir;
116620d @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@2337 5dc97367-9…
alobbs authored
76 } else {
165f0ad @alobbs Merges the 'newerrors' branch (r3613:HEAD). It implements a new
alobbs authored
77 LOG_ERROR (CHEROKEE_ERROR_VALIDATOR_FILE, subconf->val.buf);
116620d @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@2337 5dc97367-9…
alobbs authored
78 return ret_error;
79 }
80 }
81
82 /* Final checks
83 */
84 if (cherokee_buffer_is_empty (&props->password_file)) {
165f0ad @alobbs Merges the 'newerrors' branch (r3613:HEAD). It implements a new
alobbs authored
85 LOG_CRITICAL_S (CHEROKEE_ERROR_VALIDATOR_FILE_NO_FILE);
116620d @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@2337 5dc97367-9…
alobbs authored
86 return ret_error;
87 }
88
89 return ret_ok;
90 }
91
92
93 /* Validator
94 */
95
96 ret_t
97 cherokee_validator_file_init_base (cherokee_validator_file_t *validator,
98 cherokee_validator_file_props_t *props,
99 cherokee_plugin_info_validator_t *info)
100 {
101 return cherokee_validator_init_base (VALIDATOR(validator),
102 VALIDATOR_PROPS(props), info);
103 }
104
105 ret_t
106 cherokee_validator_file_free_base (cherokee_validator_file_t *validator)
107 {
108 return cherokee_validator_free_base (VALIDATOR(validator));
109 }
110
12a060c @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@2338 5dc97367-9…
alobbs authored
111
112 /* Utilities
113 */
114
115 ret_t
116 cherokee_validator_file_get_full_path (cherokee_validator_file_t *validator,
117 cherokee_connection_t *conn,
118 cherokee_buffer_t **ret_buf,
119 cherokee_buffer_t *tmp)
120 {
121 cherokee_validator_file_props_t *props = VAL_VFILE_PROP(validator);
122
123 switch (props->password_path_type) {
124 case val_path_full:
125 *ret_buf = &props->password_file;
126 return ret_ok;
127
128 case val_path_local_dir:
129 cherokee_buffer_clean (tmp);
130 cherokee_buffer_add_buffer (tmp, &conn->local_directory);
131 cherokee_buffer_add_char (tmp, '/');
132 cherokee_buffer_add_buffer (tmp, &props->password_file);
72f6444 @alobbs Clean up: Trims trailing spaces.
alobbs authored
133
12a060c @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@2338 5dc97367-9…
alobbs authored
134 *ret_buf = tmp;
135 return ret_ok;
136
137 default:
138 SHOULDNT_HAPPEN;
139 }
140
141 return ret_error;
142 }
Something went wrong with that request. Please try again.