From 83a255962cb155bd8b64e4ca452a77b737d1841f Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez-Fernandez Date: Wed, 3 Apr 2024 12:16:45 -0700 Subject: [PATCH 1/5] Add manpages for pam_cap and capability.conf --- 0001-doc-document-pam_cap-and-its-conf.patch | 179 +++++++++++++++++++ libcap.spec | 9 +- tests/manpages/test.sh | 2 + 3 files changed, 188 insertions(+), 2 deletions(-) create mode 100644 0001-doc-document-pam_cap-and-its-conf.patch diff --git a/0001-doc-document-pam_cap-and-its-conf.patch b/0001-doc-document-pam_cap-and-its-conf.patch new file mode 100644 index 0000000..c87afb3 --- /dev/null +++ b/0001-doc-document-pam_cap-and-its-conf.patch @@ -0,0 +1,179 @@ +From 7787f4019a86b962ef3b44305cde5888a14cfe52 Mon Sep 17 00:00:00 2001 +From: Carlos Rodriguez-Fernandez +Date: Wed, 3 Apr 2024 11:57:14 -0700 +Subject: [PATCH] doc: document pam_cap and its conf + +Signed-off-by: Carlos Rodriguez-Fernandez +--- + doc/Makefile | 8 ++-- + doc/capability.conf.5 | 85 +++++++++++++++++++++++++++++++++++++++++++ + doc/pam_cap.8 | 35 ++++++++++++++++++ + 3 files changed, 125 insertions(+), 3 deletions(-) + create mode 100644 doc/capability.conf.5 + create mode 100644 doc/pam_cap.8 + +diff --git a/doc/Makefile b/doc/Makefile +index 6919488..9d1574c 100644 +--- a/doc/Makefile ++++ b/doc/Makefile +@@ -32,9 +32,10 @@ MAN3S = cap_init.3 cap_free.3 cap_dup.3 \ + psx_syscall.3 psx_syscall3.3 psx_syscall6.3 psx_set_sensitivity.3 \ + psx_load_syscalls.3 __psx_syscall.3 \ + libpsx.3 +-MAN8S = getcap.8 setcap.8 getpcaps.8 captree.8 ++MAN5S = capability.conf.5 ++MAN8S = getcap.8 setcap.8 getpcaps.8 captree.8 pam_cap.8 + +-MANS = $(MAN1S) $(MAN3S) $(MAN8S) ++MANS = $(MAN1S) $(MAN3S) $(MAN5S) $(MAN8S) + + all: $(MANS) + +@@ -54,10 +55,11 @@ html: + done + + install: +- mkdir -p -m 755 $(FAKEROOT)$(MANDIR)/man1 $(FAKEROOT)$(MANDIR)/man3 $(FAKEROOT)$(MANDIR)/man8 ++ mkdir -p -m 755 $(FAKEROOT)$(MANDIR)/man1 $(FAKEROOT)$(MANDIR)/man3 $(FAKEROOT)$(MANDIR)/man5 $(FAKEROOT)$(MANDIR)/man8 + for man in \ + $(FAKEROOT)$(MANDIR)/man1 $(MAN1S) \ + $(FAKEROOT)$(MANDIR)/man3 $(MAN3S) \ ++ $(FAKEROOT)$(MANDIR)/man5 $(MAN5S) \ + $(FAKEROOT)$(MANDIR)/man8 $(MAN8S) \ + ; \ + do \ +diff --git a/doc/capability.conf.5 b/doc/capability.conf.5 +new file mode 100644 +index 0000000..10ff63b +--- /dev/null ++++ b/doc/capability.conf.5 +@@ -0,0 +1,85 @@ ++.\" generated with Ronn-NG/v0.9.1 ++.\" http://github.com/apjanke/ronn-ng/tree/0.9.1 ++.TH "CAPABILITY\.CONF" "5" "April 2024" "" ++.SH "NAME" ++\fBcapability\.conf\fR \- pam_cap module configuration file ++.SH "SYNOPSIS" ++\fB/etc/security/capability\.conf\fR ++.SH "DESCRIPTION" ++The syntax for lines in this configuration file is: ++.P ++\fB# <\-\- \'#\' precedes a comment\fR ++.P ++\fB\fR ++.P ++Where \fB\fR refers to the text format for an inheritable IAB capability tuple, or the words \fBall\fR or \fBnone\fR\. ++.P ++The reserved word \fBall\fR does \fInot\fR grant \fIall the inheritable capabilities\fR, but acts as a simple \fIpass\-through\fR for any prevailing IAB tuple capabilities\. The reserved word \fBnone\fR refers to an empty \fIInheritable\fR capability set (and by extension an empty \fIAmbient\fR vector)\. ++.P ++Here \fB\fR refers to the space separated PAM username values that will be granted the specified \fIIAB\fR tuple\. A name prefixed with the character \fB@\fR refers to the locally defined \fB/etc/group\fR \fIetc\fR users listed under that group name\. ++.P ++The parsing of the file chooses the first line that applies to the authenticating user, and attempts to apply that and only that\. ++.P ++Examples of valid syntax are: ++.IP "" 4 ++.nf ++# only root gets to keep what it had ++ ++all root ++ ++ ++# this should fire for user beta only, who will have ++ ++# cap_chown dropped from their bounding set\. ++ ++!cap_chown beta ++ ++ ++# the next one should snag the members of the \'three\' group ++ ++# granting them cap_setuid and cap_chown ++ ++cap_setuid,cap_chown @three ++ ++ ++# this would apply to beta and gamma, but beta is already ++ ++# granted a lack of cap_chown above\. Further, if gamma is ++ ++# in the \'three\' group, it would not reach this line\. ++ ++cap_chown beta gamma ++ ++ ++# members of the \'one\' group are granted the cap_setuid Inheritable ++ ++# capability, but cap_chown is dropped from their bounding set\. ++ ++!cap_chown,cap_setuid @one ++ ++ ++# user alpha gets an ambient capability (unless it is also ++ ++# a member of the groups \'one\' or \'three\')\. ++ ++^cap_setuid alpha ++ ++ ++# user delta (if not a member of groups \'one\' and \'three\') will get ++ ++# cap_chown and cap_setgid Ambient capabilities, but have cap_setuid ++ ++# dropped from its bounding set\. ++ ++^cap_chown,^cap_setgid,!cap_setuid delta ++ ++ ++# any remaining members of group \'four\' will get the cap_setuid ++ ++# Inheritable capability\. ++ ++cap_setuid @four ++.fi ++.IP "" 0 ++.SH "SEE ALSO" ++pam_cap(8) +diff --git a/doc/pam_cap.8 b/doc/pam_cap.8 +new file mode 100644 +index 0000000..93c1a71 +--- /dev/null ++++ b/doc/pam_cap.8 +@@ -0,0 +1,35 @@ ++.\" generated with Ronn-NG/v0.9.1 ++.\" http://github.com/apjanke/ronn-ng/tree/0.9.1 ++.TH "PAM_CAP" "8" "April 2024" "" ++.SH "NAME" ++\fBpam_cap\fR \- Capabilities PAM module ++.SH "SYNOPSIS" ++[service\-name] \fBauth\fR control\-flag \fBpam_cap\fR [options] ++.SH "DESCRIPTION" ++The \fBpam_so\fR module can be used to specify \fIInheritable\fR capabilities to process trees rooted in the PAM application\. The module also supports blocking \fIBounding\fR vector capabilities and adding \fIAmbient\fR vector capabilities\. ++.P ++For general PAM apps to work correctly, the application must be run with at least \fBCAP_SETPCAP\fR raised in its \fIPermitted\fR capability flag\. Many PAM applications run as \fIroot\fR, which has all of the bits in the \fIBounding\fR set raised, so this requirement is typically met\. To grant an \fIAmbient\fR vector capability, the corresponding Permitted bit must be available to the application too\. ++.P ++The \fBpam_so\fR module is a Linux\-PAM \fIauth\fR module\. It provides functionality to back \fBpam_sm_authenticate()\fR and \fBpam_sm_setcred()\fR\. It is the latter that actually modifies the inheritable 3\-tuple of capability vectors: the configured \fIIAB\fR\. In a typical application configuration you might have a line like this: ++.IP "" 4 ++.nf ++auth optional pam_cap\.so ++.fi ++.IP "" 0 ++.P ++The module arguments are: ++.IP "\[ci]" 4 ++\fBdebug\fR: While supported, this is a no\-op at present\. ++.IP "\[ci]" 4 ++\fBconfig=\fR\fI/path/to/file\fR: Override the default config for the module\. The unspecified default value for this file is \fB/etc/security/capability\.conf\fR\. Note, \fBconfig=/dev/null\fR is a valid value\. See \fBdefault=\fR below for situations in which this might be appropriate\. ++.IP "\[ci]" 4 ++\fBkeepcaps\fR: This is as much as the \fBpam_cap\.so\fR module can do to help an application support use of the \fIAmbient\fR capability vector\. The application support for the \fIAmbient\fR set is poor at the present time\. ++.IP "\[ci]" 4 ++\fBautoauth\fR: This argument causes the \fBpam_cap\.so\fR module to return \fBPAM_SUCCESS\fR if the \fBPAM_USER\fR being authenticated exists\. The absence of this argument will cause \fBpam_cap\.so\fR to only return \fBPAM_SUCCESS\fR if the \fBPAM_USER\fR is covered by a specific rule in the prevailing config file\. ++.IP "\[ci]" 4 ++\fBdefault=\fR\fIIAB\fR: This argument is ignored if the prevailing configuration file contains a "\fB*\fR" rule\. If there is no such rule, the \fIIAB\fR 3\-tuple is inserted at the end of the config file and applies to all \fBPAM_USER\fRs not covered by an earlier rule\. Note, if you want all \fBPAM_USER\fRs to be covered by this default rule, you can supply the module argument \fBconfig=/dev/null\fR\. ++.IP "\[ci]" 4 ++\fBdefer\fR: This argument arranges for the \fIIAB\fR capabilities granted to a user to be added sufficiently late in the Linux\-PAM authentication stack that they stick\. That is, \fIafter\fR the application does its \fBsetuid(UID)\fR call\. As such, in conjunction with the \fBkeepcaps\fR module argument, such compliant applications can support granting \fIAmbient\fR vector capabilities with \fBpam_cap\.so\fR\. ++.IP "" 0 ++.SH "SEE ALSO" ++pam\.conf(5), capability\.conf(5), pam(8) +-- +2.44.0 + diff --git a/libcap.spec b/libcap.spec index b8ab0a9..8c248a6 100644 --- a/libcap.spec +++ b/libcap.spec @@ -1,6 +1,6 @@ Name: libcap Version: 2.69 -Release: 4%{?dist} +Release: 5%{?dist} Summary: Library for getting and setting POSIX.1e capabilities URL: https://sites.google.com/site/fullycapable/ License: BSD-3-Clause OR GPL-2.0-only @@ -8,6 +8,7 @@ License: BSD-3-Clause OR GPL-2.0-only Source0: https://mirrors.edge.kernel.org/pub/linux/libs/security/linux-privs/libcap2/%{name}-%{version}.tar.gz Source1: https://mirrors.edge.kernel.org/pub/linux/libs/security/linux-privs/libcap2/%{name}-%{version}.tar.sign Source2: https://git.kernel.org/pub/scm/docs/kernel/pgpkeys.git/plain/keys/29EE848AE2CCF3F4.asc +Patch0: 0001-doc-document-pam_cap-and-its-conf.patch BuildRequires: pam-devel gcc BuildRequires: make @@ -84,7 +85,8 @@ chmod +x %{buildroot}/%{_libdir}/*.so.* %{_libdir}/libpsx.so.2{,.*} %{_sbindir}/{capsh,getcap,getpcaps,setcap} %{_mandir}/man1/capsh.1* -%{_mandir}/man8/{getcap,getpcaps,setcap}.8* +%{_mandir}/man5/capability.conf.5* +%{_mandir}/man8/{getcap,getpcaps,setcap,pam_cap}.8* %{_libdir}/security/pam_cap.so %exclude %{_mandir}/man8/captree.8* @@ -112,6 +114,9 @@ chmod +x %{buildroot}/%{_libdir}/*.so.* %endif %changelog +* Wed Apr 03 2024 Carlos Rodriguez-Fernandez - 2.69-5 +- Add manpages for pam_cap and capability.conf + * Sun Feb 11 2024 Maxwell G - 2.69-4 - Rebuild for golang 1.22.0 diff --git a/tests/manpages/test.sh b/tests/manpages/test.sh index f9b20ac..db05935 100755 --- a/tests/manpages/test.sh +++ b/tests/manpages/test.sh @@ -5,9 +5,11 @@ expected_manpages=( 'capsh(1)' 'libcap(3)' # there are many more but if these are present then it verifies it because of the glob install 'libpsx(3)' + 'capability.conf(5)' 'getcap(8)' 'getpcaps(8)' 'setcap(8)' + 'pam_cap(8)' ) rlJournalStart From ea9717d27dd8ea5e1d934fcd4602a1e5f267cd2d Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez-Fernandez Date: Thu, 4 Apr 2024 20:32:51 -0700 Subject: [PATCH 2/5] Fix incompatibility of the build with go 1.22. --- libcap.spec | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/libcap.spec b/libcap.spec index 8c248a6..7979446 100644 --- a/libcap.spec +++ b/libcap.spec @@ -1,6 +1,6 @@ Name: libcap Version: 2.69 -Release: 5%{?dist} +Release: 6%{?dist} Summary: Library for getting and setting POSIX.1e capabilities URL: https://sites.google.com/site/fullycapable/ License: BSD-3-Clause OR GPL-2.0-only @@ -63,15 +63,15 @@ gzip -cd %{SOURCE0} | %{gpgverify} --keyring='%{SOURCE2}' --signature='%{SOURCE1 %build -%make_build prefix=%{_prefix} lib=%{_lib} GO_BUILD_FLAGS="-ldflags=-linkmode=external" all +%make_build prefix=%{_prefix} lib=%{_lib} GO_BUILD_FLAGS="-ldflags='-B gobuildid'" all %check make test %install -%make_install prefix=%{_prefix} lib=%{_lib} GO_BUILD_FLAGS="-ldflags=-linkmode=external" +%make_install prefix=%{_prefix} lib=%{_lib} GO_BUILD_FLAGS="-ldflags='-B gobuildid'" -mkdir -p %{buildroot}/%{_mandir}/man{2,3,8} +mkdir -p %{buildroot}/%{_mandir}/man{2,3,5,8} mv -f doc/*.3 %{buildroot}/%{_mandir}/man3/ chmod +x %{buildroot}/%{_libdir}/*.so.* @@ -114,6 +114,9 @@ chmod +x %{buildroot}/%{_libdir}/*.so.* %endif %changelog +* Thu Apr 04 2024 Carlos Rodriguez-Fernandez - 2.69-6 +- Fix incompatibility of the build with go 1.22. + * Wed Apr 03 2024 Carlos Rodriguez-Fernandez - 2.69-5 - Add manpages for pam_cap and capability.conf From 95e684ecd796d5e1de06fd04caba9465da53611b Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez-Fernandez Date: Fri, 5 Apr 2024 12:18:03 -0700 Subject: [PATCH 3/5] reenable PIE in the captree tool --- libcap.spec | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libcap.spec b/libcap.spec index 7979446..5999f33 100644 --- a/libcap.spec +++ b/libcap.spec @@ -1,6 +1,6 @@ Name: libcap Version: 2.69 -Release: 6%{?dist} +Release: 7%{?dist} Summary: Library for getting and setting POSIX.1e capabilities URL: https://sites.google.com/site/fullycapable/ License: BSD-3-Clause OR GPL-2.0-only @@ -63,13 +63,13 @@ gzip -cd %{SOURCE0} | %{gpgverify} --keyring='%{SOURCE2}' --signature='%{SOURCE1 %build -%make_build prefix=%{_prefix} lib=%{_lib} GO_BUILD_FLAGS="-ldflags='-B gobuildid'" all +%make_build prefix=%{_prefix} lib=%{_lib} CGO_REQUIRED=1 GO_BUILD_FLAGS="-buildmode=pie -ldflags='-B gobuildid'" all %check make test %install -%make_install prefix=%{_prefix} lib=%{_lib} GO_BUILD_FLAGS="-ldflags='-B gobuildid'" +%make_install prefix=%{_prefix} lib=%{_lib} CGO_REQUIRED=1 GO_BUILD_FLAGS="-buildmode=pie -ldflags='-B gobuildid'" mkdir -p %{buildroot}/%{_mandir}/man{2,3,5,8} mv -f doc/*.3 %{buildroot}/%{_mandir}/man3/ @@ -114,6 +114,9 @@ chmod +x %{buildroot}/%{_libdir}/*.so.* %endif %changelog +* Fri Apr 05 2024 Carlos Rodriguez-Fernandez - 2.69-7 +- Reenable PIE in the captree tool + * Thu Apr 04 2024 Carlos Rodriguez-Fernandez - 2.69-6 - Fix incompatibility of the build with go 1.22. From ec001e0d308eb02bcfae24de2d71644ca8464d1e Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez-Fernandez Date: Fri, 5 Apr 2024 16:46:04 -0700 Subject: [PATCH 4/5] make correction to the capability.conf manpage --- ...ent-the-use-of-to-refer-to-all-users.patch | 26 +++++++++++++++++++ libcap.spec | 6 ++++- 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 0001-doc-document-the-use-of-to-refer-to-all-users.patch diff --git a/0001-doc-document-the-use-of-to-refer-to-all-users.patch b/0001-doc-document-the-use-of-to-refer-to-all-users.patch new file mode 100644 index 0000000..9741d75 --- /dev/null +++ b/0001-doc-document-the-use-of-to-refer-to-all-users.patch @@ -0,0 +1,26 @@ +From 70783bddc65628a1afc3dd2f8b4b3f03fc839b8e Mon Sep 17 00:00:00 2001 +From: Carlos Rodriguez-Fernandez +Date: Fri, 5 Apr 2024 16:37:30 -0700 +Subject: [PATCH] doc: document the use of `*` to refer to all users + +Signed-off-by: Carlos Rodriguez-Fernandez +--- + doc/capability.conf.5 | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/doc/capability.conf.5 b/doc/capability.conf.5 +index 10ff63b..15535f4 100644 +--- a/doc/capability.conf.5 ++++ b/doc/capability.conf.5 +@@ -16,7 +16,7 @@ Where \fB\fR refers to the text format for an inheritable IAB capability tu + .P + The reserved word \fBall\fR does \fInot\fR grant \fIall the inheritable capabilities\fR, but acts as a simple \fIpass\-through\fR for any prevailing IAB tuple capabilities\. The reserved word \fBnone\fR refers to an empty \fIInheritable\fR capability set (and by extension an empty \fIAmbient\fR vector)\. + .P +-Here \fB\fR refers to the space separated PAM username values that will be granted the specified \fIIAB\fR tuple\. A name prefixed with the character \fB@\fR refers to the locally defined \fB/etc/group\fR \fIetc\fR users listed under that group name\. ++Here \fB\fR refers to the space separated PAM username values that will be granted the specified \fIIAB\fR tuple\. A name prefixed with the character \fB@\fR refers to the locally defined \fB/etc/group\fR \fIetc\fR users listed under that group name\. An asterisk "\fB*\fR" can be used to denote all users\. + .P + The parsing of the file chooses the first line that applies to the authenticating user, and attempts to apply that and only that\. + .P +-- +2.44.0 + diff --git a/libcap.spec b/libcap.spec index 5999f33..7955ee0 100644 --- a/libcap.spec +++ b/libcap.spec @@ -1,6 +1,6 @@ Name: libcap Version: 2.69 -Release: 7%{?dist} +Release: 8%{?dist} Summary: Library for getting and setting POSIX.1e capabilities URL: https://sites.google.com/site/fullycapable/ License: BSD-3-Clause OR GPL-2.0-only @@ -9,6 +9,7 @@ Source0: https://mirrors.edge.kernel.org/pub/linux/libs/security/linux-privs/lib Source1: https://mirrors.edge.kernel.org/pub/linux/libs/security/linux-privs/libcap2/%{name}-%{version}.tar.sign Source2: https://git.kernel.org/pub/scm/docs/kernel/pgpkeys.git/plain/keys/29EE848AE2CCF3F4.asc Patch0: 0001-doc-document-pam_cap-and-its-conf.patch +Patch1: 0001-doc-document-the-use-of-to-refer-to-all-users.patch BuildRequires: pam-devel gcc BuildRequires: make @@ -114,6 +115,9 @@ chmod +x %{buildroot}/%{_libdir}/*.so.* %endif %changelog +* Fri Apr 05 2024 Carlos Rodriguez-Fernandez - 2.69-8 +- Make correction to the capability.conf manpage + * Fri Apr 05 2024 Carlos Rodriguez-Fernandez - 2.69-7 - Reenable PIE in the captree tool From 4521e03315ce8d995f83db54ec74fdccda12a84a Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez-Fernandez Date: Sun, 14 Apr 2024 21:28:04 -0700 Subject: [PATCH 5/5] fix golang version dependency --- libcap.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libcap.spec b/libcap.spec index 7955ee0..641742c 100644 --- a/libcap.spec +++ b/libcap.spec @@ -17,7 +17,7 @@ BuildRequires: glibc-static BuildRequires: gnupg2 %ifarch %{golang_arches} -BuildRequires: golang >= 1.11 +BuildRequires: golang >= 1.22 %endif %description