summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRemi Collet <remi@php.net>2014-11-29 16:49:08 +0100
committerRemi Collet <remi@php.net>2014-11-29 16:49:08 +0100
commite1d4ac426c817377cbe01287b6ada824146d26c9 (patch)
treefc04b281c8a9aedb7f3cd487daf80bae23716b22
parent57d7b4fc567aa43a4fb9fb021effa73a92d47461 (diff)
downloadphp-git-e1d4ac426c817377cbe01287b6ada824146d26c9.tar.gz
Move chown to fpm_unix_set_socket_premissions()
For consistency, with fpm_unix_resolve_socket_premissions. Compute + Use in the same source file. To make easier future enhancement. Also check chdir output to fix a build warning.
-rw-r--r--sapi/fpm/fpm/fpm_sockets.c9
-rw-r--r--sapi/fpm/fpm/fpm_unix.c16
-rw-r--r--sapi/fpm/fpm/fpm_unix.h1
3 files changed, 19 insertions, 7 deletions
diff --git a/sapi/fpm/fpm/fpm_sockets.c b/sapi/fpm/fpm/fpm_sockets.c
index 0286f0eee8..065f63e762 100644
--- a/sapi/fpm/fpm/fpm_sockets.c
+++ b/sapi/fpm/fpm/fpm_sockets.c
@@ -201,12 +201,9 @@ static int fpm_sockets_new_listening_socket(struct fpm_worker_pool_s *wp, struct
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, "failed to chown() the socket '%s'", wp->config->listen_address);
- close(sock);
- return -1;
- }
+ if (0 > fpm_unix_set_socket_premissions(wp, path)) {
+ close(sock);
+ return -1;
}
}
diff --git a/sapi/fpm/fpm/fpm_unix.c b/sapi/fpm/fpm/fpm_unix.c
index 32448fc4d5..57707d8f8a 100644
--- a/sapi/fpm/fpm/fpm_unix.c
+++ b/sapi/fpm/fpm/fpm_unix.c
@@ -76,6 +76,18 @@ int fpm_unix_resolve_socket_premissions(struct fpm_worker_pool_s *wp) /* {{{ */
}
/* }}} */
+int fpm_unix_set_socket_premissions(struct fpm_worker_pool_s *wp, const char *path) /* {{{ */
+{
+ if (wp->socket_uid != -1 || wp->socket_gid != -1) {
+ if (0 > chown(path, wp->socket_uid, wp->socket_gid)) {
+ zlog(ZLOG_SYSERROR, "failed to chown() the socket '%s'", wp->config->listen_address);
+ return -1;
+ }
+ }
+ return 0;
+}
+/* }}} */
+
static int fpm_unix_conf_wp(struct fpm_worker_pool_s *wp) /* {{{ */
{
struct passwd *pwd;
@@ -187,7 +199,9 @@ int fpm_unix_init_child(struct fpm_worker_pool_s *wp) /* {{{ */
return -1;
}
} else if (made_chroot) {
- chdir("/");
+ if (0 > chdir("/")) {
+ zlog(ZLOG_WARNING, "[pool %s] failed to chdir(/)", wp->config->name);
+ }
}
if (is_root) {
diff --git a/sapi/fpm/fpm/fpm_unix.h b/sapi/fpm/fpm/fpm_unix.h
index 3451db126b..b2995ff3e0 100644
--- a/sapi/fpm/fpm/fpm_unix.h
+++ b/sapi/fpm/fpm/fpm_unix.h
@@ -8,6 +8,7 @@
#include "fpm_worker_pool.h"
int fpm_unix_resolve_socket_premissions(struct fpm_worker_pool_s *wp);
+int fpm_unix_set_socket_premissions(struct fpm_worker_pool_s *wp, const char *path);
int fpm_unix_init_child(struct fpm_worker_pool_s *wp);
int fpm_unix_init_main();