LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 09-19-2011, 03:29 AM   #1
spongetron
Member
 
Registered: Apr 2010
Distribution: Slackware
Posts: 61

Rep: Reputation: Disabled
Strating service with normal user credentials


I installed Openfire (http://www.igniterealtime.org) from the *.tar.gz under /opt/openfire.

I want to run Openfire as user openfire. I added the user openfire with home directory /opt/openfire, shell is /bin/false and i also created a group openfire. I changed the rights on the openfire directory:
Code:
chown -Rv openfire:openfire /opt/openfire
I copied the following script from the openfire extras directory to /etc/rc.d/rc.openfired and made it executable. Under OPENFIRE_USER i put the user openfire.

Code:
#!/bin/sh

# openfired     stops and starts the openfire XMPP service
#
# chkconfig: 2345 99 1
# description: Used to start and stop the openfire XMPP server
#
# Script used to start openfire as daemon
# The script has currently been tested on Redhat Fedora Core 3,
# but should theoretically work on most UNIX like systems
#
# before running this script make sure $OPENFIRE_HOME/bin/openfire is
# executable by the user you want to run openfire as
# (chmod +x $OPENFIRE_HOME/bin/openfire)
#
# This script should be copied into /etc/init.d and linked into
# your default runlevel directory.
# You can find your default runlevel directory by typing:
# grep default /etc/inittab
#
# Link to the directory like follows
# cd /etc/rc<num>.d
# ln -s ../init.d/openfired $90openfired
#

# Set this to tell this script where openfire lives
# If this is not set the script will look for /opt/openfire, then /usr/local/openfire
export OPENFIRE_HOME=/opt/openfire

# If there is a different user you would like to run this script as,
# change the following line
export OPENFIRE_USER=openfire

# -----------------------------------------------------------------

# If a openfire home variable has not been specified, try to determine it
if [ ! $OPENFIRE_HOME ]; then
        if [ -d "/opt/openfire" ]; then
                OPENFIRE_HOME="/opt/openfire"
        elif [ -d "/usr/local/openfire" ]; then
                OPENFIRE_HOME="/usr/local/openfire"
        else
                echo "Could not find Openfire installation under /opt or /usr/local"
                echo "Please specify the Openfire installation location in environment variable OPENFIRE_HOME"
                exit 1
        fi
fi


execCommand() {
        OLD_PWD=`pwd`
        cd $OPENFIRE_HOME/bin
        CMD="./openfire $1"
        su -c "$CMD" $OPENFIRE_USER &
        sleep 1 # allows prompt to return
        cd $OLD_PWD
}


start() {
        execCommand "start"
}

stop() {
        execCommand "stop"
}


case "$1" in
        start)
                start
                ;;
        stop)
                stop
                ;;
        restart)
                stop
                sleep 10 # since stop is backgrounded
                start
                ;;
        status)
                retval=$(pgrep -u $OPENFIRE_USER -f $OPENFIRE_HOME/bin/openfire > /dev/null ; echo $?)
                if [ "$retval" = "0" ] ; then
                        echo "openfire is running"
                        exit 0
                else
                        echo "openfire is not running"
                        exit 0
                fi
                ;;
        *)
                echo "Usage $0 {start|stop|restart|status}"
                exit 1
esac

exit 0
If try to start openfire with
Code:
/etc/rc.d/rc.openfired start
notching happens. If i change the OPENFIRE_USER to root it starts with no problems. Can someone give me a hint what I am doing wrong?
 
Old 09-19-2011, 06:23 AM   #2
cendryon
Member
 
Registered: Aug 2005
Location: France
Distribution: Slackware64 current
Posts: 82

Rep: Reputation: 30
Hi

The culprit is the shell of openfire user, combined with the "su -c" command.
From the su manpage :
Quote:
-c, --command COMMAND
Specify a command that will be invoked by the shell using its -c.
Try changing openfire user's shell from /bin/false to /bin/bash
Code:
usermod -s /bin/bash openfire
Cheers

Last edited by cendryon; 09-19-2011 at 06:29 AM.
 
Old 09-19-2011, 08:39 AM   #3
spongetron
Member
 
Registered: Apr 2010
Distribution: Slackware
Posts: 61

Original Poster
Rep: Reputation: Disabled
Before I saw your post, I deleted my openfire user and created a new one like this:

Code:
useradd -r -d /opt/openfire -g openfire openfire
Like this the user now has /bin/bash as shell and i can start openfire through the script!

Is it true, that I don't not have to set a password for system accounts (useradd -r) and that this account will not be able to logon to the computer?
 
Old 09-19-2011, 01:31 PM   #4
cendryon
Member
 
Registered: Aug 2005
Location: France
Distribution: Slackware64 current
Posts: 82

Rep: Reputation: 30
Quote:
Originally Posted by spongetron View Post
Is it true, that I don't not have to set a password for system accounts (useradd -r) and that this account will not be able to logon to the computer?
Yes, it does. Check /etc/shadow for a ! in the password field.

You can also use the following command to disable (Lock) the openfire login:
Code:
usermod -L openfire
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Run a (service) command as a normal user during start up mycoolwater Linux - Newbie 2 10-13-2009 04:59 PM
Why are user credentials not being passed to server at time of login? rajevar Linux - Newbie 2 09-24-2009 03:57 PM
Turning off samba user credentials cache behradb Linux - Server 1 04-23-2009 03:32 AM
JCIFS: authenticating user credentials borgy_t Programming 0 04-17-2005 10:29 PM
Samba rejecting user credentials carmstrong Linux - Networking 3 05-18-2004 09:21 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 04:07 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration