[
https://issues.apache.org/jira/browse/AMQ-9690?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17943319#comment-17943319
]
Rod Allen commented on AMQ-9690:
--------------------------------
the problem appears to be that this function is run before the config is loaded
so the $ACTIVEMQ_USER is always blank and it just runs the first mkdir command
{code:java}
if [ ! -d "$ACTIVEMQ_DATA" ]; then
setCurrentUser
if ( [ -z "$ACTIVEMQ_USER" ] || [ "$ACTIVEMQ_USER" = "$CUSER" ] );then
mkdir $ACTIVEMQ_DATA
elif [ "`id -u`" = "0" ];then
su -c "mkdir $ACTIVEMQ_DATA" - $ACTIVEMQ_USER;
fi
fi {code}
moving this to after the LOAD CONFIGURATION section might be better as then the
value for $ACTIVEMQ_USER would be resolved and the directory would be created
with correct permissions :-
{code:java}
# ------------------------------------------------------------------------
# LOAD CONFIGURATION# CONFIGURATION
# For using instances
if ( basename $0 | grep "activemq-instance-" > /dev/null);then
INST="`basename $0|sed 's/^activemq-instance-//;s/\.sh$//'`"
ACTIVEMQ_CONFIGS="/etc/default/activemq-instance-${INST}
$HOME/.activemqrc-instance-${INST}"
echo "INFO: Using alternative activemq configuration files: $ACTIVEMQ_CONFIGS"
else
ACTIVEMQ_CONFIGS="/etc/default/activemq $HOME/.activemqrc
$ACTIVEMQ_HOME/bin/env"
fi# load activemq configuration
CONFIG_LOAD="no"
for ACTIVEMQ_CONFIG in $ACTIVEMQ_CONFIGS;do
if [ -f "$ACTIVEMQ_CONFIG" ] ; then
( . $ACTIVEMQ_CONFIG >/dev/null 2>&1 )
if [ "$?" != "0" ];then
echo "ERROR: There are syntax errors in '$ACTIVEMQ_CONFIG'"
exit 1
else
echo "INFO: Loading '$ACTIVEMQ_CONFIG'"
. $ACTIVEMQ_CONFIG
CONFIG_LOAD="yes"
break
fi
fi
done
if [ ! -d "$ACTIVEMQ_DATA" ]; then
setCurrentUser
if ( [ -z "$ACTIVEMQ_USER" ] || [ "$ACTIVEMQ_USER" = "$CUSER" ] );then
mkdir $ACTIVEMQ_DATA
elif [ "`id -u`" = "0" ];then
su -c "mkdir $ACTIVEMQ_DATA" - $ACTIVEMQ_USER;
fi
fi
{code}
> activemq always creates the data directory as root when run as an init.d
> service
> --------------------------------------------------------------------------------
>
> Key: AMQ-9690
> URL: https://issues.apache.org/jira/browse/AMQ-9690
> Project: ActiveMQ Classic
> Issue Type: Bug
> Components: Distribution
> Affects Versions: 6.1.6, 5.18.7
> Reporter: Rod Allen
> Priority: Minor
>
> when following instructions from
> [https://activemq.apache.org/components/classic/documentation/unix-shell-script]
> to create an init.d or systemd script, the function in the main activemq
> will create the data directory as the root user even if user is specified in
> the env/setenv and copied to /etc/default/activemq. This can be seen on any
> RHEL 8 like Linux such as Rocky Linux 8. Follow the steps in the linked
> article, delete the $ACTIVEMQ_DATA directory and the service script will
> create the directory as root but cannot be written to as the non-root user so
> the service cannot be stopped. Workaround of course is to just manually
> create the data directory.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact