|
@@ -122,6 +122,7 @@ struct subprocess_info {
|
|
struct key *ring;
|
|
struct key *ring;
|
|
int wait;
|
|
int wait;
|
|
int retval;
|
|
int retval;
|
|
|
|
+ struct file *stdin;
|
|
};
|
|
};
|
|
|
|
|
|
/*
|
|
/*
|
|
@@ -145,12 +146,26 @@ static int ____call_usermodehelper(void *data)
|
|
|
|
|
|
key_put(old_session);
|
|
key_put(old_session);
|
|
|
|
|
|
|
|
+ /* Install input pipe when needed */
|
|
|
|
+ if (sub_info->stdin) {
|
|
|
|
+ struct files_struct *f = current->files;
|
|
|
|
+ struct fdtable *fdt;
|
|
|
|
+ /* no races because files should be private here */
|
|
|
|
+ sys_close(0);
|
|
|
|
+ fd_install(0, sub_info->stdin);
|
|
|
|
+ spin_lock(&f->file_lock);
|
|
|
|
+ fdt = files_fdtable(f);
|
|
|
|
+ FD_SET(0, fdt->open_fds);
|
|
|
|
+ FD_CLR(0, fdt->close_on_exec);
|
|
|
|
+ spin_unlock(&f->file_lock);
|
|
|
|
+ }
|
|
|
|
+
|
|
/* We can run anywhere, unlike our parent keventd(). */
|
|
/* We can run anywhere, unlike our parent keventd(). */
|
|
set_cpus_allowed(current, CPU_MASK_ALL);
|
|
set_cpus_allowed(current, CPU_MASK_ALL);
|
|
|
|
|
|
retval = -EPERM;
|
|
retval = -EPERM;
|
|
if (current->fs->root)
|
|
if (current->fs->root)
|
|
- retval = execve(sub_info->path, sub_info->argv,sub_info->envp);
|
|
|
|
|
|
+ retval = execve(sub_info->path, sub_info->argv, sub_info->envp);
|
|
|
|
|
|
/* Exec failed? */
|
|
/* Exec failed? */
|
|
sub_info->retval = retval;
|
|
sub_info->retval = retval;
|
|
@@ -268,6 +283,44 @@ int call_usermodehelper_keys(char *path, char **argv, char **envp,
|
|
}
|
|
}
|
|
EXPORT_SYMBOL(call_usermodehelper_keys);
|
|
EXPORT_SYMBOL(call_usermodehelper_keys);
|
|
|
|
|
|
|
|
+int call_usermodehelper_pipe(char *path, char **argv, char **envp,
|
|
|
|
+ struct file **filp)
|
|
|
|
+{
|
|
|
|
+ DECLARE_COMPLETION(done);
|
|
|
|
+ struct subprocess_info sub_info = {
|
|
|
|
+ .complete = &done,
|
|
|
|
+ .path = path,
|
|
|
|
+ .argv = argv,
|
|
|
|
+ .envp = envp,
|
|
|
|
+ .retval = 0,
|
|
|
|
+ };
|
|
|
|
+ struct file *f;
|
|
|
|
+ DECLARE_WORK(work, __call_usermodehelper, &sub_info);
|
|
|
|
+
|
|
|
|
+ if (!khelper_wq)
|
|
|
|
+ return -EBUSY;
|
|
|
|
+
|
|
|
|
+ if (path[0] == '\0')
|
|
|
|
+ return 0;
|
|
|
|
+
|
|
|
|
+ f = create_write_pipe();
|
|
|
|
+ if (!f)
|
|
|
|
+ return -ENOMEM;
|
|
|
|
+ *filp = f;
|
|
|
|
+
|
|
|
|
+ f = create_read_pipe(f);
|
|
|
|
+ if (!f) {
|
|
|
|
+ free_write_pipe(*filp);
|
|
|
|
+ return -ENOMEM;
|
|
|
|
+ }
|
|
|
|
+ sub_info.stdin = f;
|
|
|
|
+
|
|
|
|
+ queue_work(khelper_wq, &work);
|
|
|
|
+ wait_for_completion(&done);
|
|
|
|
+ return sub_info.retval;
|
|
|
|
+}
|
|
|
|
+EXPORT_SYMBOL(call_usermodehelper_pipe);
|
|
|
|
+
|
|
void __init usermodehelper_init(void)
|
|
void __init usermodehelper_init(void)
|
|
{
|
|
{
|
|
khelper_wq = create_singlethread_workqueue("khelper");
|
|
khelper_wq = create_singlethread_workqueue("khelper");
|