Re: [gpm] Running the power manager under another session and while not having any battery to monitor?
- From: Matthew Garrett <mjg59 srcf ucam org>
- To: Richard Hughes <hughsient gmail com>
- Cc: gnome-power-manager-list gnome org
- Subject: Re: [gpm] Running the power manager under another session and while not having any battery to monitor?
- Date: Sun, 8 Jan 2006 22:11:53 +0000
On Sun, Jan 08, 2006 at 10:07:53PM +0000, Richard Hughes wrote:
> Did you patch the dbus source? Have you got the patch handy, and I'll
> send it their way. Or is libpam-foreground an ubuntu thing?
libpam-foreground is still an Ubuntu thing, but the patch is attached.
--
Matthew Garrett | mjg59 srcf ucam org
diff -urN dbus-0.60/configure.in dbus-0.60.mine/configure.in
--- dbus-0.60/configure.in 2005-12-22 16:56:06 +0000
+++ dbus-0.60.mine/configure.in 2005-12-22 16:35:20 +0000
@@ -1225,6 +1225,16 @@
AC_SUBST(DBUS_CONSOLE_AUTH_DIR)
AC_DEFINE_UNQUOTED(DBUS_CONSOLE_AUTH_DIR, "$DBUS_CONSOLE_AUTH_DIR", [Directory to check for console ownerhip])
+#### Application to check for current console
+if ! test -z "$with_foreground_console_command"; then
+ DBUS_FOREGROUND_CONSOLE_COMMAND=$with_foreground_console_comand
+else
+ DBUS_FOREGROUND_CONSOLE_COMMAND=dbus-foreground-console
+fi
+
+AC_SUBST(DBUS_FOREGROUND_CONSOLE_COMMAND)
+AC_DEFINE_UNQUOTED(DBUS_FOREGROUND_CONSOLE_COMMAND, "$DBUS_FOREGROUND_CONSOLE_COMMAND", [Application to provide the current foreground console])
+
#### User to start the system bus as
if test -z "$with_dbus_user" ; then
DBUS_USER=messagebus
@@ -1448,6 +1458,7 @@
System bus PID file: ${DBUS_SYSTEM_PID_FILE}
Session bus socket dir: ${DBUS_SESSION_SOCKET_DIR}
Console auth dir: ${DBUS_CONSOLE_AUTH_DIR}
+ Foreground console app: ${DBUS_FOREGROUND_CONSOLE_COMMAND}
System bus user: ${DBUS_USER}
'make check' socket dir: ${TEST_SOCKET_DIR}
"
diff -urN dbus-0.60/tools/dbus-foreground-console.c dbus-0.60.mine/tools/dbus-foreground-console.c
--- dbus-0.60/tools/dbus-foreground-console.c 1970-01-01 01:00:00 +0100
+++ dbus-0.60.mine/tools/dbus-foreground-console.c 2005-12-22 16:53:16 +0000
@@ -0,0 +1,32 @@
+/* dbus-foreground-console
+ * return the current foreground console
+ * Heavily based on fgconsole.c from console-tools
+ * Released under the terms of the GNU general public license, version 2.1 or
+ * later
+ */
+
+#include <stdio.h>
+#include <sys/ioctl.h>
+#include <linux/vt.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+int main() {
+ struct vt_stat vtstat;
+ int fd;
+
+ fd = open("/dev/console", O_RDWR);
+
+ if (fd < 1) {
+ return 0;
+ }
+
+ if (ioctl(fd, VT_GETSTATE, &vtstat))
+ {
+ return 0;
+ }
+
+ return vtstat.v_active;
+}
+
diff -urN dbus-0.60/tools/Makefile.am dbus-0.60.mine/tools/Makefile.am
--- dbus-0.60/tools/Makefile.am 2005-09-06 23:38:54 +0100
+++ dbus-0.60.mine/tools/Makefile.am 2005-12-22 16:54:53 +0000
@@ -26,7 +26,7 @@
DBUS_TOP_BUILDDIR=$(top_builddir) $(srcdir)/run-with-tmp-session-bus.sh ./dbus-send --print-reply=literal --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.Introspectable.Introspect > dbus-bus-introspect.xml.tmp && mv dbus-bus-introspect.xml.tmp dbus-bus-introspect.xml
endif
-bin_PROGRAMS=dbus-send $(GLIB_TOOLS) dbus-launch dbus-cleanup-sockets $(GTK_TOOLS)
+bin_PROGRAMS=dbus-send $(GLIB_TOOLS) dbus-launch dbus-cleanup-sockets $(GTK_TOOLS) dbus-foreground-console
dbus_send_SOURCES= \
dbus-print-message.c \
@@ -51,6 +51,9 @@
dbus-tree-view.h \
dbus-viewer.c
+dbus_foreground_console_SOURCES= \
+ dbus-foreground-console.c
+
dbus_send_LDADD= $(top_builddir)/dbus/libdbus-1.la
dbus_monitor_LDADD= $(top_builddir)/glib/libdbus-glib-1.la
dbus_launch_LDADD= $(DBUS_X_LIBS)
--- dbus-0.60/config.h.in 2005-11-30 21:02:10 +0000
+++ dbus-0.60.mine/config.h.in 2005-12-22 17:04:52 +0000
@@ -21,6 +21,9 @@
/* Support a verbose mode */
#undef DBUS_ENABLE_VERBOSE_MODE
+/* Application to provide the current foreground console */
+#undef DBUS_FOREGROUND_CONSOLE_COMMAND
+
/* Defined if gcov is enabled to force a rebuild due to config.h changing */
#undef DBUS_GCOV_ENABLED
--- dbus-0.60/dbus/dbus-sysdeps-util.c 2005-07-08 15:36:22 +0100
+++ dbus-0.60.mine/dbus/dbus-sysdeps-util.c 2005-12-22 17:08:22 +0000
@@ -351,8 +351,29 @@
DBusString f;
dbus_bool_t result;
+ int console;
result = FALSE;
+
+ console = system (DBUS_FOREGROUND_CONSOLE_COMMAND);
+
+ if (console == -1)
+ {
+ dbus_set_error (error, DBUS_ERROR_FAILED,
+ "Failed to execute %s: %s\n",
+ DBUS_FOREGROUND_CONSOLE_COMMAND, _dbus_strerror (errno));
+ return FALSE;
+ }
+
+ /* Consoles start at 1, so 0 denotes failure */
+ if (console == 0)
+ {
+ dbus_set_error (error, DBUS_ERROR_FAILED,
+ "Failed to get foreground console\n");
+ return FALSE;
+ }
+
+
if (!_dbus_string_init (&f))
{
_DBUS_SET_OOM (error);
@@ -365,13 +386,25 @@
goto out;
}
-
if (!_dbus_string_append (&f, username))
{
_DBUS_SET_OOM (error);
goto out;
}
+ /* : is used as a separator, since . is a valid username character */
+ if (!_dbus_string_append (&f, ":"))
+ {
+ _DBUS_SET_OOM (error);
+ goto out;
+ }
+
+ if (!_dbus_string_append_int (&f, console))
+ {
+ _DBUS_SET_OOM (error);
+ goto out;
+ }
+
result = _dbus_file_exists (_dbus_string_get_const_data (&f));
out:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]