static int exec_usermode(char *program_path, char *argv[], char *envp[])
{
+ struct files_struct *files = current->files;
+ struct fdtable *fdt;
int i, err;
err = tux_chroot(tux_cgiroot);
/* Allow execve args to be in kernel space. */
set_fs(KERNEL_DS);
- flush_signals(current);
- spin_lock_irq(¤t->sighand->siglock);
- flush_signal_handlers(current, 1);
- spin_unlock_irq(¤t->sighand->siglock);
+ // TODO: is this RCU-safe?
+ spin_lock(&files->file_lock);
+ fdt = files_fdtable(files);
+ spin_unlock(&files->file_lock);
- for (i = 3; i < current->files->max_fds; i++ )
- if (current->files->fd[i])
+ for (i = 3; i < fdt->max_fds; i++ )
+ if (fdt->fd[i])
tux_close(i);
- err = execve(program_path, argv, envp);
+ err = __exec_usermodehelper(program_path, argv, envp, NULL);
if (err < 0)
return err;
return 0;
int ret;
sprintf(current->comm,"doexec - %d", current->pid);
-#if CONFIG_SMP
+#ifdef CONFIG_SMP
if (!tux_cgi_inherit_cpu) {
-
- cpumask_t cgi_mask, map;
-
- mask_to_cpumask(tux_cgi_cpu_mask, &cgi_mask);
- cpus_and(map, cpu_online_map, cgi_mask);
-
+ cpumask_t map;
+
+ cpus_and(map, cpu_online_map, tux_cgi_cpu_mask);
+
if (!(cpus_empty(map)))
- set_cpus_allowed(current, cgi_mask);
+ set_cpus_allowed(current, map);
else
set_cpus_allowed(current, cpu_online_map);
}
* CGI application.
*/
if (param->pipe_fds) {
+ struct files_struct *files = current->files;
+ struct fdtable *fdt;
+
tux_close(1);
tux_close(2);
tux_close(4);
tux_close(3);
tux_close(5);
// do not close on exec.
-#if 0
- sys_fcntl(0, F_SETFD, 0);
- sys_fcntl(1, F_SETFD, 0);
- sys_fcntl(2, F_SETFD, 0);
-#else
- spin_lock(¤t->files->file_lock);
- FD_CLR(0, current->files->close_on_exec);
- FD_CLR(1, current->files->close_on_exec);
- FD_CLR(2, current->files->close_on_exec);
- spin_unlock(¤t->files->file_lock);
-#endif
+ spin_lock(&files->file_lock);
+ fdt = files_fdtable(files);
+ FD_CLR(0, fdt->close_on_exec);
+ FD_CLR(1, fdt->close_on_exec);
+ FD_CLR(2, fdt->close_on_exec);
+ spin_unlock(&files->file_lock);
}
ret = exec_usermode(param->command, param->argv, param->envp);
if (ret < 0)