Further systemd cleanups
v2 cover Further systemd cleanups
From: David Sommerseth <[email protected]...>
This replaces patch 2/4 [1] and patch 3/4 [2] of the last round, just fixing up things from the review.
Patch 1/4 [3] got an ACK and have been applied, while patch 4/4 [4] will be considered in a bigger scope.
[1] <http://thread.gmane.org/gmane.network.openvpn.devel/9023/focus=9024>
[2] <http://thread.gmane.org/gmane.network.openvpn.devel/9023/focus=9020>
[3] <http://thread.gmane.org/gmane.network.openvpn.devel/9023/focus=9021>
[4] <http://thread.gmane.org/gmane.network.openvpn.devel/9023/focus=9022>
David Sommerseth (2):
Don't try to use systemd-ask-password if it is not available Clean up the pipe closing in openvpn_popen()
src/openvpn/console.c | 8 +++++--- src/openvpn/misc.c | 18 ++++++++++-------- 2 files changed, 15 insertions(+), 11 deletions(-)
Signature · 1 line
1.8.3.1
PATCH v2 1/2 Don't try to use systemd-ask-password if it is not available
From: David Sommerseth <[email protected]...>
If the SYSTEMD_ASK_PASSWORD_PATH executable cannot be found, we don't consider systemd as running.
[v2 - Don't clean up white-space]
--- src/openvpn/console.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
src/openvpn/console.c +5 -3
@@ -143,14 +143,16 @@ close_tty (FILE *fp)static bool check_systemd_running () { -struct stat a, b; +struct stat a, b, c;/* We simply test whether the systemd cgroup hierarchy is -* mounted */ +* mounted, as well as the systemd-ask-password executable +* being available */ return (lstat ("/sys/fs/cgroup" , &a) ==0 ) && (lstat ("/sys/fs/cgroup/systemd" , &b) ==0 ) - && (a.st_dev != b.st_dev); + && (a.st_dev != b.st_dev) + && (stat (SYSTEMD_ASK_PASSWORD_PATH , &c) ==0 ); }
Signature · 1 line
1.8.3.1
Re: [Openvpn-devel] [PATCH v2 1/2] Don't try to use systemd-ask-password if it is not available
HI,
Quoted 6 lines · David Sommerseth
From: David Sommerseth <[email protected]...>
If the
SYSTEMD_ASK_PASSWORD_PATHexecutable cannot be found, we don't consider systemd as running.[v2 - Don't clean up white-space]
ACK, useful functionality, code looks good.
Not tested, no systemd here :)
gert
Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
//www.muc.de/~gert/
Gert Doering - Munich, Germany [email protected]...
fax: +49-89-35655025 [email protected]...Re: [Openvpn-devel] [PATCH applied] Don't try to use systemd-ask-password if it is not available
From: David Sommerseth <[email protected]...>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Your patch has been applied to the master branch.
commit 55480682b9bfa5894402954f4c740954d8c5c556
Author: David Sommerseth Date: Tue Sep 9 18:58:53 2014 +0200
Don't try to use systemd-ask-password if it is not available
Signed-off-by: David Sommerseth <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Message-Id: [email protected]...
URL: http://article.gmane.org/gmane.network.openvpn.devel/9035- --
kind regards,
David Sommerseth
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
iEYEARECAAYFAlQQIBgACgkQDC186MBRfrrmGwCeLLbMGsy9UWVsiwa9VccXqEPM sv4An1JriTjXb+jky6FtDtlbVBFo+3ca
=HIyT
-----END PGP SIGNATURE-----
PATCH v2 2/2 Clean up the pipe closing in openvpn_popen()
In reply to David SommersethFrom: David Sommerseth <[email protected]...>
Do the proper closing of the pipe ends which is not being used, also in error situations. Moved the closing of the parent side before the waitpid(), to be consistent with the child side (as early as possible).
Also improved the error messages with more details.
[v2 - Don't call close() if execve() fails]
--- src/openvpn/misc.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)
src/openvpn/misc.c +10 -8
@@ -365,27 +365,29 @@ openvpn_popen (const struct argv *a, const struct env_set *es) pid =fork ();if (pid == (pid_t )0 )/* child side */ { -close (pipe_stdout[0 ]); +close (pipe_stdout[0 ]);/* Close read end */ dup2 (pipe_stdout[1 ],1 );execve (cmd, argv, envp);exit (127 ); } -else if (pid < (pid_t )0 )/* fork failed */ - { -msg (M_ERR ,"openvpn_popen: unable to fork" ); - } -else /* parent side */ +else if (pid > (pid_t )0 )/* parent side */ {int status =0 ; +close (pipe_stdout[1 ]);/* Close write end */ waitpid (pid, &status,0 ); ret = pipe_stdout[0 ]; + } +else /* fork failed */ + { +close (pipe_stdout[0 ]);close (pipe_stdout[1 ]); +msg (M_ERR ,"openvpn_popen: unable to fork %s" , cmd); } }else { -msg (M_WARN ,"openvpn_popen: unable to create stdout pipe" ); - ret =-1 ; +msg (M_WARN ,"openvpn_popen: unable to create stdout pipe for %s" , cmd); + ret =-1 ; } }else if (!warn_shown && (script_security <SSEC_SCRIPTS ))
Signature · 1 line
1.8.3.1
Re: [Openvpn-devel] [PATCH v2 2/2] Clean up the pipe closing in openvpn_popen()
Hi,
Quoted 10 lines · David Sommerseth
From: David Sommerseth <[email protected]...>
Do the proper closing of the pipe ends which is not being used, also in error situations. Moved the closing of the parent side before the
waitpid(), to be consistent with the child side (as early as possible).Also improved the error messages with more details.
[v2 - Don't call
close()ifexecve()fails]
ACK. Looks good to me.
gert
Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
//www.muc.de/~gert/
Gert Doering - Munich, Germany [email protected]...
fax: +49-89-35655025 [email protected]...Re: [Openvpn-devel] [PATCH applied] Clean up the pipe closing in openvpn_popen()
From: David Sommerseth <[email protected]...>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Your patch has been applied to the master branch.
commit df8ebb21ad1957ec013ab832a0f6c18e9d6744f6
Author: David Sommerseth Date: Fri Sep 5 17:04:58 2014 +0200
Clean up the pipe closing in openvpn_popen()
Signed-off-by: David Sommerseth <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Message-Id: [email protected]...
URL: http://article.gmane.org/gmane.network.openvpn.devel/9036- --
kind regards,
David Sommerseth
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
iEYEARECAAYFAlQQIEIACgkQDC186MBRfrr2kgCgn3G0L2jUoqysmn4WU46+5Qg9 lNYAoIxNovrd6Ca4Oy962+ZqTNkbtDNF
=mMdO
-----END PGP SIGNATURE-----