#include <limits.h>
#include <php_config.h>
-#include <fpm/fpm.h>
-#include <fpm/fpm_request.h>
+#include "fpm.h"
+#include "fpm_request.h"
+#include "zlog.h"
#ifdef _WIN32
}
allowed_clients[n] = inet_addr(cur);
if (allowed_clients[n] == INADDR_NONE) {
- fprintf(stderr, "Wrong IP address '%s' in FCGI_WEB_SERVER_ADDRS or listen.allowed_clients\n", cur);
+ zlog(ZLOG_ERROR, "Wrong IP address '%s' in listen.allowed_clients", cur);
}
n++;
cur = end;
n++;
}
if (!allowed) {
- fprintf(stderr, "Connection from disallowed IP address '%s' is dropped.\n", inet_ntoa(sa.sa_inet.sin_addr));
+ zlog(ZLOG_ERROR, "Connection disallowed: IP address '%s' has been dropped.", inet_ntoa(sa.sa_inet.sin_addr));
closesocket(req->fd);
req->fd = -1;
continue;
}
fcgi_close(req, 1, 0);
} else {
- fprintf(stderr, "Too many open file descriptors. FD_SETSIZE limit exceeded.");
+ zlog(ZLOG_ERROR, "Too many open file descriptors. FD_SETSIZE limit exceeded.");
fcgi_close(req, 1, 0);
}
#endif
if (fpm_globals.test_successful) {
exit(0);
} else {
+ zlog(ZLOG_ERROR, "FPM initialization failed");
return -1;
}
}
if (0 > fpm_conf_write_pid()) {
+ zlog(ZLOG_ERROR, "FPM initialization failed");
return -1;
}
{
fpm_globals.max_requests = wp->config->pm_max_requests;
- if (0 > fpm_stdio_init_child(wp) ||
- 0 > fpm_log_init_child(wp) ||
- 0 > fpm_status_init_child(wp) ||
- 0 > fpm_unix_init_child(wp) ||
- 0 > fpm_signals_init_child() ||
- 0 > fpm_env_init_child(wp) ||
- 0 > fpm_php_init_child(wp)) {
+ if (0 > fpm_stdio_init_child(wp) ||
+ 0 > fpm_log_init_child(wp) ||
+ 0 > fpm_status_init_child(wp) ||
+ 0 > fpm_unix_init_child(wp) ||
+ 0 > fpm_signals_init_child() ||
+ 0 > fpm_env_init_child(wp) ||
+ 0 > fpm_php_init_child(wp)) {
zlog(ZLOG_ERROR, "[pool %s] child failed to initialize", wp->config->name);
exit(255);
}
}
} else {
- zlog(ZLOG_ALERT, "oops, unknown child (%d) exited %s", pid, buf);
+ zlog(ZLOG_ALERT, "oops, unknown child (%d) exited %s. Please open a bug report (https://bugs.php.net).", pid, buf);
}
}
}
c = fpm_child_alloc();
if (!c) {
- zlog(ZLOG_ERROR, "[pool %s] malloc failed", wp->config->name);
+ zlog(ZLOG_ERROR, "[pool %s] unable to malloc new child", wp->config->name);
return 0;
}
#include "fpm_arrays.h"
#include "fpm_cleanup.h"
-#include "zlog.h"
struct cleanup_s {
int type;
#define STR2STR(a) (a ? a : "undefined")
#define BOOL2STR(a) (a ? "yes" : "no")
-#define PM2STR(a) (a == PM_STYLE_STATIC ? "static" : "dynamic")
#define GO(field) offsetof(struct fpm_global_config_s, field)
#define WPO(field) offsetof(struct fpm_worker_pool_config_s, field)
struct fpm_worker_pool_s *wp;
if (!fpm_worker_all_pools) {
- zlog(ZLOG_ERROR, "at least one pool section must be specified in config file");
+ zlog(ZLOG_ERROR, "No pool defined. at least one pool section must be specified in config file");
return -1;
}
if (config->pm_min_spare_servers > config->pm_max_children ||
config->pm_max_spare_servers > config->pm_max_children) {
- zlog(ZLOG_ALERT, "[pool %s] pm.min_spare_servers(%d) and pm.max_spare_servers(%d) cannot be greater than pm.max_children(%d)",
- wp->config->name, config->pm_min_spare_servers, config->pm_max_spare_servers, config->pm_max_children);
+ zlog(ZLOG_ALERT, "[pool %s] pm.min_spare_servers(%d) and pm.max_spare_servers(%d) cannot be greater than pm.max_children(%d)", wp->config->name, config->pm_min_spare_servers, config->pm_max_spare_servers, config->pm_max_children);
return -1;
}
if (config->pm_start_servers <= 0) {
config->pm_start_servers = config->pm_min_spare_servers + ((config->pm_max_spare_servers - config->pm_min_spare_servers) / 2);
zlog(ZLOG_WARNING, "[pool %s] pm.start_servers is not set. It's been set to %d.", wp->config->name, config->pm_start_servers);
+
} else if (config->pm_start_servers < config->pm_min_spare_servers || config->pm_start_servers > config->pm_max_spare_servers) {
zlog(ZLOG_ALERT, "[pool %s] pm.start_servers(%d) must not be less than pm.min_spare_servers(%d) and not greater than pm.max_spare_servers(%d)", wp->config->name, config->pm_start_servers, config->pm_min_spare_servers, config->pm_max_spare_servers);
return -1;
if (wp->config->pm_status_path && *wp->config->pm_status_path) {
int i;
char *status = wp->config->pm_status_path;
- /* struct fpm_status_s fpm_status; */
if (*status != '/') {
zlog(ZLOG_ERROR, "[pool %s] the status path '%s' must start with a '/'", wp->config->name, status);
fd = open(wp->config->slowlog, O_WRONLY | O_APPEND | O_CREAT, S_IRUSR | S_IWUSR);
if (0 > fd) {
- zlog(ZLOG_SYSERROR, "open(%s) failed", wp->config->slowlog);
+ zlog(ZLOG_SYSERROR, "Unable to create or open slowlog(%s)", wp->config->slowlog);
return -1;
}
close(fd);
zlog(ZLOG_ERROR, "[pool %s] the chroot path '%s' must start with a '/'", wp->config->name, wp->config->chroot);
return -1;
}
+
if (!fpm_conf_is_dir(wp->config->chroot)) {
zlog(ZLOG_ERROR, "[pool %s] the chroot path '%s' does not exist or is not a directory", wp->config->name, wp->config->chroot);
return -1;
{
if (fpm_global_config.pid_file) {
if (0 > unlink(fpm_global_config.pid_file)) {
- zlog(ZLOG_SYSERROR, "unlink(\"%s\") failed", fpm_global_config.pid_file);
+ zlog(ZLOG_SYSERROR, "Unable to remove the PID file (%s).", fpm_global_config.pid_file);
return -1;
}
}
fd = creat(fpm_global_config.pid_file, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
if (fd < 0) {
- zlog(ZLOG_SYSERROR, "creat(\"%s\") failed", fpm_global_config.pid_file);
+ zlog(ZLOG_SYSERROR, "Unable to create the PID file (%s).", fpm_global_config.pid_file);
return -1;
}
len = sprintf(buf, "%d", (int) fpm_globals.parent_pid);
if (len != write(fd, buf, len)) {
- zlog(ZLOG_SYSERROR, "write() failed");
+ zlog(ZLOG_SYSERROR, "Unable to write to the PID file.");
return -1;
}
close(fd);
int ret = 1;
if (!filename || !filename[0]) {
- zlog(ZLOG_ERROR, "Configuration file is empty");
+ zlog(ZLOG_ERROR, "configuration filename is empty");
return -1;
}
fd = open(filename, O_RDONLY, 0);
if (fd < 0) {
- zlog(ZLOG_ERROR, "Unable to open file '%s', errno=%d", filename, errno);
+ zlog(ZLOG_SYSERROR, "failed to open configuration file '%s'", filename);
return -1;
}
if (ini_recursion++ > 4) {
- zlog(ZLOG_ERROR, "You can include more than 5 files recusively");
+ zlog(ZLOG_ERROR, "failed to include more than 5 files recusively");
return -1;
}
#include <stdint.h>
#include "php.h"
+#define PM2STR(a) (a == PM_STYLE_STATIC ? "static" : "dynamic")
+
#define FPM_CONF_MAX_PONG_LENGTH 64
struct key_value_s;
#include "fpm_env.h"
#include "fpm.h"
-#include "zlog.h"
#ifndef HAVE_SETPROCTITLE
#ifdef __linux__
if (res <= 0) {
if (res < 0 && errno != EAGAIN && errno != EWOULDBLOCK) {
- zlog(ZLOG_SYSERROR, "read() failed");
+ zlog(ZLOG_SYSERROR, "unable to read from the signal pipe");
}
return;
}
}
if (!(elt = malloc(sizeof(struct fpm_event_queue_s)))) {
- zlog(ZLOG_SYSERROR, "malloc() failed");
+ zlog(ZLOG_SYSERROR, "Unable to add the event to queue: malloc() failed");
return -1;
}
elt->prev = NULL;
/* malloc the max number of necessary fds for polling */
fpm_event_ufds = malloc(sizeof(php_pollfd) * fpm_event_nfds_max);
if (!fpm_event_ufds) {
- zlog(ZLOG_SYSERROR, "malloc() failed");
+ zlog(ZLOG_SYSERROR, "Error while initializing events: malloc() failed");
return -1;
}
/* wait for inconming event or timeout */
if ((ret = php_poll2(fpm_event_ufds, i, timeout)) == -1) {
if (errno != EINTR) {
- zlog(ZLOG_WARNING, "php_poll2() returns %d", errno);
+ zlog(ZLOG_SYSERROR, "failed to wait for events: php_poll2()");
}
} else if (ret > 0) {
fd = open(wp->config->access_log, O_WRONLY | O_APPEND | O_CREAT, S_IRUSR | S_IWUSR);
if (0 > fd) {
- zlog(ZLOG_SYSERROR, "open(\"%s\") failed", wp->config->access_log);
+ zlog(ZLOG_SYSERROR, "failed to open access log (%s)", wp->config->access_log);
return -1;
}
if (!test) {
scoreboard = fpm_scoreboard_get();
if (!scoreboard) {
- zlog(ZLOG_WARNING, "unable to get scoreboard");
+ zlog(ZLOG_WARNING, "unable to get scoreboard while preparing the access log");
return -1;
}
proc_p = fpm_scoreboard_proc_acquire(NULL, -1, 0);
if (!proc_p) {
- zlog(ZLOG_WARNING, "[pool %s] Unable to acquire shm slot", scoreboard->pool);
+ zlog(ZLOG_WARNING, "[pool %s] Unable to acquire shm slot while preparing the access log", scoreboard->pool);
return -1;
}
proc = *proc_p;
while (*s != '\0') {
if (len > FPM_LOG_BUFFER) {
- zlog(ZLOG_NOTICE, "the log buffer is full (%d). The log request has been truncated.", FPM_LOG_BUFFER);
+ zlog(ZLOG_NOTICE, "the log buffer is full (%d). The access log request has been truncated.", FPM_LOG_BUFFER);
len = FPM_LOG_BUFFER - 1;
break;
}
#include "fastcgi.h"
#include <php_config.h>
-#include <fpm/fpm.h>
-#include <fpm/fpm_request.h>
-#include <fpm/fpm_status.h>
-#include <fpm/fpm_conf.h>
-#include <fpm/fpm_php.h>
-#include <fpm/fpm_log.h>
-#include <fpm/zlog.h>
+#include "fpm.h"
+#include "fpm_request.h"
+#include "fpm_status.h"
+#include "fpm_conf.h"
+#include "fpm_php.h"
+#include "fpm_log.h"
+#include "zlog.h"
#ifndef PHP_WIN32
/* XXX this will need to change later when threaded fastcgi is implemented. shane */
}
- zlog(ZLOG_NOTICE, "Access to the file '%s' has been denied (see security.limit_extensions)", path);
+ zlog(ZLOG_NOTICE, "Access to the script '%s' has been denied (see security.limit_extensions)", path);
return 1; /* extension not found: not allowed */
}
/* }}} */
slowlog = fopen(child->wp->config->slowlog, "a+");
if (!slowlog) {
- zlog(ZLOG_SYSERROR, "fopen(%s) failed", child->wp->config->slowlog);
+ zlog(ZLOG_SYSERROR, "unable to open slowlog (%s)", child->wp->config->slowlog);
goto done0;
}
fpm_cleanups_run(FPM_CLEANUP_PARENT_EXEC);
execvp(saved_argv[0], saved_argv);
- zlog(ZLOG_SYSERROR, "execvp() failed");
+ zlog(ZLOG_SYSERROR, "failed to reload: execvp() failed");
exit(1);
}
/* }}} */
proc = fpm_scoreboard_proc_acquire(NULL, -1, 0);
if (proc == NULL) {
- zlog(ZLOG_WARNING, "unable to acquire proc scoreboard");
+ zlog(ZLOG_WARNING, "failed to acquire proc scoreboard");
return;
}
proc = fpm_scoreboard_proc_acquire(NULL, -1, 0);
if (proc == NULL) {
- zlog(ZLOG_WARNING, "unable to acquire proc scoreboard");
+ zlog(ZLOG_WARNING, "failed to acquire proc scoreboard");
return;
}
proc = fpm_scoreboard_proc_acquire(NULL, -1, 0);
if (proc == NULL) {
- zlog(ZLOG_WARNING, "unable to acquire proc scoreboard");
+ zlog(ZLOG_WARNING, "failed to acquire proc scoreboard");
return;
}
proc = fpm_scoreboard_proc_acquire(NULL, -1, 0);
if (proc == NULL) {
- zlog(ZLOG_WARNING, "unable to acquire proc scoreboard");
+ zlog(ZLOG_WARNING, "failed to acquire proc scoreboard");
return;
}
proc = fpm_scoreboard_proc_acquire(NULL, -1, 0);
if (proc == NULL) {
- zlog(ZLOG_WARNING, "unable to acquire proc scoreboard");
+ zlog(ZLOG_WARNING, "failed to acquire proc scoreboard");
return;
}
proc->request_stage = FPM_REQUEST_FINISHED;
proc = fpm_scoreboard_proc_acquire(NULL, -1, 0);
if (proc == NULL) {
- zlog(ZLOG_WARNING, "unable to acquire proc scoreboard");
+ zlog(ZLOG_WARNING, "failed to acquire proc scoreboard");
return;
}
proc_p = fpm_scoreboard_proc_acquire(child->wp->scoreboard, child->scoreboard_i, 1);
if (!proc_p) {
- zlog(ZLOG_WARNING, "unable to acquire scoreboard");
+ zlog(ZLOG_WARNING, "failed to acquire scoreboard");
return;
}
}
if (munmap(mem, size) == -1) {
- zlog(ZLOG_SYSERROR, "Unable to free shm: %s", strerror(errno));
+ zlog(ZLOG_SYSERROR, "Unable to free shm");
return 0;
}
struct sigaction act;
if (0 > socketpair(AF_UNIX, SOCK_STREAM, 0, sp)) {
- zlog(ZLOG_SYSERROR, "socketpair() failed");
+ zlog(ZLOG_SYSERROR, "failed to init signals: socketpair()");
return -1;
}
if (0 > fd_set_blocked(sp[0], 0) || 0 > fd_set_blocked(sp[1], 0)) {
- zlog(ZLOG_SYSERROR, "fd_set_blocked() failed");
+ zlog(ZLOG_SYSERROR, "failed to init signals: fd_set_blocked()");
return -1;
}
if (0 > fcntl(sp[0], F_SETFD, FD_CLOEXEC) || 0 > fcntl(sp[1], F_SETFD, FD_CLOEXEC)) {
- zlog(ZLOG_SYSERROR, "fcntl(F_SETFD, FD_CLOEXEC) failed");
+ zlog(ZLOG_SYSERROR, "falied to init signals: fcntl(F_SETFD, FD_CLOEXEC)");
return -1;
}
0 > sigaction(SIGCHLD, &act, 0) ||
0 > sigaction(SIGQUIT, &act, 0)) {
- zlog(ZLOG_SYSERROR, "sigaction() failed");
+ zlog(ZLOG_SYSERROR, "failed to init signals: sigaction()");
return -1;
}
return 0;
0 > sigaction(SIGCHLD, &act_dfl, 0) ||
0 > sigaction(SIGQUIT, &act, 0)) {
- zlog(ZLOG_SYSERROR, "sigaction() failed");
+ zlog(ZLOG_SYSERROR, "failed to init child signals: sigaction()");
return -1;
}
return 0;
sock = socket(sa->sa_family, SOCK_STREAM, 0);
if (0 > sock) {
- zlog(ZLOG_SYSERROR, "socket() failed");
+ zlog(ZLOG_SYSERROR, "failed to create new listening socket: socket()");
return -1;
}
}
if (0 > bind(sock, sa, socklen)) {
- zlog(ZLOG_SYSERROR, "bind() for address '%s' failed", wp->config->listen_address);
+ zlog(ZLOG_SYSERROR, "unable to bind listening socket for address '%s'", wp->config->listen_address);
if (wp->listen_address_domain == FPM_AF_UNIX) {
umask(saved_umask);
}
if (wp->socket_uid != -1 || wp->socket_gid != -1) {
if (0 > chown(path, wp->socket_uid, wp->socket_gid)) {
- zlog(ZLOG_SYSERROR, "chown() for address '%s' failed", wp->config->listen_address);
+ zlog(ZLOG_SYSERROR, "failed to chown() the socket '%s'", wp->config->listen_address);
return -1;
}
}
}
if (0 > listen(sock, wp->config->listen_backlog)) {
- zlog(ZLOG_SYSERROR, "listen() for address '%s' failed", wp->config->listen_address);
+ zlog(ZLOG_SYSERROR, "failed to listen to address '%s'", wp->config->listen_address);
return -1;
}
socklen_t len = sizeof(info);
if (0 > getsockopt(sock, IPPROTO_TCP, TCP_INFO, &info, &len)) {
- zlog(ZLOG_SYSERROR, "unable to retrieve TCP_INFO for socket");
+ zlog(ZLOG_SYSERROR, "failed to retrieve TCP_INFO for socket");
return -1;
}
#include "fpm_scoreboard.h"
#include "zlog.h"
#include "fpm_atomic.h"
+#include "fpm_conf.h"
#include <ext/standard/html.h>
static char *fpm_status_uri = NULL;
if (wp->config->ping_path) {
if (!wp->config->ping_response) {
- zlog(ZLOG_ERROR, "[pool %s] ping is set (%s) but pong is not set.", wp->config->name, wp->config->ping_path);
+ zlog(ZLOG_ERROR, "[pool %s] ping is set (%s) but ping.response is not set.", wp->config->name, wp->config->ping_path);
return -1;
}
fpm_status_ping_uri = strdup(wp->config->ping_path);
now_epoch = time(NULL);
spprintf(&buffer, 0, short_syntax,
scoreboard.pool,
- scoreboard.pm == PM_STYLE_STATIC ? "static" : "dynamic",
+ PM2STR(scoreboard.pm),
time_buffer,
now_epoch - scoreboard.start_epoch,
scoreboard.requests,
int fd = open("/dev/null", O_RDWR);
if (0 > fd) {
- zlog(ZLOG_SYSERROR, "open(\"/dev/null\") failed");
+ zlog(ZLOG_SYSERROR, "failed to init stdio: open(\"/dev/null\")");
return -1;
}
if (0 > dup2(fd, STDIN_FILENO) || 0 > dup2(fd, STDOUT_FILENO)) {
- zlog(ZLOG_SYSERROR, "dup2() failed");
+ zlog(ZLOG_SYSERROR, "failed to init stdio: dup2()");
return -1;
}
close(fd);
/* there might be messages to stderr from other parts of the code, we need to log them all */
if (0 > dup2(fpm_globals.error_log_fd, STDERR_FILENO)) {
- zlog(ZLOG_SYSERROR, "dup2() failed");
+ zlog(ZLOG_SYSERROR, "failed to init stdio: dup2()");
return -1;
}
}
if (wp->listening_socket != STDIN_FILENO) {
if (0 > dup2(wp->listening_socket, STDIN_FILENO)) {
- zlog(ZLOG_SYSERROR, "dup2() failed");
+ zlog(ZLOG_SYSERROR, "failed to init child stdio: dup2()");
return -1;
}
}
} else { /* error or pipe is closed */
if (res < 0) { /* error */
- zlog(ZLOG_SYSERROR, "read() failed");
+ zlog(ZLOG_SYSERROR, "unable to read what child say");
}
fpm_event_del(event);
}
if (0 > pipe(fd_stdout)) {
- zlog(ZLOG_SYSERROR, "pipe() failed");
+ zlog(ZLOG_SYSERROR, "failed to prepare the stdout pipe");
return -1;
}
if (0 > pipe(fd_stderr)) {
- zlog(ZLOG_SYSERROR, "pipe() failed");
- close(fd_stdout[0]); close(fd_stdout[1]);
+ zlog(ZLOG_SYSERROR, "failed to prepare the stderr pipe");
+ close(fd_stdout[0]);
+ close(fd_stdout[1]);
return -1;
}
if (0 > fd_set_blocked(fd_stdout[0], 0) || 0 > fd_set_blocked(fd_stderr[0], 0)) {
- zlog(ZLOG_SYSERROR, "fd_set_blocked() failed");
- close(fd_stdout[0]); close(fd_stdout[1]);
- close(fd_stderr[0]); close(fd_stderr[1]);
+ zlog(ZLOG_SYSERROR, "failed to unblock pipes");
+ close(fd_stdout[0]);
+ close(fd_stdout[1]);
+ close(fd_stderr[0]);
+ close(fd_stderr[1]);
return -1;
}
return 0;
fd = open(fpm_global_config.error_log, O_WRONLY | O_APPEND | O_CREAT, S_IRUSR | S_IWUSR);
if (0 > fd) {
- zlog(ZLOG_SYSERROR, "open(\"%s\") failed", fpm_global_config.error_log);
+ zlog(ZLOG_SYSERROR, "failed to open error_log (%s)", fpm_global_config.error_log);
return -1;
}
kr = mach_vm_read(target, page, fpm_pagesize, &local_page, &local_size);
if (kr != KERN_SUCCESS) {
- zlog(ZLOG_ERROR, "mach_vm_read() failed: %s (%d)", mach_error_string(kr), kr);
+ zlog(ZLOG_ERROR, "failed to read vm page: mach_vm_read(): %s (%d)", mach_error_string(kr), kr);
return -1;
}
return 0;
int fpm_trace_signal(pid_t pid) /* {{{ */
{
if (0 > fpm_pctl_kill(pid, FPM_PCTL_STOP)) {
- zlog(ZLOG_SYSERROR, "kill(SIGSTOP) failed");
+ zlog(ZLOG_SYSERROR, "failed to send SIGSTOP to %d", pid);
return -1;
}
return 0;
int fpm_trace_signal(pid_t pid) /* {{{ */
{
if (0 > fpm_pctl_kill(pid, FPM_PCTL_STOP)) {
- zlog(ZLOG_SYSERROR, "kill(SIGSTOP) failed");
+ zlog(ZLOG_SYSERROR, "failed to send SIGSTOP to %d", pid);
return -1;
}
return 0;
sprintf(buf, "/proc/%d/" PROC_MEM_FILE, (int) pid);
mem_file = open(buf, O_RDONLY);
if (0 > mem_file) {
- zlog(ZLOG_SYSERROR, "open(%s) failed", buf);
+ zlog(ZLOG_SYSERROR, "failed to open %s", buf);
return -1;
}
return 0;
int fpm_trace_signal(pid_t pid) /* {{{ */
{
if (0 > ptrace(PTRACE_ATTACH, pid, 0, 0)) {
- zlog(ZLOG_SYSERROR, "ptrace(ATTACH) failed");
+ zlog(ZLOG_SYSERROR, "failed to ptrace(ATTACH) child %d", pid);
return -1;
}
return 0;
int fpm_trace_close(pid_t pid) /* {{{ */
{
if (0 > ptrace(PTRACE_DETACH, pid, (void *) 1, 0)) {
- zlog(ZLOG_SYSERROR, "ptrace(DETACH) failed");
+ zlog(ZLOG_SYSERROR, "failed to ptrace(DETACH) child %d", pid);
return -1;
}
traced_pid = 0;
};
if (0 > ptrace(PT_IO, traced_pid, (void *) &ptio, 0)) {
- zlog(ZLOG_SYSERROR, "ptrace(PT_IO) failed");
+ zlog(ZLOG_SYSERROR, "failed to ptrace(PT_IO) pid %d", traced_pid);
return -1;
}
#else
errno = 0;
*data = ptrace(PTRACE_PEEKDATA, traced_pid, (void *) addr, 0);
if (errno) {
- zlog(ZLOG_SYSERROR, "ptrace(PEEKDATA) failed");
+ zlog(ZLOG_SYSERROR, "failed to ptrace(PEEKDATA) pid %d", traced_pid);
return -1;
}
#endif
static int fpm_unix_conf_wp(struct fpm_worker_pool_s *wp) /* {{{ */
{
+ struct passwd *pwd;
int is_root = !geteuid();
if (is_root) {
#endif
} else { /* not root */
if (wp->config->user && *wp->config->user) {
- zlog(ZLOG_WARNING, "[pool %s] 'user' directive is ignored", wp->config->name);
+ zlog(ZLOG_WARNING, "[pool %s] 'user' directive is ignored when FPM is not running as root", wp->config->name);
}
if (wp->config->group && *wp->config->group) {
- zlog(ZLOG_WARNING, "[pool %s] 'group' directive is ignored", wp->config->name);
+ zlog(ZLOG_WARNING, "[pool %s] 'group' directive is ignored when FPM is not running as root", wp->config->name);
}
if (wp->config->chroot && *wp->config->chroot) {
- zlog(ZLOG_WARNING, "[pool %s] 'chroot' directive is ignored", wp->config->name);
+ zlog(ZLOG_WARNING, "[pool %s] 'chroot' directive is ignored when FPM is not running as root", wp->config->name);
}
- { /* set up HOME and USER anyway */
- struct passwd *pwd;
-
- pwd = getpwuid(getuid());
- if (pwd) {
- wp->user = strdup(pwd->pw_name);
- wp->home = strdup(pwd->pw_dir);
- }
+ /* set up HOME and USER anyway */
+ pwd = getpwuid(getuid());
+ if (pwd) {
+ wp->user = strdup(pwd->pw_name);
+ wp->home = strdup(pwd->pw_dir);
}
}
return 0;
r.rlim_max = r.rlim_cur = (rlim_t) wp->config->rlimit_files;
if (0 > setrlimit(RLIMIT_NOFILE, &r)) {
- zlog(ZLOG_SYSERROR, "[pool %s] unable to set rlimit_files for this pool. Please check your system limits or decrease rlimit_files. setrlimit(RLIMIT_NOFILE, %d) failed (%d)", wp->config->name, wp->config->rlimit_files, errno);
+ zlog(ZLOG_SYSERROR, "[pool %s] failed to set rlimit_files for this pool. Please check your system limits or decrease rlimit_files. setrlimit(RLIMIT_NOFILE, %d)", wp->config->name, wp->config->rlimit_files);
}
}
r.rlim_max = r.rlim_cur = wp->config->rlimit_core == -1 ? (rlim_t) RLIM_INFINITY : (rlim_t) wp->config->rlimit_core;
if (0 > setrlimit(RLIMIT_CORE, &r)) {
- zlog(ZLOG_SYSERROR, "[pool %s] unable to set rlimit_core for this pool. Please check your system limits or decrease rlimit_core. setrlimit(RLIMIT_CORE, %d) failed (%d)", wp->config->name, wp->config->rlimit_core, errno);
+ zlog(ZLOG_SYSERROR, "[pool %s] failed to set rlimit_core for this pool. Please check your system limits or decrease rlimit_core. setrlimit(RLIMIT_CORE, %d)", wp->config->name, wp->config->rlimit_core);
}
}
if (is_root && wp->config->chroot && *wp->config->chroot) {
if (0 > chroot(wp->config->chroot)) {
- zlog(ZLOG_SYSERROR, "[pool %s] chroot(%s) failed", wp->config->name, wp->config->chroot);
+ zlog(ZLOG_SYSERROR, "[pool %s] failed to chroot(%s)", wp->config->name, wp->config->chroot);
return -1;
}
made_chroot = 1;
if (wp->config->chdir && *wp->config->chdir) {
if (0 > chdir(wp->config->chdir)) {
- zlog(ZLOG_SYSERROR, "[pool %s] chdir(%s) failed", wp->config->name, wp->config->chdir);
+ zlog(ZLOG_SYSERROR, "[pool %s] failed to chdir(%s)", wp->config->name, wp->config->chdir);
return -1;
}
} else if (made_chroot) {
if (is_root) {
if (wp->set_gid) {
if (0 > setgid(wp->set_gid)) {
- zlog(ZLOG_SYSERROR, "[pool %s] setgid(%d) failed", wp->config->name, wp->set_gid);
+ zlog(ZLOG_SYSERROR, "[pool %s] failed to setgid(%d)", wp->config->name, wp->set_gid);
return -1;
}
}
if (wp->set_uid) {
if (0 > initgroups(wp->config->user, wp->set_gid)) {
- zlog(ZLOG_SYSERROR, "[pool %s] initgroups(%s, %d) failed", wp->config->name, wp->config->user, wp->set_gid);
+ zlog(ZLOG_SYSERROR, "[pool %s] failed to initgroups(%s, %d)", wp->config->name, wp->config->user, wp->set_gid);
return -1;
}
if (0 > setuid(wp->set_uid)) {
- zlog(ZLOG_SYSERROR, "[pool %s] setuid(%d) failed", wp->config->name, wp->set_uid);
+ zlog(ZLOG_SYSERROR, "[pool %s] failed to setuid(%d)", wp->config->name, wp->set_uid);
return -1;
}
}
#ifdef HAVE_PRCTL
if (0 > prctl(PR_SET_DUMPABLE, 1, 0, 0, 0)) {
- zlog(ZLOG_SYSERROR, "[pool %s] prctl(PR_SET_DUMPABLE) failed", wp->config->name);
+ zlog(ZLOG_SYSERROR, "[pool %s] failed to prctl(PR_SET_DUMPABLE)", wp->config->name);
}
#endif
r.rlim_max = r.rlim_cur = (rlim_t) fpm_global_config.rlimit_files;
if (0 > setrlimit(RLIMIT_NOFILE, &r)) {
- zlog(ZLOG_SYSERROR, "unable to set rlimit_core for this pool. Please check your system limits or decrease rlimit_files. setrlimit(RLIMIT_NOFILE, %d) failed (%d)", fpm_global_config.rlimit_files, errno);
+ zlog(ZLOG_SYSERROR, "failed to set rlimit_core for this pool. Please check your system limits or decrease rlimit_files. setrlimit(RLIMIT_NOFILE, %d)", fpm_global_config.rlimit_files);
return -1;
}
}
r.rlim_max = r.rlim_cur = fpm_global_config.rlimit_core == -1 ? (rlim_t) RLIM_INFINITY : (rlim_t) fpm_global_config.rlimit_core;
if (0 > setrlimit(RLIMIT_CORE, &r)) {
- zlog(ZLOG_SYSERROR, "unable to set rlimit_core for this pool. Please check your system limits or decrease rlimit_core. setrlimit(RLIMIT_CORE, %d) failed (%d)", fpm_global_config.rlimit_core, errno);
+ zlog(ZLOG_SYSERROR, "failed to set rlimit_core for this pool. Please check your system limits or decrease rlimit_core. setrlimit(RLIMIT_CORE, %d)", fpm_global_config.rlimit_core);
return -1;
}
}
if (fpm_global_config.daemonize) {
switch (fork()) {
case -1 :
- zlog(ZLOG_SYSERROR, "daemonized fork() failed");
+ zlog(ZLOG_SYSERROR, "failed to daemonize");
return -1;
case 0 :
break;
#include "fpm_shm.h"
#include "fpm_scoreboard.h"
#include "fpm_conf.h"
-#include "zlog.h"
struct fpm_worker_pool_s *fpm_worker_all_pools;