xinetd startup script checking for writeable /etc/passwd ?
Linux - SecurityThis forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
It's checking to make sure that xinetd isn't started by an account other than root (or one with root privileges). That's a *good* thing. If someone is already on your box with root privileges, this won't hurt anything since the box would already be severely compromised.
Originally posted by Doug_Loss It's checking to make sure that xinetd isn't started by an account other than root (or one with root privileges). That's a *good* thing. If someone is already on your box with root privileges, this won't hurt anything since the box would already be severely compromised.
root doesn't need to have write access to /etc/passwd, for security reasons the file could have the immutable bit set => xinetd startup will fail.
There are other ways to check for root rights (checking the uid for instance), etc!
root doesn't need to have write access to /etc/passwd, for security reasons the file could have the immutable bit set(..)
It's about being capable to access/having write access to a file vs actually writing to a file. Extended bits only posess meaning when writing to a file in this case of the immutable bit.
int main( int argc, char *argv[] )
{
const char *func = "main" ;
+
+ if (getuid() & geteuid()) {
+ terminate_program();
+ }
+
sio_init();
after which it'll sigsegv when executed as non-root, LOL!
Seriously, Xinetd will *need* at least read-only access to /etc/passwd in case a service has to be started as non-root (man xinetd.conf) so it can find out the user, and since it doesn't do actual writes to /etc/passwd, the extended bits can be kept, AFAIC.
Originally posted by unSpawn Seriously, Xinetd will *need* at least read-only access to /etc/passwd in case a service has to be started as non-root (man xinetd.conf) so it can find out the user, and since it doesn't do actual writes to /etc/passwd, the extended bits can be kept, AFAIC.
Well if you have set the immutable bit xinetd refuses to start ...
Ok. That's nasty. The check ain't in 2.3.3x and it ain't in the contrib src of 2.3.9. If you run this:
#!/bin/sh
tgt=/etc/passwd
chk() { if [ -w "$tgt" ]; then echo write; else echo wont; fi; }
chattr +i "$tgt"; chk; chattr -i "$tgt"; chk
You'll see extended bit doesn't affect it, and root gets "write" every time. Ok, so I ran a strace on xinetd and it doesn't even show a open("/etc/passwd", O_RDONLY)...
Could you run a strace, scrub the output for hostnames etc and post it here?
Yeah, but I can't imagine why a script would break xinetd usage this way... Anyway, I downloaded the RH 8.0 xinetd-2.3.7 rpm, and exept for the passwd stuff there's nothing weird in it.
Stracing xinetd (ok, not the script) doesn't show me open\( 's for passwd.
If commenting out the passwd stuff from the initscript while leaving the immutable bit on works, let's drop the matter ok?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.