diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2007-02-14 03:34:11 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-02-14 11:09:59 -0500 |
commit | 1ff007eb8e8c7c44e9a384a67d0fdd0fd06ba811 (patch) | |
tree | 01ed52bee21a39302ccfd49315a79806506177c7 | |
parent | 805b5d5e063e7fde5e2eb724e3f4cb18e47cab19 (diff) |
[PATCH] sysctl: allow sysctl_perm to be called from outside of sysctl.c
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>
-rw-r--r-- | include/linux/sysctl.h | 2 | ||||
-rw-r--r-- | kernel/sysctl.c | 10 |
2 files changed, 7 insertions, 5 deletions
diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h index 72ba58b362d8..9698ac30f553 100644 --- a/include/linux/sysctl.h +++ b/include/linux/sysctl.h | |||
@@ -925,8 +925,10 @@ enum | |||
925 | #include <linux/list.h> | 925 | #include <linux/list.h> |
926 | 926 | ||
927 | /* For the /proc/sys support */ | 927 | /* For the /proc/sys support */ |
928 | struct ctl_table; | ||
928 | extern struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev); | 929 | extern struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev); |
929 | extern void sysctl_head_finish(struct ctl_table_header *prev); | 930 | extern void sysctl_head_finish(struct ctl_table_header *prev); |
931 | extern int sysctl_perm(struct ctl_table *table, int op); | ||
930 | 932 | ||
931 | extern void sysctl_init(void); | 933 | extern void sysctl_init(void); |
932 | 934 | ||
diff --git a/kernel/sysctl.c b/kernel/sysctl.c index c3e2ac9cb5fb..6bbac5ce75ed 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c | |||
@@ -1157,7 +1157,7 @@ asmlinkage long sys_sysctl(struct __sysctl_args __user *args) | |||
1157 | #endif /* CONFIG_SYSCTL_SYSCALL */ | 1157 | #endif /* CONFIG_SYSCTL_SYSCALL */ |
1158 | 1158 | ||
1159 | /* | 1159 | /* |
1160 | * ctl_perm does NOT grant the superuser all rights automatically, because | 1160 | * sysctl_perm does NOT grant the superuser all rights automatically, because |
1161 | * some sysctl variables are readonly even to root. | 1161 | * some sysctl variables are readonly even to root. |
1162 | */ | 1162 | */ |
1163 | 1163 | ||
@@ -1172,7 +1172,7 @@ static int test_perm(int mode, int op) | |||
1172 | return -EACCES; | 1172 | return -EACCES; |
1173 | } | 1173 | } |
1174 | 1174 | ||
1175 | static inline int ctl_perm(ctl_table *table, int op) | 1175 | int sysctl_perm(ctl_table *table, int op) |
1176 | { | 1176 | { |
1177 | int error; | 1177 | int error; |
1178 | error = security_sysctl(table, op); | 1178 | error = security_sysctl(table, op); |
@@ -1199,7 +1199,7 @@ repeat: | |||
1199 | if (n == table->ctl_name) { | 1199 | if (n == table->ctl_name) { |
1200 | int error; | 1200 | int error; |
1201 | if (table->child) { | 1201 | if (table->child) { |
1202 | if (ctl_perm(table, 001)) | 1202 | if (sysctl_perm(table, 001)) |
1203 | return -EPERM; | 1203 | return -EPERM; |
1204 | name++; | 1204 | name++; |
1205 | nlen--; | 1205 | nlen--; |
@@ -1228,7 +1228,7 @@ int do_sysctl_strategy (ctl_table *table, | |||
1228 | op |= 004; | 1228 | op |= 004; |
1229 | if (newval) | 1229 | if (newval) |
1230 | op |= 002; | 1230 | op |= 002; |
1231 | if (ctl_perm(table, op)) | 1231 | if (sysctl_perm(table, op)) |
1232 | return -EPERM; | 1232 | return -EPERM; |
1233 | 1233 | ||
1234 | if (table->strategy) { | 1234 | if (table->strategy) { |
@@ -1498,7 +1498,7 @@ static ssize_t do_rw_proc(int write, struct file * file, char __user * buf, | |||
1498 | goto out; | 1498 | goto out; |
1499 | error = -EPERM; | 1499 | error = -EPERM; |
1500 | op = (write ? 002 : 004); | 1500 | op = (write ? 002 : 004); |
1501 | if (ctl_perm(table, op)) | 1501 | if (sysctl_perm(table, op)) |
1502 | goto out; | 1502 | goto out; |
1503 | 1503 | ||
1504 | /* careful: calling conventions are nasty here */ | 1504 | /* careful: calling conventions are nasty here */ |