]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/shared/condition.c
Merge pull request #11827 from keszybz/pkgconfig-variables
[thirdparty/systemd.git] / src / shared / condition.c
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2
3 #include <errno.h>
4 #include <fcntl.h>
5 #include <fnmatch.h>
6 #include <limits.h>
7 #include <stdlib.h>
8 #include <string.h>
9 #include <sys/stat.h>
10 #include <sys/types.h>
11 #include <sys/utsname.h>
12 #include <time.h>
13 #include <unistd.h>
14
15 #include "sd-id128.h"
16
17 #include "alloc-util.h"
18 #include "apparmor-util.h"
19 #include "architecture.h"
20 #include "audit-util.h"
21 #include "cap-list.h"
22 #include "cgroup-util.h"
23 #include "condition.h"
24 #include "efivars.h"
25 #include "extract-word.h"
26 #include "fd-util.h"
27 #include "fileio.h"
28 #include "glob-util.h"
29 #include "hostname-util.h"
30 #include "ima-util.h"
31 #include "list.h"
32 #include "macro.h"
33 #include "mountpoint-util.h"
34 #include "env-file.h"
35 #include "parse-util.h"
36 #include "path-util.h"
37 #include "proc-cmdline.h"
38 #include "process-util.h"
39 #include "selinux-util.h"
40 #include "smack-util.h"
41 #include "stat-util.h"
42 #include "string-table.h"
43 #include "string-util.h"
44 #include "tomoyo-util.h"
45 #include "user-util.h"
46 #include "util.h"
47 #include "virt.h"
48
49 Condition* condition_new(ConditionType type, const char *parameter, bool trigger, bool negate) {
50 Condition *c;
51 int r;
52
53 assert(type >= 0);
54 assert(type < _CONDITION_TYPE_MAX);
55 assert((!parameter) == (type == CONDITION_NULL));
56
57 c = new0(Condition, 1);
58 if (!c)
59 return NULL;
60
61 c->type = type;
62 c->trigger = trigger;
63 c->negate = negate;
64
65 r = free_and_strdup(&c->parameter, parameter);
66 if (r < 0) {
67 return mfree(c);
68 }
69
70 return c;
71 }
72
73 void condition_free(Condition *c) {
74 assert(c);
75
76 free(c->parameter);
77 free(c);
78 }
79
80 Condition* condition_free_list(Condition *first) {
81 Condition *c, *n;
82
83 LIST_FOREACH_SAFE(conditions, c, n, first)
84 condition_free(c);
85
86 return NULL;
87 }
88
89 static int condition_test_kernel_command_line(Condition *c) {
90 _cleanup_free_ char *line = NULL;
91 const char *p;
92 bool equal;
93 int r;
94
95 assert(c);
96 assert(c->parameter);
97 assert(c->type == CONDITION_KERNEL_COMMAND_LINE);
98
99 r = proc_cmdline(&line);
100 if (r < 0)
101 return r;
102
103 equal = strchr(c->parameter, '=');
104
105 for (p = line;;) {
106 _cleanup_free_ char *word = NULL;
107 bool found;
108
109 r = extract_first_word(&p, &word, NULL, EXTRACT_QUOTES|EXTRACT_RELAX);
110 if (r < 0)
111 return r;
112 if (r == 0)
113 break;
114
115 if (equal)
116 found = streq(word, c->parameter);
117 else {
118 const char *f;
119
120 f = startswith(word, c->parameter);
121 found = f && IN_SET(*f, 0, '=');
122 }
123
124 if (found)
125 return true;
126 }
127
128 return false;
129 }
130
131 static int condition_test_kernel_version(Condition *c) {
132 enum {
133 /* Listed in order of checking. Note that some comparators are prefixes of others, hence the longest
134 * should be listed first. */
135 LOWER_OR_EQUAL,
136 GREATER_OR_EQUAL,
137 LOWER,
138 GREATER,
139 EQUAL,
140 _ORDER_MAX,
141 };
142
143 static const char *const prefix[_ORDER_MAX] = {
144 [LOWER_OR_EQUAL] = "<=",
145 [GREATER_OR_EQUAL] = ">=",
146 [LOWER] = "<",
147 [GREATER] = ">",
148 [EQUAL] = "=",
149 };
150 const char *p = NULL;
151 struct utsname u;
152 size_t i;
153 int k;
154
155 assert(c);
156 assert(c->parameter);
157 assert(c->type == CONDITION_KERNEL_VERSION);
158
159 assert_se(uname(&u) >= 0);
160
161 for (i = 0; i < _ORDER_MAX; i++) {
162 p = startswith(c->parameter, prefix[i]);
163 if (p)
164 break;
165 }
166
167 /* No prefix? Then treat as glob string */
168 if (!p)
169 return fnmatch(skip_leading_chars(c->parameter, NULL), u.release, 0) == 0;
170
171 k = str_verscmp(u.release, skip_leading_chars(p, NULL));
172
173 switch (i) {
174
175 case LOWER:
176 return k < 0;
177
178 case LOWER_OR_EQUAL:
179 return k <= 0;
180
181 case EQUAL:
182 return k == 0;
183
184 case GREATER_OR_EQUAL:
185 return k >= 0;
186
187 case GREATER:
188 return k > 0;
189
190 default:
191 assert_not_reached("Can't compare");
192 }
193 }
194
195 static int condition_test_user(Condition *c) {
196 uid_t id;
197 int r;
198 _cleanup_free_ char *username = NULL;
199 const char *u;
200
201 assert(c);
202 assert(c->parameter);
203 assert(c->type == CONDITION_USER);
204
205 r = parse_uid(c->parameter, &id);
206 if (r >= 0)
207 return id == getuid() || id == geteuid();
208
209 if (streq("@system", c->parameter))
210 return uid_is_system(getuid()) || uid_is_system(geteuid());
211
212 username = getusername_malloc();
213 if (!username)
214 return -ENOMEM;
215
216 if (streq(username, c->parameter))
217 return 1;
218
219 if (getpid_cached() == 1)
220 return streq(c->parameter, "root");
221
222 u = c->parameter;
223 r = get_user_creds(&u, &id, NULL, NULL, NULL, USER_CREDS_ALLOW_MISSING);
224 if (r < 0)
225 return 0;
226
227 return id == getuid() || id == geteuid();
228 }
229
230 static int condition_test_control_group_controller(Condition *c) {
231 int r;
232 CGroupMask system_mask, wanted_mask = 0;
233
234 assert(c);
235 assert(c->parameter);
236 assert(c->type == CONDITION_CONTROL_GROUP_CONTROLLER);
237
238 r = cg_mask_supported(&system_mask);
239 if (r < 0)
240 return log_debug_errno(r, "Failed to determine supported controllers: %m");
241
242 r = cg_mask_from_string(c->parameter, &wanted_mask);
243 if (r < 0 || wanted_mask <= 0) {
244 /* This won't catch the case that we have an unknown controller
245 * mixed in with valid ones -- these are only assessed on the
246 * validity of the valid controllers found. */
247 log_debug("Failed to parse cgroup string: %s", c->parameter);
248 return 1;
249 }
250
251 return FLAGS_SET(system_mask, wanted_mask);
252 }
253
254 static int condition_test_group(Condition *c) {
255 gid_t id;
256 int r;
257
258 assert(c);
259 assert(c->parameter);
260 assert(c->type == CONDITION_GROUP);
261
262 r = parse_gid(c->parameter, &id);
263 if (r >= 0)
264 return in_gid(id);
265
266 /* Avoid any NSS lookups if we are PID1 */
267 if (getpid_cached() == 1)
268 return streq(c->parameter, "root");
269
270 return in_group(c->parameter) > 0;
271 }
272
273 static int condition_test_virtualization(Condition *c) {
274 int b, v;
275
276 assert(c);
277 assert(c->parameter);
278 assert(c->type == CONDITION_VIRTUALIZATION);
279
280 if (streq(c->parameter, "private-users"))
281 return running_in_userns();
282
283 v = detect_virtualization();
284 if (v < 0)
285 return v;
286
287 /* First, compare with yes/no */
288 b = parse_boolean(c->parameter);
289 if (b >= 0)
290 return b == !!v;
291
292 /* Then, compare categorization */
293 if (streq(c->parameter, "vm"))
294 return VIRTUALIZATION_IS_VM(v);
295
296 if (streq(c->parameter, "container"))
297 return VIRTUALIZATION_IS_CONTAINER(v);
298
299 /* Finally compare id */
300 return v != VIRTUALIZATION_NONE && streq(c->parameter, virtualization_to_string(v));
301 }
302
303 static int condition_test_architecture(Condition *c) {
304 int a, b;
305
306 assert(c);
307 assert(c->parameter);
308 assert(c->type == CONDITION_ARCHITECTURE);
309
310 a = uname_architecture();
311 if (a < 0)
312 return a;
313
314 if (streq(c->parameter, "native"))
315 b = native_architecture();
316 else {
317 b = architecture_from_string(c->parameter);
318 if (b < 0) /* unknown architecture? Then it's definitely not ours */
319 return false;
320 }
321
322 return a == b;
323 }
324
325 static int condition_test_host(Condition *c) {
326 _cleanup_free_ char *h = NULL;
327 sd_id128_t x, y;
328 int r;
329
330 assert(c);
331 assert(c->parameter);
332 assert(c->type == CONDITION_HOST);
333
334 if (sd_id128_from_string(c->parameter, &x) >= 0) {
335
336 r = sd_id128_get_machine(&y);
337 if (r < 0)
338 return r;
339
340 return sd_id128_equal(x, y);
341 }
342
343 h = gethostname_malloc();
344 if (!h)
345 return -ENOMEM;
346
347 return fnmatch(c->parameter, h, FNM_CASEFOLD) == 0;
348 }
349
350 static int condition_test_ac_power(Condition *c) {
351 int r;
352
353 assert(c);
354 assert(c->parameter);
355 assert(c->type == CONDITION_AC_POWER);
356
357 r = parse_boolean(c->parameter);
358 if (r < 0)
359 return r;
360
361 return (on_ac_power() != 0) == !!r;
362 }
363
364 static int condition_test_security(Condition *c) {
365 assert(c);
366 assert(c->parameter);
367 assert(c->type == CONDITION_SECURITY);
368
369 if (streq(c->parameter, "selinux"))
370 return mac_selinux_use();
371 if (streq(c->parameter, "smack"))
372 return mac_smack_use();
373 if (streq(c->parameter, "apparmor"))
374 return mac_apparmor_use();
375 if (streq(c->parameter, "audit"))
376 return use_audit();
377 if (streq(c->parameter, "ima"))
378 return use_ima();
379 if (streq(c->parameter, "tomoyo"))
380 return mac_tomoyo_use();
381 if (streq(c->parameter, "uefi-secureboot"))
382 return is_efi_secure_boot();
383
384 return false;
385 }
386
387 static int condition_test_capability(Condition *c) {
388 unsigned long long capabilities = (unsigned long long) -1;
389 _cleanup_fclose_ FILE *f = NULL;
390 int value, r;
391
392 assert(c);
393 assert(c->parameter);
394 assert(c->type == CONDITION_CAPABILITY);
395
396 /* If it's an invalid capability, we don't have it */
397 value = capability_from_name(c->parameter);
398 if (value < 0)
399 return -EINVAL;
400
401 /* If it's a valid capability we default to assume
402 * that we have it */
403
404 f = fopen("/proc/self/status", "re");
405 if (!f)
406 return -errno;
407
408 for (;;) {
409 _cleanup_free_ char *line = NULL;
410 const char *p;
411
412 r = read_line(f, LONG_LINE_MAX, &line);
413 if (r < 0)
414 return r;
415 if (r == 0)
416 break;
417
418 p = startswith(line, "CapBnd:");
419 if (p) {
420 if (sscanf(line+7, "%llx", &capabilities) != 1)
421 return -EIO;
422
423 break;
424 }
425 }
426
427 return !!(capabilities & (1ULL << value));
428 }
429
430 static int condition_test_needs_update(Condition *c) {
431 const char *p;
432 struct stat usr, other;
433
434 assert(c);
435 assert(c->parameter);
436 assert(c->type == CONDITION_NEEDS_UPDATE);
437
438 /* If the file system is read-only we shouldn't suggest an update */
439 if (path_is_read_only_fs(c->parameter) > 0)
440 return false;
441
442 /* Any other failure means we should allow the condition to be true,
443 * so that we rather invoke too many update tools than too
444 * few. */
445
446 if (!path_is_absolute(c->parameter))
447 return true;
448
449 p = strjoina(c->parameter, "/.updated");
450 if (lstat(p, &other) < 0)
451 return true;
452
453 if (lstat("/usr/", &usr) < 0)
454 return true;
455
456 /*
457 * First, compare seconds as they are always accurate...
458 */
459 if (usr.st_mtim.tv_sec != other.st_mtim.tv_sec)
460 return usr.st_mtim.tv_sec > other.st_mtim.tv_sec;
461
462 /*
463 * ...then compare nanoseconds.
464 *
465 * A false positive is only possible when /usr's nanoseconds > 0
466 * (otherwise /usr cannot be strictly newer than the target file)
467 * AND the target file's nanoseconds == 0
468 * (otherwise the filesystem supports nsec timestamps, see stat(2)).
469 */
470 if (usr.st_mtim.tv_nsec > 0 && other.st_mtim.tv_nsec == 0) {
471 _cleanup_free_ char *timestamp_str = NULL;
472 uint64_t timestamp;
473 int r;
474
475 r = parse_env_file(NULL, p, "TIMESTAMP_NSEC", &timestamp_str);
476 if (r < 0) {
477 log_error_errno(r, "Failed to parse timestamp file '%s', using mtime: %m", p);
478 return true;
479 } else if (r == 0) {
480 log_debug("No data in timestamp file '%s', using mtime", p);
481 return true;
482 }
483
484 r = safe_atou64(timestamp_str, &timestamp);
485 if (r < 0) {
486 log_error_errno(r, "Failed to parse timestamp value '%s' in file '%s', using mtime: %m", timestamp_str, p);
487 return true;
488 }
489
490 timespec_store(&other.st_mtim, timestamp);
491 }
492
493 return usr.st_mtim.tv_nsec > other.st_mtim.tv_nsec;
494 }
495
496 static int condition_test_first_boot(Condition *c) {
497 int r;
498
499 assert(c);
500 assert(c->parameter);
501 assert(c->type == CONDITION_FIRST_BOOT);
502
503 r = parse_boolean(c->parameter);
504 if (r < 0)
505 return r;
506
507 return (access("/run/systemd/first-boot", F_OK) >= 0) == !!r;
508 }
509
510 static int condition_test_path_exists(Condition *c) {
511 assert(c);
512 assert(c->parameter);
513 assert(c->type == CONDITION_PATH_EXISTS);
514
515 return access(c->parameter, F_OK) >= 0;
516 }
517
518 static int condition_test_path_exists_glob(Condition *c) {
519 assert(c);
520 assert(c->parameter);
521 assert(c->type == CONDITION_PATH_EXISTS_GLOB);
522
523 return glob_exists(c->parameter) > 0;
524 }
525
526 static int condition_test_path_is_directory(Condition *c) {
527 assert(c);
528 assert(c->parameter);
529 assert(c->type == CONDITION_PATH_IS_DIRECTORY);
530
531 return is_dir(c->parameter, true) > 0;
532 }
533
534 static int condition_test_path_is_symbolic_link(Condition *c) {
535 assert(c);
536 assert(c->parameter);
537 assert(c->type == CONDITION_PATH_IS_SYMBOLIC_LINK);
538
539 return is_symlink(c->parameter) > 0;
540 }
541
542 static int condition_test_path_is_mount_point(Condition *c) {
543 assert(c);
544 assert(c->parameter);
545 assert(c->type == CONDITION_PATH_IS_MOUNT_POINT);
546
547 return path_is_mount_point(c->parameter, NULL, AT_SYMLINK_FOLLOW) > 0;
548 }
549
550 static int condition_test_path_is_read_write(Condition *c) {
551 assert(c);
552 assert(c->parameter);
553 assert(c->type == CONDITION_PATH_IS_READ_WRITE);
554
555 return path_is_read_only_fs(c->parameter) <= 0;
556 }
557
558 static int condition_test_directory_not_empty(Condition *c) {
559 int r;
560
561 assert(c);
562 assert(c->parameter);
563 assert(c->type == CONDITION_DIRECTORY_NOT_EMPTY);
564
565 r = dir_is_empty(c->parameter);
566 return r <= 0 && r != -ENOENT;
567 }
568
569 static int condition_test_file_not_empty(Condition *c) {
570 struct stat st;
571
572 assert(c);
573 assert(c->parameter);
574 assert(c->type == CONDITION_FILE_NOT_EMPTY);
575
576 return (stat(c->parameter, &st) >= 0 &&
577 S_ISREG(st.st_mode) &&
578 st.st_size > 0);
579 }
580
581 static int condition_test_file_is_executable(Condition *c) {
582 struct stat st;
583
584 assert(c);
585 assert(c->parameter);
586 assert(c->type == CONDITION_FILE_IS_EXECUTABLE);
587
588 return (stat(c->parameter, &st) >= 0 &&
589 S_ISREG(st.st_mode) &&
590 (st.st_mode & 0111));
591 }
592
593 static int condition_test_null(Condition *c) {
594 assert(c);
595 assert(c->type == CONDITION_NULL);
596
597 /* Note that during parsing we already evaluate the string and
598 * store it in c->negate */
599 return true;
600 }
601
602 int condition_test(Condition *c) {
603
604 static int (*const condition_tests[_CONDITION_TYPE_MAX])(Condition *c) = {
605 [CONDITION_PATH_EXISTS] = condition_test_path_exists,
606 [CONDITION_PATH_EXISTS_GLOB] = condition_test_path_exists_glob,
607 [CONDITION_PATH_IS_DIRECTORY] = condition_test_path_is_directory,
608 [CONDITION_PATH_IS_SYMBOLIC_LINK] = condition_test_path_is_symbolic_link,
609 [CONDITION_PATH_IS_MOUNT_POINT] = condition_test_path_is_mount_point,
610 [CONDITION_PATH_IS_READ_WRITE] = condition_test_path_is_read_write,
611 [CONDITION_DIRECTORY_NOT_EMPTY] = condition_test_directory_not_empty,
612 [CONDITION_FILE_NOT_EMPTY] = condition_test_file_not_empty,
613 [CONDITION_FILE_IS_EXECUTABLE] = condition_test_file_is_executable,
614 [CONDITION_KERNEL_COMMAND_LINE] = condition_test_kernel_command_line,
615 [CONDITION_KERNEL_VERSION] = condition_test_kernel_version,
616 [CONDITION_VIRTUALIZATION] = condition_test_virtualization,
617 [CONDITION_SECURITY] = condition_test_security,
618 [CONDITION_CAPABILITY] = condition_test_capability,
619 [CONDITION_HOST] = condition_test_host,
620 [CONDITION_AC_POWER] = condition_test_ac_power,
621 [CONDITION_ARCHITECTURE] = condition_test_architecture,
622 [CONDITION_NEEDS_UPDATE] = condition_test_needs_update,
623 [CONDITION_FIRST_BOOT] = condition_test_first_boot,
624 [CONDITION_USER] = condition_test_user,
625 [CONDITION_GROUP] = condition_test_group,
626 [CONDITION_CONTROL_GROUP_CONTROLLER] = condition_test_control_group_controller,
627 [CONDITION_NULL] = condition_test_null,
628 };
629
630 int r, b;
631
632 assert(c);
633 assert(c->type >= 0);
634 assert(c->type < _CONDITION_TYPE_MAX);
635
636 r = condition_tests[c->type](c);
637 if (r < 0) {
638 c->result = CONDITION_ERROR;
639 return r;
640 }
641
642 b = (r > 0) == !c->negate;
643 c->result = b ? CONDITION_SUCCEEDED : CONDITION_FAILED;
644 return b;
645 }
646
647 void condition_dump(Condition *c, FILE *f, const char *prefix, const char *(*to_string)(ConditionType t)) {
648 assert(c);
649 assert(f);
650
651 prefix = strempty(prefix);
652
653 fprintf(f,
654 "%s\t%s: %s%s%s %s\n",
655 prefix,
656 to_string(c->type),
657 c->trigger ? "|" : "",
658 c->negate ? "!" : "",
659 c->parameter,
660 condition_result_to_string(c->result));
661 }
662
663 void condition_dump_list(Condition *first, FILE *f, const char *prefix, const char *(*to_string)(ConditionType t)) {
664 Condition *c;
665
666 LIST_FOREACH(conditions, c, first)
667 condition_dump(c, f, prefix, to_string);
668 }
669
670 static const char* const condition_type_table[_CONDITION_TYPE_MAX] = {
671 [CONDITION_ARCHITECTURE] = "ConditionArchitecture",
672 [CONDITION_VIRTUALIZATION] = "ConditionVirtualization",
673 [CONDITION_HOST] = "ConditionHost",
674 [CONDITION_KERNEL_COMMAND_LINE] = "ConditionKernelCommandLine",
675 [CONDITION_KERNEL_VERSION] = "ConditionKernelVersion",
676 [CONDITION_SECURITY] = "ConditionSecurity",
677 [CONDITION_CAPABILITY] = "ConditionCapability",
678 [CONDITION_AC_POWER] = "ConditionACPower",
679 [CONDITION_NEEDS_UPDATE] = "ConditionNeedsUpdate",
680 [CONDITION_FIRST_BOOT] = "ConditionFirstBoot",
681 [CONDITION_PATH_EXISTS] = "ConditionPathExists",
682 [CONDITION_PATH_EXISTS_GLOB] = "ConditionPathExistsGlob",
683 [CONDITION_PATH_IS_DIRECTORY] = "ConditionPathIsDirectory",
684 [CONDITION_PATH_IS_SYMBOLIC_LINK] = "ConditionPathIsSymbolicLink",
685 [CONDITION_PATH_IS_MOUNT_POINT] = "ConditionPathIsMountPoint",
686 [CONDITION_PATH_IS_READ_WRITE] = "ConditionPathIsReadWrite",
687 [CONDITION_DIRECTORY_NOT_EMPTY] = "ConditionDirectoryNotEmpty",
688 [CONDITION_FILE_NOT_EMPTY] = "ConditionFileNotEmpty",
689 [CONDITION_FILE_IS_EXECUTABLE] = "ConditionFileIsExecutable",
690 [CONDITION_USER] = "ConditionUser",
691 [CONDITION_GROUP] = "ConditionGroup",
692 [CONDITION_CONTROL_GROUP_CONTROLLER] = "ConditionControlGroupController",
693 [CONDITION_NULL] = "ConditionNull"
694 };
695
696 DEFINE_STRING_TABLE_LOOKUP(condition_type, ConditionType);
697
698 static const char* const assert_type_table[_CONDITION_TYPE_MAX] = {
699 [CONDITION_ARCHITECTURE] = "AssertArchitecture",
700 [CONDITION_VIRTUALIZATION] = "AssertVirtualization",
701 [CONDITION_HOST] = "AssertHost",
702 [CONDITION_KERNEL_COMMAND_LINE] = "AssertKernelCommandLine",
703 [CONDITION_KERNEL_VERSION] = "AssertKernelVersion",
704 [CONDITION_SECURITY] = "AssertSecurity",
705 [CONDITION_CAPABILITY] = "AssertCapability",
706 [CONDITION_AC_POWER] = "AssertACPower",
707 [CONDITION_NEEDS_UPDATE] = "AssertNeedsUpdate",
708 [CONDITION_FIRST_BOOT] = "AssertFirstBoot",
709 [CONDITION_PATH_EXISTS] = "AssertPathExists",
710 [CONDITION_PATH_EXISTS_GLOB] = "AssertPathExistsGlob",
711 [CONDITION_PATH_IS_DIRECTORY] = "AssertPathIsDirectory",
712 [CONDITION_PATH_IS_SYMBOLIC_LINK] = "AssertPathIsSymbolicLink",
713 [CONDITION_PATH_IS_MOUNT_POINT] = "AssertPathIsMountPoint",
714 [CONDITION_PATH_IS_READ_WRITE] = "AssertPathIsReadWrite",
715 [CONDITION_DIRECTORY_NOT_EMPTY] = "AssertDirectoryNotEmpty",
716 [CONDITION_FILE_NOT_EMPTY] = "AssertFileNotEmpty",
717 [CONDITION_FILE_IS_EXECUTABLE] = "AssertFileIsExecutable",
718 [CONDITION_USER] = "AssertUser",
719 [CONDITION_GROUP] = "AssertGroup",
720 [CONDITION_CONTROL_GROUP_CONTROLLER] = "AssertControlGroupController",
721 [CONDITION_NULL] = "AssertNull"
722 };
723
724 DEFINE_STRING_TABLE_LOOKUP(assert_type, ConditionType);
725
726 static const char* const condition_result_table[_CONDITION_RESULT_MAX] = {
727 [CONDITION_UNTESTED] = "untested",
728 [CONDITION_SUCCEEDED] = "succeeded",
729 [CONDITION_FAILED] = "failed",
730 [CONDITION_ERROR] = "error",
731 };
732
733 DEFINE_STRING_TABLE_LOOKUP(condition_result, ConditionResult);