mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Junien Fridrick <linux.kernel@junien.fridrick.net>
To: Aleksei Besogonov <alex.besogonov@gmail.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Run a script with cap_net_bind_service - mission impossible.
Date: Wed, 17 Sep 2014 01:41:30 +0200	[thread overview]
Message-ID: <20140916234130.GA12369@jambon.ath.cx> (raw)
In-Reply-To: <loom.20140915T145605-849@post.gmane.org>

On Mon, Sep 15, 2014 at 01:07:03PM +0000, Aleksei Besogonov wrote:
> Hi!

Hi,

> 
> It seems that it's totally impossible to start a script with
> cap_net_bind_service capability and as a non-root user without modifying
> system-wide settings.
> 
> I've trawled the Net for a solution that should be exceedingly simple. I
> want to run a daemon under a non-privileged account AND allow it to bind to
> 'secure' ports (443, 589 and 53). So far I found the following non-solutions:
> 
> - Use iptables to redirect ports. Doesn't work with local traffic.

Unless I'm missing something, you can use iptables to redirect ports even for
local traffic : you need to use the OUTPUT chain. For example, if I run :
# iptables -t nat -I OUTPUT -p tcp -d 192.168.0.1 --dport 1245 -j REDIRECT --to-port 1246

and then from the same machine, run :
$ nc -v 192.168.0.1 1245

The connection will be redirected to port 1246. Doesn't that answer your use
case ?

> - Use an HTTP proxy server (yeah, and also a DNS proxy server).
> - Set cap_net_bind_service capability bit on the script interpreter (so
> it'll break during upgrades). 
> - Fuck you, run it under the root user. With several permutations like:
>   * Dropping caps after opening sockets (can't do this)
>   * Dropping all caps before starting the interpreter (fucks up the file
> ownership)
> 
> I've tried without any luck various permutations of capsh like: capsh
> --keep=1 --secbits=5 --user=cyberax --caps=cap_net_bind_service+eip -- -c
> 'nc -l 443'
> 
> So is it possible at all?
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

      reply	other threads:[~2014-09-16 23:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-15 13:07 Aleksei Besogonov
2014-09-16 23:41 ` Junien Fridrick [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140916234130.GA12369@jambon.ath.cx \
    --to=linux.kernel@junien.fridrick.net \
    --cc=alex.besogonov@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®