Skip to contentSkip to conversation

adding support for systemd tty console wrapper

PATCH In review Frederic Crozat 3 participants 9 messages Oct 31, 2011 – Jan 10, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 adding support for systemd tty console wrapper

Hi,

as part of openSUSE switching to systemd by default, openVPN was made compatible with the systemd way of querying passphrase during boot (directly opening tty isn't supported).

Signature · 2 lines
Frederic Crozat <[email protected]...>
SUSE

From 02a9e6b213eba6dbb90b92b4d51e907718e46a56 Mon Sep 17 00:00:00 2001
From: Frederic Crozat <[email protected]...>
Date: Mon, 31 Oct 2011 15:51:53 +0100
Subject: [PATCH] Add support to forward console query to systemd

Systemd requires console query to be forwarded using its own tool.

---
 misc.c |   37 ++++++++++++++++++++++++++++++-------
 1 files changed, 30 insertions(+), 7 deletions(-)
misc.c +30 -7
index 99e5bc5..c074abe 100644
@@ -1338,26 +1338,49 @@ get_console_input (const char *prompt, const bool echo, char *input, const int c
   ASSERT (input);
   ASSERT (capacity > 0);
   input[0] = '\0';
+  bool is_systemd_running;
+  struct stat a, b;
+
+  /* We simply test whether the systemd cgroup hierarchy is
+   * mounted */
+
+  is_systemd_running = (lstat("/sys/fs/cgroup", &a) == 0)
+	  && (lstat("/sys/fs/cgroup/systemd", &b) == 0)
+	  && (a.st_dev != b.st_dev);
 
 #if defined(WIN32)
   return get_console_input_win32 (prompt, echo, input, capacity);
 #elif defined(HAVE_GETPASS)
-  if (echo)
+  if (echo || is_systemd_running)
     {
       FILE *fp;
 
-      fp = open_tty (true);
-      fprintf (fp, "%s", prompt);
-      fflush (fp);
-      close_tty (fp);
+      if (is_systemd_running)
+        {
+	 char *cmd;
 
-      fp = open_tty (false);
+	 asprintf(&cmd, "/bin/systemd-ask-password \"%s\"", prompt);
+         fp = popen (cmd, "re");
+	 free (cmd);
+        }
+      else
+        {
+          fp = open_tty (true);
+          fprintf (fp, "%s", prompt);
+          fflush (fp);
+          close_tty (fp);
+
+          fp = open_tty (false);
+        }
       if (fgets (input, capacity, fp) != NULL)
 	{
 	  chomp (input);
 	  ret = true;
 	}
-      close_tty (fp);
+      if (is_systemd_running)
+	fclose (fp);
+      else
+	close_tty (fp);
     }
   else
     {
Signature · 1 line
1.7.7
#1 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 6 lines · Frederic Crozat

Hi,

as part of openSUSE switching to systemd by default, openVPN was made compatible with the systemd way of querying passphrase during boot (directly opening tty isn't supported).

Thanks a lot for looking into this! I feared that we would need to do some changes due to systemd.

Generally, this looks very fine. But I would like to see a few changes first before including it.

a) From what I've understood, systemd is by design a Linux only thing. So I'd like to see these code paths restricted to TARGET_LINUX (#ifdef statements). A lot of the dependencies is kernel related, so we probably won't see systemd for BSD, for example. And even less realistic is Solaris. Windows already goes a different route, so this won't be affected here.

b) As systemd is not targetted for embedded Linux devices (it's a massive resource hog, esp. in RAM and looks like to be most suitable in desktop/laptop environments), it could be useful to have this support compile time confiugrable via ./configure. I would even vote for disabling it by default. Right now, systemd only got traction from SuSE, Fedora. Debian is in the works and Ubuntu usually follows Debian. Arch Linux will move over as well.

However, I am systemd sceptic, and I would like to see if systemd really settles as a de-facto SySV replacement across the majority of Linux distributions, before enabling this support by default on Linux. I struggle to see that systemd will be beneficial on (enterprise) servers, as if the booting goes twice as fast or not on a server isn't that critical compared to a desktop/laptop system. And boot performance is one of the key points systemd tries to resolve.

c) It would probably be better to but the "check if systemd is available" into it's own function, for clarity - isolated in
#ifdef defined(TARGET_LINUX) && defined(USE_SYSTEMD) blocks. And likewise, do the /bin/systemd-ask-password in a separate function similar fashion as what is done with Windows' get_console_input_win32().

d) Instead of asprintf(), use openvpn_snprintf() functions. That can probably be just as fine work against a static sized buffer (say 256 bytes - it's for a password, right?) As this is called during startup, and it is serialised among all those places this might be asked for, there are no threading issues here, AFAICS.

e) Consider to make use of openvpn_execve_check() or openvpn_execve() instead of the popen() - or make a popen() variant which got similar error controls to popen() as openvpn_execve*() functions. I also think that this execution should honour the --script-security setting (which is implicitly checked for with openvpn_execve())

f) There are a few mixtures between tab and spaces in your patch. If you could please use space only, that would be great. The code is a mess in this regard, but we're trying to (very slowly) reduce the variety in new patches.

kind regards,

David Sommerseth
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk6vDvoACgkQDC186MBRfrr6PwCdGFh7VKA9nRN05ommWCnAe9CH xJIAoJRW8+pjM7ipFeQW4nHgBY7S1Ty7
=0kja
-----END PGP SIGNATURE-----

#2 lore raw
Quoted 10 lines · David Sommerseth
Quoted 6 lines · Frederic Crozat

Hi,

as part of openSUSE switching to systemd by default, openVPN was made compatible with the systemd way of querying passphrase during boot (directly opening tty isn't supported).

Thanks a lot for looking into this! I feared that we would need to do some changes due to systemd.

Sorry for the very slow answer.

Quoted 9 lines

Generally, this looks very fine. But I would like to see a few changes first before including it.

a) From what I've understood, systemd is by design a Linux only thing. So I'd like to see these code paths restricted to TARGET_LINUX (#ifdef statements). A lot of the dependencies is kernel related, so we probably won't see systemd for BSD, for example. And even less realistic is Solaris. Windows already goes a different route, so this won't be affected here.

No problem with that.

Quoted 7 lines

b) As systemd is not targetted for embedded Linux devices (it's a massive resource hog, esp. in RAM and looks like to be most suitable in desktop/laptop environments), it could be useful to have this support compile time confiugrable via ./configure. I would even vote for disabling it by default. Right now, systemd only got traction from SuSE, Fedora. Debian is in the works and Ubuntu usually follows Debian. Arch Linux will move over as well.

Well, systemd is being investigated also for embedded linux (but this is not the topic of this discussion). I'm fine for adding configure flag and making it disabled by default (or maybe auto enable if systemd is installed on the system ? )

Quoted 7 lines

However, I am systemd sceptic, and I would like to see if systemd really settles as a de-facto SySV replacement across the majority of Linux distributions, before enabling this support by default on Linux. I struggle to see that systemd will be beneficial on (enterprise) servers, as if the booting goes twice as fast or not on a server isn't that critical compared to a desktop/laptop system. And boot performance is one of the key points systemd tries to resolve.

The part for managing services is also pretty interesting, from a service side perspective (each service in a separate cgroup, etc..). I recommend reading the various "systemd for administrator" blog post from systemd author ;)

Quoted 5 lines

c) It would probably be better to but the "check if systemd is available" into it's own function, for clarity - isolated in
#ifdef defined(TARGET_LINUX) && defined(USE_SYSTEMD) blocks. And likewise, do the /bin/systemd-ask-password in a separate function similar fashion as what is done with Windows' get_console_input_win32().

Ok.

Quoted 5 lines

d) Instead of asprintf(), use openvpn_snprintf() functions. That can probably be just as fine work against a static sized buffer (say 256 bytes - it's for a password, right?) As this is called during startup, and it is serialised among all those places this might be asked for, there are no threading issues here, AFAICS.

this code changed now..

Quoted 5 lines

e) Consider to make use of openvpn_execve_check() or openvpn_execve() instead of the popen() - or make a popen() variant which got similar error controls to popen() as openvpn_execve*() functions. I also think that this execution should honour the --script-security setting (which is implicitly checked for with openvpn_execve())

I've tried to come up with something.

Quoted 4 lines

f) There are a few mixtures between tab and spaces in your patch. If you could please use space only, that would be great. The code is a mess in this regard, but we're trying to (very slowly) reduce the variety in new patches.

Should be much better now.

Comments welcome.

Signature · 2 lines
Frederic Crozat <[email protected]...>
SUSE

From caf1af91e5d6864054479476e87a752381293788 Mon Sep 17 00:00:00 2001
From: Frederic Crozat <[email protected]...>
Date: Mon, 31 Oct 2011 15:51:53 +0100
Subject: [PATCH] Add support to forward console query to systemd

Systemd requires console query to be forwarded using its own tool.

---
 configure.ac |   11 +++++
 misc.c       |  121 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 132 insertions(+), 0 deletions(-)
configure.ac +11 -0
index a4d68e6..7143cc5 100644
@@ -223,6 +223,12 @@ AC_ARG_ENABLE(selinux,
    [SELINUX="yes"]
 )
 
+AC_ARG_ENABLE(systemd,
+   [  --enable-systemd        Enable systemd suppport],
+   [SYSTEMD="$enableval"],
+   [SYSTEMD="no"]
+)
+
 AC_ARG_WITH(ssl-headers,
    [  --with-ssl-headers=DIR  Crypto/SSL Include files location],
    [CS_HDR_DIR="$withval"]
@@ -930,6 +936,11 @@ if test "$PASSWORD_SAVE" = "yes"; then
    AC_DEFINE(ENABLE_PASSWORD_SAVE, 1, [Allow --askpass and --auth-user-pass passwords to be read from a file])
 fi
 
+dnl enable systemd support
+if test "$SYSTEMD" = "yes"; then
+   AC_DEFINE(ENABLE_SYSTEMD, 1, [Enable systemd support])
+fi
+
 dnl
 dnl check for SELinux library and headers
 dnl
misc.c +121 -0

145 lines not on this page · raw message

Signature · 1 line
1.7.7
#3 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 2 lines · Frederic Crozat
Quoted 1 line · David Sommerseth

On 31/10/11 16:30, Frederic Crozat wrote:

[...snip...]

Hey again, and thanks for this great rework! I've looked through it, and it looks a lot better now. However ...

Quoted 6 lines
Quoted 6 lines

e) Consider to make use of openvpn_execve_check() or openvpn_execve() instead of the popen() - or make a popen() variant which got similar error controls to popen() as openvpn_execve*() functions. I also think that this execution should honour the --script-security setting (which is implicitly checked for with openvpn_execve())

I like the approach of the openvpn_popen(). However, there are a few things.

+ if (pipe(pipe_stdout) == 0) {
+ pid = fork ();
+ if (pid == (pid_t)0) /* child side */
+ {

+			  close(pipe_stdout[0]);
+			  dup2(pipe_stdout[1],1);
+			  execve (cmd, argv, envp);
+			  exit (127);

+ }
+ else if (pid < (pid_t)0) /* fork failed */
+ ;
^^^^^ No error message if fork() fails?
And is the (pid_t) typecasting really needed?

+ else /* parent side */
+ {
+ ret=pipe_stdout[0];
+ close(pipe_stdout[1]);
+ }
+ }

And:

+ else
+ {
+ msg (M_WARN, "openvpn_popen: called with empty argv");
+ }

This should probably be M_FATAL and not M_WARN. If openvpn_popen() receives an empty argv array, it most likely is due to very bad programming. So halting execution is quite appropriate in my eyes.

In get_console_input_systemd() you do:

+ *input = 0;

I think it would be better to do: CLEAR(*input) instead. Just setting the first byte to 0, will not solve any leak possibilities. An alternative is to use memset() directly, which the CLEAR() macro uses (see basic.h:47), but we prefer to use CLEAR() over memset() directly.

Otherwise, this looks like a very good step forward!

kind regards,

David Sommerseth
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk8HH9UACgkQDC186MBRfrosswCeNlaBSo4owmkt7rsWEKJOXK4u O3kAnjV+sCKDtMJC5AtN+vHQDwmC48ya
=J8dX
-----END PGP SIGNATURE-----

#4 lore raw
Quoted 20 lines · David Sommerseth
Quoted 2 lines · Frederic Crozat
Quoted 1 line · David Sommerseth

On 31/10/11 16:30, Frederic Crozat wrote:

[...snip...]

Hey again, and thanks for this great rework! I've looked through it, and it looks a lot better now. However ...

Quoted 6 lines
Quoted 6 lines

e) Consider to make use of openvpn_execve_check() or openvpn_execve() instead of the popen() - or make a popen() variant which got similar error controls to popen() as openvpn_execve*() functions. I also think that this execution should honour the --script-security setting (which is implicitly checked for with openvpn_execve())

I like the approach of the openvpn_popen(). However, there are a few things.

(quoted diff) +3 -0
+              if (pipe(pipe_stdout) == 0) {
+		      pid = fork ();
+		      if (pid == (pid_t)0) /* child side */

Review

Quoted 10 lines
(quoted diff) +8 -0
+			{
+			  close(pipe_stdout[0]);
+			  dup2(pipe_stdout[1],1);
+			  execve (cmd, argv, envp);
+			  exit (127);
+			}
+		      else if (pid < (pid_t)0) /* fork failed */
+			;
                       ^^^^^  No error message if fork() fails?
                              And is the (pid_t) typecasting really needed?

Well, I stole the code from openvpn_execve function ;)) I'm ok to change it, but it would be better for both function to stay similar, I think.

Quoted 14 lines
(quoted diff) +6 -0
+		      else /* parent side */
+			{
+                            ret=pipe_stdout[0];
+			    close(pipe_stdout[1]);
+			}
+	      }

And:

(quoted diff) +4 -0
+  else
+    {
+      msg (M_WARN, "openvpn_popen: called with empty argv");
+    }
Quoted 3 lines

This should probably be M_FATAL and not M_WARN. If openvpn_popen() receives an empty argv array, it most likely is due to very bad programming. So halting execution is quite appropriate in my eyes.

Again, I stole this part from openvpn_execve, but I'll change it to M_FATAL.

Quoted 8 lines

In get_console_input_systemd() you do:

+ *input = 0;

I think it would be better to do: CLEAR(*input) instead. Just setting the first byte to 0, will not solve any leak possibilities. An alternative is to use memset() directly, which the CLEAR() macro uses (see basic.h:47), but we prefer to use CLEAR() over memset() directly.

done (and I've also fixed some missing spaces in various location).

See the new version attached.

Signature · 2 lines
Frederic Crozat <[email protected]...>
SUSE

From b3eb16e24ff354ce417fee4e8f48b8a8244e8b0c Mon Sep 17 00:00:00 2001
From: Frederic Crozat <[email protected]...>
Date: Mon, 31 Oct 2011 15:51:53 +0100
Subject: [PATCH] Add support to forward console query to systemd

Systemd requires console query to be forwarded using its own tool.

---
 configure.ac |   11 +++++
 misc.c       |  121 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 132 insertions(+), 0 deletions(-)
configure.ac +11 -0
index a4d68e6..7143cc5 100644
@@ -223,6 +223,12 @@ AC_ARG_ENABLE(selinux,
    [SELINUX="yes"]
 )
 
+AC_ARG_ENABLE(systemd,
+   [  --enable-systemd        Enable systemd suppport],
+   [SYSTEMD="$enableval"],
+   [SYSTEMD="no"]
+)
+
 AC_ARG_WITH(ssl-headers,
    [  --with-ssl-headers=DIR  Crypto/SSL Include files location],
    [CS_HDR_DIR="$withval"]
@@ -930,6 +936,11 @@ if test "$PASSWORD_SAVE" = "yes"; then
    AC_DEFINE(ENABLE_PASSWORD_SAVE, 1, [Allow --askpass and --auth-user-pass passwords to be read from a file])
 fi
 
+dnl enable systemd support
+if test "$SYSTEMD" = "yes"; then
+   AC_DEFINE(ENABLE_SYSTEMD, 1, [Enable systemd support])
+fi
+
 dnl
 dnl check for SELinux library and headers
 dnl
misc.c +121 -0

145 lines not on this page · raw message

Signature · 1 line
1.7.7
#5 lore raw
Quoted 27 lines · Frederic Crozat
Quoted 26 lines · David Sommerseth
Quoted 2 lines · Frederic Crozat
Quoted 1 line · David Sommerseth

On 31/10/11 16:30, Frederic Crozat wrote:

[...snip...]

Hey again, and thanks for this great rework! I've looked through it, and it looks a lot better now. However ...

Quoted 6 lines
Quoted 6 lines

e) Consider to make use of openvpn_execve_check() or openvpn_execve() instead of the popen() - or make a popen() variant which got similar error controls to popen() as openvpn_execve*() functions. I also think that this execution should honour the --script-security setting (which is implicitly checked for with openvpn_execve())

I like the approach of the openvpn_popen(). However, there are a few things.

misc.c +9 -0
+              if (pipe(pipe_stdout) == 0) {
+		      pid = fork ();
+		      if (pid == (pid_t)0) /* child side */
+			{
+			  close(pipe_stdout[0]);
+			  dup2(pipe_stdout[1],1);
+			  execve (cmd, argv, envp);
+			  exit (127);
+			}
Quoted 8 lines

misc.c openvpn_system (const char *command, const struct env_set *es, unsigned int flag

Quoted 4 lines
misc.c +2 -0
+		      else if (pid < (pid_t)0) /* fork failed */
+			;
                       ^^^^^  No error message if fork() fails?
                              And is the (pid_t) typecasting really needed?

Well, I stole the code from openvpn_execve function ;)) I'm ok to change it, but it would be better for both function to stay similar, I think.

Well, now you got me into looking deeper :) ... First of all, there might be^W^W are code paths in openvpn which isn't pretty. And we should fix up that as we find them.

I'm still in the opinion that not reporting that the execution isn't proper behaviour. Even though, it's not likely that fork() fails often, unless the system is low on memory or RLIMIT_NPROC is exceeded. But informing that the execution failed is still important for debugging.

I'd say, let's at least add an error message here, using M_ERR. That way, we'll get the errno message returned as well. I'll take care of posting a proper fix for openvpn_execve(). You may disregard my (pid_t) comment for now.

Quoted 14 lines
Quoted 14 lines
misc.c +6 -0
+		      else /* parent side */
+			{
+                            ret=pipe_stdout[0];
+			    close(pipe_stdout[1]);
+			}
+	      }

And:

misc.c +4 -0
+  else
+    {
+      msg (M_WARN, "openvpn_popen: called with empty argv");
+    }
Quoted 6 lines
Quoted 3 lines

This should probably be M_FATAL and not M_WARN. If openvpn_popen() receives an empty argv array, it most likely is due to very bad programming. So halting execution is quite appropriate in my eyes.

Again, I stole this part from openvpn_execve, but I'll change it to M_FATAL.

I'll send a fix for this as well, in regards to openvpn_execve()

Quoted 4 lines
Quoted 4 lines

In get_console_input_systemd() you do:

+ *input = 0;

Quoted 8 lines
Quoted 4 lines

I think it would be better to do: CLEAR(*input) instead. Just setting the first byte to 0, will not solve any leak possibilities. An alternative is to use memset() directly, which the CLEAR() macro uses (see basic.h:47), but we prefer to use CLEAR() over memset() directly.

done (and I've also fixed some missing spaces in various location).

See the new version attached.

Goodie! I presume you did some compile and sanity testing before submitting the patch, so that it won't bite our compile farm :) I think we have a F15 or F16 box (which uses systemd) in the farm, so we can enable systemd features on that box.

kind regards,

David Sommerseth

#6 lore raw
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

In get_console_input_systemd() you do:

+ *input = 0;

I think it would be better to do: CLEAR(*input) instead. Just setting the first byte to 0, will not solve any leak possibilities. An alternative is to use memset() directly, which the CLEAR() macro uses (see basic.h:47), but we prefer to use CLEAR() over memset() directly.

Quoted 7 lines
Quoted 3 lines

done (and I've also fixed some missing spaces in various location).

See the new version attached.

Goodie! I presume you did some compile and sanity testing before submitting the patch, so that it won't bite our compile farm :) I think we have a F15 or F16 box (which uses systemd) in the farm, so we can enable systemd features on that box.

I got two F16 boxes which I can use for systemd testing. I'll integrate those with buildbot next week.

Signature · 5 lines
Samuli Seppänen
Community Manager
OpenVPN Technologies, Inc

irc freenode net: mattock
#7 lore raw
In reply to David Sommerseth
Quoted 41 lines · David Sommerseth
Quoted 27 lines · Frederic Crozat
Quoted 26 lines · David Sommerseth
Quoted 2 lines · Frederic Crozat
Quoted 1 line · David Sommerseth

On 31/10/11 16:30, Frederic Crozat wrote:

[...snip...]

Hey again, and thanks for this great rework! I've looked through it, and it looks a lot better now. However ...

Quoted 6 lines
Quoted 6 lines

e) Consider to make use of openvpn_execve_check() or openvpn_execve() instead of the popen() - or make a popen() variant which got similar error controls to popen() as openvpn_execve*() functions. I also think that this execution should honour the --script-security setting (which is implicitly checked for with openvpn_execve())

I like the approach of the openvpn_popen(). However, there are a few things.

(quoted diff) +9 -0
+              if (pipe(pipe_stdout) == 0) {
+		      pid = fork ();
+		      if (pid == (pid_t)0) /* child side */
+			{
+			  close(pipe_stdout[0]);
+			  dup2(pipe_stdout[1],1);
+			  execve (cmd, argv, envp);
+			  exit (127);
+			}
Quoted 8 lines

Review

Quoted 4 lines
(quoted diff) +2 -0
+		      else if (pid < (pid_t)0) /* fork failed */
+			;
                       ^^^^^  No error message if fork() fails?
                              And is the (pid_t) typecasting really needed?

Well, I stole the code from openvpn_execve function ;)) I'm ok to change it, but it would be better for both function to stay similar, I think.

Well, now you got me into looking deeper :) ... First of all, there might be^W^W are code paths in openvpn which isn't pretty. And we should fix up that as we find them.

Quoted 8 lines

I'm still in the opinion that not reporting that the execution isn't proper behaviour. Even though, it's not likely that fork() fails often, unless the system is low on memory or RLIMIT_NPROC is exceeded. But informing that the execution failed is still important for debugging.

I'd say, let's at least add an error message here, using M_ERR. That way, we'll get the errno message returned as well. I'll take care of posting a proper fix for openvpn_execve(). You may disregard my (pid_t) comment for now.

Done.

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
(quoted diff) +6 -0
+		      else /* parent side */
+			{
+                            ret=pipe_stdout[0];
+			    close(pipe_stdout[1]);
+			}
+	      }

And:

(quoted diff) +4 -0
+  else
+    {
+      msg (M_WARN, "openvpn_popen: called with empty argv");
+    }
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

This should probably be M_FATAL and not M_WARN. If openvpn_popen() receives an empty argv array, it most likely is due to very bad programming. So halting execution is quite appropriate in my eyes.

Again, I stole this part from openvpn_execve, but I'll change it to M_FATAL.

I'll send a fix for this as well, in regards to openvpn_execve()

Ok :)

Quoted 9 lines
Quoted 9 lines
Quoted 8 lines

In get_console_input_systemd() you do:

+ *input = 0;

I think it would be better to do: CLEAR(*input) instead. Just setting the first byte to 0, will not solve any leak possibilities. An alternative is to use memset() directly, which the CLEAR() macro uses (see basic.h:47), but we prefer to use CLEAR() over memset() directly.

Quoted 8 lines
Quoted 3 lines

done (and I've also fixed some missing spaces in various location).

See the new version attached.

Goodie! I presume you did some compile and sanity testing before submitting the patch, so that it won't bite our compile farm :) I think we have a F15 or F16 box (which uses systemd) in the farm, so we can enable systemd features on that box.

Well, the initial patch has been shipped as part of openSUSE 12.1 and so far, I didn't got any bug report about it, so either it is working perfectly or nobody is able to connect home using their VPN and therefore can complain ;) I'd tested again attached patch and it is still working fine.

Signature · 2 lines
Frederic Crozat <[email protected]...>
SUSE

From e6b8f470c2ede825273a47788d6b4b86b8f3b1ad Mon Sep 17 00:00:00 2001
From: Frederic Crozat <[email protected]...>
Date: Mon, 31 Oct 2011 15:51:53 +0100
Subject: [PATCH] Add support to forward console query to systemd

Systemd requires console query to be forwarded using its own tool.

---
 configure.ac |   11 +++++
 misc.c       |  123 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 134 insertions(+), 0 deletions(-)
configure.ac +11 -0
index a4d68e6..7143cc5 100644
@@ -223,6 +223,12 @@ AC_ARG_ENABLE(selinux,
    [SELINUX="yes"]
 )
 
+AC_ARG_ENABLE(systemd,
+   [  --enable-systemd        Enable systemd suppport],
+   [SYSTEMD="$enableval"],
+   [SYSTEMD="no"]
+)
+
 AC_ARG_WITH(ssl-headers,
    [  --with-ssl-headers=DIR  Crypto/SSL Include files location],
    [CS_HDR_DIR="$withval"]
@@ -930,6 +936,11 @@ if test "$PASSWORD_SAVE" = "yes"; then
    AC_DEFINE(ENABLE_PASSWORD_SAVE, 1, [Allow --askpass and --auth-user-pass passwords to be read from a file])
 fi
 
+dnl enable systemd support
+if test "$SYSTEMD" = "yes"; then
+   AC_DEFINE(ENABLE_SYSTEMD, 1, [Enable systemd support])
+fi
+
 dnl
 dnl check for SELinux library and headers
 dnl
misc.c +123 -0

147 lines not on this page · raw message

Signature · 1 line
1.7.7
#8 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 93 lines · Frederic Crozat
Quoted 44 lines · David Sommerseth
Quoted 29 lines · Frederic Crozat

Le vendredi 06 janvier 2012 à 17:22 +0100, David Sommerseth a écrit :

Quoted 19 lines · Frederic Crozat
Quoted 3 lines

Le lundi 31 octobre 2011 à 22:11 +0100, David Sommerseth a écrit :

Quoted 1 line · Frederic Crozat

[...snip...]

Hey again, and thanks for this great rework! I've looked through it, and it looks a lot better now. However ...

Quoted 6 lines
Quoted 6 lines

e) Consider to make use of openvpn_execve_check() or openvpn_execve() instead of the popen() - or make a popen() variant which got similar error controls to popen() as openvpn_execve*() functions. I also think that this execution should honour the --script-security setting (which is implicitly checked for with openvpn_execve())

I like the approach of the openvpn_popen(). However, there are a few things.

Quoted 7 lines

+ if (pipe(pipe_stdout) == 0) { + pid = fork
(); + if (pid == (pid_t)0) /* child side */ + { +
close(pipe_stdout[0]); + dup2(pipe_stdout[1],1); +
execve (cmd, argv, envp); + exit (127); + } + else
if (pid < (pid_t)0) /* fork failed */ + ; ^^^^^ No error
message if fork() fails? And is the (pid_t) typecasting really needed?

Quoted 3 lines

Well, I stole the code from openvpn_execve function ;)) I'm ok to change it, but it would be better for both function to stay similar, I think.

Well, now you got me into looking deeper :) ... First of all, there might be^W^W are code paths in openvpn which isn't pretty. And we should fix up that as we find them.

I'm still in the opinion that not reporting that the execution isn't proper behaviour. Even though, it's not likely that fork() fails often, unless the system is low on memory or RLIMIT_NPROC is exceeded. But informing that the execution failed is still important for debugging.

Quoted 4 lines

I'd say, let's at least add an error message here, using M_ERR. That way, we'll get the errno message returned as well. I'll take care of posting a proper fix for openvpn_execve(). You may disregard my (pid_t) comment for now.

Done.

Quoted 17 lines
Quoted 9 lines
Quoted 9 lines
(quoted diff) +1 -0
+		      else /* parent side */ +			{ +

ret=pipe_stdout[0]; + close(pipe_stdout[1]); + } +
}

And:

+ else + { + msg (M_WARN, "openvpn_popen: called with
empty argv"); + }

Quoted 7 lines
Quoted 4 lines

This should probably be M_FATAL and not M_WARN. If openvpn_popen() receives an empty argv array, it most likely is due to very bad programming. So halting execution is quite appropriate in my eyes.

Again, I stole this part from openvpn_execve, but I'll change it to M_FATAL.

Quoted 1 line

I'll send a fix for this as well, in regards to openvpn_execve()

Ok :)

Quoted 13 lines
Quoted 13 lines
Quoted 9 lines

In get_console_input_systemd() you do:

+ *input = 0;

I think it would be better to do: CLEAR(*input) instead. Just setting the first byte to 0, will not solve any leak possibilities. An alternative is to use memset() directly, which the CLEAR() macro uses (see basic.h:47), but we prefer to use CLEAR() over memset() directly.

done (and I've also fixed some missing spaces in various location).

Quoted 6 lines
Quoted 1 line

See the new version attached.

Goodie! I presume you did some compile and sanity testing before submitting the patch, so that it won't bite our compile farm :) I think we have a F15 or F16 box (which uses systemd) in the farm, so we can enable systemd features on that box.

Quoted 5 lines

Well, the initial patch has been shipped as part of openSUSE 12.1 and so far, I didn't got any bug report about it, so either it is working perfectly or nobody is able to connect home using their VPN and therefore can complain ;) I'd tested again attached patch and it is still working fine.

I ACKed the patch, and it's just pushed out to master branches on both
- -testing and -stable.

commit 9449e6a9eba30c9ed054f57d630a88c9f087080f

kind regards,

David Sommerseth
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk8MYRYACgkQDC186MBRfrqV9wCgl0fxhbpvY0NMav2tJkbT75T+ BaYAnRmU345zp+3+KdMlBWaAkXMHmygS
=IFYf
-----END PGP SIGNATURE-----