#include "db_sqlite.h"
Sqlite3DBase::Sqlite3DBase(const std::string& db_path, int flags)
- : m_db_handle(NULL), m_db_path(db_path), m_flags(flags)
+ : m_db_handle(nullptr), m_db_path(db_path), m_flags(flags)
{
}
sqlite3_close(m_db_handle);
}
-#define VFS_NOT_USED NULL
+#define VFS_NOT_USED nullptr
void Sqlite3DBase::open(void)
{
RUNNER_ASSERT_MSG(ret == SQLITE_OK, "Error closing the database: " <<
sqlite3_errmsg(m_db_handle));
- m_db_handle = NULL;
+ m_db_handle = nullptr;
}
bool Sqlite3DBase::is_open(void) const
void Sqlite3DBase::execute(const std::string& sql_query, Sqlite3DBaseSelectResult& result)
{
- char* tmp = NULL;
+ char* tmp = nullptr;
std::string errmsg;
int ret = sqlite3_exec(m_db_handle, sql_query.c_str(), callback, &result, &tmp);
* @var db_handle
* @brief Handle to sqlite3 database
*
- * NULL when database not opened.
+ * nullptr when database not opened.
*/
sqlite3* m_db_handle;
#include "dbus_access.h"
DBusAccess::DBusAccess(const char *service_name)
- : m_conn(NULL)
- , m_msg(NULL)
- , m_pending(NULL)
+ : m_conn(nullptr)
+ , m_msg(nullptr)
+ , m_pending(nullptr)
, m_handled(FALSE)
{
dbus_error_init(&m_err);
dbus_systemd_object.c_str(),
dbus_systemd_interface.c_str(),
method);
- RUNNER_ASSERT_MSG(NULL != m_msg,
+ RUNNER_ASSERT_MSG(nullptr != m_msg,
"Error in dbus_message_new_method_call");
}
RUNNER_ASSERT_MSG(ret == 1,
"Error in dbus_connection_send_with_reply");
- RUNNER_ASSERT_MSG(NULL != m_pending, "Pending call null");
+ RUNNER_ASSERT_MSG(nullptr != m_pending, "Pending call null");
dbus_connection_flush(m_conn);
dbus_pending_call_block(m_pending);
dbus_message_unref(m_msg);
- m_msg = NULL;
+ m_msg = nullptr;
}
void DBusAccess::getMsgReply() {
m_msg = dbus_pending_call_steal_reply(m_pending);
- RUNNER_ASSERT_MSG(NULL != m_msg,
+ RUNNER_ASSERT_MSG(nullptr != m_msg,
"Error in dbus_pending_call_steal_reply");
}
}
dbus_message_unref(m_msg);
dbus_pending_call_unref(m_pending);
- m_msg = NULL;
- m_pending = NULL;
+ m_msg = nullptr;
+ m_pending = nullptr;
}
void DBusAccess::connectToDBus() {
return XATTR_NAME_SMACKIPOUT;
default:
/* Should not reach this point */
- return NULL;
+ return nullptr;
}
}
}
RUNNER_ASSERT_MSG(ret == 0, "Error in normal getting label");
SmackLabelPtr labelPtr(tmpLabel);
- if (label == NULL && !m_label.compare(tmpLabel))
+ if (label == nullptr && !m_label.compare(tmpLabel))
return;
- RUNNER_ASSERT_MSG(label != NULL, "Path should be related with file system default label. "
+ RUNNER_ASSERT_MSG(label != nullptr, "Path should be related with file system default label. "
<< tmpLabel << " != " << m_label);
ret = strcmp(tmpLabel, label);
RUNNER_ASSERT_MSG(ret == 0, "Error in link getting label");
SmackLabelPtr labelPtr(tmpLabel);
- if (label == NULL && !m_label.compare(tmpLabel))
+ if (label == nullptr && !m_label.compare(tmpLabel))
return;
- RUNNER_ASSERT_MSG(label != NULL, "Path should be related with file system default label. "
+ RUNNER_ASSERT_MSG(label != nullptr, "Path should be related with file system default label. "
<< tmpLabel << " != " << m_label);
ret = strcmp(tmpLabel, label);
RUNNER_ASSERT_MSG(ret == 0, "Error in fd getting label");
SmackLabelPtr labelPtr(tmpLabel);
- if (label == NULL && !m_label.compare(tmpLabel))
+ if (label == nullptr && !m_label.compare(tmpLabel))
return;
- RUNNER_ASSERT_MSG(label != NULL, "Fd should be related with file system default label. "
+ RUNNER_ASSERT_MSG(label != nullptr, "Fd should be related with file system default label. "
<< tmpLabel << " != " << m_label);
ret = strcmp(tmpLabel, label);
void FsLabelManager::testSmackClearLabels(const std::string &relativePath)
{
- testSmackSetLabel(relativePath, NULL, SMACK_LABEL_ACCESS);
- testSmackGetLabel(relativePath, NULL, SMACK_LABEL_ACCESS);
- testSmackSetLabel(relativePath, NULL, SMACK_LABEL_EXEC);
- testSmackGetLabel(relativePath, NULL, SMACK_LABEL_EXEC);
+ testSmackSetLabel(relativePath, nullptr, SMACK_LABEL_ACCESS);
+ testSmackGetLabel(relativePath, nullptr, SMACK_LABEL_ACCESS);
+ testSmackSetLabel(relativePath, nullptr, SMACK_LABEL_EXEC);
+ testSmackGetLabel(relativePath, nullptr, SMACK_LABEL_EXEC);
}
void FsLabelManager::checkLabel(const std::string &path,
RUNNER_ASSERT_ERRNO_MSG(ret > 0, "Error in getting xattr");
const char *tmpLabel;
- if (label == NULL)
+ if (label == nullptr)
tmpLabel = m_label.c_str();
else
tmpLabel = label;
RUNNER_ASSERT_ERRNO_MSG(ret > 0, "Error in getting xattr");
const char *tmpLabel;
- if (label == NULL)
+ if (label == nullptr)
tmpLabel = m_label.c_str();
else
tmpLabel = label;
#include <smack_access.h>
SmackAccess::SmackAccess()
- : m_handle(NULL)
+ : m_handle(nullptr)
{
RUNNER_ASSERT_MSG(0 == smack_accesses_new(&m_handle),
"Error in smack_accesses_new");
{
// get group ID by group name
group *gr = getgrnam(group_name);
- RUNNER_ASSERT_ERRNO_MSG(gr != NULL, "getgrnam failed on '" << group_name << "' group");
+ RUNNER_ASSERT_ERRNO_MSG(gr != nullptr, "getgrnam failed on '" << group_name << "' group");
const gid_t new_group_id = gr->gr_gid;
// get number of groups that the current process belongs to
- int ngroups = getgroups(0, NULL);
+ int ngroups = getgroups(0, nullptr);
//allocate groups table + space for new group entry
std::vector<gid_t> groups(ngroups + 1);
{
// get group ID by group name
group *gr = getgrnam(group_name);
- RUNNER_ASSERT_ERRNO_MSG(gr != NULL, "getgrnam failed on '" << group_name << "' group");
+ RUNNER_ASSERT_ERRNO_MSG(gr != nullptr, "getgrnam failed on '" << group_name << "' group");
const gid_t new_group_id = gr->gr_gid;
- int ngroups = getgroups(0, NULL);
+ int ngroups = getgroups(0, nullptr);
std::vector<gid_t> groups(ngroups);
getgroups(ngroups, groups.data());
/**
* Read binary data from input
- * If no data is available method returns NULL buffer.
+ * If no data is available method returns nullptr buffer.
* In case connection was successfuly close, method returns empty buffer
*
* @param[in] size Maximum number of bytes to read from input
size_t bufferSize,
BufferDeleter deleter =
&BinaryQueue::BufferDeleterFree,
- void *userParam = NULL);
+ void *userParam = nullptr);
/**
* Append copy of other binary queue to the end of this binary queue
static void UnRef(Exception* e)
{
if (m_lastException == e) {
- m_lastException = NULL;
+ m_lastException = nullptr;
}
--m_exceptionCount;
if (!m_exceptionCount) {
std::set_terminate(m_terminateHandler);
- m_terminateHandler = NULL;
+ m_terminateHandler = nullptr;
}
}
static void TerminateHandler()
{
- if (m_lastException != NULL) {
+ if (m_lastException != nullptr) {
DisplayKnownException(*m_lastException);
abort();
} else {
Exception(const Exception &other)
{
// Deep copy
- if (other.m_reason != NULL) {
+ if (other.m_reason != nullptr) {
m_reason = new Exception(*other.m_reason);
} else {
- m_reason = NULL;
+ m_reason = nullptr;
}
m_message = other.m_message;
}
// Deep copy
- if (other.m_reason != NULL) {
+ if (other.m_reason != nullptr) {
m_reason = new Exception(*other.m_reason);
} else {
- m_reason = NULL;
+ m_reason = nullptr;
}
m_message = other.m_message;
const char *function,
int line,
const std::string &message) :
- m_reason(NULL),
+ m_reason(nullptr),
m_path(path),
m_function(function),
m_line(line),
virtual ~Exception() throw()
{
- if (m_reason != NULL) {
+ if (m_reason != nullptr) {
delete m_reason;
- m_reason = NULL;
+ m_reason = nullptr;
}
UnRef(this);
void Dump() const
{
// Show reason first
- if (m_reason != NULL) {
+ if (m_reason != nullptr) {
m_reason->Dump();
}
// Afterward, dump exception
const char *file = strchr(m_path.c_str(), '/');
- if (file == NULL) {
+ if (file == nullptr) {
file = m_path.c_str();
} else {
++file;
std::string DumpToString() const
{
std::string ret;
- if (m_reason != NULL) {
+ if (m_reason != nullptr) {
ret = m_reason->DumpToString();
}
const char *file = strchr(m_path.c_str(), '/');
- if (file == NULL) {
+ if (file == nullptr) {
file = m_path.c_str();
} else {
++file;
typedef FILE* Type;
static Type NullValue()
{
- return NULL;
+ return nullptr;
}
static void Destroy(Type file)
{
- if (file != NULL) {
+ if (file != nullptr) {
// Try to flush first
if (TEMP_FAILURE_RETRY(fflush(file)) != 0) {
std::string errString = strerror(errno);
typedef Class* Type;
static Type NullValue()
{
- return NULL;
+ return nullptr;
}
static void Destroy(Type ptr)
{
public:
TestRunner() :
- m_currentTestCase(NULL)
+ m_currentTestCase(nullptr)
, m_terminate(false)
, m_allowChildLogs(false)
{}
const char *AbstractLogProvider::LocateSourceFileName(const char *filename)
{
const char *ptr = strrchr(filename, '/');
- return ptr != NULL ? ptr + 1 : filename;
+ return ptr != nullptr ? ptr + 1 : filename;
}
}
}
// To speed things up, always copy as one bucket
void *bufferCopy = malloc(other.m_size);
- if (bufferCopy == NULL) {
+ if (bufferCopy == nullptr) {
throw std::bad_alloc();
}
try {
other.Flatten(bufferCopy, other.m_size);
- AppendUnmanaged(bufferCopy, other.m_size, &BufferDeleterFree, NULL);
+ AppendUnmanaged(bufferCopy, other.m_size, &BufferDeleterFree, nullptr);
} catch (const std::bad_alloc &) {
// Free allocated memory
free(bufferCopy);
void *bufferCopy = malloc(bufferSize);
// Check if allocation succeded
- if (bufferCopy == NULL) {
+ if (bufferCopy == nullptr) {
throw std::bad_alloc();
}
try {
// Try to append new bucket
- AppendUnmanaged(bufferCopy, bufferSize, &BufferDeleterFree, NULL);
+ AppendUnmanaged(bufferCopy, bufferSize, &BufferDeleterFree, nullptr);
} catch (const std::bad_alloc &) {
// Free allocated memory
free(bufferCopy);
deleter(dataDeleter),
param(userParam)
{
- Assert(data != NULL);
- Assert(deleter != NULL);
+ Assert(data != nullptr);
+ Assert(deleter != nullptr);
}
BinaryQueue::Bucket::~Bucket()
void BinaryQueue::VisitBuckets(BucketVisitor *visitor) const
{
- Assert(visitor != NULL);
+ Assert(visitor != nullptr);
// Visit all buckets
std::for_each(m_buckets.begin(), m_buckets.end(), BucketVisitorCall(visitor));
Flatten(bufferCopy.Get(), available);
result->AppendUnmanaged(
- bufferCopy.Get(), available, &BufferDeleterFree, NULL);
+ bufferCopy.Get(), available, &BufferDeleterFree, nullptr);
bufferCopy.Release();
Consume(available);
#include <cstdio>
namespace DPL {
-Exception* Exception::m_lastException = NULL;
+Exception* Exception::m_lastException = nullptr;
unsigned int Exception::m_exceptionCount = 0;
-void (*Exception::m_terminateHandler)() = NULL;
+void (*Exception::m_terminateHandler)() = nullptr;
void LogUnhandledException(const std::string &str)
{
result << std::endl;
size_t line_number = 1;
- while (fgets(read_buffer, sizeof(read_buffer) - 1, bt_fd) != NULL) {
+ while (fgets(read_buffer, sizeof(read_buffer) - 1, bt_fd) != nullptr) {
if (backtrace_parse_line(read_buffer, result, line_number))
++line_number;
}
if (dup2(pipe_fd[1], 1) == -1)
exit(2);
execlp("/usr/bin/gdb", "gdb", "--batch", "-n", "-ex", "thread", "-ex", "bt", "--pid",
- pid_buf.c_str(), NULL);
+ pid_buf.c_str(), nullptr);
// gdb failed to start...
exit(1);
}
}
LogSystem::LogSystem() :
- m_dlogProvider(NULL),
- m_oldStyleProvider(NULL),
+ m_dlogProvider(nullptr),
+ m_oldStyleProvider(nullptr),
m_isLoggingEnabled(!getenv(DPL_LOG_OFF))
{
bool oldStyleLogs = false;
// Check environment settings about pedantic logs
const char *value = getenv(OLD_STYLE_LOGS_ENV_NAME);
- if (value != NULL && !strcmp(value, "1")) {
+ if (value != nullptr && !strcmp(value, "1")) {
oldStyleLogs = true;
}
value = getenv(OLD_STYLE_PEDANTIC_LOGS_ENV_NAME);
- if (value != NULL && !strcmp(value, "1")) {
+ if (value != nullptr && !strcmp(value, "1")) {
oldStylePedanticLogs = true;
}
value = getenv(OLD_STYLE_LOGS_MASK_ENV_NAME);
- if (value != NULL) {
+ if (value != nullptr) {
size_t len = strlen(value);
if (len >= 1) {
m_providers.clear();
// And even default providers
- m_dlogProvider = NULL;
- m_oldStyleProvider = NULL;
+ m_dlogProvider = nullptr;
+ m_oldStyleProvider = nullptr;
}
void LogSystem::SetTag(const char* tag)
{
- if (m_dlogProvider != NULL) {
+ if (m_dlogProvider != nullptr) {
m_dlogProvider->SetTag(tag);
}
}
timeval tv;
tm localNowTime;
- gettimeofday(&tv, NULL);
+ gettimeofday(&tv, nullptr);
localtime_r(&tv.tv_sec, &localNowTime);
char format[64];
if (found != m_constructorsMap.end()) {
return found->second();
} else {
- return NULL;
+ return nullptr;
}
}
std::string BaseName(std::string aPath)
{
ScopedFree<char> path(strdup(aPath.c_str()));
- if (NULL == path.Get()) {
+ if (nullptr == path.Get()) {
throw std::bad_alloc();
}
char* baseName = basename(path.Get());
xmlDocPtr doc;
xmlXPathContextPtr xpathCtx;
- doc = xmlReadFile(file.c_str(), NULL, 0);
- if (doc == NULL) {
+ doc = xmlReadFile(file.c_str(), nullptr, 0);
+ if (doc == nullptr) {
ThrowMsg(XMLError, "File Problem");
} else {
//context
xpathCtx = xmlXPathNewContext(doc);
- if (xpathCtx == NULL) {
+ if (xpathCtx == nullptr) {
ThrowMsg(XMLError,
"Error: unable to create new XPath context\n");
}
xmlXPathObjectPtr xpathObject;
//get requested node's values
xpathObject = xmlXPathEvalExpression(BAD_CAST idPath.c_str(), xpathCtx);
- if (xpathObject == NULL)
+ if (xpathObject == nullptr)
{
ThrowMsg(XMLError, "XPath evaluation failure: " << idPath);
}
TestResultsCollectorBase::FailStatus::FAILED,
e.GetMessage());
- setCurrentTestCase(NULL);
+ setCurrentTestCase(nullptr);
return FAILED;
} catch (const Ignored &e) {
if (m_runIgnored) {
e.GetMessage());
}
- setCurrentTestCase(NULL);
+ setCurrentTestCase(nullptr);
return IGNORED;
} catch (const DPL::Exception &e) {
// DPL exception failure
TestResultsCollectorBase::FailStatus::INTERNAL,
"DPL exception:" + e.GetMessage());
- setCurrentTestCase(NULL);
+ setCurrentTestCase(nullptr);
return FAILED;
} catch (const std::exception &) {
// std exception failure
TestResultsCollectorBase::FailStatus::INTERNAL,
"std exception");
- setCurrentTestCase(NULL);
+ setCurrentTestCase(nullptr);
return FAILED;
} catch (...) {
// Unknown exception failure
TestResultsCollectorBase::FailStatus::INTERNAL,
"unknown exception");
- setCurrentTestCase(NULL);
+ setCurrentTestCase(nullptr);
return FAILED;
}
testCase.m_isPerformanceTest,
testCase.m_performanceTestDurationTime,
testCase.m_performanceMaxTime);
- setCurrentTestCase(NULL);
+ setCurrentTestCase(nullptr);
// Everything OK
return PASS;
PERMISSION_ENABLED);
int i;
- for (i = 0; perm_list[i] != NULL; ++i) {
+ for (i = 0; perm_list[i] != nullptr; ++i) {
// Ignore empty lines
if (strspn(perm_list[i], " \t\n") == strlen(perm_list[i]))
continue;
int base_name_from_perm(const char *perm, std::string& name)
{
iri_t *iris = iri_parse(perm);
- if (iris == NULL || iris->host == NULL)
+ if (iris == nullptr || iris->host == nullptr)
{
iri_destroy(iris);
return PC_ERR_INVALID_PARAM;
std::string path;
std::string::size_type pos;
- if (iris->path == NULL)
+ if (iris->path == nullptr)
{
path = iris->host;
}
const char *USER_APP_ID = "User";
-const char *PRIVS1[] = { "WRT", "test_privilege_control_rules1", NULL };
-const char *PRIVS2[] = { "test_privilege_control_rules2", NULL };
-const char *PRIVS2_NO_R[] = { "test_privilege_control_rules2_no_r", NULL };
-const char *PRIVS2_R[] = { "test_privilege_control_rules2_r", NULL };
-const char *PRIVS2_R_AND_NO_R[] = { "test_privilege_control_rules2_r", "test_privilege_control_rules2_no_r", NULL };
+const char *PRIVS1[] = { "WRT", "test_privilege_control_rules1", nullptr };
+const char *PRIVS2[] = { "test_privilege_control_rules2", nullptr };
+const char *PRIVS2_NO_R[] = { "test_privilege_control_rules2_no_r", nullptr };
+const char *PRIVS2_R[] = { "test_privilege_control_rules2_r", nullptr };
+const char *PRIVS2_R_AND_NO_R[] = { "test_privilege_control_rules2_r", "test_privilege_control_rules2_no_r", nullptr };
-const char *PRIVS_WGT[] = { "test_privilege_control_rules_wgt", NULL };
-const char *PRIVS_OSP[] = { "test_privilege_control_rules_osp", NULL };
-const char *PRIVS_EFL[] = { "test_privilege_control_rules_efl", NULL };
+const char *PRIVS_WGT[] = { "test_privilege_control_rules_wgt", nullptr };
+const char *PRIVS_OSP[] = { "test_privilege_control_rules_osp", nullptr };
+const char *PRIVS_EFL[] = { "test_privilege_control_rules_efl", nullptr };
-const char *PRIV_APPSETTING[] {"org.tizen.privilege.appsetting", NULL};
+const char *PRIV_APPSETTING[] {"org.tizen.privilege.appsetting", nullptr};
const char *PRIV_APPSETTING_RULES[] = { "~APP~ ~SETTINGS_PATH~ rwx",
"~APP~ ~ALL_APPS~ rx",
- NULL};
+ nullptr};
/**
* Check if every rule is true.
* @return 1 if ALL rules in SMACK, 0 if ANY rule isn't, -1 on failure
void read_gids(std::set<unsigned> &set, const char *file_path)
{
FILE *f = fopen(file_path, "r");
- RUNNER_ASSERT_ERRNO_MSG(f != NULL, "Unable to open file " << file_path);
+ RUNNER_ASSERT_ERRNO_MSG(f != nullptr, "Unable to open file " << file_path);
unsigned gid;
while (fscanf(f, "%u\n", &gid) == 1) {
set.insert(gid);
errno = 0;
struct passwd *pw = getpwuid(user_id);
- RUNNER_ASSERT_ERRNO_MSG(pw != NULL, "getpwuid() failed");
+ RUNNER_ASSERT_ERRNO_MSG(pw != nullptr, "getpwuid() failed");
int groups_cnt = 0;
- gid_t *groups_list = NULL;
+ gid_t *groups_list = nullptr;
ret = getgrouplist(pw->pw_name, pw->pw_gid, groups_list, &groups_cnt);
RUNNER_ASSERT_MSG(ret == -1, "getgrouplist() failed.");
if (groups_cnt == 0)
return;
groups_list = (gid_t*) calloc(groups_cnt, sizeof(gid_t));
- RUNNER_ASSERT_MSG(groups_list != NULL, "Memory allocation failed.");
+ RUNNER_ASSERT_MSG(groups_list != nullptr, "Memory allocation failed.");
ret = getgrouplist(pw->pw_name, pw->pw_gid, groups_list, &groups_cnt);
if (ret == -1) {
void read_current_gids(std::set<unsigned> &set)
{
- int groups_cnt = getgroups(0, NULL);
+ int groups_cnt = getgroups(0, nullptr);
RUNNER_ASSERT_ERRNO_MSG(groups_cnt > 0, "Wrong number of supplementary groups");
gid_t *groups_list = (gid_t*) calloc(groups_cnt, sizeof(gid_t));
- RUNNER_ASSERT_MSG(groups_list != NULL, "Memory allocation failed.");
+ RUNNER_ASSERT_MSG(groups_list != nullptr, "Memory allocation failed.");
if (getgroups(groups_cnt, groups_list) == -1){
free(groups_list);
RUNNER_FAIL_MSG("getgroups failed.");
{
std::set<unsigned> groups_check;
std::set<unsigned> groups_current;
- if(dac_file != NULL)
+ if(dac_file != nullptr)
read_gids(groups_check, dac_file);
read_current_gids(groups_current);
int nftw_remove_labels(const char *fpath, const struct stat* /*sb*/,
int /*typeflag*/, struct FTW* /*ftwbuf*/)
{
- smack_lsetlabel(fpath, NULL, SMACK_LABEL_ACCESS);
- smack_lsetlabel(fpath, NULL, SMACK_LABEL_EXEC);
- smack_lsetlabel(fpath, NULL, SMACK_LABEL_TRANSMUTE);
+ smack_lsetlabel(fpath, nullptr, SMACK_LABEL_ACCESS);
+ smack_lsetlabel(fpath, nullptr, SMACK_LABEL_EXEC);
+ smack_lsetlabel(fpath, nullptr, SMACK_LABEL_TRANSMUTE);
return 0;
}
{
int result;
CStringPtr labelPtr;
- char* label = NULL;
+ char* label = nullptr;
/* ACCESS */
result = smack_lgetlabel(fpath, &label, SMACK_LABEL_ACCESS);
RUNNER_ASSERT_MSG(result == 0, "Could not get label for the path");
labelPtr.reset(label);
- RUNNER_ASSERT_MSG(label != NULL, "ACCESS label on " << fpath << " is not set");
+ RUNNER_ASSERT_MSG(label != nullptr, "ACCESS label on " << fpath << " is not set");
result = strcmp(correctLabel, label);
RUNNER_ASSERT_MSG(result == 0, "ACCESS label on " << fpath << " is incorrect");
RUNNER_ASSERT_MSG(result == 0, "Could not get label for the path");
labelPtr.reset(label);
if (S_ISREG(sb->st_mode) && (sb->st_mode & S_IXUSR)) {
- RUNNER_ASSERT_MSG(label != NULL, "EXEC label on " << fpath << " is not set");
+ RUNNER_ASSERT_MSG(label != nullptr, "EXEC label on " << fpath << " is not set");
result = strcmp(correctLabel, label);
RUNNER_ASSERT_MSG(result == 0, "EXEC label on executable file " << fpath << " is incorrect");
} else
- RUNNER_ASSERT_MSG(label == NULL, "EXEC label on " << fpath << " is set");
+ RUNNER_ASSERT_MSG(label == nullptr, "EXEC label on " << fpath << " is set");
/* TRANSMUTE */
result = smack_lgetlabel(fpath, &label, SMACK_LABEL_TRANSMUTE);
RUNNER_ASSERT_MSG(result == 0, "Could not get label for the path");
labelPtr.reset(label);
- RUNNER_ASSERT_MSG(label == NULL, "TRANSMUTE label on " << fpath << " is set");
+ RUNNER_ASSERT_MSG(label == nullptr, "TRANSMUTE label on " << fpath << " is set");
return 0;
}
result = smack_lgetlabel(fpath, &label, SMACK_LABEL_ACCESS);
RUNNER_ASSERT_MSG(result == 0, "Could not get label for the path");
labelPtr.reset(label);
- RUNNER_ASSERT_MSG(label != NULL, "ACCESS label on " << fpath << " is not set");
+ RUNNER_ASSERT_MSG(label != nullptr, "ACCESS label on " << fpath << " is not set");
result = strcmp(LABEL_FOR_PUBLIC_SHARED_DIRS, label);
RUNNER_ASSERT_MSG(result == 0, "ACCESS label on " << fpath << " is incorrect");
result = smack_lgetlabel(fpath, &label, SMACK_LABEL_EXEC);
RUNNER_ASSERT_MSG(result == 0, "Could not get label for the path");
labelPtr.reset(label);
- RUNNER_ASSERT_MSG(label == NULL, "EXEC label on " << fpath << " is set");
+ RUNNER_ASSERT_MSG(label == nullptr, "EXEC label on " << fpath << " is set");
/* TRANSMUTE */
result = smack_lgetlabel(fpath, &label, SMACK_LABEL_TRANSMUTE);
RUNNER_ASSERT_MSG(result == 0, "Could not get label for the path");
labelPtr.reset(label);
if (S_ISDIR(sb->st_mode)) {
- RUNNER_ASSERT_MSG(label != NULL, "TRANSMUTE label on " << fpath << " is not set");
+ RUNNER_ASSERT_MSG(label != nullptr, "TRANSMUTE label on " << fpath << " is not set");
result = strcmp("TRUE", label);
RUNNER_ASSERT_MSG(result == 0, "TRANSMUTE label on " << fpath << " is not set");
} else
- RUNNER_ASSERT_MSG(label == NULL, "TRANSMUTE label on " << fpath << " is set");
+ RUNNER_ASSERT_MSG(label == nullptr, "TRANSMUTE label on " << fpath << " is set");
return 0;
}
{
smack_lsetlabel(fpath, CANARY_LABEL, SMACK_LABEL_ACCESS);
smack_lsetlabel(fpath, CANARY_LABEL, SMACK_LABEL_EXEC);
- smack_lsetlabel(fpath, NULL, SMACK_LABEL_TRANSMUTE);
+ smack_lsetlabel(fpath, nullptr, SMACK_LABEL_TRANSMUTE);
return 0;
}
{
int result;
CStringPtr labelPtr;
- char* label = NULL;
+ char* label = nullptr;
/* ACCESS */
result = smack_lgetlabel(fpath, &label, SMACK_LABEL_ACCESS);
result = smack_lgetlabel(fpath, &label, SMACK_LABEL_TRANSMUTE);
labelPtr.reset(label);
RUNNER_ASSERT_MSG(result == 0, "Could not get label for the path");
- RUNNER_ASSERT_MSG(labelPtr.get() == NULL, "TRANSMUTE label on " << fpath << " is set");
+ RUNNER_ASSERT_MSG(labelPtr.get() == nullptr, "TRANSMUTE label on " << fpath << " is set");
return 0;
}
result = smack_new_label_from_self(&label);
RUNNER_ASSERT_MSG(result >= 0,
" Error getting current process label");
- RUNNER_ASSERT_MSG(label != NULL,
+ RUNNER_ASSERT_MSG(label != nullptr,
" Process label is not set");
result = strcmp(USER_APP_ID, label);
DB_BEGIN
// argument validation
- result = perm_add_api_feature(APP_TYPE_OSP, NULL, NULL, NULL, 0);
+ result = perm_add_api_feature(APP_TYPE_OSP, nullptr, nullptr, nullptr, 0);
RUNNER_ASSERT(result == PC_ERR_INVALID_PARAM);
- result = perm_add_api_feature(APP_TYPE_OSP,"", NULL, NULL, 0);
+ result = perm_add_api_feature(APP_TYPE_OSP,"", nullptr, nullptr, 0);
RUNNER_ASSERT(result == PC_ERR_INVALID_PARAM);
// Already existing feature:
// TODO: Database will be malformed. (Rules for these features will be removed.)
- result = perm_add_api_feature(APP_TYPE_OSP,"http://tizen.org/privilege/messaging.read", NULL, NULL, 0);
+ result = perm_add_api_feature(APP_TYPE_OSP,"http://tizen.org/privilege/messaging.read", nullptr, nullptr, 0);
RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "perm_add_api_feature returned: " << result);
- result = perm_add_api_feature(APP_TYPE_WGT,"http://tizen.org/privilege/messaging.sms", NULL, NULL, 0);
+ result = perm_add_api_feature(APP_TYPE_WGT,"http://tizen.org/privilege/messaging.sms", nullptr, nullptr, 0);
RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "perm_add_api_feature returned: " << result);
// empty features
- result = perm_add_api_feature(APP_TYPE_OSP,"blahblah", NULL, NULL, 0);
+ result = perm_add_api_feature(APP_TYPE_OSP,"blahblah", nullptr, nullptr, 0);
RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "perm_add_api_feature returned: " << result);
- result = perm_add_api_feature(APP_TYPE_WGT,"blahblah", NULL, NULL, 0);
+ result = perm_add_api_feature(APP_TYPE_WGT,"blahblah", nullptr, nullptr, 0);
RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "perm_add_api_feature returned: " << result);
// empty rules
- const char *test1[] = { NULL };
- result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[0].c_str(), test1, NULL, 0);
+ const char *test1[] = { nullptr };
+ result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[0].c_str(), test1, nullptr, 0);
RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "perm_add_api_feature returned: " << result);
- const char *test2[] = { "", NULL };
- result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[1].c_str(), test2, NULL, 0);
+ const char *test2[] = { "", nullptr };
+ result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[1].c_str(), test2, nullptr, 0);
RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "perm_add_api_feature returned: " << result);
- const char *test3[] = { " \t\n", "\t \n", "\n\t ", NULL };
- result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[2].c_str(), test3, NULL, 0);
+ const char *test3[] = { " \t\n", "\t \n", "\n\t ", nullptr };
+ result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[2].c_str(), test3, nullptr, 0);
RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "perm_add_api_feature returned: " << result);
// malformed rules
- const char *test4[] = { "malformed", NULL };
- result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[3].c_str(), test4, NULL, 0);
+ const char *test4[] = { "malformed", nullptr };
+ result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[3].c_str(), test4, nullptr, 0);
RUNNER_ASSERT_MSG(result == PC_ERR_INVALID_PARAM, "perm_add_api_feature returned: " << result);
- const char *test5[] = { "malformed malformed", NULL };
- result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[4].c_str(), test5, NULL, 0);
+ const char *test5[] = { "malformed malformed", nullptr };
+ result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[4].c_str(), test5, nullptr, 0);
RUNNER_ASSERT_MSG(result == PC_ERR_INVALID_PARAM, "perm_add_api_feature returned: " << result);
- const char *test6[] = { "-malformed malformed rwxat", NULL };
- result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[5].c_str(), test6, NULL, 0);
+ const char *test6[] = { "-malformed malformed rwxat", nullptr };
+ result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[5].c_str(), test6, nullptr, 0);
RUNNER_ASSERT_MSG(result == PC_ERR_INVALID_PARAM, "perm_add_api_feature returned: " << result);
- const char *test7[] = { "~/\"\\ malformed rwxat", NULL };
- result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[6].c_str(), test7, NULL, 0);
+ const char *test7[] = { "~/\"\\ malformed rwxat", nullptr };
+ result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[6].c_str(), test7, nullptr, 0);
RUNNER_ASSERT_MSG(result == PC_ERR_INVALID_PARAM, "perm_add_api_feature returned: " << result);
- const char *test8[] = { "subject object rwxat something else", NULL };
- result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[7].c_str(), test8, NULL, 0);
+ const char *test8[] = { "subject object rwxat something else", nullptr };
+ result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[7].c_str(), test8, nullptr, 0);
RUNNER_ASSERT_MSG(result == PC_ERR_INVALID_PARAM, "perm_add_api_feature returned: " << result);
" \t \n",
"subject2\t~APP~ ltxarw",
"",
- NULL};
+ nullptr};
- result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[8].c_str(), test9, NULL, 0);
+ result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[8].c_str(), test9, nullptr, 0);
RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "perm_add_api_feature returned: " << result);
- const char *test10[] = { "Sub::jE,ct ~APP~ a-rwxl", NULL };
- result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[9].c_str(), test10, NULL, 0);
+ const char *test10[] = { "Sub::jE,ct ~APP~ a-rwxl", nullptr };
+ result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[9].c_str(), test10, nullptr, 0);
RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "perm_add_api_feature returned: " << result);
- const char *test11[] = { "Sub::sjE,ct ~APP~ a-RwXL", NULL }; // TODO This fails.
- result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[10].c_str(), test11, NULL, 0);
+ const char *test11[] = { "Sub::sjE,ct ~APP~ a-RwXL", nullptr }; // TODO This fails.
+ result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[10].c_str(), test11, nullptr, 0);
RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "perm_add_api_feature returned: " << result);
" \t \n",
"subject2 ~APP~ ltxarw",
"",
- NULL};
- result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[11].c_str(), test12, NULL, 0);
+ nullptr};
+ result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[11].c_str(), test12, nullptr, 0);
RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "perm_add_api_feature returned: " << result);
// empty group ids
- const char *test13[] = { "~APP~ b a", NULL};
+ const char *test13[] = { "~APP~ b a", nullptr};
result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[12].c_str(), test13,(const gid_t[]) {0,1,2},0);
RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "perm_add_api_feature returned: " << result);
result = file_exists(OSP_BLAHBLAH_DAC[12].c_str());
RUNNER_TEST_SMACK(privilege_control09_perm_add_api_feature_redefine)
{
int result;
- const char *permissionName[] = { "org.tizen.test.permtoberedefined", NULL};
+ const char *permissionName[] = { "org.tizen.test.permtoberedefined", nullptr};
// Rules to be used with the first check
const rules_t test_rules1 = {
"~APP~ " PERM_TO_REDEFINE " rx",
PERM_TO_REDEFINE " ~APP~ rwx",
"~APP~ " PERM_SUB_TO_REDEFINE " rx",
- NULL
+ nullptr
};
// Rules that contain differences - to be used with the second definition (re-def)
"~APP~ " PERM_TO_REDEFINE " rwx",
PERM_TO_REDEFINE " ~APP~ rx",
"~APP~ " PERM_SUB_TO_REDEFINE " watl",
- NULL
+ nullptr
};
DB_BEGIN
RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS,
"perm_app_install failed: " << perm_strerror(result));
- result = perm_add_api_feature(APP_TYPE_OSP, permissionName[0], perm_rules1, NULL, 0);
+ result = perm_add_api_feature(APP_TYPE_OSP, permissionName[0], perm_rules1, nullptr, 0);
RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS,
"perm_add_api_feature failed: " << result);
DB_BEGIN
// Redefine the permission
- result = perm_add_api_feature(APP_TYPE_OSP, permissionName[0], perm_rules2, NULL, 0);
+ result = perm_add_api_feature(APP_TYPE_OSP, permissionName[0], perm_rules2, nullptr, 0);
RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS,
"perm_add_api_feature failed: " << result);
char *smack_label;
alarm(2);
- fd = accept(sock, NULL, NULL);
+ fd = accept(sock, nullptr, nullptr);
alarm(0);
if (fd < 0)
return;
smack_label1[result] = '\0';
smack_label2 = perm_app_id_from_socket(sock);
- RUNNER_ASSERT_MSG(smack_label2 != NULL, "perm_app_id_from_socket failed");
+ RUNNER_ASSERT_MSG(smack_label2 != nullptr, "perm_app_id_from_socket failed");
result = strcmp(smack_label1, smack_label2);
RUNNER_ASSERT_MSG(result == 0, "smack labels differ: '" << smack_label1
<< "' != '" << smack_label2 << "-" << random() << "'");
RUNNER_TEST(privilege_control21c_incorrect_params_perm_app_set_privilege)
{
- RUNNER_ASSERT_MSG(perm_app_set_privilege(NULL, NULL, APP_SET_PRIV_PATH) == PC_ERR_INVALID_PARAM,
- "perm_app_set_privilege didn't check if package name isn't NULL.");
+ RUNNER_ASSERT_MSG(perm_app_set_privilege(nullptr, nullptr, APP_SET_PRIV_PATH) == PC_ERR_INVALID_PARAM,
+ "perm_app_set_privilege didn't check if package name isn't nullptr.");
}
RUNNER_TEST(privilege_control21d_incorrect_params_perm_app_install)
{
- RUNNER_ASSERT_MSG(perm_app_install(NULL) == PC_ERR_INVALID_PARAM,
- "perm_app_install didn't check if pkg_id isn't NULL.");
+ RUNNER_ASSERT_MSG(perm_app_install(nullptr) == PC_ERR_INVALID_PARAM,
+ "perm_app_install didn't check if pkg_id isn't nullptr.");
RUNNER_ASSERT_MSG(perm_app_install("") == PC_ERR_INVALID_PARAM,
"perm_app_install didn't check if pkg_id isn't empty.");
}
RUNNER_TEST(privilege_control21e_incorrect_params_perm_app_uninstall)
{
- RUNNER_ASSERT_MSG(perm_app_uninstall(NULL) == PC_ERR_INVALID_PARAM,
- "perm_app_uninstall didn't check if pkg_id isn't NULL.");
+ RUNNER_ASSERT_MSG(perm_app_uninstall(nullptr) == PC_ERR_INVALID_PARAM,
+ "perm_app_uninstall didn't check if pkg_id isn't nullptr.");
RUNNER_ASSERT_MSG(perm_app_uninstall("") == PC_ERR_INVALID_PARAM,
"perm_app_uninstall didn't check if pkg_id isn't empty.");
}
RUNNER_TEST(privilege_control21f_incorrect_params_perm_app_enable_permissions)
{
- RUNNER_ASSERT_MSG(perm_app_enable_permissions(APP_ID, APP_TYPE_OTHER, NULL, 1) == PC_ERR_INVALID_PARAM,
- "perm_app_enable_permissions didn't check if perm_list isn't NULL.");
- RUNNER_ASSERT_MSG(perm_app_enable_permissions(NULL, APP_TYPE_OTHER, PRIVS2, 1) == PC_ERR_INVALID_PARAM,
- "perm_app_enable_permissions didn't check if pkg_id isn't NULL.");
+ RUNNER_ASSERT_MSG(perm_app_enable_permissions(APP_ID, APP_TYPE_OTHER, nullptr, 1) == PC_ERR_INVALID_PARAM,
+ "perm_app_enable_permissions didn't check if perm_list isn't nullptr.");
+ RUNNER_ASSERT_MSG(perm_app_enable_permissions(nullptr, APP_TYPE_OTHER, PRIVS2, 1) == PC_ERR_INVALID_PARAM,
+ "perm_app_enable_permissions didn't check if pkg_id isn't nullptr.");
RUNNER_ASSERT_MSG(perm_app_enable_permissions("", APP_TYPE_OTHER, PRIVS2, 1) == PC_ERR_INVALID_PARAM,
"perm_app_enable_permissions didn't check if pkg_id isn't empty.");
RUNNER_ASSERT_MSG(perm_app_enable_permissions("~APP~", APP_TYPE_OTHER, PRIVS2, 1) == PC_ERR_INVALID_PARAM,
RUNNER_TEST(privilege_control21g_incorrect_params_app_revoke_permissions)
{
- RUNNER_ASSERT_MSG(perm_app_revoke_permissions(NULL) == PC_ERR_INVALID_PARAM,
- "perm_app_revoke_permissions didn't check if pkg_id isn't NULL.");
+ RUNNER_ASSERT_MSG(perm_app_revoke_permissions(nullptr) == PC_ERR_INVALID_PARAM,
+ "perm_app_revoke_permissions didn't check if pkg_id isn't nullptr.");
RUNNER_ASSERT_MSG(perm_app_revoke_permissions("") == PC_ERR_INVALID_PARAM,
"perm_app_revoke_permissions didn't check if pkg_id isn't empty.");
RUNNER_ASSERT_MSG(perm_app_revoke_permissions("~APP~") == PC_ERR_INVALID_PARAM,
RUNNER_TEST(privilege_control21h_incorrect_params_app_reset_permissions)
{
- RUNNER_ASSERT_MSG(perm_app_reset_permissions(NULL) == PC_ERR_INVALID_PARAM,
- "perm_app_reset_permissions didn't check if pkg_id isn't NULL.");
+ RUNNER_ASSERT_MSG(perm_app_reset_permissions(nullptr) == PC_ERR_INVALID_PARAM,
+ "perm_app_reset_permissions didn't check if pkg_id isn't nullptr.");
RUNNER_ASSERT_MSG(perm_app_reset_permissions("") == PC_ERR_INVALID_PARAM,
"perm_app_reset_permissions didn't check if pkg_id isn't empty.");
RUNNER_ASSERT_MSG(perm_app_reset_permissions("~APP~") == PC_ERR_INVALID_PARAM,
RUNNER_TEST(privilege_control21i_incorrect_params_app_setup_path)
{
- RUNNER_ASSERT_MSG(perm_app_setup_path(APPID_DIR, NULL, APP_PATH_PRIVATE) == PC_ERR_INVALID_PARAM,
- "perm_app_setup_path didn't check if path isn't NULL.");
- RUNNER_ASSERT_MSG(perm_app_setup_path(NULL, TEST_APP_DIR, APP_PATH_PRIVATE) == PC_ERR_INVALID_PARAM,
- "perm_app_setup_path didn't check if pkg_id isn't NULL.");
+ RUNNER_ASSERT_MSG(perm_app_setup_path(APPID_DIR, nullptr, APP_PATH_PRIVATE) == PC_ERR_INVALID_PARAM,
+ "perm_app_setup_path didn't check if path isn't nullptr.");
+ RUNNER_ASSERT_MSG(perm_app_setup_path(nullptr, TEST_APP_DIR, APP_PATH_PRIVATE) == PC_ERR_INVALID_PARAM,
+ "perm_app_setup_path didn't check if pkg_id isn't nullptr.");
RUNNER_ASSERT_MSG(perm_app_setup_path("", TEST_APP_DIR, APP_PATH_PRIVATE) == PC_ERR_INVALID_PARAM,
"perm_app_setup_path didn't check if pkg_id isn't empty.");
RUNNER_ASSERT_MSG(perm_app_setup_path("~APP~", TEST_APP_DIR, APP_PATH_PRIVATE) == PC_ERR_INVALID_PARAM,
RUNNER_TEST(privilege_control21k_incorrect_params_add_api_feature)
{
- RUNNER_ASSERT_MSG(perm_add_api_feature(APP_TYPE_OSP, NULL, NULL, NULL, 0) == PC_ERR_INVALID_PARAM,
- "perm_add_api_feature didn't check if api_feature_name isn't NULL.");
- RUNNER_ASSERT_MSG(perm_add_api_feature(APP_TYPE_OSP, "", NULL, NULL, 0) == PC_ERR_INVALID_PARAM,
+ RUNNER_ASSERT_MSG(perm_add_api_feature(APP_TYPE_OSP, nullptr, nullptr, nullptr, 0) == PC_ERR_INVALID_PARAM,
+ "perm_add_api_feature didn't check if api_feature_name isn't nullptr.");
+ RUNNER_ASSERT_MSG(perm_add_api_feature(APP_TYPE_OSP, "", nullptr, nullptr, 0) == PC_ERR_INVALID_PARAM,
"perm_add_api_feature didn't check if api_feature_name isn't empty.");
}
RUNNER_TEST(privilege_control21l_incorrect_params_ignored_disable_permissions)
{
- RUNNER_ASSERT_MSG(perm_app_disable_permissions(APP_ID, APP_TYPE_OTHER, NULL) == PC_ERR_INVALID_PARAM,
- "perm_app_disable_permissions didn't check if perm_list isn't NULL.");
- RUNNER_ASSERT_MSG(perm_app_disable_permissions(NULL, APP_TYPE_OTHER, PRIVS2) == PC_ERR_INVALID_PARAM,
- "perm_app_disable_permissions didn't check if pkg_id isn't NULL.");
+ RUNNER_ASSERT_MSG(perm_app_disable_permissions(APP_ID, APP_TYPE_OTHER, nullptr) == PC_ERR_INVALID_PARAM,
+ "perm_app_disable_permissions didn't check if perm_list isn't nullptr.");
+ RUNNER_ASSERT_MSG(perm_app_disable_permissions(nullptr, APP_TYPE_OTHER, PRIVS2) == PC_ERR_INVALID_PARAM,
+ "perm_app_disable_permissions didn't check if pkg_id isn't nullptr.");
RUNNER_ASSERT_MSG(perm_app_disable_permissions("", APP_TYPE_OTHER, PRIVS2) == PC_ERR_INVALID_PARAM,
"perm_app_disable_permissions didn't check if pkg_id isn't empty.");
RUNNER_ASSERT_MSG(perm_app_disable_permissions("~APP~", APP_TYPE_OTHER, PRIVS2) == PC_ERR_INVALID_PARAM,
bool has_permission;
const char *app_label = "test_app_label";
- RUNNER_ASSERT_MSG(perm_app_has_permission(NULL, APP_TYPE_WGT,
+ RUNNER_ASSERT_MSG(perm_app_has_permission(nullptr, APP_TYPE_WGT,
PRIVS2[0], &has_permission) == PC_ERR_INVALID_PARAM,
- "perm_app_has_permission didn't check if pkg_id isn't NULL.");
+ "perm_app_has_permission didn't check if pkg_id isn't nullptr.");
RUNNER_ASSERT_MSG(perm_app_has_permission(app_label, APP_TYPE_OTHER,
PRIVS2[0], &has_permission) == PC_ERR_INVALID_PARAM,
"perm_app_has_permission should not accept app_type = OTHER.");
RUNNER_ASSERT_MSG(perm_app_has_permission(app_label, APP_TYPE_WGT,
- NULL, &has_permission) == PC_ERR_INVALID_PARAM,
- "perm_app_has_permission didn't check if permission_name isn't NULL.");
+ nullptr, &has_permission) == PC_ERR_INVALID_PARAM,
+ "perm_app_has_permission didn't check if permission_name isn't nullptr.");
RUNNER_ASSERT_MSG(perm_app_has_permission(app_label, APP_TYPE_WGT,
- PRIVS2[0], NULL) == PC_ERR_INVALID_PARAM,
- "perm_app_has_permission didn't check if has_permission isn't NULL.");
+ PRIVS2[0], nullptr) == PC_ERR_INVALID_PARAM,
+ "perm_app_has_permission didn't check if has_permission isn't nullptr.");
}
" Error in perm_app_set_privilege. Error: " << result);
//Even though app privileges are set, no smack label should be extracted.
- char* label = NULL;
+ char* label = nullptr;
result = smack_new_label_from_self(&label);
RUNNER_ASSERT_MSG(result == -1,
" new_label_from_self should return error (SMACK is off). Result: " << result);
- RUNNER_ASSERT_MSG(label == NULL,
+ RUNNER_ASSERT_MSG(label == nullptr,
" new_label_from_self shouldn't allocate memory for label.");
check_groups(groups_before, dac_file);
read_user_gids(groups_before, APP_UID);
//Set app privileges
- result = perm_app_set_privilege(APP_ID, NULL, APP_SET_PRIV_PATH);
+ result = perm_app_set_privilege(APP_ID, nullptr, APP_SET_PRIV_PATH);
RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS,
"Error in perm_app_set_privilege. Error: " << result);
//Even though app privileges are set, no smack label should be extracted.
- char* label = NULL;
+ char* label = nullptr;
result = smack_new_label_from_self(&label);
RUNNER_ASSERT_MSG(result == -1,
"new_label_from_self should return error (SMACK is off). Result: " << result);
- RUNNER_ASSERT_MSG(label == NULL, "new_label_from_self shouldn't allocate memory for label.");
+ RUNNER_ASSERT_MSG(label == nullptr, "new_label_from_self shouldn't allocate memory for label.");
//Check if DAC privileges really set
RUNNER_ASSERT_MSG(getuid() == APP_UID, "Wrong UID");
result = strcmp(getenv("USER"), APP_USER_NAME);
RUNNER_ASSERT_MSG(result == 0, "Wrong user USER NAME. Result: " << result);
- check_groups(groups_before, NULL);
+ check_groups(groups_before, nullptr);
}
/**
*
* This test works similarly to libsmack test smack09_new_label_from_socket. At first server and
* client are created then sockets are set up and perm_app_id_from_socket is used. On NOSMACK env
- * correct behavior for perm_app_id_from_socket would be returning NULL label.
+ * correct behavior for perm_app_id_from_socket would be returning nullptr label.
*/
RUNNER_MULTIPROCESS_TEST_NOSMACK(privilege_control15_app_id_from_socket_nosmack)
{
//Accept connection
alarm(2);
- fd = accept(sock, NULL, NULL);
+ fd = accept(sock, nullptr, nullptr);
alarm(0);
RUNNER_ASSERT_ERRNO_MSG(fd >= 0, "accept failed");
// Give server some time to setup listening socket
sleep(1);
int sock, result;
- char* smack_label = NULL;
+ char* smack_label = nullptr;
//Create socket
sock = socket(AF_UNIX, SOCK_STREAM, 0);
result = connect(sock, (struct sockaddr*) &sockaddr, sizeof(struct sockaddr_un));
RUNNER_ASSERT_ERRNO_MSG(result == 0, "connect failed");
- //Use perm_app_id_from_socket. Should fail and return NULL smack_label.
+ //Use perm_app_id_from_socket. Should fail and return nullptr smack_label.
smack_label = perm_app_id_from_socket(sock);
RUNNER_ASSERT_MSG(!smack_label, "perm_app_id_from_socket should fail.");
//cleanup
- RUNNER_ASSERT_MSG(smack_label == NULL, "perm_app_id_from_socket should fail.");
+ RUNNER_ASSERT_MSG(smack_label == nullptr, "perm_app_id_from_socket should fail.");
}
}
// OSP Api Feature Test data - gives rxl access to OSP app and rl access to WGT app also!
const char *test_osp_feature_rule_set[] = { "~APP~ " TEST_OSP_FEATURE_APP_ID " rxl",
"~APP~ " TEST_WGT_FEATURE_APP_ID " rl",
- NULL };
-const char *TEST_OSP_FEATURE_PRIVS[] = { TEST_OSP_FEATURE, NULL };
+ nullptr };
+const char *TEST_OSP_FEATURE_PRIVS[] = { TEST_OSP_FEATURE, nullptr };
// WGT Api Feature Test data - rwx access only to WGT app
const char *test_wgt_feature_rule_set[] = { "~APP~ " TEST_WGT_FEATURE_APP_ID " rwx",
- NULL };
-const char *TEST_WGT_FEATURE_PRIVS[] = { TEST_WGT_FEATURE, NULL };
+ nullptr };
+const char *TEST_WGT_FEATURE_PRIVS[] = { TEST_WGT_FEATURE, nullptr };
rules_t rules_to_test_any_access1 = {
{ TEST_OSP_FEATURE_APP_ID, APP_ID, "r" },
"Error in perm_app_install. Result: " << result);
// Register appsettings feature
- result = perm_add_api_feature(APP_TYPE_OSP, PRIV_APPSETTING[0], PRIV_APPSETTING_RULES, NULL, 0);
+ result = perm_add_api_feature(APP_TYPE_OSP, PRIV_APPSETTING[0], PRIV_APPSETTING_RULES, nullptr, 0);
RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS,
" Error while registering api feature. Result: " << result);
result = perm_app_install(TEST_OSP_FEATURE_APP_ID);
RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS,
"Error in perm_app_install. Result: " << result);
- const char *test1[] = { NULL };
+ const char *test1[] = { nullptr };
result = perm_app_enable_permissions(TEST_OSP_FEATURE_APP_ID,
APP_TYPE_OSP, test1, true);
RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS,
// Register two valid api features
result = perm_add_api_feature(APP_TYPE_OSP, TEST_OSP_FEATURE,
- test_osp_feature_rule_set, NULL, 0);
+ test_osp_feature_rule_set, nullptr, 0);
RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS,
"Error in perm_add_api_feature. Cannot add TEST_OSP_FEATURE: "
<< TEST_OSP_FEATURE << ". Result: " << result);
result = perm_add_api_feature(APP_TYPE_WGT, TEST_WGT_FEATURE,
- test_wgt_feature_rule_set, NULL, 0);
+ test_wgt_feature_rule_set, nullptr, 0);
RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS,
"Error in perm_add_api_feature. Cannot add TEST_WGT_FEATURE: "
<< TEST_WGT_FEATURE << ". Result: " << result);
"~APP~ " APP_ID "7 rxl",
"~APP~ " APP_ID "8 rwxal",
"~APP~ " APP_ID "9 rwxatl",
- NULL };
+ nullptr };
const char *test_wgt_feature_rule_set2[] = { "~APP~ " APP_ID "1 r",
"~APP~ " APP_ID "2 rxl",
"~APP~ " APP_ID "3 rwxal",
"~APP~ " APP_ID "4 rwxatl",
- NULL };
+ nullptr };
// generate app ids: test_APP0, test_APP1, test_APP2 etc.:
<< " Result: " << result);
// Register appsettings feature
- result = perm_add_api_feature(APP_TYPE_OSP, PRIV_APPSETTING[0], PRIV_APPSETTING_RULES, NULL, 0);
+ result = perm_add_api_feature(APP_TYPE_OSP, PRIV_APPSETTING[0], PRIV_APPSETTING_RULES, nullptr, 0);
RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS,
" Error while registering api feature. Result: " << result);
// Register two valid api features
result = perm_add_api_feature(APP_TYPE_OSP, TEST_OSP_FEATURE,
- test_osp_feature_rule_set2, NULL, 0);
+ test_osp_feature_rule_set2, nullptr, 0);
RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS,
"Error in perm_add_api_feature. Cannot add TEST_OSP_FEATURE: "
<< TEST_OSP_FEATURE << ". Result: " << result);
result = perm_add_api_feature(APP_TYPE_WGT, TEST_WGT_FEATURE,
- test_wgt_feature_rule_set2, NULL, 0);
+ test_wgt_feature_rule_set2, nullptr, 0);
RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS,
"Error in perm_add_api_feature. Cannot add TEST_WGT_FEATURE: "
<< TEST_WGT_FEATURE << ". Result: " << result);
clean_up();
- struct smack_accesses *rules = NULL;
+ struct smack_accesses *rules = nullptr;
RUNNER_ASSERT(smack_accesses_new(&rules) == 0);
SmackAccessesPtr rules_ptr(rules);
*/
RUNNER_TEST_SMACK(smack_accesses_add_modify_test_2){
int result;
- struct smack_accesses *rules = NULL;
+ struct smack_accesses *rules = nullptr;
RUNNER_ASSERT(smack_accesses_new(&rules) == 0);
SmackAccessesPtr rules_ptr(rules);
*/
RUNNER_TEST_SMACK(smack_accesses_add_modify_test_3){
int result;
- struct smack_accesses *rules = NULL;
+ struct smack_accesses *rules = nullptr;
RUNNER_ASSERT(smack_accesses_new(&rules) == 0);
SmackAccessesPtr rules_ptr(rules);
*/
RUNNER_TEST_SMACK(smack_accesses_add_modify_test_4){
int result;
- struct smack_accesses *rules = NULL;
+ struct smack_accesses *rules = nullptr;
RUNNER_ASSERT(smack_accesses_new(&rules) == 0);
SmackAccessesPtr rules_ptr(rules);
*/
RUNNER_TEST_SMACK(smack_accesses_add_modify_test_5){
int result;
- struct smack_accesses *rules = NULL;
+ struct smack_accesses *rules = nullptr;
RUNNER_ASSERT(smack_accesses_new(&rules) == 0);
SmackAccessesPtr rules_ptr(rules);
*/
RUNNER_TEST_SMACK(smack_accesses_add_modify_test_6){
int result;
- struct smack_accesses *rules = NULL;
+ struct smack_accesses *rules = nullptr;
RUNNER_ASSERT(smack_accesses_new(&rules) == 0);
SmackAccessesPtr rules_ptr(rules);
unsigned int i;
int result;
- struct smack_accesses *rules = NULL;
+ struct smack_accesses *rules = nullptr;
for (i = 0; i < accessesBasic.size(); ++i) {
RUNNER_ASSERT(smack_accesses_new(&rules) == 0);
unsigned int i;
int result;
- struct smack_accesses *rules = NULL;
+ struct smack_accesses *rules = nullptr;
for (i = 0; i < accessesBasic.size(); ++i) {
// Creating and adding rules with TEST_OBJECT and TEST_OBJECT_2
unsigned int i;
int result;
- struct smack_accesses *rules = NULL;
+ struct smack_accesses *rules = nullptr;
for (i = 0; i < accessesBasic.size(); ++i) {
// Creating and adding rules with TEST_OBJECT and TEST_OBJECT_2
* expect: Rules created and stored in file should be identical to predefined template.
*/
- struct smack_accesses *rules = NULL; //rules prepared in this test case
- struct smack_accesses *import_test = NULL; //rules imported from file
+ struct smack_accesses *rules = nullptr; //rules prepared in this test case
+ struct smack_accesses *import_test = nullptr; //rules imported from file
int result; //result of each operation to be tested by RUNNER_ASSERT
int fd, tmp, sample; //file descripptors for save / restore rules tests
//CAP_MAC_ADMIN needed for process to be able to change rules in kernel (apllying, removing)
- struct smack_accesses *rules = NULL; //rules prepared in this test case
+ struct smack_accesses *rules = nullptr; //rules prepared in this test case
int result; //for storing functions results
RUNNER_ASSERT(smack_accesses_new(&rules) == 0);
//In thist test case mixed string are used as rules applied to kernel, next they are
//readed and compared with correct form of rules
- struct smack_accesses *rules = NULL; //rules prepared in this test case
+ struct smack_accesses *rules = nullptr; //rules prepared in this test case
int result; //for storing functions results
int expected;
//In this test case process will manipulate it own label
- char *label = NULL;
+ char *label = nullptr;
int result;
int fd;
fs.testSmackGetLabel(linkPath, testLabelExec, SMACK_LABEL_EXEC);
// link labels should not be changed
- fs.testSmackLGetLabel(linkPath, NULL, SMACK_LABEL_ACCESS);
- fs.testSmackLGetLabel(linkPath, NULL, SMACK_LABEL_EXEC);
+ fs.testSmackLGetLabel(linkPath, nullptr, SMACK_LABEL_ACCESS);
+ fs.testSmackLGetLabel(linkPath, nullptr, SMACK_LABEL_EXEC);
}
RUNNER_TEST_SMACK(smack06_lsetlabel_lgetlabel_test_1)
unsigned int i;
int result;
- struct smack_accesses *rules = NULL;
+ struct smack_accesses *rules = nullptr;
for (i = 0; i < accessesBasic.size(); ++i)
{
int result;
int fd;
- struct smack_accesses *rules = NULL;
+ struct smack_accesses *rules = nullptr;
// Pre-cleanup
removeAccessesAll();
static void smack_set_another_label_for_self(void)
{
- static int number = time(NULL);
+ static int number = time(nullptr);
number++;
std::string smack_label("s" + std::to_string(number));
char *label;
alarm(2);
- fd = accept(sock, NULL, NULL);
+ fd = accept(sock, nullptr, nullptr);
alarm(0);
RUNNER_ASSERT_ERRNO(fd >= 0);
FdUniquePtr fd_ptr(&fd);
ret = smack_setlabel(filePath.c_str(), fileLabel.c_str(), SMACK_LABEL_ACCESS);
RUNNER_ASSERT_MSG(ret == 0, "Unable to set label for file: " << ret);
- char *label = NULL;
+ char *label = nullptr;
ret = smack_getlabel(filePath.c_str(), &label, SMACK_LABEL_ACCESS);
RUNNER_ASSERT_MSG(ret == 0, "Unable to get label from file");
std::string label_str(label ? label : "");
RUNNER_TEST_NOSMACK(smack02_aplying_rules_into_kernel_nosmack)
{
- smack_accesses *rules = NULL;
+ smack_accesses *rules = nullptr;
int result;
//init rules
int result;
int fd;
- smack_accesses* tmp = NULL;
+ smack_accesses* tmp = nullptr;
RUNNER_ASSERT(smack_accesses_new(&tmp) == 0);
SmackAccessesPtr rules(tmp);
*/
RUNNER_TEST_NOSMACK(smack04_self_label_nosmack)
{
- char* label = NULL;
+ char* label = nullptr;
int result;
int fd;
//smack_new_label_from_self should fail
result = smack_new_label_from_self(&label);
RUNNER_ASSERT_MSG(result == -1, "new_label_from_self should return error (SMACK is off).");
- RUNNER_ASSERT_MSG(label == NULL, "new_label_from_self shouldn't allocate memory to label.");
- //We don't need to remember about freeing label - smack_new_label_from_self must return NULL
+ RUNNER_ASSERT_MSG(label == nullptr, "new_label_from_self shouldn't allocate memory to label.");
+ //We don't need to remember about freeing label - smack_new_label_from_self must return nullptr
//label if it's working properly.
// /proc/self/attr/current shouldn't keep any rules inside
//getting previously set label should also fail
result = smack_new_label_from_self(&label);
RUNNER_ASSERT_MSG(result == -1, "new_label_from_self should return error (SMACK is off).");
- RUNNER_ASSERT_MSG(label == NULL, "new_label_from_self shouldn't allocate memory to label.");
+ RUNNER_ASSERT_MSG(label == nullptr, "new_label_from_self shouldn't allocate memory to label.");
// /proc/self/attr/current still shouldn't keep any rules inside
result = lseek(fd, 0, SEEK_SET); //going to the file beginning
RUNNER_TEST_NOSMACK(smack05_accesses_add_modify_nosmack)
{
int result;
- smack_accesses* rules = NULL;
+ smack_accesses* rules = nullptr;
RUNNER_ASSERT(smack_accesses_new(&rules) == 0);
//Accept client
alarm(2);
- fd = accept(sock, NULL, NULL);
+ fd = accept(sock, nullptr, nullptr);
alarm(0);
RUNNER_ASSERT_ERRNO_MSG(fd >= 0, "Failed when accepting connection from client");
FdUniquePtr fd_ptr(&fd);
if ( !S_ISLNK(sb->st_mode))
return false;
- target = realpath(fpath, NULL);
+ target = realpath(fpath, nullptr);
RUNNER_ASSERT_ERRNO_MSG(target != 0, "Could not obtain real path from link");
ret = stat(target, &buf);
{
int result;
CStringPtr labelPtr;
- char* label = NULL;
+ char* label = nullptr;
/* ACCESS */
result = smack_lgetlabel(fpath, &label, SMACK_LABEL_ACCESS);
RUNNER_ASSERT_MSG(result == 0, "Could not get label for the path");
labelPtr.reset(label);
- RUNNER_ASSERT_MSG(label != NULL, "ACCESS label on " << fpath << " is not set");
+ RUNNER_ASSERT_MSG(label != nullptr, "ACCESS label on " << fpath << " is not set");
result = strcmp(correctLabel, label);
RUNNER_ASSERT_MSG(result == 0, "ACCESS label on " << fpath << " is incorrect"
" (should be '" << correctLabel << "' and is '" << label << "')");
labelPtr.reset(label);
if (S_ISREG(sb->st_mode) && (sb->st_mode & S_IXUSR) && exec_test) {
- RUNNER_ASSERT_MSG(label != NULL, "EXEC label on " << fpath << " is not set");
+ RUNNER_ASSERT_MSG(label != nullptr, "EXEC label on " << fpath << " is not set");
result = strcmp(correctLabel, label);
RUNNER_ASSERT_MSG(result == 0, "Incorrect EXEC label on executable file " << fpath);
} else
- RUNNER_ASSERT_MSG(label == NULL, "EXEC label on " << fpath << " is set");
+ RUNNER_ASSERT_MSG(label == nullptr, "EXEC label on " << fpath << " is set");
/* LINK TO EXEC */
labelPtr.reset(label);
if (S_ISDIR(sb->st_mode) && transmute_test == true) {
- RUNNER_ASSERT_MSG(label != NULL, "TRANSMUTE label on " << fpath << " is not set at all");
+ RUNNER_ASSERT_MSG(label != nullptr, "TRANSMUTE label on " << fpath << " is not set at all");
RUNNER_ASSERT_MSG(strcmp(label,"TRUE") == 0,
"TRANSMUTE label on " << fpath << " is not set properly: '"<<label<<"'");
} else {
- RUNNER_ASSERT_MSG(label == NULL, "TRANSMUTE label on " << fpath << " is set");
+ RUNNER_ASSERT_MSG(label == nullptr, "TRANSMUTE label on " << fpath << " is set");
}
return 0;
static app_inst_req* do_app_inst_req_new()
{
int result;
- app_inst_req *req = NULL;
+ app_inst_req *req = nullptr;
result = security_manager_app_inst_req_new(&req);
RUNNER_ASSERT_MSG((lib_retcode)result == SECURITY_MANAGER_SUCCESS,
"creation of new request failed. Result: " << result);
- RUNNER_ASSERT_MSG(req != NULL, "creation of new request did not allocate memory");
+ RUNNER_ASSERT_MSG(req != nullptr, "creation of new request did not allocate memory");
return req;
}
const char *const testBinaryPath = LABELLED_BINARY_PATH;
const char *const expectedLabel = USER_APP_ID;
int result;
- char *label = NULL;
+ char *label = nullptr;
CStringPtr labelPtr;
result = security_manager_set_process_label_from_binary(testBinaryPath);
result = smack_new_label_from_self(&label);
RUNNER_ASSERT_MSG(result >= 0,
" Error getting current process label");
- RUNNER_ASSERT_MSG(label != NULL,
+ RUNNER_ASSERT_MSG(label != nullptr,
" Process label is not set");
labelPtr.reset(label);
const char *const app_id = "sm_test_app_id_set_label_from_appid";
const char *const pkg_id = "sm_test_pkg_id_set_label_from_appid";
const char *const expected_label = USER_APP_ID;
- char *label = NULL;
+ char *label = nullptr;
CStringPtr labelPtr;
int result;
result = smack_new_label_from_self(&label);
RUNNER_ASSERT_MSG(result >= 0,
" Error getting current process label");
- RUNNER_ASSERT_MSG(label != NULL,
+ RUNNER_ASSERT_MSG(label != nullptr,
" Process label is not set");
labelPtr.reset(label);
*/
//---------------------------------------------------------------------------
-//passing NULL as a buffer pointer
+//passing nullptr as a buffer pointer
RUNNER_CHILD_TEST(tc_arguments_01_01_security_server_request_cookie)
{
- int ret = security_server_request_cookie(NULL, KNOWN_COOKIE_SIZE);
+ int ret = security_server_request_cookie(nullptr, KNOWN_COOKIE_SIZE);
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM,
"Error in security_server_request_cookie() argument checking: " << ret);
}
}
//---------------------------------------------------------------------------
-//passing NULL as a cookie pointer
+//passing nullptr as a cookie pointer
RUNNER_CHILD_TEST(tc_arguments_02_01_security_server_check_privilege)
{
- int ret = security_server_check_privilege(NULL, 0);
+ int ret = security_server_check_privilege(nullptr, 0);
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM,
"Error in security_server_check_privilege() argument checking: " << ret);
}
//---------------------------------------------------------------------------
-//passing NULL as a cookie pointer
+//passing nullptr as a cookie pointer
RUNNER_CHILD_TEST(tc_arguments_03_01_security_server_check_privilege_by_cookie)
{
RUNNER_IGNORED_MSG("security_server_check_privilege_by_cookie is temporarily disabled: always returns success");
- int ret = security_server_check_privilege_by_cookie(NULL, "wiadro", "rwx");
+ int ret = security_server_check_privilege_by_cookie(nullptr, "wiadro", "rwx");
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM,
"Error in security_server_check_privilege_by_cookie() argument checking: "
<< ret);
}
-//passing NULL as an object pointer
+//passing nullptr as an object pointer
RUNNER_CHILD_TEST(tc_arguments_03_02_security_server_check_privilege_by_cookie)
{
RUNNER_IGNORED_MSG("security_server_check_privilege_by_cookie is temporarily disabled: always returns success");
Cookie cookie = getCookieFromSS();
- int ret = security_server_check_privilege_by_cookie(cookie.data(), NULL, "rwx");
+ int ret = security_server_check_privilege_by_cookie(cookie.data(), nullptr, "rwx");
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM,
"Error in security_server_check_privilege_by_cookie() argument checking: "
<< ret);
}
-//passing NULL as an access pointer
+//passing nullptr as an access pointer
RUNNER_CHILD_TEST(tc_arguments_03_03_security_server_check_privilege_by_cookie)
{
RUNNER_IGNORED_MSG("security_server_check_privilege_by_cookie is temporarily disabled: always returns success");
Cookie cookie = getCookieFromSS();
- int ret = security_server_check_privilege_by_cookie(cookie.data(), "wiadro", NULL);
+ int ret = security_server_check_privilege_by_cookie(cookie.data(), "wiadro", nullptr);
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM,
"Error in security_server_check_privilege_by_cookie() argument checking: "
<< ret);
}
//---------------------------------------------------------------------------
-//passing NULL as a cookie pointer
+//passing nullptr as a cookie pointer
RUNNER_CHILD_TEST(tc_arguments_04_01_security_server_get_cookie_pid)
{
- int ret = security_server_get_cookie_pid(NULL);
+ int ret = security_server_get_cookie_pid(nullptr);
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM,
"Error in security_server_get_cookie_pid() argument checking: " << ret);
}
}
//---------------------------------------------------------------------------
-//passing NULL as a cookie pointer
+//passing nullptr as a cookie pointer
RUNNER_CHILD_TEST(tc_arguments_05_01_security_server_get_smacklabel_cookie)
{
- char *label = NULL;
- label = security_server_get_smacklabel_cookie(NULL);
- RUNNER_ASSERT_MSG(label == NULL,
+ char *label = nullptr;
+ label = security_server_get_smacklabel_cookie(nullptr);
+ RUNNER_ASSERT_MSG(label == nullptr,
"Error in security_server_get_smacklabel_cookie() argument checking");
}
Cookie cookie = getCookieFromSS();
char *receivedLabel = security_server_get_smacklabel_cookie(cookie.data());
- RUNNER_ASSERT_MSG(receivedLabel != NULL,
- "security_server_get_smacklabel_cookie returned NULL");
+ RUNNER_ASSERT_MSG(receivedLabel != nullptr,
+ "security_server_get_smacklabel_cookie returned nullptr");
std::string label(receivedLabel);
free(receivedLabel);
RUNNER_ASSERT_MSG(label.empty(),
provider.applyAndSwithToUser(APP_UID, APP_GID);
CStringPtr label(security_server_get_smacklabel_cookie(cookie.data()));
- RUNNER_ASSERT_MSG(label.get() == NULL,
- "NULL should be received due to access denied, received label: "
+ RUNNER_ASSERT_MSG(label.get() == nullptr,
+ "nullptr should be received due to access denied, received label: "
<< label.get());
}
RUNNER_ASSERT_MSG(ret == getpid(), "ret: " << ret);
CStringPtr ss_label(security_server_get_smacklabel_cookie(cookie.data()));
- RUNNER_ASSERT_MSG(ss_label.get() != NULL, "ss_label: " << ss_label.get());
+ RUNNER_ASSERT_MSG(ss_label.get() != nullptr, "ss_label: " << ss_label.get());
RUNNER_IGNORED_MSG("security_server_check_privilege_by_cookie is temporarily disabled: always returns success");
"ret: " << ret);
CStringPtr ss_label(security_server_get_smacklabel_cookie(cookie.data()));
- RUNNER_ASSERT_MSG(ss_label.get() == NULL,
- "access should be denied so label should be NULL: " << ss_label.get());
+ RUNNER_ASSERT_MSG(ss_label.get() == nullptr,
+ "access should be denied so label should be nullptr: " << ss_label.get());
RUNNER_IGNORED_MSG("security_server_check_privilege_by_sockfd is temporarily disabled: always returns success");
"get_cookie_pid returned different pid than it should. Result: " << ret);
CStringPtr ss_label(security_server_get_smacklabel_cookie(cookie.data()));
- RUNNER_ASSERT_MSG(ss_label.get() != NULL, "get_smacklabel_cookie failed.");
+ RUNNER_ASSERT_MSG(ss_label.get() != nullptr, "get_smacklabel_cookie failed.");
RUNNER_IGNORED_MSG("security_server_check_privilege_by_sockfd is temporarily disabled: always returns success");
timespec sleep_spec;
sleep_spec.tv_sec = 0;
sleep_spec.tv_nsec = nanoseconds;
- return nanosleep(&sleep_spec, NULL);
+ return nanosleep(&sleep_spec, nullptr);
}
/**Read from pipe descriptor to buffer; retries if less than count bytes were read.
*/
timeval my_gettime() {
timeval t;
- int res = gettimeofday(&t, NULL);
+ int res = gettimeofday(&t, nullptr);
RUNNER_ASSERT_ERRNO_MSG(res == 0, "gettimeofday() returned error value: " << res);
return t;
}
SockUniquePtr sockfd_ptr(&sockfd);
label = security_server_get_smacklabel_sockfd(sockfd);
- RUNNER_ASSERT_MSG(label != NULL, "security_server_get_smacklabel_sockfd failed");
+ RUNNER_ASSERT_MSG(label != nullptr, "security_server_get_smacklabel_sockfd failed");
RUNNER_ASSERT_MSG(strcmp(label,"") == 0, "label is \"" << label << "\"");
free(label);
RUNNER_ASSERT_ERRNO_MSG(listen(sockfd, 5) >= 0, "child listen failed");
label = security_server_get_smacklabel_sockfd(sockfd);
- RUNNER_ASSERT_MSG(label != NULL, "security_server_get_smacklabel_sockfd failed");
+ RUNNER_ASSERT_MSG(label != nullptr, "security_server_get_smacklabel_sockfd failed");
RUNNER_ASSERT_MSG(strcmp(label,"") == 0, "label is \"" << label << "\"");
free(label);
SockUniquePtr sockfd_ptr(&sockfd);
label = security_server_get_smacklabel_sockfd(sockfd);
- RUNNER_ASSERT_MSG(label != NULL, "security_server_get_smacklabel_sockfd failed");
+ RUNNER_ASSERT_MSG(label != nullptr, "security_server_get_smacklabel_sockfd failed");
RUNNER_ASSERT_MSG(strcmp(label,subject_label) == 0, "label is \"" << label << "\"" << ", subject_label is \"" << subject_label << "\"" );
free(label);
//check if get_smacklabel_sockfd works correctly
label = security_server_get_smacklabel_sockfd(sockfd);
- RUNNER_ASSERT_MSG(label != NULL, "security_server_get_smacklabel_sockfd failed");
+ RUNNER_ASSERT_MSG(label != nullptr, "security_server_get_smacklabel_sockfd failed");
ret = strcmp(label, "");
free(label);
RUNNER_ASSERT_MSG(ret == 0, "label is \"" << label << "\"");
SockUniquePtr sockfd_ptr(&sockfd);
label = security_server_get_smacklabel_sockfd(sockfd);
- RUNNER_ASSERT_MSG(label != NULL, "get_smacklabel_sockfd failed.");
+ RUNNER_ASSERT_MSG(label != nullptr, "get_smacklabel_sockfd failed.");
ret = strcmp(label, "");
free(label);
RUNNER_ASSERT_MSG(ret == 0, "label is \"" << label << "\"");
RUNNER_TEST_SMACK(tc18_security_server_get_smacklabel_cookie) {
int res;
- char *label_smack = NULL;
- char *label_ss = NULL;
- char *cookie = NULL;
+ char *label_smack = nullptr;
+ char *label_ss = nullptr;
+ char *cookie = nullptr;
int cookie_size = security_server_get_cookie_size();
RUNNER_ASSERT_MSG(PROPER_COOKIE_SIZE == cookie_size, "Wrong cookie size from security-server");
cookie = (char*) calloc(cookie_size, 1);
- RUNNER_ASSERT_MSG(NULL != cookie, "Memory allocation error");
+ RUNNER_ASSERT_MSG(nullptr != cookie, "Memory allocation error");
res = security_server_request_cookie(cookie, cookie_size);
if (res != SECURITY_SERVER_API_SUCCESS) {
label_ss = security_server_get_smacklabel_cookie(cookie);
free(cookie);
- RUNNER_ASSERT_MSG(label_ss != NULL, "Error in getting label by cookie");
+ RUNNER_ASSERT_MSG(label_ss != nullptr, "Error in getting label by cookie");
std::string label_cookie(label_ss);
* NOSMACK version of tc_security_server_get_smacklabel_cookie test.
*
* Most of this test goes exactly as the original one. The only difference are the labels:
- * - We assume that libsmack tests passed and smack_new_label_from_self will return -1 and NULL
+ * - We assume that libsmack tests passed and smack_new_label_from_self will return -1 and nullptr
* label - there is no need to re-check it.
* - Label acquired from security_server_get_smacklabel_cookie should be an empty string.
*/
RUNNER_TEST_NOSMACK(tc18_security_server_get_smacklabel_cookie_nosmack) {
int res;
- char* label_ss = NULL;
- char* cookie = NULL;
+ char* label_ss = nullptr;
+ char* cookie = nullptr;
int cookie_size = security_server_get_cookie_size();
RUNNER_ASSERT_MSG(PROPER_COOKIE_SIZE == cookie_size,
"Wrong cookie size from security-server. Size: " << cookie_size);
cookie = (char*) calloc(cookie_size, sizeof(char));
- RUNNER_ASSERT_MSG(NULL != cookie, "Memory allocation error");
+ RUNNER_ASSERT_MSG(nullptr != cookie, "Memory allocation error");
//Request cookie from SS
res = security_server_request_cookie(cookie, cookie_size);
CookieUniquePtr cookie_ptr(cookie);
- cookie = NULL;
+ cookie = nullptr;
RUNNER_ASSERT_MSG(res == SECURITY_SERVER_API_SUCCESS,
"Error in requesting cookie from security-server. Result: " << res);
label_ss = security_server_get_smacklabel_cookie(cookie_ptr.get());
- RUNNER_ASSERT_MSG(label_ss != NULL, "Error in getting label by cookie");
+ RUNNER_ASSERT_MSG(label_ss != nullptr, "Error in getting label by cookie");
std::string label(label_ss);
free(label_ss);
const char *subject_parent = "subject_parent";
const char *subject_child = "subject_child";
- DBusMessage* msg = NULL;
+ DBusMessage* msg = nullptr;
DBusMessageIter args, iter, var, var_iter, var_value;
- DBusConnection* conn = NULL;
+ DBusConnection* conn = nullptr;
DBusError err;
- DBusPendingCall *pending = NULL;
+ DBusPendingCall *pending = nullptr;
const char *dbus_server_name = DBUS_SERVER_NAME;
- char *smack_context = NULL;
+ char *smack_context = nullptr;
pid_t pid = fork();
RUNNER_ASSERT_ERRNO_MSG(-1 != pid, "fork() failed");
DBUS_SMACK_INTERFACE,
DBUS_SMACK_METHOD);
- RUNNER_ASSERT_MSG(NULL != msg,
+ RUNNER_ASSERT_MSG(nullptr != msg,
"dbus_message_new_method_call() failed, ret: " << ret);
// append arguments, we need SMACK context for our parent process "test.method.server"
// -1 is default timeout
ret = dbus_connection_send_with_reply (conn, msg, &pending, -1);
RUNNER_ASSERT_MSG(1 == ret, "Out of memory");
- RUNNER_ASSERT_MSG(NULL != pending, "Pending call null");
+ RUNNER_ASSERT_MSG(nullptr != pending, "Pending call null");
dbus_connection_flush(conn);
// get the reply
msg = dbus_pending_call_steal_reply(pending);
- RUNNER_ASSERT_MSG(NULL != msg, "Reply null");
+ RUNNER_ASSERT_MSG(nullptr != msg, "Reply null");
// free message handle
dbus_pending_call_unref(pending);
dbus_message_unref(msg);
dbus_connection_unref(conn);
- RUNNER_ASSERT(smack_context != NULL);
+ RUNNER_ASSERT(smack_context != nullptr);
ret = strcmp(smack_context, subject_parent);
RUNNER_ASSERT_MSG(0 == ret,
"Context mismatch! context from dbus: " << smack_context);
int ret = -1;
const char* subject_parent = "subject_parent";
- DBusMessage* msg = NULL;
+ DBusMessage* msg = nullptr;
DBusMessageIter args, iter, var, var_iter, var_value;
- DBusConnection* conn = NULL;
+ DBusConnection* conn = nullptr;
DBusError err;
- DBusPendingCall *pending = NULL;
+ DBusPendingCall *pending = nullptr;
const char *dbus_server_name = DBUS_SERVER_NAME;
- char *smack_context = NULL;
+ char *smack_context = nullptr;
pid_t pid = fork();
RUNNER_ASSERT_ERRNO_MSG(-1 != pid, "fork() failed");
DBUS_SMACK_INTERFACE,
DBUS_SMACK_METHOD);
- RUNNER_ASSERT_MSG(msg != NULL, "dbus_message_new_method_call() failed.");
+ RUNNER_ASSERT_MSG(msg != nullptr, "dbus_message_new_method_call() failed.");
// append arguments, we need SMACK context for our parent process "test.method.server"
dbus_message_iter_init_append(msg, &args);
// -1 is default timeout
ret = dbus_connection_send_with_reply (conn, msg, &pending, -1);
RUNNER_ASSERT_MSG(ret == 1, "Out of memory. Ret " << ret);
- RUNNER_ASSERT_MSG(pending != NULL, "Pending call is NULL.");
+ RUNNER_ASSERT_MSG(pending != nullptr, "Pending call is nullptr.");
dbus_connection_flush(conn);
// get the reply
msg = dbus_pending_call_steal_reply(pending);
- RUNNER_ASSERT_MSG(msg != NULL, "Failed to get the reply from bus.");
+ RUNNER_ASSERT_MSG(msg != nullptr, "Failed to get the reply from bus.");
// free message handle
dbus_pending_call_unref(pending);
dbus_message_unref(msg);
dbus_connection_unref(conn);
- RUNNER_ASSERT(smack_context != NULL);
+ RUNNER_ASSERT(smack_context != nullptr);
ret = strcmp(smack_context, subject_parent);
RUNNER_ASSERT_MSG(ret == 0, "Context mismatch. Context " << smack_context);
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_NO_PASSWORD, "ret = " << ret);
// WITH password
- ret = security_server_set_pwd(NULL, TEST_PASSWORD, 10, 10);
+ ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 10, 10);
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
ret = security_server_set_pwd_validity(10);
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_NO_PASSWORD, "ret = " << ret);
// WITH password
- ret = security_server_set_pwd(NULL, TEST_PASSWORD, 10, 10);
+ ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 10, 10);
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
ret = security_server_set_pwd_max_challenge(5);
int ret;
unsigned int attempt, max_attempt, expire_sec;
- ret = security_server_chk_pwd(NULL, &attempt, &max_attempt, &expire_sec);
+ ret = security_server_chk_pwd(nullptr, &attempt, &max_attempt, &expire_sec);
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret = " << ret);
- ret = security_server_chk_pwd("password", NULL, &max_attempt, &expire_sec);
+ ret = security_server_chk_pwd("password", nullptr, &max_attempt, &expire_sec);
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret = " << ret);
- ret = security_server_chk_pwd("password", &attempt, NULL, &expire_sec);
+ ret = security_server_chk_pwd("password", &attempt, nullptr, &expire_sec);
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret = " << ret);
- ret = security_server_chk_pwd("password", &attempt, &max_attempt, NULL);
+ ret = security_server_chk_pwd("password", &attempt, &max_attempt, nullptr);
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret = " << ret);
}
reset_security_server();
// TEST
- ret = security_server_set_pwd(NULL, NULL, 0, 0);
+ ret = security_server_set_pwd(nullptr, nullptr, 0, 0);
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret = " << ret);
}
reset_security_server();
// TEST
- ret = security_server_set_pwd(NULL, TEST_PASSWORD, 0, 0);
+ ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 0, 0);
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
}
int ret;
// Prepare environment
reset_security_server();
- ret = security_server_set_pwd(NULL, TEST_PASSWORD, 10, 10);
+ ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 10, 10);
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
// TEST
usleep(PASSWORD_RETRY_TIMEOUT_US);
// calculate max applicable valid days that will not be rejected by ss
// ensure, that after conversion from days to seconds in ss there will be no uint overflow
- unsigned int valid_days = ((UINT_MAX - time(NULL)) / 86400) - 1;
+ unsigned int valid_days = ((UINT_MAX - time(nullptr)) / 86400) - 1;
ret = security_server_set_pwd(TEST_PASSWORD, SECOND_TEST_PASSWORD, 0, valid_days);
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
}
int ret;
// Prepare environment
reset_security_server();
- ret = security_server_set_pwd(NULL, TEST_PASSWORD, 10, 10);
+ ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 10, 10);
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
// TEST
int ret;
// Prepare environment
reset_security_server();
- ret = security_server_set_pwd(NULL, TEST_PASSWORD, 10, 10);
+ ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 10, 10);
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
// TEST
int ret;
// Prepare environment
reset_security_server();
- ret = security_server_set_pwd(NULL, TEST_PASSWORD, 10, 10);
+ ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 10, 10);
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
// TEST
// Prepare environment
reset_security_server();
- ret = security_server_set_pwd(NULL, TEST_PASSWORD, 10, 10);
+ ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 10, 10);
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
// TEST
int ret;
// Prepare environment
reset_security_server();
- ret = security_server_set_pwd(NULL, TEST_PASSWORD, 10, 10);
+ ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 10, 10);
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
// TEST
// Prepare environment
reset_security_server();
- ret = security_server_set_pwd(NULL, TEST_PASSWORD, 10, 2);
+ ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 10, 2);
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
// TEST:
reset_security_server();
// calculate max applicable valid days that will not be rejected by ss
// ensure, that after conversion from days to seconds in ss there will be no uint overflow
- unsigned int valid_days = ((UINT_MAX - time(NULL)) / 86400) - 1;
- ret = security_server_set_pwd(NULL, TEST_PASSWORD, 10, valid_days);
+ unsigned int valid_days = ((UINT_MAX - time(nullptr)) / 86400) - 1;
+ ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 10, valid_days);
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
// TESTS
unsigned int attempt, max_attempt, expire_sec;
// Prepare environment
reset_security_server();
- ret = security_server_set_pwd(NULL, TEST_PASSWORD, 10, 10);
+ ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 10, 10);
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
ret = security_server_set_pwd_max_challenge(6);
// Prepare environment
reset_security_server();
- ret = security_server_set_pwd(NULL, TEST_PASSWORD, 10, 10);
+ ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 10, 10);
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
// TEST
// Prepare environment
reset_security_server();
- ret = security_server_set_pwd(NULL, TEST_PASSWORD, 10, 10);
+ ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 10, 10);
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
//TEST
// Prepare environment
reset_security_server();
- ret = security_server_set_pwd(NULL, TEST_PASSWORD, 10, 10);
+ ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 10, 10);
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
// TEST
// Prepare environment
reset_security_server();
- ret = security_server_set_pwd(NULL, TEST_PASSWORD, 10, 10);
+ ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 10, 10);
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
// TEST
// Prepare environment
reset_security_server();
- ret = security_server_set_pwd(NULL, TEST_PASSWORD, 10, 10);
+ ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 10, 10);
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
// TEST
// Prepare environment
reset_security_server();
- ret = security_server_set_pwd(NULL, TEST_PASSWORD, 10, 1);
+ ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 10, 1);
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
// TEST
// Prepare environment
reset_security_server();
- ret = security_server_set_pwd(NULL, TEST_PASSWORD, 5, 10);
+ ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 5, 10);
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
// TEST
unsigned int attempt, max_attempt, expire_sec;
// Prepare environment
reset_security_server();
- ret = security_server_set_pwd(NULL, TEST_PASSWORD, 5, 10);
+ ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 5, 10);
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
// TEST
// Prepare environment
reset_security_server();
- ret = security_server_set_pwd(NULL, TEST_PASSWORD, 5, 1);
+ ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 5, 1);
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
// TEST
// Prepare environment
reset_security_server();
- ret = security_server_set_pwd(NULL, TEST_PASSWORD, 5, 1);
+ ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 5, 1);
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
// TESTS
// Prepare environment
reset_security_server();
- ret = security_server_set_pwd(NULL, TEST_PASSWORD, 4, 1);
+ ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 4, 1);
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
// TEST
ret = security_server_chk_pwd(TEST_PASSWORD, &attempt, &max_attempt, &expire_sec);
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
- ret = gettimeofday(&cur_time, NULL);
+ ret = gettimeofday(&cur_time, nullptr);
RUNNER_ASSERT_ERRNO(ret != -1);
cur_time.tv_sec += (expire_sec + 1);
- ret = settimeofday(&cur_time, NULL);
+ ret = settimeofday(&cur_time, nullptr);
RUNNER_ASSERT_ERRNO(ret != -1);
usleep(PASSWORD_RETRY_TIMEOUT_US);
reset_security_server();
// TEST
- ret = security_server_reset_pwd(NULL, 10, 10);
+ ret = security_server_reset_pwd(nullptr, 10, 10);
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret = " << ret);
}
// Prepare environment
reset_security_server();
- int ret = security_server_set_pwd(NULL, TEST_PASSWORD, 0, 0);
+ int ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 0, 0);
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
// change max attempts number few times
// Prepare environment
reset_security_server();
- int ret = security_server_set_pwd(NULL, TEST_PASSWORD, max_challenge_more, 0);
+ int ret = security_server_set_pwd(nullptr, TEST_PASSWORD, max_challenge_more, 0);
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
// missed attempts
reset_security_server();
const unsigned int max_challenge = 2;
- int ret = security_server_set_pwd(NULL, TEST_PASSWORD, max_challenge, 0);
+ int ret = security_server_set_pwd(nullptr, TEST_PASSWORD, max_challenge, 0);
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
// 2x correct pwd - verify that 'cuurrent attempt' isn't increased
// Prepare environment
reset_security_server();
- int ret = security_server_set_pwd(NULL, TEST_PASSWORD, max_challenge, 0);
+ int ret = security_server_set_pwd(nullptr, TEST_PASSWORD, max_challenge, 0);
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
// missed attempts
reset_security_server();
//set a password
- int ret = security_server_set_pwd(NULL, TEST_PASSWORD, 0, 0);
+ int ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 0, 0);
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
- //try setting different password and giving NULL as current once again
+ //try setting different password and giving nullptr as current once again
usleep(PASSWORD_RETRY_TIMEOUT_US);
- ret = security_server_set_pwd(NULL, SECOND_TEST_PASSWORD, 0, 0);
+ ret = security_server_set_pwd(nullptr, SECOND_TEST_PASSWORD, 0, 0);
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_PASSWORD_EXIST, "ret = " << ret);
}
reset_security_server();
//set a password
- int ret = security_server_set_pwd(NULL, TEST_PASSWORD, 0, 0);
+ int ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 0, 0);
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
//do test
reset_security_server();
//set a password
- int ret = security_server_set_pwd(NULL, TEST_PASSWORD, 0, 0);
+ int ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 0, 0);
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
//do test
reset_security_server();
//set a password
- int ret = security_server_set_pwd(NULL, TEST_PASSWORD, 0, 0);
+ int ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 0, 0);
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
//do test
reset_security_server();
//set a password
- int ret = security_server_set_pwd(NULL, TEST_PASSWORD, 0, 0);
+ int ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 0, 0);
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
//do test
reset_security_server();
//set a password
- int ret = security_server_set_pwd(NULL, TEST_PASSWORD, 0, 0);
+ int ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 0, 0);
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
//do test
reset_security_server();
//set a password
- int ret = security_server_set_pwd(NULL, TEST_PASSWORD, 0, 0);
+ int ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 0, 0);
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
//do test
reset_security_server();
//set a password
- int ret = security_server_set_pwd(NULL, TEST_PASSWORD, 0, 0);
+ int ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 0, 0);
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
//do test
// Prepare environment
reset_security_server();
- ret = security_server_set_pwd(NULL, TEST_PASSWORD, 10, 10);
+ ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 10, 10);
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
usleep(PASSWORD_RETRY_TIMEOUT_US);
{
reset_security_server();
- int ret = security_server_set_pwd(NULL, TEST_PASSWORD, 0, 1);
+ int ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 0, 1);
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
unsigned int attempt, maxAttempt, validSec;
{
reset_security_server();
- int ret = security_server_set_pwd(NULL, TEST_PASSWORD, 0, 0);
+ int ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 0, 0);
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
unsigned int attempt, maxAttempt, validSec;
{
reset_security_server();
- int ret = security_server_set_pwd(NULL, TEST_PASSWORD, 0, 3);
+ int ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 0, 3);
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
unsigned int attempt, maxAttempt, validSec;
const char *SSTP_PERMS[] = {
"sstp_test_rules1",
"sstp_test_rules2",
- NULL
+ nullptr
};
const char *SSTP_PERMS1[] = {
SSTP_PERMS[0],
- NULL
+ nullptr
};
const char *SSTP_PERMS2[] = {
SSTP_PERMS[1],
- NULL
+ nullptr
};
void check_security_server_app_has_privilege(const char *app_label,
return;
}
- char *labelFromSelfTmp = NULL;
+ char *labelFromSelfTmp = nullptr;
ret = smack_new_label_from_self(&labelFromSelfTmp);
if (ret < 0) {
appendError("Error in smack_new_label_from_self(): " + std::to_string(ret));
int ret = smack_set_label_for_self(g_subject.data());
RUNNER_ASSERT_MSG(ret == 0, "Error in smack_set_label_for_self()");
- struct smack_accesses *rulesRaw = NULL;
+ struct smack_accesses *rulesRaw = nullptr;
ret = smack_accesses_new(&rulesRaw);
RUNNER_ASSERT_MSG(ret == 0, "Error in smack_accesses_new()");
SmackAccessesPtr rules(rulesRaw);
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_NO_PASSWORD, "ret: " << ret);
usleep(PASSWORD_RETRY_TIMEOUT_US);
- ret = security_server_set_pwd(NULL, "12345", 0, 0);
+ ret = security_server_set_pwd(nullptr, "12345", 0, 0);
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret: " << ret);
ret = security_server_reset_pwd("12345",0, 0);
"is_pwd_valid should return no password error. Result: " << ret);
usleep(PASSWORD_RETRY_TIMEOUT_US);
- ret = security_server_set_pwd(NULL, "12345", 0, 0);
+ ret = security_server_set_pwd(nullptr, "12345", 0, 0);
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS,
"set_pwd failed. Result: " << ret);
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_NO_SUCH_OBJECT, "ret: " << ret);
/* null param case */
- ret = security_server_get_gid(NULL);
+ ret = security_server_get_gid(nullptr);
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret: " << ret);
/* param too long case */
size_t cookie_size = security_server_get_cookie_size();
/* null cookie case */
- char *cookie = NULL;
+ char *cookie = nullptr;
ret = security_server_request_cookie(cookie, cookie_size);
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret: " << ret);
gid_t gid = DB_ALARM_GID;
/* null cookie case */
- char *cookie = NULL;
+ char *cookie = nullptr;
ret = security_server_check_privilege(cookie, gid);
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret: " << ret);
const char *access_rights = "r";
/* null cookie case */
- char *cookie = NULL;
+ char *cookie = nullptr;
ret = security_server_check_privilege_by_cookie(cookie, object, access_rights);
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret: " << ret);
/* null object case */
- char *object2 = NULL;
+ char *object2 = nullptr;
char cookie2[cookie_size];
ret = security_server_request_cookie(cookie2, cookie_size);
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret: " << ret);
/* null access rights case */
- access_rights = NULL;
+ access_rights = nullptr;
ret = security_server_check_privilege_by_cookie(cookie2, object, access_rights);
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret: " << ret);
}
sockfd = 0;
/* null object case */
- char *object2 = NULL;
+ char *object2 = nullptr;
ret = security_server_check_privilege_by_sockfd(sockfd, object2, access_rights);
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret: " << ret);
/* null access rights case */
- access_rights = NULL;
+ access_rights = nullptr;
ret = security_server_check_privilege_by_sockfd(sockfd, object, access_rights);
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret: " << ret);
}
RUNNER_TEST(tc07_security_server_get_cookie_pid_weird_input_case)
{
int ret = 0;
- char *cookie = NULL;
+ char *cookie = nullptr;
ret = security_server_get_cookie_pid(cookie);
RUNNER_ASSERT(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM);
sockfd = 0;
//null object case
- char *object2 = NULL;
+ char *object2 = nullptr;
ret = security_server_check_privilege_by_sockfd(sockfd, object2, access_rights);
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS,
"check_privilege_by_sockfd failed. Result: " << ret);
//null access rights case
- access_rights = NULL;
+ access_rights = nullptr;
ret = security_server_check_privilege_by_sockfd(sockfd, object, access_rights);
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS,
"check_privilege_by_sockfd failed. Result: " << ret);