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
) {
549 struct stat usr
, other
;
555 assert(c
->parameter
);
556 assert(c
->type
== CONDITION_NEEDS_UPDATE
);
558 r
= proc_cmdline_get_bool("systemd.condition-needs-update", &b
);
560 log_debug_errno(r
, "Failed to parse systemd.condition-needs-update= kernel command line argument, ignoring: %m");
564 if (!path_is_absolute(c
->parameter
)) {
565 log_debug("Specified condition parameter '%s' is not absolute, assuming an update is needed.", c
->parameter
);
569 /* If the file system is read-only we shouldn't suggest an update */
570 r
= path_is_read_only_fs(c
->parameter
);
572 log_debug_errno(r
, "Failed to determine if '%s' is read-only, ignoring: %m", c
->parameter
);
576 /* Any other failure means we should allow the condition to be true, so that we rather invoke too
577 * many update tools than too few. */
579 p
= strjoina(c
->parameter
, "/.updated");
580 if (lstat(p
, &other
) < 0) {
582 log_debug_errno(errno
, "Failed to stat() '%s', assuming an update is needed: %m", p
);
586 if (lstat("/usr/", &usr
) < 0) {
587 log_debug_errno(errno
, "Failed to stat() /usr/, assuming an update is needed: %m");
592 * First, compare seconds as they are always accurate...
594 if (usr
.st_mtim
.tv_sec
!= other
.st_mtim
.tv_sec
)
595 return usr
.st_mtim
.tv_sec
> other
.st_mtim
.tv_sec
;
598 * ...then compare nanoseconds.
600 * A false positive is only possible when /usr's nanoseconds > 0
601 * (otherwise /usr cannot be strictly newer than the target file)
602 * AND the target file's nanoseconds == 0
603 * (otherwise the filesystem supports nsec timestamps, see stat(2)).
605 if (usr
.st_mtim
.tv_nsec
== 0 || other
.st_mtim
.tv_nsec
> 0)
606 return usr
.st_mtim
.tv_nsec
> other
.st_mtim
.tv_nsec
;
608 _cleanup_free_
char *timestamp_str
= NULL
;
609 r
= parse_env_file(NULL
, p
, "TIMESTAMP_NSEC", ×tamp_str
);
611 log_debug_errno(r
, "Failed to parse timestamp file '%s', using mtime: %m", p
);
614 log_debug("No data in timestamp file '%s', using mtime.", p
);
619 r
= safe_atou64(timestamp_str
, ×tamp
);
621 log_debug_errno(r
, "Failed to parse timestamp value '%s' in file '%s', using mtime: %m", timestamp_str
, p
);
625 return timespec_load_nsec(&usr
.st_mtim
) > timestamp
;
628 static int condition_test_first_boot(Condition
*c
, char **env
) {
633 assert(c
->parameter
);
634 assert(c
->type
== CONDITION_FIRST_BOOT
);
636 r
= proc_cmdline_get_bool("systemd.condition-first-boot", &b
);
638 log_debug_errno(r
, "Failed to parse systemd.condition-first-boot= kernel command line argument, ignoring: %m");
642 r
= parse_boolean(c
->parameter
);
646 q
= access("/run/systemd/first-boot", F_OK
);
647 if (q
< 0 && errno
!= ENOENT
)
648 log_debug_errno(errno
, "Failed to check if /run/systemd/first-boot exists, ignoring: %m");
650 return (q
>= 0) == !!r
;
653 static int condition_test_environment(Condition
*c
, char **env
) {
658 assert(c
->parameter
);
659 assert(c
->type
== CONDITION_ENVIRONMENT
);
661 equal
= strchr(c
->parameter
, '=');
663 STRV_FOREACH(i
, env
) {
667 found
= streq(c
->parameter
, *i
);
671 f
= startswith(*i
, c
->parameter
);
672 found
= f
&& IN_SET(*f
, 0, '=');
682 static int condition_test_path_exists(Condition
*c
, char **env
) {
684 assert(c
->parameter
);
685 assert(c
->type
== CONDITION_PATH_EXISTS
);
687 return access(c
->parameter
, F_OK
) >= 0;
690 static int condition_test_path_exists_glob(Condition
*c
, char **env
) {
692 assert(c
->parameter
);
693 assert(c
->type
== CONDITION_PATH_EXISTS_GLOB
);
695 return glob_exists(c
->parameter
) > 0;
698 static int condition_test_path_is_directory(Condition
*c
, char **env
) {
700 assert(c
->parameter
);
701 assert(c
->type
== CONDITION_PATH_IS_DIRECTORY
);
703 return is_dir(c
->parameter
, true) > 0;
706 static int condition_test_path_is_symbolic_link(Condition
*c
, char **env
) {
708 assert(c
->parameter
);
709 assert(c
->type
== CONDITION_PATH_IS_SYMBOLIC_LINK
);
711 return is_symlink(c
->parameter
) > 0;
714 static int condition_test_path_is_mount_point(Condition
*c
, char **env
) {
716 assert(c
->parameter
);
717 assert(c
->type
== CONDITION_PATH_IS_MOUNT_POINT
);
719 return path_is_mount_point(c
->parameter
, NULL
, AT_SYMLINK_FOLLOW
) > 0;
722 static int condition_test_path_is_read_write(Condition
*c
, char **env
) {
724 assert(c
->parameter
);
725 assert(c
->type
== CONDITION_PATH_IS_READ_WRITE
);
727 return path_is_read_only_fs(c
->parameter
) <= 0;
730 static int condition_test_path_is_encrypted(Condition
*c
, char **env
) {
734 assert(c
->parameter
);
735 assert(c
->type
== CONDITION_PATH_IS_ENCRYPTED
);
737 r
= path_is_encrypted(c
->parameter
);
738 if (r
< 0 && r
!= -ENOENT
)
739 log_debug_errno(r
, "Failed to determine if '%s' is encrypted: %m", c
->parameter
);
744 static int condition_test_directory_not_empty(Condition
*c
, char **env
) {
748 assert(c
->parameter
);
749 assert(c
->type
== CONDITION_DIRECTORY_NOT_EMPTY
);
751 r
= dir_is_empty(c
->parameter
);
752 return r
<= 0 && r
!= -ENOENT
;
755 static int condition_test_file_not_empty(Condition
*c
, char **env
) {
759 assert(c
->parameter
);
760 assert(c
->type
== CONDITION_FILE_NOT_EMPTY
);
762 return (stat(c
->parameter
, &st
) >= 0 &&
763 S_ISREG(st
.st_mode
) &&
767 static int condition_test_file_is_executable(Condition
*c
, char **env
) {
771 assert(c
->parameter
);
772 assert(c
->type
== CONDITION_FILE_IS_EXECUTABLE
);
774 return (stat(c
->parameter
, &st
) >= 0 &&
775 S_ISREG(st
.st_mode
) &&
776 (st
.st_mode
& 0111));
779 static int condition_test_null(Condition
*c
, char **env
) {
781 assert(c
->type
== CONDITION_NULL
);
783 /* Note that during parsing we already evaluate the string and
784 * store it in c->negate */
788 int condition_test(Condition
*c
, char **env
) {
790 static int (*const condition_tests
[_CONDITION_TYPE_MAX
])(Condition
*c
, char **env
) = {
791 [CONDITION_PATH_EXISTS
] = condition_test_path_exists
,
792 [CONDITION_PATH_EXISTS_GLOB
] = condition_test_path_exists_glob
,
793 [CONDITION_PATH_IS_DIRECTORY
] = condition_test_path_is_directory
,
794 [CONDITION_PATH_IS_SYMBOLIC_LINK
] = condition_test_path_is_symbolic_link
,
795 [CONDITION_PATH_IS_MOUNT_POINT
] = condition_test_path_is_mount_point
,
796 [CONDITION_PATH_IS_READ_WRITE
] = condition_test_path_is_read_write
,
797 [CONDITION_PATH_IS_ENCRYPTED
] = condition_test_path_is_encrypted
,
798 [CONDITION_DIRECTORY_NOT_EMPTY
] = condition_test_directory_not_empty
,
799 [CONDITION_FILE_NOT_EMPTY
] = condition_test_file_not_empty
,
800 [CONDITION_FILE_IS_EXECUTABLE
] = condition_test_file_is_executable
,
801 [CONDITION_KERNEL_COMMAND_LINE
] = condition_test_kernel_command_line
,
802 [CONDITION_KERNEL_VERSION
] = condition_test_kernel_version
,
803 [CONDITION_VIRTUALIZATION
] = condition_test_virtualization
,
804 [CONDITION_SECURITY
] = condition_test_security
,
805 [CONDITION_CAPABILITY
] = condition_test_capability
,
806 [CONDITION_HOST
] = condition_test_host
,
807 [CONDITION_AC_POWER
] = condition_test_ac_power
,
808 [CONDITION_ARCHITECTURE
] = condition_test_architecture
,
809 [CONDITION_NEEDS_UPDATE
] = condition_test_needs_update
,
810 [CONDITION_FIRST_BOOT
] = condition_test_first_boot
,
811 [CONDITION_USER
] = condition_test_user
,
812 [CONDITION_GROUP
] = condition_test_group
,
813 [CONDITION_CONTROL_GROUP_CONTROLLER
] = condition_test_control_group_controller
,
814 [CONDITION_NULL
] = condition_test_null
,
815 [CONDITION_CPUS
] = condition_test_cpus
,
816 [CONDITION_MEMORY
] = condition_test_memory
,
817 [CONDITION_ENVIRONMENT
] = condition_test_environment
,
823 assert(c
->type
>= 0);
824 assert(c
->type
< _CONDITION_TYPE_MAX
);
826 r
= condition_tests
[c
->type
](c
, env
);
828 c
->result
= CONDITION_ERROR
;
832 b
= (r
> 0) == !c
->negate
;
833 c
->result
= b
? CONDITION_SUCCEEDED
: CONDITION_FAILED
;
837 bool condition_test_list(
840 condition_to_string_t to_string
,
841 condition_test_logger_t logger
,
847 assert(!!logger
== !!to_string
);
849 /* If the condition list is empty, then it is true */
853 /* Otherwise, if all of the non-trigger conditions apply and
854 * if any of the trigger conditions apply (unless there are
855 * none) we return true */
856 LIST_FOREACH(conditions
, c
, first
) {
859 r
= condition_test(c
, env
);
862 const char *p
= c
->type
== CONDITION_NULL
? "true" : c
->parameter
;
866 logger(userdata
, LOG_WARNING
, r
, PROJECT_FILE
, __LINE__
, __func__
,
867 "Couldn't determine result for %s=%s%s%s, assuming failed: %m",
869 c
->trigger
? "|" : "",
870 c
->negate
? "!" : "",
873 logger(userdata
, LOG_DEBUG
, 0, PROJECT_FILE
, __LINE__
, __func__
,
876 c
->trigger
? "|" : "",
877 c
->negate
? "!" : "",
879 condition_result_to_string(c
->result
));
882 if (!c
->trigger
&& r
<= 0)
885 if (c
->trigger
&& triggered
<= 0)
889 return triggered
!= 0;
892 void condition_dump(Condition
*c
, FILE *f
, const char *prefix
, condition_to_string_t to_string
) {
897 prefix
= strempty(prefix
);
900 "%s\t%s: %s%s%s %s\n",
903 c
->trigger
? "|" : "",
904 c
->negate
? "!" : "",
906 condition_result_to_string(c
->result
));
909 void condition_dump_list(Condition
*first
, FILE *f
, const char *prefix
, condition_to_string_t to_string
) {
912 LIST_FOREACH(conditions
, c
, first
)
913 condition_dump(c
, f
, prefix
, to_string
);
916 static const char* const condition_type_table
[_CONDITION_TYPE_MAX
] = {
917 [CONDITION_ARCHITECTURE
] = "ConditionArchitecture",
918 [CONDITION_VIRTUALIZATION
] = "ConditionVirtualization",
919 [CONDITION_HOST
] = "ConditionHost",
920 [CONDITION_KERNEL_COMMAND_LINE
] = "ConditionKernelCommandLine",
921 [CONDITION_KERNEL_VERSION
] = "ConditionKernelVersion",
922 [CONDITION_SECURITY
] = "ConditionSecurity",
923 [CONDITION_CAPABILITY
] = "ConditionCapability",
924 [CONDITION_AC_POWER
] = "ConditionACPower",
925 [CONDITION_NEEDS_UPDATE
] = "ConditionNeedsUpdate",
926 [CONDITION_FIRST_BOOT
] = "ConditionFirstBoot",
927 [CONDITION_PATH_EXISTS
] = "ConditionPathExists",
928 [CONDITION_PATH_EXISTS_GLOB
] = "ConditionPathExistsGlob",
929 [CONDITION_PATH_IS_DIRECTORY
] = "ConditionPathIsDirectory",
930 [CONDITION_PATH_IS_SYMBOLIC_LINK
] = "ConditionPathIsSymbolicLink",
931 [CONDITION_PATH_IS_MOUNT_POINT
] = "ConditionPathIsMountPoint",
932 [CONDITION_PATH_IS_READ_WRITE
] = "ConditionPathIsReadWrite",
933 [CONDITION_PATH_IS_ENCRYPTED
] = "ConditionPathIsEncrypted",
934 [CONDITION_DIRECTORY_NOT_EMPTY
] = "ConditionDirectoryNotEmpty",
935 [CONDITION_FILE_NOT_EMPTY
] = "ConditionFileNotEmpty",
936 [CONDITION_FILE_IS_EXECUTABLE
] = "ConditionFileIsExecutable",
937 [CONDITION_USER
] = "ConditionUser",
938 [CONDITION_GROUP
] = "ConditionGroup",
939 [CONDITION_CONTROL_GROUP_CONTROLLER
] = "ConditionControlGroupController",
940 [CONDITION_NULL
] = "ConditionNull",
941 [CONDITION_CPUS
] = "ConditionCPUs",
942 [CONDITION_MEMORY
] = "ConditionMemory",
943 [CONDITION_ENVIRONMENT
] = "ConditionEnvironment",
946 DEFINE_STRING_TABLE_LOOKUP(condition_type
, ConditionType
);
948 static const char* const assert_type_table
[_CONDITION_TYPE_MAX
] = {
949 [CONDITION_ARCHITECTURE
] = "AssertArchitecture",
950 [CONDITION_VIRTUALIZATION
] = "AssertVirtualization",
951 [CONDITION_HOST
] = "AssertHost",
952 [CONDITION_KERNEL_COMMAND_LINE
] = "AssertKernelCommandLine",
953 [CONDITION_KERNEL_VERSION
] = "AssertKernelVersion",
954 [CONDITION_SECURITY
] = "AssertSecurity",
955 [CONDITION_CAPABILITY
] = "AssertCapability",
956 [CONDITION_AC_POWER
] = "AssertACPower",
957 [CONDITION_NEEDS_UPDATE
] = "AssertNeedsUpdate",
958 [CONDITION_FIRST_BOOT
] = "AssertFirstBoot",
959 [CONDITION_PATH_EXISTS
] = "AssertPathExists",
960 [CONDITION_PATH_EXISTS_GLOB
] = "AssertPathExistsGlob",
961 [CONDITION_PATH_IS_DIRECTORY
] = "AssertPathIsDirectory",
962 [CONDITION_PATH_IS_SYMBOLIC_LINK
] = "AssertPathIsSymbolicLink",
963 [CONDITION_PATH_IS_MOUNT_POINT
] = "AssertPathIsMountPoint",
964 [CONDITION_PATH_IS_READ_WRITE
] = "AssertPathIsReadWrite",
965 [CONDITION_PATH_IS_ENCRYPTED
] = "AssertPathIsEncrypted",
966 [CONDITION_DIRECTORY_NOT_EMPTY
] = "AssertDirectoryNotEmpty",
967 [CONDITION_FILE_NOT_EMPTY
] = "AssertFileNotEmpty",
968 [CONDITION_FILE_IS_EXECUTABLE
] = "AssertFileIsExecutable",
969 [CONDITION_USER
] = "AssertUser",
970 [CONDITION_GROUP
] = "AssertGroup",
971 [CONDITION_CONTROL_GROUP_CONTROLLER
] = "AssertControlGroupController",
972 [CONDITION_NULL
] = "AssertNull",
973 [CONDITION_CPUS
] = "AssertCPUs",
974 [CONDITION_MEMORY
] = "AssertMemory",
975 [CONDITION_ENVIRONMENT
] = "AssertEnvironment",
978 DEFINE_STRING_TABLE_LOOKUP(assert_type
, ConditionType
);
980 static const char* const condition_result_table
[_CONDITION_RESULT_MAX
] = {
981 [CONDITION_UNTESTED
] = "untested",
982 [CONDITION_SUCCEEDED
] = "succeeded",
983 [CONDITION_FAILED
] = "failed",
984 [CONDITION_ERROR
] = "error",
987 DEFINE_STRING_TABLE_LOOKUP(condition_result
, ConditionResult
);