* Child process main loop.
*/
-static void process_socket(apr_pool_t *p, apr_socket_t *sock, long conn_id)
+static void process_socket(apr_pool_t *p, apr_socket_t *sock, long conn_id,
+ apr_bucket_alloc_t *bucket_alloc)
{
conn_rec *current_conn;
int csd;
}
ap_create_sb_handle(&sbh, p, conn_id / thread_limit, thread_num);
- current_conn = ap_run_create_connection(p, ap_server_conf, sock, conn_id, sbh);
+ current_conn = ap_run_create_connection(p, ap_server_conf, sock, conn_id,
+ sbh, bucket_alloc);
if (current_conn) {
ap_process_connection(current_conn, sock);
ap_lingering_close(current_conn);
ap_listen_rec *lr;
int n;
apr_socket_t *childsock = NULL;
+ apr_bucket_alloc_t *bucket_alloc;
apr_lock_acquire(thread_pool_parent_mutex);
apr_pool_create(&tpool, thread_pool_parent);
SERVER_STARTING,
(request_rec *) NULL);
+ bucket_alloc = apr_bucket_alloc_create(apr_thread_pool_get(thd));
+
apr_poll_setup(&pollset, num_listensocks + 1, tpool);
for(lr = ap_listeners; lr != NULL; lr = lr->next) {
apr_poll_socket_add(pollset, lr->sd, APR_POLLIN);
/* apr_poll_revents_get(&event, listenfds[0], pollset);
if (event & APR_POLLIN) {
- /* A process got a signal on the shutdown pipe. Check if we're
+ * A process got a signal on the shutdown pipe. Check if we're
* the lucky process to die.
check_pipe_of_death();
continue;
}
apr_poll_revents_get(&event, listenfds[1], pollset);
if (event & APR_POLLIN || event & APR_POLLOUT) {
- /* This request is from another child in our current process.
+ * This request is from another child in our current process.
* We should set a flag here, and then below we will read
* two bytes (the socket number and the NULL byte.
thread_socket_table[thread_num] = AP_PERCHILD_OTHERCHILD;
apr_os_sock_put(&csd, &child_info_table[child_num].sd, ptrans);
}
if (setjmp(jmpbuffer) != 1) {
- process_socket(ptrans, csd, conn_id);
+ process_socket(ptrans, csd, conn_id, bucket_alloc);
}
else {
thread_socket_table[thread_num] = AP_PERCHILD_THISCHILD;
}
apr_lock_release(worker_thread_count_mutex);
+ apr_bucket_alloc_destroy(bucket_alloc);
+
return NULL;
}
"NumServers in your config file.";
}
- ug->uid = atoi(u);
- ug->gid = atoi(g);
+ ug->uid = ap_uname2id(u);
+ ug->gid = ap_uname2id(g);
+#ifndef BIG_SECURITY_HOLE
+ if (ug->uid == 0 || ug->gid == 0) {
+ return "Assigning root user/group to a child.";
+ }
+#endif
}
return NULL;
}
const char *gid)
{
int i;
- int u = atoi(uid);
- int g = atoi(gid);
+ int matching = 0;
+ int u = ap_uname2id(uid);
+ int g = ap_uname2id(gid);
const char *errstr;
int socks[2];
perchild_server_conf *sconf = (perchild_server_conf *)
for (i = 0; i < num_daemons; i++) {
if (u == child_info_table[i].uid && g == child_info_table[i].gid) {
child_info_table[i].sd = sconf->sd;
+ matching++;
}
}
+ if (!matching) {
+ return "Unable to find process with matching uid/gid.";
+ }
return NULL;
}
* Child process main loop.
*/
-static void process_socket(apr_pool_t *p, apr_socket_t *sock, long conn_id)
+static void process_socket(apr_pool_t *p, apr_socket_t *sock, long conn_id,
+ apr_bucket_alloc_t *bucket_alloc)
{
conn_rec *current_conn;
int csd;
}
ap_create_sb_handle(&sbh, p, conn_id / thread_limit, thread_num);
- current_conn = ap_run_create_connection(p, ap_server_conf, sock, conn_id, sbh);
+ current_conn = ap_run_create_connection(p, ap_server_conf, sock, conn_id,
+ sbh, bucket_alloc);
if (current_conn) {
ap_process_connection(current_conn, sock);
ap_lingering_close(current_conn);
ap_listen_rec *lr;
int n;
apr_socket_t *childsock = NULL;
+ apr_bucket_alloc_t *bucket_alloc;
apr_lock_acquire(thread_pool_parent_mutex);
apr_pool_create(&tpool, thread_pool_parent);
SERVER_STARTING,
(request_rec *) NULL);
+ bucket_alloc = apr_bucket_alloc_create(apr_thread_pool_get(thd));
+
apr_poll_setup(&pollset, num_listensocks + 1, tpool);
for(lr = ap_listeners; lr != NULL; lr = lr->next) {
apr_poll_socket_add(pollset, lr->sd, APR_POLLIN);
/* apr_poll_revents_get(&event, listenfds[0], pollset);
if (event & APR_POLLIN) {
- /* A process got a signal on the shutdown pipe. Check if we're
+ * A process got a signal on the shutdown pipe. Check if we're
* the lucky process to die.
check_pipe_of_death();
continue;
}
apr_poll_revents_get(&event, listenfds[1], pollset);
if (event & APR_POLLIN || event & APR_POLLOUT) {
- /* This request is from another child in our current process.
+ * This request is from another child in our current process.
* We should set a flag here, and then below we will read
* two bytes (the socket number and the NULL byte.
thread_socket_table[thread_num] = AP_PERCHILD_OTHERCHILD;
apr_os_sock_put(&csd, &child_info_table[child_num].sd, ptrans);
}
if (setjmp(jmpbuffer) != 1) {
- process_socket(ptrans, csd, conn_id);
+ process_socket(ptrans, csd, conn_id, bucket_alloc);
}
else {
thread_socket_table[thread_num] = AP_PERCHILD_THISCHILD;
}
apr_lock_release(worker_thread_count_mutex);
+ apr_bucket_alloc_destroy(bucket_alloc);
+
return NULL;
}
"NumServers in your config file.";
}
- ug->uid = atoi(u);
- ug->gid = atoi(g);
+ ug->uid = ap_uname2id(u);
+ ug->gid = ap_uname2id(g);
+#ifndef BIG_SECURITY_HOLE
+ if (ug->uid == 0 || ug->gid == 0) {
+ return "Assigning root user/group to a child.";
+ }
+#endif
}
return NULL;
}
const char *gid)
{
int i;
- int u = atoi(uid);
- int g = atoi(gid);
+ int matching = 0;
+ int u = ap_uname2id(uid);
+ int g = ap_uname2id(gid);
const char *errstr;
int socks[2];
perchild_server_conf *sconf = (perchild_server_conf *)
for (i = 0; i < num_daemons; i++) {
if (u == child_info_table[i].uid && g == child_info_table[i].gid) {
child_info_table[i].sd = sconf->sd;
+ matching++;
}
}
+ if (!matching) {
+ return "Unable to find process with matching uid/gid.";
+ }
return NULL;
}