Lines Matching refs:attr

42 APR_DECLARE(apr_status_t) apr_procattr_io_set(apr_procattr_t *attr,  in apr_procattr_io_set()  argument
60 if ((rv = apr_file_pipe_create_ex(&attr->child_in, &attr->parent_in, in apr_procattr_io_set()
61 in, attr->pool)) == APR_SUCCESS) in apr_procattr_io_set()
62 rv = apr_file_inherit_unset(attr->parent_in); in apr_procattr_io_set()
67 attr->child_in = &no_file; in apr_procattr_io_set()
70 if ((rv = apr_file_pipe_create_ex(&attr->parent_out, &attr->child_out, in apr_procattr_io_set()
71 out, attr->pool)) == APR_SUCCESS) in apr_procattr_io_set()
72 rv = apr_file_inherit_unset(attr->parent_out); in apr_procattr_io_set()
77 attr->child_out = &no_file; in apr_procattr_io_set()
80 if ((rv = apr_file_pipe_create_ex(&attr->parent_err, &attr->child_err, in apr_procattr_io_set()
81 err, attr->pool)) == APR_SUCCESS) in apr_procattr_io_set()
82 rv = apr_file_inherit_unset(attr->parent_err); in apr_procattr_io_set()
87 attr->child_err = &no_file; in apr_procattr_io_set()
93 APR_DECLARE(apr_status_t) apr_procattr_child_in_set(apr_procattr_t *attr, in apr_procattr_child_in_set() argument
99 if (attr->child_in == NULL && attr->parent_in == NULL in apr_procattr_child_in_set()
101 if ((rv = apr_file_pipe_create(&attr->child_in, &attr->parent_in, in apr_procattr_child_in_set()
102 attr->pool)) == APR_SUCCESS) in apr_procattr_child_in_set()
103 rv = apr_file_inherit_unset(attr->parent_in); in apr_procattr_child_in_set()
106 if (attr->child_in && (attr->child_in->filedes != -1)) in apr_procattr_child_in_set()
107 rv = apr_file_dup2(attr->child_in, child_in, attr->pool); in apr_procattr_child_in_set()
109 attr->child_in = NULL; in apr_procattr_child_in_set()
110 if ((rv = apr_file_dup(&attr->child_in, child_in, attr->pool)) in apr_procattr_child_in_set()
112 rv = apr_file_inherit_set(attr->child_in); in apr_procattr_child_in_set()
117 if (attr->parent_in) in apr_procattr_child_in_set()
118 rv = apr_file_dup2(attr->parent_in, parent_in, attr->pool); in apr_procattr_child_in_set()
120 rv = apr_file_dup(&attr->parent_in, parent_in, attr->pool); in apr_procattr_child_in_set()
127 APR_DECLARE(apr_status_t) apr_procattr_child_out_set(apr_procattr_t *attr, in apr_procattr_child_out_set() argument
133 if (attr->child_out == NULL && attr->parent_out == NULL in apr_procattr_child_out_set()
135 if ((rv = apr_file_pipe_create(&attr->parent_out, &attr->child_out, in apr_procattr_child_out_set()
136 attr->pool)) == APR_SUCCESS) in apr_procattr_child_out_set()
137 rv = apr_file_inherit_unset(attr->parent_out); in apr_procattr_child_out_set()
140 if (attr->child_out && (attr->child_out->filedes != -1)) in apr_procattr_child_out_set()
141 rv = apr_file_dup2(attr->child_out, child_out, attr->pool); in apr_procattr_child_out_set()
143 attr->child_out = NULL; in apr_procattr_child_out_set()
144 if ((rv = apr_file_dup(&attr->child_out, child_out, attr->pool)) in apr_procattr_child_out_set()
146 rv = apr_file_inherit_set(attr->child_out); in apr_procattr_child_out_set()
151 if (attr->parent_out) in apr_procattr_child_out_set()
152 rv = apr_file_dup2(attr->parent_out, parent_out, attr->pool); in apr_procattr_child_out_set()
154 rv = apr_file_dup(&attr->parent_out, parent_out, attr->pool); in apr_procattr_child_out_set()
161 APR_DECLARE(apr_status_t) apr_procattr_child_err_set(apr_procattr_t *attr, in apr_procattr_child_err_set() argument
167 if (attr->child_err == NULL && attr->parent_err == NULL in apr_procattr_child_err_set()
169 if ((rv = apr_file_pipe_create(&attr->parent_err, &attr->child_err, in apr_procattr_child_err_set()
170 attr->pool)) == APR_SUCCESS) in apr_procattr_child_err_set()
171 rv = apr_file_inherit_unset(attr->parent_err); in apr_procattr_child_err_set()
174 if (attr->child_err && (attr->child_err->filedes != -1)) in apr_procattr_child_err_set()
175 rv = apr_file_dup2(attr->child_err, child_err, attr->pool); in apr_procattr_child_err_set()
177 attr->child_err = NULL; in apr_procattr_child_err_set()
178 if ((rv = apr_file_dup(&attr->child_err, child_err, attr->pool)) in apr_procattr_child_err_set()
180 rv = apr_file_inherit_set(attr->child_err); in apr_procattr_child_err_set()
184 if (attr->parent_err) in apr_procattr_child_err_set()
185 rv = apr_file_dup2(attr->parent_err, parent_err, attr->pool); in apr_procattr_child_err_set()
187 rv = apr_file_dup(&attr->parent_err, parent_err, attr->pool); in apr_procattr_child_err_set()
194 APR_DECLARE(apr_status_t) apr_procattr_dir_set(apr_procattr_t *attr, in apr_procattr_dir_set() argument
197 attr->currdir = apr_pstrdup(attr->pool, dir); in apr_procattr_dir_set()
198 if (attr->currdir) { in apr_procattr_dir_set()
205 APR_DECLARE(apr_status_t) apr_procattr_cmdtype_set(apr_procattr_t *attr, in apr_procattr_cmdtype_set() argument
208 attr->cmdtype = cmd; in apr_procattr_cmdtype_set()
212 APR_DECLARE(apr_status_t) apr_procattr_detach_set(apr_procattr_t *attr, in apr_procattr_detach_set() argument
215 attr->detached = detach; in apr_procattr_detach_set()
241 static apr_status_t limit_proc(apr_procattr_t *attr) in limit_proc() argument
245 if (attr->limit_cpu != NULL) { in limit_proc()
246 if ((setrlimit(RLIMIT_CPU, attr->limit_cpu)) != 0) { in limit_proc()
252 if (attr->limit_nproc != NULL) { in limit_proc()
253 if ((setrlimit(RLIMIT_NPROC, attr->limit_nproc)) != 0) { in limit_proc()
259 if (attr->limit_nofile != NULL) { in limit_proc()
260 if ((setrlimit(RLIMIT_NOFILE, attr->limit_nofile)) != 0) { in limit_proc()
266 if (attr->limit_mem != NULL) { in limit_proc()
267 if ((setrlimit(RLIMIT_AS, attr->limit_mem)) != 0) { in limit_proc()
272 if (attr->limit_mem != NULL) { in limit_proc()
273 if ((setrlimit(RLIMIT_DATA, attr->limit_mem)) != 0) { in limit_proc()
278 if (attr->limit_mem != NULL) { in limit_proc()
279 if ((setrlimit(RLIMIT_VMEM, attr->limit_mem)) != 0) { in limit_proc()
293 APR_DECLARE(apr_status_t) apr_procattr_child_errfn_set(apr_procattr_t *attr, in apr_procattr_child_errfn_set() argument
296 attr->errfn = errfn; in apr_procattr_child_errfn_set()
300 APR_DECLARE(apr_status_t) apr_procattr_error_check_set(apr_procattr_t *attr, in apr_procattr_error_check_set() argument
303 attr->errchk = chk; in apr_procattr_error_check_set()
307 APR_DECLARE(apr_status_t) apr_procattr_addrspace_set(apr_procattr_t *attr, in apr_procattr_addrspace_set() argument
314 APR_DECLARE(apr_status_t) apr_procattr_user_set(apr_procattr_t *attr, in apr_procattr_user_set() argument
321 if ((rv = apr_uid_get(&attr->uid, &gid, username, in apr_procattr_user_set()
322 attr->pool)) != APR_SUCCESS) { in apr_procattr_user_set()
323 attr->uid = -1; in apr_procattr_user_set()
328 if (attr->gid == -1) { in apr_procattr_user_set()
329 attr->gid = gid; in apr_procattr_user_set()
334 APR_DECLARE(apr_status_t) apr_procattr_group_set(apr_procattr_t *attr, in apr_procattr_group_set() argument
339 if ((rv = apr_gid_get(&attr->gid, groupname, attr->pool)) != APR_SUCCESS) in apr_procattr_group_set()
340 attr->gid = -1; in apr_procattr_group_set()
348 apr_procattr_t *attr, in apr_proc_create() argument
361 new->in = attr->parent_in; in apr_proc_create()
362 new->err = attr->parent_err; in apr_proc_create()
363 new->out = attr->parent_out; in apr_proc_create()
365 if (attr->errchk) { in apr_proc_create()
366 if (attr->currdir) { in apr_proc_create()
367 if (access(attr->currdir, X_OK) == -1) { in apr_proc_create()
373 if (attr->cmdtype == APR_PROGRAM || in apr_proc_create()
374 attr->cmdtype == APR_PROGRAM_ENV || in apr_proc_create()
410 if (attr->child_in) { in apr_proc_create()
411 apr_pool_cleanup_kill(apr_file_pool_get(attr->child_in), in apr_proc_create()
412 attr->child_in, apr_unix_file_cleanup); in apr_proc_create()
415 if (attr->child_out) { in apr_proc_create()
416 apr_pool_cleanup_kill(apr_file_pool_get(attr->child_out), in apr_proc_create()
417 attr->child_out, apr_unix_file_cleanup); in apr_proc_create()
420 if (attr->child_err) { in apr_proc_create()
421 apr_pool_cleanup_kill(apr_file_pool_get(attr->child_err), in apr_proc_create()
422 attr->child_err, apr_unix_file_cleanup); in apr_proc_create()
427 if ((attr->child_in) && (attr->child_in->filedes == -1)) { in apr_proc_create()
430 else if (attr->child_in && in apr_proc_create()
431 attr->child_in->filedes != STDIN_FILENO) { in apr_proc_create()
432 dup2(attr->child_in->filedes, STDIN_FILENO); in apr_proc_create()
433 apr_file_close(attr->child_in); in apr_proc_create()
436 if ((attr->child_out) && (attr->child_out->filedes == -1)) { in apr_proc_create()
439 else if (attr->child_out && in apr_proc_create()
440 attr->child_out->filedes != STDOUT_FILENO) { in apr_proc_create()
441 dup2(attr->child_out->filedes, STDOUT_FILENO); in apr_proc_create()
442 apr_file_close(attr->child_out); in apr_proc_create()
445 if ((attr->child_err) && (attr->child_err->filedes == -1)) { in apr_proc_create()
448 else if (attr->child_err && in apr_proc_create()
449 attr->child_err->filedes != STDERR_FILENO) { in apr_proc_create()
450 dup2(attr->child_err->filedes, STDERR_FILENO); in apr_proc_create()
451 apr_file_close(attr->child_err); in apr_proc_create()
456 if (attr->currdir != NULL) { in apr_proc_create()
457 if (chdir(attr->currdir) == -1) { in apr_proc_create()
458 if (attr->errfn) { in apr_proc_create()
459 attr->errfn(pool, errno, "change of working directory failed"); in apr_proc_create()
465 apr_procattr_pscb_t *c = attr->perms_set_callbacks; in apr_proc_create()
470 attr->uid, attr->gid); in apr_proc_create()
478 if (attr->gid != -1 && !geteuid()) { in apr_proc_create()
479 if (setgid(attr->gid)) { in apr_proc_create()
480 if (attr->errfn) { in apr_proc_create()
481 attr->errfn(pool, errno, "setting of group failed"); in apr_proc_create()
487 if (attr->uid != -1 && !geteuid()) { in apr_proc_create()
488 if (setuid(attr->uid)) { in apr_proc_create()
489 if (attr->errfn) { in apr_proc_create()
490 attr->errfn(pool, errno, "setting of user failed"); in apr_proc_create()
496 if (limit_proc(attr) != APR_SUCCESS) { in apr_proc_create()
497 if (attr->errfn) { in apr_proc_create()
498 attr->errfn(pool, errno, "setting of resource limits failed"); in apr_proc_create()
503 if (attr->cmdtype == APR_SHELLCMD || in apr_proc_create()
504 attr->cmdtype == APR_SHELLCMD_ENV) { in apr_proc_create()
551 if (attr->detached) { in apr_proc_create()
555 if (attr->cmdtype == APR_SHELLCMD) { in apr_proc_create()
562 else if (attr->cmdtype == APR_PROGRAM) { in apr_proc_create()
563 if (attr->detached) { in apr_proc_create()
569 else if (attr->cmdtype == APR_PROGRAM_ENV) { in apr_proc_create()
570 if (attr->detached) { in apr_proc_create()
578 if (attr->detached) { in apr_proc_create()
584 if (attr->errfn) { in apr_proc_create()
589 attr->errfn(pool, errno, desc); in apr_proc_create()
597 if (attr->child_in && (attr->child_in->filedes != -1)) { in apr_proc_create()
598 apr_file_close(attr->child_in); in apr_proc_create()
601 if (attr->child_out && (attr->child_out->filedes != -1)) { in apr_proc_create()
602 apr_file_close(attr->child_out); in apr_proc_create()
605 if (attr->child_err && (attr->child_err->filedes != -1)) { in apr_proc_create()
606 apr_file_close(attr->child_err); in apr_proc_create()
681 APR_DECLARE(apr_status_t) apr_procattr_limit_set(apr_procattr_t *attr, in apr_procattr_limit_set() argument
688 attr->limit_cpu = limit; in apr_procattr_limit_set()
696 attr->limit_mem = limit; in apr_procattr_limit_set()
704 attr->limit_nproc = limit; in apr_procattr_limit_set()
712 attr->limit_nofile = limit; in apr_procattr_limit_set()
724 APR_DECLARE(apr_status_t) apr_procattr_perms_set_register(apr_procattr_t *attr, in apr_procattr_perms_set_register() argument
731 c = apr_palloc(attr->pool, sizeof(apr_procattr_pscb_t)); in apr_procattr_perms_set_register()
735 c->next = attr->perms_set_callbacks; in apr_procattr_perms_set_register()
736 attr->perms_set_callbacks = c; in apr_procattr_perms_set_register()