LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (http://www.linuxquestions.org/questions/slackware-14/)
-   -   Since Slackware doesn't provide the runuser command... (http://www.linuxquestions.org/questions/slackware-14/since-slackware-doesnt-provide-the-runuser-command-4175498212/)

Richard Cranium 03-14-2014 03:33 PM

Since Slackware doesn't provide the runuser command...
 
...could the Slackware maintainers change line 226 in /etc/rc.d/init.d/functions from
Code:

$nice runuser -s /bin/bash - $user -c "$corelimit >/dev/null 2>&1 ; $*"
to
Code:

$nice su -s /bin/bash $user -c "$corelimit >/dev/null 2>&1 ; $*"
...?

That line is in the daemon function defined in the file and it just won't work if you attempt to run a service as some user other than root.


This is all coming about from my recompiling mongoDB with SSL support. If anyone else wants to do that, make sure that:
  1. You have 8G of free space available on the partition where you are building it.
  2. You don't attempt to compile the stable version (2.4.9). The current unstable version (2.5.5) compiles just fine and you can tell it to use the system boost and system pcre libraries.

Didier Spaier 03-14-2014 04:07 PM

Someone *could* want to install runuser (and PAM). Else you could just "ln -s /bin/su /bin/runuser" as suggested in this thread.

Oh, and in the sentence "...could the Slackware maintainers [...]" the plural form is not necessary, as AFAIK there is only one Slackware maintainer ;)

Richard Cranium 03-14-2014 08:09 PM

Quote:

Originally Posted by Didier Spaier (Post 5134674)
Else you could just "ln -s /bin/su /bin/runuser" as suggested in this thread.

There's something not quite correct with that approach.

With the symlink:
Code:

root@testbed:~# /etc/rc.d/rc.mongodb start
Starting mongod: No directory, logging in with HOME=/
                                                          [  OK  ]

Without the symlink and my suggested version:
Code:

root@testbed:~# /etc/rc.d/rc.mongodb start
Starting mongod:                                          [  OK  ]


The command line handling between runuser and su is not exactly the same. That's why I'm replacing
Code:

$nice runuser -s /bin/bash - $user -c "$corelimit >/dev/null 2>&1 ; $*"
with
Code:

$nice su -s /bin/bash $user -c "$corelimit >/dev/null 2>&1 ; $*"
Note the omitted dash.

It may well be the case that the "su" code looks to see what name was used to invoke it and attempts to act accordingly. (I haven't bothered to look since this is a problem encountered when solving another problem.) If that's the case, the attempt appears to not be working 100%. I find the error message troubling but haven't checked to see what the ramifications are. The daemon in question appears to be otherwise running correctly.

I didn't quote it, but your comment about users that install PAM would have a problem with this change is a fair point.

FWIW, I've looked at a current CentOS system (well, we use RedHat at work damn it) and the current versions of the functions file contains cgroup support which I should think those users would also miss.

Since the symlink approach appears to work (despite the error message), I'll mark this as SOLVED.

mancha 03-14-2014 09:45 PM

Maybe we can default to runuser and fallback to su:

Code:

--- a/etc/init.d/functions
+++ b/etc/init.d/functions
@@ -223,7 +223,8 @@ daemon() {
        if [ -z "$user" ]; then
          $nice /bin/bash -c "$corelimit >/dev/null 2>&1 ; $*"
        else
-          $nice runuser -s /bin/bash - $user -c "$corelimit >/dev/null 2>&1 ; $*"
+          [ -n "$(which runuser 2>/dev/null)" ] && RUNUSERCOMM="runuser -s /bin/bash -" || RUNUSERCOMM="su -s /bin/bash"
+          $nice $RUNUSERCOMM $user -c "$corelimit >/dev/null 2>&1 ; $*"
        fi
        [ "$?" -eq 0 ] && success $"$base startup" || failure $"$base startup"
 }

--mancha


All times are GMT -5. The time now is 06:14 AM.