[systemd-commits] Makefile.am src/acl-util.c src/acl-util.h src/journal src/login src/shared

Kay Sievers kay at kemper.freedesktop.org
Tue Apr 10 06:12:31 PDT 2012


 Makefile.am            |   61 ++++++++++++++++++++++++-------------------
 src/acl-util.c         |   68 -------------------------------------------------
 src/acl-util.h         |   27 -------------------
 src/journal/journald.c |    2 -
 src/login/logind-acl.c |    2 -
 src/shared/acl.c       |   68 +++++++++++++++++++++++++++++++++++++++++++++++++
 src/shared/acl.h       |   27 +++++++++++++++++++
 7 files changed, 131 insertions(+), 124 deletions(-)

New commits:
commit 78b2e3a632748fbeae8a9eb70ab1940e4a70619a
Author: Kay Sievers <kay at vrfy.org>
Date:   Tue Apr 10 14:53:38 2012 +0200

    util: move ACL code into internal library

diff --git a/Makefile.am b/Makefile.am
index 357002b..789e442 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -477,6 +477,7 @@ noinst_LTLIBRARIES = \
 	libsystemd-basic.la \
 	libsystemd-capability.la \
 	libsystemd-audit.la \
+	libsystemd-acl.la \
 	libsystemd-core.la
 
 # ------------------------------------------------------------------------------
@@ -535,6 +536,18 @@ libsystemd_audit_la_LIBADD = \
 	libsystemd-capability.la
 
 # ------------------------------------------------------------------------------
+libsystemd_acl_la_SOURCES = \
+	src/shared/acl.c \
+	src/shared/acl.h
+
+libsystemd_acl_la_CFLAGS = \
+	$(AM_CFLAGS) \
+	$(ACL_CFLAGS)
+
+libsystemd_acl_la_LIBADD = \
+	$(ACL_LIBS)
+
+# ------------------------------------------------------------------------------
 libsystemd_core_la_SOURCES = \
 	src/unit.c \
 	src/unit.h \
@@ -666,7 +679,6 @@ libsystemd_core_la_SOURCES = \
 	src/polkit.h \
 	src/dbus-loop.h \
 	src/spawn-agent.h \
-	src/acl-util.h \
 	src/logs-show.h
 
 nodist_libsystemd_core_la_SOURCES = \
@@ -1345,15 +1357,11 @@ udev_common_CPPFLAGS = \
 if HAVE_ACL
 udev_common_sources += \
 	src/udev/udev-builtin-uaccess.c \
-	src/login/logind-acl.c \
-	src/acl-util.c
-
-udev_common_CFLAGS += \
-	$(ACL_CFLAGS)
+	src/login/logind-acl.c
 
 udev_common_LDADD += \
 	libsystemd-login.la \
-	$(ACL_LIBS)
+	libsystemd-acl.la
 endif
 
 udevd_SOURCES = \
@@ -1883,30 +1891,29 @@ systemd_journald_SOURCES = \
 	src/sd-id128.c \
 	src/cgroup-util.c
 
-if HAVE_ACL
-systemd_journald_SOURCES += \
-	src/acl-util.c
-endif
-
 nodist_systemd_journald_SOURCES = \
 	src/journal/journald-gperf.c
 
-systemd_journald_CFLAGS = \
-	$(AM_CFLAGS) \
-	$(ACL_CFLAGS)
+systemd_journald_CFLAGS =
 
 systemd_journald_LDADD = \
 	libsystemd-basic.la \
 	libsystemd-audit.la \
 	libsystemd-daemon.la \
-	libsystemd-login.la \
-	$(ACL_LIBS)
+	libsystemd-login.la
+
+if HAVE_ACL
+systemd_journald_LDADD += \
+	libsystemd-acl.la
+endif
 
 if HAVE_XZ
 systemd_journald_SOURCES += \
 	src/journal/compress.c
+
 systemd_journald_CFLAGS += \
 	$(XZ_CFLAGS)
+
 systemd_journald_LDADD += \
 	$(XZ_LIBS)
 endif
@@ -2493,24 +2500,24 @@ systemd_logind_SOURCES = \
 nodist_systemd_logind_SOURCES = \
 	src/login/logind-gperf.c
 
-if HAVE_ACL
-systemd_logind_SOURCES += \
-	src/login/logind-acl.c \
-	src/acl-util.c
-endif
-
 systemd_logind_CFLAGS = \
 	$(AM_CFLAGS) \
-	$(DBUS_CFLAGS) \
-	$(ACL_CFLAGS)
+	$(DBUS_CFLAGS)
 
 systemd_logind_LDADD = \
 	libsystemd-basic.la \
 	libsystemd-audit.la \
 	libsystemd-daemon.la \
 	libudev.la \
-	$(DBUS_LIBS) \
-	$(ACL_LIBS)
+	$(DBUS_LIBS)
+
+if HAVE_ACL
+systemd_logind_SOURCES += \
+	src/login/logind-acl.c
+
+systemd_logind_LDADD += \
+	libsystemd-acl.la
+endif
 
 systemd_user_sessions_SOURCES = \
 	src/login/user-sessions.c \
diff --git a/src/acl-util.c b/src/acl-util.c
deleted file mode 100644
index a2a9f9a..0000000
--- a/src/acl-util.c
+++ /dev/null
@@ -1,68 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
-  This file is part of systemd.
-
-  Copyright 2011 Lennart Poettering
-
-  systemd 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.
-
-  systemd 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 systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <assert.h>
-#include <sys/acl.h>
-#include <acl/libacl.h>
-#include <errno.h>
-#include <stdbool.h>
-
-#include "acl-util.h"
-
-int acl_find_uid(acl_t acl, uid_t uid, acl_entry_t *entry) {
-        acl_entry_t i;
-        int found;
-
-        assert(acl);
-        assert(entry);
-
-        for (found = acl_get_entry(acl, ACL_FIRST_ENTRY, &i);
-             found > 0;
-             found = acl_get_entry(acl, ACL_NEXT_ENTRY, &i)) {
-
-                acl_tag_t tag;
-                uid_t *u;
-                bool b;
-
-                if (acl_get_tag_type(i, &tag) < 0)
-                        return -errno;
-
-                if (tag != ACL_USER)
-                        continue;
-
-                u = acl_get_qualifier(i);
-                if (!u)
-                        return -errno;
-
-                b = *u == uid;
-                acl_free(u);
-
-                if (b) {
-                        *entry = i;
-                        return 1;
-                }
-        }
-
-        if (found < 0)
-                return -errno;
-
-        return 0;
-}
diff --git a/src/acl-util.h b/src/acl-util.h
deleted file mode 100644
index 798ce43..0000000
--- a/src/acl-util.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-#ifndef fooaclutilhfoo
-#define fooaclutilhfoo
-
-/***
-  This file is part of systemd.
-
-  Copyright 2011 Lennart Poettering
-
-  systemd 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.
-
-  systemd 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 systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-int acl_find_uid(acl_t acl, uid_t uid, acl_entry_t *entry);
-
-#endif
diff --git a/src/journal/journald.c b/src/journal/journald.c
index 555d74f..442d2eb 100644
--- a/src/journal/journald.c
+++ b/src/journal/journald.c
@@ -50,7 +50,7 @@
 #ifdef HAVE_ACL
 #include <sys/acl.h>
 #include <acl/libacl.h>
-#include "acl-util.h"
+#include "acl.h"
 #endif
 
 #ifdef HAVE_SELINUX
diff --git a/src/login/logind-acl.c b/src/login/logind-acl.c
index eb8a48d..e2e8696 100644
--- a/src/login/logind-acl.c
+++ b/src/login/logind-acl.c
@@ -27,7 +27,7 @@
 
 #include "logind-acl.h"
 #include "util.h"
-#include "acl-util.h"
+#include "acl.h"
 
 static int flush_acl(acl_t acl) {
         acl_entry_t i;
diff --git a/src/shared/acl.c b/src/shared/acl.c
new file mode 100644
index 0000000..d6a80f4
--- /dev/null
+++ b/src/shared/acl.c
@@ -0,0 +1,68 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
+/***
+  This file is part of systemd.
+
+  Copyright 2011 Lennart Poettering
+
+  systemd 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.
+
+  systemd 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 systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include <assert.h>
+#include <sys/acl.h>
+#include <acl/libacl.h>
+#include <errno.h>
+#include <stdbool.h>
+
+#include "acl.h"
+
+int acl_find_uid(acl_t acl, uid_t uid, acl_entry_t *entry) {
+        acl_entry_t i;
+        int found;
+
+        assert(acl);
+        assert(entry);
+
+        for (found = acl_get_entry(acl, ACL_FIRST_ENTRY, &i);
+             found > 0;
+             found = acl_get_entry(acl, ACL_NEXT_ENTRY, &i)) {
+
+                acl_tag_t tag;
+                uid_t *u;
+                bool b;
+
+                if (acl_get_tag_type(i, &tag) < 0)
+                        return -errno;
+
+                if (tag != ACL_USER)
+                        continue;
+
+                u = acl_get_qualifier(i);
+                if (!u)
+                        return -errno;
+
+                b = *u == uid;
+                acl_free(u);
+
+                if (b) {
+                        *entry = i;
+                        return 1;
+                }
+        }
+
+        if (found < 0)
+                return -errno;
+
+        return 0;
+}
diff --git a/src/shared/acl.h b/src/shared/acl.h
new file mode 100644
index 0000000..798ce43
--- /dev/null
+++ b/src/shared/acl.h
@@ -0,0 +1,27 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
+#ifndef fooaclutilhfoo
+#define fooaclutilhfoo
+
+/***
+  This file is part of systemd.
+
+  Copyright 2011 Lennart Poettering
+
+  systemd 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.
+
+  systemd 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 systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+int acl_find_uid(acl_t acl, uid_t uid, acl_entry_t *entry);
+
+#endif



More information about the systemd-commits mailing list