summaryrefslogtreecommitdiffstats
path: root/src/ck-run-programs.h
diff options
context:
space:
mode:
authorDavid Zeuthen <davidz@redhat.com>2007-10-04 20:39:09 -0400
committerWilliam Jon McCann <mccann@jhu.edu>2007-10-04 20:39:09 -0400
commita90ecd3544f03c16f6c5a97aafb1c0b33b58101c (patch)
tree3c52a6ac890ce96ab9af100655577614002b8e28 /src/ck-run-programs.h
parentad9dbd345dbec43ffc24481a0d21c261e49347fb (diff)
add a way to synchronously run programs on session add/remove/activity_change
This patch adds support for running programs when 1. A session is added 2. A session is removed 3. The activity of a session changes Executables with the suffix .ck in the directories $sysconfdir/ConsoleKit/run-session.d (typically /etc/ConsoleKit/run-session.d) and $libdir/ConsoleKit/run-session.d (typically /usr/lib/ConsoleKit/run-session.d) will be run on each event. The former directory is meant to be used for the system administrator and the latter is meant to be used by programs. Only when all programs in these directories have run, ConsoleKit will resume event processing and e.g. broadcast the event on the system message bus. Hence, this new mechanism can be used to safely (e.g. without race conditions) perform operations on certain resources before programs in the desktop session are told they may use them. The obvious example here is managing ACL's on /dev such that certain device nodes are only available to users in local and active sessions. The environment of the program launched is the environment that the ConsoleKit daemon was launched with and also the following variables (variables tagged with [*] may not be set). CK_SESSION_ID CK_SESSION_TYPE CK_SESSION_SEAT_ID CK_SESSION_USER_UID CK_SESSION_DISPLAY_DEVICE [*] CK_SESSION_X11_DISPLAY_DEVICE [*] CK_SESSION_X11_DISPLAY [*] CK_SESSION_REMOTE_HOST_NAME [*] CK_SESSION_IS_ACTIVE CK_SESSION_IS_LOCAL corresponding to the properties of a Session object in question. Each program is passed exactly one parameter that can assume one of the following values: - session_active_changed: is_active changed - session_added: the session was added - session_removed: the session was removed As a safety hatch, there is a timeout of 15 seconds for each program; if it hasn't exited within 15 seconds, the daemon will send it a SIGTERM signal, and move on to the next program. The daemon is still responsive when the program is running - this is to ensure that the program itself can call into the org.freedesktop.ConsoleKit service.
Diffstat (limited to 'src/ck-run-programs.h')
-rw-r--r--src/ck-run-programs.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/ck-run-programs.h b/src/ck-run-programs.h
new file mode 100644
index 0000000..77cdf48
--- /dev/null
+++ b/src/ck-run-programs.h
@@ -0,0 +1,38 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007 David Zeuthen <david@fubar.dk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+
+#ifndef __CK_RUN_PROGRAMS_H
+#define __CK_RUN_PROGRAMS_H
+
+#include <glib-object.h>
+#include <dbus/dbus-glib.h>
+#include "ck-session.h"
+
+G_BEGIN_DECLS
+
+void ck_run_programs (const char *dirpath, const char *action, char **extra_env);
+
+void ck_session_run_programs (CkSession *session, const char *action);
+
+
+G_END_DECLS
+
+#endif /* __CK_RUN_PROGRAMS_H */