Esempio n. 1
0
int
pam_modutil_sanitize_helper_fds(pam_handle_t *pamh,
				enum pam_modutil_redirect_fd stdin_mode,
				enum pam_modutil_redirect_fd stdout_mode,
				enum pam_modutil_redirect_fd stderr_mode)
{
	if (stdin_mode != PAM_MODUTIL_IGNORE_FD &&
	    redirect_in_pipe(pamh, STDIN_FILENO, "stdin") < 0) {
		return -1;
	}

	if (redirect_out(pamh, stdout_mode, STDOUT_FILENO, "stdout") < 0)
		return -1;

	/*
	 * If stderr should not be ignored and
	 * redirect mode for stdout and stderr are the same,
	 * optimize by redirecting stderr to stdout.
	 */
	if (stderr_mode != PAM_MODUTIL_IGNORE_FD &&
	    stdout_mode == stderr_mode) {
		if (dup2(STDOUT_FILENO, STDERR_FILENO) != STDERR_FILENO) {
			pam_syslog(pamh, LOG_ERR,
				   "dup2 of %s failed: %m", "stderr");
			return -1;
		}
	} else {
		if (redirect_out(pamh, stderr_mode, STDERR_FILENO, "stderr") < 0)
			return -1;
	}

	close_fds();
	return 0;
}
Esempio n. 2
0
void convert_S_to_s(char *path)
{
	build_arglist(CMD_CPP);
	redirect_in(path);
	redirect_out(pathmod(path, ".S", ".s", 1));
	run_command();
}
Esempio n. 3
0
void convert_c_to_s(char *path)
{
	char *tmp;
	build_arglist(CMD_CC);
	redirect_in(path);
	tmp = strdup(pathmod(path, ".%", ".@", 0));
	if (tmp == NULL)
		memory();
	redirect_out(tmp);
	run_command();
	build_arglist(CMD_COPT);
	add_argument(COPT_FILE);
	redirect_in(tmp);
	redirect_out(pathmod(path, ".%", ".s", 2));
	run_command();
	free(tmp);
}
Esempio n. 4
0
void preprocess_c(char *path)
{
	build_arglist(CMD_CPP);

	add_argument_list("-I", &inclist);
	add_argument_list("-D", &deflist);
	add_argument(path);
	/* Weird one .. -E goes to stdout */
	if (last_phase != 1)
		redirect_out(pathmod(path, ".c", ".%", 0));
	run_command();
}