syslog-ng as non-root user? (and misc acl syntax questions)
Posted: Thu Jan 06, 2005 10:57 pm
Hi.
Still kinda trying to grapple with the acl's, so excuse me if I'm being stupid.
I'm trying to run syslog-ng as its own non-root user, It keeps getting a Operation not permitted when it tries to read from /proc/kmsg .
Now at some point the linux kernel was patched to allow anyone with CAP_SYS_ADMIN to read from it:
Ok, so as I am understanding the acl's, I should be able to setup a role, ie 'syslog', give it minimal privs, then a subject like /sbin/syslog-ng and give it CAP_SYS_ADMIN and etc permissions and we should be good to go correct ?
Below is a copy of the relevant acl's, also - as I understand it this function will only be called in process context (do_syslog()), so I could just as easily patch the source there and check the uid against my syslog uid, instead of having to give it CAP_SYS_ADMIN ?
Any thoughts on that would be helpful.
My other question as I grapple with the ACL's is the basic syntax, meaning:
If I am understanding things correct, here we have the role foo, who can transition to bar, and is allowed to come from any address, by default he has no capabilities and can only exec bash, then bash itself can do whatever files are listed in the first [ ... ] , (i.e. /lib/libc.so.2 x would allow it to execute libc.so.2), it should also run with the sys admin capability correct? If I am following all of that correctly (feel free to correct me or point me in the direction of better documentation) then this should be working correctly:
This all works correctly, when it open's /proc/kmsg it does so with mode O_RDWR and that returns fine, however any attempts to read from it return Operation not permitted.
Any ideas?
Still kinda trying to grapple with the acl's, so excuse me if I'm being stupid.
I'm trying to run syslog-ng as its own non-root user, It keeps getting a Operation not permitted when it tries to read from /proc/kmsg .
Now at some point the linux kernel was patched to allow anyone with CAP_SYS_ADMIN to read from it:
- Code: Select all
kmsg.c
[ ... ]
static int kmsg_open(struct inode * inode, struct file * file)
{
return do_syslog(1,NULL,0);
}
[ ... ]
static ssize_t kmsg_read(struct file * file, char * buf,
size_t count, loff_t *ppos)
{
return do_syslog(2,buf,count);
}
printk.c
[ .... ]
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
Ok, so as I am understanding the acl's, I should be able to setup a role, ie 'syslog', give it minimal privs, then a subject like /sbin/syslog-ng and give it CAP_SYS_ADMIN and etc permissions and we should be good to go correct ?
Below is a copy of the relevant acl's, also - as I understand it this function will only be called in process context (do_syslog()), so I could just as easily patch the source there and check the uid against my syslog uid, instead of having to give it CAP_SYS_ADMIN ?
Any thoughts on that would be helpful.
My other question as I grapple with the ACL's is the basic syntax, meaning:
- Code: Select all
role foo
role_transitions bar
role_allow_ip 0.0.0.0/32
subject / {
/ h
/bin/bash x
-CAP_ALL
bind disabled
connect disabled
}
subject /bin/bash o {
[ ... ]
-CAP_ALL
+CAP_SYS_ADMIN
bind [ ... ]
connect [ ... ]
}
If I am understanding things correct, here we have the role foo, who can transition to bar, and is allowed to come from any address, by default he has no capabilities and can only exec bash, then bash itself can do whatever files are listed in the first [ ... ] , (i.e. /lib/libc.so.2 x would allow it to execute libc.so.2), it should also run with the sys admin capability correct? If I am following all of that correctly (feel free to correct me or point me in the direction of better documentation) then this should be working correctly:
- Code: Select all
role syslog uTi
subject / {
/ h
-CAP_ALL
bind disabled
connect disabled
}
subject /sbin/syslog-ng o {
/ h
/proc h
/proc/kmsg rw
/proc/sys/kernel/ngroups_max r
/dev h
/dev/log rw
/var h
/var/run h
/var/run/syslog-ng rwcd
/var/run/nscd
/var/run/nscd/socket rw
/lib h
/lib/libnsl.so.1 rx
/lib/libnss_files.so.2 rx
/lib/libresolv.so.2 rx
/lib/libc.so rx
/lib/ld-linux.so.2 rx
/usr/lib h
/usr/lib/libwrap.so.0 rx
/etc h
/etc/passwd r
/etc/group r
/etc/ld.so.cache r
/etc/hosts r
/etc/nsswitch.conf r
/etc/resolv.conf r
/etc/syslog-ng
/etc/syslog-ng/syslog-ng.conf r
-CAP_ALL
+CAP_SYS_ADMIN
bind disabled
connect 172.0.0.0/32:514 stream tcp # real ip edited
}
This all works correctly, when it open's /proc/kmsg it does so with mode O_RDWR and that returns fine, however any attempts to read from it return Operation not permitted.
Any ideas?