#include <dpl/log/log.h>
#include <dpl/exception.h>
+#include <smack-check.h>
#include <smack-labels.h>
#include <message-buffer.h>
#include <client-common.h>
static std::string g_app_label;
static std::atomic<int> g_threads_count;
static std::map<uid_t, std::string> g_tid_attr_current_map;
-static bool g_smack_fs_path;
+static bool g_smack_present;
static cap_t g_cap;
#define MAX_SIG_WAIT_TIME 1000
LogDebug("security_manager_set_process_label_from_appid() called");
- if (smack_smackfs_path() == NULL)
+ if (!smack_check())
return SECURITY_MANAGER_SUCCESS;
try {
return ret;
g_threads_count = 0;
g_tid_attr_current_map.clear();
- g_smack_fs_path = smack_smackfs_path() != NULL;
+ g_smack_present = smack_check();
g_cap = cap_init();
if (!g_cap) {
std::atomic_thread_fence(std::memory_order_acquire);
- if (g_smack_fs_path)
+ if (g_smack_present)
if(label_for_self_internal() != 0)
return;
return SECURITY_MANAGER_ERROR_UNKNOWN;
}
- if (g_smack_fs_path)
- if (smack_set_label_for_self(g_app_label.c_str()) != 0) {
- LogError("smack_set_label_for_self failed");
- cap_free(g_cap);
- return SECURITY_MANAGER_ERROR_UNKNOWN;
- }
+ if (g_smack_present && smack_set_label_for_self(g_app_label.c_str()) != 0) {
+ LogError("smack_set_label_for_self failed");
+ cap_free(g_cap);
+ return SECURITY_MANAGER_ERROR_UNKNOWN;
+ }
if (cap_set_proc(g_cap)) {
LogError("Can't drop main thread capabilities");
#include "smack-labels.h"
#include "tzplatform-config.h"
+#include "smack-check.h"
#include "smack-rules.h"
namespace SecurityManager {
}
}
- if (smack_smackfs_path() != NULL)
+ if (smack_check())
rules.apply();
rules.saveToFile(SMACK_RULES_SHARED_RO_PATH);
{
LogDebug("Revoking SharedRO rules for target pkg " << revokePkg);
- if (smack_smackfs_path() == NULL)
+ if (!smack_check())
return;
SmackRules rules;
SmackRules smackRules;
smackRules.addFromTemplateFile(templatePath, appProcessLabel, pkgName, authorId);
- if (smack_smackfs_path() != NULL)
+ if (smack_check())
smackRules.apply();
smackRules.saveToFile(outputPath);
smackRules.generatePackageCrossDeps(pkgLabels);
- if (smack_smackfs_path() != NULL)
+ if (smack_check())
smackRules.apply();
smackRules.saveToFile(getPackageRulesFilePath(pkgName));
try {
SmackRules rules;
rules.loadFromFile(path);
- if (smack_smackfs_path())
+ if (smack_check())
rules.clear();
} catch (const SmackException::Base &e) {
LogWarning("Failed to clear smack kernel rules from file: " << path);