summaryrefslogtreecommitdiff
path: root/progs
Commit message (Collapse)AuthorAgeFilesLines
* Fix to 'make clean sudotest' reliablyAndrew G. Morgan2021-09-241-1/+1
| | | | Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
* Fix typo in capsh.Andrew G. Morgan2021-09-141-1/+1
| | | | Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
* Implement --strict capsh argument.Andrew G. Morgan2021-09-072-88/+89
| | | | | | | | | | | | | | Up to this point, capsh hides some complexity concerning raising the CAP_SETPCAP in order to raise inheritable and drop bounding set values. This made it harder to explain some aspects of inheritance, and I ran into that detail writing this: https://sites.google.com/site/fullycapable/why-didnt-that-work#h.z7rwbcazhr4r Refactored capsh.c to clean up some buggy code, and also fix some documentation, including reference to the --strict argument. Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
* Be more systematic about POSIX.1e value group namesAndrew G. Morgan2021-09-071-17/+22
| | | | | | | cap.Set's have Flag component Values cap.IAB's have Vector component Values Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
* Fixed parallel make issuesAndrew G. Morgan2021-09-051-1/+1
| | | | | | Tried make -j12 and these fixes were needed. Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
* Treat ENOTSUP as an expected error for getcap.Andrew G. Morgan2021-09-051-1/+1
| | | | | | | | | | | | Things like /proc/* files don't support capabilities on them and if getcap looks at them it generates a lot of errors. Treat it as equivalent to there being no capability on the file. This addresses https://bugzilla.kernel.org/show_bug.cgi?id=214317 Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
* Add --mode query support to capshAndrew G. Morgan2021-09-051-24/+33
| | | | | | | | This addresses the feature request: https://bugzilla.kernel.org/show_bug.cgi?id=214319 Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
* Refactor top level Makefile to reduce redundant buildingAndrew G. Morgan2021-09-041-2/+3
| | | | | | Make build a bit quicker for folk that don't want to run tests. Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
* Move $(LDFLAGS) earlier in build command lines.Andrew G. Morgan2021-08-311-2/+4
| | | | | | | | | As explained (thanks David Seifert) there are some LDFLAGS that need to precede actual linked libraries. For example, -Wl,--as-needed. Given this, I've tried it and it appears to work for the default build cases as captured in 'make distcheck'. Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
* Be more consistent with make variables.Andrew G. Morgan2021-08-301-2/+2
| | | | | | | | Noticed that we weren't applying the same amount of flag discipline to local BUILD_* tool rules. Fixing that, I see we've been carrying a source code issue in libcap/_makenames.c for a while. (FIXED). Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
* Make sudotest more robust against untestable environmentsAndrew G. Morgan2021-08-282-6/+19
| | | | | | | I'm setting up some testing environments and they are not all created equal. Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
* More fixes for static analysis issues.Andrew G. Morgan2021-08-272-11/+30
| | | | | | | | | Further observations from Zoltan Fridrich's static analysis of libcap. This commit also includes a fix for something I broke with the last round of "fixing", and a test to make sure I don't make that mistake again. Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
* Fix some static analysis results.Andrew G. Morgan2021-08-263-5/+26
| | | | | | This series of issues was found by Zoltan Fridrich. Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
* Support overriding choice of 'sudo'.Andrew G. Morgan2021-08-251-1/+1
| | | | | | | | Use something like: make SUDO=my_sudo sudotest Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
* Add some more information to help, and contextual error messages.Andrew G. Morgan2021-08-251-7/+21
| | | | | | | This was inspired by a feature Debian has been patching orginally credited to Zhi Li. Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
* Make 'progs/getpcaps --iab' act like 'go/captree' in output formatAndrew G. Morgan2021-08-231-12/+23
| | | | | | | | | The combined options 'getpcaps --iab --verbose' will show everything in detail (even the boring stuff). Also used this exercise to test the libcap changes for iab comparisons. Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
* Revert most of the LDFLAGS -> LDSTATIC change.Andrew G. Morgan2021-08-231-3/+6
| | | | | | | | | | | | The intention was to force --static linking in only one corner case, so be more explicit about that one, and revert the build behavior in the others. Reason for doing this was feedback from Arnout Vandecappelle in: https://bugzilla.kernel.org/show_bug.cgi?id=214023#c16 Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
* Add cap_iab_{compare,get_pid} functions to libcap; --iab to getpcaps.Andrew G. Morgan2021-08-221-2/+20
| | | | | | | | | | | | | This brings libcap back to parity with the Go 'cap' package. We provide a CAP_IAB_DIFFERS(result, vector) macro to evaluate the result of cap_iab_compare(). Extend the getpcaps arguments to include --iab. This causes the utility to explore the IAB tuple for the specified process. When used, this outputs a text representation in a similar format to that of the 'captree' (Go) utility. Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
* Drop non-standard IPATH in favor of CPPFLAGS.Andrew G. Morgan2021-08-191-3/+3
| | | | | | | This also required locally augmenting CFLAGS with -fPIC in the Makefile's that required it. Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
* Fix typos.Samanta Navarro2021-08-142-5/+5
| | | | | | | Typos found with codespell Signed-off-by: Samanta Navarro <ferivoz@riseup.net> Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
* Support distributions that build libcap with aggressive link options.Andrew G. Morgan2021-08-131-4/+4
| | | | | | | | | | | | Discussion of one such setup in this bug (reported by David Runge): https://bugzilla.kernel.org/show_bug.cgi?id=214023 Work around the failure to run ./pam_cap.so in these cases with some more Makefile magic, and adjust test building with these flags so it works in DYNAMIC=yes|no and SHARED=yes|no cases. Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
* When --suggest'ing also compare against capability namesAndrew G. Morgan2021-07-021-0/+10
| | | | Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
* Provide a '--current' command line argument for capsh.Andrew G. Morgan2021-07-022-12/+29
| | | | | | | | | This is equivalent to 'capsh --print|fgrep Current'. I've been using that combination a lot in the write-ups on the libcap website (https://sites.google.com/site/fullycapable/) and so it struck me that capsh probably should support it natively. Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
* Clean up some compilation warningsAndrew G. Morgan2021-06-201-0/+1
| | | | | | Also amend .gitignore to ignore uns_test binary in the progs directory. Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
* Add kernel test to quicktest.shAndrew G. Morgan2021-06-192-2/+13
| | | | | | | | This resolves: https://bugzilla.kernel.org/show_bug.cgi?id=212737 Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
* Make capsh an installed binary againAndrew G. Morgan2021-05-281-2/+2
| | | | | | | | Bug report from Jan Palus: https://bugzilla.kernel.org/show_bug.cgi?id=213261 Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
* Add support for --suggest=phrase to capsh.Andrew G. Morgan2021-05-162-16/+42
| | | | | | | | | | | | | | | Ever wondered something like which capability allows a process to do privileged things with a tty? Try this: capsh --suggest="tty" cap_sys_tty_config (26) [/proc/self/status:CapXXX: 0x0000000004000000] Allows a process to manipulate tty devices: - configure tty devices - perform vhangup() of a tty Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
* Validate that user namespaces require CAP_SETFCAP to map UID=0.Andrew G. Morgan2021-05-161-0/+5
| | | | | | | | | | | I found this corner case privilege escalation in December 2020. Now that it is fixed upstream and widely deployed, add a test so we don't regress. [If you find 'make sutotest' fails for you, you should upgrade your kernel.] Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
* Fruit of more static analysis resultsAndrew G. Morgan2021-04-221-6/+18
| | | | | | Fixes for further analysis issues from Zoltan Fridrich of Redhat. Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
* Bug fixes identified by static code analysis.Andrew G. Morgan2021-04-211-8/+22
| | | | | | | Analysis and much of this commit was contributed by Zoltan Fridrich of Redhat. Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
* Add --explain=cap_foo support to capsh.Andrew G. Morgan2021-03-274-8/+496
| | | | | | | | | | | A convenience feature, so you don't have to grep the system header, and/or wade through a man page. This addresses: https://bugzilla.kernel.org/show_bug.cgi?id=212451 Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
* Trying to stop the DOS attack on me from lawyers.Andrew G. Morgan2021-02-144-7/+8
| | | | | | | | | | | | | | | | | | | | | | Reformatted the license files to capture the same info but in a more clear way. Note, I have migrated the license texts to "License" files since, apparently, LICENSE files are picked up and parsed by all sorts of automation that I don't want to reverse engineer. The compiled binaries refer to said LICENSE file(s). The default LICENSE files refer to the License files for details. It is expected that folk that build against libcap and friends, and need to choose one or the other license will simplify their copies of LICENSE consistent with their own needs and the scope explained in the License file(s). All code distributed with the official libcap, unless explicitly stated, is covered by the libcap License file. Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
* Augment NOPRIV libcap mode with the sticky NO_NEW_PRIVS prctl bit.Andrew G. Morgan2020-12-261-2/+15
| | | | | | | | Since I last visited securebits no privs mode, a new prctl bit has been added (it isn't a securebit, but a parallel implementation of something similar). So, layer that bit on top of NOPRIV mode. Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
* People keep emailing me about the license for libcap.Andrew G. Morgan2020-12-264-41/+65
| | | | | | | | | | | | There seems to have been a misconception that the tools and library are GPL only. This has never been the case. The system was developed from the start with a you-choose license: GPL(2 at the time) OR BSD 3-clause. When GPL3 was released, it was decided that the distribution would not follow that. As such, everything is: BSD 3-clause or GPL2 (you choose). Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
* Clean up the exit status to match other binaries.Andrew G. Morgan2020-12-261-5/+5
| | | | Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
* checkpointAndrew G. Morgan2020-12-233-10/+15
|
* Improve the usage and diagnostic message for setcapAndrew G. Morgan2020-12-221-14/+30
| | | | | | | Also, explicitly support -h rather than fail over to display the usage info. Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
* Make quicktest.sh work again with kernel testAndrew G. Morgan2020-12-071-1/+3
| | | | | | | | | | | | | It has been a while since I tried: make -C kdebug test A few details for quicktest.sh's dependencies have changed, so accommodate them. Also support custom local experiments in the QEMU session. Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
* Guarantee sufficient memory for scratch pathnameAndrew G. Morgan2020-10-281-1/+1
| | | | | | | Fix a malloc bug with single entry/short PATHs in capsh code for "==" support. Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
* Support systems with no available pthreads support.Andrew G. Morgan2020-10-271-7/+8
| | | | | | | | | | | | This change addresses: https://bugzilla.kernel.org/show_bug.cgi?id=209875 Howto: make PTHREADS=no ... Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
* If needed search PATH for capsh (==) self-execution.Andrew G. Morgan2020-10-272-2/+56
| | | | | | | | | | | | This addresses the following bug: https://bugzilla.kernel.org/show_bug.cgi?id=209873 Namely, the following didn't previously work: PATH=/sbin capsh == --print Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
* Be slightly more selective in what to build.Andrew G. Morgan2020-09-121-2/+4
| | | | | | | | | | The static build of progs and tests, only needs the .a libraries to be built. Bug report from Thomas Petazzoni (trying to get capsh etc to build against uClibc statically). Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
* Migrate all uses of tcapsh-static to sudotest target.Andrew G. Morgan2020-09-071-1/+1
| | | | | | | Since sudotest is mostly the reason for using a static binary, force all uses to be under this test target. Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
* Support dynamic test compilation and execution.Andrew G. Morgan2020-09-073-9/+15
| | | | | | | | | | | make DYNAMIC=yes test sudotest works now. Thomas Petazzoni provided a patch that built the tests this way, but I've restructured things to make the above command line work against the uninstalled library builds. Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
* capsh.c: Spelling fixes in usage() messageMichael Kerrisk (man-pages)2020-07-161-2/+2
| | | | | Signed-off-by: Michael Kerrisk (man-pages) <mtk.manpages@gmail.com> Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
* Better protect some header #define's.Andrew G. Morgan2020-06-042-0/+3
| | | | | | | Apparently some folk like to supply these defines on the compiler command line. Protect these defines with some more macrology. Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
* Work around a bug in glibc.Andrew G. Morgan2020-06-011-9/+9
| | | | | | | | | | When compiled statically getpwuid() can't handle an unsupported uid. So, pick the test uids we use to be likely to be defined. Filed a glibc bug with redhat since this was discovered on a fedora-32 system: https://bugzilla.redhat.com/show_bug.cgi?id=1842745 Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
* Fix typosChristian Kastner2020-05-121-1/+1
| | | | | Signed-off-by: Christian Kastner <ckk@kvr.at> Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
* Support overriding the preferred shell for capsh.Andrew G. Morgan2020-04-052-7/+15
| | | | | | | | | Either supply --shell=/xx/yy as an argument to capsh, or use the Make.Rules CAPSH_SHELL override when building. This is an adaptation of an idea from Rosen Penev. Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
* Remove ` character from getcap outputretornam2020-02-251-2/+2
| | | | | | | This update removes the ` character in output Signed-off-by: Raymond Etornam <retornam@users.noreply.github.com> Signed-off-by: Andrew G. Morgan <morgan@kernel.org>