GCC Code Coverage Report


Directory: cvmfs/
File: cvmfs/publish/repository_env.cc
Date: 2025-06-22 02:36:02
Exec Total Coverage
Lines: 0 13 0.0%
Branches: 0 24 0.0%

Line Branch Exec Source
1 /**
2 * This file is part of the CernVM File System.
3 */
4
5
6 #include <sys/capability.h>
7 #include <sys/prctl.h>
8 #include <unistd.h>
9
10 #include "publish/except.h"
11 #include "repository.h"
12 #include "util/posix.h"
13
14 namespace publish {
15
16 void Env::DropCapabilities() {
17 int retval;
18
19 // Because the process has file capabilities, its dumpable state is set to
20 // false, which in turn makes the /proc/self/... files owned by root. We
21 // need to reset this to have them owned by the effective UID in order to
22 // set, e.g., uid_map/gid_map of user namespaces.
23 retval = prctl(PR_SET_DUMPABLE, 1, 0, 0, 0);
24 if (retval != 0)
25 throw EPublish("cannot clear dumpable state");
26
27 cap_t caps = cap_get_proc();
28 retval = cap_clear(caps);
29 cap_free(caps);
30 if (retval != 0)
31 throw EPublish("cannot clear process capabilities");
32 }
33
34
35 std::string Env::GetEnterSessionDir() {
36 if (SymlinkExists("/.cvmfsenter"))
37 return ResolvePath("/.cvmfsenter");
38 return "";
39 }
40
41 } // namespace publish
42