Gentoo Archives: gentoo-user

From: wabe <wabenbau@×××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] executing a command as a nologin user
Date: Wed, 13 Jul 2016 17:42:05
Message-Id: 20160713194141.54a86f10@hal9000.localdomain
In Reply to: Re: [gentoo-user] executing a command as a nologin user by Fernando Rodriguez
1 Fernando Rodriguez <cyklonite@×××××.com> wrote:
2
3 > -----BEGIN PGP SIGNED MESSAGE-----
4 > Hash: SHA256
5 >
6 > On 07/13/2016 07:10 AM, Alan McKinnon wrote:
7 > > On 12/07/2016 03:47, jens w wrote:
8 > >> .procmailrc
9 > >> :0 c
10 > >> * !^X-Loop: name@×××××××.com
11 > >> | formail -X "From:" | $HOME/bin/script.sh
12 > >>
13 > >> procmail.log
14 > >> procmail: Executing " formail -X "From:" | $HOME/bin/script.sh
15 > >>
16 > >> for incoming mail, a script is executed. logfile has the same
17 > >> entry as it is in other users. but the script do nothing.
18 > >>
19 > >> How executing a command as a nologin user?
20 > >>
21 > >
22 > >
23 > > You can't, not the way you are doing it.
24 > > You want to launch a shell script for the user, but the user's
25 > > shell is /sbin/nologin. This exits immediately without launching
26 > > the script.
27 > >
28 > > Give the user a real shell.
29 > >
30 > > Alan
31 > >
32 >
33 > I've been following this thread and thinking the same thing but
34 > wasn't sure.
35 >
36 > What if you invoke the shell directly instead of the script, either:
37 > /bin/sh -c "<path to script>" or /bin/sh -c "$(cat <script>)"?
38 >
39 > If procmail uses the system() call to launch the script it won't work
40 > but if it uses fork()/exec() or similar I think that it should work.
41
42 I don't know how procmail is launching scripts so I don't know if
43 that what I say now makes sense. :-)
44
45 I tested if another regular user (lets call him user1) can execute
46 scripts that are owned by nologinuser. It works as long as the path
47 and the script itself are readable and executable by user1.
48 If the script is writing stuff into /home/nologinuser then it is
49 also necessary that the home directory is writable by user1.
50
51 Of course user1 hasn't executed the script as nologinuser. I don't
52 know if procmail is doing so.
53
54 --
55 Regards
56 wabe

Replies

Subject Author
Re: [gentoo-user] executing a command as a nologin user Fernando Rodriguez <cyklonite@×××××.com>