From efee76e1848e21cc9c98ce24162508405ff53e81 Mon Sep 17 00:00:00 2001 From: Pierre Fersing Date: Thu, 22 Jun 2017 11:07:15 +0200 Subject: [PATCH] Create PID dir is not existent --- .../src/main/patches/sh.script.in | 19 +++++++++++++++++++ .../jsw/no-generator-configurations-run.sh | 19 +++++++++++++++++++ .../mojo/appassembler/daemon/jsw/run-1.sh | 19 +++++++++++++++++++ .../mojo/appassembler/daemon/jsw/run-14.sh | 19 +++++++++++++++++++ .../mojo/appassembler/daemon/jsw/run-8.sh | 19 +++++++++++++++++++ .../mojo/appassembler/daemon/jsw/run-9.sh | 19 +++++++++++++++++++ 6 files changed, 114 insertions(+) diff --git a/appassembler-maven-plugin/src/main/patches/sh.script.in b/appassembler-maven-plugin/src/main/patches/sh.script.in index 9242db83..eb8dd91e 100644 --- a/appassembler-maven-plugin/src/main/patches/sh.script.in +++ b/appassembler-maven-plugin/src/main/patches/sh.script.in @@ -297,6 +297,13 @@ then fi fi +# If $PIDDIR is in a tmpfs (typically /var/run) the PIDDIR it is likely to not exists. +# Make sure the folder exists +if [ ! -d "$PIDDIR" ]; then + _PIDIR_CREATED=1 + mkdir "$PIDDIR" +fi + checkUser() { # $1 touchLock flag # $2 command @@ -343,6 +350,18 @@ checkUser() { chown $RUN_AS_USER:$RUN_AS_GROUP $LOCKFILE fi fi + # If $RUN_AS_USER is defined and PIDDIR was created, the new user it will not be + # able to create the pid file. Make sure new user has permission over PIDDIR. + if [ "X$_PIDIR_CREATED" != "X" ] + then + # Resolve the primary group + RUN_AS_GROUP=`groups $RUN_AS_USER | awk '{print $3}' | tail -1` + if [ "X$RUN_AS_GROUP" = "X" ] + then + RUN_AS_GROUP=$RUN_AS_USER + fi + chown $RUN_AS_USER:$RUN_AS_GROUP "$PIDDIR" + fi # Still want to change users, recurse. This means that the user will only be # prompted for a password once. Variables shifted by 1 diff --git a/appassembler-maven-plugin/src/test/resources/org/codehaus/mojo/appassembler/daemon/jsw/no-generator-configurations-run.sh b/appassembler-maven-plugin/src/test/resources/org/codehaus/mojo/appassembler/daemon/jsw/no-generator-configurations-run.sh index b0c3d1e1..b00b6341 100644 --- a/appassembler-maven-plugin/src/test/resources/org/codehaus/mojo/appassembler/daemon/jsw/no-generator-configurations-run.sh +++ b/appassembler-maven-plugin/src/test/resources/org/codehaus/mojo/appassembler/daemon/jsw/no-generator-configurations-run.sh @@ -297,6 +297,13 @@ then fi fi +# If $PIDDIR is in a tmpfs (typically /var/run) the PIDDIR it is likely to not exists. +# Make sure the folder exists +if [ ! -d "$PIDDIR" ]; then + _PIDIR_CREATED=1 + mkdir "$PIDDIR" +fi + checkUser() { # $1 touchLock flag # $2 command @@ -343,6 +350,18 @@ checkUser() { chown $RUN_AS_USER:$RUN_AS_GROUP $LOCKFILE fi fi + # If $RUN_AS_USER is defined and PIDDIR was created, the new user it will not be + # able to create the pid file. Make sure new user has permission over PIDDIR. + if [ "X$_PIDIR_CREATED" != "X" ] + then + # Resolve the primary group + RUN_AS_GROUP=`groups $RUN_AS_USER | awk '{print $3}' | tail -1` + if [ "X$RUN_AS_GROUP" = "X" ] + then + RUN_AS_GROUP=$RUN_AS_USER + fi + chown $RUN_AS_USER:$RUN_AS_GROUP "$PIDDIR" + fi # Still want to change users, recurse. This means that the user will only be # prompted for a password once. Variables shifted by 1 diff --git a/appassembler-maven-plugin/src/test/resources/org/codehaus/mojo/appassembler/daemon/jsw/run-1.sh b/appassembler-maven-plugin/src/test/resources/org/codehaus/mojo/appassembler/daemon/jsw/run-1.sh index b0c3d1e1..b00b6341 100644 --- a/appassembler-maven-plugin/src/test/resources/org/codehaus/mojo/appassembler/daemon/jsw/run-1.sh +++ b/appassembler-maven-plugin/src/test/resources/org/codehaus/mojo/appassembler/daemon/jsw/run-1.sh @@ -297,6 +297,13 @@ then fi fi +# If $PIDDIR is in a tmpfs (typically /var/run) the PIDDIR it is likely to not exists. +# Make sure the folder exists +if [ ! -d "$PIDDIR" ]; then + _PIDIR_CREATED=1 + mkdir "$PIDDIR" +fi + checkUser() { # $1 touchLock flag # $2 command @@ -343,6 +350,18 @@ checkUser() { chown $RUN_AS_USER:$RUN_AS_GROUP $LOCKFILE fi fi + # If $RUN_AS_USER is defined and PIDDIR was created, the new user it will not be + # able to create the pid file. Make sure new user has permission over PIDDIR. + if [ "X$_PIDIR_CREATED" != "X" ] + then + # Resolve the primary group + RUN_AS_GROUP=`groups $RUN_AS_USER | awk '{print $3}' | tail -1` + if [ "X$RUN_AS_GROUP" = "X" ] + then + RUN_AS_GROUP=$RUN_AS_USER + fi + chown $RUN_AS_USER:$RUN_AS_GROUP "$PIDDIR" + fi # Still want to change users, recurse. This means that the user will only be # prompted for a password once. Variables shifted by 1 diff --git a/appassembler-maven-plugin/src/test/resources/org/codehaus/mojo/appassembler/daemon/jsw/run-14.sh b/appassembler-maven-plugin/src/test/resources/org/codehaus/mojo/appassembler/daemon/jsw/run-14.sh index 7cdf69aa..28e91049 100644 --- a/appassembler-maven-plugin/src/test/resources/org/codehaus/mojo/appassembler/daemon/jsw/run-14.sh +++ b/appassembler-maven-plugin/src/test/resources/org/codehaus/mojo/appassembler/daemon/jsw/run-14.sh @@ -297,6 +297,13 @@ then fi fi +# If $PIDDIR is in a tmpfs (typically /var/run) the PIDDIR it is likely to not exists. +# Make sure the folder exists +if [ ! -d "$PIDDIR" ]; then + _PIDIR_CREATED=1 + mkdir "$PIDDIR" +fi + checkUser() { # $1 touchLock flag # $2 command @@ -343,6 +350,18 @@ checkUser() { chown $RUN_AS_USER:$RUN_AS_GROUP $LOCKFILE fi fi + # If $RUN_AS_USER is defined and PIDDIR was created, the new user it will not be + # able to create the pid file. Make sure new user has permission over PIDDIR. + if [ "X$_PIDIR_CREATED" != "X" ] + then + # Resolve the primary group + RUN_AS_GROUP=`groups $RUN_AS_USER | awk '{print $3}' | tail -1` + if [ "X$RUN_AS_GROUP" = "X" ] + then + RUN_AS_GROUP=$RUN_AS_USER + fi + chown $RUN_AS_USER:$RUN_AS_GROUP "$PIDDIR" + fi # Still want to change users, recurse. This means that the user will only be # prompted for a password once. Variables shifted by 1 diff --git a/appassembler-maven-plugin/src/test/resources/org/codehaus/mojo/appassembler/daemon/jsw/run-8.sh b/appassembler-maven-plugin/src/test/resources/org/codehaus/mojo/appassembler/daemon/jsw/run-8.sh index 0f0d790e..bf0a63dc 100644 --- a/appassembler-maven-plugin/src/test/resources/org/codehaus/mojo/appassembler/daemon/jsw/run-8.sh +++ b/appassembler-maven-plugin/src/test/resources/org/codehaus/mojo/appassembler/daemon/jsw/run-8.sh @@ -297,6 +297,13 @@ then fi fi +# If $PIDDIR is in a tmpfs (typically /var/run) the PIDDIR it is likely to not exists. +# Make sure the folder exists +if [ ! -d "$PIDDIR" ]; then + _PIDIR_CREATED=1 + mkdir "$PIDDIR" +fi + checkUser() { # $1 touchLock flag # $2 command @@ -343,6 +350,18 @@ checkUser() { chown $RUN_AS_USER:$RUN_AS_GROUP $LOCKFILE fi fi + # If $RUN_AS_USER is defined and PIDDIR was created, the new user it will not be + # able to create the pid file. Make sure new user has permission over PIDDIR. + if [ "X$_PIDIR_CREATED" != "X" ] + then + # Resolve the primary group + RUN_AS_GROUP=`groups $RUN_AS_USER | awk '{print $3}' | tail -1` + if [ "X$RUN_AS_GROUP" = "X" ] + then + RUN_AS_GROUP=$RUN_AS_USER + fi + chown $RUN_AS_USER:$RUN_AS_GROUP "$PIDDIR" + fi # Still want to change users, recurse. This means that the user will only be # prompted for a password once. Variables shifted by 1 diff --git a/appassembler-maven-plugin/src/test/resources/org/codehaus/mojo/appassembler/daemon/jsw/run-9.sh b/appassembler-maven-plugin/src/test/resources/org/codehaus/mojo/appassembler/daemon/jsw/run-9.sh index 3370adec..159ed22c 100644 --- a/appassembler-maven-plugin/src/test/resources/org/codehaus/mojo/appassembler/daemon/jsw/run-9.sh +++ b/appassembler-maven-plugin/src/test/resources/org/codehaus/mojo/appassembler/daemon/jsw/run-9.sh @@ -297,6 +297,13 @@ then fi fi +# If $PIDDIR is in a tmpfs (typically /var/run) the PIDDIR it is likely to not exists. +# Make sure the folder exists +if [ ! -d "$PIDDIR" ]; then + _PIDIR_CREATED=1 + mkdir "$PIDDIR" +fi + checkUser() { # $1 touchLock flag # $2 command @@ -343,6 +350,18 @@ checkUser() { chown $RUN_AS_USER:$RUN_AS_GROUP $LOCKFILE fi fi + # If $RUN_AS_USER is defined and PIDDIR was created, the new user it will not be + # able to create the pid file. Make sure new user has permission over PIDDIR. + if [ "X$_PIDIR_CREATED" != "X" ] + then + # Resolve the primary group + RUN_AS_GROUP=`groups $RUN_AS_USER | awk '{print $3}' | tail -1` + if [ "X$RUN_AS_GROUP" = "X" ] + then + RUN_AS_GROUP=$RUN_AS_USER + fi + chown $RUN_AS_USER:$RUN_AS_GROUP "$PIDDIR" + fi # Still want to change users, recurse. This means that the user will only be # prompted for a password once. Variables shifted by 1