diff options
author | Greg Kroah-Hartman <gregkh@suse.de> | 2009-02-24 23:06:34 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-04-03 17:54:23 -0400 |
commit | 5dba0826999683fe39aa8b49480b0e953afd117a (patch) | |
tree | b593b8740d642d0191aaa264a208275fefb31743 /drivers/staging | |
parent | 55643171de7ba429fbf2cb72fb1f2c6f2df0dcf3 (diff) |
Staging: p9auth: fix credential logic
current->uid is no longer allowed in the 2.6.29 kernel, so use
the proper credential api to be able to alter the uid and euid values.
Note, this now builds properly, hopefully still works properly, would be
good for someone to test it out...
Cc: Ashwin Ganti <ashwin.ganti@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging')
-rw-r--r-- | drivers/staging/p9auth/p9auth.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/drivers/staging/p9auth/p9auth.c b/drivers/staging/p9auth/p9auth.c index 6704d97194a8..4f079faeb8a1 100644 --- a/drivers/staging/p9auth/p9auth.c +++ b/drivers/staging/p9auth/p9auth.c | |||
@@ -31,6 +31,8 @@ | |||
31 | #include <linux/interrupt.h> | 31 | #include <linux/interrupt.h> |
32 | #include <linux/scatterlist.h> | 32 | #include <linux/scatterlist.h> |
33 | #include <linux/crypto.h> | 33 | #include <linux/crypto.h> |
34 | #include <linux/sched.h> | ||
35 | #include <linux/cred.h> | ||
34 | #include "p9auth.h" | 36 | #include "p9auth.h" |
35 | 37 | ||
36 | int cap_major = CAP_MAJOR; | 38 | int cap_major = CAP_MAJOR; |
@@ -104,6 +106,7 @@ cap_write(struct file * filp, const char __user * buf, | |||
104 | struct list_head *pos; | 106 | struct list_head *pos; |
105 | struct cap_dev *dev = filp->private_data; | 107 | struct cap_dev *dev = filp->private_data; |
106 | ssize_t retval = -ENOMEM; | 108 | ssize_t retval = -ENOMEM; |
109 | struct cred *new; | ||
107 | int len, target_int, source_int, flag = 0; | 110 | int len, target_int, source_int, flag = 0; |
108 | char *user_buf, *user_buf_running, *source_user, *target_user, | 111 | char *user_buf, *user_buf_running, *source_user, *target_user, |
109 | *rand_str, *hash_str, *result; | 112 | *rand_str, *hash_str, *result; |
@@ -177,7 +180,7 @@ cap_write(struct file * filp, const char __user * buf, | |||
177 | /* Check whether the process writing to capuse is actually owned by | 180 | /* Check whether the process writing to capuse is actually owned by |
178 | * the source owner | 181 | * the source owner |
179 | */ | 182 | */ |
180 | if (source_int != current->uid) { | 183 | if (source_int != current_uid()) { |
181 | printk(KERN_ALERT | 184 | printk(KERN_ALERT |
182 | "Process is not owned by the source user of the capability.\n"); | 185 | "Process is not owned by the source user of the capability.\n"); |
183 | retval = -EFAULT; | 186 | retval = -EFAULT; |
@@ -187,8 +190,16 @@ cap_write(struct file * filp, const char __user * buf, | |||
187 | * Currently I am changing the effective user id | 190 | * Currently I am changing the effective user id |
188 | * since most of the authorisation decisions are based on it | 191 | * since most of the authorisation decisions are based on it |
189 | */ | 192 | */ |
190 | current->uid = (uid_t) target_int; | 193 | new = prepare_creds(); |
191 | current->euid = (uid_t) target_int; | 194 | if (!new) { |
195 | retval = -ENOMEM; | ||
196 | goto out; | ||
197 | } | ||
198 | new->uid = (uid_t) target_int; | ||
199 | new->euid = (uid_t) target_int; | ||
200 | retval = commit_creds(new); | ||
201 | if (retval) | ||
202 | goto out; | ||
192 | 203 | ||
193 | /* Remove the capability from the list and break */ | 204 | /* Remove the capability from the list and break */ |
194 | tmp = | 205 | tmp = |