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.
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;
}
}
}
/* }}} */
+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;
return -1;
}
} else if (made_chroot) {
- chdir("/");
+ if (0 > chdir("/")) {
+ zlog(ZLOG_WARNING, "[pool %s] failed to chdir(/)", wp->config->name);
+ }
}
if (is_root) {
#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();