diff options
author | Florian Weimer <fweimer@redhat.com> | 2016-12-31 18:51:07 +0100 |
---|---|---|
committer | Florian Weimer <fweimer@redhat.com> | 2016-12-31 18:51:07 +0100 |
commit | 5707a64d9462001f9c7c2e02d3f52cf8b0181658 (patch) | |
tree | 21d7c8e03848524dd858199032194665847ee7b5 /support/namespace.h | |
parent | a851999f61ad7ceabc2a945a3c31c60e8c914a4b (diff) | |
download | glibc-5707a64d9462001f9c7c2e02d3f52cf8b0181658.tar.gz glibc-5707a64d9462001f9c7c2e02d3f52cf8b0181658.tar.xz glibc-5707a64d9462001f9c7c2e02d3f52cf8b0181658.zip |
support: Helper functions for entering namespaces
Diffstat (limited to 'support/namespace.h')
-rw-r--r-- | support/namespace.h | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/support/namespace.h b/support/namespace.h new file mode 100644 index 0000000000..4692907676 --- /dev/null +++ b/support/namespace.h @@ -0,0 +1,53 @@ +/* Entering namespaces for test case isolation. + Copyright (C) 2016 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#ifndef SUPPORT_NAMESPACE_H +#define SUPPORT_NAMESPACE_H + +#include <stdbool.h> +#include <sys/cdefs.h> + +__BEGIN_DECLS + +/* Attempts to become root (or acquire root-like privileges), possibly + with the help of user namespaces. Return true if (restricted) root + privileges could be attained in some way. Print diagnostics to + standard output. + + Note that this function generally has to be called before a process + becomes multi-threaded, otherwise it may fail with insufficient + privileges on systems which would support this operation for + single-threaded processes. */ +bool support_become_root (void); + +/* Enter a network namespace (and a UTS namespace if possible) and + configure the loopback interface. Return true if a network + namespace could be created. Print diagnostics to standard output. + If a network namespace could be created, but networking in it could + not be configured, terminate the process. It is recommended to + call support_become_root before this function so that the process + has sufficient privileges. */ +bool support_enter_network_namespace (void); + +/* Return true if support_enter_network_namespace managed to enter a + UTS namespace. */ +bool support_in_uts_namespace (void); + +__END_DECLS + +#endif |