[PATCH] sysctl: allow sysctl_perm to be called from outside of sysctl.c
authorEric W. Biederman <ebiederm@xmission.com>
Wed, 14 Feb 2007 08:34:11 +0000 (00:34 -0800)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Wed, 14 Feb 2007 16:09:59 +0000 (08:09 -0800)
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
include/linux/sysctl.h
kernel/sysctl.c

index 72ba58b362d8e1afc7ae9288f2035f45a19e18a4..9698ac30f553bf33424b7ec0a2efb7c87e5ea5df 100644 (file)
@@ -925,8 +925,10 @@ enum
 #include <linux/list.h>
 
 /* For the /proc/sys support */
+struct ctl_table;
 extern struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev);
 extern void sysctl_head_finish(struct ctl_table_header *prev);
+extern int sysctl_perm(struct ctl_table *table, int op);
 
 extern void sysctl_init(void);
 
index c3e2ac9cb5fb19e9158dc833ce6309d129c89d2d..6bbac5ce75ed73d4c9ebae196dfdde6a9dc2ec9b 100644 (file)
@@ -1157,7 +1157,7 @@ asmlinkage long sys_sysctl(struct __sysctl_args __user *args)
 #endif /* CONFIG_SYSCTL_SYSCALL */
 
 /*
- * ctl_perm does NOT grant the superuser all rights automatically, because
+ * sysctl_perm does NOT grant the superuser all rights automatically, because
  * some sysctl variables are readonly even to root.
  */
 
@@ -1172,7 +1172,7 @@ static int test_perm(int mode, int op)
        return -EACCES;
 }
 
-static inline int ctl_perm(ctl_table *table, int op)
+int sysctl_perm(ctl_table *table, int op)
 {
        int error;
        error = security_sysctl(table, op);
@@ -1199,7 +1199,7 @@ repeat:
                if (n == table->ctl_name) {
                        int error;
                        if (table->child) {
-                               if (ctl_perm(table, 001))
+                               if (sysctl_perm(table, 001))
                                        return -EPERM;
                                name++;
                                nlen--;
@@ -1228,7 +1228,7 @@ int do_sysctl_strategy (ctl_table *table,
                op |= 004;
        if (newval) 
                op |= 002;
-       if (ctl_perm(table, op))
+       if (sysctl_perm(table, op))
                return -EPERM;
 
        if (table->strategy) {
@@ -1498,7 +1498,7 @@ static ssize_t do_rw_proc(int write, struct file * file, char __user * buf,
                        goto out;
                error = -EPERM;
                op = (write ? 002 : 004);
-               if (ctl_perm(table, op))
+               if (sysctl_perm(table, op))
                        goto out;
                
                /* careful: calling conventions are nasty here */