[Libreoffice-commits] online.git: loolwsd/Capabilities.hpp loolwsd/LOOLBroker.cpp loolwsd/Makefile.am

Tor Lillqvist tml at collabora.com
Mon Apr 4 07:06:14 UTC 2016


 loolwsd/Capabilities.hpp |   58 -----------------------------------------------
 loolwsd/LOOLBroker.cpp   |   39 ++++++++++++++++++++++++++++++-
 loolwsd/Makefile.am      |    1 
 3 files changed, 38 insertions(+), 60 deletions(-)

New commits:
commit d137653db59b72b209e35e4233ece81ad1f78c21
Author: Tor Lillqvist <tml at collabora.com>
Date:   Mon Apr 4 10:03:32 2016 +0300

    Avoid over-engineering: Insert Capabilities.hpp in the only file where used

diff --git a/loolwsd/Capabilities.hpp b/loolwsd/Capabilities.hpp
deleted file mode 100644
index 3137426..0000000
--- a/loolwsd/Capabilities.hpp
+++ /dev/null
@@ -1,58 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- */
-
-#ifndef INCLUDED_CAPABILITIES
-#define INCLUDED_CAPABILITIES
-
-#include <sys/capability.h>
-
-#include <cstdlib>
-
-#include "Util.hpp"
-
-static
-void dropCapability(cap_value_t capability)
-{
-    cap_t caps;
-    cap_value_t cap_list[] = { capability };
-
-    caps = cap_get_proc();
-    if (caps == nullptr)
-    {
-        Log::error("Error: cap_get_proc() failed.");
-        std::exit(1);
-    }
-
-    char *capText = cap_to_text(caps, nullptr);
-    Log::trace("Capabilities first: " + std::string(capText));
-    cap_free(capText);
-
-    if (cap_set_flag(caps, CAP_EFFECTIVE, sizeof(cap_list)/sizeof(cap_list[0]), cap_list, CAP_CLEAR) == -1 ||
-        cap_set_flag(caps, CAP_PERMITTED, sizeof(cap_list)/sizeof(cap_list[0]), cap_list, CAP_CLEAR) == -1)
-    {
-        Log::error("Error: cap_set_flag() failed.");
-        std::exit(1);
-    }
-
-    if (cap_set_proc(caps) == -1)
-    {
-        Log::error("Error: cap_set_proc() failed.");
-        std::exit(1);
-    }
-
-    capText = cap_to_text(caps, nullptr);
-    Log::trace("Capabilities now: " + std::string(capText));
-    cap_free(capText);
-
-    cap_free(caps);
-}
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/loolwsd/LOOLBroker.cpp b/loolwsd/LOOLBroker.cpp
index 2cc8c9f..430eccc 100644
--- a/loolwsd/LOOLBroker.cpp
+++ b/loolwsd/LOOLBroker.cpp
@@ -9,6 +9,7 @@
 
 #include <dlfcn.h>
 #include <ftw.h>
+#include <sys/capability.h>
 #include <sys/prctl.h>
 #include <sys/wait.h>
 #include <unistd.h>
@@ -40,7 +41,6 @@
 #include <Poco/Util/Application.h>
 #include <Poco/URI.h>
 
-#include "Capabilities.hpp"
 #include "ChildProcessSession.hpp"
 #include "Common.hpp"
 #include "IoUtil.hpp"
@@ -187,6 +187,43 @@ namespace
         if (nftw(source.c_str(), linkOrCopyFunction, 10, FTW_ACTIONRETVAL) == -1)
             Log::error("linkOrCopy: nftw() failed for '" + source + "'");
     }
+
+    void dropCapability(cap_value_t capability)
+    {
+        cap_t caps;
+        cap_value_t cap_list[] = { capability };
+
+        caps = cap_get_proc();
+        if (caps == nullptr)
+        {
+            Log::error("Error: cap_get_proc() failed.");
+            std::exit(1);
+        }
+
+        char *capText = cap_to_text(caps, nullptr);
+        Log::trace("Capabilities first: " + std::string(capText));
+        cap_free(capText);
+
+        if (cap_set_flag(caps, CAP_EFFECTIVE, sizeof(cap_list)/sizeof(cap_list[0]), cap_list, CAP_CLEAR) == -1 ||
+            cap_set_flag(caps, CAP_PERMITTED, sizeof(cap_list)/sizeof(cap_list[0]), cap_list, CAP_CLEAR) == -1)
+        {
+            Log::error("Error: cap_set_flag() failed.");
+            std::exit(1);
+        }
+
+        if (cap_set_proc(caps) == -1)
+        {
+            Log::error("Error: cap_set_proc() failed.");
+            std::exit(1);
+        }
+
+        capText = cap_to_text(caps, nullptr);
+        Log::trace("Capabilities now: " + std::string(capText));
+        cap_free(capText);
+
+        cap_free(caps);
+    }
+
 }
 
 class Connection: public Runnable
diff --git a/loolwsd/Makefile.am b/loolwsd/Makefile.am
index 4a0d753..c0bf767 100644
--- a/loolwsd/Makefile.am
+++ b/loolwsd/Makefile.am
@@ -57,7 +57,6 @@ loolmap_SOURCES = loolmap.c
 noinst_HEADERS = Admin.hpp \
                  AdminModel.hpp \
                  Auth.hpp \
-                 Capabilities.hpp \
                  ChildProcessSession.hpp \
                  Common.hpp \
                  DocumentBroker.hpp \


More information about the Libreoffice-commits mailing list