add polkit auth object, compile it in makefile, add header to interfaces
authorkremlin <ian@kremlin.cc>
Sat, 16 Aug 2014 02:11:32 +0000 (21:11 -0500)
committerkremlin <ian@kremlin.cc>
Sat, 16 Aug 2014 02:11:32 +0000 (21:11 -0500)
src/polkit-auth.c and its header are seperately built objects, linked
to interfaces, which expose a single, safe auth checking function

Makefile
src/interfaces/hostnamed/hostnamed.c
src/interfaces/localed/localed.c
src/interfaces/logind/logind.c
src/interfaces/timedated/timedated.c
src/polkit-auth.c [new file with mode: 0644]
src/polkit-auth.h [new file with mode: 0644]

index 9664f9e899f29474ec6ebe759dc855ca196f4818..93f52f248a5d51a5f63f37d66631a03d58c16e6f 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -67,17 +67,20 @@ clean:
 install: _install_conf _install_interface_binaries
 
 _build_interface_objs: _build_genfile_objs
 install: _install_conf _install_interface_binaries
 
 _build_interface_objs: _build_genfile_objs
-       $(CC) -o bin/systemd-hostnamed $(CFLAGS) $(GLIBEF) $(INTFDIR)/hostnamed/hostnamed.c bin/obj/hostnamed-gen.o 
-       $(CC) -o bin/systemd-localed   $(CFLAGS) $(GLIBEF) $(INTFDIR)/localed/localed.c     bin/obj/localed-gen.o
-       $(CC) -o bin/systemd-timedated $(CFLAGS) $(GLIBEF) $(INTFDIR)/timedated/timedated.c bin/obj/timedated-gen.o
-       $(CC) -o bin/systemd-logind    $(CFLAGS) $(GLIBEF) $(INTFDIR)/logind/logind.c       bin/obj/logind-gen.o
+       $(CC) -o bin/systemd-hostnamed $(CFLAGS) $(GLIBEF) $(INTFDIR)/hostnamed/hostnamed.c bin/obj/hostnamed-gen.o bin/obj/polkit-auth.o 
+       $(CC) -o bin/systemd-localed   $(CFLAGS) $(GLIBEF) $(INTFDIR)/localed/localed.c     bin/obj/localed-gen.o   bin/obj/polkit-auth.o
+       $(CC) -o bin/systemd-timedated $(CFLAGS) $(GLIBEF) $(INTFDIR)/timedated/timedated.c bin/obj/timedated-gen.o bin/obj/polkit-auth.o
+       $(CC) -o bin/systemd-logind    $(CFLAGS) $(GLIBEF) $(INTFDIR)/logind/logind.c       bin/obj/logind-gen.o    bin/obj/polkit-auth.o
 
 
-_build_genfile_objs: _generate_genfiles
+_build_genfile_objs: _generate_genfiles _build_auth_obj
        $(CC) -o bin/obj/hostnamed-gen.o $(CFLAGS) $(GLIBOF) -c $(INTFDIR)/hostnamed/hostnamed-gen.c
        $(CC) -o bin/obj/localed-gen.o   $(CFLAGS) $(GLIBOF) -c $(INTFDIR)/localed/localed-gen.c
        $(CC) -o bin/obj/timedated-gen.o $(CFLAGS) $(GLIBOF) -c $(INTFDIR)/timedated/timedated-gen.c
        $(CC) -o bin/obj/logind-gen.o    $(CFLAGS) $(GLIBOF) -c $(INTFDIR)/logind/logind-gen.c
 
        $(CC) -o bin/obj/hostnamed-gen.o $(CFLAGS) $(GLIBOF) -c $(INTFDIR)/hostnamed/hostnamed-gen.c
        $(CC) -o bin/obj/localed-gen.o   $(CFLAGS) $(GLIBOF) -c $(INTFDIR)/localed/localed-gen.c
        $(CC) -o bin/obj/timedated-gen.o $(CFLAGS) $(GLIBOF) -c $(INTFDIR)/timedated/timedated-gen.c
        $(CC) -o bin/obj/logind-gen.o    $(CFLAGS) $(GLIBOF) -c $(INTFDIR)/logind/logind-gen.c
 
+_build_auth_obj:
+       $(CC) -o bin/obj/polkit-auth.o $(CFLAGS) $(GLIBOF) -c $(SRCDIR)/polkit-auth.c
+
 _generate_genfiles:
        $(INVOKE_GENFILE_SCRIPT) hostnamed
        $(INVOKE_GENFILE_SCRIPT) localed
 _generate_genfiles:
        $(INVOKE_GENFILE_SCRIPT) hostnamed
        $(INVOKE_GENFILE_SCRIPT) localed
index b10b4b767b63abd19cbcd61922287ad7b4fe4c3e..574357de08484c2fdfa7a1cd7858b05706ac9a0e 100644 (file)
@@ -34,6 +34,8 @@
 #include "hostnamed-gen.h"
 #include "hostnamed.h"
 
 #include "hostnamed-gen.h"
 #include "hostnamed.h"
 
+#include "../../polkit-auth.h"
+
 /* format: {
  *           (1) string to be matched against runtime machine's sysctl output.
  *               can be either the exact string or a substring contained
 /* format: {
  *           (1) string to be matched against runtime machine's sysctl output.
  *               can be either the exact string or a substring contained
@@ -403,6 +405,8 @@ int main() {
     CHASSIS = ICON = OS_CPENAME = 0;
     KERN_NAME = KERN_RELEASE = KERN_VERS = 0;
     HOSTNAME = STATIC_HOSTNAME = PRETTY_HOSTNAME = NULL;
     CHASSIS = ICON = OS_CPENAME = 0;
     KERN_NAME = KERN_RELEASE = KERN_VERS = 0;
     HOSTNAME = STATIC_HOSTNAME = PRETTY_HOSTNAME = NULL;
+
+    test_func();
  
     set_signal_handlers();
 
  
     set_signal_handlers();
 
index 596c2e3404e8b65cc7292f42290f996b1928e357..33769a3f06a4ba3449533d8c466ae8a098058a5b 100644 (file)
@@ -28,6 +28,8 @@
 #include "localed-gen.h"
 #include "localed.h"
 
 #include "localed-gen.h"
 #include "localed.h"
 
+#include "../../polkit-auth.h"
+
 GPtrArray *localed_freeable;
 Locale1 *localed_interf;
 
 GPtrArray *localed_freeable;
 Locale1 *localed_interf;
 
index 9ccde2f42ceed1da92326ad22b96e6cba4946a5a..c4456654e4830e98955e6419026b176f8dd4bb2b 100644 (file)
@@ -28,6 +28,8 @@
 #include "logind-gen.h"
 #include "logind.h"
 
 #include "logind-gen.h"
 #include "logind.h"
 
+#include "../../polkit-auth.h"
+
 GPtrArray *logind_freeable;
 Login1Manager *logind_interf;
 
 GPtrArray *logind_freeable;
 Login1Manager *logind_interf;
 
index 67f7a0c4a9bcac07a81f92d447c53a87c7306d43..f76850c4f6fadd270307b4c0c15ffb96c0e5e4fe 100644 (file)
@@ -28,6 +28,8 @@
 #include "timedated-gen.h"
 #include "timedated.h"
 
 #include "timedated-gen.h"
 #include "timedated.h"
 
+#include "../../polkit-auth.h"
+
 GPtrArray *timedated_freeable;
 Timedate1 *timedated_interf;
 
 GPtrArray *timedated_freeable;
 Timedate1 *timedated_interf;
 
diff --git a/src/polkit-auth.c b/src/polkit-auth.c
new file mode 100644 (file)
index 0000000..2e4178f
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2014 Ian Sutton <ian@kremlin.cc>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <unistd.h>
+#include <limits.h>
+#include <string.h>
+
+#include <glib/gprintf.h>
+#include <glib-unix.h>
+#include <polkit/polkit.h>
+
+#include "polkit-auth.h"
+
+void test_func() {
+    g_printf("test!\n");
+}
diff --git a/src/polkit-auth.h b/src/polkit-auth.h
new file mode 100644 (file)
index 0000000..17a919b
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+ * Copyright (c) 2014 Ian Sutton <ian@kremlin.cc>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+
+void test_func();