diff options
author | 2018-07-02 14:20:38 +0200 | |
---|---|---|
committer | 2018-07-05 22:22:33 +0200 | |
commit | 57d293ab1fe34be609a4580539132bda44fa1352 (patch) | |
tree | 87726b477f4195181d424c744bd2372850777d4c | |
parent | 0c637845aa89238c6498ae466a0778a753a4bece (diff) | |
download | paludis-57d293ab1fe34be609a4580539132bda44fa1352.tar.gz paludis-57d293ab1fe34be609a4580539132bda44fa1352.tar.xz |
python: Implement and expose Environment::reduced_username
It was forgotten in 917cc160a which introduced this pure virtual
function in the `Environment` base class:
/var/tmp/paludis/build/sys-apps-paludis-scm/work/paludis-scm/python/environment.cc:48:7: note: because the following virtual functions are pure within 'EnvironmentImplementationWrapper':
class EnvironmentImplementationWrapper :
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /var/tmp/paludis/build/sys-apps-paludis-scm/work/paludis-scm/paludis/environment_implementation.hh:23:0,
from /var/tmp/paludis/build/sys-apps-paludis-scm/work/paludis-scm/paludis/environments/paludis/paludis_environment.hh:23,
from /var/tmp/paludis/build/sys-apps-paludis-scm/work/paludis-scm/python/environment.cc:24:
/var/tmp/paludis/build/sys-apps-paludis-scm/work/paludis-scm/paludis/environment.hh:427:33: note: virtual std::__cxx11::string paludis::Environment::reduced_username() const
virtual std::string reduced_username() const = 0;
^~~~~~~~~~~~~~~~
-rw-r--r-- | python/environment.cc | 20 | ||||
-rwxr-xr-x | python/environment_TEST.py | 1 |
2 files changed, 21 insertions, 0 deletions
diff --git a/python/environment.cc b/python/environment.cc index b0274b171..8fe93574e 100644 --- a/python/environment.cc +++ b/python/environment.cc @@ -167,6 +167,16 @@ class EnvironmentImplementationWrapper : throw PythonMethodNotImplemented("EnvironmentImplementation", "hook_dirs"); } + virtual std::string reduced_username() const + { + std::unique_lock<std::recursive_mutex> l(get_mutex()); + + if (bp::override f = get_override("reduced_username")) + return f(); + else + throw PythonMethodNotImplemented("EnvironmentImplementation", "reduced_username"); + } + virtual uid_t reduced_uid() const { std::unique_lock<std::recursive_mutex> l(get_mutex()); @@ -504,6 +514,11 @@ void expose_environment() "Return true if the first repository is more important than the second." ) + .def("reduced_username", &Environment::reduced_username, + "reduced_username() -> str\n" + "User name to use when reduced privs are permissible." + ) + .def("reduced_uid", &Environment::reduced_uid, "reduced_uid() -> int\n" "User id to use when reduced privs are permissible." @@ -583,6 +598,11 @@ void expose_environment() "Return directories to search for hooks." ) + .def("reduced_username", bp::pure_virtual(&EnvImp::reduced_username), + "reduced_username() -> str\n" + "User name to use when reduced privs are permissible." + ) + .def("reduced_uid", bp::pure_virtual(&EnvImp::reduced_uid), "reduced_uid() -> int\n" "User id to use when reduced privs are permissible." diff --git a/python/environment_TEST.py b/python/environment_TEST.py index bba853bc9..7f95edc76 100755 --- a/python/environment_TEST.py +++ b/python/environment_TEST.py @@ -58,6 +58,7 @@ class TestCase_01_Environments(unittest.TestCase): Filter.SupportsUninstallAction()) def test_25_reduced(self): + self.assert_(self.e.reduced_username() != "") self.assert_(self.e.reduced_uid() >= 0) self.assert_(self.e.reduced_gid() >= 0) |