summaryrefslogtreecommitdiffstats
path: root/scull/access.c
diff options
context:
space:
mode:
Diffstat (limited to 'scull/access.c')
-rw-r--r--scull/access.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/scull/access.c b/scull/access.c
index 970b57c..b534721 100644
--- a/scull/access.c
+++ b/scull/access.c
@@ -28,6 +28,8 @@
#include <linux/tty.h>
#include <asm/atomic.h>
#include <linux/list.h>
+#include <linux/cred.h> /* current_uid(), current_euid() */
+#include <linux/sched.h>
#include "scull.h" /* local definitions */
@@ -103,15 +105,15 @@ static int scull_u_open(struct inode *inode, struct file *filp)
spin_lock(&scull_u_lock);
if (scull_u_count &&
- (scull_u_owner != current->uid) && /* allow user */
- (scull_u_owner != current->euid) && /* allow whoever did su */
+ (scull_u_owner != current_uid()) && /* allow user */
+ (scull_u_owner != current_euid()) && /* allow whoever did su */
!capable(CAP_DAC_OVERRIDE)) { /* still allow root */
spin_unlock(&scull_u_lock);
return -EBUSY; /* -EPERM would confuse the user */
}
if (scull_u_count == 0)
- scull_u_owner = current->uid; /* grab it */
+ scull_u_owner = current_uid(); /* grab it */
scull_u_count++;
spin_unlock(&scull_u_lock);
@@ -162,8 +164,8 @@ static spinlock_t scull_w_lock = SPIN_LOCK_UNLOCKED;
static inline int scull_w_available(void)
{
return scull_w_count == 0 ||
- scull_w_owner == current->uid ||
- scull_w_owner == current->euid ||
+ scull_w_owner == current_uid() ||
+ scull_w_owner == current_euid() ||
capable(CAP_DAC_OVERRIDE);
}
@@ -181,7 +183,7 @@ static int scull_w_open(struct inode *inode, struct file *filp)
spin_lock(&scull_w_lock);
}
if (scull_w_count == 0)
- scull_w_owner = current->uid; /* grab it */
+ scull_w_owner = current_uid(); /* grab it */
scull_w_count++;
spin_unlock(&scull_w_lock);