reading /proc/kmsg

Alexander Kjeldaas (astor@guardian.no)
Tue, 17 Nov 1998 14:48:32 +0100


--WIyZ46R2i8wDzkSu
Content-Type: text/plain; charset=us-ascii

Currently the kernel checks credentials on each read from /proc/kmsg
which means that klogd has to run as root. The following patch (I've
lost the name of the guy who wrote the original patch) moves the
credentials checking out of the syslog function and into the syslog
system call where it belongs.

astor

-- 
 Alexander Kjeldaas, Guardian Networks AS, Trondheim, Norway
 http://www.guardian.no/

--WIyZ46R2i8wDzkSu Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=out3

diff -urN linux-2.1.128/fs/proc/kmsg.c l128/fs/proc/kmsg.c --- linux-2.1.128/fs/proc/kmsg.c Mon Aug 24 22:14:09 1998 +++ l128/fs/proc/kmsg.c Tue Nov 17 14:06:35 1998 @@ -17,23 +17,23 @@ extern unsigned long log_size; extern struct wait_queue * log_wait; -asmlinkage int sys_syslog(int type, char * bug, int count); +asmlinkage int do_syslog(int type, char * bug, int count); static int kmsg_open(struct inode * inode, struct file * file) { - return sys_syslog(1,NULL,0); + return do_syslog(1,NULL,0); } static int kmsg_release(struct inode * inode, struct file * file) { - (void) sys_syslog(0,NULL,0); + (void) do_syslog(0,NULL,0); return 0; } static ssize_t kmsg_read(struct file * file, char * buf, size_t count, loff_t *ppos) { - return sys_syslog(2,buf,count); + return do_syslog(2,buf,count); } static unsigned int kmsg_poll(struct file *file, poll_table * wait) diff -urN linux-2.1.128/kernel/printk.c l128/kernel/printk.c --- linux-2.1.128/kernel/printk.c Mon Nov 16 12:59:41 1998 +++ l128/kernel/printk.c Tue Nov 17 14:15:24 1998 @@ -105,7 +105,7 @@ /* - * Commands to sys_syslog: + * Commands to do_syslog: * * 0 -- Close the log. Currently a NOP. * 1 -- Open the log. Currently a NOP. @@ -117,7 +117,7 @@ * 7 -- Enable printk's to console * 8 -- Set level of messages printed to console */ -asmlinkage int sys_syslog(int type, char * buf, int len) +int do_syslog(int type, char * buf, int len) { unsigned long i, j, count, flags; int do_clear = 0; @@ -125,8 +125,6 @@ int error = -EPERM; lock_kernel(); - if ((type != 3) && !capable(CAP_SYS_ADMIN)) - goto out; error = 0; switch (type) { case 0: /* Close log */ @@ -227,6 +225,14 @@ unlock_kernel(); return error; } + +asmlinkage int sys_syslog(int type, char * buf, int len) +{ + if ((type != 3) && !capable(CAP_SYS_ADMIN)) + return -EPERM; + return do_syslog(type, buf, len); +} + spinlock_t console_lock;

--WIyZ46R2i8wDzkSu--

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/