aboutsummaryrefslogtreecommitdiff
path: root/debian/patches/0001-Add-simple-AFS-plugin.patch
blob: f7cad683727cca4c79898a524bea1017b0dd82ae (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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
From: =?UTF-8?q?Guido=20G=C3=BCnther?= <agx@sigxcpu.org>
Date: Wed, 7 Jul 2010 17:31:57 +0200
Subject: [PATCH] Add simple AFS plugin

that calls aklog or afslog if available.
---
 plugins/Makefile.am     |   17 +++++++
 plugins/ka-plugin-afs.c |  114 +++++++++++++++++++++++++++++++++++++++++++++++
 plugins/ka-plugin-afs.h |   50 ++++++++++++++++++++
 3 files changed, 181 insertions(+), 0 deletions(-)
 create mode 100644 plugins/ka-plugin-afs.c
 create mode 100644 plugins/ka-plugin-afs.h

diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index 8fecd5c..cf69e7b 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -11,6 +11,7 @@ endif
 pkglib_LTLIBRARIES = \
 	libka-plugin-dummy.la \
 	$(PAM_PLUGIN) \
+	libka-plugin-afs.la \
 	$(NULL)
 
 # Dummy example plugin
@@ -47,3 +48,19 @@ libka_plugin_pam_la_LDFLAGS = \
 	$(PAM_LIBS) \
 	$(NULL)
 endif
+
+# AFS plugin
+libka_plugin_afs_la_SOURCES = \
+	ka-plugin-afs.c \
+	ka-plugin-afs.h \
+	$(NULL)
+
+libka_plugin_afs_la_CPPFLAGS = \
+	$(GTK_CFLAGS)       \
+	-I$(top_srcdir)/src \
+	$(NULL)
+
+libka_plugin_afs_la_LDFLAGS = \
+	-module \
+	-avoid-version \
+	$(NULL)
diff --git a/plugins/ka-plugin-afs.c b/plugins/ka-plugin-afs.c
new file mode 100644
index 0000000..57daed0
--- /dev/null
+++ b/plugins/ka-plugin-afs.c
@@ -0,0 +1,114 @@
+/*
+ * Copyright (C) 2010 Guido Guenther <agx@sigxcpu.org>
+ *
+ * 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, 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.
+ */
+
+#include "ka-plugin-afs.h"
+#include <gmodule.h>
+
+G_DEFINE_TYPE (KaPluginAfs, ka_plugin_afs, KA_TYPE_PLUGIN)
+#define GET_PRIVATE(o) \
+  (G_TYPE_INSTANCE_GET_PRIVATE ((o), KA_TYPE_PLUGIN_AFS, KaPluginAfsPrivate))
+
+int ka_plugin_major_version = KA_PLUGIN_MAJOR_VERSION;
+int ka_plugin_minor_version = KA_PLUGIN_MINOR_VERSION;
+
+G_MODULE_EXPORT KaPlugin *
+ka_plugin_create (void)
+{
+    return KA_PLUGIN (ka_plugin_afs_new ());
+}
+
+typedef struct _KaPluginAfsPrivate KaPluginAfsPrivate;
+
+struct _KaPluginAfsPrivate {
+    gulong handlers[2];
+};
+
+static void
+event_cb (gpointer *applet, gchar *princ, guint when, gpointer user_data)
+{
+    GError *err = NULL;
+    gboolean ret;
+    int i;
+    const char *afslog_cmds[] = { "aklog", "afslog" };
+
+    for (i = 0; i < G_N_ELEMENTS (afslog_cmds); i++) {
+        ret = g_spawn_command_line_async (afslog_cmds[i], &err);
+        if (!ret) {
+            if (G_SPAWN_ERROR_NOENT != err->code)
+                g_warning ("%s", err->message);
+        } else
+            break;
+        g_clear_error (&err);
+    }
+
+    if (!ret)
+        g_warning ("Couldn't run any afslog command");
+}
+
+static void
+ka_plugin_afs_finalize (GObject *object)
+{
+    G_OBJECT_CLASS (ka_plugin_afs_parent_class)->finalize (object);
+}
+
+static void
+ka_plugin_afs_activate (KaPlugin *self, KaApplet *applet)
+{
+    KaPluginAfsPrivate *priv = GET_PRIVATE (self);
+
+    priv->handlers[0] = g_signal_connect (applet,
+                                          "krb-tgt-acquired",
+                                          G_CALLBACK (event_cb), "Acquired");
+    priv->handlers[1] = g_signal_connect (applet,
+                                          "krb-tgt-renewed",
+                                          G_CALLBACK (event_cb), "Renewed");
+}
+
+static void
+ka_plugin_afs_deactivate (KaPlugin *self, KaApplet *applet)
+{
+    int i;
+    KaPluginAfsPrivate *priv = GET_PRIVATE (self);
+
+    for (i = 0; i < G_N_ELEMENTS (priv->handlers); i++)
+        g_signal_handler_disconnect (applet, priv->handlers[i]);
+}
+
+static void
+ka_plugin_afs_class_init (KaPluginAfsClass *klass)
+{
+    GObjectClass *object_class = G_OBJECT_CLASS (klass);
+    KaPluginClass *plugin_class = KA_PLUGIN_CLASS (klass);
+
+    g_type_class_add_private (klass, sizeof (KaPluginAfsPrivate));
+
+    plugin_class->activate = ka_plugin_afs_activate;
+    plugin_class->deactivate = ka_plugin_afs_deactivate;
+    object_class->finalize = ka_plugin_afs_finalize;
+}
+
+static void
+ka_plugin_afs_init (KaPluginAfs *self)
+{
+}
+
+KaPluginAfs *
+ka_plugin_afs_new (void)
+{
+    return g_object_new (KA_TYPE_PLUGIN_AFS, KA_PLUGIN_PROP_NAME, "afs", NULL);
+}
diff --git a/plugins/ka-plugin-afs.h b/plugins/ka-plugin-afs.h
new file mode 100644
index 0000000..c4fb71d
--- /dev/null
+++ b/plugins/ka-plugin-afs.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2010 Guido Guenther <agx@sigxcpu.org>
+ *
+ * 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, 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 _KA_PLUGIN_DUMMY
+#define _KA_PLUGIN_DUMMY
+
+#include "ka-plugin.h"
+
+G_BEGIN_DECLS
+#define KA_TYPE_PLUGIN_AFS ka_plugin_afs_get_type()
+#define KA_PLUGIN_AFS(obj) \
+  (G_TYPE_CHECK_INSTANCE_CAST ((obj), KA_TYPE_PLUGIN_AFS, KaPluginAfs))
+#define KA_PLUGIN_AFS_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_CAST ((klass), KA_TYPE_PLUGIN_AFS, KaPluginAfsClass))
+#define KA_IS_PLUGIN_AFS(obj) \
+  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), KA_TYPE_PLUGIN_AFS))
+#define KA_IS_PLUGIN_AFS_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_TYPE ((klass), KA_TYPE_PLUGIN_AFS))
+#define KA_PLUGIN_AFS_GET_CLASS(obj) \
+  (G_TYPE_INSTANCE_GET_CLASS ((obj), KA_TYPE_PLUGIN_AFS, KaPluginAfsClass))
+
+typedef struct {
+    KaPlugin parent;
+} KaPluginAfs;
+
+typedef struct {
+    KaPluginClass parent_class;
+} KaPluginAfsClass;
+
+GType ka_plugin_afs_get_type (void);
+
+KaPluginAfs *ka_plugin_afs_new (void);
+
+G_END_DECLS
+#endif /* _KA_PLUGIN_AFS */
-- 
bgstack15