Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / net / tux / cgi.c
index fda4d38..e839bf6 100644 (file)
@@ -30,6 +30,8 @@
 
 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);
@@ -41,16 +43,16 @@ static int exec_usermode(char *program_path, char *argv[], char *envp[])
        /* Allow execve args to be in kernel space. */
        set_fs(KERNEL_DS);
 
-       flush_signals(current);
-       spin_lock_irq(&current->sighand->siglock);
-       flush_signal_handlers(current, 1);
-       spin_unlock_irq(&current->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;
@@ -73,16 +75,14 @@ static int exec_helper (void * data)
        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);
        }
@@ -111,6 +111,9 @@ static int exec_helper (void * data)
         * CGI application.
         */
        if (param->pipe_fds) {
+               struct files_struct *files = current->files;
+               struct fdtable *fdt;
+
                tux_close(1);
                tux_close(2);
                tux_close(4);
@@ -121,17 +124,12 @@ static int exec_helper (void * data)
                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(&current->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(&current->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)