[systemd-devel] [PATCH 5/7] tty-ask-password-agent: honour !HAVE_UTMP

Emil Renner Berthing systemd at esmil.dk
Wed Sep 24 08:25:04 PDT 2014


---
 src/tty-ask-password-agent/tty-ask-password-agent.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/tty-ask-password-agent/tty-ask-password-agent.c b/src/tty-ask-password-agent/tty-ask-password-agent.c
index 8a02fb0..9428419 100644
--- a/src/tty-ask-password-agent/tty-ask-password-agent.c
+++ b/src/tty-ask-password-agent/tty-ask-password-agent.c
@@ -36,13 +36,16 @@
 #include "mkdir.h"
 #include "path-util.h"
 #include "conf-parser.h"
-#include "utmp-wtmp.h"
 #include "socket-util.h"
 #include "ask-password-api.h"
 #include "strv.h"
 #include "build.h"
 #include "def.h"
 
+#ifdef HAVE_UTMP
+#include "utmp-wtmp.h"
+#endif
+
 static enum {
         ACTION_LIST,
         ACTION_QUERY,
@@ -251,6 +254,7 @@ static int parse_password(const char *filename, char **wall) {
                 printf("'%s' (PID %u)\n", message, pid);
 
         else if (arg_action == ACTION_WALL) {
+#ifdef HAVE_UTMP
                 char *_wall;
 
                 if (asprintf(&_wall,
@@ -264,7 +268,10 @@ static int parse_password(const char *filename, char **wall) {
 
                 free(*wall);
                 *wall = _wall;
-
+#else
+                log_warning("utmp not supported, not issuing wall message for \'%s\' (PID %u).",
+                                message, pid);
+#endif
         } else {
                 union sockaddr_union sa = {};
                 size_t packet_length = 0;
@@ -384,6 +391,7 @@ static int wall_tty_block(void) {
         return fd;
 }
 
+#ifdef HAVE_UTMP
 static bool wall_tty_match(const char *path) {
         int fd, r;
         struct stat st;
@@ -418,6 +426,7 @@ static bool wall_tty_match(const char *path) {
         safe_close(fd);
         return false;
 }
+#endif
 
 static int show_passwords(void) {
         _cleanup_closedir_ DIR *d;
@@ -457,8 +466,10 @@ static int show_passwords(void) {
                 if (q < 0 && r == 0)
                         r = q;
 
+#ifdef HAVE_UTMP
                 if (wall)
                         utmp_wall(wall, NULL, wall_tty_match);
+#endif
         }
 
         return r;
-- 
2.1.0



More information about the systemd-devel mailing list