1 /* SPDX-License-Identifier: LGPL-2.1+ */
9 #include <sys/utsname.h>
15 #include "alloc-util.h"
16 #include "apparmor-util.h"
17 #include "architecture.h"
18 #include "audit-util.h"
20 #include "cgroup-util.h"
21 #include "condition.h"
22 #include "cpu-set-util.h"
23 #include "efi-loader.h"
25 #include "extract-word.h"
29 #include "glob-util.h"
30 #include "hostname-util.h"
32 #include "limits-util.h"
35 #include "mountpoint-util.h"
36 #include "parse-util.h"
37 #include "path-util.h"
38 #include "proc-cmdline.h"
39 #include "process-util.h"
40 #include "selinux-util.h"
41 #include "smack-util.h"
42 #include "stat-util.h"
43 #include "string-table.h"
44 #include "string-util.h"
45 #include "tomoyo-util.h"
46 #include "user-util.h"
50 Condition
* condition_new(ConditionType type
, const char *parameter
, bool trigger
, bool negate
) {
54 assert(type
< _CONDITION_TYPE_MAX
);
55 assert((!parameter
) == (type
== CONDITION_NULL
));
57 c
= new(Condition
, 1);
68 c
->parameter
= strdup(parameter
);
76 Condition
* condition_free(Condition
*c
) {
83 Condition
* condition_free_list_type(Condition
*head
, ConditionType type
) {
86 LIST_FOREACH_SAFE(conditions
, c
, n
, head
)
87 if (type
< 0 || c
->type
== type
) {
88 LIST_REMOVE(conditions
, head
, c
);
92 assert(type
>= 0 || !head
);
96 static int condition_test_kernel_command_line(Condition
*c
, char **env
) {
97 _cleanup_free_
char *line
= NULL
;
103 assert(c
->parameter
);
104 assert(c
->type
== CONDITION_KERNEL_COMMAND_LINE
);
106 r
= proc_cmdline(&line
);
110 equal
= strchr(c
->parameter
, '=');
113 _cleanup_free_
char *word
= NULL
;
116 r
= extract_first_word(&p
, &word
, NULL
, EXTRACT_UNQUOTE
|EXTRACT_RELAX
);
123 found
= streq(word
, c
->parameter
);
127 f
= startswith(word
, c
->parameter
);
128 found
= f
&& IN_SET(*f
, 0, '=');
139 /* Listed in order of checking. Note that some comparators are prefixes of others, hence the longest
140 * should be listed first. */
141 ORDER_LOWER_OR_EQUAL
,
142 ORDER_GREATER_OR_EQUAL
,
151 static OrderOperator
parse_order(const char **s
) {
153 static const char *const prefix
[_ORDER_MAX
] = {
154 [ORDER_LOWER_OR_EQUAL
] = "<=",
155 [ORDER_GREATER_OR_EQUAL
] = ">=",
157 [ORDER_GREATER
] = ">",
159 [ORDER_UNEQUAL
] = "!=",
164 for (i
= 0; i
< _ORDER_MAX
; i
++) {
167 e
= startswith(*s
, prefix
[i
]);
174 return _ORDER_INVALID
;
177 static bool test_order(int k
, OrderOperator p
) {
184 case ORDER_LOWER_OR_EQUAL
:
193 case ORDER_GREATER_OR_EQUAL
:
200 assert_not_reached("unknown order");
205 static int condition_test_kernel_version(Condition
*c
, char **env
) {
212 assert(c
->parameter
);
213 assert(c
->type
== CONDITION_KERNEL_VERSION
);
215 assert_se(uname(&u
) >= 0);
220 _cleanup_free_
char *word
= NULL
;
224 r
= extract_first_word(&p
, &word
, NULL
, EXTRACT_UNQUOTE
);
226 return log_debug_errno(r
, "Failed to parse condition string \"%s\": %m", p
);
231 order
= parse_order(&s
);
233 s
+= strspn(s
, WHITESPACE
);
236 /* For backwards compatibility, allow whitespace between the operator and
237 * value, without quoting, but only in the first expression. */
239 r
= extract_first_word(&p
, &word
, NULL
, 0);
241 return log_debug_errno(r
, "Failed to parse condition string \"%s\": %m", p
);
243 return log_debug_errno(SYNTHETIC_ERRNO(EINVAL
), "Unexpected end of expression: %s", p
);
246 return log_debug_errno(SYNTHETIC_ERRNO(EINVAL
), "Unexpected end of expression: %s", p
);
249 r
= test_order(str_verscmp(u
.release
, s
), order
);
251 /* No prefix? Then treat as glob string */
252 r
= fnmatch(s
, u
.release
, 0) == 0;
263 static int condition_test_memory(Condition
*c
, char **env
) {
270 assert(c
->parameter
);
271 assert(c
->type
== CONDITION_MEMORY
);
273 m
= physical_memory();
276 order
= parse_order(&p
);
278 order
= ORDER_GREATER_OR_EQUAL
; /* default to >= check, if nothing is specified. */
280 r
= safe_atou64(p
, &k
);
282 return log_debug_errno(r
, "Failed to parse size: %m");
284 return test_order(CMP(m
, k
), order
);
287 static int condition_test_cpus(Condition
*c
, char **env
) {
294 assert(c
->parameter
);
295 assert(c
->type
== CONDITION_CPUS
);
297 n
= cpus_in_affinity_mask();
299 return log_debug_errno(n
, "Failed to determine CPUs in affinity mask: %m");
302 order
= parse_order(&p
);
304 order
= ORDER_GREATER_OR_EQUAL
; /* default to >= check, if nothing is specified. */
306 r
= safe_atou(p
, &k
);
308 return log_debug_errno(r
, "Failed to parse number of CPUs: %m");
310 return test_order(CMP((unsigned) n
, k
), order
);
313 static int condition_test_user(Condition
*c
, char **env
) {
316 _cleanup_free_
char *username
= NULL
;
320 assert(c
->parameter
);
321 assert(c
->type
== CONDITION_USER
);
323 r
= parse_uid(c
->parameter
, &id
);
325 return id
== getuid() || id
== geteuid();
327 if (streq("@system", c
->parameter
))
328 return uid_is_system(getuid()) || uid_is_system(geteuid());
330 username
= getusername_malloc();
334 if (streq(username
, c
->parameter
))
337 if (getpid_cached() == 1)
338 return streq(c
->parameter
, "root");
341 r
= get_user_creds(&u
, &id
, NULL
, NULL
, NULL
, USER_CREDS_ALLOW_MISSING
);
345 return id
== getuid() || id
== geteuid();
348 static int condition_test_control_group_controller(Condition
*c
, char **env
) {
350 CGroupMask system_mask
, wanted_mask
= 0;
353 assert(c
->parameter
);
354 assert(c
->type
== CONDITION_CONTROL_GROUP_CONTROLLER
);
356 r
= cg_mask_supported(&system_mask
);
358 return log_debug_errno(r
, "Failed to determine supported controllers: %m");
360 r
= cg_mask_from_string(c
->parameter
, &wanted_mask
);
361 if (r
< 0 || wanted_mask
<= 0) {
362 /* This won't catch the case that we have an unknown controller
363 * mixed in with valid ones -- these are only assessed on the
364 * validity of the valid controllers found. */
365 log_debug("Failed to parse cgroup string: %s", c
->parameter
);
369 return FLAGS_SET(system_mask
, wanted_mask
);
372 static int condition_test_group(Condition
*c
, char **env
) {
377 assert(c
->parameter
);
378 assert(c
->type
== CONDITION_GROUP
);
380 r
= parse_gid(c
->parameter
, &id
);
384 /* Avoid any NSS lookups if we are PID1 */
385 if (getpid_cached() == 1)
386 return streq(c
->parameter
, "root");
388 return in_group(c
->parameter
) > 0;
391 static int condition_test_virtualization(Condition
*c
, char **env
) {
395 assert(c
->parameter
);
396 assert(c
->type
== CONDITION_VIRTUALIZATION
);
398 if (streq(c
->parameter
, "private-users"))
399 return running_in_userns();
401 v
= detect_virtualization();
405 /* First, compare with yes/no */
406 b
= parse_boolean(c
->parameter
);
410 /* Then, compare categorization */
411 if (streq(c
->parameter
, "vm"))
412 return VIRTUALIZATION_IS_VM(v
);
414 if (streq(c
->parameter
, "container"))
415 return VIRTUALIZATION_IS_CONTAINER(v
);
417 /* Finally compare id */
418 return v
!= VIRTUALIZATION_NONE
&& streq(c
->parameter
, virtualization_to_string(v
));
421 static int condition_test_architecture(Condition
*c
, char **env
) {
425 assert(c
->parameter
);
426 assert(c
->type
== CONDITION_ARCHITECTURE
);
428 a
= uname_architecture();
432 if (streq(c
->parameter
, "native"))
433 b
= native_architecture();
435 b
= architecture_from_string(c
->parameter
);
436 if (b
< 0) /* unknown architecture? Then it's definitely not ours */
443 static int condition_test_host(Condition
*c
, char **env
) {
444 _cleanup_free_
char *h
= NULL
;
449 assert(c
->parameter
);
450 assert(c
->type
== CONDITION_HOST
);
452 if (sd_id128_from_string(c
->parameter
, &x
) >= 0) {
454 r
= sd_id128_get_machine(&y
);
458 return sd_id128_equal(x
, y
);
461 h
= gethostname_malloc();
465 return fnmatch(c
->parameter
, h
, FNM_CASEFOLD
) == 0;
468 static int condition_test_ac_power(Condition
*c
, char **env
) {
472 assert(c
->parameter
);
473 assert(c
->type
== CONDITION_AC_POWER
);
475 r
= parse_boolean(c
->parameter
);
479 return (on_ac_power() != 0) == !!r
;
482 static int condition_test_security(Condition
*c
, char **env
) {
484 assert(c
->parameter
);
485 assert(c
->type
== CONDITION_SECURITY
);
487 if (streq(c
->parameter
, "selinux"))
488 return mac_selinux_use();
489 if (streq(c
->parameter
, "smack"))
490 return mac_smack_use();
491 if (streq(c
->parameter
, "apparmor"))
492 return mac_apparmor_use();
493 if (streq(c
->parameter
, "audit"))
495 if (streq(c
->parameter
, "ima"))
497 if (streq(c
->parameter
, "tomoyo"))
498 return mac_tomoyo_use();
499 if (streq(c
->parameter
, "uefi-secureboot"))
500 return is_efi_secure_boot();
505 static int condition_test_capability(Condition
*c
, char **env
) {
506 unsigned long long capabilities
= (unsigned long long) -1;
507 _cleanup_fclose_
FILE *f
= NULL
;
511 assert(c
->parameter
);
512 assert(c
->type
== CONDITION_CAPABILITY
);
514 /* If it's an invalid capability, we don't have it */
515 value
= capability_from_name(c
->parameter
);
519 /* If it's a valid capability we default to assume
522 f
= fopen("/proc/self/status", "re");
527 _cleanup_free_
char *line
= NULL
;
530 r
= read_line(f
, LONG_LINE_MAX
, &line
);
536 p
= startswith(line
, "CapBnd:");
538 if (sscanf(line
+7, "%llx", &capabilities
) != 1)
545 return !!(capabilities
& (1ULL << value
));
548 static int condition_test_needs_update(Condition
*c
, char **env
) {
550 struct stat usr
, other
;
553 assert(c
->parameter
);
554 assert(c
->type
== CONDITION_NEEDS_UPDATE
);
556 /* If the file system is read-only we shouldn't suggest an update */
557 if (path_is_read_only_fs(c
->parameter
) > 0)
560 /* Any other failure means we should allow the condition to be true,
561 * so that we rather invoke too many update tools than too
564 if (!path_is_absolute(c
->parameter
))
567 p
= strjoina(c
->parameter
, "/.updated");
568 if (lstat(p
, &other
) < 0)
571 if (lstat("/usr/", &usr
) < 0)
575 * First, compare seconds as they are always accurate...
577 if (usr
.st_mtim
.tv_sec
!= other
.st_mtim
.tv_sec
)
578 return usr
.st_mtim
.tv_sec
> other
.st_mtim
.tv_sec
;
581 * ...then compare nanoseconds.
583 * A false positive is only possible when /usr's nanoseconds > 0
584 * (otherwise /usr cannot be strictly newer than the target file)
585 * AND the target file's nanoseconds == 0
586 * (otherwise the filesystem supports nsec timestamps, see stat(2)).
588 if (usr
.st_mtim
.tv_nsec
> 0 && other
.st_mtim
.tv_nsec
== 0) {
589 _cleanup_free_
char *timestamp_str
= NULL
;
593 r
= parse_env_file(NULL
, p
, "TIMESTAMP_NSEC", ×tamp_str
);
595 log_error_errno(r
, "Failed to parse timestamp file '%s', using mtime: %m", p
);
598 log_debug("No data in timestamp file '%s', using mtime", p
);
602 r
= safe_atou64(timestamp_str
, ×tamp
);
604 log_error_errno(r
, "Failed to parse timestamp value '%s' in file '%s', using mtime: %m", timestamp_str
, p
);
608 timespec_store(&other
.st_mtim
, timestamp
);
611 return usr
.st_mtim
.tv_nsec
> other
.st_mtim
.tv_nsec
;
614 static int condition_test_first_boot(Condition
*c
, char **env
) {
618 assert(c
->parameter
);
619 assert(c
->type
== CONDITION_FIRST_BOOT
);
621 r
= parse_boolean(c
->parameter
);
625 return (access("/run/systemd/first-boot", F_OK
) >= 0) == !!r
;
628 static int condition_test_environment(Condition
*c
, char **env
) {
633 assert(c
->parameter
);
634 assert(c
->type
== CONDITION_ENVIRONMENT
);
636 equal
= strchr(c
->parameter
, '=');
638 STRV_FOREACH(i
, env
) {
642 found
= streq(c
->parameter
, *i
);
646 f
= startswith(*i
, c
->parameter
);
647 found
= f
&& IN_SET(*f
, 0, '=');
657 static int condition_test_path_exists(Condition
*c
, char **env
) {
659 assert(c
->parameter
);
660 assert(c
->type
== CONDITION_PATH_EXISTS
);
662 return access(c
->parameter
, F_OK
) >= 0;
665 static int condition_test_path_exists_glob(Condition
*c
, char **env
) {
667 assert(c
->parameter
);
668 assert(c
->type
== CONDITION_PATH_EXISTS_GLOB
);
670 return glob_exists(c
->parameter
) > 0;
673 static int condition_test_path_is_directory(Condition
*c
, char **env
) {
675 assert(c
->parameter
);
676 assert(c
->type
== CONDITION_PATH_IS_DIRECTORY
);
678 return is_dir(c
->parameter
, true) > 0;
681 static int condition_test_path_is_symbolic_link(Condition
*c
, char **env
) {
683 assert(c
->parameter
);
684 assert(c
->type
== CONDITION_PATH_IS_SYMBOLIC_LINK
);
686 return is_symlink(c
->parameter
) > 0;
689 static int condition_test_path_is_mount_point(Condition
*c
, char **env
) {
691 assert(c
->parameter
);
692 assert(c
->type
== CONDITION_PATH_IS_MOUNT_POINT
);
694 return path_is_mount_point(c
->parameter
, NULL
, AT_SYMLINK_FOLLOW
) > 0;
697 static int condition_test_path_is_read_write(Condition
*c
, char **env
) {
699 assert(c
->parameter
);
700 assert(c
->type
== CONDITION_PATH_IS_READ_WRITE
);
702 return path_is_read_only_fs(c
->parameter
) <= 0;
705 static int condition_test_path_is_encrypted(Condition
*c
, char **env
) {
709 assert(c
->parameter
);
710 assert(c
->type
== CONDITION_PATH_IS_ENCRYPTED
);
712 r
= path_is_encrypted(c
->parameter
);
713 if (r
< 0 && r
!= -ENOENT
)
714 log_debug_errno(r
, "Failed to determine if '%s' is encrypted: %m", c
->parameter
);
719 static int condition_test_directory_not_empty(Condition
*c
, char **env
) {
723 assert(c
->parameter
);
724 assert(c
->type
== CONDITION_DIRECTORY_NOT_EMPTY
);
726 r
= dir_is_empty(c
->parameter
);
727 return r
<= 0 && r
!= -ENOENT
;
730 static int condition_test_file_not_empty(Condition
*c
, char **env
) {
734 assert(c
->parameter
);
735 assert(c
->type
== CONDITION_FILE_NOT_EMPTY
);
737 return (stat(c
->parameter
, &st
) >= 0 &&
738 S_ISREG(st
.st_mode
) &&
742 static int condition_test_file_is_executable(Condition
*c
, char **env
) {
746 assert(c
->parameter
);
747 assert(c
->type
== CONDITION_FILE_IS_EXECUTABLE
);
749 return (stat(c
->parameter
, &st
) >= 0 &&
750 S_ISREG(st
.st_mode
) &&
751 (st
.st_mode
& 0111));
754 static int condition_test_null(Condition
*c
, char **env
) {
756 assert(c
->type
== CONDITION_NULL
);
758 /* Note that during parsing we already evaluate the string and
759 * store it in c->negate */
763 int condition_test(Condition
*c
, char **env
) {
765 static int (*const condition_tests
[_CONDITION_TYPE_MAX
])(Condition
*c
, char **env
) = {
766 [CONDITION_PATH_EXISTS
] = condition_test_path_exists
,
767 [CONDITION_PATH_EXISTS_GLOB
] = condition_test_path_exists_glob
,
768 [CONDITION_PATH_IS_DIRECTORY
] = condition_test_path_is_directory
,
769 [CONDITION_PATH_IS_SYMBOLIC_LINK
] = condition_test_path_is_symbolic_link
,
770 [CONDITION_PATH_IS_MOUNT_POINT
] = condition_test_path_is_mount_point
,
771 [CONDITION_PATH_IS_READ_WRITE
] = condition_test_path_is_read_write
,
772 [CONDITION_PATH_IS_ENCRYPTED
] = condition_test_path_is_encrypted
,
773 [CONDITION_DIRECTORY_NOT_EMPTY
] = condition_test_directory_not_empty
,
774 [CONDITION_FILE_NOT_EMPTY
] = condition_test_file_not_empty
,
775 [CONDITION_FILE_IS_EXECUTABLE
] = condition_test_file_is_executable
,
776 [CONDITION_KERNEL_COMMAND_LINE
] = condition_test_kernel_command_line
,
777 [CONDITION_KERNEL_VERSION
] = condition_test_kernel_version
,
778 [CONDITION_VIRTUALIZATION
] = condition_test_virtualization
,
779 [CONDITION_SECURITY
] = condition_test_security
,
780 [CONDITION_CAPABILITY
] = condition_test_capability
,
781 [CONDITION_HOST
] = condition_test_host
,
782 [CONDITION_AC_POWER
] = condition_test_ac_power
,
783 [CONDITION_ARCHITECTURE
] = condition_test_architecture
,
784 [CONDITION_NEEDS_UPDATE
] = condition_test_needs_update
,
785 [CONDITION_FIRST_BOOT
] = condition_test_first_boot
,
786 [CONDITION_USER
] = condition_test_user
,
787 [CONDITION_GROUP
] = condition_test_group
,
788 [CONDITION_CONTROL_GROUP_CONTROLLER
] = condition_test_control_group_controller
,
789 [CONDITION_NULL
] = condition_test_null
,
790 [CONDITION_CPUS
] = condition_test_cpus
,
791 [CONDITION_MEMORY
] = condition_test_memory
,
792 [CONDITION_ENVIRONMENT
] = condition_test_environment
,
798 assert(c
->type
>= 0);
799 assert(c
->type
< _CONDITION_TYPE_MAX
);
801 r
= condition_tests
[c
->type
](c
, env
);
803 c
->result
= CONDITION_ERROR
;
807 b
= (r
> 0) == !c
->negate
;
808 c
->result
= b
? CONDITION_SUCCEEDED
: CONDITION_FAILED
;
812 bool condition_test_list(
815 condition_to_string_t to_string
,
816 condition_test_logger_t logger
,
822 assert(!!logger
== !!to_string
);
824 /* If the condition list is empty, then it is true */
828 /* Otherwise, if all of the non-trigger conditions apply and
829 * if any of the trigger conditions apply (unless there are
830 * none) we return true */
831 LIST_FOREACH(conditions
, c
, first
) {
834 r
= condition_test(c
, env
);
837 const char *p
= c
->type
== CONDITION_NULL
? "true" : c
->parameter
;
841 logger(userdata
, LOG_WARNING
, r
, PROJECT_FILE
, __LINE__
, __func__
,
842 "Couldn't determine result for %s=%s%s%s, assuming failed: %m",
844 c
->trigger
? "|" : "",
845 c
->negate
? "!" : "",
848 logger(userdata
, LOG_DEBUG
, 0, PROJECT_FILE
, __LINE__
, __func__
,
851 c
->trigger
? "|" : "",
852 c
->negate
? "!" : "",
854 condition_result_to_string(c
->result
));
857 if (!c
->trigger
&& r
<= 0)
860 if (c
->trigger
&& triggered
<= 0)
864 return triggered
!= 0;
867 void condition_dump(Condition
*c
, FILE *f
, const char *prefix
, condition_to_string_t to_string
) {
872 prefix
= strempty(prefix
);
875 "%s\t%s: %s%s%s %s\n",
878 c
->trigger
? "|" : "",
879 c
->negate
? "!" : "",
881 condition_result_to_string(c
->result
));
884 void condition_dump_list(Condition
*first
, FILE *f
, const char *prefix
, condition_to_string_t to_string
) {
887 LIST_FOREACH(conditions
, c
, first
)
888 condition_dump(c
, f
, prefix
, to_string
);
891 static const char* const condition_type_table
[_CONDITION_TYPE_MAX
] = {
892 [CONDITION_ARCHITECTURE
] = "ConditionArchitecture",
893 [CONDITION_VIRTUALIZATION
] = "ConditionVirtualization",
894 [CONDITION_HOST
] = "ConditionHost",
895 [CONDITION_KERNEL_COMMAND_LINE
] = "ConditionKernelCommandLine",
896 [CONDITION_KERNEL_VERSION
] = "ConditionKernelVersion",
897 [CONDITION_SECURITY
] = "ConditionSecurity",
898 [CONDITION_CAPABILITY
] = "ConditionCapability",
899 [CONDITION_AC_POWER
] = "ConditionACPower",
900 [CONDITION_NEEDS_UPDATE
] = "ConditionNeedsUpdate",
901 [CONDITION_FIRST_BOOT
] = "ConditionFirstBoot",
902 [CONDITION_PATH_EXISTS
] = "ConditionPathExists",
903 [CONDITION_PATH_EXISTS_GLOB
] = "ConditionPathExistsGlob",
904 [CONDITION_PATH_IS_DIRECTORY
] = "ConditionPathIsDirectory",
905 [CONDITION_PATH_IS_SYMBOLIC_LINK
] = "ConditionPathIsSymbolicLink",
906 [CONDITION_PATH_IS_MOUNT_POINT
] = "ConditionPathIsMountPoint",
907 [CONDITION_PATH_IS_READ_WRITE
] = "ConditionPathIsReadWrite",
908 [CONDITION_PATH_IS_ENCRYPTED
] = "ConditionPathIsEncrypted",
909 [CONDITION_DIRECTORY_NOT_EMPTY
] = "ConditionDirectoryNotEmpty",
910 [CONDITION_FILE_NOT_EMPTY
] = "ConditionFileNotEmpty",
911 [CONDITION_FILE_IS_EXECUTABLE
] = "ConditionFileIsExecutable",
912 [CONDITION_USER
] = "ConditionUser",
913 [CONDITION_GROUP
] = "ConditionGroup",
914 [CONDITION_CONTROL_GROUP_CONTROLLER
] = "ConditionControlGroupController",
915 [CONDITION_NULL
] = "ConditionNull",
916 [CONDITION_CPUS
] = "ConditionCPUs",
917 [CONDITION_MEMORY
] = "ConditionMemory",
918 [CONDITION_ENVIRONMENT
] = "ConditionEnvironment",
921 DEFINE_STRING_TABLE_LOOKUP(condition_type
, ConditionType
);
923 static const char* const assert_type_table
[_CONDITION_TYPE_MAX
] = {
924 [CONDITION_ARCHITECTURE
] = "AssertArchitecture",
925 [CONDITION_VIRTUALIZATION
] = "AssertVirtualization",
926 [CONDITION_HOST
] = "AssertHost",
927 [CONDITION_KERNEL_COMMAND_LINE
] = "AssertKernelCommandLine",
928 [CONDITION_KERNEL_VERSION
] = "AssertKernelVersion",
929 [CONDITION_SECURITY
] = "AssertSecurity",
930 [CONDITION_CAPABILITY
] = "AssertCapability",
931 [CONDITION_AC_POWER
] = "AssertACPower",
932 [CONDITION_NEEDS_UPDATE
] = "AssertNeedsUpdate",
933 [CONDITION_FIRST_BOOT
] = "AssertFirstBoot",
934 [CONDITION_PATH_EXISTS
] = "AssertPathExists",
935 [CONDITION_PATH_EXISTS_GLOB
] = "AssertPathExistsGlob",
936 [CONDITION_PATH_IS_DIRECTORY
] = "AssertPathIsDirectory",
937 [CONDITION_PATH_IS_SYMBOLIC_LINK
] = "AssertPathIsSymbolicLink",
938 [CONDITION_PATH_IS_MOUNT_POINT
] = "AssertPathIsMountPoint",
939 [CONDITION_PATH_IS_READ_WRITE
] = "AssertPathIsReadWrite",
940 [CONDITION_PATH_IS_ENCRYPTED
] = "AssertPathIsEncrypted",
941 [CONDITION_DIRECTORY_NOT_EMPTY
] = "AssertDirectoryNotEmpty",
942 [CONDITION_FILE_NOT_EMPTY
] = "AssertFileNotEmpty",
943 [CONDITION_FILE_IS_EXECUTABLE
] = "AssertFileIsExecutable",
944 [CONDITION_USER
] = "AssertUser",
945 [CONDITION_GROUP
] = "AssertGroup",
946 [CONDITION_CONTROL_GROUP_CONTROLLER
] = "AssertControlGroupController",
947 [CONDITION_NULL
] = "AssertNull",
948 [CONDITION_CPUS
] = "AssertCPUs",
949 [CONDITION_MEMORY
] = "AssertMemory",
950 [CONDITION_ENVIRONMENT
] = "AssertEnvironment",
953 DEFINE_STRING_TABLE_LOOKUP(assert_type
, ConditionType
);
955 static const char* const condition_result_table
[_CONDITION_RESULT_MAX
] = {
956 [CONDITION_UNTESTED
] = "untested",
957 [CONDITION_SUCCEEDED
] = "succeeded",
958 [CONDITION_FAILED
] = "failed",
959 [CONDITION_ERROR
] = "error",
962 DEFINE_STRING_TABLE_LOOKUP(condition_result
, ConditionResult
);