You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jena.apache.org by "Dan Pritts (JIRA)" <ji...@apache.org> on 2016/07/29 22:08:20 UTC
[jira] [Updated] (JENA-1219) fuseki init script problems -
FUSEKI_USER doesn't work - shell quoting wonky
[ https://issues.apache.org/jira/browse/JENA-1219?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Dan Pritts updated JENA-1219:
-----------------------------
Description:
another init script issue.
If FUSEKI_USER is defined, the script attempts to su to that user. Here's the original code snippet.
su - "$FUSEKI_USER" -c "
log_daemon_msg "Redirecting Fuseki stderr/stdout to $FUSEKI_LOGS_STDERROUT"
exec ${RUN_CMD[*]} &> '$FUSEKI_LOGS_STDERROUT' &
disown \$!
echo \$! > '$FUSEKI_PID'"
There are several problems with this.
0) log_daemon_msg doesn't exist in this subshell so it throws an error. I filed a separate bug about this.
1) the quoting is problematic, so as written, it doesn't successfully start the software.
I think what happens is that the double-quote before the word "Redirecting" closes out the argument to -c
then the exec happens, but the FUSEKI_LOGS_STDERROROUT is not expanded because it's inside single quotes. So no log, or possibly there's a file sitting somewhere called literally $FUSEKI_LOGS_STDERROROUT - but only if the FUSEKI_USER has permissions to write in the current directory.
Without the log file, I'm not sure why it doesn't start properly, i didn't troubleshoot further down this path.
2) Normally if you "exec" something, the exec'd program *replaces* the running process. Since the script has the & to background the process, it does that instead. Weird. It's counter-intuitive, though, and unless there's a good reason to have the exec I would suggest removing it. It seems like the subshell + background + disown should provide the functionality that you would normally expect from exec.
I would suggest the following, but I'm not entirely sure of the design goal behind the code snippet so i am not sure it meets the needs.
su "$FUSEKI_USER" -c "
echo Redirecting Fuseki stderr/stdout to $FUSEKI_LOGS_STDERROUT
${RUN_CMD[*]} &> $FUSEKI_LOGS_STDERROUT &
disown \$!
echo \$! > $FUSEKI_PID "
was:
another init script issue.
If FUSEKI_USER is defined, the script attempts to su to that user. Here's the original code snippet.
su - "$FUSEKI_USER" -c "
log_daemon_msg "Redirecting Fuseki stderr/stdout to $FUSEKI_LOGS_STDERROUT"
exec ${RUN_CMD[*]} &> '$FUSEKI_LOGS_STDERROUT' &
disown \$!
echo \$! > '$FUSEKI_PID'"
There are several problems with this.
0) log_daemon_msg doesn't exist in this subshell so it throws an error. I filed a separate bug about this.
1) the quoting is problematic, so as written, it doesn't successfully start the software.
I think what happens is that the double-quote before the word `Redirecting` closes out the argument to `-c`;
then the exec happens, but the FUSEKI_LOGS_STDERROROUT is not expanded because it's inside single quotes.
Without the log file, I'm not sure why it doesn't start properly, i didn't troubleshoot further down this path.
2) if you "exec" something, the exec'd program *replaces* the running process, so the "disown" and "echo" command never have a chance to run.
I would suggest the following, but I'm not entirely sure of the design goal behind the code snippet so i am not sure it meets the needs.
su "$FUSEKI_USER" -c "
echo Redirecting Fuseki stderr/stdout to $FUSEKI_LOGS_STDERROUT
${RUN_CMD[*]} &> $FUSEKI_LOGS_STDERROUT &
disown \$!
echo \$! > $FUSEKI_PID "
> fuseki init script problems - FUSEKI_USER doesn't work - shell quoting wonky
> ----------------------------------------------------------------------------
>
> Key: JENA-1219
> URL: https://issues.apache.org/jira/browse/JENA-1219
> Project: Apache Jena
> Issue Type: Bug
> Components: Fuseki
> Affects Versions: Fuseki 2.3.1
> Environment: RHEL 6
> Reporter: Dan Pritts
> Priority: Minor
>
> another init script issue.
> If FUSEKI_USER is defined, the script attempts to su to that user. Here's the original code snippet.
> su - "$FUSEKI_USER" -c "
> log_daemon_msg "Redirecting Fuseki stderr/stdout to $FUSEKI_LOGS_STDERROUT"
> exec ${RUN_CMD[*]} &> '$FUSEKI_LOGS_STDERROUT' &
> disown \$!
> echo \$! > '$FUSEKI_PID'"
> There are several problems with this.
> 0) log_daemon_msg doesn't exist in this subshell so it throws an error. I filed a separate bug about this.
> 1) the quoting is problematic, so as written, it doesn't successfully start the software.
> I think what happens is that the double-quote before the word "Redirecting" closes out the argument to -c
> then the exec happens, but the FUSEKI_LOGS_STDERROROUT is not expanded because it's inside single quotes. So no log, or possibly there's a file sitting somewhere called literally $FUSEKI_LOGS_STDERROROUT - but only if the FUSEKI_USER has permissions to write in the current directory.
> Without the log file, I'm not sure why it doesn't start properly, i didn't troubleshoot further down this path.
> 2) Normally if you "exec" something, the exec'd program *replaces* the running process. Since the script has the & to background the process, it does that instead. Weird. It's counter-intuitive, though, and unless there's a good reason to have the exec I would suggest removing it. It seems like the subshell + background + disown should provide the functionality that you would normally expect from exec.
> I would suggest the following, but I'm not entirely sure of the design goal behind the code snippet so i am not sure it meets the needs.
> su "$FUSEKI_USER" -c "
> echo Redirecting Fuseki stderr/stdout to $FUSEKI_LOGS_STDERROUT
> ${RUN_CMD[*]} &> $FUSEKI_LOGS_STDERROUT &
> disown \$!
> echo \$! > $FUSEKI_PID "
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)