summaryrefslogtreecommitdiff
blob: bb6b6103dde2496306ef2ddc69a7870f78b03836 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
--- a/config.h.in	2017-06-07 16:38:45.046910693 +0200
+++ b/config.h.in	2017-06-07 16:39:06.973911120 +0200
@@ -78,8 +78,8 @@
 /* Define to 1 if you have the <string.h> header file. */
 #undef HAVE_STRING_H
 
-/* Build systemd code */
-#undef HAVE_SYSTEMD
+/* Build systemd-login code */
+#undef HAVE_SYSTEMD_SD_LOGIN_H
 
 /* Define to 1 if you have the <sys/stat.h> header file. */
 #undef HAVE_SYS_STAT_H
--- a/configure.ac	2017-06-06 09:03:57.171355965 +0200
+++ b/configure.ac	2017-06-06 09:55:11.242384458 +0200
@@ -254,7 +254,6 @@
 		    AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files]),
 		    [has_systemdsystemunitdir=$with_systemdsystemunitdir],
 		    [has_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)])
-	AC_DEFINE(HAVE_SYSTEMD,1,[Build systemd code])
 	AC_SUBST([systemdsystemunitdir], [$has_systemdsystemunitdir])
 fi
 AM_CONDITIONAL(HAVE_SYSTEMD, [test -n "$has_systemdsystemunitdir"])
@@ -267,6 +266,24 @@
 AM_CONDITIONAL(ENABLE_OFFLINE_UPDATE, [test x$enable_systemd = xyes -a x$enable_offline_update = xyes])
 
 dnl ---------------------------------------------------------------------------
+dnl - Use elogind instead of systemd-login
+dnl ---------------------------------------------------------------------------
+AC_ARG_ENABLE(elogind, AS_HELP_STRING([--enable-elogind],[enable elogind session tracker]),
+	      enable_elogind=$enableval,enable_elogind=no)
+if test x$enable_elogind = xyes; then
+	PKG_CHECK_MODULES(ELOGIND, [libelogind >= 229.4], [have_elogind=yes], [have_elogind=no])
+else
+	have_elogind=no
+fi
+
+dnl ---------------------------------------------------------------------------
+dnl --- Is systemd/sd-login.h, either from systemd or elogind, available?
+dnl ---------------------------------------------------------------------------
+if test -n "$has_systemdsystemunitdir" -o "x$have_elogind" != "xno" ; then
+		AC_DEFINE(HAVE_SYSTEMD_SD_LOGIN_H,1,[Build systemd-login code])
+fi
+
+dnl ---------------------------------------------------------------------------
 dnl - Generate man pages ? (default enabled)
 dnl ---------------------------------------------------------------------------
 AC_ARG_ENABLE(man_pages, AS_HELP_STRING([--disable-man-pages],[Disable man pages generation]), enable_man_pages=$enableval)
@@ -629,6 +644,7 @@
         cflags:                    ${CFLAGS}
         cppflags:                  ${CPPFLAGS}
         Able to run locally:       ${enable_local}
+        Use elogind:               ${enable_elogind}
         Use systemd:               ${enable_systemd}
         Enable offline update:     ${enable_offline_update}
         Networking stacks:         ${networking_apis}
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -9,6 +9,7 @@ AM_CPPFLAGS =						\
 	$(SQLITE_CFLAGS)				\
 	$(POLKIT_CFLAGS)				\
 	$(PYTHON_CFLAGS)				\
+	$(ELOGIND_CFLAGS)				\
 	$(SYSTEMD_CFLAGS)				\
 	-DPACKAGE_LOCALE_DIR=\"$(localedir)\"		\
 	-DBINDIR=\"$(bindir)\"				\
@@ -100,6 +101,7 @@ packagekit_direct_LDADD =				\
 	$(POLKIT_LIBS)					\
 	$(GIO_LIBS)					\
 	$(ARCHIVE_LIBS)					\
+	$(ELOGIND_LIBS)					\
 	$(SYSTEMD_LIBS)
 
 packagekit_direct_LDFLAGS =				\
@@ -128,6 +130,7 @@ packagekitd_LDADD =					\
 	$(POLKIT_LIBS)					\
 	$(GIO_LIBS)					\
 	$(ARCHIVE_LIBS)					\
+	$(ELOGIND_LIBS)					\
 	$(SYSTEMD_LIBS)
 
 packagekitd_LDFLAGS =					\
@@ -153,6 +156,7 @@ pk_self_test_LDADD =					\
 	$(POLKIT_LIBS)					\
 	$(GIO_LIBS)					\
 	$(ARCHIVE_LIBS)					\
+	$(ELOGIND_LIBS)					\
 	$(SYSTEMD_LIBS)
 
 pk_self_test_CPPFLAGS =					\
--- a/src/pk-engine.c	2017-06-06 09:12:23.828371176 +0200
+++ b/src/pk-engine.c	2017-06-06 09:55:47.426385545 +0200
@@ -98,7 +98,7 @@
 	guint			 owner_id;
 	GDBusNodeInfo		*introspection;
 	GDBusConnection		*connection;
-#ifdef HAVE_SYSTEMD
+#ifdef HAVE_SYSTEMD_SD_LOGIN_H
 	GDBusProxy		*logind_proxy;
 	gint			 logind_fd;
 #endif
@@ -281,7 +281,7 @@
 static void
 pk_engine_inhibit (PkEngine *engine)
 {
-#ifdef HAVE_SYSTEMD
+#ifdef HAVE_SYSTEMD_SD_LOGIN_H
 	g_autoptr(GError) error = NULL;
 	g_autoptr(GUnixFDList) out_fd_list = NULL;
 	g_autoptr(GVariant) res = NULL;
@@ -331,7 +331,7 @@
 static void
 pk_engine_uninhibit (PkEngine *engine)
 {
-#ifdef HAVE_SYSTEMD
+#ifdef HAVE_SYSTEMD_SD_LOGIN_H
 	if (engine->priv->logind_fd == 0)
 		return;
 	g_debug ("closed logind fd %i", engine->priv->logind_fd);
@@ -1830,7 +1830,7 @@
 	}
 }
 
-#ifdef HAVE_SYSTEMD
+#ifdef HAVE_SYSTEMD_SD_LOGIN_H
 /**
  * pk_engine_proxy_logind_cb:
  **/
@@ -1872,7 +1872,7 @@
 	/* save copy for emitting signals */
 	engine->priv->connection = g_object_ref (connection);
 
-#ifdef HAVE_SYSTEMD
+#ifdef HAVE_SYSTEMD_SD_LOGIN_H
 	/* connect to logind */
 	g_dbus_proxy_new (connection,
 			  G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
@@ -2031,7 +2031,7 @@
 	if (engine->priv->connection != NULL)
 		g_object_unref (engine->priv->connection);
 
-#ifdef HAVE_SYSTEMD
+#ifdef HAVE_SYSTEMD_SD_LOGIN_H
 	/* uninhibit */
 	if (engine->priv->logind_fd != 0)
 		close (engine->priv->logind_fd);
--- a/src/pk-dbus.c	2017-06-06 09:12:13.254370858 +0200
+++ b/src/pk-dbus.c	2017-06-06 10:09:17.249409857 +0200
@@ -27,7 +27,7 @@
 #include <glib.h>
 #include <gio/gio.h>
 
-#ifdef HAVE_SYSTEMD
+#ifdef HAVE_SYSTEMD_SD_LOGIN_H
  #include <systemd/sd-login.h>
 #endif
 
@@ -177,7 +177,7 @@
 	return cmdline;
 }
 
-#ifdef HAVE_SYSTEMD
+#ifdef HAVE_SYSTEMD_SD_LOGIN_H
 /**
  * pk_dbus_get_session_systemd:
  **/
@@ -220,7 +220,7 @@
 pk_dbus_get_session (PkDbus *dbus, const gchar *sender)
 {
 	gchar *session = NULL;
-#ifndef HAVE_SYSTEMD
+#ifndef HAVE_SYSTEMD_SD_LOGIN_H
 	g_autoptr(GError) error = NULL;
 #endif
 	guint pid;
@@ -250,7 +250,7 @@
 	}
 
 	/* get session from systemd or ConsoleKit */
-#ifdef HAVE_SYSTEMD
+#ifdef HAVE_SYSTEMD_SD_LOGIN_H
 	session = pk_dbus_get_session_systemd (pid);
 #else
 	/* get session from ConsoleKit */