| 1 | /* Entering namespaces for test case isolation. |
| 2 | Copyright (C) 2016-2017 Free Software Foundation, Inc. |
| 3 | This file is part of the GNU C Library. |
| 4 | |
| 5 | The GNU C Library is free software; you can redistribute it and/or |
| 6 | modify it under the terms of the GNU Lesser General Public |
| 7 | License as published by the Free Software Foundation; either |
| 8 | version 2.1 of the License, or (at your option) any later version. |
| 9 | |
| 10 | The GNU C Library is distributed in the hope that it will be useful, |
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | Lesser General Public License for more details. |
| 14 | |
| 15 | You should have received a copy of the GNU Lesser General Public |
| 16 | License along with the GNU C Library; if not, see |
| 17 | <http://www.gnu.org/licenses/>. */ |
| 18 | |
| 19 | #ifndef SUPPORT_NAMESPACE_H |
| 20 | #define SUPPORT_NAMESPACE_H |
| 21 | |
| 22 | #include <stdbool.h> |
| 23 | #include <sys/cdefs.h> |
| 24 | |
| 25 | __BEGIN_DECLS |
| 26 | |
| 27 | /* Attempts to become root (or acquire root-like privileges), possibly |
| 28 | with the help of user namespaces. Return true if (restricted) root |
| 29 | privileges could be attained in some way. Print diagnostics to |
| 30 | standard output. |
| 31 | |
| 32 | Note that this function generally has to be called before a process |
| 33 | becomes multi-threaded, otherwise it may fail with insufficient |
| 34 | privileges on systems which would support this operation for |
| 35 | single-threaded processes. */ |
| 36 | bool support_become_root (void); |
| 37 | |
| 38 | /* Enter a network namespace (and a UTS namespace if possible) and |
| 39 | configure the loopback interface. Return true if a network |
| 40 | namespace could be created. Print diagnostics to standard output. |
| 41 | If a network namespace could be created, but networking in it could |
| 42 | not be configured, terminate the process. It is recommended to |
| 43 | call support_become_root before this function so that the process |
| 44 | has sufficient privileges. */ |
| 45 | bool support_enter_network_namespace (void); |
| 46 | |
| 47 | /* Return true if support_enter_network_namespace managed to enter a |
| 48 | UTS namespace. */ |
| 49 | bool support_in_uts_namespace (void); |
| 50 | |
| 51 | __END_DECLS |
| 52 | |
| 53 | #endif |
| 54 | |