Remove unused bubblewrap source
This commit is contained in:
parent
908469846d
commit
4b63f8dca2
36 changed files with 2 additions and 6202 deletions
|
|
@ -76,9 +76,8 @@ will install the necessary bits into your system.
|
||||||
|
|
||||||
## Copyright and Licensing
|
## Copyright and Licensing
|
||||||
|
|
||||||
Anbox reuses code from other projects like the Android Qemu emulator
|
Anbox reuses code from other projects like the Android Qemu emulator.
|
||||||
or bubblewrap (https://github.com/projectatomic/bubblewrap). These
|
These projects are available in the external/ subdirectory with the
|
||||||
projects are available in the external/ subdirectory with the
|
|
||||||
licensing terms included.
|
licensing terms included.
|
||||||
|
|
||||||
The anbox source itself (in src/) is licensed under the terms of
|
The anbox source itself (in src/) is licensed under the terms of
|
||||||
|
|
|
||||||
1
external/CMakeLists.txt
vendored
1
external/CMakeLists.txt
vendored
|
|
@ -1,4 +1,3 @@
|
||||||
add_subdirectory(bubblewrap)
|
|
||||||
add_subdirectory(process-cpp-minimal)
|
add_subdirectory(process-cpp-minimal)
|
||||||
add_subdirectory(android-emugl)
|
add_subdirectory(android-emugl)
|
||||||
add_subdirectory(xdg)
|
add_subdirectory(xdg)
|
||||||
|
|
|
||||||
1
external/bubblewrap/.dir-locals.el
vendored
1
external/bubblewrap/.dir-locals.el
vendored
|
|
@ -1 +0,0 @@
|
||||||
((c-mode . ((indent-tabs-mode . nil) (c-file-style . "gnu"))))
|
|
||||||
6
external/bubblewrap/.editorconfig
vendored
6
external/bubblewrap/.editorconfig
vendored
|
|
@ -1,6 +0,0 @@
|
||||||
[*.[ch]]
|
|
||||||
indent_style = space
|
|
||||||
indent_size = 2
|
|
||||||
trim_trailing_whitespace = true
|
|
||||||
indent_brace_style = gnu
|
|
||||||
|
|
||||||
25
external/bubblewrap/.travis.yml
vendored
25
external/bubblewrap/.travis.yml
vendored
|
|
@ -1,25 +0,0 @@
|
||||||
language: c
|
|
||||||
dist: trusty
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
packages:
|
|
||||||
- automake
|
|
||||||
- autotools-dev
|
|
||||||
- libcap-dev
|
|
||||||
script:
|
|
||||||
- env NOCONFIGURE=1 ./autogen.sh
|
|
||||||
- mkdir build
|
|
||||||
- cd build && ../configure
|
|
||||||
- make -j 2
|
|
||||||
- make check
|
|
||||||
|
|
||||||
notifications:
|
|
||||||
# This is Colin's instance of Homu, in the future
|
|
||||||
# we'll move this to a production cluster.
|
|
||||||
webhooks: http://escher.verbum.org:54856/travis
|
|
||||||
email: false
|
|
||||||
|
|
||||||
branches:
|
|
||||||
only:
|
|
||||||
- auto
|
|
||||||
|
|
||||||
14
external/bubblewrap/CMakeLists.txt
vendored
14
external/bubblewrap/CMakeLists.txt
vendored
|
|
@ -1,14 +0,0 @@
|
||||||
# Don't treat any warnings as error as we take the source directly from
|
|
||||||
# upstream and just compile it.
|
|
||||||
set(CMAKE_C_FLAGS "-Wall")
|
|
||||||
|
|
||||||
set(SOURCES
|
|
||||||
bind-mount.c
|
|
||||||
bubblewrap.c
|
|
||||||
network.c
|
|
||||||
utils.c)
|
|
||||||
|
|
||||||
set(HEADERS
|
|
||||||
config.h)
|
|
||||||
|
|
||||||
add_library(bwrap ${SOURCES} ${HEADERS})
|
|
||||||
481
external/bubblewrap/COPYING
vendored
481
external/bubblewrap/COPYING
vendored
|
|
@ -1,481 +0,0 @@
|
||||||
GNU LIBRARY GENERAL PUBLIC LICENSE
|
|
||||||
Version 2, June 1991
|
|
||||||
|
|
||||||
Copyright (C) 1991 Free Software Foundation, Inc.
|
|
||||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
Everyone is permitted to copy and distribute verbatim copies
|
|
||||||
of this license document, but changing it is not allowed.
|
|
||||||
|
|
||||||
[This is the first released version of the library GPL. It is
|
|
||||||
numbered 2 because it goes with version 2 of the ordinary GPL.]
|
|
||||||
|
|
||||||
Preamble
|
|
||||||
|
|
||||||
The licenses for most software are designed to take away your
|
|
||||||
freedom to share and change it. By contrast, the GNU General Public
|
|
||||||
Licenses are intended to guarantee your freedom to share and change
|
|
||||||
free software--to make sure the software is free for all its users.
|
|
||||||
|
|
||||||
This license, the Library General Public License, applies to some
|
|
||||||
specially designated Free Software Foundation software, and to any
|
|
||||||
other libraries whose authors decide to use it. You can use it for
|
|
||||||
your libraries, too.
|
|
||||||
|
|
||||||
When we speak of free software, we are referring to freedom, not
|
|
||||||
price. Our General Public Licenses are designed to make sure that you
|
|
||||||
have the freedom to distribute copies of free software (and charge for
|
|
||||||
this service if you wish), that you receive source code or can get it
|
|
||||||
if you want it, that you can change the software or use pieces of it
|
|
||||||
in new free programs; and that you know you can do these things.
|
|
||||||
|
|
||||||
To protect your rights, we need to make restrictions that forbid
|
|
||||||
anyone to deny you these rights or to ask you to surrender the rights.
|
|
||||||
These restrictions translate to certain responsibilities for you if
|
|
||||||
you distribute copies of the library, or if you modify it.
|
|
||||||
|
|
||||||
For example, if you distribute copies of the library, whether gratis
|
|
||||||
or for a fee, you must give the recipients all the rights that we gave
|
|
||||||
you. You must make sure that they, too, receive or can get the source
|
|
||||||
code. If you link a program with the library, you must provide
|
|
||||||
complete object files to the recipients so that they can relink them
|
|
||||||
with the library, after making changes to the library and recompiling
|
|
||||||
it. And you must show them these terms so they know their rights.
|
|
||||||
|
|
||||||
Our method of protecting your rights has two steps: (1) copyright
|
|
||||||
the library, and (2) offer you this license which gives you legal
|
|
||||||
permission to copy, distribute and/or modify the library.
|
|
||||||
|
|
||||||
Also, for each distributor's protection, we want to make certain
|
|
||||||
that everyone understands that there is no warranty for this free
|
|
||||||
library. If the library is modified by someone else and passed on, we
|
|
||||||
want its recipients to know that what they have is not the original
|
|
||||||
version, so that any problems introduced by others will not reflect on
|
|
||||||
the original authors' reputations.
|
|
||||||
|
|
||||||
Finally, any free program is threatened constantly by software
|
|
||||||
patents. We wish to avoid the danger that companies distributing free
|
|
||||||
software will individually obtain patent licenses, thus in effect
|
|
||||||
transforming the program into proprietary software. To prevent this,
|
|
||||||
we have made it clear that any patent must be licensed for everyone's
|
|
||||||
free use or not licensed at all.
|
|
||||||
|
|
||||||
Most GNU software, including some libraries, is covered by the ordinary
|
|
||||||
GNU General Public License, which was designed for utility programs. This
|
|
||||||
license, the GNU Library General Public License, applies to certain
|
|
||||||
designated libraries. This license is quite different from the ordinary
|
|
||||||
one; be sure to read it in full, and don't assume that anything in it is
|
|
||||||
the same as in the ordinary license.
|
|
||||||
|
|
||||||
The reason we have a separate public license for some libraries is that
|
|
||||||
they blur the distinction we usually make between modifying or adding to a
|
|
||||||
program and simply using it. Linking a program with a library, without
|
|
||||||
changing the library, is in some sense simply using the library, and is
|
|
||||||
analogous to running a utility program or application program. However, in
|
|
||||||
a textual and legal sense, the linked executable is a combined work, a
|
|
||||||
derivative of the original library, and the ordinary General Public License
|
|
||||||
treats it as such.
|
|
||||||
|
|
||||||
Because of this blurred distinction, using the ordinary General
|
|
||||||
Public License for libraries did not effectively promote software
|
|
||||||
sharing, because most developers did not use the libraries. We
|
|
||||||
concluded that weaker conditions might promote sharing better.
|
|
||||||
|
|
||||||
However, unrestricted linking of non-free programs would deprive the
|
|
||||||
users of those programs of all benefit from the free status of the
|
|
||||||
libraries themselves. This Library General Public License is intended to
|
|
||||||
permit developers of non-free programs to use free libraries, while
|
|
||||||
preserving your freedom as a user of such programs to change the free
|
|
||||||
libraries that are incorporated in them. (We have not seen how to achieve
|
|
||||||
this as regards changes in header files, but we have achieved it as regards
|
|
||||||
changes in the actual functions of the Library.) The hope is that this
|
|
||||||
will lead to faster development of free libraries.
|
|
||||||
|
|
||||||
The precise terms and conditions for copying, distribution and
|
|
||||||
modification follow. Pay close attention to the difference between a
|
|
||||||
"work based on the library" and a "work that uses the library". The
|
|
||||||
former contains code derived from the library, while the latter only
|
|
||||||
works together with the library.
|
|
||||||
|
|
||||||
Note that it is possible for a library to be covered by the ordinary
|
|
||||||
General Public License rather than by this special one.
|
|
||||||
|
|
||||||
GNU LIBRARY GENERAL PUBLIC LICENSE
|
|
||||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
|
||||||
|
|
||||||
0. This License Agreement applies to any software library which
|
|
||||||
contains a notice placed by the copyright holder or other authorized
|
|
||||||
party saying it may be distributed under the terms of this Library
|
|
||||||
General Public License (also called "this License"). Each licensee is
|
|
||||||
addressed as "you".
|
|
||||||
|
|
||||||
A "library" means a collection of software functions and/or data
|
|
||||||
prepared so as to be conveniently linked with application programs
|
|
||||||
(which use some of those functions and data) to form executables.
|
|
||||||
|
|
||||||
The "Library", below, refers to any such software library or work
|
|
||||||
which has been distributed under these terms. A "work based on the
|
|
||||||
Library" means either the Library or any derivative work under
|
|
||||||
copyright law: that is to say, a work containing the Library or a
|
|
||||||
portion of it, either verbatim or with modifications and/or translated
|
|
||||||
straightforwardly into another language. (Hereinafter, translation is
|
|
||||||
included without limitation in the term "modification".)
|
|
||||||
|
|
||||||
"Source code" for a work means the preferred form of the work for
|
|
||||||
making modifications to it. For a library, complete source code means
|
|
||||||
all the source code for all modules it contains, plus any associated
|
|
||||||
interface definition files, plus the scripts used to control compilation
|
|
||||||
and installation of the library.
|
|
||||||
|
|
||||||
Activities other than copying, distribution and modification are not
|
|
||||||
covered by this License; they are outside its scope. The act of
|
|
||||||
running a program using the Library is not restricted, and output from
|
|
||||||
such a program is covered only if its contents constitute a work based
|
|
||||||
on the Library (independent of the use of the Library in a tool for
|
|
||||||
writing it). Whether that is true depends on what the Library does
|
|
||||||
and what the program that uses the Library does.
|
|
||||||
|
|
||||||
1. You may copy and distribute verbatim copies of the Library's
|
|
||||||
complete source code as you receive it, in any medium, provided that
|
|
||||||
you conspicuously and appropriately publish on each copy an
|
|
||||||
appropriate copyright notice and disclaimer of warranty; keep intact
|
|
||||||
all the notices that refer to this License and to the absence of any
|
|
||||||
warranty; and distribute a copy of this License along with the
|
|
||||||
Library.
|
|
||||||
|
|
||||||
You may charge a fee for the physical act of transferring a copy,
|
|
||||||
and you may at your option offer warranty protection in exchange for a
|
|
||||||
fee.
|
|
||||||
|
|
||||||
2. You may modify your copy or copies of the Library or any portion
|
|
||||||
of it, thus forming a work based on the Library, and copy and
|
|
||||||
distribute such modifications or work under the terms of Section 1
|
|
||||||
above, provided that you also meet all of these conditions:
|
|
||||||
|
|
||||||
a) The modified work must itself be a software library.
|
|
||||||
|
|
||||||
b) You must cause the files modified to carry prominent notices
|
|
||||||
stating that you changed the files and the date of any change.
|
|
||||||
|
|
||||||
c) You must cause the whole of the work to be licensed at no
|
|
||||||
charge to all third parties under the terms of this License.
|
|
||||||
|
|
||||||
d) If a facility in the modified Library refers to a function or a
|
|
||||||
table of data to be supplied by an application program that uses
|
|
||||||
the facility, other than as an argument passed when the facility
|
|
||||||
is invoked, then you must make a good faith effort to ensure that,
|
|
||||||
in the event an application does not supply such function or
|
|
||||||
table, the facility still operates, and performs whatever part of
|
|
||||||
its purpose remains meaningful.
|
|
||||||
|
|
||||||
(For example, a function in a library to compute square roots has
|
|
||||||
a purpose that is entirely well-defined independent of the
|
|
||||||
application. Therefore, Subsection 2d requires that any
|
|
||||||
application-supplied function or table used by this function must
|
|
||||||
be optional: if the application does not supply it, the square
|
|
||||||
root function must still compute square roots.)
|
|
||||||
|
|
||||||
These requirements apply to the modified work as a whole. If
|
|
||||||
identifiable sections of that work are not derived from the Library,
|
|
||||||
and can be reasonably considered independent and separate works in
|
|
||||||
themselves, then this License, and its terms, do not apply to those
|
|
||||||
sections when you distribute them as separate works. But when you
|
|
||||||
distribute the same sections as part of a whole which is a work based
|
|
||||||
on the Library, the distribution of the whole must be on the terms of
|
|
||||||
this License, whose permissions for other licensees extend to the
|
|
||||||
entire whole, and thus to each and every part regardless of who wrote
|
|
||||||
it.
|
|
||||||
|
|
||||||
Thus, it is not the intent of this section to claim rights or contest
|
|
||||||
your rights to work written entirely by you; rather, the intent is to
|
|
||||||
exercise the right to control the distribution of derivative or
|
|
||||||
collective works based on the Library.
|
|
||||||
|
|
||||||
In addition, mere aggregation of another work not based on the Library
|
|
||||||
with the Library (or with a work based on the Library) on a volume of
|
|
||||||
a storage or distribution medium does not bring the other work under
|
|
||||||
the scope of this License.
|
|
||||||
|
|
||||||
3. You may opt to apply the terms of the ordinary GNU General Public
|
|
||||||
License instead of this License to a given copy of the Library. To do
|
|
||||||
this, you must alter all the notices that refer to this License, so
|
|
||||||
that they refer to the ordinary GNU General Public License, version 2,
|
|
||||||
instead of to this License. (If a newer version than version 2 of the
|
|
||||||
ordinary GNU General Public License has appeared, then you can specify
|
|
||||||
that version instead if you wish.) Do not make any other change in
|
|
||||||
these notices.
|
|
||||||
|
|
||||||
Once this change is made in a given copy, it is irreversible for
|
|
||||||
that copy, so the ordinary GNU General Public License applies to all
|
|
||||||
subsequent copies and derivative works made from that copy.
|
|
||||||
|
|
||||||
This option is useful when you wish to copy part of the code of
|
|
||||||
the Library into a program that is not a library.
|
|
||||||
|
|
||||||
4. You may copy and distribute the Library (or a portion or
|
|
||||||
derivative of it, under Section 2) in object code or executable form
|
|
||||||
under the terms of Sections 1 and 2 above provided that you accompany
|
|
||||||
it with the complete corresponding machine-readable source code, which
|
|
||||||
must be distributed under the terms of Sections 1 and 2 above on a
|
|
||||||
medium customarily used for software interchange.
|
|
||||||
|
|
||||||
If distribution of object code is made by offering access to copy
|
|
||||||
from a designated place, then offering equivalent access to copy the
|
|
||||||
source code from the same place satisfies the requirement to
|
|
||||||
distribute the source code, even though third parties are not
|
|
||||||
compelled to copy the source along with the object code.
|
|
||||||
|
|
||||||
5. A program that contains no derivative of any portion of the
|
|
||||||
Library, but is designed to work with the Library by being compiled or
|
|
||||||
linked with it, is called a "work that uses the Library". Such a
|
|
||||||
work, in isolation, is not a derivative work of the Library, and
|
|
||||||
therefore falls outside the scope of this License.
|
|
||||||
|
|
||||||
However, linking a "work that uses the Library" with the Library
|
|
||||||
creates an executable that is a derivative of the Library (because it
|
|
||||||
contains portions of the Library), rather than a "work that uses the
|
|
||||||
library". The executable is therefore covered by this License.
|
|
||||||
Section 6 states terms for distribution of such executables.
|
|
||||||
|
|
||||||
When a "work that uses the Library" uses material from a header file
|
|
||||||
that is part of the Library, the object code for the work may be a
|
|
||||||
derivative work of the Library even though the source code is not.
|
|
||||||
Whether this is true is especially significant if the work can be
|
|
||||||
linked without the Library, or if the work is itself a library. The
|
|
||||||
threshold for this to be true is not precisely defined by law.
|
|
||||||
|
|
||||||
If such an object file uses only numerical parameters, data
|
|
||||||
structure layouts and accessors, and small macros and small inline
|
|
||||||
functions (ten lines or less in length), then the use of the object
|
|
||||||
file is unrestricted, regardless of whether it is legally a derivative
|
|
||||||
work. (Executables containing this object code plus portions of the
|
|
||||||
Library will still fall under Section 6.)
|
|
||||||
|
|
||||||
Otherwise, if the work is a derivative of the Library, you may
|
|
||||||
distribute the object code for the work under the terms of Section 6.
|
|
||||||
Any executables containing that work also fall under Section 6,
|
|
||||||
whether or not they are linked directly with the Library itself.
|
|
||||||
|
|
||||||
6. As an exception to the Sections above, you may also compile or
|
|
||||||
link a "work that uses the Library" with the Library to produce a
|
|
||||||
work containing portions of the Library, and distribute that work
|
|
||||||
under terms of your choice, provided that the terms permit
|
|
||||||
modification of the work for the customer's own use and reverse
|
|
||||||
engineering for debugging such modifications.
|
|
||||||
|
|
||||||
You must give prominent notice with each copy of the work that the
|
|
||||||
Library is used in it and that the Library and its use are covered by
|
|
||||||
this License. You must supply a copy of this License. If the work
|
|
||||||
during execution displays copyright notices, you must include the
|
|
||||||
copyright notice for the Library among them, as well as a reference
|
|
||||||
directing the user to the copy of this License. Also, you must do one
|
|
||||||
of these things:
|
|
||||||
|
|
||||||
a) Accompany the work with the complete corresponding
|
|
||||||
machine-readable source code for the Library including whatever
|
|
||||||
changes were used in the work (which must be distributed under
|
|
||||||
Sections 1 and 2 above); and, if the work is an executable linked
|
|
||||||
with the Library, with the complete machine-readable "work that
|
|
||||||
uses the Library", as object code and/or source code, so that the
|
|
||||||
user can modify the Library and then relink to produce a modified
|
|
||||||
executable containing the modified Library. (It is understood
|
|
||||||
that the user who changes the contents of definitions files in the
|
|
||||||
Library will not necessarily be able to recompile the application
|
|
||||||
to use the modified definitions.)
|
|
||||||
|
|
||||||
b) Accompany the work with a written offer, valid for at
|
|
||||||
least three years, to give the same user the materials
|
|
||||||
specified in Subsection 6a, above, for a charge no more
|
|
||||||
than the cost of performing this distribution.
|
|
||||||
|
|
||||||
c) If distribution of the work is made by offering access to copy
|
|
||||||
from a designated place, offer equivalent access to copy the above
|
|
||||||
specified materials from the same place.
|
|
||||||
|
|
||||||
d) Verify that the user has already received a copy of these
|
|
||||||
materials or that you have already sent this user a copy.
|
|
||||||
|
|
||||||
For an executable, the required form of the "work that uses the
|
|
||||||
Library" must include any data and utility programs needed for
|
|
||||||
reproducing the executable from it. However, as a special exception,
|
|
||||||
the source code distributed need not include anything that is normally
|
|
||||||
distributed (in either source or binary form) with the major
|
|
||||||
components (compiler, kernel, and so on) of the operating system on
|
|
||||||
which the executable runs, unless that component itself accompanies
|
|
||||||
the executable.
|
|
||||||
|
|
||||||
It may happen that this requirement contradicts the license
|
|
||||||
restrictions of other proprietary libraries that do not normally
|
|
||||||
accompany the operating system. Such a contradiction means you cannot
|
|
||||||
use both them and the Library together in an executable that you
|
|
||||||
distribute.
|
|
||||||
|
|
||||||
7. You may place library facilities that are a work based on the
|
|
||||||
Library side-by-side in a single library together with other library
|
|
||||||
facilities not covered by this License, and distribute such a combined
|
|
||||||
library, provided that the separate distribution of the work based on
|
|
||||||
the Library and of the other library facilities is otherwise
|
|
||||||
permitted, and provided that you do these two things:
|
|
||||||
|
|
||||||
a) Accompany the combined library with a copy of the same work
|
|
||||||
based on the Library, uncombined with any other library
|
|
||||||
facilities. This must be distributed under the terms of the
|
|
||||||
Sections above.
|
|
||||||
|
|
||||||
b) Give prominent notice with the combined library of the fact
|
|
||||||
that part of it is a work based on the Library, and explaining
|
|
||||||
where to find the accompanying uncombined form of the same work.
|
|
||||||
|
|
||||||
8. You may not copy, modify, sublicense, link with, or distribute
|
|
||||||
the Library except as expressly provided under this License. Any
|
|
||||||
attempt otherwise to copy, modify, sublicense, link with, or
|
|
||||||
distribute the Library is void, and will automatically terminate your
|
|
||||||
rights under this License. However, parties who have received copies,
|
|
||||||
or rights, from you under this License will not have their licenses
|
|
||||||
terminated so long as such parties remain in full compliance.
|
|
||||||
|
|
||||||
9. You are not required to accept this License, since you have not
|
|
||||||
signed it. However, nothing else grants you permission to modify or
|
|
||||||
distribute the Library or its derivative works. These actions are
|
|
||||||
prohibited by law if you do not accept this License. Therefore, by
|
|
||||||
modifying or distributing the Library (or any work based on the
|
|
||||||
Library), you indicate your acceptance of this License to do so, and
|
|
||||||
all its terms and conditions for copying, distributing or modifying
|
|
||||||
the Library or works based on it.
|
|
||||||
|
|
||||||
10. Each time you redistribute the Library (or any work based on the
|
|
||||||
Library), the recipient automatically receives a license from the
|
|
||||||
original licensor to copy, distribute, link with or modify the Library
|
|
||||||
subject to these terms and conditions. You may not impose any further
|
|
||||||
restrictions on the recipients' exercise of the rights granted herein.
|
|
||||||
You are not responsible for enforcing compliance by third parties to
|
|
||||||
this License.
|
|
||||||
|
|
||||||
11. If, as a consequence of a court judgment or allegation of patent
|
|
||||||
infringement or for any other reason (not limited to patent issues),
|
|
||||||
conditions are imposed on you (whether by court order, agreement or
|
|
||||||
otherwise) that contradict the conditions of this License, they do not
|
|
||||||
excuse you from the conditions of this License. If you cannot
|
|
||||||
distribute so as to satisfy simultaneously your obligations under this
|
|
||||||
License and any other pertinent obligations, then as a consequence you
|
|
||||||
may not distribute the Library at all. For example, if a patent
|
|
||||||
license would not permit royalty-free redistribution of the Library by
|
|
||||||
all those who receive copies directly or indirectly through you, then
|
|
||||||
the only way you could satisfy both it and this License would be to
|
|
||||||
refrain entirely from distribution of the Library.
|
|
||||||
|
|
||||||
If any portion of this section is held invalid or unenforceable under any
|
|
||||||
particular circumstance, the balance of the section is intended to apply,
|
|
||||||
and the section as a whole is intended to apply in other circumstances.
|
|
||||||
|
|
||||||
It is not the purpose of this section to induce you to infringe any
|
|
||||||
patents or other property right claims or to contest validity of any
|
|
||||||
such claims; this section has the sole purpose of protecting the
|
|
||||||
integrity of the free software distribution system which is
|
|
||||||
implemented by public license practices. Many people have made
|
|
||||||
generous contributions to the wide range of software distributed
|
|
||||||
through that system in reliance on consistent application of that
|
|
||||||
system; it is up to the author/donor to decide if he or she is willing
|
|
||||||
to distribute software through any other system and a licensee cannot
|
|
||||||
impose that choice.
|
|
||||||
|
|
||||||
This section is intended to make thoroughly clear what is believed to
|
|
||||||
be a consequence of the rest of this License.
|
|
||||||
|
|
||||||
12. If the distribution and/or use of the Library is restricted in
|
|
||||||
certain countries either by patents or by copyrighted interfaces, the
|
|
||||||
original copyright holder who places the Library under this License may add
|
|
||||||
an explicit geographical distribution limitation excluding those countries,
|
|
||||||
so that distribution is permitted only in or among countries not thus
|
|
||||||
excluded. In such case, this License incorporates the limitation as if
|
|
||||||
written in the body of this License.
|
|
||||||
|
|
||||||
13. The Free Software Foundation may publish revised and/or new
|
|
||||||
versions of the Library General Public License from time to time.
|
|
||||||
Such new versions will be similar in spirit to the present version,
|
|
||||||
but may differ in detail to address new problems or concerns.
|
|
||||||
|
|
||||||
Each version is given a distinguishing version number. If the Library
|
|
||||||
specifies a version number of this License which applies to it and
|
|
||||||
"any later version", you have the option of following the terms and
|
|
||||||
conditions either of that version or of any later version published by
|
|
||||||
the Free Software Foundation. If the Library does not specify a
|
|
||||||
license version number, you may choose any version ever published by
|
|
||||||
the Free Software Foundation.
|
|
||||||
|
|
||||||
14. If you wish to incorporate parts of the Library into other free
|
|
||||||
programs whose distribution conditions are incompatible with these,
|
|
||||||
write to the author to ask for permission. For software which is
|
|
||||||
copyrighted by the Free Software Foundation, write to the Free
|
|
||||||
Software Foundation; we sometimes make exceptions for this. Our
|
|
||||||
decision will be guided by the two goals of preserving the free status
|
|
||||||
of all derivatives of our free software and of promoting the sharing
|
|
||||||
and reuse of software generally.
|
|
||||||
|
|
||||||
NO WARRANTY
|
|
||||||
|
|
||||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
|
||||||
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
|
||||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
|
||||||
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
|
|
||||||
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
|
|
||||||
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
|
||||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
|
||||||
|
|
||||||
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
|
||||||
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
|
||||||
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
|
|
||||||
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
|
||||||
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
|
||||||
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
|
||||||
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
|
||||||
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
|
||||||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
|
||||||
DAMAGES.
|
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
How to Apply These Terms to Your New Libraries
|
|
||||||
|
|
||||||
If you develop a new library, and you want it to be of the greatest
|
|
||||||
possible use to the public, we recommend making it free software that
|
|
||||||
everyone can redistribute and change. You can do so by permitting
|
|
||||||
redistribution under these terms (or, alternatively, under the terms of the
|
|
||||||
ordinary General Public License).
|
|
||||||
|
|
||||||
To apply these terms, attach the following notices to the library. It is
|
|
||||||
safest to attach them to the start of each source file to most effectively
|
|
||||||
convey the exclusion of warranty; and each file should have at least the
|
|
||||||
"copyright" line and a pointer to where the full notice is found.
|
|
||||||
|
|
||||||
<one line to give the library's name and a brief idea of what it does.>
|
|
||||||
Copyright (C) <year> <name of author>
|
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Library General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This 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
|
|
||||||
Library General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public
|
|
||||||
License along with this library; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
|
|
||||||
Also add information on how to contact you by electronic and paper mail.
|
|
||||||
|
|
||||||
You should also get your employer (if you work as a programmer) or your
|
|
||||||
school, if any, to sign a "copyright disclaimer" for the library, if
|
|
||||||
necessary. Here is a sample; alter the names:
|
|
||||||
|
|
||||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
|
||||||
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
|
|
||||||
|
|
||||||
<signature of Ty Coon>, 1 April 1990
|
|
||||||
Ty Coon, President of Vice
|
|
||||||
|
|
||||||
That's all there is to it!
|
|
||||||
1
external/bubblewrap/LICENSE
vendored
1
external/bubblewrap/LICENSE
vendored
|
|
@ -1 +0,0 @@
|
||||||
COPYING
|
|
||||||
13
external/bubblewrap/Makefile-bwrap.am
vendored
13
external/bubblewrap/Makefile-bwrap.am
vendored
|
|
@ -1,13 +0,0 @@
|
||||||
|
|
||||||
bwrap_SOURCES = \
|
|
||||||
$(bwrap_srcpath)/bubblewrap.c \
|
|
||||||
$(bwrap_srcpath)/bind-mount.h \
|
|
||||||
$(bwrap_srcpath)/bind-mount.c \
|
|
||||||
$(bwrap_srcpath)/network.h \
|
|
||||||
$(bwrap_srcpath)/network.c \
|
|
||||||
$(bwrap_srcpath)/utils.h \
|
|
||||||
$(bwrap_srcpath)/utils.c \
|
|
||||||
$(NULL)
|
|
||||||
|
|
||||||
bwrap_CFLAGS = $(AM_CFLAGS)
|
|
||||||
bwrap_LDFLAGS = $(SELINUX_LIBS)
|
|
||||||
17
external/bubblewrap/Makefile-docs.am
vendored
17
external/bubblewrap/Makefile-docs.am
vendored
|
|
@ -1,17 +0,0 @@
|
||||||
XSLTPROC = xsltproc
|
|
||||||
|
|
||||||
XSLTPROC_FLAGS = \
|
|
||||||
--nonet \
|
|
||||||
--stringparam man.output.quietly 1 \
|
|
||||||
--stringparam funcsynopsis.style ansi \
|
|
||||||
--stringparam man.th.extra1.suppress 1 \
|
|
||||||
--stringparam man.authors.section.enabled 0 \
|
|
||||||
--stringparam man.copyright.section.enabled 0
|
|
||||||
|
|
||||||
.xml.1:
|
|
||||||
$(XSLTPROC) $(XSLTPROC_FLAGS) http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl $<
|
|
||||||
|
|
||||||
if ENABLE_MAN
|
|
||||||
man_MANS = bwrap.1
|
|
||||||
CLEANFILES += $(man_MANS)
|
|
||||||
endif
|
|
||||||
31
external/bubblewrap/Makefile.am
vendored
31
external/bubblewrap/Makefile.am
vendored
|
|
@ -1,31 +0,0 @@
|
||||||
AM_CFLAGS = $(WARN_CFLAGS)
|
|
||||||
CLEANFILES =
|
|
||||||
|
|
||||||
GITIGNOREFILES = build-aux/ gtk-doc.make config.h.in aclocal.m4
|
|
||||||
|
|
||||||
bin_PROGRAMS = bwrap
|
|
||||||
|
|
||||||
bwrap_srcpath := $(srcdir)
|
|
||||||
include Makefile-bwrap.am
|
|
||||||
|
|
||||||
install-exec-hook:
|
|
||||||
if PRIV_MODE_SETUID
|
|
||||||
$(SUDO_BIN) chown root $(DESTDIR)$(bindir)/bwrap
|
|
||||||
$(SUDO_BIN) chmod u+s $(DESTDIR)$(bindir)/bwrap
|
|
||||||
else
|
|
||||||
if PRIV_MODE_FILECAPS
|
|
||||||
$(SUDO_BIN) setcap cap_sys_admin,cap_net_admin,cap_sys_chroot,cap_setuid,cap_setgid+ep $(DESTDIR)$(bindir)/bwrap
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
include Makefile-docs.am
|
|
||||||
|
|
||||||
TESTS = tests/test-basic.sh
|
|
||||||
TESTS_ENVIRONMENT = PATH=$$(cd $(top_builddir) && pwd):$${PATH}
|
|
||||||
|
|
||||||
if ENABLE_BASH_COMPLETION
|
|
||||||
bashcompletiondir = $(BASH_COMPLETION_DIR)
|
|
||||||
dist_bashcompletion_DATA = completions/bash/bwrap
|
|
||||||
endif
|
|
||||||
|
|
||||||
-include $(top_srcdir)/git.mk
|
|
||||||
191
external/bubblewrap/README.md
vendored
191
external/bubblewrap/README.md
vendored
|
|
@ -1,191 +0,0 @@
|
||||||
Bubblewrap
|
|
||||||
==========
|
|
||||||
|
|
||||||
Many container runtime tools like `systemd-nspawn`, `docker`,
|
|
||||||
etc. focus on providing infrastructure for system administrators and
|
|
||||||
orchestration tools (e.g. Kubernetes) to run containers.
|
|
||||||
|
|
||||||
These tools are not suitable to give to unprivileged users, because it
|
|
||||||
is trivial to turn such access into to a fully privileged root shell
|
|
||||||
on the host.
|
|
||||||
|
|
||||||
User namespaces
|
|
||||||
---------------
|
|
||||||
|
|
||||||
There is an effort in the Linux kernel called
|
|
||||||
[user namespaces](https://www.google.com/search?q=user+namespaces+site%3Ahttps%3A%2F%2Flwn.net)
|
|
||||||
which attempts to allow unprivileged users to use container features.
|
|
||||||
While significant progress has been made, there are
|
|
||||||
[still concerns](https://lwn.net/Articles/673597/) about it, and
|
|
||||||
it is not available to unprivileged users in several production distributions
|
|
||||||
such as CentOS/Red Hat Enterprise Linux 7, Debian Jessie, etc.
|
|
||||||
|
|
||||||
See for example
|
|
||||||
[CVE-2016-3135](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2016-3135)
|
|
||||||
which is a local root vulnerability introduced by userns.
|
|
||||||
[This March 2016 post](https://lkml.org/lkml/2016/3/9/555) has some
|
|
||||||
more discussion.
|
|
||||||
|
|
||||||
Bubblewrap could be viewed as setuid implementation of a *subset* of
|
|
||||||
user namespaces. Emphasis on subset - specifically relevant to the
|
|
||||||
above CVE, bubblewrap does not allow control over iptables.
|
|
||||||
|
|
||||||
The original bubblewrap code existed before user namespaces - it inherits code from
|
|
||||||
[xdg-app helper](https://cgit.freedesktop.org/xdg-app/xdg-app/tree/common/xdg-app-helper.c)
|
|
||||||
which in turn distantly derives from
|
|
||||||
[linux-user-chroot](https://git.gnome.org/browse/linux-user-chroot).
|
|
||||||
|
|
||||||
Security
|
|
||||||
--------
|
|
||||||
|
|
||||||
The maintainers of this tool believe that it does not, even when used
|
|
||||||
in combination with typical software installed on that distribution,
|
|
||||||
allow privilege escalation. It may increase the ability of a logged
|
|
||||||
in user to perform denial of service attacks, however.
|
|
||||||
|
|
||||||
In particular, bubblewrap uses `PR_SET_NO_NEW_PRIVS` to turn off
|
|
||||||
setuid binaries, which is the [traditional way](https://en.wikipedia.org/wiki/Chroot#Limitations) to get out of things
|
|
||||||
like chroots.
|
|
||||||
|
|
||||||
Users
|
|
||||||
-----
|
|
||||||
|
|
||||||
This program can be shared by all container tools which perform
|
|
||||||
non-root operation, such as:
|
|
||||||
|
|
||||||
- [xdg-app](https://cgit.freedesktop.org/xdg-app/xdg-app)
|
|
||||||
- [rpm-ostree unprivileged](https://github.com/projectatomic/rpm-ostree/pull/209)
|
|
||||||
|
|
||||||
We would also like to see this be available in Kubernetes/OpenShift
|
|
||||||
clusters. Having the ability for unprivileged users to use container
|
|
||||||
features would make it significantly easier to do interactive
|
|
||||||
debugging scenarios and the like.
|
|
||||||
|
|
||||||
Usage
|
|
||||||
-----
|
|
||||||
|
|
||||||
bubblewrap works by creating a new, completely empty, mount
|
|
||||||
namespace where the root is on a tmpfs that is invisible from the
|
|
||||||
host, and will be automatically cleaned up when the last process
|
|
||||||
exists. You can then use commandline options to construct the root
|
|
||||||
filesystem and process environment and command to run in the
|
|
||||||
namespace.
|
|
||||||
|
|
||||||
A simple example is
|
|
||||||
```
|
|
||||||
bwrap --ro-bind / / bash
|
|
||||||
```
|
|
||||||
This will create a read-only bind mount of the host root at the
|
|
||||||
sandbox root, and then start a bash.
|
|
||||||
|
|
||||||
Another simple example would be a read-write chroot operation:
|
|
||||||
```
|
|
||||||
bwrap --bind /some/chroot/dir / bash
|
|
||||||
```
|
|
||||||
|
|
||||||
A more complex example is to run a with a custom (readonly) /usr,
|
|
||||||
but your own (tmpfs) data, running in a PID and network namespace:
|
|
||||||
|
|
||||||
```
|
|
||||||
bwrap --ro-bind /usr /usr \
|
|
||||||
--tmpfs /tmp \
|
|
||||||
--proc /proc \
|
|
||||||
--dev /dev \
|
|
||||||
--ro-bind /etc/resolv.conf /etc/resolv.conf \
|
|
||||||
--symlink usr/lib /lib \
|
|
||||||
--symlink usr/lib64 /lib64 \
|
|
||||||
--symlink usr/bin /bin \
|
|
||||||
--symlink usr/sbin /sbin \
|
|
||||||
--chdir / \
|
|
||||||
--unshare-pid \
|
|
||||||
--unshare-net \
|
|
||||||
--dir /run/user/$(id -u) \
|
|
||||||
--setenv XDG_RUNTIME_DIR "/run/user/`id -u`" \
|
|
||||||
/bin/sh
|
|
||||||
```
|
|
||||||
|
|
||||||
Sandboxing
|
|
||||||
----------
|
|
||||||
|
|
||||||
The goal of bubblewrap is to run an application in a sandbox, where it
|
|
||||||
has restricted access to parts of the operating system or user data
|
|
||||||
such as the home directory.
|
|
||||||
|
|
||||||
bubblewrap always creates a new mount namespace, and the user can specify
|
|
||||||
exactly what parts of the filesystem should be visible in the sandbox.
|
|
||||||
Any such directories you specify mounted `nodev` by default, and can be made readonly.
|
|
||||||
|
|
||||||
Additionally you can use these kernel features:
|
|
||||||
|
|
||||||
User namespaces ([CLONE_NEWUSER](http://linux.die.net/man/2/clone)): This hides all but the current uid and gid from the
|
|
||||||
sandbox. You can also change what the value of uid/gid should be in the sandbox.
|
|
||||||
|
|
||||||
IPC namespaces ([CLONE_NEWIPC](http://linux.die.net/man/2/clone)): The sandbox will get its own copy of all the
|
|
||||||
different forms of IPCs, like SysV shared memory and semaphores.
|
|
||||||
|
|
||||||
PID namespaces ([CLONE_NEWPID](http://linux.die.net/man/2/clone)): The sandbox will not see any processes outside the sandbox. Additionally, bubblewrap will run a trivial pid1 inside your container to handle the requirements of reaping children in the sandbox. .This avoids what is known now as the [Docker pid 1 problem](https://blog.phusion.nl/2015/01/20/docker-and-the-pid-1-zombie-reaping-problem/).
|
|
||||||
|
|
||||||
|
|
||||||
Network namespaces ([CLONE_NEWNET](http://linux.die.net/man/2/clone)): The sandbox will not see the network. Instead it will have its own network namespace with only a loopback device.
|
|
||||||
|
|
||||||
UTS namespace ([CLONE_NEWUTS](http://linux.die.net/man/2/clone)): The sandbox will have its own hostname.
|
|
||||||
|
|
||||||
Seccomp filters: You can pass in seccomp filters that limit which syscalls can be done in the sandbox. For more information, see [Seccomp](https://en.wikipedia.org/wiki/Seccomp).
|
|
||||||
|
|
||||||
Related project comparison: Firejail
|
|
||||||
------------------------------------
|
|
||||||
|
|
||||||
[Firejail](https://github.com/netblue30/firejail/tree/master/src/firejail) is
|
|
||||||
similar to xdg-app before bubblewrap was split out in that it combines
|
|
||||||
a setuid tool with a lot of desktop-specific sandboxing features. For
|
|
||||||
example, Firejail knows about Pulseaudio, whereas bubblewrap does not.
|
|
||||||
|
|
||||||
The bubblewrap authors believe it's much easier to audit a small
|
|
||||||
setuid program, and keep features such as Pulseaudio filtering as an
|
|
||||||
unprivileged process, as now occurs in xdg-app.
|
|
||||||
|
|
||||||
Also, @cgwalters thinks trying to
|
|
||||||
[whitelist file paths](https://github.com/netblue30/firejail/blob/37a5a3545ef6d8d03dad8bbd888f53e13274c9e5/src/firejail/fs_whitelist.c#L176)
|
|
||||||
is a bad idea given the myriad ways users have to manipulate paths,
|
|
||||||
and the myriad ways in which system administrators may configure a
|
|
||||||
system. The bubblewrap approach is to only retain a few specific
|
|
||||||
Linux capabilities such as `CAP_SYS_ADMIN`, but to always access the
|
|
||||||
filesystem as the invoking uid. This entirely closes
|
|
||||||
[TOCTOCU attacks](https://cwe.mitre.org/data/definitions/367.html) and
|
|
||||||
such.
|
|
||||||
|
|
||||||
Related project comparison: Sandstorm.io
|
|
||||||
----------------------------------------
|
|
||||||
|
|
||||||
[Sandstorm.io](https://sandstorm.io/) also has a setuid helper
|
|
||||||
process. @cgwalters believes their setuid code is fairly good, but it
|
|
||||||
could still make sense to unify on bubblewrap as a setuid core. That
|
|
||||||
hasn't been ruled out, but neither is it being actively pursued today.
|
|
||||||
|
|
||||||
Related project comparison: runc/binctr
|
|
||||||
----------------------------------------
|
|
||||||
|
|
||||||
[runc](https://github.com/opencontainers/runc) is similar to
|
|
||||||
[systemd nspawn](https://www.freedesktop.org/software/systemd/man/systemd-nspawn.html)
|
|
||||||
in that it is tooling intended to be invoked by root. There is an
|
|
||||||
effort to have runc optionally use
|
|
||||||
[user namespaces](https://github.com/opencontainers/runc/issues/38),
|
|
||||||
but no plans for any setuid support.
|
|
||||||
|
|
||||||
The bubblewrap authors believe that runc and systemd-nspawn are not
|
|
||||||
designed to be made setuid and are distant from supporting such a
|
|
||||||
mode.
|
|
||||||
|
|
||||||
[binctr](https://github.com/jfrazelle/binctr) is just a wrapper for
|
|
||||||
runc, so inherits all of its design tradeoffs.
|
|
||||||
|
|
||||||
Whats with the name ?!
|
|
||||||
----------------------
|
|
||||||
|
|
||||||
The name bubblewrap was chosen to convey that this
|
|
||||||
tool runs as the parent of the application (so wraps it in some sense) and creates
|
|
||||||
a protective layer (the sandbox) around it.
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
(Bubblewrap cat by [dancing_stupidity](https://www.flickr.com/photos/27549668@N03/))
|
|
||||||
19
external/bubblewrap/autogen.sh
vendored
19
external/bubblewrap/autogen.sh
vendored
|
|
@ -1,19 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
test -n "$srcdir" || srcdir=`dirname "$0"`
|
|
||||||
test -n "$srcdir" || srcdir=.
|
|
||||||
|
|
||||||
olddir=`pwd`
|
|
||||||
cd $srcdir
|
|
||||||
|
|
||||||
if ! (autoreconf --version >/dev/null 2>&1); then
|
|
||||||
echo "*** No autoreconf found, please install it ***"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
mkdir -p m4
|
|
||||||
|
|
||||||
autoreconf --force --install --verbose
|
|
||||||
|
|
||||||
cd $olddir
|
|
||||||
test -n "$NOCONFIGURE" || "$srcdir/configure" "$@"
|
|
||||||
285
external/bubblewrap/bind-mount.c
vendored
285
external/bubblewrap/bind-mount.c
vendored
|
|
@ -1,285 +0,0 @@
|
||||||
/* bubblewrap
|
|
||||||
* Copyright (C) 2016 Alexander Larsson
|
|
||||||
*
|
|
||||||
* This program 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 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This 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 this library. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "config.h"
|
|
||||||
|
|
||||||
#include <sys/mount.h>
|
|
||||||
|
|
||||||
#include "utils.h"
|
|
||||||
#include "bind-mount.h"
|
|
||||||
|
|
||||||
static char *
|
|
||||||
skip_line (char *line)
|
|
||||||
{
|
|
||||||
while (*line != 0 && *line != '\n')
|
|
||||||
line++;
|
|
||||||
|
|
||||||
if (*line == '\n')
|
|
||||||
line++;
|
|
||||||
|
|
||||||
return line;
|
|
||||||
}
|
|
||||||
|
|
||||||
static char *
|
|
||||||
skip_token (char *line, bool eat_whitespace)
|
|
||||||
{
|
|
||||||
while (*line != ' ' && *line != '\n')
|
|
||||||
line++;
|
|
||||||
|
|
||||||
if (eat_whitespace && *line == ' ')
|
|
||||||
line++;
|
|
||||||
|
|
||||||
return line;
|
|
||||||
}
|
|
||||||
|
|
||||||
static char *
|
|
||||||
unescape_mountpoint (const char *escaped, ssize_t len)
|
|
||||||
{
|
|
||||||
char *unescaped, *res;
|
|
||||||
const char *end;
|
|
||||||
|
|
||||||
if (len < 0)
|
|
||||||
len = strlen (escaped);
|
|
||||||
end = escaped + len;
|
|
||||||
|
|
||||||
unescaped = res = xmalloc (len + 1);
|
|
||||||
while (escaped < end)
|
|
||||||
{
|
|
||||||
if (*escaped == '\\')
|
|
||||||
{
|
|
||||||
*unescaped++ =
|
|
||||||
((escaped[1] - '0') << 6) |
|
|
||||||
((escaped[2] - '0') << 3) |
|
|
||||||
((escaped[3] - '0') << 0);
|
|
||||||
escaped += 4;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
*unescaped++ = *escaped++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*unescaped = 0;
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
static char *
|
|
||||||
get_mountinfo (int proc_fd,
|
|
||||||
const char *mountpoint)
|
|
||||||
{
|
|
||||||
char *line_mountpoint, *line_mountpoint_end;
|
|
||||||
cleanup_free char *mountinfo = NULL;
|
|
||||||
cleanup_free char *free_me = NULL;
|
|
||||||
char *line, *line_start;
|
|
||||||
char *res = NULL;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
if (mountpoint[0] != '/')
|
|
||||||
{
|
|
||||||
cleanup_free char *cwd = getcwd (NULL, 0);
|
|
||||||
if (cwd == NULL)
|
|
||||||
die_oom ();
|
|
||||||
|
|
||||||
mountpoint = free_me = strconcat3 (cwd, "/", mountpoint);
|
|
||||||
}
|
|
||||||
|
|
||||||
mountinfo = load_file_at (proc_fd, "self/mountinfo");
|
|
||||||
if (mountinfo == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
line = mountinfo;
|
|
||||||
|
|
||||||
while (*line != 0)
|
|
||||||
{
|
|
||||||
cleanup_free char *unescaped = NULL;
|
|
||||||
|
|
||||||
line_start = line;
|
|
||||||
for (i = 0; i < 4; i++)
|
|
||||||
line = skip_token (line, TRUE);
|
|
||||||
line_mountpoint = line;
|
|
||||||
line = skip_token (line, FALSE);
|
|
||||||
line_mountpoint_end = line;
|
|
||||||
line = skip_line (line);
|
|
||||||
|
|
||||||
unescaped = unescape_mountpoint (line_mountpoint, line_mountpoint_end - line_mountpoint);
|
|
||||||
if (strcmp (mountpoint, unescaped) == 0)
|
|
||||||
{
|
|
||||||
res = line_start;
|
|
||||||
line[-1] = 0;
|
|
||||||
/* Keep going, because we want to return the *last* match */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (res)
|
|
||||||
return xstrdup (res);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static unsigned long
|
|
||||||
get_mountflags (int proc_fd,
|
|
||||||
const char *mountpoint)
|
|
||||||
{
|
|
||||||
cleanup_free char *line = NULL;
|
|
||||||
char *token, *end_token;
|
|
||||||
int i;
|
|
||||||
unsigned long flags = 0;
|
|
||||||
static const struct { int flag;
|
|
||||||
char *name;
|
|
||||||
} flags_data[] = {
|
|
||||||
{ 0, "rw" },
|
|
||||||
{ MS_RDONLY, "ro" },
|
|
||||||
{ MS_NOSUID, "nosuid" },
|
|
||||||
{ MS_NODEV, "nodev" },
|
|
||||||
{ MS_NOEXEC, "noexec" },
|
|
||||||
{ MS_NOATIME, "noatime" },
|
|
||||||
{ MS_NODIRATIME, "nodiratime" },
|
|
||||||
{ MS_RELATIME, "relatime" },
|
|
||||||
{ 0, NULL }
|
|
||||||
};
|
|
||||||
|
|
||||||
line = get_mountinfo (proc_fd, mountpoint);
|
|
||||||
if (line == NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
token = line;
|
|
||||||
for (i = 0; i < 5; i++)
|
|
||||||
token = skip_token (token, TRUE);
|
|
||||||
|
|
||||||
end_token = skip_token (token, FALSE);
|
|
||||||
*end_token = 0;
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
end_token = strchr (token, ',');
|
|
||||||
if (end_token != NULL)
|
|
||||||
*end_token = 0;
|
|
||||||
|
|
||||||
for (i = 0; flags_data[i].name != NULL; i++)
|
|
||||||
if (strcmp (token, flags_data[i].name) == 0)
|
|
||||||
flags |= flags_data[i].flag;
|
|
||||||
|
|
||||||
if (end_token)
|
|
||||||
token = end_token + 1;
|
|
||||||
else
|
|
||||||
token = NULL;
|
|
||||||
}
|
|
||||||
while (token != NULL);
|
|
||||||
|
|
||||||
return flags;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static char **
|
|
||||||
get_submounts (int proc_fd,
|
|
||||||
const char *parent_mount)
|
|
||||||
{
|
|
||||||
char *mountpoint, *mountpoint_end;
|
|
||||||
char **submounts;
|
|
||||||
int i, n_submounts, submounts_size;
|
|
||||||
cleanup_free char *mountinfo = NULL;
|
|
||||||
char *line;
|
|
||||||
|
|
||||||
mountinfo = load_file_at (proc_fd, "self/mountinfo");
|
|
||||||
if (mountinfo == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
submounts_size = 8;
|
|
||||||
n_submounts = 0;
|
|
||||||
submounts = xmalloc (sizeof (char *) * submounts_size);
|
|
||||||
|
|
||||||
line = mountinfo;
|
|
||||||
|
|
||||||
while (*line != 0)
|
|
||||||
{
|
|
||||||
cleanup_free char *unescaped = NULL;
|
|
||||||
for (i = 0; i < 4; i++)
|
|
||||||
line = skip_token (line, TRUE);
|
|
||||||
mountpoint = line;
|
|
||||||
line = skip_token (line, FALSE);
|
|
||||||
mountpoint_end = line;
|
|
||||||
line = skip_line (line);
|
|
||||||
*mountpoint_end = 0;
|
|
||||||
|
|
||||||
unescaped = unescape_mountpoint (mountpoint, -1);
|
|
||||||
|
|
||||||
if (has_path_prefix (unescaped, parent_mount))
|
|
||||||
{
|
|
||||||
if (n_submounts + 1 >= submounts_size)
|
|
||||||
{
|
|
||||||
submounts_size *= 2;
|
|
||||||
submounts = xrealloc (submounts, sizeof (char *) * submounts_size);
|
|
||||||
}
|
|
||||||
submounts[n_submounts++] = xstrdup (unescaped);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
submounts[n_submounts] = NULL;
|
|
||||||
|
|
||||||
return submounts;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
bind_mount (int proc_fd,
|
|
||||||
const char *src,
|
|
||||||
const char *dest,
|
|
||||||
bind_option_t options)
|
|
||||||
{
|
|
||||||
bool readonly = (options & BIND_READONLY) != 0;
|
|
||||||
bool devices = (options & BIND_DEVICES) != 0;
|
|
||||||
bool recursive = (options & BIND_RECURSIVE) != 0;
|
|
||||||
unsigned long current_flags, new_flags;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
if (mount (src, dest, NULL, MS_MGC_VAL | MS_BIND | (recursive ? MS_REC : 0), NULL) != 0)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
current_flags = get_mountflags (proc_fd, dest);
|
|
||||||
|
|
||||||
new_flags = current_flags | (devices ? 0 : MS_NODEV) | MS_NOSUID | (readonly ? MS_RDONLY : 0);
|
|
||||||
if (new_flags != current_flags &&
|
|
||||||
mount ("none", dest,
|
|
||||||
NULL, MS_MGC_VAL | MS_BIND | MS_REMOUNT | new_flags, NULL) != 0)
|
|
||||||
return 3;
|
|
||||||
|
|
||||||
/* We need to work around the fact that a bind mount does not apply the flags, so we need to manually
|
|
||||||
* apply the flags to all submounts in the recursive case.
|
|
||||||
* Note: This does not apply the flags to mounts which are later propagated into this namespace.
|
|
||||||
*/
|
|
||||||
if (recursive)
|
|
||||||
{
|
|
||||||
cleanup_strv char **submounts = get_submounts (proc_fd, dest);
|
|
||||||
if (submounts == NULL)
|
|
||||||
return 4;
|
|
||||||
|
|
||||||
for (i = 0; submounts[i] != NULL; i++)
|
|
||||||
{
|
|
||||||
current_flags = get_mountflags (proc_fd, submounts[i]);
|
|
||||||
new_flags = current_flags | (devices ? 0 : MS_NODEV) | MS_NOSUID | (readonly ? MS_RDONLY : 0);
|
|
||||||
if (new_flags != current_flags &&
|
|
||||||
mount ("none", submounts[i],
|
|
||||||
NULL, MS_MGC_VAL | MS_BIND | MS_REMOUNT | new_flags, NULL) != 0)
|
|
||||||
{
|
|
||||||
/* If we can't read the mountpoint we can't remount it, but that should
|
|
||||||
be safe to ignore because its not something the user can access. */
|
|
||||||
if (errno != EACCES)
|
|
||||||
return 5;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
30
external/bubblewrap/bind-mount.h
vendored
30
external/bubblewrap/bind-mount.h
vendored
|
|
@ -1,30 +0,0 @@
|
||||||
/* bubblewrap
|
|
||||||
* Copyright (C) 2016 Alexander Larsson
|
|
||||||
*
|
|
||||||
* This program 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 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This 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 this library. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
BIND_READONLY = (1 << 0),
|
|
||||||
BIND_DEVICES = (1 << 2),
|
|
||||||
BIND_RECURSIVE = (1 << 3),
|
|
||||||
} bind_option_t;
|
|
||||||
|
|
||||||
int bind_mount (int proc_fd,
|
|
||||||
const char *src,
|
|
||||||
const char *dest,
|
|
||||||
bind_option_t options);
|
|
||||||
1593
external/bubblewrap/bubblewrap.c
vendored
1593
external/bubblewrap/bubblewrap.c
vendored
File diff suppressed because it is too large
Load diff
BIN
external/bubblewrap/bubblewrap.jpg
vendored
BIN
external/bubblewrap/bubblewrap.jpg
vendored
Binary file not shown.
|
Before Width: | Height: | Size: 39 KiB |
266
external/bubblewrap/bwrap.xml
vendored
266
external/bubblewrap/bwrap.xml
vendored
|
|
@ -1,266 +0,0 @@
|
||||||
<?xml version="1.0"?>
|
|
||||||
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
|
|
||||||
"http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
|
|
||||||
]>
|
|
||||||
<refentry id="bwrap">
|
|
||||||
|
|
||||||
<refentryinfo>
|
|
||||||
<title>bwrap</title>
|
|
||||||
<productname>Project Atomic</productname>
|
|
||||||
<authorgroup>
|
|
||||||
<author>
|
|
||||||
<contrib>Developer</contrib>
|
|
||||||
<firstname>Alexander</firstname>
|
|
||||||
<surname>Larsson</surname>
|
|
||||||
</author>
|
|
||||||
<author>
|
|
||||||
<contrib>Developer</contrib>
|
|
||||||
<firstname>Colin</firstname>
|
|
||||||
<surname>Walters</surname>
|
|
||||||
</author>
|
|
||||||
</authorgroup>
|
|
||||||
</refentryinfo>
|
|
||||||
|
|
||||||
<refmeta>
|
|
||||||
<refentrytitle>bwrap</refentrytitle>
|
|
||||||
<manvolnum>1</manvolnum>
|
|
||||||
<refmiscinfo class="manual">User Commands</refmiscinfo>
|
|
||||||
</refmeta>
|
|
||||||
|
|
||||||
<refnamediv>
|
|
||||||
<refname>bwrap</refname>
|
|
||||||
<refpurpose>container setup utility</refpurpose>
|
|
||||||
</refnamediv>
|
|
||||||
|
|
||||||
<refsynopsisdiv>
|
|
||||||
<cmdsynopsis>
|
|
||||||
<command>bwrap</command>
|
|
||||||
<arg choice="opt" rep="repeat"><replaceable>OPTION</replaceable></arg>
|
|
||||||
<arg choice="opt"><replaceable>COMMAND</replaceable></arg>
|
|
||||||
</cmdsynopsis>
|
|
||||||
</refsynopsisdiv>
|
|
||||||
|
|
||||||
<refsect1><title>Description</title>
|
|
||||||
<para>
|
|
||||||
<command>bwrap</command> is a privileged helper for container setup. You
|
|
||||||
are unlikely to use it directly from the commandline, although that is possible.
|
|
||||||
</para>
|
|
||||||
<para>
|
|
||||||
It works by creating a new, completely empty, filesystem namespace where the root
|
|
||||||
is on a tmpfs that is invisible from the host, and which will be automatically
|
|
||||||
cleaned up when the last process exists. You can then use commandline options to
|
|
||||||
construct the root filesystem and process environment for the command to run in
|
|
||||||
the namespace.
|
|
||||||
</para>
|
|
||||||
<para>
|
|
||||||
By default, <command>bwrap</command> creates a new user namespace for the sandbox.
|
|
||||||
Optionally it also sets up new ipc, pid, network and uts namespaces. The application
|
|
||||||
in the sandbox can be made to run with a different UID and GID.
|
|
||||||
</para>
|
|
||||||
<para>
|
|
||||||
If needed (e.g. when using a PID namespace) <command>bwrap</command>
|
|
||||||
is running a minimal pid 1 process in the sandbox that is
|
|
||||||
responsible for reaping zombies. It also detects when the initial
|
|
||||||
application process (pid 2) dies and reports its exit status back to
|
|
||||||
the original spawner. The pid 1 process exits to clean up the
|
|
||||||
sandbox when there are no other processes in the sandbox left.
|
|
||||||
</para>
|
|
||||||
</refsect1>
|
|
||||||
|
|
||||||
<refsect1><title>Options</title>
|
|
||||||
<para>
|
|
||||||
When options are used multiple times, the last option wins, unless otherwise
|
|
||||||
specified.
|
|
||||||
</para>
|
|
||||||
<para>General options:</para>
|
|
||||||
<variablelist>
|
|
||||||
<varlistentry>
|
|
||||||
<term><option>--help</option></term>
|
|
||||||
<listitem><para>Print help and exit</para></listitem>
|
|
||||||
</varlistentry>
|
|
||||||
<varlistentry>
|
|
||||||
<term><option>--version</option></term>
|
|
||||||
<listitem><para>Print version</para></listitem>
|
|
||||||
</varlistentry>
|
|
||||||
<varlistentry>
|
|
||||||
<term><option>--args <arg choice="plain">FD</arg></option></term>
|
|
||||||
<listitem><para>
|
|
||||||
Parse nul-separated arguments from the given file descriptor.
|
|
||||||
This option can be used multiple times to parse options from
|
|
||||||
multiple sources.
|
|
||||||
</para></listitem>
|
|
||||||
</varlistentry>
|
|
||||||
</variablelist>
|
|
||||||
<para>Options related to kernel namespaces:</para>
|
|
||||||
<variablelist>
|
|
||||||
<varlistentry>
|
|
||||||
<term><option>--share-user</option></term>
|
|
||||||
<listitem><para>Don't create a new user namespace</para></listitem>
|
|
||||||
</varlistentry>
|
|
||||||
<varlistentry>
|
|
||||||
<term><option>--unshare-ipc</option></term>
|
|
||||||
<listitem><para>Create a new ipc namespace</para></listitem>
|
|
||||||
</varlistentry>
|
|
||||||
<varlistentry>
|
|
||||||
<term><option>--unshare-pid</option></term>
|
|
||||||
<listitem><para>Create a new pid namespace</para></listitem>
|
|
||||||
</varlistentry>
|
|
||||||
<varlistentry>
|
|
||||||
<term><option>--unshare-net</option></term>
|
|
||||||
<listitem><para>Create a new network namespace</para></listitem>
|
|
||||||
</varlistentry>
|
|
||||||
<varlistentry>
|
|
||||||
<term><option>--unshare-uts</option></term>
|
|
||||||
<listitem><para>Create a new uts namespace</para></listitem>
|
|
||||||
</varlistentry>
|
|
||||||
<varlistentry>
|
|
||||||
<term><option>--unshare-cgroup</option></term>
|
|
||||||
<listitem><para>Create a new cgroup namespace</para></listitem>
|
|
||||||
</varlistentry>
|
|
||||||
<varlistentry>
|
|
||||||
<term><option>--unshare-cgroup-try</option></term>
|
|
||||||
<listitem><para>Create a new cgroup namespace if possible else skip it</para></listitem>
|
|
||||||
</varlistentry>
|
|
||||||
<varlistentry>
|
|
||||||
<term><option>--uid <arg choice="plain">UID</arg></option></term>
|
|
||||||
<listitem><para>Use a custom user id in the sandbox (incompatible with <option>--share-user</option>)</para></listitem>
|
|
||||||
</varlistentry>
|
|
||||||
<varlistentry>
|
|
||||||
<term><option>--gid <arg choice="plain">GID</arg></option></term>
|
|
||||||
<listitem><para>Use a custom group id in the sandbox (incompatible with <option>--share-user</option>)</para></listitem>
|
|
||||||
</varlistentry>
|
|
||||||
</variablelist>
|
|
||||||
<para>Options about environment setup:</para>
|
|
||||||
<variablelist>
|
|
||||||
<varlistentry>
|
|
||||||
<term><option>--chdir <arg choice="plain">DIR</arg></option></term>
|
|
||||||
<listitem><para>Change directory to <arg choice="plain">DIR</arg></para></listitem>
|
|
||||||
</varlistentry>
|
|
||||||
<varlistentry>
|
|
||||||
<term><option>--setenv <arg choice="plain">VAR</arg> <arg choice="plain">VALUE</arg></option></term>
|
|
||||||
<listitem><para>Set an environment variable</para></listitem>
|
|
||||||
</varlistentry>
|
|
||||||
<varlistentry>
|
|
||||||
<term><option>--unsetenv <arg choice="plain">VAR</arg></option></term>
|
|
||||||
<listitem><para>Unset an environment variable</para></listitem>
|
|
||||||
</varlistentry>
|
|
||||||
</variablelist>
|
|
||||||
<para>Options for monitoring the sandbox from the outside:</para>
|
|
||||||
<variablelist>
|
|
||||||
<varlistentry>
|
|
||||||
<term><option>--lock-file <arg choice="plain">DEST</arg></option></term>
|
|
||||||
<listitem><para>
|
|
||||||
Take a lock on <arg choice="plain">DEST</arg> while the sandbox is running.
|
|
||||||
This option can be used multiple times to take locks on multiple files.
|
|
||||||
</para></listitem>
|
|
||||||
</varlistentry>
|
|
||||||
<varlistentry>
|
|
||||||
<term><option>--sync-fd <arg choice="plain">FD</arg></option></term>
|
|
||||||
<listitem><para>Keep this file descriptor open while the sandbox is running</para></listitem>
|
|
||||||
</varlistentry>
|
|
||||||
</variablelist>
|
|
||||||
<para>
|
|
||||||
Filesystem related options. These are all operations that modify the filesystem directly, or
|
|
||||||
mounts stuff in the filesystem. These are applied in the order they are given as arguments.
|
|
||||||
Any missing parent directories that are required to create a specified destination are
|
|
||||||
automatically created as needed.
|
|
||||||
</para>
|
|
||||||
<variablelist>
|
|
||||||
<varlistentry>
|
|
||||||
<term><option>--bind <arg choice="plain">SRC</arg> <arg choice="plain">DEST</arg></option></term>
|
|
||||||
<listitem><para>Bind mount the host path <arg choice="plain">SRC</arg> on <arg choice="plain">DEST</arg></para></listitem>
|
|
||||||
</varlistentry>
|
|
||||||
<varlistentry>
|
|
||||||
<term><option>--dev-bind <arg choice="plain">SRC</arg> <arg choice="plain">DEST</arg></option></term>
|
|
||||||
<listitem><para>Bind mount the host path <arg choice="plain">SRC</arg> on <arg choice="plain">DEST</arg>, allowing device access</para></listitem>
|
|
||||||
</varlistentry>
|
|
||||||
<varlistentry>
|
|
||||||
<term><option>--ro-bind <arg choice="plain">SRC</arg> <arg choice="plain">DEST</arg></option></term>
|
|
||||||
<listitem><para>Bind mount the host path <arg choice="plain">SRC</arg> readonly on <arg choice="plain">DEST</arg></para></listitem>
|
|
||||||
</varlistentry>
|
|
||||||
<varlistentry>
|
|
||||||
<term><option>--proc <arg choice="plain">DEST</arg></option></term>
|
|
||||||
<listitem><para>Mount procfs on <arg choice="plain">DEST</arg></para></listitem>
|
|
||||||
</varlistentry>
|
|
||||||
<varlistentry>
|
|
||||||
<term><option>--dev <arg choice="plain">DEST</arg></option></term>
|
|
||||||
<listitem><para>Mount new devtmpfs on <arg choice="plain">DEST</arg></para></listitem>
|
|
||||||
</varlistentry>
|
|
||||||
<varlistentry>
|
|
||||||
<term><option>--tmpfs <arg choice="plain">DEST</arg></option></term>
|
|
||||||
<listitem><para>Mount new tmpfs on <arg choice="plain">DEST</arg></para></listitem>
|
|
||||||
</varlistentry>
|
|
||||||
<varlistentry>
|
|
||||||
<term><option>--mqueue <arg choice="plain">DEST</arg></option></term>
|
|
||||||
<listitem><para>Mount new mqueue on <arg choice="plain">DEST</arg></para></listitem>
|
|
||||||
</varlistentry>
|
|
||||||
<varlistentry>
|
|
||||||
<term><option>--dir <arg choice="plain">DEST</arg></option></term>
|
|
||||||
<listitem><para>Create a directory at <arg choice="plain">DEST</arg></para></listitem>
|
|
||||||
</varlistentry>
|
|
||||||
<varlistentry>
|
|
||||||
<term><option>--file <arg choice="plain">FD</arg> <arg choice="plain">DEST</arg></option></term>
|
|
||||||
<listitem><para>Copy from the file descriptor <arg choice="plain">FD</arg> to <arg choice="plain">DEST</arg></para></listitem>
|
|
||||||
</varlistentry>
|
|
||||||
<varlistentry>
|
|
||||||
<term><option>--bind-data <arg choice="plain">FD</arg> <arg choice="plain">DEST</arg></option></term>
|
|
||||||
<listitem><para>Copy from the file descriptor <arg choice="plain">FD</arg> to a file which is bind-mounted on <arg choice="plain">DEST</arg></para></listitem>
|
|
||||||
</varlistentry>
|
|
||||||
<varlistentry>
|
|
||||||
<term><option>--symlink <arg choice="plain">SRC</arg> <arg choice="plain">DEST</arg></option></term>
|
|
||||||
<listitem><para>Create a symlink at <arg choice="plain">DEST</arg> with target <arg choice="plain">SRC</arg></para></listitem>
|
|
||||||
</varlistentry>
|
|
||||||
</variablelist>
|
|
||||||
<para>Lockdown options:</para>
|
|
||||||
<variablelist>
|
|
||||||
<varlistentry>
|
|
||||||
<term><option>--seccomp <arg choice="plain">FD</arg></option></term>
|
|
||||||
<listitem><para>
|
|
||||||
Load and use seccomp rules from <arg choice="plain">FD</arg>.
|
|
||||||
The rules need to be in the form of a compiled eBPF program,
|
|
||||||
as generated by seccomp_export_bpf.
|
|
||||||
</para></listitem>
|
|
||||||
</varlistentry>
|
|
||||||
<varlistentry>
|
|
||||||
<term><option>--exec-label <arg choice="plain">LABEL</arg></option></term>
|
|
||||||
<listitem><para>
|
|
||||||
Exec Label from the sandbox. On an SELinux system you can specify the SELinux
|
|
||||||
context for the sandbox process(s).
|
|
||||||
</para></listitem>
|
|
||||||
</varlistentry>
|
|
||||||
<varlistentry>
|
|
||||||
<term><option>--file-label <arg choice="plain">LABEL</arg></option></term>
|
|
||||||
<listitem><para>
|
|
||||||
File label for temporary sandbox content. On an SELinux system you can specify
|
|
||||||
the SELinux context for the sandbox content.
|
|
||||||
</para></listitem>
|
|
||||||
</varlistentry>
|
|
||||||
</variablelist>
|
|
||||||
</refsect1>
|
|
||||||
|
|
||||||
<refsect1>
|
|
||||||
<title>Environment</title>
|
|
||||||
|
|
||||||
<variablelist>
|
|
||||||
<varlistentry>
|
|
||||||
<term><envar>HOME</envar></term>
|
|
||||||
<listitem><para>
|
|
||||||
Used as the cwd in the sandbox if <option>--cwd</option> has not been
|
|
||||||
explicitly specified and the current cwd is not present inside the sandbox.
|
|
||||||
The <option>--setenv</option> option can be used to override the value
|
|
||||||
that is used here.
|
|
||||||
</para></listitem>
|
|
||||||
</varlistentry>
|
|
||||||
</variablelist>
|
|
||||||
</refsect1>
|
|
||||||
|
|
||||||
<refsect1>
|
|
||||||
<title>Exit status</title>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
The <command>bwrap</command> command returns the exit status of the
|
|
||||||
initial application process (pid 2 in the sandbox).
|
|
||||||
</para>
|
|
||||||
</refsect1>
|
|
||||||
|
|
||||||
</refentry>
|
|
||||||
52
external/bubblewrap/completions/bash/bwrap
vendored
52
external/bubblewrap/completions/bash/bwrap
vendored
|
|
@ -1,52 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
#
|
|
||||||
# bash completion file for bubblewrap commands
|
|
||||||
#
|
|
||||||
|
|
||||||
_bwrap() {
|
|
||||||
local cur prev words cword
|
|
||||||
_init_completion || return
|
|
||||||
|
|
||||||
local boolean_options="
|
|
||||||
--help
|
|
||||||
--share-user
|
|
||||||
--unshare-ipc
|
|
||||||
--unshare-net
|
|
||||||
--unshare-pid
|
|
||||||
--unshare-uts
|
|
||||||
--version
|
|
||||||
"
|
|
||||||
|
|
||||||
local options_with_args="
|
|
||||||
$boolean_optons
|
|
||||||
--args
|
|
||||||
--bind
|
|
||||||
--bind-data
|
|
||||||
--chdir
|
|
||||||
--dev
|
|
||||||
--dev-bind
|
|
||||||
--dir
|
|
||||||
--exec-label
|
|
||||||
--file
|
|
||||||
--file-label
|
|
||||||
--gid
|
|
||||||
--lock-file
|
|
||||||
--proc
|
|
||||||
--ro-bind
|
|
||||||
--seccomp
|
|
||||||
--setenv
|
|
||||||
--symlink
|
|
||||||
--sync-fd
|
|
||||||
--uid
|
|
||||||
--unsetenv
|
|
||||||
--seccomp
|
|
||||||
--symlink
|
|
||||||
"
|
|
||||||
|
|
||||||
if [[ "$cur" == -* ]]; then
|
|
||||||
COMPREPLY=( $( compgen -W "$boolean_options $options_with_args" -- "$cur" ) )
|
|
||||||
fi
|
|
||||||
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
complete -F _bwrap bwrap
|
|
||||||
5
external/bubblewrap/config.h
vendored
5
external/bubblewrap/config.h
vendored
|
|
@ -1,5 +0,0 @@
|
||||||
#ifndef _GNU_SOURCE
|
|
||||||
# define _GNU_SOURCE 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define PACKAGE_STRING "bubblewrap 0.1"
|
|
||||||
103
external/bubblewrap/configure.ac
vendored
103
external/bubblewrap/configure.ac
vendored
|
|
@ -1,103 +0,0 @@
|
||||||
AC_PREREQ([2.63])
|
|
||||||
AC_INIT([bubblewrap], [0.1], [alexl@redhat.com])
|
|
||||||
AC_CONFIG_HEADER([config.h])
|
|
||||||
AC_CONFIG_MACRO_DIR([m4])
|
|
||||||
AC_CONFIG_AUX_DIR([build-aux])
|
|
||||||
|
|
||||||
AC_USE_SYSTEM_EXTENSIONS
|
|
||||||
|
|
||||||
AM_INIT_AUTOMAKE([1.11 -Wno-portability foreign no-define tar-ustar no-dist-gzip dist-xz])
|
|
||||||
AM_MAINTAINER_MODE([enable])
|
|
||||||
AM_SILENT_RULES([yes])
|
|
||||||
|
|
||||||
AC_SYS_LARGEFILE
|
|
||||||
|
|
||||||
AC_PROG_CC
|
|
||||||
AM_PROG_CC_C_O
|
|
||||||
|
|
||||||
AC_CHECK_HEADERS([sys/capability.h], [], [AC_MSG_ERROR([*** POSIX caps headers not found])])
|
|
||||||
|
|
||||||
AC_ARG_ENABLE(man,
|
|
||||||
[AS_HELP_STRING([--enable-man],
|
|
||||||
[generate man pages [default=auto]])],,
|
|
||||||
enable_man=maybe)
|
|
||||||
|
|
||||||
AS_IF([test "$enable_man" != no], [
|
|
||||||
AC_PATH_PROG([XSLTPROC], [xsltproc], [])
|
|
||||||
AS_IF([test -z "$XSLTPROC"], [
|
|
||||||
AS_IF([test "$enable_man" = yes], [
|
|
||||||
AC_MSG_ERROR([xsltproc is required for --enable-man])
|
|
||||||
])
|
|
||||||
enable_man=no
|
|
||||||
], [
|
|
||||||
enable_man=yes
|
|
||||||
])
|
|
||||||
])
|
|
||||||
AM_CONDITIONAL(ENABLE_MAN, test "$enable_man" != no)
|
|
||||||
|
|
||||||
AC_ARG_WITH([bash-completion-dir],
|
|
||||||
AS_HELP_STRING([--with-bash-completion-dir[=PATH]],
|
|
||||||
[Install the bash auto-completion script in this directory. @<:@default=yes@:>@]),
|
|
||||||
[],
|
|
||||||
[with_bash_completion_dir=yes])
|
|
||||||
|
|
||||||
if test "x$with_bash_completion_dir" = "xyes"; then
|
|
||||||
PKG_CHECK_MODULES([BASH_COMPLETION], [bash-completion >= 2.0],
|
|
||||||
[BASH_COMPLETION_DIR="`pkg-config --variable=completionsdir bash-completion`"],
|
|
||||||
[BASH_COMPLETION_DIR="$datadir/bash-completion/completions"])
|
|
||||||
else
|
|
||||||
BASH_COMPLETION_DIR="$with_bash_completion_dir"
|
|
||||||
fi
|
|
||||||
|
|
||||||
AC_SUBST([BASH_COMPLETION_DIR])
|
|
||||||
AM_CONDITIONAL([ENABLE_BASH_COMPLETION],[test "x$with_bash_completion_dir" != "xno"])
|
|
||||||
# ------------------------------------------------------------------------------
|
|
||||||
have_selinux=no
|
|
||||||
AC_ARG_ENABLE(selinux, AS_HELP_STRING([--disable-selinux], [Disable optional SELINUX support]))
|
|
||||||
if test "x$enable_selinux" != "xno"; then
|
|
||||||
PKG_CHECK_MODULES([SELINUX], [libselinux >= 2.1.9],
|
|
||||||
[AC_DEFINE(HAVE_SELINUX, 1, [Define if SELinux is available])
|
|
||||||
have_selinux=yes
|
|
||||||
M4_DEFINES="$M4_DEFINES -DHAVE_SELINUX"],
|
|
||||||
[have_selinux=no])
|
|
||||||
if test "x$have_selinux" = xno -a "x$enable_selinux" = xyes; then
|
|
||||||
AC_MSG_ERROR([*** SELinux support requested but libraries not found])
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
AM_CONDITIONAL(HAVE_SELINUX, [test "$have_selinux" = "yes"])
|
|
||||||
|
|
||||||
changequote(,)dnl
|
|
||||||
if test "x$GCC" = "xyes"; then
|
|
||||||
WARN_CFLAGS="-Wall -Werror=missing-prototypes"
|
|
||||||
fi
|
|
||||||
changequote([,])dnl
|
|
||||||
AC_SUBST(WARN_CFLAGS)
|
|
||||||
|
|
||||||
AC_ARG_WITH(priv-mode,
|
|
||||||
AS_HELP_STRING([--with-priv-mode=setuid/caps/none],
|
|
||||||
[How to set privilege-raising during make install)]),
|
|
||||||
[],
|
|
||||||
[with_priv_mode="none"])
|
|
||||||
|
|
||||||
AM_CONDITIONAL(PRIV_MODE_FILECAPS, test "x$with_priv_mode" = "xcaps")
|
|
||||||
AM_CONDITIONAL(PRIV_MODE_SETUID, test "x$with_priv_mode" = "xsetuid")
|
|
||||||
|
|
||||||
AC_ARG_ENABLE(sudo,
|
|
||||||
AS_HELP_STRING([--enable-sudo],[Use sudo to set privileged mode on binaries during install (only needed if --with-priv-mode used)]),
|
|
||||||
[SUDO_BIN="sudo"], [SUDO_BIN=""])
|
|
||||||
AC_SUBST([SUDO_BIN])
|
|
||||||
|
|
||||||
AC_CONFIG_FILES([
|
|
||||||
Makefile
|
|
||||||
])
|
|
||||||
AC_OUTPUT
|
|
||||||
|
|
||||||
echo "
|
|
||||||
bubblewrap $VERSION
|
|
||||||
===================
|
|
||||||
|
|
||||||
man pages (xsltproc): $enable_man
|
|
||||||
SELinux: $have_selinux
|
|
||||||
setuid mode on make install: $with_priv_mode
|
|
||||||
mysteriously satisfying to pop: yes"
|
|
||||||
echo ""
|
|
||||||
21
external/bubblewrap/demos/bubblewrap-shell.sh
vendored
21
external/bubblewrap/demos/bubblewrap-shell.sh
vendored
|
|
@ -1,21 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
# Use bubblewrap to run /bin/sh in the host's rootfs.
|
|
||||||
set -euo pipefail
|
|
||||||
(exec bwrap --ro-bind /usr /usr \
|
|
||||||
--dir /tmp \
|
|
||||||
--proc /proc \
|
|
||||||
--dev /dev \
|
|
||||||
--ro-bind /etc/resolv.conf /etc/resolv.conf \
|
|
||||||
--symlink usr/lib /lib \
|
|
||||||
--symlink usr/lib64 /lib64 \
|
|
||||||
--symlink usr/bin /bin \
|
|
||||||
--symlink usr/sbin /sbin \
|
|
||||||
--chdir / \
|
|
||||||
--unshare-pid \
|
|
||||||
--dir /run/user/$(id -u) \
|
|
||||||
--setenv XDG_RUNTIME_DIR "/run/user/`id -u`" \
|
|
||||||
--file 11 /etc/passwd \
|
|
||||||
--file 12 /etc/group \
|
|
||||||
/bin/sh) \
|
|
||||||
11< <(getent passwd $UID 65534) \
|
|
||||||
12< <(getent group $(id -g) 65534)
|
|
||||||
65
external/bubblewrap/demos/xdg-app-run.sh
vendored
65
external/bubblewrap/demos/xdg-app-run.sh
vendored
|
|
@ -1,65 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
# For this to work you first have to run these commands:
|
|
||||||
# curl -O http://sdk.gnome.org/nightly/keys/nightly.gpg
|
|
||||||
# xdg-app --user remote-add --gpg-key=nightly.gpg gnome-nightly http://sdk.gnome.org/nightly/repo/
|
|
||||||
# xdg-app --user install gnome-nightly org.gnome.Platform
|
|
||||||
# xdg-app --user install gnome-nightly org.gnome.Weather
|
|
||||||
|
|
||||||
mkdir -p ~/.var/app/org.gnome.Weather/cache ~/.var/app/org.gnome.Weather/config ~/.var/app/org.gnome.Weather/data
|
|
||||||
|
|
||||||
(
|
|
||||||
exec bwrap \
|
|
||||||
--ro-bind ~/.local/share/xdg-app/runtime/org.gnome.Platform/x86_64/master/active/files /usr \
|
|
||||||
--lock-file /usr/.ref \
|
|
||||||
--ro-bind ~/.local/share/xdg-app/app/org.gnome.Weather/x86_64/master/active/files/ /app \
|
|
||||||
--lock-file /app/.ref \
|
|
||||||
--dev /dev \
|
|
||||||
--proc /proc \
|
|
||||||
--dir /tmp \
|
|
||||||
--symlink /tmp /var/tmp \
|
|
||||||
--symlink /run /var/run \
|
|
||||||
--symlink usr/lib /lib \
|
|
||||||
--symlink usr/lib64 /lib64 \
|
|
||||||
--symlink usr/bin /bin \
|
|
||||||
--symlink usr/sbin /sbin \
|
|
||||||
--symlink usr/etc /etc \
|
|
||||||
--dir /run/user/`id -u` \
|
|
||||||
--ro-bind /etc/machine-id /usr/etc/machine-id \
|
|
||||||
--ro-bind /etc/resolv.conf /run/host/monitor/resolv.conf \
|
|
||||||
--ro-bind /sys/block /sys/block \
|
|
||||||
--ro-bind /sys/bus /sys/bus \
|
|
||||||
--ro-bind /sys/class /sys/class \
|
|
||||||
--ro-bind /sys/dev /sys/dev \
|
|
||||||
--ro-bind /sys/devices /sys/devices \
|
|
||||||
--dev-bind /dev/dri /dev/dri \
|
|
||||||
--bind /tmp/.X11-unix/X0 /tmp/.X11-unix/X99 \
|
|
||||||
--bind ~/.var/app/org.gnome.Weather ~/.var/app/org.gnome.Weather \
|
|
||||||
--bind ~/.config/dconf ~/.config/dconf \
|
|
||||||
--bind /run/user/`id -u`/dconf /run/user/`id -u`/dconf \
|
|
||||||
--unshare-pid \
|
|
||||||
--setenv XDG_RUNTIME_DIR "/run/user/`id -u`" \
|
|
||||||
--setenv DISPLAY :99 \
|
|
||||||
--setenv GI_TYPELIB_PATH /app/lib/girepository-1.0 \
|
|
||||||
--setenv GST_PLUGIN_PATH /app/lib/gstreamer-1.0 \
|
|
||||||
--setenv LD_LIBRARY_PATH /app/lib:/usr/lib/GL \
|
|
||||||
--setenv DCONF_USER_CONFIG_DIR .config/dconf \
|
|
||||||
--setenv PATH /app/bin:/usr/bin \
|
|
||||||
--setenv XDG_CONFIG_DIRS /app/etc/xdg:/etc/xdg \
|
|
||||||
--setenv XDG_DATA_DIRS /app/share:/usr/share \
|
|
||||||
--setenv SHELL /bin/sh \
|
|
||||||
--setenv XDG_CACHE_HOME ~/.var/app/org.gnome.Weather/cache \
|
|
||||||
--setenv XDG_CONFIG_HOME ~/.var/app/org.gnome.Weather/config \
|
|
||||||
--setenv XDG_DATA_HOME ~/.var/app/org.gnome.Weather/data \
|
|
||||||
--file 10 /run/user/`id -u`/xdg-app-info \
|
|
||||||
--bind-data 11 /usr/etc/passwd \
|
|
||||||
--bind-data 12 /usr/etc/group \
|
|
||||||
--seccomp 13 \
|
|
||||||
/bin/sh) \
|
|
||||||
11< <(getent passwd $UID 65534 ) \
|
|
||||||
12< <(getent group $(id -g) 65534) \
|
|
||||||
13< `dirname $0`/xdg-app.bpf \
|
|
||||||
10<<EOF
|
|
||||||
[Application]
|
|
||||||
name=org.gnome.Weather
|
|
||||||
runtime=runtime/org.gnome.Platform/x86_64/master
|
|
||||||
EOF
|
|
||||||
BIN
external/bubblewrap/demos/xdg-app.bpf
vendored
BIN
external/bubblewrap/demos/xdg-app.bpf
vendored
Binary file not shown.
348
external/bubblewrap/git.mk
vendored
348
external/bubblewrap/git.mk
vendored
|
|
@ -1,348 +0,0 @@
|
||||||
# git.mk, a small Makefile to autogenerate .gitignore files
|
|
||||||
# for autotools-based projects.
|
|
||||||
#
|
|
||||||
# Copyright 2009, Red Hat, Inc.
|
|
||||||
# Copyright 2010,2011,2012,2013 Behdad Esfahbod
|
|
||||||
# Written by Behdad Esfahbod
|
|
||||||
#
|
|
||||||
# Copying and distribution of this file, with or without modification,
|
|
||||||
# is permitted in any medium without royalty provided the copyright
|
|
||||||
# notice and this notice are preserved.
|
|
||||||
#
|
|
||||||
# The latest version of this file can be downloaded from:
|
|
||||||
GIT_MK_URL = https://raw.githubusercontent.com/behdad/git.mk/master/git.mk
|
|
||||||
#
|
|
||||||
# Bugs, etc, should be reported upstream at:
|
|
||||||
# https://github.com/behdad/git.mk
|
|
||||||
#
|
|
||||||
# To use in your project, import this file in your git repo's toplevel,
|
|
||||||
# then do "make -f git.mk". This modifies all Makefile.am files in
|
|
||||||
# your project to -include git.mk. Remember to add that line to new
|
|
||||||
# Makefile.am files you create in your project, or just rerun the
|
|
||||||
# "make -f git.mk".
|
|
||||||
#
|
|
||||||
# This enables automatic .gitignore generation. If you need to ignore
|
|
||||||
# more files, add them to the GITIGNOREFILES variable in your Makefile.am.
|
|
||||||
# But think twice before doing that. If a file has to be in .gitignore,
|
|
||||||
# chances are very high that it's a generated file and should be in one
|
|
||||||
# of MOSTLYCLEANFILES, CLEANFILES, DISTCLEANFILES, or MAINTAINERCLEANFILES.
|
|
||||||
#
|
|
||||||
# The only case that you need to manually add a file to GITIGNOREFILES is
|
|
||||||
# when remove files in one of mostlyclean-local, clean-local, distclean-local,
|
|
||||||
# or maintainer-clean-local make targets.
|
|
||||||
#
|
|
||||||
# Note that for files like editor backup, etc, there are better places to
|
|
||||||
# ignore them. See "man gitignore".
|
|
||||||
#
|
|
||||||
# If "make maintainer-clean" removes the files but they are not recognized
|
|
||||||
# by this script (that is, if "git status" shows untracked files still), send
|
|
||||||
# me the output of "git status" as well as your Makefile.am and Makefile for
|
|
||||||
# the directories involved and I'll diagnose.
|
|
||||||
#
|
|
||||||
# For a list of toplevel files that should be in MAINTAINERCLEANFILES, see
|
|
||||||
# Makefile.am.sample in the git.mk git repo.
|
|
||||||
#
|
|
||||||
# Don't EXTRA_DIST this file. It is supposed to only live in git clones,
|
|
||||||
# not tarballs. It serves no useful purpose in tarballs and clutters the
|
|
||||||
# build dir.
|
|
||||||
#
|
|
||||||
# This file knows how to handle autoconf, automake, libtool, gtk-doc,
|
|
||||||
# gnome-doc-utils, yelp.m4, mallard, intltool, gsettings, dejagnu, appdata,
|
|
||||||
# appstream.
|
|
||||||
#
|
|
||||||
# This makefile provides the following targets:
|
|
||||||
#
|
|
||||||
# - all: "make all" will build all gitignore files.
|
|
||||||
# - gitignore: makes all gitignore files in the current dir and subdirs.
|
|
||||||
# - .gitignore: make gitignore file for the current dir.
|
|
||||||
# - gitignore-recurse: makes all gitignore files in the subdirs.
|
|
||||||
#
|
|
||||||
# KNOWN ISSUES:
|
|
||||||
#
|
|
||||||
# - Recursive configure doesn't work as $(top_srcdir)/git.mk inside the
|
|
||||||
# submodule doesn't find us. If you have configure.{in,ac} files in
|
|
||||||
# subdirs, add a proxy git.mk file in those dirs that simply does:
|
|
||||||
# "include $(top_srcdir)/../git.mk". Add more ..'s to your taste.
|
|
||||||
# And add those files to git. See vte/gnome-pty-helper/git.mk for
|
|
||||||
# example.
|
|
||||||
#
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
# Variables user modules may want to add to toplevel MAINTAINERCLEANFILES:
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
#
|
|
||||||
# Most autotools-using modules should be fine including this variable in their
|
|
||||||
# toplevel MAINTAINERCLEANFILES:
|
|
||||||
GITIGNORE_MAINTAINERCLEANFILES_TOPLEVEL = \
|
|
||||||
$(srcdir)/aclocal.m4 \
|
|
||||||
$(srcdir)/autoscan.log \
|
|
||||||
$(srcdir)/configure.scan \
|
|
||||||
`AUX_DIR=$(srcdir)/$$(cd $(top_srcdir); $(AUTOCONF) --trace 'AC_CONFIG_AUX_DIR:$$1' ./configure.ac); \
|
|
||||||
test "x$$AUX_DIR" = "x$(srcdir)/" && AUX_DIR=$(srcdir); \
|
|
||||||
for x in \
|
|
||||||
ar-lib \
|
|
||||||
compile \
|
|
||||||
config.guess \
|
|
||||||
config.sub \
|
|
||||||
depcomp \
|
|
||||||
install-sh \
|
|
||||||
ltmain.sh \
|
|
||||||
missing \
|
|
||||||
mkinstalldirs \
|
|
||||||
test-driver \
|
|
||||||
ylwrap \
|
|
||||||
; do echo "$$AUX_DIR/$$x"; done` \
|
|
||||||
`cd $(top_srcdir); $(AUTOCONF) --trace 'AC_CONFIG_HEADERS:$$1' ./configure.ac | \
|
|
||||||
head -n 1 | while read f; do echo "$(srcdir)/$$f.in"; done`
|
|
||||||
#
|
|
||||||
# All modules should also be fine including the following variable, which
|
|
||||||
# removes automake-generated Makefile.in files:
|
|
||||||
GITIGNORE_MAINTAINERCLEANFILES_MAKEFILE_IN = \
|
|
||||||
`cd $(top_srcdir); $(AUTOCONF) --trace 'AC_CONFIG_FILES:$$1' ./configure.ac | \
|
|
||||||
while read f; do \
|
|
||||||
case $$f in Makefile|*/Makefile) \
|
|
||||||
test -f "$(srcdir)/$$f.am" && echo "$(srcdir)/$$f.in";; esac; \
|
|
||||||
done`
|
|
||||||
#
|
|
||||||
# Modules that use libtool and use AC_CONFIG_MACRO_DIR() may also include this,
|
|
||||||
# though it's harmless to include regardless.
|
|
||||||
GITIGNORE_MAINTAINERCLEANFILES_M4_LIBTOOL = \
|
|
||||||
`MACRO_DIR=$(srcdir)/$$(cd $(top_srcdir); $(AUTOCONF) --trace 'AC_CONFIG_MACRO_DIR:$$1' ./configure.ac); \
|
|
||||||
if test "x$$MACRO_DIR" != "x$(srcdir)/"; then \
|
|
||||||
for x in \
|
|
||||||
libtool.m4 \
|
|
||||||
ltoptions.m4 \
|
|
||||||
ltsugar.m4 \
|
|
||||||
ltversion.m4 \
|
|
||||||
lt~obsolete.m4 \
|
|
||||||
; do echo "$$MACRO_DIR/$$x"; done; \
|
|
||||||
fi`
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
# Default rule is to install ourselves in all Makefile.am files:
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
git-all: git-mk-install
|
|
||||||
|
|
||||||
git-mk-install:
|
|
||||||
@echo "Installing git makefile"
|
|
||||||
@any_failed=; \
|
|
||||||
find "`test -z "$(top_srcdir)" && echo . || echo "$(top_srcdir)"`" -name Makefile.am | while read x; do \
|
|
||||||
if grep 'include .*/git.mk' $$x >/dev/null; then \
|
|
||||||
echo "$$x already includes git.mk"; \
|
|
||||||
else \
|
|
||||||
failed=; \
|
|
||||||
echo "Updating $$x"; \
|
|
||||||
{ cat $$x; \
|
|
||||||
echo ''; \
|
|
||||||
echo '-include $$(top_srcdir)/git.mk'; \
|
|
||||||
} > $$x.tmp || failed=1; \
|
|
||||||
if test x$$failed = x; then \
|
|
||||||
mv $$x.tmp $$x || failed=1; \
|
|
||||||
fi; \
|
|
||||||
if test x$$failed = x; then : else \
|
|
||||||
echo "Failed updating $$x"; >&2 \
|
|
||||||
any_failed=1; \
|
|
||||||
fi; \
|
|
||||||
fi; done; test -z "$$any_failed"
|
|
||||||
|
|
||||||
git-mk-update:
|
|
||||||
wget $(GIT_MK_URL) -O $(top_srcdir)/git.mk
|
|
||||||
|
|
||||||
.PHONY: git-all git-mk-install git-mk-update
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
# Actual .gitignore generation:
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
$(srcdir)/.gitignore: Makefile.am $(top_srcdir)/git.mk
|
|
||||||
@echo "git.mk: Generating $@"
|
|
||||||
@{ \
|
|
||||||
if test "x$(DOC_MODULE)" = x -o "x$(DOC_MAIN_SGML_FILE)" = x; then :; else \
|
|
||||||
for x in \
|
|
||||||
$(DOC_MODULE)-decl-list.txt \
|
|
||||||
$(DOC_MODULE)-decl.txt \
|
|
||||||
tmpl/$(DOC_MODULE)-unused.sgml \
|
|
||||||
"tmpl/*.bak" \
|
|
||||||
$(REPORT_FILES) \
|
|
||||||
$(DOC_MODULE).pdf \
|
|
||||||
xml html \
|
|
||||||
; do echo "/$$x"; done; \
|
|
||||||
FLAVOR=$$(cd $(top_srcdir); $(AUTOCONF) --trace 'GTK_DOC_CHECK:$$2' ./configure.ac); \
|
|
||||||
case $$FLAVOR in *no-tmpl*) echo /tmpl;; esac; \
|
|
||||||
if echo "$(SCAN_OPTIONS)" | grep -q "\-\-rebuild-types"; then \
|
|
||||||
echo "/$(DOC_MODULE).types"; \
|
|
||||||
fi; \
|
|
||||||
if echo "$(SCAN_OPTIONS)" | grep -q "\-\-rebuild-sections"; then \
|
|
||||||
echo "/$(DOC_MODULE)-sections.txt"; \
|
|
||||||
fi; \
|
|
||||||
if test "$(abs_srcdir)" != "$(abs_builddir)" ; then \
|
|
||||||
for x in \
|
|
||||||
$(SETUP_FILES) \
|
|
||||||
$(DOC_MODULE).types \
|
|
||||||
; do echo "/$$x"; done; \
|
|
||||||
fi; \
|
|
||||||
fi; \
|
|
||||||
if test "x$(DOC_MODULE)$(DOC_ID)" = x -o "x$(DOC_LINGUAS)" = x; then :; else \
|
|
||||||
for lc in $(DOC_LINGUAS); do \
|
|
||||||
for x in \
|
|
||||||
$(if $(DOC_MODULE),$(DOC_MODULE).xml) \
|
|
||||||
$(DOC_PAGES) \
|
|
||||||
$(DOC_INCLUDES) \
|
|
||||||
; do echo "/$$lc/$$x"; done; \
|
|
||||||
done; \
|
|
||||||
for x in \
|
|
||||||
$(_DOC_OMF_ALL) \
|
|
||||||
$(_DOC_DSK_ALL) \
|
|
||||||
$(_DOC_HTML_ALL) \
|
|
||||||
$(_DOC_MOFILES) \
|
|
||||||
$(DOC_H_FILE) \
|
|
||||||
"*/.xml2po.mo" \
|
|
||||||
"*/*.omf.out" \
|
|
||||||
; do echo /$$x; done; \
|
|
||||||
fi; \
|
|
||||||
if test "x$(HELP_ID)" = x -o "x$(HELP_LINGUAS)" = x; then :; else \
|
|
||||||
for lc in $(HELP_LINGUAS); do \
|
|
||||||
for x in \
|
|
||||||
$(HELP_FILES) \
|
|
||||||
"$$lc.stamp" \
|
|
||||||
"$$lc.mo" \
|
|
||||||
; do echo "/$$lc/$$x"; done; \
|
|
||||||
done; \
|
|
||||||
fi; \
|
|
||||||
if test "x$(gsettings_SCHEMAS)" = x; then :; else \
|
|
||||||
for x in \
|
|
||||||
$(gsettings_SCHEMAS:.xml=.valid) \
|
|
||||||
$(gsettings__enum_file) \
|
|
||||||
; do echo "/$$x"; done; \
|
|
||||||
fi; \
|
|
||||||
if test "x$(appdata_XML)" = x; then :; else \
|
|
||||||
for x in \
|
|
||||||
$(appdata_XML:.xml=.valid) \
|
|
||||||
; do echo "/$$x"; done; \
|
|
||||||
fi; \
|
|
||||||
if test "x$(appstream_XML)" = x; then :; else \
|
|
||||||
for x in \
|
|
||||||
$(appstream_XML:.xml=.valid) \
|
|
||||||
; do echo "/$$x"; done; \
|
|
||||||
fi; \
|
|
||||||
if test -f $(srcdir)/po/Makefile.in.in; then \
|
|
||||||
for x in \
|
|
||||||
po/Makefile.in.in \
|
|
||||||
po/Makefile.in.in~ \
|
|
||||||
po/Makefile.in \
|
|
||||||
po/Makefile \
|
|
||||||
po/Makevars.template \
|
|
||||||
po/POTFILES \
|
|
||||||
po/Rules-quot \
|
|
||||||
po/stamp-it \
|
|
||||||
po/stamp-po \
|
|
||||||
po/.intltool-merge-cache \
|
|
||||||
"po/*.gmo" \
|
|
||||||
"po/*.header" \
|
|
||||||
"po/*.mo" \
|
|
||||||
"po/*.sed" \
|
|
||||||
"po/*.sin" \
|
|
||||||
po/$(GETTEXT_PACKAGE).pot \
|
|
||||||
intltool-extract.in \
|
|
||||||
intltool-merge.in \
|
|
||||||
intltool-update.in \
|
|
||||||
; do echo "/$$x"; done; \
|
|
||||||
fi; \
|
|
||||||
if test -f $(srcdir)/configure; then \
|
|
||||||
for x in \
|
|
||||||
autom4te.cache \
|
|
||||||
configure \
|
|
||||||
config.h \
|
|
||||||
stamp-h1 \
|
|
||||||
libtool \
|
|
||||||
config.lt \
|
|
||||||
; do echo "/$$x"; done; \
|
|
||||||
fi; \
|
|
||||||
if test "x$(DEJATOOL)" = x; then :; else \
|
|
||||||
for x in \
|
|
||||||
$(DEJATOOL) \
|
|
||||||
; do echo "/$$x.sum"; echo "/$$x.log"; done; \
|
|
||||||
echo /site.exp; \
|
|
||||||
fi; \
|
|
||||||
if test "x$(am__dirstamp)" = x; then :; else \
|
|
||||||
echo "$(am__dirstamp)"; \
|
|
||||||
fi; \
|
|
||||||
if test "x$(LTCOMPILE)" = x -a "x$(LTCXXCOMPILE)" = x -a "x$(GTKDOC_RUN)" = x; then :; else \
|
|
||||||
for x in \
|
|
||||||
"*.lo" \
|
|
||||||
".libs" "_libs" \
|
|
||||||
; do echo "$$x"; done; \
|
|
||||||
fi; \
|
|
||||||
for x in \
|
|
||||||
.gitignore \
|
|
||||||
$(GITIGNOREFILES) \
|
|
||||||
$(CLEANFILES) \
|
|
||||||
$(PROGRAMS) $(check_PROGRAMS) $(EXTRA_PROGRAMS) \
|
|
||||||
$(LIBRARIES) $(check_LIBRARIES) $(EXTRA_LIBRARIES) \
|
|
||||||
$(LTLIBRARIES) $(check_LTLIBRARIES) $(EXTRA_LTLIBRARIES) \
|
|
||||||
so_locations \
|
|
||||||
$(MOSTLYCLEANFILES) \
|
|
||||||
$(TEST_LOGS) \
|
|
||||||
$(TEST_LOGS:.log=.trs) \
|
|
||||||
$(TEST_SUITE_LOG) \
|
|
||||||
$(TESTS:=.test) \
|
|
||||||
"*.gcda" \
|
|
||||||
"*.gcno" \
|
|
||||||
$(DISTCLEANFILES) \
|
|
||||||
$(am__CONFIG_DISTCLEAN_FILES) \
|
|
||||||
$(CONFIG_CLEAN_FILES) \
|
|
||||||
TAGS ID GTAGS GRTAGS GSYMS GPATH tags \
|
|
||||||
"*.tab.c" \
|
|
||||||
$(MAINTAINERCLEANFILES) \
|
|
||||||
$(BUILT_SOURCES) \
|
|
||||||
$(patsubst %.vala,%.c,$(filter %.vala,$(SOURCES))) \
|
|
||||||
$(filter %_vala.stamp,$(DIST_COMMON)) \
|
|
||||||
$(filter %.vapi,$(DIST_COMMON)) \
|
|
||||||
$(filter $(addprefix %,$(notdir $(patsubst %.vapi,%.h,$(filter %.vapi,$(DIST_COMMON))))),$(DIST_COMMON)) \
|
|
||||||
Makefile \
|
|
||||||
Makefile.in \
|
|
||||||
"*.orig" \
|
|
||||||
"*.rej" \
|
|
||||||
"*.bak" \
|
|
||||||
"*~" \
|
|
||||||
".*.sw[nop]" \
|
|
||||||
".dirstamp" \
|
|
||||||
; do echo "/$$x"; done; \
|
|
||||||
for x in \
|
|
||||||
"*.$(OBJEXT)" \
|
|
||||||
$(DEPDIR) \
|
|
||||||
; do echo "$$x"; done; \
|
|
||||||
} | \
|
|
||||||
sed "s@^/`echo "$(srcdir)" | sed 's/\(.\)/[\1]/g'`/@/@" | \
|
|
||||||
sed 's@/[.]/@/@g' | \
|
|
||||||
LC_ALL=C sort | uniq > $@.tmp && \
|
|
||||||
mv $@.tmp $@;
|
|
||||||
|
|
||||||
all: $(srcdir)/.gitignore gitignore-recurse-maybe
|
|
||||||
gitignore: $(srcdir)/.gitignore gitignore-recurse
|
|
||||||
|
|
||||||
gitignore-recurse-maybe:
|
|
||||||
@for subdir in $(DIST_SUBDIRS); do \
|
|
||||||
case " $(SUBDIRS) " in \
|
|
||||||
*" $$subdir "*) :;; \
|
|
||||||
*) test "$$subdir" = . -o -e "$$subdir/.git" || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) gitignore || echo "Skipping $$subdir");; \
|
|
||||||
esac; \
|
|
||||||
done
|
|
||||||
gitignore-recurse:
|
|
||||||
@for subdir in $(DIST_SUBDIRS); do \
|
|
||||||
test "$$subdir" = . -o -e "$$subdir/.git" || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) gitignore || echo "Skipping $$subdir"); \
|
|
||||||
done
|
|
||||||
|
|
||||||
maintainer-clean: gitignore-clean
|
|
||||||
gitignore-clean:
|
|
||||||
-rm -f $(srcdir)/.gitignore
|
|
||||||
|
|
||||||
.PHONY: gitignore-clean gitignore gitignore-recurse gitignore-recurse-maybe
|
|
||||||
200
external/bubblewrap/network.c
vendored
200
external/bubblewrap/network.c
vendored
|
|
@ -1,200 +0,0 @@
|
||||||
/* bubblewrap
|
|
||||||
* Copyright (C) 2016 Alexander Larsson
|
|
||||||
*
|
|
||||||
* This program 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 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This 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 this library. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "config.h"
|
|
||||||
|
|
||||||
#include <arpa/inet.h>
|
|
||||||
#include <net/if.h>
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#include <linux/loop.h>
|
|
||||||
#include <linux/netlink.h>
|
|
||||||
#include <linux/rtnetlink.h>
|
|
||||||
|
|
||||||
#include "utils.h"
|
|
||||||
#include "network.h"
|
|
||||||
|
|
||||||
static void *
|
|
||||||
add_rta (struct nlmsghdr *header,
|
|
||||||
int type,
|
|
||||||
size_t size)
|
|
||||||
{
|
|
||||||
struct rtattr *rta;
|
|
||||||
size_t rta_size = RTA_LENGTH (size);
|
|
||||||
|
|
||||||
rta = (struct rtattr *) ((char *) header + NLMSG_ALIGN (header->nlmsg_len));
|
|
||||||
rta->rta_type = type;
|
|
||||||
rta->rta_len = rta_size;
|
|
||||||
|
|
||||||
header->nlmsg_len = NLMSG_ALIGN (header->nlmsg_len) + rta_size;
|
|
||||||
|
|
||||||
return RTA_DATA (rta);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
rtnl_send_request (int rtnl_fd,
|
|
||||||
struct nlmsghdr *header)
|
|
||||||
{
|
|
||||||
struct sockaddr_nl dst_addr = { AF_NETLINK, 0 };
|
|
||||||
ssize_t sent;
|
|
||||||
|
|
||||||
sent = sendto (rtnl_fd, (void *) header, header->nlmsg_len, 0,
|
|
||||||
(struct sockaddr *) &dst_addr, sizeof (dst_addr));
|
|
||||||
if (sent < 0)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
rtnl_read_reply (int rtnl_fd,
|
|
||||||
int seq_nr)
|
|
||||||
{
|
|
||||||
char buffer[1024];
|
|
||||||
ssize_t received;
|
|
||||||
struct nlmsghdr *rheader;
|
|
||||||
|
|
||||||
while (1)
|
|
||||||
{
|
|
||||||
received = recv (rtnl_fd, buffer, sizeof (buffer), 0);
|
|
||||||
if (received < 0)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
rheader = (struct nlmsghdr *) buffer;
|
|
||||||
while (received >= NLMSG_HDRLEN)
|
|
||||||
{
|
|
||||||
if (rheader->nlmsg_seq != seq_nr)
|
|
||||||
return -1;
|
|
||||||
if (rheader->nlmsg_pid != getpid ())
|
|
||||||
return -1;
|
|
||||||
if (rheader->nlmsg_type == NLMSG_ERROR)
|
|
||||||
{
|
|
||||||
uint32_t *err = NLMSG_DATA (rheader);
|
|
||||||
if (*err == 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (rheader->nlmsg_type == NLMSG_DONE)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
rheader = NLMSG_NEXT (rheader, received);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
rtnl_do_request (int rtnl_fd,
|
|
||||||
struct nlmsghdr *header)
|
|
||||||
{
|
|
||||||
if (rtnl_send_request (rtnl_fd, header) != 0)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
if (rtnl_read_reply (rtnl_fd, header->nlmsg_seq) != 0)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct nlmsghdr *
|
|
||||||
rtnl_setup_request (char *buffer,
|
|
||||||
int type,
|
|
||||||
int flags,
|
|
||||||
size_t size)
|
|
||||||
{
|
|
||||||
struct nlmsghdr *header;
|
|
||||||
size_t len = NLMSG_LENGTH (size);
|
|
||||||
static uint32_t counter = 0;
|
|
||||||
|
|
||||||
memset (buffer, 0, len);
|
|
||||||
|
|
||||||
header = (struct nlmsghdr *) buffer;
|
|
||||||
header->nlmsg_len = len;
|
|
||||||
header->nlmsg_type = type;
|
|
||||||
header->nlmsg_flags = flags | NLM_F_REQUEST;
|
|
||||||
header->nlmsg_seq = counter++;
|
|
||||||
header->nlmsg_pid = getpid ();
|
|
||||||
|
|
||||||
return (struct nlmsghdr *) header;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
loopback_setup (void)
|
|
||||||
{
|
|
||||||
int r, if_loopback;
|
|
||||||
cleanup_fd int rtnl_fd = -1;
|
|
||||||
char buffer[1024];
|
|
||||||
struct sockaddr_nl src_addr = { AF_NETLINK, 0 };
|
|
||||||
struct nlmsghdr *header;
|
|
||||||
struct ifaddrmsg *addmsg;
|
|
||||||
struct ifinfomsg *infomsg;
|
|
||||||
struct in_addr *ip_addr;
|
|
||||||
|
|
||||||
src_addr.nl_pid = getpid ();
|
|
||||||
|
|
||||||
if_loopback = (int) if_nametoindex ("lo");
|
|
||||||
if (if_loopback <= 0)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
rtnl_fd = socket (PF_NETLINK, SOCK_RAW | SOCK_CLOEXEC, NETLINK_ROUTE);
|
|
||||||
if (rtnl_fd < 0)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
r = bind (rtnl_fd, (struct sockaddr *) &src_addr, sizeof (src_addr));
|
|
||||||
if (r < 0)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
header = rtnl_setup_request (buffer, RTM_NEWADDR,
|
|
||||||
NLM_F_CREATE | NLM_F_EXCL | NLM_F_ACK,
|
|
||||||
sizeof (struct ifaddrmsg));
|
|
||||||
addmsg = NLMSG_DATA (header);
|
|
||||||
|
|
||||||
addmsg->ifa_family = AF_INET;
|
|
||||||
addmsg->ifa_prefixlen = 8;
|
|
||||||
addmsg->ifa_flags = IFA_F_PERMANENT;
|
|
||||||
addmsg->ifa_scope = RT_SCOPE_HOST;
|
|
||||||
addmsg->ifa_index = if_loopback;
|
|
||||||
|
|
||||||
ip_addr = add_rta (header, IFA_LOCAL, sizeof (*ip_addr));
|
|
||||||
ip_addr->s_addr = htonl (INADDR_LOOPBACK);
|
|
||||||
|
|
||||||
ip_addr = add_rta (header, IFA_ADDRESS, sizeof (*ip_addr));
|
|
||||||
ip_addr->s_addr = htonl (INADDR_LOOPBACK);
|
|
||||||
|
|
||||||
assert (header->nlmsg_len < sizeof (buffer));
|
|
||||||
|
|
||||||
if (rtnl_do_request (rtnl_fd, header) != 0)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
header = rtnl_setup_request (buffer, RTM_NEWLINK,
|
|
||||||
NLM_F_ACK,
|
|
||||||
sizeof (struct ifinfomsg));
|
|
||||||
infomsg = NLMSG_DATA (header);
|
|
||||||
|
|
||||||
infomsg->ifi_family = AF_UNSPEC;
|
|
||||||
infomsg->ifi_type = 0;
|
|
||||||
infomsg->ifi_index = if_loopback;
|
|
||||||
infomsg->ifi_flags = IFF_UP;
|
|
||||||
infomsg->ifi_change = IFF_UP;
|
|
||||||
|
|
||||||
assert (header->nlmsg_len < sizeof (buffer));
|
|
||||||
|
|
||||||
if (rtnl_do_request (rtnl_fd, header) != 0)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
21
external/bubblewrap/network.h
vendored
21
external/bubblewrap/network.h
vendored
|
|
@ -1,21 +0,0 @@
|
||||||
/* bubblewrap
|
|
||||||
* Copyright (C) 2016 Alexander Larsson
|
|
||||||
*
|
|
||||||
* This program 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 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This 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 this library. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
int loopback_setup (void);
|
|
||||||
49
external/bubblewrap/packaging/bubblewrap.spec
vendored
49
external/bubblewrap/packaging/bubblewrap.spec
vendored
|
|
@ -1,49 +0,0 @@
|
||||||
%global commit0 66d12bb23b04e201c5846e325f0b10930ed802f8
|
|
||||||
%global shortcommit0 %(c=%{commit0}; echo ${c:0:7})
|
|
||||||
|
|
||||||
Summary: Core execution tool for unprivileged containers
|
|
||||||
Name: bubblewrap
|
|
||||||
Version: 0
|
|
||||||
Release: 1%{?dist}
|
|
||||||
#VCS: git:https://github.com/projectatomic/bubblewrap
|
|
||||||
Source0: https://github.com/projectatomic/%{name}/archive/%{commit0}.tar.gz#/%{name}-%{shortcommit0}.tar.gz
|
|
||||||
License: LGPLv2+
|
|
||||||
URL: https://github.com/projectatomic/bubblewrap
|
|
||||||
|
|
||||||
BuildRequires: git
|
|
||||||
# We always run autogen.sh
|
|
||||||
BuildRequires: autoconf automake libtool
|
|
||||||
BuildRequires: libcap-devel
|
|
||||||
BuildRequires: pkgconfig(libselinux)
|
|
||||||
BuildRequires: libxslt
|
|
||||||
BuildRequires: docbook-style-xsl
|
|
||||||
|
|
||||||
%description
|
|
||||||
Bubblewrap (/usr/bin/bwrap) is a core execution engine for unprivileged
|
|
||||||
containers that works as a setuid binary on kernels without
|
|
||||||
user namespaces.
|
|
||||||
|
|
||||||
%prep
|
|
||||||
%autosetup -Sgit -n %{name}-%{version}
|
|
||||||
|
|
||||||
%build
|
|
||||||
env NOCONFIGURE=1 ./autogen.sh
|
|
||||||
%configure --disable-silent-rules --with-priv-mode=none
|
|
||||||
|
|
||||||
make %{?_smp_mflags}
|
|
||||||
|
|
||||||
%install
|
|
||||||
make install DESTDIR=$RPM_BUILD_ROOT INSTALL="install -p -c"
|
|
||||||
find $RPM_BUILD_ROOT -name '*.la' -delete
|
|
||||||
|
|
||||||
%files
|
|
||||||
%license COPYING
|
|
||||||
%doc README.md
|
|
||||||
%{_datadir}/bash-completion/completions/bwrap
|
|
||||||
%if (0%{?rhel} != 0 && 0%{?rhel} <= 7)
|
|
||||||
%attr(0755,root,root) %caps(cap_sys_admin,cap_net_admin,cap_sys_chroot=ep) %{_bindir}/bwrap
|
|
||||||
%else
|
|
||||||
%{_bindir}/bwrap
|
|
||||||
%endif
|
|
||||||
%{_mandir}/man1/*
|
|
||||||
|
|
||||||
35
external/bubblewrap/tests/test-basic.sh
vendored
35
external/bubblewrap/tests/test-basic.sh
vendored
|
|
@ -1,35 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -xeuo pipefail
|
|
||||||
|
|
||||||
srcd=$(cd $(dirname $0) && pwd)
|
|
||||||
bn=$(basename $0)
|
|
||||||
tempdir=$(mktemp -d /var/tmp/tap-test.XXXXXX)
|
|
||||||
touch ${tempdir}/.testtmp
|
|
||||||
function cleanup () {
|
|
||||||
if test -n "${TEST_SKIP_CLEANUP:-}"; then
|
|
||||||
echo "Skipping cleanup of ${test_tmpdir}"
|
|
||||||
else if test -f ${tempdir}/.test; then
|
|
||||||
rm "${tempdir}" -rf
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
trap cleanup EXIT
|
|
||||||
cd ${tempdir}
|
|
||||||
|
|
||||||
assert_not_reached () {
|
|
||||||
echo $@ 1>&2; exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
assert_file_has_content () {
|
|
||||||
if ! grep -q -e "$2" "$1"; then
|
|
||||||
echo 1>&2 "File '$1' doesn't match regexp '$2'"; exit 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# At the moment we're testing in Travis' container infrastructure
|
|
||||||
# which also uses PR_SET_NO_NEW_PRIVS...but let's at least
|
|
||||||
# verify --help works!
|
|
||||||
bwrap --help >out.txt 2>&1
|
|
||||||
assert_file_has_content out.txt "--lock-file"
|
|
||||||
|
|
||||||
136
external/bubblewrap/uncrustify.cfg
vendored
136
external/bubblewrap/uncrustify.cfg
vendored
|
|
@ -1,136 +0,0 @@
|
||||||
newlines lf
|
|
||||||
|
|
||||||
input_tab_size 8
|
|
||||||
output_tab_size 8
|
|
||||||
|
|
||||||
string_escape_char 92
|
|
||||||
string_escape_char2 0
|
|
||||||
|
|
||||||
# indenting
|
|
||||||
indent_columns 2
|
|
||||||
indent_with_tabs 0
|
|
||||||
indent_align_string True
|
|
||||||
indent_brace 2
|
|
||||||
indent_braces false
|
|
||||||
indent_braces_no_func True
|
|
||||||
indent_func_call_param false
|
|
||||||
indent_func_def_param false
|
|
||||||
indent_func_proto_param false
|
|
||||||
indent_switch_case 0
|
|
||||||
indent_case_brace 2
|
|
||||||
indent_paren_close 1
|
|
||||||
|
|
||||||
# spacing
|
|
||||||
sp_arith Add
|
|
||||||
sp_assign Add
|
|
||||||
sp_enum_assign Add
|
|
||||||
sp_bool Add
|
|
||||||
sp_compare Add
|
|
||||||
sp_inside_paren Remove
|
|
||||||
sp_inside_fparens Remove
|
|
||||||
sp_func_def_paren Force
|
|
||||||
sp_func_proto_paren Force
|
|
||||||
sp_paren_paren Remove
|
|
||||||
sp_balance_nested_parens False
|
|
||||||
sp_paren_brace Remove
|
|
||||||
sp_before_square Remove
|
|
||||||
sp_before_squares Remove
|
|
||||||
sp_inside_square Remove
|
|
||||||
sp_before_ptr_star Add
|
|
||||||
sp_between_ptr_star Remove
|
|
||||||
sp_after_comma Add
|
|
||||||
sp_before_comma Remove
|
|
||||||
sp_after_cast Add
|
|
||||||
sp_sizeof_paren Add
|
|
||||||
sp_not Remove
|
|
||||||
sp_inv Remove
|
|
||||||
sp_addr Remove
|
|
||||||
sp_member Remove
|
|
||||||
sp_deref Remove
|
|
||||||
sp_sign Remove
|
|
||||||
sp_incdec Remove
|
|
||||||
sp_attribute_paren remove
|
|
||||||
sp_macro Force
|
|
||||||
sp_func_call_paren Force
|
|
||||||
sp_func_call_user_paren Remove
|
|
||||||
set func_call_user _ N_ C_ g_autoptr g_auto
|
|
||||||
sp_brace_typedef add
|
|
||||||
sp_cond_colon add
|
|
||||||
sp_cond_question add
|
|
||||||
sp_defined_paren remove
|
|
||||||
|
|
||||||
# alignment
|
|
||||||
align_keep_tabs False
|
|
||||||
align_with_tabs False
|
|
||||||
align_on_tabstop False
|
|
||||||
align_number_left True
|
|
||||||
align_func_params True
|
|
||||||
align_var_def_span 0
|
|
||||||
align_var_def_amp_style 1
|
|
||||||
align_var_def_colon true
|
|
||||||
align_enum_equ_span 0
|
|
||||||
align_var_struct_span 2
|
|
||||||
align_var_def_star_style 2
|
|
||||||
align_var_def_amp_style 2
|
|
||||||
align_typedef_span 2
|
|
||||||
align_typedef_func 0
|
|
||||||
align_typedef_star_style 2
|
|
||||||
align_typedef_amp_style 2
|
|
||||||
|
|
||||||
# newlines
|
|
||||||
nl_assign_leave_one_liners True
|
|
||||||
nl_enum_leave_one_liners False
|
|
||||||
nl_func_leave_one_liners False
|
|
||||||
nl_if_leave_one_liners False
|
|
||||||
nl_end_of_file Add
|
|
||||||
nl_assign_brace Remove
|
|
||||||
nl_func_var_def_blk 1
|
|
||||||
nl_fcall_brace Add
|
|
||||||
nl_enum_brace Remove
|
|
||||||
nl_struct_brace Force
|
|
||||||
nl_union_brace Force
|
|
||||||
nl_if_brace Force
|
|
||||||
nl_brace_else Force
|
|
||||||
nl_elseif_brace Force
|
|
||||||
nl_else_brace Add
|
|
||||||
nl_for_brace Force
|
|
||||||
nl_while_brace Force
|
|
||||||
nl_do_brace Force
|
|
||||||
nl_brace_while Force
|
|
||||||
nl_switch_brace Force
|
|
||||||
nl_before_case True
|
|
||||||
nl_after_case False
|
|
||||||
nl_func_type_name Force
|
|
||||||
nl_func_proto_type_name Remove
|
|
||||||
nl_func_paren Remove
|
|
||||||
nl_func_decl_start Remove
|
|
||||||
nl_func_decl_args Force
|
|
||||||
nl_func_decl_end Remove
|
|
||||||
nl_fdef_brace Force
|
|
||||||
nl_after_return False
|
|
||||||
nl_define_macro False
|
|
||||||
nl_create_if_one_liner False
|
|
||||||
nl_create_for_one_liner False
|
|
||||||
nl_create_while_one_liner False
|
|
||||||
nl_after_semicolon True
|
|
||||||
nl_multi_line_cond true
|
|
||||||
|
|
||||||
# mod
|
|
||||||
# I'd like these to be remove, but that removes brackets in if { if { foo } }, which i dislike
|
|
||||||
# Not clear what to do about that...
|
|
||||||
mod_full_brace_for Remove
|
|
||||||
mod_full_brace_if Remove
|
|
||||||
mod_full_brace_if_chain True
|
|
||||||
mod_full_brace_while Remove
|
|
||||||
mod_full_brace_do Remove
|
|
||||||
mod_full_brace_nl 3
|
|
||||||
mod_paren_on_return Remove
|
|
||||||
|
|
||||||
# line splitting
|
|
||||||
#code_width = 78
|
|
||||||
ls_for_split_full True
|
|
||||||
ls_func_split_full True
|
|
||||||
|
|
||||||
# positioning
|
|
||||||
pos_bool Trail
|
|
||||||
pos_conditional Trail
|
|
||||||
2
external/bubblewrap/uncrustify.sh
vendored
2
external/bubblewrap/uncrustify.sh
vendored
|
|
@ -1,2 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
uncrustify -c uncrustify.cfg --no-backup `git ls-tree --name-only -r HEAD | grep \\\.[ch]$`
|
|
||||||
676
external/bubblewrap/utils.c
vendored
676
external/bubblewrap/utils.c
vendored
|
|
@ -1,676 +0,0 @@
|
||||||
/* bubblewrap
|
|
||||||
* Copyright (C) 2016 Alexander Larsson
|
|
||||||
*
|
|
||||||
* This program 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 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This 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 this library. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
#include "config.h"
|
|
||||||
|
|
||||||
#include "utils.h"
|
|
||||||
#include <sys/syscall.h>
|
|
||||||
#ifdef HAVE_SELINUX
|
|
||||||
#include <selinux/selinux.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void
|
|
||||||
die_with_error (const char *format, ...)
|
|
||||||
{
|
|
||||||
va_list args;
|
|
||||||
int errsv;
|
|
||||||
|
|
||||||
errsv = errno;
|
|
||||||
|
|
||||||
va_start (args, format);
|
|
||||||
vfprintf (stderr, format, args);
|
|
||||||
va_end (args);
|
|
||||||
|
|
||||||
fprintf (stderr, ": %s\n", strerror (errsv));
|
|
||||||
|
|
||||||
exit (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
die (const char *format, ...)
|
|
||||||
{
|
|
||||||
va_list args;
|
|
||||||
|
|
||||||
va_start (args, format);
|
|
||||||
vfprintf (stderr, format, args);
|
|
||||||
va_end (args);
|
|
||||||
|
|
||||||
fprintf (stderr, "\n");
|
|
||||||
|
|
||||||
exit (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
die_unless_label_valid (const char *label)
|
|
||||||
{
|
|
||||||
#ifdef HAVE_SELINUX
|
|
||||||
if (is_selinux_enabled () == 1)
|
|
||||||
{
|
|
||||||
if (security_check_context ((security_context_t) label) < 0)
|
|
||||||
die_with_error ("invalid label %s", label);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
die ("labeling not supported on this system");
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
die_oom (void)
|
|
||||||
{
|
|
||||||
puts ("Out of memory");
|
|
||||||
exit (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void *
|
|
||||||
xmalloc (size_t size)
|
|
||||||
{
|
|
||||||
void *res = malloc (size);
|
|
||||||
|
|
||||||
if (res == NULL)
|
|
||||||
die_oom ();
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
void *
|
|
||||||
xcalloc (size_t size)
|
|
||||||
{
|
|
||||||
void *res = calloc (1, size);
|
|
||||||
|
|
||||||
if (res == NULL)
|
|
||||||
die_oom ();
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
void *
|
|
||||||
xrealloc (void *ptr, size_t size)
|
|
||||||
{
|
|
||||||
void *res = realloc (ptr, size);
|
|
||||||
|
|
||||||
if (size != 0 && res == NULL)
|
|
||||||
die_oom ();
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *
|
|
||||||
xstrdup (const char *str)
|
|
||||||
{
|
|
||||||
char *res;
|
|
||||||
|
|
||||||
assert (str != NULL);
|
|
||||||
|
|
||||||
res = strdup (str);
|
|
||||||
if (res == NULL)
|
|
||||||
die_oom ();
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
strfreev (char **str_array)
|
|
||||||
{
|
|
||||||
if (str_array)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; str_array[i] != NULL; i++)
|
|
||||||
free (str_array[i]);
|
|
||||||
|
|
||||||
free (str_array);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Compares if str has a specific path prefix. This differs
|
|
||||||
from a regular prefix in two ways. First of all there may
|
|
||||||
be multiple slashes separating the path elements, and
|
|
||||||
secondly, if a prefix is matched that has to be en entire
|
|
||||||
path element. For instance /a/prefix matches /a/prefix/foo/bar,
|
|
||||||
but not /a/prefixfoo/bar. */
|
|
||||||
bool
|
|
||||||
has_path_prefix (const char *str,
|
|
||||||
const char *prefix)
|
|
||||||
{
|
|
||||||
while (TRUE)
|
|
||||||
{
|
|
||||||
/* Skip consecutive slashes to reach next path
|
|
||||||
element */
|
|
||||||
while (*str == '/')
|
|
||||||
str++;
|
|
||||||
while (*prefix == '/')
|
|
||||||
prefix++;
|
|
||||||
|
|
||||||
/* No more prefix path elements? Done! */
|
|
||||||
if (*prefix == 0)
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
/* Compare path element */
|
|
||||||
while (*prefix != 0 && *prefix != '/')
|
|
||||||
{
|
|
||||||
if (*str != *prefix)
|
|
||||||
return FALSE;
|
|
||||||
str++;
|
|
||||||
prefix++;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Matched prefix path element,
|
|
||||||
must be entire str path element */
|
|
||||||
if (*str != '/' && *str != 0)
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
|
||||||
has_prefix (const char *str,
|
|
||||||
const char *prefix)
|
|
||||||
{
|
|
||||||
return strncmp (str, prefix, strlen (prefix)) == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
xsetenv (const char *name, const char *value, int overwrite)
|
|
||||||
{
|
|
||||||
if (setenv (name, value, overwrite))
|
|
||||||
die ("setenv failed");
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
xunsetenv (const char *name)
|
|
||||||
{
|
|
||||||
if (unsetenv (name))
|
|
||||||
die ("unsetenv failed");
|
|
||||||
}
|
|
||||||
|
|
||||||
char *
|
|
||||||
strconcat (const char *s1,
|
|
||||||
const char *s2)
|
|
||||||
{
|
|
||||||
size_t len = 0;
|
|
||||||
char *res;
|
|
||||||
|
|
||||||
if (s1)
|
|
||||||
len += strlen (s1);
|
|
||||||
if (s2)
|
|
||||||
len += strlen (s2);
|
|
||||||
|
|
||||||
res = xmalloc (len + 1);
|
|
||||||
*res = 0;
|
|
||||||
if (s1)
|
|
||||||
strcat (res, s1);
|
|
||||||
if (s2)
|
|
||||||
strcat (res, s2);
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *
|
|
||||||
strconcat3 (const char *s1,
|
|
||||||
const char *s2,
|
|
||||||
const char *s3)
|
|
||||||
{
|
|
||||||
size_t len = 0;
|
|
||||||
char *res;
|
|
||||||
|
|
||||||
if (s1)
|
|
||||||
len += strlen (s1);
|
|
||||||
if (s2)
|
|
||||||
len += strlen (s2);
|
|
||||||
if (s3)
|
|
||||||
len += strlen (s3);
|
|
||||||
|
|
||||||
res = xmalloc (len + 1);
|
|
||||||
*res = 0;
|
|
||||||
if (s1)
|
|
||||||
strcat (res, s1);
|
|
||||||
if (s2)
|
|
||||||
strcat (res, s2);
|
|
||||||
if (s3)
|
|
||||||
strcat (res, s3);
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *
|
|
||||||
xasprintf (const char *format,
|
|
||||||
...)
|
|
||||||
{
|
|
||||||
char *buffer = NULL;
|
|
||||||
va_list args;
|
|
||||||
|
|
||||||
va_start (args, format);
|
|
||||||
if (vasprintf (&buffer, format, args) == -1)
|
|
||||||
die_oom ();
|
|
||||||
va_end (args);
|
|
||||||
|
|
||||||
return buffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
fdwalk (int proc_fd, int (*cb)(void *data,
|
|
||||||
int fd), void *data)
|
|
||||||
{
|
|
||||||
int open_max;
|
|
||||||
int fd;
|
|
||||||
int dfd;
|
|
||||||
int res = 0;
|
|
||||||
DIR *d;
|
|
||||||
|
|
||||||
dfd = openat (proc_fd, "self/fd", O_DIRECTORY | O_RDONLY | O_NONBLOCK | O_CLOEXEC | O_NOCTTY);
|
|
||||||
if (dfd == -1)
|
|
||||||
return res;
|
|
||||||
|
|
||||||
if ((d = fdopendir (dfd)))
|
|
||||||
{
|
|
||||||
struct dirent *de;
|
|
||||||
|
|
||||||
while ((de = readdir (d)))
|
|
||||||
{
|
|
||||||
long l;
|
|
||||||
char *e = NULL;
|
|
||||||
|
|
||||||
if (de->d_name[0] == '.')
|
|
||||||
continue;
|
|
||||||
|
|
||||||
errno = 0;
|
|
||||||
l = strtol (de->d_name, &e, 10);
|
|
||||||
if (errno != 0 || !e || *e)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
fd = (int) l;
|
|
||||||
|
|
||||||
if ((long) fd != l)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (fd == dirfd (d))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if ((res = cb (data, fd)) != 0)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
closedir (d);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
open_max = sysconf (_SC_OPEN_MAX);
|
|
||||||
|
|
||||||
for (fd = 0; fd < open_max; fd++)
|
|
||||||
if ((res = cb (data, fd)) != 0)
|
|
||||||
break;
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Sets errno on error (!= 0), ENOSPC on short write */
|
|
||||||
int
|
|
||||||
write_to_fd (int fd,
|
|
||||||
const char *content,
|
|
||||||
ssize_t len)
|
|
||||||
{
|
|
||||||
ssize_t res;
|
|
||||||
|
|
||||||
while (len > 0)
|
|
||||||
{
|
|
||||||
res = write (fd, content, len);
|
|
||||||
if (res < 0 && errno == EINTR)
|
|
||||||
continue;
|
|
||||||
if (res <= 0)
|
|
||||||
{
|
|
||||||
if (res == 0) /* Unexpected short write, should not happen when writing to a file */
|
|
||||||
errno = ENOSPC;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
len -= res;
|
|
||||||
content += res;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Sets errno on error (!= 0), ENOSPC on short write */
|
|
||||||
int
|
|
||||||
write_file_at (int dirfd,
|
|
||||||
const char *path,
|
|
||||||
const char *content)
|
|
||||||
{
|
|
||||||
int fd;
|
|
||||||
bool res;
|
|
||||||
int errsv;
|
|
||||||
|
|
||||||
fd = openat (dirfd, path, O_RDWR | O_CLOEXEC, 0);
|
|
||||||
if (fd == -1)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
res = 0;
|
|
||||||
if (content)
|
|
||||||
res = write_to_fd (fd, content, strlen (content));
|
|
||||||
|
|
||||||
errsv = errno;
|
|
||||||
close (fd);
|
|
||||||
errno = errsv;
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Sets errno on error (!= 0), ENOSPC on short write */
|
|
||||||
int
|
|
||||||
create_file (const char *path,
|
|
||||||
mode_t mode,
|
|
||||||
const char *content)
|
|
||||||
{
|
|
||||||
int fd;
|
|
||||||
int res;
|
|
||||||
int errsv;
|
|
||||||
|
|
||||||
fd = creat (path, mode);
|
|
||||||
if (fd == -1)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
res = 0;
|
|
||||||
if (content)
|
|
||||||
res = write_to_fd (fd, content, strlen (content));
|
|
||||||
|
|
||||||
errsv = errno;
|
|
||||||
close (fd);
|
|
||||||
errno = errsv;
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
ensure_file (const char *path,
|
|
||||||
mode_t mode)
|
|
||||||
{
|
|
||||||
struct stat buf;
|
|
||||||
|
|
||||||
/* We check this ahead of time, otherwise
|
|
||||||
the create file will fail in the read-only
|
|
||||||
case with EROFD instead of EEXIST */
|
|
||||||
if (stat (path, &buf) == 0 &&
|
|
||||||
S_ISREG (buf.st_mode))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (create_file (path, mode, NULL) != 0 && errno != EEXIST)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#define BUFSIZE 8192
|
|
||||||
/* Sets errno on error (!= 0), ENOSPC on short write */
|
|
||||||
int
|
|
||||||
copy_file_data (int sfd,
|
|
||||||
int dfd)
|
|
||||||
{
|
|
||||||
char buffer[BUFSIZE];
|
|
||||||
ssize_t bytes_read;
|
|
||||||
|
|
||||||
while (TRUE)
|
|
||||||
{
|
|
||||||
bytes_read = read (sfd, buffer, BUFSIZE);
|
|
||||||
if (bytes_read == -1)
|
|
||||||
{
|
|
||||||
if (errno == EINTR)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bytes_read == 0)
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (write_to_fd (dfd, buffer, bytes_read) != 0)
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Sets errno on error (!= 0), ENOSPC on short write */
|
|
||||||
int
|
|
||||||
copy_file (const char *src_path,
|
|
||||||
const char *dst_path,
|
|
||||||
mode_t mode)
|
|
||||||
{
|
|
||||||
int sfd;
|
|
||||||
int dfd;
|
|
||||||
int res;
|
|
||||||
int errsv;
|
|
||||||
|
|
||||||
sfd = open (src_path, O_CLOEXEC | O_RDONLY);
|
|
||||||
if (sfd == -1)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
dfd = creat (dst_path, mode);
|
|
||||||
if (dfd == -1)
|
|
||||||
{
|
|
||||||
errsv = errno;
|
|
||||||
close (sfd);
|
|
||||||
errno = errsv;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
res = copy_file_data (sfd, dfd);
|
|
||||||
|
|
||||||
errsv = errno;
|
|
||||||
close (sfd);
|
|
||||||
close (dfd);
|
|
||||||
errno = errsv;
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Sets errno on error (== NULL),
|
|
||||||
* Always ensures terminating zero */
|
|
||||||
char *
|
|
||||||
load_file_data (int fd,
|
|
||||||
size_t *size)
|
|
||||||
{
|
|
||||||
cleanup_free char *data = NULL;
|
|
||||||
ssize_t data_read;
|
|
||||||
ssize_t data_len;
|
|
||||||
ssize_t res;
|
|
||||||
int errsv;
|
|
||||||
|
|
||||||
data_read = 0;
|
|
||||||
data_len = 4080;
|
|
||||||
data = xmalloc (data_len);
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
if (data_len == data_read + 1)
|
|
||||||
{
|
|
||||||
data_len *= 2;
|
|
||||||
data = xrealloc (data, data_len);
|
|
||||||
}
|
|
||||||
|
|
||||||
do
|
|
||||||
res = read (fd, data + data_read, data_len - data_read - 1);
|
|
||||||
while (res < 0 && errno == EINTR);
|
|
||||||
|
|
||||||
if (res < 0)
|
|
||||||
{
|
|
||||||
errsv = errno;
|
|
||||||
close (fd);
|
|
||||||
errno = errsv;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
data_read += res;
|
|
||||||
}
|
|
||||||
while (res > 0);
|
|
||||||
|
|
||||||
data[data_read] = 0;
|
|
||||||
|
|
||||||
if (size)
|
|
||||||
*size = (size_t) data_read;
|
|
||||||
|
|
||||||
return steal_pointer (&data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Sets errno on error (== NULL),
|
|
||||||
* Always ensures terminating zero */
|
|
||||||
char *
|
|
||||||
load_file_at (int dirfd,
|
|
||||||
const char *path)
|
|
||||||
{
|
|
||||||
int fd;
|
|
||||||
char *data;
|
|
||||||
int errsv;
|
|
||||||
|
|
||||||
fd = openat (dirfd, path, O_CLOEXEC | O_RDONLY);
|
|
||||||
if (fd == -1)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
data = load_file_data (fd, NULL);
|
|
||||||
|
|
||||||
errsv = errno;
|
|
||||||
close (fd);
|
|
||||||
errno = errsv;
|
|
||||||
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Sets errno on error (< 0) */
|
|
||||||
int
|
|
||||||
get_file_mode (const char *pathname)
|
|
||||||
{
|
|
||||||
struct stat buf;
|
|
||||||
|
|
||||||
if (stat (pathname, &buf) != 0)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
return buf.st_mode & S_IFMT;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Sets errno on error (!= 0) */
|
|
||||||
int
|
|
||||||
mkdir_with_parents (const char *pathname,
|
|
||||||
int mode,
|
|
||||||
bool create_last)
|
|
||||||
{
|
|
||||||
cleanup_free char *fn = NULL;
|
|
||||||
char *p;
|
|
||||||
struct stat buf;
|
|
||||||
|
|
||||||
if (pathname == NULL || *pathname == '\0')
|
|
||||||
{
|
|
||||||
errno = EINVAL;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
fn = xstrdup (pathname);
|
|
||||||
|
|
||||||
p = fn;
|
|
||||||
while (*p == '/')
|
|
||||||
p++;
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
while (*p && *p != '/')
|
|
||||||
p++;
|
|
||||||
|
|
||||||
if (!*p)
|
|
||||||
p = NULL;
|
|
||||||
else
|
|
||||||
*p = '\0';
|
|
||||||
|
|
||||||
if (!create_last && p == NULL)
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (stat (fn, &buf) != 0)
|
|
||||||
{
|
|
||||||
if (mkdir (fn, mode) == -1 && errno != EEXIST)
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
else if (!S_ISDIR (buf.st_mode))
|
|
||||||
{
|
|
||||||
errno = ENOTDIR;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (p)
|
|
||||||
{
|
|
||||||
*p++ = '/';
|
|
||||||
while (*p && *p == '/')
|
|
||||||
p++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
while (p);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
raw_clone (unsigned long flags,
|
|
||||||
void *child_stack)
|
|
||||||
{
|
|
||||||
#if defined(__s390__) || defined(__CRIS__)
|
|
||||||
/* On s390 and cris the order of the first and second arguments
|
|
||||||
* of the raw clone() system call is reversed. */
|
|
||||||
return (int) syscall (__NR_clone, child_stack, flags);
|
|
||||||
#else
|
|
||||||
return (int) syscall (__NR_clone, flags, child_stack);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
pivot_root (const char * new_root, const char * put_old)
|
|
||||||
{
|
|
||||||
#ifdef __NR_pivot_root
|
|
||||||
return syscall (__NR_pivot_root, new_root, put_old);
|
|
||||||
#else
|
|
||||||
errno = ENOSYS;
|
|
||||||
return -1;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
char *
|
|
||||||
label_mount (const char *opt, const char *mount_label)
|
|
||||||
{
|
|
||||||
#ifdef HAVE_SELINUX
|
|
||||||
if (mount_label)
|
|
||||||
{
|
|
||||||
if (opt)
|
|
||||||
return xasprintf ("%s,context=\"%s\"", opt, mount_label);
|
|
||||||
else
|
|
||||||
return xasprintf ("context=\"%s\"", mount_label);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if (opt)
|
|
||||||
return xstrdup (opt);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
label_create_file (const char *file_label)
|
|
||||||
{
|
|
||||||
#ifdef HAVE_SELINUX
|
|
||||||
if (is_selinux_enabled () > 0 && file_label)
|
|
||||||
return setfscreatecon ((security_context_t) file_label);
|
|
||||||
#endif
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
label_exec (const char *exec_label)
|
|
||||||
{
|
|
||||||
#ifdef HAVE_SELINUX
|
|
||||||
if (is_selinux_enabled () > 0 && exec_label)
|
|
||||||
return setexeccon ((security_context_t) exec_label);
|
|
||||||
#endif
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
164
external/bubblewrap/utils.h
vendored
164
external/bubblewrap/utils.h
vendored
|
|
@ -1,164 +0,0 @@
|
||||||
/* bubblewrap
|
|
||||||
* Copyright (C) 2016 Alexander Larsson
|
|
||||||
*
|
|
||||||
* This program 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 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This 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 this library. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <dirent.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <stdarg.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
|
|
||||||
#if 1
|
|
||||||
#define __debug__(x) printf x
|
|
||||||
#else
|
|
||||||
#define __debug__(x)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define UNUSED __attribute__((__unused__))
|
|
||||||
|
|
||||||
#define N_ELEMENTS(arr) (sizeof (arr) / sizeof ((arr)[0]))
|
|
||||||
|
|
||||||
#define TRUE 1
|
|
||||||
#define FALSE 0
|
|
||||||
typedef int bool;
|
|
||||||
|
|
||||||
#define PIPE_READ_END 0
|
|
||||||
#define PIPE_WRITE_END 1
|
|
||||||
|
|
||||||
void die_with_error (const char *format,
|
|
||||||
...) __attribute__((__noreturn__)) __attribute__((format (printf, 1, 2)));
|
|
||||||
void die (const char *format,
|
|
||||||
...) __attribute__((__noreturn__));
|
|
||||||
void die_oom (void) __attribute__((__noreturn__));
|
|
||||||
void die_unless_label_valid (const char *label);
|
|
||||||
|
|
||||||
void *xmalloc (size_t size);
|
|
||||||
void *xcalloc (size_t size);
|
|
||||||
void *xrealloc (void *ptr,
|
|
||||||
size_t size);
|
|
||||||
char *xstrdup (const char *str);
|
|
||||||
void strfreev (char **str_array);
|
|
||||||
void xsetenv (const char *name,
|
|
||||||
const char *value,
|
|
||||||
int overwrite);
|
|
||||||
void xunsetenv (const char *name);
|
|
||||||
char *strconcat (const char *s1,
|
|
||||||
const char *s2);
|
|
||||||
char *strconcat3 (const char *s1,
|
|
||||||
const char *s2,
|
|
||||||
const char *s3);
|
|
||||||
char * xasprintf (const char *format,
|
|
||||||
...) __attribute__((format (printf, 1, 2)));
|
|
||||||
bool has_prefix (const char *str,
|
|
||||||
const char *prefix);
|
|
||||||
bool has_path_prefix (const char *str,
|
|
||||||
const char *prefix);
|
|
||||||
int fdwalk (int proc_fd,
|
|
||||||
int (*cb)(void *data,
|
|
||||||
int fd),
|
|
||||||
void *data);
|
|
||||||
char *load_file_data (int fd,
|
|
||||||
size_t *size);
|
|
||||||
char *load_file_at (int dirfd,
|
|
||||||
const char *path);
|
|
||||||
int write_file_at (int dirfd,
|
|
||||||
const char *path,
|
|
||||||
const char *content);
|
|
||||||
int write_to_fd (int fd,
|
|
||||||
const char *content,
|
|
||||||
ssize_t len);
|
|
||||||
int copy_file_data (int sfd,
|
|
||||||
int dfd);
|
|
||||||
int copy_file (const char *src_path,
|
|
||||||
const char *dst_path,
|
|
||||||
mode_t mode);
|
|
||||||
int create_file (const char *path,
|
|
||||||
mode_t mode,
|
|
||||||
const char *content);
|
|
||||||
int ensure_file (const char *path,
|
|
||||||
mode_t mode);
|
|
||||||
int get_file_mode (const char *pathname);
|
|
||||||
int mkdir_with_parents (const char *pathname,
|
|
||||||
int mode,
|
|
||||||
bool create_last);
|
|
||||||
|
|
||||||
/* syscall wrappers */
|
|
||||||
int raw_clone (unsigned long flags,
|
|
||||||
void *child_stack);
|
|
||||||
int pivot_root (const char *new_root,
|
|
||||||
const char *put_old);
|
|
||||||
char *label_mount (const char *opt,
|
|
||||||
const char *mount_label);
|
|
||||||
int label_exec (const char *exec_label);
|
|
||||||
int label_create_file (const char *file_label);
|
|
||||||
|
|
||||||
static inline void
|
|
||||||
cleanup_freep (void *p)
|
|
||||||
{
|
|
||||||
void **pp = (void **) p;
|
|
||||||
|
|
||||||
if (*pp)
|
|
||||||
free (*pp);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void
|
|
||||||
cleanup_strvp (void *p)
|
|
||||||
{
|
|
||||||
void **pp = (void **) p;
|
|
||||||
|
|
||||||
strfreev (*pp);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void
|
|
||||||
cleanup_fdp (int *fdp)
|
|
||||||
{
|
|
||||||
int fd;
|
|
||||||
|
|
||||||
assert (fdp);
|
|
||||||
|
|
||||||
fd = *fdp;
|
|
||||||
if (fd != -1)
|
|
||||||
(void) close (fd);
|
|
||||||
}
|
|
||||||
|
|
||||||
#define cleanup_free __attribute__((cleanup (cleanup_freep)))
|
|
||||||
#define cleanup_fd __attribute__((cleanup (cleanup_fdp)))
|
|
||||||
#define cleanup_strv __attribute__((cleanup (cleanup_strvp)))
|
|
||||||
|
|
||||||
static inline void *
|
|
||||||
steal_pointer (void *pp)
|
|
||||||
{
|
|
||||||
void **ptr = (void **) pp;
|
|
||||||
void *ref;
|
|
||||||
|
|
||||||
ref = *ptr;
|
|
||||||
*ptr = NULL;
|
|
||||||
|
|
||||||
return ref;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* type safety */
|
|
||||||
#define steal_pointer(pp) \
|
|
||||||
(0 ? (*(pp)) : (steal_pointer) (pp))
|
|
||||||
206
external/jni/JNIHelp.h
vendored
206
external/jni/JNIHelp.h
vendored
|
|
@ -1,206 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2007 The Android Open Source Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* JNI helper functions.
|
|
||||||
*
|
|
||||||
* This file may be included by C or C++ code, which is trouble because jni.h
|
|
||||||
* uses different typedefs for JNIEnv in each language.
|
|
||||||
*
|
|
||||||
* TODO: remove C support.
|
|
||||||
*/
|
|
||||||
#ifndef NATIVEHELPER_JNIHELP_H_
|
|
||||||
#define NATIVEHELPER_JNIHELP_H_
|
|
||||||
|
|
||||||
#include "jni.h"
|
|
||||||
#include <errno.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#ifndef NELEM
|
|
||||||
# define NELEM(x) ((int) (sizeof(x) / sizeof((x)[0])))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Register one or more native methods with a particular class.
|
|
||||||
* "className" looks like "java/lang/String". Aborts on failure.
|
|
||||||
* TODO: fix all callers and change the return type to void.
|
|
||||||
*/
|
|
||||||
int jniRegisterNativeMethods(C_JNIEnv* env, const char* className, const JNINativeMethod* gMethods, int numMethods);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Throw an exception with the specified class and an optional message.
|
|
||||||
*
|
|
||||||
* The "className" argument will be passed directly to FindClass, which
|
|
||||||
* takes strings with slashes (e.g. "java/lang/Object").
|
|
||||||
*
|
|
||||||
* If an exception is currently pending, we log a warning message and
|
|
||||||
* clear it.
|
|
||||||
*
|
|
||||||
* Returns 0 on success, nonzero if something failed (e.g. the exception
|
|
||||||
* class couldn't be found, so *an* exception will still be pending).
|
|
||||||
*
|
|
||||||
* Currently aborts the VM if it can't throw the exception.
|
|
||||||
*/
|
|
||||||
int jniThrowException(C_JNIEnv* env, const char* className, const char* msg);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Throw a java.lang.NullPointerException, with an optional message.
|
|
||||||
*/
|
|
||||||
int jniThrowNullPointerException(C_JNIEnv* env, const char* msg);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Throw a java.lang.RuntimeException, with an optional message.
|
|
||||||
*/
|
|
||||||
int jniThrowRuntimeException(C_JNIEnv* env, const char* msg);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Throw a java.io.IOException, generating the message from errno.
|
|
||||||
*/
|
|
||||||
int jniThrowIOException(C_JNIEnv* env, int errnum);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Return a pointer to a locale-dependent error string explaining errno
|
|
||||||
* value 'errnum'. The returned pointer may or may not be equal to 'buf'.
|
|
||||||
* This function is thread-safe (unlike strerror) and portable (unlike
|
|
||||||
* strerror_r).
|
|
||||||
*/
|
|
||||||
const char* jniStrError(int errnum, char* buf, size_t buflen);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Returns a new java.io.FileDescriptor for the given int fd.
|
|
||||||
*/
|
|
||||||
jobject jniCreateFileDescriptor(C_JNIEnv* env, int fd);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Returns the int fd from a java.io.FileDescriptor.
|
|
||||||
*/
|
|
||||||
int jniGetFDFromFileDescriptor(C_JNIEnv* env, jobject fileDescriptor);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Sets the int fd in a java.io.FileDescriptor.
|
|
||||||
*/
|
|
||||||
void jniSetFileDescriptorOfFD(C_JNIEnv* env, jobject fileDescriptor, int value);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Returns the reference from a java.lang.ref.Reference.
|
|
||||||
*/
|
|
||||||
jobject jniGetReferent(C_JNIEnv* env, jobject ref);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Log a message and an exception.
|
|
||||||
* If exception is NULL, logs the current exception in the JNI environment.
|
|
||||||
*/
|
|
||||||
void jniLogException(C_JNIEnv* env, int priority, const char* tag, jthrowable exception);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* For C++ code, we provide inlines that map to the C functions. g++ always
|
|
||||||
* inlines these, even on non-optimized builds.
|
|
||||||
*/
|
|
||||||
#if defined(__cplusplus)
|
|
||||||
inline int jniRegisterNativeMethods(JNIEnv* env, const char* className, const JNINativeMethod* gMethods, int numMethods) {
|
|
||||||
return jniRegisterNativeMethods(&env->functions, className, gMethods, numMethods);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline int jniThrowException(JNIEnv* env, const char* className, const char* msg) {
|
|
||||||
return jniThrowException(&env->functions, className, msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" int jniThrowExceptionFmt(C_JNIEnv* env, const char* className, const char* fmt, va_list args);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Equivalent to jniThrowException but with a printf-like format string and
|
|
||||||
* variable-length argument list. This is only available in C++.
|
|
||||||
*/
|
|
||||||
inline int jniThrowExceptionFmt(JNIEnv* env, const char* className, const char* fmt, ...) {
|
|
||||||
va_list args;
|
|
||||||
va_start(args, fmt);
|
|
||||||
return jniThrowExceptionFmt(&env->functions, className, fmt, args);
|
|
||||||
va_end(args);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline int jniThrowNullPointerException(JNIEnv* env, const char* msg) {
|
|
||||||
return jniThrowNullPointerException(&env->functions, msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline int jniThrowRuntimeException(JNIEnv* env, const char* msg) {
|
|
||||||
return jniThrowRuntimeException(&env->functions, msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline int jniThrowIOException(JNIEnv* env, int errnum) {
|
|
||||||
return jniThrowIOException(&env->functions, errnum);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline jobject jniCreateFileDescriptor(JNIEnv* env, int fd) {
|
|
||||||
return jniCreateFileDescriptor(&env->functions, fd);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline int jniGetFDFromFileDescriptor(JNIEnv* env, jobject fileDescriptor) {
|
|
||||||
return jniGetFDFromFileDescriptor(&env->functions, fileDescriptor);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void jniSetFileDescriptorOfFD(JNIEnv* env, jobject fileDescriptor, int value) {
|
|
||||||
jniSetFileDescriptorOfFD(&env->functions, fileDescriptor, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline jobject jniGetReferent(JNIEnv* env, jobject ref) {
|
|
||||||
return jniGetReferent(&env->functions, ref);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void jniLogException(JNIEnv* env, int priority, const char* tag, jthrowable exception = NULL) {
|
|
||||||
jniLogException(&env->functions, priority, tag, exception);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if !defined(DISALLOW_COPY_AND_ASSIGN)
|
|
||||||
// DISALLOW_COPY_AND_ASSIGN disallows the copy and operator= functions. It goes in the private:
|
|
||||||
// declarations in a class.
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
|
|
||||||
TypeName(const TypeName&) = delete; \
|
|
||||||
void operator=(const TypeName&) = delete
|
|
||||||
#else
|
|
||||||
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
|
|
||||||
TypeName(const TypeName&); \
|
|
||||||
void operator=(const TypeName&)
|
|
||||||
#endif // __has_feature(cxx_deleted_functions)
|
|
||||||
#endif // !defined(DISALLOW_COPY_AND_ASSIGN)
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* TEMP_FAILURE_RETRY is defined by some, but not all, versions of
|
|
||||||
* <unistd.h>. (Alas, it is not as standard as we'd hoped!) So, if it's
|
|
||||||
* not already defined, then define it here.
|
|
||||||
*/
|
|
||||||
#ifndef TEMP_FAILURE_RETRY
|
|
||||||
/* Used to retry syscalls that can return EINTR. */
|
|
||||||
#define TEMP_FAILURE_RETRY(exp) ({ \
|
|
||||||
typeof (exp) _rc; \
|
|
||||||
do { \
|
|
||||||
_rc = (exp); \
|
|
||||||
} while (_rc == -1 && errno == EINTR); \
|
|
||||||
_rc; })
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* NATIVEHELPER_JNIHELP_H_ */
|
|
||||||
1
external/jni/README.md
vendored
1
external/jni/README.md
vendored
|
|
@ -1 +0,0 @@
|
||||||
Taken from https://android.googlesource.com/platform/libnativehelper/
|
|
||||||
1141
external/jni/jni.h
vendored
1141
external/jni/jni.h
vendored
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue