[jira] [Commented] (NIFI-3294) NiFi will ignore nifi-env properties when running as another user
[ https://issues.apache.org/jira/browse/NIFI-3294?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15880517#comment-15880517 ] ASF GitHub Bot commented on NIFI-3294: -- Github user apiri commented on the issue: https://github.com/apache/nifi/pull/1525 Great, thanks. Will do. > NiFi will ignore nifi-env properties when running as another user > - > > Key: NIFI-3294 > URL: https://issues.apache.org/jira/browse/NIFI-3294 > Project: Apache NiFi > Issue Type: Bug > Components: Configuration >Affects Versions: 1.0.0, 0.7.0, 0.7.1, 1.1.1, 1.0.1 > Environment: All non-Windows, non-Cygwin OSes >Reporter: Aldrin Piri >Assignee: Aldrin Piri > Fix For: 0.8.0, 1.2.0 > > > nifi-env is a script that allows setting of certain properties external to > the core run scripts. However, when sudo is used, the resulting > subshell/child process is a separate environment that does not have the > needed information that was established in nifi-env. This needs to be > incorporated into the run command such that those properties are preserved. -- This message was sent by Atlassian JIRA (v6.3.15#6346)
[jira] [Commented] (NIFI-3294) NiFi will ignore nifi-env properties when running as another user
[ https://issues.apache.org/jira/browse/NIFI-3294?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15880518#comment-15880518 ] ASF GitHub Bot commented on NIFI-3294: -- Github user apiri closed the pull request at: https://github.com/apache/nifi/pull/1525 > NiFi will ignore nifi-env properties when running as another user > - > > Key: NIFI-3294 > URL: https://issues.apache.org/jira/browse/NIFI-3294 > Project: Apache NiFi > Issue Type: Bug > Components: Configuration >Affects Versions: 1.0.0, 0.7.0, 0.7.1, 1.1.1, 1.0.1 > Environment: All non-Windows, non-Cygwin OSes >Reporter: Aldrin Piri >Assignee: Aldrin Piri > Fix For: 0.8.0, 1.2.0 > > > nifi-env is a script that allows setting of certain properties external to > the core run scripts. However, when sudo is used, the resulting > subshell/child process is a separate environment that does not have the > needed information that was established in nifi-env. This needs to be > incorporated into the run command such that those properties are preserved. -- This message was sent by Atlassian JIRA (v6.3.15#6346)
[jira] [Commented] (NIFI-3294) NiFi will ignore nifi-env properties when running as another user
[ https://issues.apache.org/jira/browse/NIFI-3294?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15879520#comment-15879520 ] ASF GitHub Bot commented on NIFI-3294: -- Github user ijokarumawak commented on the issue: https://github.com/apache/nifi/pull/1525 Confirmed with/without `run.as` configuration the shell worked, with 'restart', 'stop', 'start', 'run' ... etc. LGTM +1. Squashed and merged into 0.x branch. @apiri Would you manually close this PR? Thanks! > NiFi will ignore nifi-env properties when running as another user > - > > Key: NIFI-3294 > URL: https://issues.apache.org/jira/browse/NIFI-3294 > Project: Apache NiFi > Issue Type: Bug > Components: Configuration >Affects Versions: 1.0.0, 0.7.0, 0.7.1, 1.1.1, 1.0.1 > Environment: All non-Windows, non-Cygwin OSes >Reporter: Aldrin Piri >Assignee: Aldrin Piri > Fix For: 0.8.0, 1.2.0 > > > nifi-env is a script that allows setting of certain properties external to > the core run scripts. However, when sudo is used, the resulting > subshell/child process is a separate environment that does not have the > needed information that was established in nifi-env. This needs to be > incorporated into the run command such that those properties are preserved. -- This message was sent by Atlassian JIRA (v6.3.15#6346)
[jira] [Commented] (NIFI-3294) NiFi will ignore nifi-env properties when running as another user
[ https://issues.apache.org/jira/browse/NIFI-3294?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15879500#comment-15879500 ] ASF subversion and git services commented on NIFI-3294: --- Commit 9a5487cde360116ec309dce9eb526b2364632f33 in nifi's branch refs/heads/0.x from [~aldrin] [ https://git-wip-us.apache.org/repos/asf?p=nifi.git;h=9a5487c ] NIFI-3294 Adjusting nifi.sh to invoke nifi-env.sh when running as another user such that properties are preserved across environments. Updating nifi.sh to include improvements by NIFI-2689 This closes #1525. Signed-off-by: ijokarumawak> NiFi will ignore nifi-env properties when running as another user > - > > Key: NIFI-3294 > URL: https://issues.apache.org/jira/browse/NIFI-3294 > Project: Apache NiFi > Issue Type: Bug > Components: Configuration >Affects Versions: 1.0.0, 0.7.0, 0.7.1, 1.1.1, 1.0.1 > Environment: All non-Windows, non-Cygwin OSes >Reporter: Aldrin Piri >Assignee: Aldrin Piri > Fix For: 0.8.0, 1.2.0 > > > nifi-env is a script that allows setting of certain properties external to > the core run scripts. However, when sudo is used, the resulting > subshell/child process is a separate environment that does not have the > needed information that was established in nifi-env. This needs to be > incorporated into the run command such that those properties are preserved. -- This message was sent by Atlassian JIRA (v6.3.15#6346)
[jira] [Commented] (NIFI-3294) NiFi will ignore nifi-env properties when running as another user
[ https://issues.apache.org/jira/browse/NIFI-3294?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15879435#comment-15879435 ] ASF GitHub Bot commented on NIFI-3294: -- Github user ijokarumawak commented on the issue: https://github.com/apache/nifi/pull/1525 Thanks for updating. Reviewing.. > NiFi will ignore nifi-env properties when running as another user > - > > Key: NIFI-3294 > URL: https://issues.apache.org/jira/browse/NIFI-3294 > Project: Apache NiFi > Issue Type: Bug > Components: Configuration >Affects Versions: 1.0.0, 0.7.0, 0.7.1, 1.1.1, 1.0.1 > Environment: All non-Windows, non-Cygwin OSes >Reporter: Aldrin Piri >Assignee: Aldrin Piri > Fix For: 0.8.0, 1.2.0 > > > nifi-env is a script that allows setting of certain properties external to > the core run scripts. However, when sudo is used, the resulting > subshell/child process is a separate environment that does not have the > needed information that was established in nifi-env. This needs to be > incorporated into the run command such that those properties are preserved. -- This message was sent by Atlassian JIRA (v6.3.15#6346)
[jira] [Commented] (NIFI-3294) NiFi will ignore nifi-env properties when running as another user
[ https://issues.apache.org/jira/browse/NIFI-3294?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15878525#comment-15878525 ] ASF GitHub Bot commented on NIFI-3294: -- Github user apiri commented on the issue: https://github.com/apache/nifi/pull/1525 @ijokarumawak Added the changes per #1523. > NiFi will ignore nifi-env properties when running as another user > - > > Key: NIFI-3294 > URL: https://issues.apache.org/jira/browse/NIFI-3294 > Project: Apache NiFi > Issue Type: Bug > Components: Configuration >Affects Versions: 1.0.0, 0.7.0, 0.7.1, 1.1.1, 1.0.1 > Environment: All non-Windows, non-Cygwin OSes >Reporter: Aldrin Piri >Assignee: Aldrin Piri > Fix For: 0.8.0, 1.2.0 > > > nifi-env is a script that allows setting of certain properties external to > the core run scripts. However, when sudo is used, the resulting > subshell/child process is a separate environment that does not have the > needed information that was established in nifi-env. This needs to be > incorporated into the run command such that those properties are preserved. -- This message was sent by Atlassian JIRA (v6.3.15#6346)
[jira] [Commented] (NIFI-3294) NiFi will ignore nifi-env properties when running as another user
[ https://issues.apache.org/jira/browse/NIFI-3294?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15878512#comment-15878512 ] ASF GitHub Bot commented on NIFI-3294: -- Github user apiri commented on the issue: https://github.com/apache/nifi/pull/1525 Will incorporate that into here as well and resubmit. > NiFi will ignore nifi-env properties when running as another user > - > > Key: NIFI-3294 > URL: https://issues.apache.org/jira/browse/NIFI-3294 > Project: Apache NiFi > Issue Type: Bug > Components: Configuration >Affects Versions: 1.0.0, 0.7.0, 0.7.1, 1.1.1, 1.0.1 > Environment: All non-Windows, non-Cygwin OSes >Reporter: Aldrin Piri >Assignee: Aldrin Piri > Fix For: 0.8.0, 1.2.0 > > > nifi-env is a script that allows setting of certain properties external to > the core run scripts. However, when sudo is used, the resulting > subshell/child process is a separate environment that does not have the > needed information that was established in nifi-env. This needs to be > incorporated into the run command such that those properties are preserved. -- This message was sent by Atlassian JIRA (v6.3.15#6346)
[jira] [Commented] (NIFI-3294) NiFi will ignore nifi-env properties when running as another user
[ https://issues.apache.org/jira/browse/NIFI-3294?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15876740#comment-15876740 ] ASF GitHub Bot commented on NIFI-3294: -- Github user apiri commented on the issue: https://github.com/apache/nifi/pull/1525 @ijokarumawak - did some testing and had similar results > NiFi will ignore nifi-env properties when running as another user > - > > Key: NIFI-3294 > URL: https://issues.apache.org/jira/browse/NIFI-3294 > Project: Apache NiFi > Issue Type: Bug > Components: Configuration >Affects Versions: 1.0.0, 0.7.0, 0.7.1, 1.1.1, 1.0.1 > Environment: All non-Windows, non-Cygwin OSes >Reporter: Aldrin Piri >Assignee: Aldrin Piri > Fix For: 0.8.0, 1.2.0 > > > nifi-env is a script that allows setting of certain properties external to > the core run scripts. However, when sudo is used, the resulting > subshell/child process is a separate environment that does not have the > needed information that was established in nifi-env. This needs to be > incorporated into the run command such that those properties are preserved. -- This message was sent by Atlassian JIRA (v6.3.15#6346)
[jira] [Commented] (NIFI-3294) NiFi will ignore nifi-env properties when running as another user
[ https://issues.apache.org/jira/browse/NIFI-3294?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15876738#comment-15876738 ] ASF GitHub Bot commented on NIFI-3294: -- GitHub user apiri opened a pull request: https://github.com/apache/nifi/pull/1525 NIFI-3294 (0.x) - Adjusting nifi.sh to invoke nifi-env.sh when running as ano… …ther user such that properties are preserved across environments. Updating nifi.sh to include improvements by NIFI-2689 Thank you for submitting a contribution to Apache NiFi. In order to streamline the review of the contribution we ask you to ensure the following steps have been taken: ### For all changes: - [X] Is there a JIRA ticket associated with this PR? Is it referenced in the commit message? - [X] Does your PR title start with NIFI- where is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character. - [X] Has your PR been rebased against the latest commit within the target branch (typically master)? - [X] Is your initial contribution a single, squashed commit? ### For code changes: - [X] Have you ensured that the full suite of tests is executed via mvn -Pcontrib-check clean install at the root nifi folder? - [-] Have you written or updated unit tests to verify your changes? - [-] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)? - [-] If applicable, have you updated the LICENSE file, including the main LICENSE file under nifi-assembly? - [-] If applicable, have you updated the NOTICE file, including the main NOTICE file found under nifi-assembly? - [-] If adding new Properties, have you added .displayName in addition to .name (programmatic access) for each of the new properties? ### For documentation related changes: - [-] Have you ensured that format looks appropriate for the output in which it is rendered? ### Note: Please ensure that once the PR is submitted, you check travis-ci for build issues and submit an update to your PR as soon as possible. You can merge this pull request into a Git repository by running: $ git pull https://github.com/apiri/incubator-nifi NIFI-3294-0.x Alternatively you can review and apply these changes as the patch at: https://github.com/apache/nifi/pull/1525.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #1525 commit a0c5334b7bdd3358ae6b4811756d385ca09c454e Author: Aldrin PiriDate: 2017-02-21T21:15:20Z NIFI-3294 Adjusting nifi.sh to invoke nifi-env.sh when running as another user such that properties are preserved across environments. Updating nifi.sh to include improvements by NIFI-2689 > NiFi will ignore nifi-env properties when running as another user > - > > Key: NIFI-3294 > URL: https://issues.apache.org/jira/browse/NIFI-3294 > Project: Apache NiFi > Issue Type: Bug > Components: Configuration >Affects Versions: 1.0.0, 0.7.0, 0.7.1, 1.1.1, 1.0.1 > Environment: All non-Windows, non-Cygwin OSes >Reporter: Aldrin Piri >Assignee: Aldrin Piri > Fix For: 0.8.0, 1.2.0 > > > nifi-env is a script that allows setting of certain properties external to > the core run scripts. However, when sudo is used, the resulting > subshell/child process is a separate environment that does not have the > needed information that was established in nifi-env. This needs to be > incorporated into the run command such that those properties are preserved. -- This message was sent by Atlassian JIRA (v6.3.15#6346)
[jira] [Commented] (NIFI-3294) NiFi will ignore nifi-env properties when running as another user
[ https://issues.apache.org/jira/browse/NIFI-3294?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15873955#comment-15873955 ] Koji Kawamura commented on NIFI-3294: - [~aldrin] I've merged PR1405 to master branch, but it can't be applied to 0.x branch. Would you create another PR targeting 0.x branch? > NiFi will ignore nifi-env properties when running as another user > - > > Key: NIFI-3294 > URL: https://issues.apache.org/jira/browse/NIFI-3294 > Project: Apache NiFi > Issue Type: Bug > Components: Configuration >Affects Versions: 1.0.0, 0.7.0, 0.7.1, 1.1.1, 1.0.1 > Environment: All non-Windows, non-Cygwin OSes >Reporter: Aldrin Piri >Assignee: Aldrin Piri > Fix For: 0.8.0, 1.2.0 > > > nifi-env is a script that allows setting of certain properties external to > the core run scripts. However, when sudo is used, the resulting > subshell/child process is a separate environment that does not have the > needed information that was established in nifi-env. This needs to be > incorporated into the run command such that those properties are preserved. -- This message was sent by Atlassian JIRA (v6.3.15#6346)
[jira] [Commented] (NIFI-3294) NiFi will ignore nifi-env properties when running as another user
[ https://issues.apache.org/jira/browse/NIFI-3294?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15873949#comment-15873949 ] ASF GitHub Bot commented on NIFI-3294: -- Github user asfgit closed the pull request at: https://github.com/apache/nifi/pull/1405 > NiFi will ignore nifi-env properties when running as another user > - > > Key: NIFI-3294 > URL: https://issues.apache.org/jira/browse/NIFI-3294 > Project: Apache NiFi > Issue Type: Bug > Components: Configuration >Affects Versions: 1.0.0, 0.7.0, 0.7.1, 1.1.1, 1.0.1 > Environment: All non-Windows, non-Cygwin OSes >Reporter: Aldrin Piri >Assignee: Aldrin Piri > Fix For: 0.8.0, 1.2.0 > > > nifi-env is a script that allows setting of certain properties external to > the core run scripts. However, when sudo is used, the resulting > subshell/child process is a separate environment that does not have the > needed information that was established in nifi-env. This needs to be > incorporated into the run command such that those properties are preserved. -- This message was sent by Atlassian JIRA (v6.3.15#6346)
[jira] [Commented] (NIFI-3294) NiFi will ignore nifi-env properties when running as another user
[ https://issues.apache.org/jira/browse/NIFI-3294?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15873946#comment-15873946 ] ASF GitHub Bot commented on NIFI-3294: -- Github user ijokarumawak commented on the issue: https://github.com/apache/nifi/pull/1405 @apiri Thanks for the fix. Confirmed it runs with/without run.as configuration. LGTM +1. Merging into master. > NiFi will ignore nifi-env properties when running as another user > - > > Key: NIFI-3294 > URL: https://issues.apache.org/jira/browse/NIFI-3294 > Project: Apache NiFi > Issue Type: Bug > Components: Configuration >Affects Versions: 1.0.0, 0.7.0, 0.7.1, 1.1.1, 1.0.1 > Environment: All non-Windows, non-Cygwin OSes >Reporter: Aldrin Piri >Assignee: Aldrin Piri > Fix For: 0.8.0, 1.2.0 > > > nifi-env is a script that allows setting of certain properties external to > the core run scripts. However, when sudo is used, the resulting > subshell/child process is a separate environment that does not have the > needed information that was established in nifi-env. This needs to be > incorporated into the run command such that those properties are preserved. -- This message was sent by Atlassian JIRA (v6.3.15#6346)
[jira] [Commented] (NIFI-3294) NiFi will ignore nifi-env properties when running as another user
[ https://issues.apache.org/jira/browse/NIFI-3294?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15872148#comment-15872148 ] ASF GitHub Bot commented on NIFI-3294: -- Github user apiri commented on the issue: https://github.com/apache/nifi/pull/1405 @ijokarumawak Okay should be good to go now, rolled the arg capture to the main command here https://github.com/apache/nifi/pull/1405/files#diff-0242d48c1b4267348183977fd0cf8966R289 and then additionally went through and tightened up quoting to avoid any issues with possible paths including spaces. > NiFi will ignore nifi-env properties when running as another user > - > > Key: NIFI-3294 > URL: https://issues.apache.org/jira/browse/NIFI-3294 > Project: Apache NiFi > Issue Type: Bug > Components: Configuration >Affects Versions: 1.0.0, 0.7.0, 0.7.1, 1.1.1, 1.0.1 > Environment: All non-Windows, non-Cygwin OSes >Reporter: Aldrin Piri >Assignee: Aldrin Piri > Fix For: 0.8.0, 1.2.0 > > > nifi-env is a script that allows setting of certain properties external to > the core run scripts. However, when sudo is used, the resulting > subshell/child process is a separate environment that does not have the > needed information that was established in nifi-env. This needs to be > incorporated into the run command such that those properties are preserved. -- This message was sent by Atlassian JIRA (v6.3.15#6346)
[jira] [Commented] (NIFI-3294) NiFi will ignore nifi-env properties when running as another user
[ https://issues.apache.org/jira/browse/NIFI-3294?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15871948#comment-15871948 ] ASF GitHub Bot commented on NIFI-3294: -- Github user apiri commented on a diff in the pull request: https://github.com/apache/nifi/pull/1405#discussion_r101775516 --- Diff: nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-resources/src/main/resources/bin/nifi.sh --- @@ -284,18 +281,21 @@ run() { # all other commands will terminate quickly so want to just wait for them #setup directory parameters - BOOTSTRAP_LOG_PARAMS="-Dorg.apache.nifi.bootstrap.config.log.dir="\""${NIFI_LOG_DIR}"\""" - BOOTSTRAP_PID_PARAMS="-Dorg.apache.nifi.bootstrap.config.pid.dir="\""${NIFI_PID_DIR}"\""" - BOOTSTRAP_CONF_PARAMS="-Dorg.apache.nifi.bootstrap.config.file="\""${BOOTSTRAP_CONF}"\""" + BOOTSTRAP_LOG_PARAMS="-Dorg.apache.nifi.bootstrap.config.log.dir=\"${NIFI_LOG_DIR}\"" + BOOTSTRAP_PID_PARAMS="-Dorg.apache.nifi.bootstrap.config.pid.dir=\"${NIFI_PID_DIR}\"" + BOOTSTRAP_CONF_PARAMS="-Dorg.apache.nifi.bootstrap.config.file=\"${BOOTSTRAP_CONF}\"" BOOTSTRAP_DIR_PARAMS="${BOOTSTRAP_LOG_PARAMS} ${BOOTSTRAP_PID_PARAMS} ${BOOTSTRAP_CONF_PARAMS}" - -RUN_NIFI_CMD="cd "\""${NIFI_HOME}"\"" && exec ${sudo_cmd_prefix} "\""${JAVA}"\"" -cp "\""${BOOTSTRAP_CLASSPATH}"\"" -Xms12m -Xmx24m ${BOOTSTRAP_DIR_PARAMS} org.apache.nifi.bootstrap.RunNiFi" +run_nifi_cmd="exec ${JAVA} -cp ${BOOTSTRAP_CLASSPATH} -Xms12m -Xmx24m ${BOOTSTRAP_DIR_PARAMS} org.apache.nifi.bootstrap.RunNiFi" +if [ -n "${run_as_user}" ]; then + # Provide SCRIPT_DIR to nifi-env for the run.as user + run_nifi_cmd="sudo -u ${run_as_user} sh -c 'SCRIPT_DIR=${SCRIPT_DIR} && . ${SCRIPT_DIR}/nifi-env.sh && ${run_nifi_cmd} $@'" +fi if [ "$1" = "start" ]; then -(eval $RUN_NIFI_CMD $@ &) +(eval "cd ${NIFI_HOME} && ${run_nifi_cmd}" &) else -eval $RUN_NIFI_CMD $@ +eval "cd ${NIFI_HOME} && ${run_nifi_cmd}" --- End diff -- yep, messed up the conflict resolution, thanks for catching. will adjust and submit. > NiFi will ignore nifi-env properties when running as another user > - > > Key: NIFI-3294 > URL: https://issues.apache.org/jira/browse/NIFI-3294 > Project: Apache NiFi > Issue Type: Bug > Components: Configuration >Affects Versions: 1.0.0, 0.7.0, 0.7.1, 1.1.1, 1.0.1 > Environment: All non-Windows, non-Cygwin OSes >Reporter: Aldrin Piri >Assignee: Aldrin Piri > Fix For: 0.8.0, 1.2.0 > > > nifi-env is a script that allows setting of certain properties external to > the core run scripts. However, when sudo is used, the resulting > subshell/child process is a separate environment that does not have the > needed information that was established in nifi-env. This needs to be > incorporated into the run command such that those properties are preserved. -- This message was sent by Atlassian JIRA (v6.3.15#6346)
[jira] [Commented] (NIFI-3294) NiFi will ignore nifi-env properties when running as another user
[ https://issues.apache.org/jira/browse/NIFI-3294?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15871409#comment-15871409 ] ASF GitHub Bot commented on NIFI-3294: -- Github user ijokarumawak commented on a diff in the pull request: https://github.com/apache/nifi/pull/1405#discussion_r101703608 --- Diff: nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-resources/src/main/resources/bin/nifi.sh --- @@ -284,18 +281,21 @@ run() { # all other commands will terminate quickly so want to just wait for them #setup directory parameters - BOOTSTRAP_LOG_PARAMS="-Dorg.apache.nifi.bootstrap.config.log.dir="\""${NIFI_LOG_DIR}"\""" - BOOTSTRAP_PID_PARAMS="-Dorg.apache.nifi.bootstrap.config.pid.dir="\""${NIFI_PID_DIR}"\""" - BOOTSTRAP_CONF_PARAMS="-Dorg.apache.nifi.bootstrap.config.file="\""${BOOTSTRAP_CONF}"\""" + BOOTSTRAP_LOG_PARAMS="-Dorg.apache.nifi.bootstrap.config.log.dir=\"${NIFI_LOG_DIR}\"" + BOOTSTRAP_PID_PARAMS="-Dorg.apache.nifi.bootstrap.config.pid.dir=\"${NIFI_PID_DIR}\"" + BOOTSTRAP_CONF_PARAMS="-Dorg.apache.nifi.bootstrap.config.file=\"${BOOTSTRAP_CONF}\"" BOOTSTRAP_DIR_PARAMS="${BOOTSTRAP_LOG_PARAMS} ${BOOTSTRAP_PID_PARAMS} ${BOOTSTRAP_CONF_PARAMS}" - -RUN_NIFI_CMD="cd "\""${NIFI_HOME}"\"" && exec ${sudo_cmd_prefix} "\""${JAVA}"\"" -cp "\""${BOOTSTRAP_CLASSPATH}"\"" -Xms12m -Xmx24m ${BOOTSTRAP_DIR_PARAMS} org.apache.nifi.bootstrap.RunNiFi" +run_nifi_cmd="exec ${JAVA} -cp ${BOOTSTRAP_CLASSPATH} -Xms12m -Xmx24m ${BOOTSTRAP_DIR_PARAMS} org.apache.nifi.bootstrap.RunNiFi" +if [ -n "${run_as_user}" ]; then + # Provide SCRIPT_DIR to nifi-env for the run.as user + run_nifi_cmd="sudo -u ${run_as_user} sh -c 'SCRIPT_DIR=${SCRIPT_DIR} && . ${SCRIPT_DIR}/nifi-env.sh && ${run_nifi_cmd} $@'" +fi if [ "$1" = "start" ]; then -(eval $RUN_NIFI_CMD $@ &) +(eval "cd ${NIFI_HOME} && ${run_nifi_cmd}" &) else -eval $RUN_NIFI_CMD $@ +eval "cd ${NIFI_HOME} && ${run_nifi_cmd}" --- End diff -- `$@` used to be added here before. > NiFi will ignore nifi-env properties when running as another user > - > > Key: NIFI-3294 > URL: https://issues.apache.org/jira/browse/NIFI-3294 > Project: Apache NiFi > Issue Type: Bug > Components: Configuration >Affects Versions: 1.0.0, 0.7.0, 0.7.1, 1.1.1, 1.0.1 > Environment: All non-Windows, non-Cygwin OSes >Reporter: Aldrin Piri >Assignee: Aldrin Piri > Fix For: 0.8.0, 1.2.0 > > > nifi-env is a script that allows setting of certain properties external to > the core run scripts. However, when sudo is used, the resulting > subshell/child process is a separate environment that does not have the > needed information that was established in nifi-env. This needs to be > incorporated into the run command such that those properties are preserved. -- This message was sent by Atlassian JIRA (v6.3.15#6346)
[jira] [Commented] (NIFI-3294) NiFi will ignore nifi-env properties when running as another user
[ https://issues.apache.org/jira/browse/NIFI-3294?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15871410#comment-15871410 ] ASF GitHub Bot commented on NIFI-3294: -- Github user ijokarumawak commented on a diff in the pull request: https://github.com/apache/nifi/pull/1405#discussion_r101703153 --- Diff: nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-resources/src/main/resources/bin/nifi.sh --- @@ -284,18 +281,21 @@ run() { # all other commands will terminate quickly so want to just wait for them #setup directory parameters - BOOTSTRAP_LOG_PARAMS="-Dorg.apache.nifi.bootstrap.config.log.dir="\""${NIFI_LOG_DIR}"\""" - BOOTSTRAP_PID_PARAMS="-Dorg.apache.nifi.bootstrap.config.pid.dir="\""${NIFI_PID_DIR}"\""" - BOOTSTRAP_CONF_PARAMS="-Dorg.apache.nifi.bootstrap.config.file="\""${BOOTSTRAP_CONF}"\""" + BOOTSTRAP_LOG_PARAMS="-Dorg.apache.nifi.bootstrap.config.log.dir=\"${NIFI_LOG_DIR}\"" + BOOTSTRAP_PID_PARAMS="-Dorg.apache.nifi.bootstrap.config.pid.dir=\"${NIFI_PID_DIR}\"" + BOOTSTRAP_CONF_PARAMS="-Dorg.apache.nifi.bootstrap.config.file=\"${BOOTSTRAP_CONF}\"" BOOTSTRAP_DIR_PARAMS="${BOOTSTRAP_LOG_PARAMS} ${BOOTSTRAP_PID_PARAMS} ${BOOTSTRAP_CONF_PARAMS}" - -RUN_NIFI_CMD="cd "\""${NIFI_HOME}"\"" && exec ${sudo_cmd_prefix} "\""${JAVA}"\"" -cp "\""${BOOTSTRAP_CLASSPATH}"\"" -Xms12m -Xmx24m ${BOOTSTRAP_DIR_PARAMS} org.apache.nifi.bootstrap.RunNiFi" +run_nifi_cmd="exec ${JAVA} -cp ${BOOTSTRAP_CLASSPATH} -Xms12m -Xmx24m ${BOOTSTRAP_DIR_PARAMS} org.apache.nifi.bootstrap.RunNiFi" +if [ -n "${run_as_user}" ]; then + # Provide SCRIPT_DIR to nifi-env for the run.as user + run_nifi_cmd="sudo -u ${run_as_user} sh -c 'SCRIPT_DIR=${SCRIPT_DIR} && . ${SCRIPT_DIR}/nifi-env.sh && ${run_nifi_cmd} $@'" --- End diff -- @apiri Without run.as property, nifi.sh didn't work properly. Because this line is the only case that `$@` is added to `run_nifi_cmd`. So, if bootstrap.conf doesn't have `run.as`, the arguments of nifi.sh won't be passed to RunNiFi class. > NiFi will ignore nifi-env properties when running as another user > - > > Key: NIFI-3294 > URL: https://issues.apache.org/jira/browse/NIFI-3294 > Project: Apache NiFi > Issue Type: Bug > Components: Configuration >Affects Versions: 1.0.0, 0.7.0, 0.7.1, 1.1.1, 1.0.1 > Environment: All non-Windows, non-Cygwin OSes >Reporter: Aldrin Piri >Assignee: Aldrin Piri > Fix For: 0.8.0, 1.2.0 > > > nifi-env is a script that allows setting of certain properties external to > the core run scripts. However, when sudo is used, the resulting > subshell/child process is a separate environment that does not have the > needed information that was established in nifi-env. This needs to be > incorporated into the run command such that those properties are preserved. -- This message was sent by Atlassian JIRA (v6.3.15#6346)
[jira] [Commented] (NIFI-3294) NiFi will ignore nifi-env properties when running as another user
[ https://issues.apache.org/jira/browse/NIFI-3294?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15870795#comment-15870795 ] ASF GitHub Bot commented on NIFI-3294: -- Github user apiri commented on the issue: https://github.com/apache/nifi/pull/1405 @ijokarumawak Believe I have corrected the issue. Created a similar flow of GenerateFlowFile -> UpdateAttribute -> LogAttribute and verified successful passing of environment variables into NiFi. The updated commit additionally merged in the changes to resolve the previous conflict. > NiFi will ignore nifi-env properties when running as another user > - > > Key: NIFI-3294 > URL: https://issues.apache.org/jira/browse/NIFI-3294 > Project: Apache NiFi > Issue Type: Bug > Components: Configuration >Affects Versions: 1.0.0, 0.7.0, 0.7.1, 1.1.1, 1.0.1 > Environment: All non-Windows, non-Cygwin OSes >Reporter: Aldrin Piri >Assignee: Aldrin Piri > Fix For: 0.8.0, 1.2.0 > > > nifi-env is a script that allows setting of certain properties external to > the core run scripts. However, when sudo is used, the resulting > subshell/child process is a separate environment that does not have the > needed information that was established in nifi-env. This needs to be > incorporated into the run command such that those properties are preserved. -- This message was sent by Atlassian JIRA (v6.3.15#6346)
[jira] [Commented] (NIFI-3294) NiFi will ignore nifi-env properties when running as another user
[ https://issues.apache.org/jira/browse/NIFI-3294?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15867961#comment-15867961 ] ASF GitHub Bot commented on NIFI-3294: -- Github user apiri commented on the issue: https://github.com/apache/nifi/pull/1405 okay, will work on adjusting conflicts > NiFi will ignore nifi-env properties when running as another user > - > > Key: NIFI-3294 > URL: https://issues.apache.org/jira/browse/NIFI-3294 > Project: Apache NiFi > Issue Type: Bug > Components: Configuration >Affects Versions: 1.0.0, 0.7.0, 0.7.1, 1.1.1, 1.0.1 > Environment: All non-Windows, non-Cygwin OSes >Reporter: Aldrin Piri >Assignee: Aldrin Piri > Fix For: 0.8.0, 1.2.0 > > > nifi-env is a script that allows setting of certain properties external to > the core run scripts. However, when sudo is used, the resulting > subshell/child process is a separate environment that does not have the > needed information that was established in nifi-env. This needs to be > incorporated into the run command such that those properties are preserved. -- This message was sent by Atlassian JIRA (v6.3.15#6346)
[jira] [Commented] (NIFI-3294) NiFi will ignore nifi-env properties when running as another user
[ https://issues.apache.org/jira/browse/NIFI-3294?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15867381#comment-15867381 ] ASF GitHub Bot commented on NIFI-3294: -- Github user ijokarumawak commented on the issue: https://github.com/apache/nifi/pull/1405 Thanks @apiri , I didn't notice that nifi.sh has conflict. I used latest 1.2.0-SNAPSHOT and replaced nifi.sh with the one in this PR. I'll test it again once the conflict gets addressed. > NiFi will ignore nifi-env properties when running as another user > - > > Key: NIFI-3294 > URL: https://issues.apache.org/jira/browse/NIFI-3294 > Project: Apache NiFi > Issue Type: Bug > Components: Configuration >Affects Versions: 1.0.0, 0.7.0, 0.7.1, 1.1.1, 1.0.1 > Environment: All non-Windows, non-Cygwin OSes >Reporter: Aldrin Piri >Assignee: Aldrin Piri > Fix For: 0.8.0, 1.2.0 > > > nifi-env is a script that allows setting of certain properties external to > the core run scripts. However, when sudo is used, the resulting > subshell/child process is a separate environment that does not have the > needed information that was established in nifi-env. This needs to be > incorporated into the run command such that those properties are preserved. -- This message was sent by Atlassian JIRA (v6.3.15#6346)
[jira] [Commented] (NIFI-3294) NiFi will ignore nifi-env properties when running as another user
[ https://issues.apache.org/jira/browse/NIFI-3294?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15867136#comment-15867136 ] ASF GitHub Bot commented on NIFI-3294: -- Github user apiri commented on the issue: https://github.com/apache/nifi/pull/1405 Was this performed by the PR on its own or applied on top of current master? I see there is a conflict currently. Can evaluate tomorrow. > NiFi will ignore nifi-env properties when running as another user > - > > Key: NIFI-3294 > URL: https://issues.apache.org/jira/browse/NIFI-3294 > Project: Apache NiFi > Issue Type: Bug > Components: Configuration >Affects Versions: 1.0.0, 0.7.0, 0.7.1, 1.1.1, 1.0.1 > Environment: All non-Windows, non-Cygwin OSes >Reporter: Aldrin Piri >Assignee: Aldrin Piri > Fix For: 0.8.0, 1.2.0 > > > nifi-env is a script that allows setting of certain properties external to > the core run scripts. However, when sudo is used, the resulting > subshell/child process is a separate environment that does not have the > needed information that was established in nifi-env. This needs to be > incorporated into the run command such that those properties are preserved. -- This message was sent by Atlassian JIRA (v6.3.15#6346)
[jira] [Commented] (NIFI-3294) NiFi will ignore nifi-env properties when running as another user
[ https://issues.apache.org/jira/browse/NIFI-3294?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15867118#comment-15867118 ] ASF GitHub Bot commented on NIFI-3294: -- Github user ijokarumawak commented on the issue: https://github.com/apache/nifi/pull/1405 I was testing this PR using Amazon Linux. Checking if I can refer ${NIFI_HOME} environmental value via Attribute Expression Language, before and after applying the patch. I set run.as = 'nifi', and execute `bin/nifi.sh start` by root user. ```properties # conf/bootstrap.conf run.as=nifi ``` NiFi flow is simple as: `GenerateFlowFile` using dynamic attribute as `nifi.home` = `${NIFI_HOME}`, also I added `lang` = `${LANG}` to make sure that it can refer OS env values via VariableRegistry. ## Result: Without this PR ```properties nifi.home=(Empty string) lang=en_US.UTF-8 ``` NIFI_HOME was not retrieved as expected. ## Result: With this PR ```properties nifi.home=/mnt lang=en_US.UTF-8 ``` Although NIFI_HOME was retrieved, the value was not the expected one. It should be `/mnt/nifi-1.2.0-SNAPSHOT` but it was just `/mnt`. I also found that without `run.as` property, nifi.sh doesn't work with this PR. It seems Command argument is not passed properly to RunNiFi: ```bash [root@ip-172-31-20-144 nifi-1.2.0-SNAPSHOT-root]# ./bin/nifi.sh status Java home: /usr/lib/jvm/jre NiFi home: /mnt/nifi-1.2.0-SNAPSHOT-root Bootstrap Config File: /mnt/nifi-1.2.0-SNAPSHOT-root/conf/bootstrap.conf Usage: java org.apache.nifi.bootstrap.RunNiFi [<-verbose>] [options] Valid commands include: ... ``` I will keep investigating what's going on but would like to share current status. Please let me know if you noticed something. Thanks! > NiFi will ignore nifi-env properties when running as another user > - > > Key: NIFI-3294 > URL: https://issues.apache.org/jira/browse/NIFI-3294 > Project: Apache NiFi > Issue Type: Bug > Components: Configuration >Affects Versions: 1.0.0, 0.7.0, 0.7.1, 1.1.1, 1.0.1 > Environment: All non-Windows, non-Cygwin OSes >Reporter: Aldrin Piri >Assignee: Aldrin Piri > Fix For: 0.8.0, 1.2.0 > > > nifi-env is a script that allows setting of certain properties external to > the core run scripts. However, when sudo is used, the resulting > subshell/child process is a separate environment that does not have the > needed information that was established in nifi-env. This needs to be > incorporated into the run command such that those properties are preserved. -- This message was sent by Atlassian JIRA (v6.3.15#6346)
[jira] [Commented] (NIFI-3294) NiFi will ignore nifi-env properties when running as another user
[ https://issues.apache.org/jira/browse/NIFI-3294?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15865373#comment-15865373 ] ASF GitHub Bot commented on NIFI-3294: -- Github user ijokarumawak commented on the issue: https://github.com/apache/nifi/pull/1405 Reviewing... > NiFi will ignore nifi-env properties when running as another user > - > > Key: NIFI-3294 > URL: https://issues.apache.org/jira/browse/NIFI-3294 > Project: Apache NiFi > Issue Type: Bug > Components: Configuration >Affects Versions: 1.0.0, 0.7.0, 0.7.1, 1.1.1, 1.0.1 > Environment: All non-Windows, non-Cygwin OSes >Reporter: Aldrin Piri >Assignee: Aldrin Piri > Fix For: 0.8.0, 1.2.0 > > > nifi-env is a script that allows setting of certain properties external to > the core run scripts. However, when sudo is used, the resulting > subshell/child process is a separate environment that does not have the > needed information that was established in nifi-env. This needs to be > incorporated into the run command such that those properties are preserved. -- This message was sent by Atlassian JIRA (v6.3.15#6346)
[jira] [Commented] (NIFI-3294) NiFi will ignore nifi-env properties when running as another user
[ https://issues.apache.org/jira/browse/NIFI-3294?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15806737#comment-15806737 ] ASF GitHub Bot commented on NIFI-3294: -- GitHub user apiri opened a pull request: https://github.com/apache/nifi/pull/1405 NIFI-3294 Adjusting nifi.sh to invoke nifi-env.sh NIFI-3294 Adjusting nifi.sh to invoke nifi-env.sh when running as another user such that properties are preserved across environments. Thank you for submitting a contribution to Apache NiFi. In order to streamline the review of the contribution we ask you to ensure the following steps have been taken: ### For all changes: - [x] Is there a JIRA ticket associated with this PR? Is it referenced in the commit message? - [x] Does your PR title start with NIFI- where is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character. - [x] Has your PR been rebased against the latest commit within the target branch (typically master)? - [x] Is your initial contribution a single, squashed commit? ### For code changes: - [x] Have you ensured that the full suite of tests is executed via mvn -Pcontrib-check clean install at the root nifi folder? You can merge this pull request into a Git repository by running: $ git pull https://github.com/apiri/incubator-nifi nifi-3294 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/nifi/pull/1405.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #1405 commit 92bc346d52a91945a5c76d6dc01f877bc1ee949e Author: Aldrin PiriDate: 2017-01-07T04:20:54Z NIFI-3294 Adjusting nifi.sh to invoke nifi-env.sh when running as another user such that properties are preserved across environments. > NiFi will ignore nifi-env properties when running as another user > - > > Key: NIFI-3294 > URL: https://issues.apache.org/jira/browse/NIFI-3294 > Project: Apache NiFi > Issue Type: Bug > Components: Configuration >Affects Versions: 1.0.0, 0.7.0, 0.7.1, 1.1.1, 1.0.1 > Environment: All non-Windows, non-Cygwin OSes >Reporter: Aldrin Piri >Assignee: Aldrin Piri > Fix For: 0.8.0, 1.2.0 > > > nifi-env is a script that allows setting of certain properties external to > the core run scripts. However, when sudo is used, the resulting > subshell/child process is a separate environment that does not have the > needed information that was established in nifi-env. This needs to be > incorporated into the run command such that those properties are preserved. -- This message was sent by Atlassian JIRA (v6.3.4#6332)