1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
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-record.h"
47 #include "user-util.h"
51 Condition
* condition_new(ConditionType type
, const char *parameter
, bool trigger
, bool negate
) {
55 assert(type
< _CONDITION_TYPE_MAX
);
58 c
= new(Condition
, 1);
69 c
->parameter
= strdup(parameter
);
77 Condition
* condition_free(Condition
*c
) {
84 Condition
* condition_free_list_type(Condition
*head
, ConditionType type
) {
87 LIST_FOREACH_SAFE(conditions
, c
, n
, head
)
88 if (type
< 0 || c
->type
== type
) {
89 LIST_REMOVE(conditions
, head
, c
);
93 assert(type
>= 0 || !head
);
97 static int condition_test_kernel_command_line(Condition
*c
, char **env
) {
98 _cleanup_free_
char *line
= NULL
;
104 assert(c
->parameter
);
105 assert(c
->type
== CONDITION_KERNEL_COMMAND_LINE
);
107 r
= proc_cmdline(&line
);
111 equal
= strchr(c
->parameter
, '=');
114 _cleanup_free_
char *word
= NULL
;
117 r
= extract_first_word(&p
, &word
, NULL
, EXTRACT_UNQUOTE
|EXTRACT_RELAX
);
124 found
= streq(word
, c
->parameter
);
128 f
= startswith(word
, c
->parameter
);
129 found
= f
&& IN_SET(*f
, 0, '=');
140 /* Listed in order of checking. Note that some comparators are prefixes of others, hence the longest
141 * should be listed first. */
142 ORDER_LOWER_OR_EQUAL
,
143 ORDER_GREATER_OR_EQUAL
,
152 static OrderOperator
parse_order(const char **s
) {
154 static const char *const prefix
[_ORDER_MAX
] = {
155 [ORDER_LOWER_OR_EQUAL
] = "<=",
156 [ORDER_GREATER_OR_EQUAL
] = ">=",
158 [ORDER_GREATER
] = ">",
160 [ORDER_UNEQUAL
] = "!=",
165 for (i
= 0; i
< _ORDER_MAX
; i
++) {
168 e
= startswith(*s
, prefix
[i
]);
175 return _ORDER_INVALID
;
178 static bool test_order(int k
, OrderOperator p
) {
185 case ORDER_LOWER_OR_EQUAL
:
194 case ORDER_GREATER_OR_EQUAL
:
201 assert_not_reached("unknown order");
206 static int condition_test_kernel_version(Condition
*c
, char **env
) {
213 assert(c
->parameter
);
214 assert(c
->type
== CONDITION_KERNEL_VERSION
);
216 assert_se(uname(&u
) >= 0);
221 _cleanup_free_
char *word
= NULL
;
225 r
= extract_first_word(&p
, &word
, NULL
, EXTRACT_UNQUOTE
);
227 return log_debug_errno(r
, "Failed to parse condition string \"%s\": %m", p
);
232 order
= parse_order(&s
);
234 s
+= strspn(s
, WHITESPACE
);
237 /* For backwards compatibility, allow whitespace between the operator and
238 * value, without quoting, but only in the first expression. */
240 r
= extract_first_word(&p
, &word
, NULL
, 0);
242 return log_debug_errno(r
, "Failed to parse condition string \"%s\": %m", p
);
244 return log_debug_errno(SYNTHETIC_ERRNO(EINVAL
), "Unexpected end of expression: %s", p
);
247 return log_debug_errno(SYNTHETIC_ERRNO(EINVAL
), "Unexpected end of expression: %s", p
);
250 r
= test_order(strverscmp_improved(u
.release
, s
), order
);
252 /* No prefix? Then treat as glob string */
253 r
= fnmatch(s
, u
.release
, 0) == 0;
264 static int condition_test_memory(Condition
*c
, char **env
) {
271 assert(c
->parameter
);
272 assert(c
->type
== CONDITION_MEMORY
);
274 m
= physical_memory();
277 order
= parse_order(&p
);
279 order
= ORDER_GREATER_OR_EQUAL
; /* default to >= check, if nothing is specified. */
281 r
= safe_atou64(p
, &k
);
283 return log_debug_errno(r
, "Failed to parse size: %m");
285 return test_order(CMP(m
, k
), order
);
288 static int condition_test_cpus(Condition
*c
, char **env
) {
295 assert(c
->parameter
);
296 assert(c
->type
== CONDITION_CPUS
);
298 n
= cpus_in_affinity_mask();
300 return log_debug_errno(n
, "Failed to determine CPUs in affinity mask: %m");
303 order
= parse_order(&p
);
305 order
= ORDER_GREATER_OR_EQUAL
; /* default to >= check, if nothing is specified. */
307 r
= safe_atou(p
, &k
);
309 return log_debug_errno(r
, "Failed to parse number of CPUs: %m");
311 return test_order(CMP((unsigned) n
, k
), order
);
314 static int condition_test_user(Condition
*c
, char **env
) {
317 _cleanup_free_
char *username
= NULL
;
321 assert(c
->parameter
);
322 assert(c
->type
== CONDITION_USER
);
324 r
= parse_uid(c
->parameter
, &id
);
326 return id
== getuid() || id
== geteuid();
328 if (streq("@system", c
->parameter
))
329 return uid_is_system(getuid()) || uid_is_system(geteuid());
331 username
= getusername_malloc();
335 if (streq(username
, c
->parameter
))
338 if (getpid_cached() == 1)
339 return streq(c
->parameter
, "root");
342 r
= get_user_creds(&u
, &id
, NULL
, NULL
, NULL
, USER_CREDS_ALLOW_MISSING
);
346 return id
== getuid() || id
== geteuid();
349 static int condition_test_control_group_controller(Condition
*c
, char **env
) {
351 CGroupMask system_mask
, wanted_mask
= 0;
354 assert(c
->parameter
);
355 assert(c
->type
== CONDITION_CONTROL_GROUP_CONTROLLER
);
357 r
= cg_mask_supported(&system_mask
);
359 return log_debug_errno(r
, "Failed to determine supported controllers: %m");
361 r
= cg_mask_from_string(c
->parameter
, &wanted_mask
);
362 if (r
< 0 || wanted_mask
<= 0) {
363 /* This won't catch the case that we have an unknown controller
364 * mixed in with valid ones -- these are only assessed on the
365 * validity of the valid controllers found. */
366 log_debug("Failed to parse cgroup string: %s", c
->parameter
);
370 return FLAGS_SET(system_mask
, wanted_mask
);
373 static int condition_test_group(Condition
*c
, char **env
) {
378 assert(c
->parameter
);
379 assert(c
->type
== CONDITION_GROUP
);
381 r
= parse_gid(c
->parameter
, &id
);
385 /* Avoid any NSS lookups if we are PID1 */
386 if (getpid_cached() == 1)
387 return streq(c
->parameter
, "root");
389 return in_group(c
->parameter
) > 0;
392 static int condition_test_virtualization(Condition
*c
, char **env
) {
396 assert(c
->parameter
);
397 assert(c
->type
== CONDITION_VIRTUALIZATION
);
399 if (streq(c
->parameter
, "private-users"))
400 return running_in_userns();
402 v
= detect_virtualization();
406 /* First, compare with yes/no */
407 b
= parse_boolean(c
->parameter
);
411 /* Then, compare categorization */
412 if (streq(c
->parameter
, "vm"))
413 return VIRTUALIZATION_IS_VM(v
);
415 if (streq(c
->parameter
, "container"))
416 return VIRTUALIZATION_IS_CONTAINER(v
);
418 /* Finally compare id */
419 return v
!= VIRTUALIZATION_NONE
&& streq(c
->parameter
, virtualization_to_string(v
));
422 static int condition_test_architecture(Condition
*c
, char **env
) {
426 assert(c
->parameter
);
427 assert(c
->type
== CONDITION_ARCHITECTURE
);
429 a
= uname_architecture();
433 if (streq(c
->parameter
, "native"))
434 b
= native_architecture();
436 b
= architecture_from_string(c
->parameter
);
437 if (b
< 0) /* unknown architecture? Then it's definitely not ours */
444 static int condition_test_host(Condition
*c
, char **env
) {
445 _cleanup_free_
char *h
= NULL
;
450 assert(c
->parameter
);
451 assert(c
->type
== CONDITION_HOST
);
453 if (sd_id128_from_string(c
->parameter
, &x
) >= 0) {
455 r
= sd_id128_get_machine(&y
);
459 return sd_id128_equal(x
, y
);
462 h
= gethostname_malloc();
466 return fnmatch(c
->parameter
, h
, FNM_CASEFOLD
) == 0;
469 static int condition_test_ac_power(Condition
*c
, char **env
) {
473 assert(c
->parameter
);
474 assert(c
->type
== CONDITION_AC_POWER
);
476 r
= parse_boolean(c
->parameter
);
480 return (on_ac_power() != 0) == !!r
;
483 static int has_tpm2(void) {
486 /* Checks whether the system has at least one TPM2 resource manager device, i.e. at least one "tpmrm"
489 r
= dir_is_empty("/sys/class/tpmrm");
493 return log_debug_errno(r
, "Failed to determine whether system has TPM2 support: %m");
498 static int condition_test_security(Condition
*c
, char **env
) {
500 assert(c
->parameter
);
501 assert(c
->type
== CONDITION_SECURITY
);
503 if (streq(c
->parameter
, "selinux"))
504 return mac_selinux_use();
505 if (streq(c
->parameter
, "smack"))
506 return mac_smack_use();
507 if (streq(c
->parameter
, "apparmor"))
508 return mac_apparmor_use();
509 if (streq(c
->parameter
, "audit"))
511 if (streq(c
->parameter
, "ima"))
513 if (streq(c
->parameter
, "tomoyo"))
514 return mac_tomoyo_use();
515 if (streq(c
->parameter
, "uefi-secureboot"))
516 return is_efi_secure_boot();
517 if (streq(c
->parameter
, "tpm2"))
523 static int condition_test_capability(Condition
*c
, char **env
) {
524 unsigned long long capabilities
= (unsigned long long) -1;
525 _cleanup_fclose_
FILE *f
= NULL
;
529 assert(c
->parameter
);
530 assert(c
->type
== CONDITION_CAPABILITY
);
532 /* If it's an invalid capability, we don't have it */
533 value
= capability_from_name(c
->parameter
);
537 /* If it's a valid capability we default to assume
540 f
= fopen("/proc/self/status", "re");
545 _cleanup_free_
char *line
= NULL
;
548 r
= read_line(f
, LONG_LINE_MAX
, &line
);
554 p
= startswith(line
, "CapBnd:");
556 if (sscanf(line
+7, "%llx", &capabilities
) != 1)
563 return !!(capabilities
& (1ULL << value
));
566 static int condition_test_needs_update(Condition
*c
, char **env
) {
567 struct stat usr
, other
;
573 assert(c
->parameter
);
574 assert(c
->type
== CONDITION_NEEDS_UPDATE
);
576 r
= proc_cmdline_get_bool("systemd.condition-needs-update", &b
);
578 log_debug_errno(r
, "Failed to parse systemd.condition-needs-update= kernel command line argument, ignoring: %m");
582 if (!path_is_absolute(c
->parameter
)) {
583 log_debug("Specified condition parameter '%s' is not absolute, assuming an update is needed.", c
->parameter
);
587 /* If the file system is read-only we shouldn't suggest an update */
588 r
= path_is_read_only_fs(c
->parameter
);
590 log_debug_errno(r
, "Failed to determine if '%s' is read-only, ignoring: %m", c
->parameter
);
594 /* Any other failure means we should allow the condition to be true, so that we rather invoke too
595 * many update tools than too few. */
597 p
= strjoina(c
->parameter
, "/.updated");
598 if (lstat(p
, &other
) < 0) {
600 log_debug_errno(errno
, "Failed to stat() '%s', assuming an update is needed: %m", p
);
604 if (lstat("/usr/", &usr
) < 0) {
605 log_debug_errno(errno
, "Failed to stat() /usr/, assuming an update is needed: %m");
610 * First, compare seconds as they are always accurate...
612 if (usr
.st_mtim
.tv_sec
!= other
.st_mtim
.tv_sec
)
613 return usr
.st_mtim
.tv_sec
> other
.st_mtim
.tv_sec
;
616 * ...then compare nanoseconds.
618 * A false positive is only possible when /usr's nanoseconds > 0
619 * (otherwise /usr cannot be strictly newer than the target file)
620 * AND the target file's nanoseconds == 0
621 * (otherwise the filesystem supports nsec timestamps, see stat(2)).
623 if (usr
.st_mtim
.tv_nsec
== 0 || other
.st_mtim
.tv_nsec
> 0)
624 return usr
.st_mtim
.tv_nsec
> other
.st_mtim
.tv_nsec
;
626 _cleanup_free_
char *timestamp_str
= NULL
;
627 r
= parse_env_file(NULL
, p
, "TIMESTAMP_NSEC", ×tamp_str
);
629 log_debug_errno(r
, "Failed to parse timestamp file '%s', using mtime: %m", p
);
632 log_debug("No data in timestamp file '%s', using mtime.", p
);
637 r
= safe_atou64(timestamp_str
, ×tamp
);
639 log_debug_errno(r
, "Failed to parse timestamp value '%s' in file '%s', using mtime: %m", timestamp_str
, p
);
643 return timespec_load_nsec(&usr
.st_mtim
) > timestamp
;
646 static int condition_test_first_boot(Condition
*c
, char **env
) {
651 assert(c
->parameter
);
652 assert(c
->type
== CONDITION_FIRST_BOOT
);
654 r
= proc_cmdline_get_bool("systemd.condition-first-boot", &b
);
656 log_debug_errno(r
, "Failed to parse systemd.condition-first-boot= kernel command line argument, ignoring: %m");
660 r
= parse_boolean(c
->parameter
);
664 q
= access("/run/systemd/first-boot", F_OK
);
665 if (q
< 0 && errno
!= ENOENT
)
666 log_debug_errno(errno
, "Failed to check if /run/systemd/first-boot exists, ignoring: %m");
668 return (q
>= 0) == !!r
;
671 static int condition_test_environment(Condition
*c
, char **env
) {
676 assert(c
->parameter
);
677 assert(c
->type
== CONDITION_ENVIRONMENT
);
679 equal
= strchr(c
->parameter
, '=');
681 STRV_FOREACH(i
, env
) {
685 found
= streq(c
->parameter
, *i
);
689 f
= startswith(*i
, c
->parameter
);
690 found
= f
&& IN_SET(*f
, 0, '=');
700 static int condition_test_path_exists(Condition
*c
, char **env
) {
702 assert(c
->parameter
);
703 assert(c
->type
== CONDITION_PATH_EXISTS
);
705 return access(c
->parameter
, F_OK
) >= 0;
708 static int condition_test_path_exists_glob(Condition
*c
, char **env
) {
710 assert(c
->parameter
);
711 assert(c
->type
== CONDITION_PATH_EXISTS_GLOB
);
713 return glob_exists(c
->parameter
) > 0;
716 static int condition_test_path_is_directory(Condition
*c
, char **env
) {
718 assert(c
->parameter
);
719 assert(c
->type
== CONDITION_PATH_IS_DIRECTORY
);
721 return is_dir(c
->parameter
, true) > 0;
724 static int condition_test_path_is_symbolic_link(Condition
*c
, char **env
) {
726 assert(c
->parameter
);
727 assert(c
->type
== CONDITION_PATH_IS_SYMBOLIC_LINK
);
729 return is_symlink(c
->parameter
) > 0;
732 static int condition_test_path_is_mount_point(Condition
*c
, char **env
) {
734 assert(c
->parameter
);
735 assert(c
->type
== CONDITION_PATH_IS_MOUNT_POINT
);
737 return path_is_mount_point(c
->parameter
, NULL
, AT_SYMLINK_FOLLOW
) > 0;
740 static int condition_test_path_is_read_write(Condition
*c
, char **env
) {
742 assert(c
->parameter
);
743 assert(c
->type
== CONDITION_PATH_IS_READ_WRITE
);
745 return path_is_read_only_fs(c
->parameter
) <= 0;
748 static int condition_test_path_is_encrypted(Condition
*c
, char **env
) {
752 assert(c
->parameter
);
753 assert(c
->type
== CONDITION_PATH_IS_ENCRYPTED
);
755 r
= path_is_encrypted(c
->parameter
);
756 if (r
< 0 && r
!= -ENOENT
)
757 log_debug_errno(r
, "Failed to determine if '%s' is encrypted: %m", c
->parameter
);
762 static int condition_test_directory_not_empty(Condition
*c
, char **env
) {
766 assert(c
->parameter
);
767 assert(c
->type
== CONDITION_DIRECTORY_NOT_EMPTY
);
769 r
= dir_is_empty(c
->parameter
);
770 return r
<= 0 && r
!= -ENOENT
;
773 static int condition_test_file_not_empty(Condition
*c
, char **env
) {
777 assert(c
->parameter
);
778 assert(c
->type
== CONDITION_FILE_NOT_EMPTY
);
780 return (stat(c
->parameter
, &st
) >= 0 &&
781 S_ISREG(st
.st_mode
) &&
785 static int condition_test_file_is_executable(Condition
*c
, char **env
) {
789 assert(c
->parameter
);
790 assert(c
->type
== CONDITION_FILE_IS_EXECUTABLE
);
792 return (stat(c
->parameter
, &st
) >= 0 &&
793 S_ISREG(st
.st_mode
) &&
794 (st
.st_mode
& 0111));
797 int condition_test(Condition
*c
, char **env
) {
799 static int (*const condition_tests
[_CONDITION_TYPE_MAX
])(Condition
*c
, char **env
) = {
800 [CONDITION_PATH_EXISTS
] = condition_test_path_exists
,
801 [CONDITION_PATH_EXISTS_GLOB
] = condition_test_path_exists_glob
,
802 [CONDITION_PATH_IS_DIRECTORY
] = condition_test_path_is_directory
,
803 [CONDITION_PATH_IS_SYMBOLIC_LINK
] = condition_test_path_is_symbolic_link
,
804 [CONDITION_PATH_IS_MOUNT_POINT
] = condition_test_path_is_mount_point
,
805 [CONDITION_PATH_IS_READ_WRITE
] = condition_test_path_is_read_write
,
806 [CONDITION_PATH_IS_ENCRYPTED
] = condition_test_path_is_encrypted
,
807 [CONDITION_DIRECTORY_NOT_EMPTY
] = condition_test_directory_not_empty
,
808 [CONDITION_FILE_NOT_EMPTY
] = condition_test_file_not_empty
,
809 [CONDITION_FILE_IS_EXECUTABLE
] = condition_test_file_is_executable
,
810 [CONDITION_KERNEL_COMMAND_LINE
] = condition_test_kernel_command_line
,
811 [CONDITION_KERNEL_VERSION
] = condition_test_kernel_version
,
812 [CONDITION_VIRTUALIZATION
] = condition_test_virtualization
,
813 [CONDITION_SECURITY
] = condition_test_security
,
814 [CONDITION_CAPABILITY
] = condition_test_capability
,
815 [CONDITION_HOST
] = condition_test_host
,
816 [CONDITION_AC_POWER
] = condition_test_ac_power
,
817 [CONDITION_ARCHITECTURE
] = condition_test_architecture
,
818 [CONDITION_NEEDS_UPDATE
] = condition_test_needs_update
,
819 [CONDITION_FIRST_BOOT
] = condition_test_first_boot
,
820 [CONDITION_USER
] = condition_test_user
,
821 [CONDITION_GROUP
] = condition_test_group
,
822 [CONDITION_CONTROL_GROUP_CONTROLLER
] = condition_test_control_group_controller
,
823 [CONDITION_CPUS
] = condition_test_cpus
,
824 [CONDITION_MEMORY
] = condition_test_memory
,
825 [CONDITION_ENVIRONMENT
] = condition_test_environment
,
831 assert(c
->type
>= 0);
832 assert(c
->type
< _CONDITION_TYPE_MAX
);
834 r
= condition_tests
[c
->type
](c
, env
);
836 c
->result
= CONDITION_ERROR
;
840 b
= (r
> 0) == !c
->negate
;
841 c
->result
= b
? CONDITION_SUCCEEDED
: CONDITION_FAILED
;
845 bool condition_test_list(
848 condition_to_string_t to_string
,
849 condition_test_logger_t logger
,
855 assert(!!logger
== !!to_string
);
857 /* If the condition list is empty, then it is true */
861 /* Otherwise, if all of the non-trigger conditions apply and
862 * if any of the trigger conditions apply (unless there are
863 * none) we return true */
864 LIST_FOREACH(conditions
, c
, first
) {
867 r
= condition_test(c
, env
);
871 logger(userdata
, LOG_WARNING
, r
, PROJECT_FILE
, __LINE__
, __func__
,
872 "Couldn't determine result for %s=%s%s%s, assuming failed: %m",
874 c
->trigger
? "|" : "",
875 c
->negate
? "!" : "",
878 logger(userdata
, LOG_DEBUG
, 0, PROJECT_FILE
, __LINE__
, __func__
,
881 c
->trigger
? "|" : "",
882 c
->negate
? "!" : "",
884 condition_result_to_string(c
->result
));
887 if (!c
->trigger
&& r
<= 0)
890 if (c
->trigger
&& triggered
<= 0)
894 return triggered
!= 0;
897 void condition_dump(Condition
*c
, FILE *f
, const char *prefix
, condition_to_string_t to_string
) {
902 prefix
= strempty(prefix
);
905 "%s\t%s: %s%s%s %s\n",
908 c
->trigger
? "|" : "",
909 c
->negate
? "!" : "",
911 condition_result_to_string(c
->result
));
914 void condition_dump_list(Condition
*first
, FILE *f
, const char *prefix
, condition_to_string_t to_string
) {
917 LIST_FOREACH(conditions
, c
, first
)
918 condition_dump(c
, f
, prefix
, to_string
);
921 static const char* const condition_type_table
[_CONDITION_TYPE_MAX
] = {
922 [CONDITION_ARCHITECTURE
] = "ConditionArchitecture",
923 [CONDITION_VIRTUALIZATION
] = "ConditionVirtualization",
924 [CONDITION_HOST
] = "ConditionHost",
925 [CONDITION_KERNEL_COMMAND_LINE
] = "ConditionKernelCommandLine",
926 [CONDITION_KERNEL_VERSION
] = "ConditionKernelVersion",
927 [CONDITION_SECURITY
] = "ConditionSecurity",
928 [CONDITION_CAPABILITY
] = "ConditionCapability",
929 [CONDITION_AC_POWER
] = "ConditionACPower",
930 [CONDITION_NEEDS_UPDATE
] = "ConditionNeedsUpdate",
931 [CONDITION_FIRST_BOOT
] = "ConditionFirstBoot",
932 [CONDITION_PATH_EXISTS
] = "ConditionPathExists",
933 [CONDITION_PATH_EXISTS_GLOB
] = "ConditionPathExistsGlob",
934 [CONDITION_PATH_IS_DIRECTORY
] = "ConditionPathIsDirectory",
935 [CONDITION_PATH_IS_SYMBOLIC_LINK
] = "ConditionPathIsSymbolicLink",
936 [CONDITION_PATH_IS_MOUNT_POINT
] = "ConditionPathIsMountPoint",
937 [CONDITION_PATH_IS_READ_WRITE
] = "ConditionPathIsReadWrite",
938 [CONDITION_PATH_IS_ENCRYPTED
] = "ConditionPathIsEncrypted",
939 [CONDITION_DIRECTORY_NOT_EMPTY
] = "ConditionDirectoryNotEmpty",
940 [CONDITION_FILE_NOT_EMPTY
] = "ConditionFileNotEmpty",
941 [CONDITION_FILE_IS_EXECUTABLE
] = "ConditionFileIsExecutable",
942 [CONDITION_USER
] = "ConditionUser",
943 [CONDITION_GROUP
] = "ConditionGroup",
944 [CONDITION_CONTROL_GROUP_CONTROLLER
] = "ConditionControlGroupController",
945 [CONDITION_CPUS
] = "ConditionCPUs",
946 [CONDITION_MEMORY
] = "ConditionMemory",
947 [CONDITION_ENVIRONMENT
] = "ConditionEnvironment",
950 DEFINE_STRING_TABLE_LOOKUP(condition_type
, ConditionType
);
952 static const char* const assert_type_table
[_CONDITION_TYPE_MAX
] = {
953 [CONDITION_ARCHITECTURE
] = "AssertArchitecture",
954 [CONDITION_VIRTUALIZATION
] = "AssertVirtualization",
955 [CONDITION_HOST
] = "AssertHost",
956 [CONDITION_KERNEL_COMMAND_LINE
] = "AssertKernelCommandLine",
957 [CONDITION_KERNEL_VERSION
] = "AssertKernelVersion",
958 [CONDITION_SECURITY
] = "AssertSecurity",
959 [CONDITION_CAPABILITY
] = "AssertCapability",
960 [CONDITION_AC_POWER
] = "AssertACPower",
961 [CONDITION_NEEDS_UPDATE
] = "AssertNeedsUpdate",
962 [CONDITION_FIRST_BOOT
] = "AssertFirstBoot",
963 [CONDITION_PATH_EXISTS
] = "AssertPathExists",
964 [CONDITION_PATH_EXISTS_GLOB
] = "AssertPathExistsGlob",
965 [CONDITION_PATH_IS_DIRECTORY
] = "AssertPathIsDirectory",
966 [CONDITION_PATH_IS_SYMBOLIC_LINK
] = "AssertPathIsSymbolicLink",
967 [CONDITION_PATH_IS_MOUNT_POINT
] = "AssertPathIsMountPoint",
968 [CONDITION_PATH_IS_READ_WRITE
] = "AssertPathIsReadWrite",
969 [CONDITION_PATH_IS_ENCRYPTED
] = "AssertPathIsEncrypted",
970 [CONDITION_DIRECTORY_NOT_EMPTY
] = "AssertDirectoryNotEmpty",
971 [CONDITION_FILE_NOT_EMPTY
] = "AssertFileNotEmpty",
972 [CONDITION_FILE_IS_EXECUTABLE
] = "AssertFileIsExecutable",
973 [CONDITION_USER
] = "AssertUser",
974 [CONDITION_GROUP
] = "AssertGroup",
975 [CONDITION_CONTROL_GROUP_CONTROLLER
] = "AssertControlGroupController",
976 [CONDITION_CPUS
] = "AssertCPUs",
977 [CONDITION_MEMORY
] = "AssertMemory",
978 [CONDITION_ENVIRONMENT
] = "AssertEnvironment",
981 DEFINE_STRING_TABLE_LOOKUP(assert_type
, ConditionType
);
983 static const char* const condition_result_table
[_CONDITION_RESULT_MAX
] = {
984 [CONDITION_UNTESTED
] = "untested",
985 [CONDITION_SUCCEEDED
] = "succeeded",
986 [CONDITION_FAILED
] = "failed",
987 [CONDITION_ERROR
] = "error",
990 DEFINE_STRING_TABLE_LOOKUP(condition_result
, ConditionResult
);