CKM: Handle the empty onlycap case properly 84/208784/1
authorKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Fri, 28 Jun 2019 09:39:32 +0000 (11:39 +0200)
committerKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Fri, 28 Jun 2019 09:39:32 +0000 (11:39 +0200)
In case of empty onlycap the original process label was not restored
properly leading to failures in following tests.

Change-Id: I9e4cdce234b425887da07892773f21465087c4a6

src/common/scoped_process_label.cpp

index 47872bc..793a6ef 100644 (file)
@@ -122,7 +122,6 @@ ScopedProcessLabel::ScopedProcessLabel(std::string label, bool restore) :
                        newOnlycap.insert(m_label);
                        smackSetOnlycap(newOnlycap);
                } else {
-                       m_originalLabel.clear();
                        m_originalOnlycap.clear();
                }
        }
@@ -135,7 +134,8 @@ ScopedProcessLabel::~ScopedProcessLabel()
        if (!m_originalLabel.empty()) {
                try {
                        smackSetLabelForSelf(m_originalLabel);
-                       smackSetOnlycap(m_originalOnlycap);
+                       if (!m_originalOnlycap.empty())
+                               smackSetOnlycap(m_originalOnlycap);
                } catch (const DPL::Test::TestException& e) {
                        RUNNER_ERROR_MSG("Test exception occurred: " << e.GetMessage());
                } catch (const std::exception& e) {