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
,
149 _ORDER_INVALID
= -EINVAL
,
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");
491 return true; /* nice! we have a device */
493 /* Hmm, so Linux doesn't know of the TPM2 device (or we couldn't check for it), most likely because
494 * the driver wasn't loaded yet. Let's see if the firmware knows about a TPM2 device, in this
495 * case. This way we can answer the TPM2 question already during early boot (where we most likely
500 /* OK, this didn't work either, in this case propagate the original errors */
504 return log_debug_errno(r
, "Failed to determine whether system has TPM2 support: %m");
509 static int condition_test_security(Condition
*c
, char **env
) {
511 assert(c
->parameter
);
512 assert(c
->type
== CONDITION_SECURITY
);
514 if (streq(c
->parameter
, "selinux"))
515 return mac_selinux_use();
516 if (streq(c
->parameter
, "smack"))
517 return mac_smack_use();
518 if (streq(c
->parameter
, "apparmor"))
519 return mac_apparmor_use();
520 if (streq(c
->parameter
, "audit"))
522 if (streq(c
->parameter
, "ima"))
524 if (streq(c
->parameter
, "tomoyo"))
525 return mac_tomoyo_use();
526 if (streq(c
->parameter
, "uefi-secureboot"))
527 return is_efi_secure_boot();
528 if (streq(c
->parameter
, "tpm2"))
534 static int condition_test_capability(Condition
*c
, char **env
) {
535 unsigned long long capabilities
= (unsigned long long) -1;
536 _cleanup_fclose_
FILE *f
= NULL
;
540 assert(c
->parameter
);
541 assert(c
->type
== CONDITION_CAPABILITY
);
543 /* If it's an invalid capability, we don't have it */
544 value
= capability_from_name(c
->parameter
);
548 /* If it's a valid capability we default to assume
551 f
= fopen("/proc/self/status", "re");
556 _cleanup_free_
char *line
= NULL
;
559 r
= read_line(f
, LONG_LINE_MAX
, &line
);
565 p
= startswith(line
, "CapBnd:");
567 if (sscanf(line
+7, "%llx", &capabilities
) != 1)
574 return !!(capabilities
& (1ULL << value
));
577 static int condition_test_needs_update(Condition
*c
, char **env
) {
578 struct stat usr
, other
;
584 assert(c
->parameter
);
585 assert(c
->type
== CONDITION_NEEDS_UPDATE
);
587 r
= proc_cmdline_get_bool("systemd.condition-needs-update", &b
);
589 log_debug_errno(r
, "Failed to parse systemd.condition-needs-update= kernel command line argument, ignoring: %m");
593 if (!path_is_absolute(c
->parameter
)) {
594 log_debug("Specified condition parameter '%s' is not absolute, assuming an update is needed.", c
->parameter
);
598 /* If the file system is read-only we shouldn't suggest an update */
599 r
= path_is_read_only_fs(c
->parameter
);
601 log_debug_errno(r
, "Failed to determine if '%s' is read-only, ignoring: %m", c
->parameter
);
605 /* Any other failure means we should allow the condition to be true, so that we rather invoke too
606 * many update tools than too few. */
608 p
= strjoina(c
->parameter
, "/.updated");
609 if (lstat(p
, &other
) < 0) {
611 log_debug_errno(errno
, "Failed to stat() '%s', assuming an update is needed: %m", p
);
615 if (lstat("/usr/", &usr
) < 0) {
616 log_debug_errno(errno
, "Failed to stat() /usr/, assuming an update is needed: %m");
621 * First, compare seconds as they are always accurate...
623 if (usr
.st_mtim
.tv_sec
!= other
.st_mtim
.tv_sec
)
624 return usr
.st_mtim
.tv_sec
> other
.st_mtim
.tv_sec
;
627 * ...then compare nanoseconds.
629 * A false positive is only possible when /usr's nanoseconds > 0
630 * (otherwise /usr cannot be strictly newer than the target file)
631 * AND the target file's nanoseconds == 0
632 * (otherwise the filesystem supports nsec timestamps, see stat(2)).
634 if (usr
.st_mtim
.tv_nsec
== 0 || other
.st_mtim
.tv_nsec
> 0)
635 return usr
.st_mtim
.tv_nsec
> other
.st_mtim
.tv_nsec
;
637 _cleanup_free_
char *timestamp_str
= NULL
;
638 r
= parse_env_file(NULL
, p
, "TIMESTAMP_NSEC", ×tamp_str
);
640 log_debug_errno(r
, "Failed to parse timestamp file '%s', using mtime: %m", p
);
643 log_debug("No data in timestamp file '%s', using mtime.", p
);
648 r
= safe_atou64(timestamp_str
, ×tamp
);
650 log_debug_errno(r
, "Failed to parse timestamp value '%s' in file '%s', using mtime: %m", timestamp_str
, p
);
654 return timespec_load_nsec(&usr
.st_mtim
) > timestamp
;
657 static int condition_test_first_boot(Condition
*c
, char **env
) {
662 assert(c
->parameter
);
663 assert(c
->type
== CONDITION_FIRST_BOOT
);
665 r
= proc_cmdline_get_bool("systemd.condition-first-boot", &b
);
667 log_debug_errno(r
, "Failed to parse systemd.condition-first-boot= kernel command line argument, ignoring: %m");
671 r
= parse_boolean(c
->parameter
);
675 q
= access("/run/systemd/first-boot", F_OK
);
676 if (q
< 0 && errno
!= ENOENT
)
677 log_debug_errno(errno
, "Failed to check if /run/systemd/first-boot exists, ignoring: %m");
679 return (q
>= 0) == !!r
;
682 static int condition_test_environment(Condition
*c
, char **env
) {
687 assert(c
->parameter
);
688 assert(c
->type
== CONDITION_ENVIRONMENT
);
690 equal
= strchr(c
->parameter
, '=');
692 STRV_FOREACH(i
, env
) {
696 found
= streq(c
->parameter
, *i
);
700 f
= startswith(*i
, c
->parameter
);
701 found
= f
&& IN_SET(*f
, 0, '=');
711 static int condition_test_path_exists(Condition
*c
, char **env
) {
713 assert(c
->parameter
);
714 assert(c
->type
== CONDITION_PATH_EXISTS
);
716 return access(c
->parameter
, F_OK
) >= 0;
719 static int condition_test_path_exists_glob(Condition
*c
, char **env
) {
721 assert(c
->parameter
);
722 assert(c
->type
== CONDITION_PATH_EXISTS_GLOB
);
724 return glob_exists(c
->parameter
) > 0;
727 static int condition_test_path_is_directory(Condition
*c
, char **env
) {
729 assert(c
->parameter
);
730 assert(c
->type
== CONDITION_PATH_IS_DIRECTORY
);
732 return is_dir(c
->parameter
, true) > 0;
735 static int condition_test_path_is_symbolic_link(Condition
*c
, char **env
) {
737 assert(c
->parameter
);
738 assert(c
->type
== CONDITION_PATH_IS_SYMBOLIC_LINK
);
740 return is_symlink(c
->parameter
) > 0;
743 static int condition_test_path_is_mount_point(Condition
*c
, char **env
) {
745 assert(c
->parameter
);
746 assert(c
->type
== CONDITION_PATH_IS_MOUNT_POINT
);
748 return path_is_mount_point(c
->parameter
, NULL
, AT_SYMLINK_FOLLOW
) > 0;
751 static int condition_test_path_is_read_write(Condition
*c
, char **env
) {
753 assert(c
->parameter
);
754 assert(c
->type
== CONDITION_PATH_IS_READ_WRITE
);
756 return path_is_read_only_fs(c
->parameter
) <= 0;
759 static int condition_test_path_is_encrypted(Condition
*c
, char **env
) {
763 assert(c
->parameter
);
764 assert(c
->type
== CONDITION_PATH_IS_ENCRYPTED
);
766 r
= path_is_encrypted(c
->parameter
);
767 if (r
< 0 && r
!= -ENOENT
)
768 log_debug_errno(r
, "Failed to determine if '%s' is encrypted: %m", c
->parameter
);
773 static int condition_test_directory_not_empty(Condition
*c
, char **env
) {
777 assert(c
->parameter
);
778 assert(c
->type
== CONDITION_DIRECTORY_NOT_EMPTY
);
780 r
= dir_is_empty(c
->parameter
);
781 return r
<= 0 && r
!= -ENOENT
;
784 static int condition_test_file_not_empty(Condition
*c
, char **env
) {
788 assert(c
->parameter
);
789 assert(c
->type
== CONDITION_FILE_NOT_EMPTY
);
791 return (stat(c
->parameter
, &st
) >= 0 &&
792 S_ISREG(st
.st_mode
) &&
796 static int condition_test_file_is_executable(Condition
*c
, char **env
) {
800 assert(c
->parameter
);
801 assert(c
->type
== CONDITION_FILE_IS_EXECUTABLE
);
803 return (stat(c
->parameter
, &st
) >= 0 &&
804 S_ISREG(st
.st_mode
) &&
805 (st
.st_mode
& 0111));
808 int condition_test(Condition
*c
, char **env
) {
810 static int (*const condition_tests
[_CONDITION_TYPE_MAX
])(Condition
*c
, char **env
) = {
811 [CONDITION_PATH_EXISTS
] = condition_test_path_exists
,
812 [CONDITION_PATH_EXISTS_GLOB
] = condition_test_path_exists_glob
,
813 [CONDITION_PATH_IS_DIRECTORY
] = condition_test_path_is_directory
,
814 [CONDITION_PATH_IS_SYMBOLIC_LINK
] = condition_test_path_is_symbolic_link
,
815 [CONDITION_PATH_IS_MOUNT_POINT
] = condition_test_path_is_mount_point
,
816 [CONDITION_PATH_IS_READ_WRITE
] = condition_test_path_is_read_write
,
817 [CONDITION_PATH_IS_ENCRYPTED
] = condition_test_path_is_encrypted
,
818 [CONDITION_DIRECTORY_NOT_EMPTY
] = condition_test_directory_not_empty
,
819 [CONDITION_FILE_NOT_EMPTY
] = condition_test_file_not_empty
,
820 [CONDITION_FILE_IS_EXECUTABLE
] = condition_test_file_is_executable
,
821 [CONDITION_KERNEL_COMMAND_LINE
] = condition_test_kernel_command_line
,
822 [CONDITION_KERNEL_VERSION
] = condition_test_kernel_version
,
823 [CONDITION_VIRTUALIZATION
] = condition_test_virtualization
,
824 [CONDITION_SECURITY
] = condition_test_security
,
825 [CONDITION_CAPABILITY
] = condition_test_capability
,
826 [CONDITION_HOST
] = condition_test_host
,
827 [CONDITION_AC_POWER
] = condition_test_ac_power
,
828 [CONDITION_ARCHITECTURE
] = condition_test_architecture
,
829 [CONDITION_NEEDS_UPDATE
] = condition_test_needs_update
,
830 [CONDITION_FIRST_BOOT
] = condition_test_first_boot
,
831 [CONDITION_USER
] = condition_test_user
,
832 [CONDITION_GROUP
] = condition_test_group
,
833 [CONDITION_CONTROL_GROUP_CONTROLLER
] = condition_test_control_group_controller
,
834 [CONDITION_CPUS
] = condition_test_cpus
,
835 [CONDITION_MEMORY
] = condition_test_memory
,
836 [CONDITION_ENVIRONMENT
] = condition_test_environment
,
842 assert(c
->type
>= 0);
843 assert(c
->type
< _CONDITION_TYPE_MAX
);
845 r
= condition_tests
[c
->type
](c
, env
);
847 c
->result
= CONDITION_ERROR
;
851 b
= (r
> 0) == !c
->negate
;
852 c
->result
= b
? CONDITION_SUCCEEDED
: CONDITION_FAILED
;
856 bool condition_test_list(
859 condition_to_string_t to_string
,
860 condition_test_logger_t logger
,
866 assert(!!logger
== !!to_string
);
868 /* If the condition list is empty, then it is true */
872 /* Otherwise, if all of the non-trigger conditions apply and
873 * if any of the trigger conditions apply (unless there are
874 * none) we return true */
875 LIST_FOREACH(conditions
, c
, first
) {
878 r
= condition_test(c
, env
);
882 logger(userdata
, LOG_WARNING
, r
, PROJECT_FILE
, __LINE__
, __func__
,
883 "Couldn't determine result for %s=%s%s%s, assuming failed: %m",
885 c
->trigger
? "|" : "",
886 c
->negate
? "!" : "",
889 logger(userdata
, LOG_DEBUG
, 0, PROJECT_FILE
, __LINE__
, __func__
,
892 c
->trigger
? "|" : "",
893 c
->negate
? "!" : "",
895 condition_result_to_string(c
->result
));
898 if (!c
->trigger
&& r
<= 0)
901 if (c
->trigger
&& triggered
<= 0)
905 return triggered
!= 0;
908 void condition_dump(Condition
*c
, FILE *f
, const char *prefix
, condition_to_string_t to_string
) {
913 prefix
= strempty(prefix
);
916 "%s\t%s: %s%s%s %s\n",
919 c
->trigger
? "|" : "",
920 c
->negate
? "!" : "",
922 condition_result_to_string(c
->result
));
925 void condition_dump_list(Condition
*first
, FILE *f
, const char *prefix
, condition_to_string_t to_string
) {
928 LIST_FOREACH(conditions
, c
, first
)
929 condition_dump(c
, f
, prefix
, to_string
);
932 static const char* const condition_type_table
[_CONDITION_TYPE_MAX
] = {
933 [CONDITION_ARCHITECTURE
] = "ConditionArchitecture",
934 [CONDITION_VIRTUALIZATION
] = "ConditionVirtualization",
935 [CONDITION_HOST
] = "ConditionHost",
936 [CONDITION_KERNEL_COMMAND_LINE
] = "ConditionKernelCommandLine",
937 [CONDITION_KERNEL_VERSION
] = "ConditionKernelVersion",
938 [CONDITION_SECURITY
] = "ConditionSecurity",
939 [CONDITION_CAPABILITY
] = "ConditionCapability",
940 [CONDITION_AC_POWER
] = "ConditionACPower",
941 [CONDITION_NEEDS_UPDATE
] = "ConditionNeedsUpdate",
942 [CONDITION_FIRST_BOOT
] = "ConditionFirstBoot",
943 [CONDITION_PATH_EXISTS
] = "ConditionPathExists",
944 [CONDITION_PATH_EXISTS_GLOB
] = "ConditionPathExistsGlob",
945 [CONDITION_PATH_IS_DIRECTORY
] = "ConditionPathIsDirectory",
946 [CONDITION_PATH_IS_SYMBOLIC_LINK
] = "ConditionPathIsSymbolicLink",
947 [CONDITION_PATH_IS_MOUNT_POINT
] = "ConditionPathIsMountPoint",
948 [CONDITION_PATH_IS_READ_WRITE
] = "ConditionPathIsReadWrite",
949 [CONDITION_PATH_IS_ENCRYPTED
] = "ConditionPathIsEncrypted",
950 [CONDITION_DIRECTORY_NOT_EMPTY
] = "ConditionDirectoryNotEmpty",
951 [CONDITION_FILE_NOT_EMPTY
] = "ConditionFileNotEmpty",
952 [CONDITION_FILE_IS_EXECUTABLE
] = "ConditionFileIsExecutable",
953 [CONDITION_USER
] = "ConditionUser",
954 [CONDITION_GROUP
] = "ConditionGroup",
955 [CONDITION_CONTROL_GROUP_CONTROLLER
] = "ConditionControlGroupController",
956 [CONDITION_CPUS
] = "ConditionCPUs",
957 [CONDITION_MEMORY
] = "ConditionMemory",
958 [CONDITION_ENVIRONMENT
] = "ConditionEnvironment",
961 DEFINE_STRING_TABLE_LOOKUP(condition_type
, ConditionType
);
963 static const char* const assert_type_table
[_CONDITION_TYPE_MAX
] = {
964 [CONDITION_ARCHITECTURE
] = "AssertArchitecture",
965 [CONDITION_VIRTUALIZATION
] = "AssertVirtualization",
966 [CONDITION_HOST
] = "AssertHost",
967 [CONDITION_KERNEL_COMMAND_LINE
] = "AssertKernelCommandLine",
968 [CONDITION_KERNEL_VERSION
] = "AssertKernelVersion",
969 [CONDITION_SECURITY
] = "AssertSecurity",
970 [CONDITION_CAPABILITY
] = "AssertCapability",
971 [CONDITION_AC_POWER
] = "AssertACPower",
972 [CONDITION_NEEDS_UPDATE
] = "AssertNeedsUpdate",
973 [CONDITION_FIRST_BOOT
] = "AssertFirstBoot",
974 [CONDITION_PATH_EXISTS
] = "AssertPathExists",
975 [CONDITION_PATH_EXISTS_GLOB
] = "AssertPathExistsGlob",
976 [CONDITION_PATH_IS_DIRECTORY
] = "AssertPathIsDirectory",
977 [CONDITION_PATH_IS_SYMBOLIC_LINK
] = "AssertPathIsSymbolicLink",
978 [CONDITION_PATH_IS_MOUNT_POINT
] = "AssertPathIsMountPoint",
979 [CONDITION_PATH_IS_READ_WRITE
] = "AssertPathIsReadWrite",
980 [CONDITION_PATH_IS_ENCRYPTED
] = "AssertPathIsEncrypted",
981 [CONDITION_DIRECTORY_NOT_EMPTY
] = "AssertDirectoryNotEmpty",
982 [CONDITION_FILE_NOT_EMPTY
] = "AssertFileNotEmpty",
983 [CONDITION_FILE_IS_EXECUTABLE
] = "AssertFileIsExecutable",
984 [CONDITION_USER
] = "AssertUser",
985 [CONDITION_GROUP
] = "AssertGroup",
986 [CONDITION_CONTROL_GROUP_CONTROLLER
] = "AssertControlGroupController",
987 [CONDITION_CPUS
] = "AssertCPUs",
988 [CONDITION_MEMORY
] = "AssertMemory",
989 [CONDITION_ENVIRONMENT
] = "AssertEnvironment",
992 DEFINE_STRING_TABLE_LOOKUP(assert_type
, ConditionType
);
994 static const char* const condition_result_table
[_CONDITION_RESULT_MAX
] = {
995 [CONDITION_UNTESTED
] = "untested",
996 [CONDITION_SUCCEEDED
] = "succeeded",
997 [CONDITION_FAILED
] = "failed",
998 [CONDITION_ERROR
] = "error",
1001 DEFINE_STRING_TABLE_LOOKUP(condition_result
, ConditionResult
);