[MNT-17279] alfresco.sh does not avoid root execution Created: 16-Dec-16  Updated: 26-Feb-19  Resolved: 02-May-18

Status: Closed
Project: Service Packs and Hot Fixes
Component/s: Installer
Affects Version/s: 5.1.1
Fix Version/s: None

Type: Service Pack Request
Reporter: Dwayne Ray Assignee: Closed Issues
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
Bug Priority:
Category 3
ACT Numbers:

00784120


 Description   

The alfresco.sh script has a typo that causes the root execution prevention to fail. The "$2" should be "$1". Specifically, this section from the alfresco.sh script contains an error:

# Avoid root execution
if [ `id|sed -e s/uid=//g -e s/\(.*//g` -eq 0 ] && [ $2 != "stop" ]; then
    echo "Execution by root not allowed"
    exit 1
fi

This should be:

# Avoid root execution
if [ `id|sed -e s/uid=//g -e s/\(.*//g` -eq 0 ] && [ $1 != "stop" ]; then
    echo "Execution by root not allowed"
    exit 1
fi

[Steps to reproduce]
1. Install Alfresco 5.1 on Linux as a non-root user
2. Switch to the root user ("su")
3. As root, attempt to start Alfresco using the alfresco.sh script:

./alfresco.sh start

[Expected Behaviour]
The alfresco.sh script should prevent root execution:

[root@localhost alfresco-5.1.1.4]# ./alfresco.sh start
Execution by root not allowed

[Observed Behaviour]
The following message is displayed, then Alfresco starts as expected:

[root@localhost alfresco-5.1.1.4]# ./alfresco.sh start
./alfresco.sh: line 4: [: !=: unary operator expected


Generated at Tue Aug 04 06:47:17 BST 2020 using JIRA 7.6.3#76005-sha1:8a4e38d34af948780dbf52044e7aafb13a7cae58.