com php-src: Move chown to fpm_unix_set_socket_premissi ons(): sapi/fpm/fpm/fpm_sockets.c sapi/fpm/fpm/fp m_unix.c sapi/fpm/fpm/fpm_unix.h

From: Date: Sat, 29 Nov 2014 15:49:08 +0000
Subject: com php-src: Move chown to fpm_unix_set_socket_premissi ons(): sapi/fpm/fpm/fpm_sockets.c sapi/fpm/fpm/fp m_unix.c sapi/fpm/fpm/fpm_unix.h
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-83393@lists.php.net to get a copy of this message
Commit: e1d4ac426c817377cbe01287b6ada824146d26c9 Author: Remi Collet <remi@php.net> Sat, 29 Nov 2014 16:49:08 +0100 Parents: 57d7b4fc567aa43a4fb9fb021effa73a92d47461 Branches: PHP-5.6 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=e1d4ac426c817377cbe01287b6ada824146d26c9 Log: 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. Changed paths: M sapi/fpm/fpm/fpm_sockets.c M sapi/fpm/fpm/fpm_unix.c M sapi/fpm/fpm/fpm_unix.h Diff: diff --git a/sapi/fpm/fpm/fpm_sockets.c b/sapi/fpm/fpm/fpm_sockets.c index 0286f0e..065f63e 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 32448fc..57707d8 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 3451db1..b2995ff 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();

« previous php.cvs (#83393) next »