test-condition.c revision 015df1f78f443f91b354e0c4b4cb76de86c838eb
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering/***
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering This file is part of systemd
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering Copyright 2014 Ronny Chevalier
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering systemd is free software; you can redistribute it and/or modify it
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering under the terms of the GNU Lesser General Public License as published by
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering the Free Software Foundation; either version 2.1 of the License, or
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering (at your option) any later version.
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering systemd is distributed in the hope that it will be useful, but
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering WITHOUT ANY WARRANTY; without even the implied warranty of
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering Lesser General Public License for more details.
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering You should have received a copy of the GNU Lesser General Public License
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering along with systemd; If not, see <http://www.gnu.org/licenses/>.
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering***/
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering#include "condition.h"
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering#include "macro.h"
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering#include "util.h"
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering#include "log.h"
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering#include "architecture.h"
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering#include "sd-id128.h"
50f1e641a93cacfc693b0c3d300bee5df0c8c460Tom Gundersen#include "selinux-util.h"
71d35b6b5563817dfbe757ab9e3b9f018b2db491Thomas Hindoe Paaboel Andersen#include "audit.h"
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering#include "ima-util.h"
623a4c97b9175f95c4b1c6fc34e36c56f1e4ddbfLennart Poettering#include "apparmor-util.h"
2001c80560e3dae69e14fd994d3978c187af48b8Lennart Poettering#include "smack-util.h"
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringstatic void test_condition_test_path(void) {
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering Condition *condition;
2001c80560e3dae69e14fd994d3978c187af48b8Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering condition = condition_new(CONDITION_PATH_EXISTS, "/bin/sh", false, false);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering assert_se(condition_test(condition));
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering condition_free(condition);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering condition = condition_new(CONDITION_PATH_EXISTS, "/bin/s?", false, false);
b93312f5960b276bae915906ccde36f545bae3e0Zbigniew Jędrzejewski-Szmek assert_se(!condition_test(condition));
b93312f5960b276bae915906ccde36f545bae3e0Zbigniew Jędrzejewski-Szmek condition_free(condition);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering condition = condition_new(CONDITION_PATH_EXISTS_GLOB, "/bin/s?", false, false);
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering assert_se(condition_test(condition));
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering condition_free(condition);
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering condition = condition_new(CONDITION_PATH_EXISTS_GLOB, "/bin/s?", false, true);
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering assert_se(!condition_test(condition));
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering condition_free(condition);
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering condition = condition_new(CONDITION_PATH_EXISTS, "/thiscertainlywontexist", false, false);
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering assert_se(!condition_test(condition));
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering condition_free(condition);
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering condition = condition_new(CONDITION_PATH_EXISTS, "/thiscertainlywontexist", false, true);
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering assert_se(condition_test(condition));
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering condition_free(condition);
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering condition = condition_new(CONDITION_PATH_IS_DIRECTORY, "/bin", false, false);
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering assert_se(condition_test(condition));
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering condition_free(condition);
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering condition = condition_new(CONDITION_DIRECTORY_NOT_EMPTY, "/bin", false, false);
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering assert_se(condition_test(condition));
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering condition_free(condition);
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering condition = condition_new(CONDITION_FILE_NOT_EMPTY, "/bin/sh", false, false);
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering assert_se(condition_test(condition));
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering condition_free(condition);
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering condition = condition_new(CONDITION_FILE_IS_EXECUTABLE, "/bin/sh", false, false);
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering assert_se(condition_test(condition));
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering condition_free(condition);
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering condition = condition_new(CONDITION_FILE_IS_EXECUTABLE, "/etc/passwd", false, false);
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering assert_se(!condition_test(condition));
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering condition_free(condition);
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering condition = condition_new(CONDITION_PATH_IS_MOUNT_POINT, "/proc", false, false);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering assert_se(condition_test(condition));
1b4f6e79ec51a57003896a0b605fba427b4a98d2Lennart Poettering condition_free(condition);
1b4f6e79ec51a57003896a0b605fba427b4a98d2Lennart Poettering
1b4f6e79ec51a57003896a0b605fba427b4a98d2Lennart Poettering condition = condition_new(CONDITION_PATH_IS_MOUNT_POINT, "/", false, false);
1b4f6e79ec51a57003896a0b605fba427b4a98d2Lennart Poettering assert_se(condition_test(condition));
1b4f6e79ec51a57003896a0b605fba427b4a98d2Lennart Poettering condition_free(condition);
1b4f6e79ec51a57003896a0b605fba427b4a98d2Lennart Poettering
1b4f6e79ec51a57003896a0b605fba427b4a98d2Lennart Poettering condition = condition_new(CONDITION_PATH_IS_MOUNT_POINT, "/bin", false, false);
1b4f6e79ec51a57003896a0b605fba427b4a98d2Lennart Poettering assert_se(!condition_test(condition));
1b4f6e79ec51a57003896a0b605fba427b4a98d2Lennart Poettering condition_free(condition);
1b4f6e79ec51a57003896a0b605fba427b4a98d2Lennart Poettering
1b4f6e79ec51a57003896a0b605fba427b4a98d2Lennart Poettering condition = condition_new(CONDITION_PATH_IS_READ_WRITE, "/tmp", false, false);
1b4f6e79ec51a57003896a0b605fba427b4a98d2Lennart Poettering assert_se(condition_test(condition));
1b4f6e79ec51a57003896a0b605fba427b4a98d2Lennart Poettering condition_free(condition);
2001c80560e3dae69e14fd994d3978c187af48b8Lennart Poettering
2001c80560e3dae69e14fd994d3978c187af48b8Lennart Poettering condition = condition_new(CONDITION_PATH_IS_SYMBOLIC_LINK, "/dev/stdout", false, false);
2001c80560e3dae69e14fd994d3978c187af48b8Lennart Poettering assert_se(condition_test(condition));
2001c80560e3dae69e14fd994d3978c187af48b8Lennart Poettering condition_free(condition);
2001c80560e3dae69e14fd994d3978c187af48b8Lennart Poettering}
2001c80560e3dae69e14fd994d3978c187af48b8Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringstatic void test_condition_test_ac_power(void) {
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering Condition *condition;
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering condition = condition_new(CONDITION_AC_POWER, "true", false, false);
a8812dd7f161a3e459c1730ac92ff2bbc9986ff1Lennart Poettering assert_se(condition_test(condition) == on_ac_power());
a8812dd7f161a3e459c1730ac92ff2bbc9986ff1Lennart Poettering condition_free(condition);
a8812dd7f161a3e459c1730ac92ff2bbc9986ff1Lennart Poettering
a8812dd7f161a3e459c1730ac92ff2bbc9986ff1Lennart Poettering condition = condition_new(CONDITION_AC_POWER, "false", false, false);
a8812dd7f161a3e459c1730ac92ff2bbc9986ff1Lennart Poettering assert_se(condition_test(condition) != on_ac_power());
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering condition_free(condition);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering condition = condition_new(CONDITION_AC_POWER, "false", false, true);
f5430a3ef308f3a102899fcaf7fbece757082f2aLennart Poettering assert_se(condition_test(condition) == on_ac_power());
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering condition_free(condition);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering}
9c92ce6d67f88beb31dd6555d12ae3f632218a39Lennart Poettering
9c92ce6d67f88beb31dd6555d12ae3f632218a39Lennart Poetteringstatic void test_condition_test_host(void) {
9c92ce6d67f88beb31dd6555d12ae3f632218a39Lennart Poettering Condition *condition;
9c92ce6d67f88beb31dd6555d12ae3f632218a39Lennart Poettering sd_id128_t id;
9c92ce6d67f88beb31dd6555d12ae3f632218a39Lennart Poettering int r;
9c92ce6d67f88beb31dd6555d12ae3f632218a39Lennart Poettering char sid[SD_ID128_STRING_MAX];
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering _cleanup_free_ char *hostname = NULL;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering r = sd_id128_get_machine(&id);
8ac4e9e1e54397f6d1745c2a7a806132418c7da2Lennart Poettering assert_se(r >= 0);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering assert_se(sd_id128_to_string(id, sid));
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering condition = condition_new(CONDITION_HOST, sid, false, false);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering assert_se(condition_test(condition));
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering condition_free(condition);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
2e276efc7b0398a3086629a52970bdd4ab7252f9Zbigniew Jędrzejewski-Szmek condition = condition_new(CONDITION_HOST, "garbage value jjjjjjjjjjjjjj", false, false);
2001c80560e3dae69e14fd994d3978c187af48b8Lennart Poettering assert_se(!condition_test(condition));
c0eb11cfd016381fe02875a4ef29c1ade00c94e7Lennart Poettering condition_free(condition);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering condition = condition_new(CONDITION_HOST, sid, false, true);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering assert_se(!condition_test(condition));
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering condition_free(condition);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering hostname = gethostname_malloc();
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering assert_se(hostname);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
7e8e0422aeb16f2a09a40546c61df753d10029b6Lennart Poettering condition = condition_new(CONDITION_HOST, hostname, false, false);
7e8e0422aeb16f2a09a40546c61df753d10029b6Lennart Poettering assert_se(condition_test(condition));
7e8e0422aeb16f2a09a40546c61df753d10029b6Lennart Poettering condition_free(condition);
7e8e0422aeb16f2a09a40546c61df753d10029b6Lennart Poettering}
7e8e0422aeb16f2a09a40546c61df753d10029b6Lennart Poettering
7e8e0422aeb16f2a09a40546c61df753d10029b6Lennart Poetteringstatic void test_condition_test_architecture(void) {
7e8e0422aeb16f2a09a40546c61df753d10029b6Lennart Poettering Condition *condition;
7e8e0422aeb16f2a09a40546c61df753d10029b6Lennart Poettering const char *sa;
7e8e0422aeb16f2a09a40546c61df753d10029b6Lennart Poettering int a;
7e8e0422aeb16f2a09a40546c61df753d10029b6Lennart Poettering
946c70944ebdf428ffeb9991a7449edbd4011461Zbigniew Jędrzejewski-Szmek a = uname_architecture();
946c70944ebdf428ffeb9991a7449edbd4011461Zbigniew Jędrzejewski-Szmek assert_se(a >= 0);
946c70944ebdf428ffeb9991a7449edbd4011461Zbigniew Jędrzejewski-Szmek
946c70944ebdf428ffeb9991a7449edbd4011461Zbigniew Jędrzejewski-Szmek sa = architecture_to_string(a);
946c70944ebdf428ffeb9991a7449edbd4011461Zbigniew Jędrzejewski-Szmek assert_se(sa);
0dae31d468b1a0e22d98921f7b0dbd92fd217167Zbigniew Jędrzejewski-Szmek
0dae31d468b1a0e22d98921f7b0dbd92fd217167Zbigniew Jędrzejewski-Szmek condition = condition_new(CONDITION_ARCHITECTURE, sa, false, false);
0dae31d468b1a0e22d98921f7b0dbd92fd217167Zbigniew Jędrzejewski-Szmek assert_se(condition_test(condition));
0dae31d468b1a0e22d98921f7b0dbd92fd217167Zbigniew Jędrzejewski-Szmek condition_free(condition);
0dae31d468b1a0e22d98921f7b0dbd92fd217167Zbigniew Jędrzejewski-Szmek
0dae31d468b1a0e22d98921f7b0dbd92fd217167Zbigniew Jędrzejewski-Szmek condition = condition_new(CONDITION_ARCHITECTURE, "garbage value", false, false);
0dae31d468b1a0e22d98921f7b0dbd92fd217167Zbigniew Jędrzejewski-Szmek assert_se(condition_test(condition) < 0);
0dae31d468b1a0e22d98921f7b0dbd92fd217167Zbigniew Jędrzejewski-Szmek condition_free(condition);
0dae31d468b1a0e22d98921f7b0dbd92fd217167Zbigniew Jędrzejewski-Szmek
0dae31d468b1a0e22d98921f7b0dbd92fd217167Zbigniew Jędrzejewski-Szmek condition = condition_new(CONDITION_ARCHITECTURE, sa, false, true);
42cc2eebb01056beb7acd3ecfe8e533558237f84Lennart Poettering assert_se(!condition_test(condition));
abf126a355e2f2b62b6c51ab3bb37895d1e3eee7Tom Gundersen condition_free(condition);
abf126a355e2f2b62b6c51ab3bb37895d1e3eee7Tom Gundersen}
abf126a355e2f2b62b6c51ab3bb37895d1e3eee7Tom Gundersen
abf126a355e2f2b62b6c51ab3bb37895d1e3eee7Tom Gundersenstatic void test_condition_test_kernel_command_line(void) {
abf126a355e2f2b62b6c51ab3bb37895d1e3eee7Tom Gundersen Condition *condition;
abf126a355e2f2b62b6c51ab3bb37895d1e3eee7Tom Gundersen
abf126a355e2f2b62b6c51ab3bb37895d1e3eee7Tom Gundersen condition = condition_new(CONDITION_KERNEL_COMMAND_LINE, "thisreallyshouldntbeonthekernelcommandline", false, false);
abf126a355e2f2b62b6c51ab3bb37895d1e3eee7Tom Gundersen assert_se(!condition_test(condition));
549c1a2564b56f2bb38f1203d59c747ea15817f3Tom Gundersen condition_free(condition);
42cc2eebb01056beb7acd3ecfe8e533558237f84Lennart Poettering
42cc2eebb01056beb7acd3ecfe8e533558237f84Lennart Poettering condition = condition_new(CONDITION_KERNEL_COMMAND_LINE, "andthis=neither", false, false);
42cc2eebb01056beb7acd3ecfe8e533558237f84Lennart Poettering assert_se(!condition_test(condition));
549c1a2564b56f2bb38f1203d59c747ea15817f3Tom Gundersen condition_free(condition);
549c1a2564b56f2bb38f1203d59c747ea15817f3Tom Gundersen}
42cc2eebb01056beb7acd3ecfe8e533558237f84Lennart Poettering
8db0d2f5c37e7e8f5bfce016cfdad7947a3ea939Zbigniew Jędrzejewski-Szmekstatic void test_condition_test_null(void) {
8db0d2f5c37e7e8f5bfce016cfdad7947a3ea939Zbigniew Jędrzejewski-Szmek Condition *condition;
8db0d2f5c37e7e8f5bfce016cfdad7947a3ea939Zbigniew Jędrzejewski-Szmek
f91dc2400dc33e9a0745ecaaef7489af116dca38Lennart Poettering condition = condition_new(CONDITION_NULL, NULL, false, false);
f91dc2400dc33e9a0745ecaaef7489af116dca38Lennart Poettering assert_se(condition_test(condition));
8db0d2f5c37e7e8f5bfce016cfdad7947a3ea939Zbigniew Jędrzejewski-Szmek condition_free(condition);
8db0d2f5c37e7e8f5bfce016cfdad7947a3ea939Zbigniew Jędrzejewski-Szmek
8db0d2f5c37e7e8f5bfce016cfdad7947a3ea939Zbigniew Jędrzejewski-Szmek condition = condition_new(CONDITION_NULL, NULL, false, true);
8db0d2f5c37e7e8f5bfce016cfdad7947a3ea939Zbigniew Jędrzejewski-Szmek assert_se(!condition_test(condition));
151226ab4bf276d60d51864330a99f886b923697Zbigniew Jędrzejewski-Szmek condition_free(condition);
151226ab4bf276d60d51864330a99f886b923697Zbigniew Jędrzejewski-Szmek}
151226ab4bf276d60d51864330a99f886b923697Zbigniew Jędrzejewski-Szmek
151226ab4bf276d60d51864330a99f886b923697Zbigniew Jędrzejewski-Szmekstatic void test_condition_test_security(void) {
151226ab4bf276d60d51864330a99f886b923697Zbigniew Jędrzejewski-Szmek Condition *condition;
151226ab4bf276d60d51864330a99f886b923697Zbigniew Jędrzejewski-Szmek
151226ab4bf276d60d51864330a99f886b923697Zbigniew Jędrzejewski-Szmek condition = condition_new(CONDITION_SECURITY, "garbage oifdsjfoidsjoj", false, false);
151226ab4bf276d60d51864330a99f886b923697Zbigniew Jędrzejewski-Szmek assert_se(!condition_test(condition));
151226ab4bf276d60d51864330a99f886b923697Zbigniew Jędrzejewski-Szmek condition_free(condition);
151226ab4bf276d60d51864330a99f886b923697Zbigniew Jędrzejewski-Szmek
151226ab4bf276d60d51864330a99f886b923697Zbigniew Jędrzejewski-Szmek condition = condition_new(CONDITION_SECURITY, "selinux", false, true);
151226ab4bf276d60d51864330a99f886b923697Zbigniew Jędrzejewski-Szmek assert_se(condition_test(condition) != mac_selinux_use());
151226ab4bf276d60d51864330a99f886b923697Zbigniew Jędrzejewski-Szmek condition_free(condition);
151226ab4bf276d60d51864330a99f886b923697Zbigniew Jędrzejewski-Szmek
50f1e641a93cacfc693b0c3d300bee5df0c8c460Tom Gundersen condition = condition_new(CONDITION_SECURITY, "ima", false, false);
9ead3519c54b6d1b79b35541873b5cf7c8b3a7d3Lennart Poettering assert_se(condition_test(condition) == use_ima());
50f1e641a93cacfc693b0c3d300bee5df0c8c460Tom Gundersen condition_free(condition);
50f1e641a93cacfc693b0c3d300bee5df0c8c460Tom Gundersen
50f1e641a93cacfc693b0c3d300bee5df0c8c460Tom Gundersen condition = condition_new(CONDITION_SECURITY, "apparmor", false, false);
50f1e641a93cacfc693b0c3d300bee5df0c8c460Tom Gundersen assert_se(condition_test(condition) == mac_apparmor_use());
5d45a8808431987c370706d365fb0cc95cf03d52Tom Gundersen condition_free(condition);
5d45a8808431987c370706d365fb0cc95cf03d52Tom Gundersen
5d45a8808431987c370706d365fb0cc95cf03d52Tom Gundersen condition = condition_new(CONDITION_SECURITY, "smack", false, false);
5d45a8808431987c370706d365fb0cc95cf03d52Tom Gundersen assert_se(condition_test(condition) == mac_smack_use());
5d45a8808431987c370706d365fb0cc95cf03d52Tom Gundersen condition_free(condition);
5d45a8808431987c370706d365fb0cc95cf03d52Tom Gundersen
5d45a8808431987c370706d365fb0cc95cf03d52Tom Gundersen condition = condition_new(CONDITION_SECURITY, "audit", false, false);
5d45a8808431987c370706d365fb0cc95cf03d52Tom Gundersen assert_se(condition_test(condition) == use_audit());
5d45a8808431987c370706d365fb0cc95cf03d52Tom Gundersen condition_free(condition);
5d45a8808431987c370706d365fb0cc95cf03d52Tom Gundersen}
5d45a8808431987c370706d365fb0cc95cf03d52Tom Gundersen
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringint main(int argc, char *argv[]) {
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering log_parse_environment();
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering log_open();
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering test_condition_test_path();
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering test_condition_test_ac_power();
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering test_condition_test_host();
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering test_condition_test_architecture();
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering test_condition_test_kernel_command_line();
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering test_condition_test_null();
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering test_condition_test_security();
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering return 0;
36d9205d669bcdcb04fa730d1f3549a9fc9a9001Tom Gundersen}
801ad6a6a9cd8fbd58b9f9c27f20dbb3c87d47ddLennart Poettering