* allow process or user to listen on priviledged ports?
@ 2003-12-24 16:43 Sven Köhler
2003-12-24 17:02 ` Michael Buesch
` (3 more replies)
0 siblings, 4 replies; 9+ messages in thread
From: Sven Köhler @ 2003-12-24 16:43 UTC (permalink / raw)
To: linux-kernel
Hi,
don't blame me for asking such a question in the LKML, but i already
asked it in other linux-newsgroups. i haven't got any real answer yet.
my problem is, that i want an application to listen on a priviledged
port (e.g. port 80) and to run as a "normal" unpriviledged user (e.g.
wwwrun). Well - how? The application is not a C/C++-application, so i
cannot ask the author (myself) to implement a mechanism to switch the
userid (e.g. like apache does it).
So is there any machanism to bind that permission (to listen on a
priviledged tcp-port) to a specific user or a specific process?
The application is written in Java. Of course Java could implement
userid-switching, but the linux could also have an ACL for that. So
please don't answer with "go and ask Sun for that feature". I already
considered that.
Thx
Sven
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: allow process or user to listen on priviledged ports?
2003-12-24 16:43 allow process or user to listen on priviledged ports? Sven Köhler
@ 2003-12-24 17:02 ` Michael Buesch
2003-12-24 17:23 ` Olaf Dietsche
` (2 subsequent siblings)
3 siblings, 0 replies; 9+ messages in thread
From: Michael Buesch @ 2003-12-24 17:02 UTC (permalink / raw)
To: Sven Köhler; +Cc: linux kernel mailing list
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Wednesday 24 December 2003 17:43, Sven Köhler wrote:
> Hi,
Hi Sven,
> So is there any machanism to bind that permission (to listen on a
> priviledged tcp-port) to a specific user or a specific process?
I think (AFAIK) either grsec or selinux (or both) have the
ability to make the kernel accepting binds to those
privileged ports as normal user.
>
> Thx
> Sven
- --
Regards Michael Buesch [ http://www.tuxsoft.de.vu ]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)
iD8DBQE/6caxFGK1OIvVOP4RAupiAJ0SewsaODhJK8uQmmeQwEV8tGxp4QCfW4Fd
epUXG6pd5lERWvEIC+Ok7W0=
=7G/F
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: allow process or user to listen on priviledged ports?
2003-12-24 16:43 allow process or user to listen on priviledged ports? Sven Köhler
2003-12-24 17:02 ` Michael Buesch
@ 2003-12-24 17:23 ` Olaf Dietsche
2003-12-24 21:34 ` Adam Sampson
2003-12-25 10:45 ` Nick Craig-Wood
3 siblings, 0 replies; 9+ messages in thread
From: Olaf Dietsche @ 2003-12-24 17:23 UTC (permalink / raw)
To: Sven Köhler; +Cc: linux-kernel
Sven Köhler <skoehler@upb.de> writes:
> my problem is, that i want an application to listen on a priviledged
> port (e.g. port 80) and to run as a "normal" unpriviledged user
>
> So is there any machanism to bind that permission (to listen on a
> priviledged tcp-port) to a specific user or a specific process?
Of course, there is :-)
<http://www.olafdietsche.de/linux/accessfs/>
Regards, Olaf.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: allow process or user to listen on priviledged ports?
2003-12-24 16:43 allow process or user to listen on priviledged ports? Sven Köhler
2003-12-24 17:02 ` Michael Buesch
2003-12-24 17:23 ` Olaf Dietsche
@ 2003-12-24 21:34 ` Adam Sampson
2003-12-24 21:59 ` Thomas Zehetbauer
2003-12-24 22:00 ` Eric
2003-12-25 10:45 ` Nick Craig-Wood
3 siblings, 2 replies; 9+ messages in thread
From: Adam Sampson @ 2003-12-24 21:34 UTC (permalink / raw)
To: Sven Köhler; +Cc: linux-kernel
Sven Köhler <skoehler@upb.de> writes:
> So is there any machanism to bind that permission (to listen on a
> priviledged tcp-port) to a specific user or a specific process?
Even if you can't find a way to do this, you can cheat: use an
iptables DNAT rule to translate connections to the desired port into
connections to a non-privileged port upon which your daemon is
actually listening. Something like:
iptables -t nat -A PREROUTING -p tcp --dport 80 -j DNAT --to 1.2.3.4:8080
--
Adam Sampson <azz@us-lot.org> <http://offog.org/>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: allow process or user to listen on priviledged ports?
2003-12-24 16:43 allow process or user to listen on priviledged ports? Sven Köhler
` (2 preceding siblings ...)
2003-12-24 21:34 ` Adam Sampson
@ 2003-12-25 10:45 ` Nick Craig-Wood
2003-12-25 12:18 ` Sven Köhler
3 siblings, 1 reply; 9+ messages in thread
From: Nick Craig-Wood @ 2003-12-25 10:45 UTC (permalink / raw)
To: Sven K; +Cc: linux-kernel
On Wed, Dec 24, 2003 at 05:43:09PM +0100, Sven K?hler wrote:
> my problem is, that i want an application to listen on a priviledged
> port (e.g. port 80) and to run as a "normal" unpriviledged user
I would give your application this capability (from #include "linux/capability.h")
/* Allows binding to TCP/UDP sockets below 1024 */
/* Allows binding to ATM VCIs below 32 */
#define CAP_NET_BIND_SERVICE 10
You do this with a setuid wrapper which drops all capabilities but
that one and then runs your application.
One day there will be a way of doing this in the filing system, so
instead of doing a chmod u+s you do a chmod +CAP_NET_BIND_SERVICE or
something! Until then use a setuid wrapper....
Here is a FAQ
http://ftp.kernel.org/pub/linux/libs/security/linux-privs/kernel-2.4/capfaq-0.2.txt
Actually the FAQ mentions sucap which seems to be a fairly standard
program (its in Debian anyway!). You could use this too...
--
Nick Craig-Wood
ncw1@axis.demon.co.uk
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: allow process or user to listen on priviledged ports?
2003-12-25 10:45 ` Nick Craig-Wood
@ 2003-12-25 12:18 ` Sven Köhler
2003-12-25 17:46 ` Sven Köhler
0 siblings, 1 reply; 9+ messages in thread
From: Sven Köhler @ 2003-12-25 12:18 UTC (permalink / raw)
To: Nick Craig-Wood; +Cc: linux-kernel
> I would give your application this capability (from #include "linux/capability.h")
>
> /* Allows binding to TCP/UDP sockets below 1024 */
> /* Allows binding to ATM VCIs below 32 */
>
> #define CAP_NET_BIND_SERVICE 10
>
> You do this with a setuid wrapper which drops all capabilities but
> that one and then runs your application.
Thx for the answer! That's exactly what i search for.
I will try to write such a program. It seems that sucap keeps all
capabilities and drops none. Depending on the other capabilities, that
could be a bad idea.
Thx
Sven
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2003-12-25 17:52 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-12-24 16:43 allow process or user to listen on priviledged ports? Sven Köhler
2003-12-24 17:02 ` Michael Buesch
2003-12-24 17:23 ` Olaf Dietsche
2003-12-24 21:34 ` Adam Sampson
2003-12-24 21:59 ` Thomas Zehetbauer
2003-12-24 22:00 ` Eric
2003-12-25 10:45 ` Nick Craig-Wood
2003-12-25 12:18 ` Sven Köhler
2003-12-25 17:46 ` Sven Köhler
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox