All of lore.kernel.org
 help / color / mirror / Atom feed
From: "André Draszik" <git@andred.net>
To: yocto@yoctoproject.org
Subject: [meta-security][PATCH] trousers: make initscript more reliable
Date: Wed,  1 Nov 2017 11:16:32 +0000	[thread overview]
Message-ID: <20171101111632.19287-1-git@andred.net> (raw)

From: André Draszik <adraszik@tycoint.com>

The combination of using start-stop-daemon and pidof is
not working reliably in all cases. Sometimes, the
tcsd daemon isn't running yet at the time pidof is being
invoked.

This results in an empty /var/run/tcsd.pid, making it
impossible to stop tcsd using the init script.

To solve this, one could either add a delay before calling
pidof, or alternatively use start-stop-daemon's built-in
functionality to achieve the same.

Let's do the latter.

Signed-off-by: André Draszik <adraszik@tycoint.com>
---
 meta-tpm/recipes-tpm/trousers/files/trousers.init.sh | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/meta-tpm/recipes-tpm/trousers/files/trousers.init.sh b/meta-tpm/recipes-tpm/trousers/files/trousers.init.sh
index 0ecf7cc..d0d6cb3 100644
--- a/meta-tpm/recipes-tpm/trousers/files/trousers.init.sh
+++ b/meta-tpm/recipes-tpm/trousers/files/trousers.init.sh
@@ -33,10 +33,12 @@ case "${1}" in
 			exit 0
 		fi
 
-		start-stop-daemon --start --quiet --oknodo --pidfile /var/run/${NAME}.pid --user ${USER} --chuid ${USER} --exec ${DAEMON} -- ${DAEMON_OPTS}
+		start-stop-daemon --start --quiet --oknodo \
+			--pidfile /var/run/${NAME}.pid --make-pidfile --background \
+			--user ${USER} --chuid ${USER} \
+			--exec ${DAEMON} -- ${DAEMON_OPTS} --foreground
 		RETVAL="$?"
 		echo "$NAME."
-		[ "$RETVAL" = 0 ] && pidof $DAEMON > /var/run/${NAME}.pid
 		exit $RETVAL
 		;;
 
-- 
2.15.0.rc1



                 reply	other threads:[~2017-11-01 11:16 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171101111632.19287-1-git@andred.net \
    --to=git@andred.net \
    --cc=yocto@yoctoproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.