Lines Matching refs:wp

31 int fpm_unix_resolve_socket_premissions(struct fpm_worker_pool_s *wp) /* {{{ */  in fpm_unix_resolve_socket_premissions()  argument
33 struct fpm_worker_pool_config_s *c = wp->config; in fpm_unix_resolve_socket_premissions()
36 wp->socket_uid = -1; in fpm_unix_resolve_socket_premissions()
37 wp->socket_gid = -1; in fpm_unix_resolve_socket_premissions()
38 wp->socket_mode = 0660; in fpm_unix_resolve_socket_premissions()
49 zlog(ZLOG_SYSERROR, "[pool %s] cannot get uid for user '%s'", wp->config->name, c->listen_owner); in fpm_unix_resolve_socket_premissions()
53 wp->socket_uid = pwd->pw_uid; in fpm_unix_resolve_socket_premissions()
54 wp->socket_gid = pwd->pw_gid; in fpm_unix_resolve_socket_premissions()
62 … zlog(ZLOG_SYSERROR, "[pool %s] cannot get gid for group '%s'", wp->config->name, c->listen_group); in fpm_unix_resolve_socket_premissions()
65 wp->socket_gid = grp->gr_gid; in fpm_unix_resolve_socket_premissions()
69 wp->socket_mode = strtoul(c->listen_mode, 0, 8); in fpm_unix_resolve_socket_premissions()
75 static int fpm_unix_conf_wp(struct fpm_worker_pool_s *wp) /* {{{ */ in fpm_unix_conf_wp() argument
81 if (wp->config->user && *wp->config->user) { in fpm_unix_conf_wp()
82 if (strlen(wp->config->user) == strspn(wp->config->user, "0123456789")) { in fpm_unix_conf_wp()
83 wp->set_uid = strtoul(wp->config->user, 0, 10); in fpm_unix_conf_wp()
87 pwd = getpwnam(wp->config->user); in fpm_unix_conf_wp()
89 zlog(ZLOG_ERROR, "[pool %s] cannot get uid for user '%s'", wp->config->name, wp->config->user); in fpm_unix_conf_wp()
93 wp->set_uid = pwd->pw_uid; in fpm_unix_conf_wp()
94 wp->set_gid = pwd->pw_gid; in fpm_unix_conf_wp()
96 wp->user = strdup(pwd->pw_name); in fpm_unix_conf_wp()
97 wp->home = strdup(pwd->pw_dir); in fpm_unix_conf_wp()
101 if (wp->config->group && *wp->config->group) { in fpm_unix_conf_wp()
102 if (strlen(wp->config->group) == strspn(wp->config->group, "0123456789")) { in fpm_unix_conf_wp()
103 wp->set_gid = strtoul(wp->config->group, 0, 10); in fpm_unix_conf_wp()
107 grp = getgrnam(wp->config->group); in fpm_unix_conf_wp()
109 … zlog(ZLOG_ERROR, "[pool %s] cannot get gid for group '%s'", wp->config->name, wp->config->group); in fpm_unix_conf_wp()
112 wp->set_gid = grp->gr_gid; in fpm_unix_conf_wp()
117 if (wp->set_uid == 0 || wp->set_gid == 0) { in fpm_unix_conf_wp()
118 zlog(ZLOG_ERROR, "[pool %s] please specify user and group other than root", wp->config->name); in fpm_unix_conf_wp()
123 if (wp->config->user && *wp->config->user) { in fpm_unix_conf_wp()
124 …zlog(ZLOG_NOTICE, "[pool %s] 'user' directive is ignored when FPM is not running as root", wp->con… in fpm_unix_conf_wp()
126 if (wp->config->group && *wp->config->group) { in fpm_unix_conf_wp()
127 …zlog(ZLOG_NOTICE, "[pool %s] 'group' directive is ignored when FPM is not running as root", wp->co… in fpm_unix_conf_wp()
129 if (wp->config->chroot && *wp->config->chroot) { in fpm_unix_conf_wp()
130 …zlog(ZLOG_NOTICE, "[pool %s] 'chroot' directive is ignored when FPM is not running as root", wp->c… in fpm_unix_conf_wp()
132 if (wp->config->process_priority != 64) { in fpm_unix_conf_wp()
133 …ol %s] 'process.priority' directive is ignored when FPM is not running as root", wp->config->name); in fpm_unix_conf_wp()
139 wp->user = strdup(pwd->pw_name); in fpm_unix_conf_wp()
140 wp->home = strdup(pwd->pw_dir); in fpm_unix_conf_wp()
147 int fpm_unix_init_child(struct fpm_worker_pool_s *wp) /* {{{ */ in fpm_unix_init_child() argument
152 if (wp->config->rlimit_files) { in fpm_unix_init_child()
155 r.rlim_max = r.rlim_cur = (rlim_t) wp->config->rlimit_files; in fpm_unix_init_child()
158 …m limits or decrease rlimit_files. setrlimit(RLIMIT_NOFILE, %d)", wp->config->name, wp->config->rl… in fpm_unix_init_child()
162 if (wp->config->rlimit_core) { in fpm_unix_init_child()
165 …r.rlim_max = r.rlim_cur = wp->config->rlimit_core == -1 ? (rlim_t) RLIM_INFINITY : (rlim_t) wp->co… in fpm_unix_init_child()
168 …stem limits or decrease rlimit_core. setrlimit(RLIMIT_CORE, %d)", wp->config->name, wp->config->rl… in fpm_unix_init_child()
172 if (is_root && wp->config->chroot && *wp->config->chroot) { in fpm_unix_init_child()
173 if (0 > chroot(wp->config->chroot)) { in fpm_unix_init_child()
174 zlog(ZLOG_SYSERROR, "[pool %s] failed to chroot(%s)", wp->config->name, wp->config->chroot); in fpm_unix_init_child()
180 if (wp->config->chdir && *wp->config->chdir) { in fpm_unix_init_child()
181 if (0 > chdir(wp->config->chdir)) { in fpm_unix_init_child()
182 zlog(ZLOG_SYSERROR, "[pool %s] failed to chdir(%s)", wp->config->name, wp->config->chdir); in fpm_unix_init_child()
191 if (wp->config->process_priority != 64) { in fpm_unix_init_child()
192 if (setpriority(PRIO_PROCESS, 0, wp->config->process_priority) < 0) { in fpm_unix_init_child()
193 zlog(ZLOG_SYSERROR, "[pool %s] Unable to set priority for this new process", wp->config->name); in fpm_unix_init_child()
198 if (wp->set_gid) { in fpm_unix_init_child()
199 if (0 > setgid(wp->set_gid)) { in fpm_unix_init_child()
200 zlog(ZLOG_SYSERROR, "[pool %s] failed to setgid(%d)", wp->config->name, wp->set_gid); in fpm_unix_init_child()
204 if (wp->set_uid) { in fpm_unix_init_child()
205 if (0 > initgroups(wp->config->user, wp->set_gid)) { in fpm_unix_init_child()
206 …ZLOG_SYSERROR, "[pool %s] failed to initgroups(%s, %d)", wp->config->name, wp->config->user, wp->s… in fpm_unix_init_child()
209 if (0 > setuid(wp->set_uid)) { in fpm_unix_init_child()
210 zlog(ZLOG_SYSERROR, "[pool %s] failed to setuid(%d)", wp->config->name, wp->set_uid); in fpm_unix_init_child()
218 zlog(ZLOG_SYSERROR, "[pool %s] failed to prctl(PR_SET_DUMPABLE)", wp->config->name); in fpm_unix_init_child()
231 struct fpm_worker_pool_s *wp; in fpm_unix_init_main() local
358 for (wp = fpm_worker_all_pools; wp; wp = wp->next) { in fpm_unix_init_main()
359 if (0 > fpm_unix_conf_wp(wp)) { in fpm_unix_init_main()