chiark / gitweb /
Prep v225: Applying various fixes and changes to src/shared that got lost during...
[elogind.git] / src / shared / condition.c
index 59f262244b202a3f7aa6bc72ed13e5ea023bea18..24871b0daedb2b3491e78aaff0f42803ad1a79cc 100644 (file)
 #include <errno.h>
 #include <string.h>
 #include <unistd.h>
-#include <sys/statvfs.h>
 #include <fnmatch.h>
 
 #include "sd-id128.h"
 #include "util.h"
 #include "virt.h"
 #include "path-util.h"
-#include "fileio.h"
-#include "unit.h"
 #include "architecture.h"
 #include "smack-util.h"
 #include "apparmor-util.h"
 #include "ima-util.h"
 #include "selinux-util.h"
 #include "audit.h"
+#include "cap-list.h"
+#include "hostname-util.h"
 #include "condition.h"
 
 Condition* condition_new(ConditionType type, const char *parameter, bool trigger, bool negate) {
@@ -46,7 +45,7 @@ Condition* condition_new(ConditionType type, const char *parameter, bool trigger
 
         assert(type >= 0);
         assert(type < _CONDITION_TYPE_MAX);
-        assert(!parameter == (type == CONDITION_NULL));
+        assert((!parameter) == (type == CONDITION_NULL));
 
         c = new0(Condition, 1);
         if (!c)
@@ -72,11 +71,13 @@ void condition_free(Condition *c) {
         free(c);
 }
 
-void condition_free_list(Condition *first) {
+Condition* condition_free_list(Condition *first) {
         Condition *c, *n;
 
         LIST_FOREACH_SAFE(conditions, c, n, first)
                 condition_free(c);
+
+        return NULL;
 }
 
 static int condition_test_kernel_command_line(Condition *c) {
@@ -100,7 +101,7 @@ static int condition_test_kernel_command_line(Condition *c) {
                 _cleanup_free_ char *word = NULL;
                 bool found;
 
-                r = unquote_first_word(&p, &word, true);
+                r = unquote_first_word(&p, &word, UNQUOTE_RELAX);
                 if (r < 0)
                         return r;
                 if (r == 0)
@@ -235,7 +236,7 @@ static int condition_test_security(Condition *c) {
 
 static int condition_test_capability(Condition *c) {
         _cleanup_fclose_ FILE *f = NULL;
-        cap_value_t value;
+        int value;
         char line[LINE_MAX];
         unsigned long long capabilities = -1;
 
@@ -244,8 +245,8 @@ static int condition_test_capability(Condition *c) {
         assert(c->type == CONDITION_CAPABILITY);
 
         /* If it's an invalid capability, we don't have it */
-
-        if (cap_from_name(c->parameter, &value) < 0)
+        value = capability_from_name(c->parameter);
+        if (value < 0)
                 return -EINVAL;
 
         /* If it's a valid capability we default to assume
@@ -286,7 +287,7 @@ static int condition_test_needs_update(Condition *c) {
         if (!path_is_absolute(c->parameter))
                 return true;
 
-        p = strappenda(c->parameter, "/.updated");
+        p = strjoina(c->parameter, "/.updated");
         if (lstat(p, &other) < 0)
                 return true;
 
@@ -348,7 +349,7 @@ static int condition_test_path_is_mount_point(Condition *c) {
         assert(c->parameter);
         assert(c->type == CONDITION_PATH_IS_MOUNT_POINT);
 
-        return path_is_mount_point(c->parameter, true) > 0;
+        return path_is_mount_point(c->parameter, AT_SYMLINK_FOLLOW) > 0;
 }
 
 static int condition_test_path_is_read_write(Condition *c) {