Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Privileged ports and users
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
har3
n00b
n00b


Joined: 28 Apr 2004
Posts: 5

PostPosted: Thu Sep 23, 2004 8:43 am    Post subject: Privileged ports and users Reply with quote

Hi all.

I need to run some services as a user on privileged ports (<1024).
How can I accomplish that.

Thanks.
Back to top
View user's profile Send private message
nightblade
Guru
Guru


Joined: 20 Jul 2004
Posts: 368
Location: back from SE Asia

PostPosted: Thu Sep 23, 2004 9:44 am    Post subject: Reply with quote

If you mean that a service on a privileged port must run with low privileges, just drop root privileges after the service is started (apache does that, for instance). You should be able to accomplish this with setuid() and setgid() functions.

If you mean that a regular user must be able to start a service on a privileged port, I think you only need to set the suid bit of the program that launches that service, so that it will be launched by the user but it will run with root privileges.

Keep in mind that you are messing with limitations that are in place to secure your system, so be careful ;)
_________________
In God we trust. All the others must provide a valid X.509 certificate
Back to top
View user's profile Send private message
har3
n00b
n00b


Joined: 28 Apr 2004
Posts: 5

PostPosted: Thu Sep 23, 2004 12:49 pm    Post subject: Reply with quote

Thanks for your reply nightblade.

I'm trying to run eggdrop, so that its telnet part will listen on some privileged port (firewall issues).
Code:

Eggdrop v1.6.16+Gentoo (C) 1997 Robey Pointer (C) 2004 Eggheads
[15:48] --- Loading eggdrop v1.6.16+Gentoo (Thu Sep 23 2004)
[15:48] Tcl error in file 'eggdrop.conf':
[15:48] Couldn't grab nearby port
    while executing
"listen 650 all"
    (file "eggdrop.conf" line 251)


Setting suid bit on eggdrop executable won't help me I'm afraid...
Code:

Eggdrop v1.6.16+Gentoo (C) 1997 Robey Pointer (C) 2004 Eggheads
[09:46] * ERROR: Eggdrop will not run as root!
Back to top
View user's profile Send private message
nightblade
Guru
Guru


Joined: 20 Jul 2004
Posts: 368
Location: back from SE Asia

PostPosted: Thu Sep 23, 2004 1:42 pm    Post subject: Reply with quote

what about getting eggdrop to listen on some non-privileged port, and then set an iptables rule to forward the traffic from a privileged port to the non-privileged one ? You would solve the problem making eggdrop run without root privileges, which I think is quite nice :)
_________________
In God we trust. All the others must provide a valid X.509 certificate
Back to top
View user's profile Send private message
har3
n00b
n00b


Joined: 28 Apr 2004
Posts: 5

PostPosted: Fri Sep 24, 2004 6:17 am    Post subject: Reply with quote

Great idea!

Got it working with some iptables trickery.

Thank you nightblade.
Back to top
View user's profile Send private message
nightblade
Guru
Guru


Joined: 20 Jul 2004
Posts: 368
Location: back from SE Asia

PostPosted: Fri Sep 24, 2004 8:21 am    Post subject: Reply with quote

Glad it was useful, mate ! 8)
_________________
In God we trust. All the others must provide a valid X.509 certificate
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum