[ https://issues.apache.org/jira/browse/RANGER-1275?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Qiang Zhang updated RANGER-1275: -------------------------------- Description: At the beginning of the security-admin/scripts/setup.sh file there are three logical errors. 1. The logic to judgment if the install.properties file exists is wrong . The reason for the error is that the author doesn't understand the meaning of the "$?" correctly in shell script. 2. The "/var/run/ranger" path is very important. So the program should determine whether the directory has been created successfully. 3. The following error occurred if the 'log "$PROPFILE file not found....!!";' could be executed. ./setup.sh: line 27: log: command not found =========================================================== Code error analysis is as follow: 1. code PROPFILE=$PWD/install.properties pidFolderName='/var/run/ranger' mkdir -p ${pidFolderName} propertyValue='' if [ ! $? = "0" ];then log "$PROPFILE file not found....!!"; exit 1; fi 2. analysis 1). The "$?" is the result value of the "propertyValue=''" in (if [ ! $? = "0" ];then). So the (! $? = "0") expression is always equal to false, the (log "$PROPFILE file not found....!!") code always can't be executed. 2). The log function should be declared before execute. So the following error occurred when execute the (log "$PROPFILE file not found....!!") code. ./setup.sh: line 27: log: command not found =========================================================== Reproducible Steps: ------------------------------------------------------------------------------- 1. Run "mv install.properties install.properties.bak" command. 2. Run setup.sh. Result: The following statements will not be executed. log "$PROPFILE file not found....!!"; exit 1; --------------------------------------------------------------------------------------- 1. Comment out the line 26 and 29 lines and add "exit 0" at the 30 line in the security-admin/scripts/setup.sh file. 2. Run setup.sh. Result. ./setup.sh: line 27: log: command not found was: At the beginning of the security-admin/scripts/setup.sh file there are three logical errors. 1. The judgment logic that the install.properties file exists is wrong. The reason for the error is that the author doesn't understand the meaning of the "$?" correctly in shell script. 2. The "/var/run/ranger" path is very important. So the program should determine whether the directory to create success. 3. The following error occurred if the 'log "$PROPFILE file not found....!!";' could be executed. ./setup.sh: line 27: log: command not found =========================================================== Code error analysis is as follows: 1. code PROPFILE=$PWD/install.properties pidFolderName='/var/run/ranger' mkdir -p ${pidFolderName} propertyValue='' if [ ! $? = "0" ];then log "$PROPFILE file not found....!!"; exit 1; fi 2. analysis 1). The "$?" is the result value of the "propertyValue=''" in (if [ ! $? = "0" ];then). So the (! $? = "0") expression is always equal to false, the (log "$PROPFILE file not found....!!") code has always been unable to execute. 2). The log function is declared at the back. So the following error occurred if executing the (log "$PROPFILE file not found....!!") code. ./setup.sh: line 27: log: command not found =========================================================== Reproducible Steps: ------------------------------------------------------------------------------- 1. Run "mv install.properties install.properties.bak" command. 2. Run setup.sh. Result: The following statement was not executed. log "$PROPFILE file not found....!!"; exit 1; --------------------------------------------------------------------------------------- 1. Comment out the line 26 and 29 lines and add "exit 0" at the 30 line in the security-admin/scripts/setup.sh file. 2. Run setup.sh. Result. ./setup.sh: line 27: log: command not found > At the beginning of the security-admin/scripts/setup.sh file there are three > logical errors. > -------------------------------------------------------------------------------------------- > > Key: RANGER-1275 > URL: https://issues.apache.org/jira/browse/RANGER-1275 > Project: Ranger > Issue Type: Bug > Components: admin > Reporter: Qiang Zhang > Assignee: Qiang Zhang > Labels: patch > Attachments: > 0001-RANGER-1275-At-the-beginning-of-the-security-admin-s.patch > > > At the beginning of the security-admin/scripts/setup.sh file there are three > logical errors. > 1. The logic to judgment if the install.properties file exists is wrong . The > reason for the error is that the author doesn't understand the meaning of the > "$?" correctly in shell script. > 2. The "/var/run/ranger" path is very important. So the program should > determine whether the directory has been created successfully. > 3. The following error occurred if the 'log "$PROPFILE file not > found....!!";' could be executed. > ./setup.sh: line 27: log: command not found > =========================================================== > Code error analysis is as follow: > 1. code > PROPFILE=$PWD/install.properties > pidFolderName='/var/run/ranger' > mkdir -p ${pidFolderName} > propertyValue='' > if [ ! $? = "0" ];then > log "$PROPFILE file not found....!!"; > exit 1; > fi > 2. analysis > 1). The "$?" is the result value of the "propertyValue=''" in (if [ ! $? = > "0" ];then). So the (! $? = "0") expression is always equal to false, the > (log "$PROPFILE file not found....!!") code always can't be executed. > 2). The log function should be declared before execute. So the following > error occurred when execute the (log "$PROPFILE file not found....!!") code. > ./setup.sh: line 27: log: command not found > =========================================================== > Reproducible Steps: > ------------------------------------------------------------------------------- > 1. Run "mv install.properties install.properties.bak" command. > 2. Run setup.sh. > Result: > The following statements will not be executed. > log "$PROPFILE file not found....!!"; > exit 1; > --------------------------------------------------------------------------------------- > 1. Comment out the line 26 and 29 lines and add "exit 0" at the 30 line in > the security-admin/scripts/setup.sh file. > 2. Run setup.sh. > Result. > ./setup.sh: line 27: log: command not found -- This message was sent by Atlassian JIRA (v6.3.4#6332)