Remove unused functions 66/318866/3
authorKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Tue, 21 Jan 2025 13:59:57 +0000 (14:59 +0100)
committerKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Thu, 30 Jan 2025 10:45:33 +0000 (11:45 +0100)
Change-Id: Ia92180da601a967b12c4a3fe0856e4545c844d1e

src/common/fs_label_manager.cpp
src/common/fs_label_manager.h
src/security-manager-tests/common/sm_commons.cpp

index 79d9b21df74ff864c74ed6d99a3a6fceea853f99..9a4cda5f9762f0e798208cb6ae8de373ab47e028 100644 (file)
@@ -104,34 +104,6 @@ void FsLabelManager::testSmackSetLabel(const std::string &relativePath,
     checkLabel(path, label, labelType);
 }
 
-void FsLabelManager::testSmackLSetLabel(const std::string &relativePath,
-                                        const char *label,
-                                        enum smack_label_type labelType)
-{
-    std::string path = m_path + relativePath;
-
-    int ret = smack_lsetlabel(path.c_str(), label, labelType);
-    RUNNER_ASSERT_MSG(ret == 0, "Error in link setting label " << label);
-
-    checkLinkLabel(path, label, labelType);
-}
-
-void FsLabelManager::testSmackFSetLabel(const std::string &relativePath,
-                                        const char *label,
-                                        enum smack_label_type labelType)
-{
-    std::string path = m_path + relativePath;
-
-    int fd = open(path.c_str(), O_WRONLY);
-    RUNNER_ASSERT_ERRNO_MSG(fd > -1, "Unable to open file");
-
-    int ret = smack_fsetlabel(fd, label, labelType);
-    close(fd);
-    RUNNER_ASSERT_MSG(ret == 0, "Error in fd setting " << label);
-
-    checkLabel(path, label, labelType);
-}
-
 void FsLabelManager::testSmackGetLabel(const std::string &relativePath,
                                        const char *label,
                                        enum smack_label_type labelType)
@@ -154,53 +126,6 @@ void FsLabelManager::testSmackGetLabel(const std::string &relativePath,
     checkLabel(path, tmpLabel, labelType);
 }
 
-void FsLabelManager::testSmackLGetLabel(const std::string &relativePath,
-                                        const char *label,
-                                        enum smack_label_type labelType)
-{
-    std::string path = m_path + relativePath;
-
-    char *tmpLabel;
-    int ret = smack_lgetlabel(path.c_str(), &tmpLabel, labelType);
-    RUNNER_ASSERT_MSG(ret == 0, "Error in link getting label");
-    SmackLabelPtr labelPtr(tmpLabel);
-
-    if (label == nullptr && !m_label.compare(tmpLabel))
-        return;
-    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, "Wrong label. " << tmpLabel << " != " << label);
-
-    checkLinkLabel(path, tmpLabel, labelType);
-}
-
-void FsLabelManager::testSmackFGetLabel(const std::string &relativePath,
-                                        const char *label,
-                                        enum smack_label_type labelType)
-{
-    std::string path = m_path + relativePath;
-    int fd = open(path.c_str(), O_WRONLY);
-    RUNNER_ASSERT_ERRNO_MSG(fd > -1, "Unable to open file");
-
-    char *tmpLabel;
-    int ret = smack_fgetlabel(fd, &tmpLabel, labelType);
-    close(fd);
-    RUNNER_ASSERT_MSG(ret == 0, "Error in fd getting label");
-    SmackLabelPtr labelPtr(tmpLabel);
-
-    if (label == nullptr && !m_label.compare(tmpLabel))
-        return;
-    RUNNER_ASSERT_MSG(label != nullptr, "Fd should be related with file system default label. "
-                                        << tmpLabel << " != " << m_label);
-
-    ret = strcmp(tmpLabel, label);
-    RUNNER_ASSERT_MSG(ret == 0, "Wrong label. " << tmpLabel << " != " << label);
-
-    checkLabel(path, tmpLabel, labelType);
-}
-
 void FsLabelManager::testSmackClearLabels(const std::string &relativePath)
 {
     testSmackSetLabel(relativePath, nullptr, SMACK_LABEL_ACCESS);
index f45611f4452b47ca58bcafce895090dc4f8705c9..b97a71fac7f24d31c2e542edb3a0881f48af4ae3 100644 (file)
@@ -41,22 +41,10 @@ public:
     void testSmackSetLabel(const std::string &relativePath,
                            const char *label,
                            enum smack_label_type labelType);
-    void testSmackLSetLabel(const std::string &relativePath,
-                            const char *label,
-                            enum smack_label_type labelType);
-    void testSmackFSetLabel(const std::string &relativePath,
-                            const char *label,
-                            enum smack_label_type labelType);
 
     void testSmackGetLabel(const std::string &relativePath,
                            const char *label,
                            enum smack_label_type labelType);
-    void testSmackLGetLabel(const std::string &relativePath,
-                            const char *label,
-                            enum smack_label_type labelType);
-    void testSmackFGetLabel(const std::string &relativePath,
-                            const char *label,
-                            enum smack_label_type labelType);
 
     void testSmackClearLabels(const std::string &relativePath);
 
index be7edc58b75e57a03469813e4d5bfa68cdf49fee..1a636e4615ca0c279914122fa87195d49278db60 100644 (file)
@@ -108,36 +108,6 @@ static int nftw_check_sm_labels(const char *fpath, const struct stat *sb,
         nftw_expected_label.c_str(), nftw_expected_transmute, nftw_expected_exec);
 }
 
-int nftw_check_labels_non_app_dir(const char *fpath, const struct stat* /*sb*/,
-                                  int /*typeflag*/, struct FTW* /*ftwbuf*/)
-{
-    int result;
-    CStringPtr labelPtr;
-    char* label = nullptr;
-
-    /* ACCESS */
-    result = smack_lgetlabel(fpath, &label, SMACK_LABEL_ACCESS);
-    labelPtr.reset(label);
-    RUNNER_ASSERT_MSG(result == 0, "Could not get label for the path");
-    result = strcmp("canary_label", labelPtr.get());
-    RUNNER_ASSERT_MSG(result == 0, "ACCESS label on " << fpath << " is overwritten");
-
-    /* EXEC */
-    result = smack_lgetlabel(fpath, &label, SMACK_LABEL_EXEC);
-    labelPtr.reset(label);
-    RUNNER_ASSERT_MSG(result == 0, "Could not get label for the path");
-    result = strcmp("canary_label", labelPtr.get());
-    RUNNER_ASSERT_MSG(result == 0, "EXEC label on " << fpath << " is overwritten");
-
-    /* TRANSMUTE */
-    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() == nullptr, "TRANSMUTE label on " << fpath << " is set");
-
-    return 0;
-}
-
 int nftw_remove_labels(const char *fpath, const struct stat* /*sb*/,
                        int /*typeflag*/, struct FTW* /*ftwbuf*/)
 {