[PATCH] inetd as unprivileged user

2017-10-31 Thread Jack Schmidt
When I tried to use inetd as an unprivileged user on linux (4.9.x, x86_64, 
glibc or musl), I get:

inetd: can't set groups: Operation not permitted

I believe the problem is line 1486, where it compares the desired uid to 0, 
rather than to the current uid, to decide whether to set groups.

For example:

printf '127.0.0.1:3030 stream tcp nowait jack ./echo.sh' > inetd.conf
printf '#!/bin/sh\necho ok\nsleep 1' > echo.sh
chmod 755 echo.sh
./busybox inetd -e -f inetd.conf &
nc 127.0.0.1 3030

With the patch, it echoes "ok".

Without the patch, inetd gives an error:

inetd: can't set groups: Operation not permitted


Of course, to placate line 1486 one could use:

printf '127.0.0.1:3030 stream tcp nowait root ./echo.sh' > inetd.conf

but this results in the earlier error:

inetd: non-root must run services as himself





inetd-setgroups-fix.diff
Description: Binary data
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox

Re: [PATCH] inetd as unprivileged user

2017-11-09 Thread Denys Vlasenko
Fixed, thanks!

On Wed, Nov 1, 2017 at 3:19 AM, Jack Schmidt  wrote:
> When I tried to use inetd as an unprivileged user on linux (4.9.x, x86_64, 
> glibc or musl), I get:
>
> inetd: can't set groups: Operation not permitted
>
> I believe the problem is line 1486, where it compares the desired uid to 0, 
> rather than to the current uid, to decide whether to set groups.
>
> For example:
>
> printf '127.0.0.1:3030 stream tcp nowait jack ./echo.sh' > inetd.conf
> printf '#!/bin/sh\necho ok\nsleep 1' > echo.sh
> chmod 755 echo.sh
> ./busybox inetd -e -f inetd.conf &
> nc 127.0.0.1 3030
>
> With the patch, it echoes "ok".
>
> Without the patch, inetd gives an error:
>
> inetd: can't set groups: Operation not permitted
>
>
> Of course, to placate line 1486 one could use:
>
> printf '127.0.0.1:3030 stream tcp nowait root ./echo.sh' > inetd.conf
>
> but this results in the earlier error:
>
> inetd: non-root must run services as himself
>
>
>
>
> ___
> busybox mailing list
> busybox@busybox.net
> http://lists.busybox.net/mailman/listinfo/busybox
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox