Changeset 379
- Timestamp:
- 08/31/06 20:28:05 (2 years ago)
- Files:
-
- cherokee/trunk/cherokee/Makefile.am (modified) (3 diffs)
- cherokee/trunk/cherokee/balancer.h (modified) (1 diff)
- cherokee/trunk/cherokee/balancer_round_robin.c (added)
- cherokee/trunk/cherokee/balancer_round_robin.h (added)
- cherokee/trunk/cherokee/connection.c (modified) (2 diffs)
- cherokee/trunk/cherokee/handler.h (modified) (1 diff)
- cherokee/trunk/cherokee/handler_error_redir.c (modified) (2 diffs)
- cherokee/trunk/cherokee/module.h (modified) (1 diff)
- cherokee/trunk/cherokee/util.c (modified) (1 diff)
- cherokee/trunk/cherokee/util.h (modified) (3 diffs)
- cherokee/trunk/configure.in (modified) (3 diffs)
- cherokee/trunk/m4/Makefile.am (modified) (1 diff)
- cherokee/trunk/m4/pwd_grp.m4 (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
cherokee/trunk/cherokee/Makefile.am
r370 r379 544 544 else 545 545 dynamic_validator_htdigest_lib = libplugin_htdigest.la 546 endif 547 548 549 # 550 # Balancer Round Robin 551 # 552 balancer_round_robin = \ 553 balancer_round_robin.c \ 554 balancer_round_robin.h 555 556 libplugin_round_robin_la_LDFLAGS = $(module_ldflags) 557 libplugin_round_robin_la_SOURCES = $(balancer_round_robin) 558 559 if STATIC_BALANCER_ROUND_ROBIN 560 static_balancer_round_robin_src = $(balancer_round_robin) 561 else 562 dynamic_balancer_round_robin_lib = libplugin_round_robin.la 546 563 endif 547 564 … … 764 781 $(static_validator_htpasswd_src) \ 765 782 \ 783 $(static_balancer_round_robin_src) \ 784 \ 766 785 $(common_cgi) \ 767 786 \ … … 886 905 $(dynamic_validator_plain_lib) \ 887 906 $(dynamic_validator_htdigest_lib) \ 888 $(dynamic_validator_htpasswd_lib) 907 $(dynamic_validator_htpasswd_lib) \ 908 $(dynamic_balancer_round_robin_lib) 889 909 890 910 cherokee/trunk/cherokee/balancer.h
r372 r379 44 44 45 45 46 /* Handler properties 47 */ 48 typedef ret_t (* balancer_props_func_free_t) (void *balancerp); 49 50 typedef struct { 51 balancer_props_func_free_t free; 52 } cherokee_balancer_props_t; 53 54 46 55 /* Balancer 47 56 */ cherokee/trunk/cherokee/connection.c
r376 r379 1161 1161 cherokee_connection_build_local_directory_userdir (cherokee_connection_t *conn, cherokee_virtual_server_t *vsrv, cherokee_config_entry_t *entry) 1162 1162 { 1163 struct passwd *pwd; 1163 ret_t ret; 1164 struct passwd pwd; 1165 char tmp[1024]; 1164 1166 1165 1167 /* Has a defined DocumentRoot … … 1182 1184 /* Default: it is inside the UserDir in home 1183 1185 */ 1184 pwd = (struct passwd *) getpwnam (conn->userdir.buf);1185 if (( pwd == NULL) || (pwd->pw_dir == NULL)) {1186 ret = cherokee_getpwnam (conn->userdir.buf, &pwd, tmp, 1024); 1187 if ((ret != ret_ok) || (pwd.pw_dir == NULL)) { 1186 1188 conn->error_code = http_not_found; 1187 1189 return ret_error; 1188 1190 } 1189 1191 1190 1192 /* Build the local_directory: 1191 1193 */ 1192 cherokee_buffer_add (&conn->local_directory, pwd ->pw_dir, strlen(pwd->pw_dir));1193 cherokee_buffer_add (&conn->local_directory, "/", 1);1194 cherokee_buffer_add (&conn->local_directory, pwd.pw_dir, strlen(pwd.pw_dir)); 1195 cherokee_buffer_add_str (&conn->local_directory, "/"); 1194 1196 cherokee_buffer_add_buffer (&conn->local_directory, &vsrv->userdir); 1195 1197 cherokee/trunk/cherokee/handler.h
r370 r379 60 60 61 61 typedef struct { 62 handler_props_func_free_t free;62 handler_props_func_free_t free; 63 63 } cherokee_handler_props_t; 64 64 cherokee/trunk/cherokee/handler_error_redir.c
r378 r379 102 102 103 103 ret_t 104 cherokee_handler_error_redir_new (cherokee_handler_t **hdl, cherokee_connection_t *c nt, cherokee_handler_props_t *props)104 cherokee_handler_error_redir_new (cherokee_handler_t **hdl, cherokee_connection_t *conn, cherokee_handler_props_t *props) 105 105 { 106 106 list_t *i; … … 109 109 error_entry_t *entry = (error_entry_t *)i; 110 110 111 if (entry->error != c nt->error_code)111 if (entry->error != conn->error_code) 112 112 continue; 113 113 114 cherokee_buffer_clean (&c nt->redirect);115 cherokee_buffer_add_buffer (&c nt->redirect, &entry->url);114 cherokee_buffer_clean (&conn->redirect); 115 cherokee_buffer_add_buffer (&conn->redirect, &entry->url); 116 116 117 c nt->error_code = http_moved_permanently;118 return cherokee_handler_redir_new (hdl, c nt, props);117 conn->error_code = http_moved_permanently; 118 return cherokee_handler_redir_new (hdl, conn, props); 119 119 } 120 120 cherokee/trunk/cherokee/module.h
r347 r379 44 44 cherokee_handler = 1 << 2, 45 45 cherokee_encoder = 1 << 3, 46 cherokee_validator = 1 << 4 46 cherokee_validator = 1 << 4, 47 cherokee_balancer = 1 << 5 47 48 } cherokee_module_type_t; 48 49 cherokee/trunk/cherokee/util.c
r370 r379 1080 1080 return ret_ok; 1081 1081 } 1082 1083 1084 1085 #if defined(HAVE_PTHREAD) && !defined(HAVE_GETPWNAM_R) 1086 static pthread_mutex_t __global_getpwnam_mutex = PTHREAD_MUTEX_INITIALIZER; 1087 #endif 1088 1089 ret_t 1090 cherokee_getpwnam (const char *name, struct passwd *pwbuf, char *buf, size_t buflen) 1091 { 1092 #ifndef HAVE_GETPWNAM_R 1093 size_t pw_name_len = 0; 1094 size_t pw_passwd_len = 0; 1095 size_t pw_gecos_len = 0; 1096 size_t pw_dir_len = 0; 1097 size_t pw_shell_len = 0; 1098 char *ptr; 1099 struct passwd *tmp; 1100 1101 CHEROKEE_MUTEX_LOCK (&__global_getpwnam_mutex); 1102 1103 tmp = getpwnam (name); 1104 if (tmp == NULL) 1105 return ret_error; 1106 1107 if (tmp->pw_name) pw_name_len = strlen(tmp->pw_name); 1108 if (tmp->pw_passwd) pw_passwd_len = strlen(tmp->pw_passwd); 1109 if (tmp->pw_gecos) pw_gecos_len = strlen(tmp->pw_gecos); 1110 if (tmp->pw_dir) pw_dir_len = strlen(tmp->pw_dir); 1111 if (tmp->pw_shell) pw_shell_len = strlen(tmp->pw_shell); 1112 1113 if ((pw_name_len + pw_passwd_len + 1114 pw_gecos_len + pw_dir_len + pw_shell_len) > buflen) 1115 return ret_error; 1116 1117 memset (buf, 0, buflen); 1118 ptr = buf; 1119 1120 pwbuf->pw_uid = tmp->pw_uid; 1121 pwbuf->pw_gid = tmp->pw_gid; 1122 1123 if (tmp->pw_dir) { 1124 memcpy (ptr, tmp->pw_dir, pw_dir_len); 1125 pwbuf->pw_dir = ptr; 1126 ptr += pw_dir_len + 1; 1127 } 1128 1129 if (tmp->pw_passwd) { 1130 memcpy (ptr, tmp->pw_passwd, pw_passwd_len); 1131 pwbuf->pw_passwd = ptr; 1132 ptr += pw_passwd_len + 1; 1133 } 1134 1135 if (tmp->pw_name) { 1136 memcpy (ptr, tmp->pw_name, pw_name_len); 1137 pwbuf->pw_name = ptr; 1138 ptr += pw_name_len + 1; 1139 } 1140 1141 if (tmp->pw_gecos) { 1142 memcpy (ptr, tmp->pw_gecos, pw_gecos_len); 1143 pwbuf->pw_gecos = ptr; 1144 ptr += pw_gecos_len + 1; 1145 } 1146 1147 if (tmp->pw_shell) { 1148 memcpy (ptr, tmp->pw_shell, pw_shell_len); 1149 pwbuf->pw_shell = ptr; 1150 ptr += pw_shell_len + 1; 1151 } 1152 1153 CHEROKEE_MUTEX_UNLOCK (&__global_getpwnam_mutex); 1154 return ret_ok; 1155 1156 #elif HAVE_GETPWNAM_R_5 1157 int re; 1158 struct passwd *tmp; 1159 1160 re = getpwnam_r (name, pwbuf, buf, buflen, &tmp); 1161 if (re != 0) return ret_error; 1162 1163 return ret_ok; 1164 1165 #elif HAVE_GETPWNAM_R_4 1166 int re; 1167 1168 re = getpwnam_r (name, pwbuf, buf, buflen); 1169 if (re != 0) return ret_error; 1170 1171 return ret_ok; 1172 #endif 1173 1174 return ret_no_sys; 1175 } 1176 1177 1178 #if defined(HAVE_PTHREAD) && !defined(HAVE_GETGRNAM_R) 1179 static pthread_mutex_t __global_getgrnam_mutex = PTHREAD_MUTEX_INITIALIZER; 1180 #endif 1181 1182 ret_t 1183 cherokee_getgrnam (const char *name, struct group *grbuf, char *buf, size_t buflen) 1184 { 1185 #ifndef HAVE_GETGRNAM_R 1186 size_t gr_name_len = 0; 1187 size_t gr_passwd_len = 0; 1188 char *ptr; 1189 struct group *tmp; 1190 1191 CHEROKEE_MUTEX_LOCK (&__global_getgrnam_mutex); 1192 1193 tmp = getgrnam (name); 1194 if (tmp == NULL) 1195 return ret_error; 1196 1197 if (tmp->gr_name) gr_name_len = strlen(tmp->gr_name); 1198 if (tmp->gr_passwd) gr_passwd_len = strlen(tmp->gr_passwd); 1199 1200 if ((gr_name_len + gr_passwd_len) > buflen) 1201 return ret_error; 1202 1203 memset (buf, 0, buflen); 1204 ptr = buf; 1205 1206 grbuf->gr_gid = tmp->gr_gid; 1207 1208 if (tmp->gr_name) { 1209 memcpy (ptr, tmp->gr_name, gr_name_len); 1210 grbuf->gr_name = ptr; 1211 ptr += gr_name_len + 1; 1212 } 1213 1214 if (tmp->gr_passwd) { 1215 memcpy (ptr, tmp->gr_passwd, gr_passwd_len); 1216 grbuf->gr_passwd = ptr; 1217 ptr += gr_passwd_len + 1; 1218 } 1219 1220 // TODO: Duplicate char **tmp->gr_mem 1221 1222 CHEROKEE_MUTEX_UNLOCK (&__global_getgrnam_mutex); 1223 return ret_ok; 1224 1225 #elif HAVE_GETGRNAM_R_5 1226 int re; 1227 struct group *tmp; 1228 1229 re = getgrnam_r (name, grbuf, buf, buflen, &tmp); 1230 if (re != 0) return ret_error; 1231 1232 return ret_ok; 1233 1234 #elif HAVE_GETGRNAM_R_4 1235 int re; 1236 1237 re = getgrnam_r (name, grbuf, buf, buflen); 1238 if (re != 0) return ret_error; 1239 1240 return ret_ok; 1241 #endif 1242 1243 return ret_no_sys; 1244 } cherokee/trunk/cherokee/util.h
r370 r379 41 41 #endif 42 42 43 #include <pwd.h> 44 #include <grp.h> 45 43 46 #include <time.h> 44 47 #include <dirent.h> … … 77 80 /* Time management functions 78 81 */ 79 80 82 struct tm *cherokee_gmtime (const time_t *timep, struct tm *result); 81 83 struct tm *cherokee_localtime (const time_t *timep, struct tm *result); … … 87 89 ret_t cherokee_gethostbyname (const char *hostname, void *addr); 88 90 ret_t cherokee_syslog (int priority, cherokee_buffer_t *buf); 91 ret_t cherokee_getpwnam (const char *name, struct passwd *pwbuf, char *buf, size_t buflen); 92 ret_t cherokee_getgrnam (const char *name, struct group *pwbuf, char *buf, size_t buflen); 89 93 90 94 /* Misc cherokee/trunk/configure.in
r370 r379 212 212 AC_CHECK_FUNCS(gmtime gmtime_r localtime localtime_r getrlimit getdtablesize readdir readdir_r flockfile funlockfile) 213 213 214 FW_CHECK_PWD 215 FW_CHECK_GRP 214 216 215 217 AH_BOTTOM([ … … 920 922 [use_static_module="$use_static_module $enableval "],[]) 921 923 922 modules="error_redir server_info file admin dirlist fcgi fastcgi scgi redir common nn cgi phpcgi proxy gzip ncsa combined w3c pam ldap htpasswd plain htdigest "924 modules="error_redir server_info file admin dirlist fcgi fastcgi scgi redir common nn cgi phpcgi proxy gzip ncsa combined w3c pam ldap htpasswd plain htdigest round_robin" 923 925 924 926 # Remove modules that will not be compiles … … 985 987 AM_CONDITIONAL(STATIC_VALIDATOR_PLAIN, grep plain $conf_h >/dev/null) 986 988 AM_CONDITIONAL(STATIC_VALIDATOR_HTDIGEST, grep htdigest $conf_h >/dev/null) 989 AM_CONDITIONAL(STATIC_BALANCER_ROUND_ROBIN, grep round_robin $conf_h >/dev/null) 987 990 988 991 AC_OUTPUT(Makefile cherokee/Makefile.MingW m4/Makefile cherokee/Makefile cget/Makefile icons/Makefile themes/Makefile www/Makefile doc/Makefile doc/develop/Makefile doc/develop/doxygen.cfg contrib/Makefile qa/Makefile windows/Makefile cherokee-config cherokee.spec cherokee.pc windows/cherokee.nsi) cherokee/trunk/m4/Makefile.am
r324 r379 3 3 network.m4 \ 4 4 sendfile_samba.m4 \ 5 etr_socket_nsl.m4 5 etr_socket_nsl.m4 \ 6 pwd_grp.m4