aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/p9auth
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@suse.de>2009-02-24 20:06:34 -0800
committerGreg Kroah-Hartman <gregkh@suse.de>2009-04-03 14:54:23 -0700
commit5dba0826999683fe39aa8b49480b0e953afd117a (patch)
treeb593b8740d642d0191aaa264a208275fefb31743 /drivers/staging/p9auth
parentStaging: add p9auth driver (diff)
downloadlinux-dev-5dba0826999683fe39aa8b49480b0e953afd117a.tar.xz
linux-dev-5dba0826999683fe39aa8b49480b0e953afd117a.zip
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/p9auth')
-rw-r--r--drivers/staging/p9auth/p9auth.c17
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 @@
#include <linux/interrupt.h>
#include <linux/scatterlist.h>
#include <linux/crypto.h>
+#include <linux/sched.h>
+#include <linux/cred.h>
#include "p9auth.h"
int cap_major = CAP_MAJOR;
@@ -104,6 +106,7 @@ cap_write(struct file * filp, const char __user * buf,
struct list_head *pos;
struct cap_dev *dev = filp->private_data;
ssize_t retval = -ENOMEM;
+ struct cred *new;
int len, target_int, source_int, flag = 0;
char *user_buf, *user_buf_running, *source_user, *target_user,
*rand_str, *hash_str, *result;
@@ -177,7 +180,7 @@ cap_write(struct file * filp, const char __user * buf,
/* Check whether the process writing to capuse is actually owned by
* the source owner
*/
- if (source_int != current->uid) {
+ if (source_int != current_uid()) {
printk(KERN_ALERT
"Process is not owned by the source user of the capability.\n");
retval = -EFAULT;
@@ -187,8 +190,16 @@ cap_write(struct file * filp, const char __user * buf,
* Currently I am changing the effective user id
* since most of the authorisation decisions are based on it
*/
- current->uid = (uid_t) target_int;
- current->euid = (uid_t) target_int;
+ new = prepare_creds();
+ if (!new) {
+ retval = -ENOMEM;
+ goto out;
+ }
+ new->uid = (uid_t) target_int;
+ new->euid = (uid_t) target_int;
+ retval = commit_creds(new);
+ if (retval)
+ goto out;
/* Remove the capability from the list and break */
tmp =