diff --git a/nifi/nifi-assembly/pom.xml b/nifi/nifi-assembly/pom.xml index 9b17617b2a..c679d22ab5 100644 --- a/nifi/nifi-assembly/pom.xml +++ b/nifi/nifi-assembly/pom.xml @@ -35,6 +35,11 @@ language governing permissions and limitations under the License. --> package + + 0775 + 0775 + 0664 + src/main/assembly/dependencies.xml diff --git a/nifi/nifi-assembly/src/main/assembly/dependencies.xml b/nifi/nifi-assembly/src/main/assembly/dependencies.xml index a3e3a18597..243d0acc37 100644 --- a/nifi/nifi-assembly/src/main/assembly/dependencies.xml +++ b/nifi/nifi-assembly/src/main/assembly/dependencies.xml @@ -29,8 +29,8 @@ runtime false lib - 0750 - 0640 + 0770 + 0660 true nifi-bootstrap @@ -44,8 +44,8 @@ runtime false lib/bootstrap - 0750 - 0640 + 0770 + 0660 true nifi-bootstrap @@ -59,8 +59,8 @@ runtime false ./ - 0750 - 0640 + 0770 + 0664 true nifi-resources @@ -79,8 +79,8 @@ runtime false ./ - 0750 - 0750 + 0770 + 0770 true nifi-resources diff --git a/nifi/nifi-bootstrap/src/main/java/org/apache/nifi/bootstrap/RunNiFi.java b/nifi/nifi-bootstrap/src/main/java/org/apache/nifi/bootstrap/RunNiFi.java index 2bc44cc726..a48a1de455 100644 --- a/nifi/nifi-bootstrap/src/main/java/org/apache/nifi/bootstrap/RunNiFi.java +++ b/nifi/nifi-bootstrap/src/main/java/org/apache/nifi/bootstrap/RunNiFi.java @@ -728,20 +728,8 @@ public class RunNiFi { final NiFiListener listener = new NiFiListener(); final int listenPort = listener.start(this); - String runAs = isWindows() ? null : props.get(RUN_AS_PROP); - if (runAs != null) { - runAs = runAs.trim(); - if (runAs.isEmpty()) { - runAs = null; - } - } - final List cmd = new ArrayList<>(); - if (runAs != null) { - cmd.add("sudo"); - cmd.add("-u"); - cmd.add(runAs); - } + cmd.add(javaCmd); cmd.add("-classpath"); cmd.add(classPath); diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-resources/src/main/resources/bin/nifi.sh b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-resources/src/main/resources/bin/nifi.sh old mode 100644 new mode 100755 index 8caf55e84d..01a3f81b18 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-resources/src/main/resources/bin/nifi.sh +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-resources/src/main/resources/bin/nifi.sh @@ -151,9 +151,26 @@ install() { run() { BOOTSTRAP_CONF="$NIFI_HOME/conf/bootstrap.conf"; + run_as=$(grep run.as ${BOOTSTRAP_CONF} | cut -d'=' -f2) + + sudo_cmd_prefix="" if $cygwin; then + if [[ -n "$run_as" ]]; then + echo "The run.as option is not supported in a Cygwin environment. Exiting." + exit 1 + fi; + NIFI_HOME=`cygpath --path --windows "$NIFI_HOME"` BOOTSTRAP_CONF=`cygpath --path --windows "$BOOTSTRAP_CONF"` + else + if [[ -n "$run_as" ]]; then + if id -u "$run_as" >/dev/null 2>&1; then + sudo_cmd_prefix="sudo -u ${run_as}" + else + echo "The specified run.as user ${run_as} does not exist. Exiting." + exit 1 + fi + fi; fi echo @@ -166,9 +183,9 @@ run() { # run 'start' in the background because the process will continue to run, monitoring NiFi. # all other commands will terminate quickly so want to just wait for them if [ "$1" = "start" ]; then - ("$JAVA" -cp "$NIFI_HOME"/conf/:"$NIFI_HOME"/lib/bootstrap/* -Xms12m -Xmx24m -Dorg.apache.nifi.bootstrap.config.file="$BOOTSTRAP_CONF" org.apache.nifi.bootstrap.RunNiFi $@ &) + (${sudo_cmd_prefix} "$JAVA" -cp "$NIFI_HOME"/conf/:"$NIFI_HOME"/lib/bootstrap/* -Xms12m -Xmx24m -Dorg.apache.nifi.bootstrap.config.file="$BOOTSTRAP_CONF" org.apache.nifi.bootstrap.RunNiFi $@ &) else - "$JAVA" -cp "$NIFI_HOME"/conf/:"$NIFI_HOME"/lib/bootstrap/* -Xms12m -Xmx24m -Dorg.apache.nifi.bootstrap.config.file="$BOOTSTRAP_CONF" org.apache.nifi.bootstrap.RunNiFi $@ + ${sudo_cmd_prefix} "$JAVA" -cp "$NIFI_HOME"/conf/:"$NIFI_HOME"/lib/bootstrap/* -Xms12m -Xmx24m -Dorg.apache.nifi.bootstrap.config.file="$BOOTSTRAP_CONF" org.apache.nifi.bootstrap.RunNiFi $@ fi # Wait just a bit (3 secs) to wait for the logging to finish and then echo a new-line.