From: Marcin Niesluchowski Date: Wed, 29 Oct 2014 10:44:56 +0000 (+0100) Subject: Fix smack_check() function X-Git-Tag: security-manager_5.5_testing~119^2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Ftest%2Fsecurity-tests.git;a=commitdiff_plain;h=16c20883780444ad820e3f24032f0c7db9079bf9 Fix smack_check() function Change-Id: I0ce0e769b7eb5b50dff34eea00db86c54a80eed9 --- diff --git a/src/common/tests_common.cpp b/src/common/tests_common.cpp index 6808b57..3095243 100644 --- a/src/common/tests_common.cpp +++ b/src/common/tests_common.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2013-2015 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,25 +35,15 @@ int DB::Transaction::db_result = PC_OPERATION_SUCCESS; const char *WGT_APP_ID = "QwCqJ0ttyS"; -int smack_runtime_check(void) -{ - static int smack_present = -1; - if (-1 == smack_present) { - if (smack_smackfs_path()) { - smack_present = 1; - } else { - smack_present = 0; - } - } - return smack_present; -} - -int smack_check(void) +bool smack_check(void) { #ifndef WRT_SMACK_ENABLED - return 0; + return false; #else - return smack_runtime_check(); + static int smack_present = -1; + if (-1 == smack_present) + smack_present = smack_smackfs_path() == nullptr ? 0 : 1; + return smack_present == 1; #endif } diff --git a/src/common/tests_common.h b/src/common/tests_common.h index c03d37a..2fb249b 100644 --- a/src/common/tests_common.h +++ b/src/common/tests_common.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2013-2015 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,8 +40,7 @@ const uid_t DB_ALARM_UID = 6001; const gid_t DB_ALARM_GID = 6001; const std::string TMP_DIR("/tmp"); -int smack_runtime_check(void); -int smack_check(void); +bool smack_check(void); int drop_root_privileges(uid_t appUid = APP_UID, gid_t appGid = APP_GID); void setLabelForSelf(const int line, const char *label); void add_process_group(const char* group_name);