]> granicus.if.org Git - php/commitdiff
Move chown to fpm_unix_set_socket_premissions()
authorRemi Collet <remi@php.net>
Sat, 29 Nov 2014 15:49:08 +0000 (16:49 +0100)
committerRemi Collet <remi@php.net>
Sat, 29 Nov 2014 15:49:08 +0000 (16:49 +0100)
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.

sapi/fpm/fpm/fpm_sockets.c
sapi/fpm/fpm/fpm_unix.c
sapi/fpm/fpm/fpm_unix.h

index 0286f0eee8d1b47b3cafac1fbc80e2fa624f0a6b..065f63e76219ff2bc6febe3ee6d86820e12e7fce 100644 (file)
@@ -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;
                }
        }
 
index 32448fc4d5dffa650aad506c6f4326e49708eb55..57707d8f8a2ff97653ec50f60574f0eccb4000f4 100644 (file)
@@ -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) {
index 3451db126b70acb7d83eee472e56d35fc79913ca..b2995ff3e0ab0dddf8b827a4046c9d55c6a27166 100644 (file)
@@ -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();