Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
devel:openSUSE:Factory:rpmlint
pesign-obs-integration
pesign-obs-integration-10.2+git20240723.d344d91...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File pesign-obs-integration-10.2+git20240723.d344d91.obscpio of Package pesign-obs-integration
07070100000000000081A4000000000000000000000001669F469C000046AC000000000000000000000000000000000000003800000000pesign-obs-integration-10.2+git20240723.d344d91/COPYING GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 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. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, 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 software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, 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 redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's 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 give any other recipients of the Program a copy of this License along with the Program. 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 Program or any portion of it, thus forming a work based on the Program, 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) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, 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 Program, 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 Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) 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; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, 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 executable. 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. If distribution of executable or 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 counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program 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. 5. 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 Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program 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. 7. 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 Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program 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 Program. 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. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program 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. 9. The Free Software Foundation may publish revised and/or new versions of the 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 Program 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 Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, 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 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "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 PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. 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 PROGRAM 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 PROGRAM (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 PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 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 Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. 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 program's name and a brief idea of what it does.> Copyright (C) <year> <name of author> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program 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 General Public License for more details. You should have received a copy of the GNU General Public License along with this program; 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. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. <signature of Ty Coon>, 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. 07070100000001000081A4000000000000000000000001669F469C00000B38000000000000000000000000000000000000003A00000000pesign-obs-integration-10.2+git20240723.d344d91/README.md # Signing kernel modules and EFI binaries in the Open Build Service RPM packages that need to sign files during build should add the following lines to the specfile ``` # needssslcertforbuild export BRP_PESIGN_FILES='pattern...' BuildRequires: pesign-obs-integration ``` Debian packages need to add the following line to the Source stanza in the debian/control file, which will add "Obs: needssslcertforbuild" to the generated .dsc file: ```XS-Obs: needssslcertforbuild``` The "# needssslcertforbuild" comment tells the buildservice to store the signing certificate in %_sourcedir/_projectcert.crt. At the end of the install phase, the brp-99-pesign script computes hashes of all files matching the patterns in $BRP_PESIGN_FILES. The sha256 hashes are stored in %_topdir/OTHER/%name.cpio.rsasign, plus the script places a pesign-repackage.spec file there. When the first rpmbuild finishes, the buildservice sends the cpio archive to the signing server, which returns a rsasigned.cpio archive with RSA signatures of the sha256 hashes. The pesign-repackage.spec takes the original RPMs, unpacks them and appends the signatures to the files. It then uses the pesign-gen-repackage-spec script to generate another specfile, which builds new RPMs with signed files. The supported file types are: - *.ko - Signature appended to the module - efi binaries - Signature embedded in a header. If a HMAC checksum named .$file.hmac exists, it is regenerated Debian packages can use the dh-signobs debhelper to automate signing and repacking. Build-depend on dh-signobs and add --with signobs to the dh line in debian/rules to use the fully automated helper. Consult the dh_signobs manpage for more information. ## Options ### Kernel Module Compression When BRP_PESIGN_COMPRESS_MODULE is passed, the script tries to compress the kernel modules at the repackaging phase. Currently xz, gzip and zstd format is supported. For enable the compression feature, put the following along with BRP_PESIGN_FILES setup: ```export BRP_PESIGN_COMPRESS_MODULE="xz"``` ### Dependency Generation If you need macros within the pesign-repackage specfile to adjust [dependency generation](https://rpm-software-management.github.io/rpm/manual/dependency_generators.html) , then place these in a source file called pesign-spec-macros, this will subseqently be loaded. Example of pesign-spec-macros: ```%__kmp_supplements %_sourcedir/my-find-supplements %_sourcedir/pci_ids-%{version}``` To save creating duplicate copies of macros, load this file from your existing spec file by using the following: ```%{load:%{_sourcedir}/pesign-spec-macros}``` If you need some source files such as dependency generation scripts then place the names of these source files in a source file called pesign-copy-sources. Example of pesign-copy-sources: ``` my-find-supplements pci_ids-%{version} ``` 07070100000002000081ED000000000000000000000001669F469C00000208000000000000000000000000000000000000004800000000pesign-obs-integration-10.2+git20240723.d344d91/brp-99-compress-vmlinux#!/bin/bash # Compress the /boot/vmlinux image after find-debuginfo.sh has done its job set -e case "$RPM_PACKAGE_NAME" in kernel-*) ;; *) exit 0 esac for f in $RPM_BUILD_ROOT/boot/vmlinux-*; do if [ -L "$f" ]; then f=`readlink -f "$f"` fi for compression in gz/gzip xz; do if test -e "$f" -a -e "$f.${compression%/*}"; then echo "${compression#*/} $f" # Deliberately not using -n; the vmlinux image has a # predictable timestamp (bnc#880848#c20) ${compression#*/} -k -9 -f "$f" fi done done 07070100000003000081A4000000000000000000000001669F469C00001393000000000000000000000000000000000000003E00000000pesign-obs-integration-10.2+git20240723.d344d91/brp-99-pesign#!/bin/bash # This script is run by rpmbuild at the end of the brp checks. It computes # hashes of files listed in the BRP_PESIGN_FILES environment and stores them in # %_topdir/OTHER/%name.cpio.rsasign. It also puts a specfile there, that # is later used to repackage the RPMs. # # Copyright (c) 2013 SUSE Linux Products GmbH, Nuernberg, Germany. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA set -e files="*.ko" if test -n "${BRP_PESIGN_FILES+x}"; then files=${BRP_PESIGN_FILES} fi output= while test $# -gt 0; do case "$1" in --files) files=$2 shift 2 ;; --output) output=$2 shift 2 ;; *) echo "$0: Unknown option: $1" >&2 exit 1 esac done if test -z "$files"; then exit 0 fi if test -z "$output"; then output=`rpm --eval %_topdir/OTHER` fi if test -z "$RPM_BUILD_ROOT"; then echo "$0: warning: \$RPM_BUILD_ROOT not set, using the root directory" >&2 RPM_BUILD_ROOT=/ fi if ! mkdir -p "$output"; then echo "$0: warning: $output cannot be created, giving up" >&2 exit 0 fi case "$BRP_PESIGN_GRUB_RESERVATION" in '') pesign_grub_reservation="0" ;; *[!0-9]*) echo "$0: warning: non-numerc value '$BRP_PESIGN_GRUB_RESERVATION' of BRP_PESIGN_GRUB_RESERVATION" >&2 pesign_grub_reservation="0" ;; *) pesign_grub_reservation="${BRP_PESIGN_GRUB_RESERVATION}" ;; esac if test "${BRP_PESIGN_COMPRESS_MODULE}" = "xz"; then pesign_repackage_compress="--compress xz" elif test "${BRP_PESIGN_COMPRESS_MODULE}" = "gzip"; then pesign_repackage_compress="--compress gzip" elif test "${BRP_PESIGN_COMPRESS_MODULE}" = "zstd"; then pesign_repackage_compress="--compress zstd" else pesign_repackage_compress="" fi cert=$RPM_SOURCE_DIR/_projectcert.crt if test -e "$cert"; then echo "Using signing certificate $cert" else echo "No buildservice signing certificate" cert=/dev/null fi if test -e $RPM_SOURCE_DIR/pesign-spec-macros; then sed " s:%{name}:$RPM_PACKAGE_NAME:g s:%{version}:$RPM_PACKAGE_VERSION:g " $RPM_SOURCE_DIR/pesign-spec-macros > $output/pesign-spec-macros spec_macros="--macros pesign-spec-macros" fi if test -e $RPM_SOURCE_DIR/pesign-copy-sources; then sed " s:%{name}:$RPM_PACKAGE_NAME:g s:%{version}:$RPM_PACKAGE_VERSION:g " $RPM_SOURCE_DIR/pesign-copy-sources > $output/pesign-copy-sources while read -r line; do if [ -n "${line}" ]; then source_files="${source_files}${RPM_SOURCE_DIR}/${line}\n" fi done < $output/pesign-copy-sources echo -e "$source_files" | head -c -1 | cpio -o > $output/source_files.cpio rm $output/pesign-copy-sources fi sed " s:@NAME@:$RPM_PACKAGE_NAME:g s:@PESIGN_GRUB_RESERVATION@:$pesign_grub_reservation:g s:@PESIGN_REPACKAGE_COMPRESS@:$pesign_repackage_compress:g s:@PESIGN_LOAD_SPEC_MACROS@:$spec_macros:g /@CERT@/ { r $cert d } " /usr/lib/rpm/pesign/pesign-repackage.spec.in >"$output/pesign-repackage.spec" date="$(LANG=C date --utc --date "@${SOURCE_DATE_EPOCH:-$(date +%s)}" '+%a %b %d %H:%M:%S %Z %Y')" cat <<EOF >"$output/pesign-repackage.changes" ------------------------------------------------------------------- $date - openSUSE <packaging@lists.opensuse.org> - automatically generated EOF for rpmlintrc in $RPM_SOURCE_DIR/*rpmlintrc; do if test -e "$rpmlintrc"; then cp "$rpmlintrc" "$output/" fi done cd "$RPM_BUILD_ROOT" args=() for pattern in $files; do pattern=${pattern#/} if test "${pattern:0:2}" != "./"; then pattern="./$pattern" fi if test -d "$pattern"; then pattern="$pattern/*" fi args=("${args[@]}" -o -path "$pattern") done # delete the leading -o unset args[0] archive=$output/$RPM_PACKAGE_NAME.cpio.rsasign archive_dir=$output/$RPM_PACKAGE_NAME mkdir -p "$archive_dir" # create an empty nss database to make pesign happy nss_db=$(mktemp -d) trap 'rm -rf "$nss_db"' EXIT echo foofoofoo > "$nss_db/passwd" certutil -N -d "$nss_db" -f "$nss_db/passwd" echo "Creating $archive" files=($(find . -type f \( "${args[@]}" \))) for f in "${files[@]}"; do dest="$archive_dir/$f" mkdir -p "${dest%/*}" case "$f" in ./boot/* | *.efi | */lib/modules/*/vmlinu[xz] | */lib/modules/*/[Ii]mage | */lib/modules/*/z[Ii]mage) if [ -f /usr/bin/pesign ]; then pesign --certdir="$nss_db" -i "$f" -E $dest else # Non PE architectures like s390x cp "$f" "$dest" fi ;; *) cp "$f" "$dest" esac done cd "$archive_dir" find . -type f | cpio -H newc -o >"$archive" rm -rf "$archive_dir" 07070100000004000041ED000000000000000000000001669F469C00000000000000000000000000000000000000000000003700000000pesign-obs-integration-10.2+git20240723.d344d91/debian07070100000005000081A4000000000000000000000001669F469C00000125000000000000000000000000000000000000004100000000pesign-obs-integration-10.2+git20240723.d344d91/debian/changelogpesign-obs-integration (10.1) unstable; urgency=medium * Update to 10.1 -- Gary Lin <glin@suse.com> Tue, 11 Dec 2018 18:31:01 +0800 pesign-obs-integration (10.0) unstable; urgency=medium * Initial Debian packaging. -- Michal Marek <mmarek@suse.cz> Tue, 31 Oct 2017 17:44:08 +0000 07070100000006000081A4000000000000000000000001669F469C00000002000000000000000000000000000000000000003E00000000pesign-obs-integration-10.2+git20240723.d344d91/debian/compat7 07070100000007000081A4000000000000000000000001669F469C00000347000000000000000000000000000000000000003F00000000pesign-obs-integration-10.2+git20240723.d344d91/debian/controlSource: pesign-obs-integration Section: devel Priority: optional Maintainer: Michal Marek <mmarek@suse.cz> Build-Depends: debhelper (>= 7), openssl, shellcheck Standards-Version: 3.9.8 Package: pesign-obs-integration Architecture: all Depends: ${perl:Depends}, ${misc:Depends}, libnss3-tools, openssl, pesign Description: Automate signing EFI binaries and kernel modules on OBS This package provides scripts and rpm macros to automate signing of the boot loader, kernel and kernel modules in the openSUSE Buildservice. Package: dh-signobs Architecture: all Enhances: debhelper Depends: ${misc:Depends}, debhelper, cpio, libnss3-tools, jq, pesign, pesign-obs-integration, openssl Description: Debian Helper for EFI signing on OBS Adds a helper sequence to dh to send EFI signatures to OBS and to re-package them using the templates. 07070100000008000081A4000000000000000000000001669F469C00000787000000000000000000000000000000000000004100000000pesign-obs-integration-10.2+git20240723.d344d91/debian/copyrightFormat: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Source: https://github.com/openSUSE/pesign-obs-integration Files: * Copyright: 2013-2017 SUSE LINUX Products GmbH License: GPL-2 This package is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. . This package 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 General Public License for more details. . You should have received a copy of the GNU General Public License along with this package; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA . On Debian systems, the complete text of the GNU General Public License version 2 can be found in `/usr/share/common-licenses/GPL-2'. Files: dh_signobs signobs.pm debian/* Copyright: 2018 Luca Boccassi <bluca@debian.org> License: GPL-2+ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. . This program 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 General Public License for more details. . You should have received a copy of the GNU General Public License along with this package; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA . On Debian systems, the full text of the GNU General Public License version 2 can be found in the file `/usr/share/common-licenses/GPL-2'. 07070100000009000081A4000000000000000000000001669F469C00000049000000000000000000000000000000000000004A00000000pesign-obs-integration-10.2+git20240723.d344d91/debian/dh-signobs.installdh_signobs usr/bin/ signobs.pm usr/share/perl5/Debian/Debhelper/Sequence 0707010000000A000081A4000000000000000000000001669F469C0000015A000000000000000000000000000000000000004800000000pesign-obs-integration-10.2+git20240723.d344d91/debian/dh-signobs.linksusr/bin/dh_signobs usr/bin/dh_signobs_pack usr/bin/dh_signobs usr/bin/dh_signobs_unpack usr/bin/dh_signobs usr/bin/dh_signobs_getcert usr/share/man/man1/dh_signobs.1 usr/share/man/man1/dh_signobs_pack.1 usr/share/man/man1/dh_signobs.1 usr/share/man/man1/dh_signobs_unpack.1 usr/share/man/man1/dh_signobs.1 usr/share/man/man1/dh_signobs_getcert.1 0707010000000B000081A4000000000000000000000001669F469C0000000D000000000000000000000000000000000000004B00000000pesign-obs-integration-10.2+git20240723.d344d91/debian/dh-signobs.manpagesdh_signobs.1 0707010000000C000081A4000000000000000000000001669F469C00000007000000000000000000000000000000000000003C00000000pesign-obs-integration-10.2+git20240723.d344d91/debian/docsREADME 0707010000000D000081A4000000000000000000000001669F469C0000010E000000000000000000000000000000000000005600000000pesign-obs-integration-10.2+git20240723.d344d91/debian/pesign-obs-integration.installpesign-gen-repackage-spec usr/lib/rpm/pesign/ kernel-sign-file usr/lib/rpm/pesign/ gen-hmac usr/lib/rpm/pesign/ pesign-repackage.spec.in usr/lib/rpm/pesign/ brp-99-pesign usr/lib/rpm/brp-suse.d/ brp-99-compress-vmlinux usr/lib/rpm/brp-suse.d/ modsign-repackage usr/bin/ 0707010000000E000081ED000000000000000000000001669F469C0000023B000000000000000000000000000000000000003D00000000pesign-obs-integration-10.2+git20240723.d344d91/debian/rules#!/usr/bin/make -f # -*- makefile -*- # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 %: dh $@ override_dh_auto_clean: rm -f pesign-cert.x509 dh_auto_clean override_dh_auto_build: if test -e ../SOURCES/_projectcert.crt; then \ openssl x509 -inform PEM -in ../SOURCES/_projectcert.crt \ -outform DER -out pesign-cert.x509; \ fi dh_auto_build override_dh_install: dh_install if test -e pesign-cert.x509; then \ dh_install -p pesign-obs-integration pesign-cert.x509 /usr/lib/rpm/pesign; \ fi override_dh_auto_test: shellcheck dh_signobs 0707010000000F000041ED000000000000000000000001669F469C00000000000000000000000000000000000000000000003E00000000pesign-obs-integration-10.2+git20240723.d344d91/debian/source07070100000010000081A4000000000000000000000001669F469C0000000D000000000000000000000000000000000000004500000000pesign-obs-integration-10.2+git20240723.d344d91/debian/source/format3.0 (native) 07070100000011000081A4000000000000000000000001669F469C00000015000000000000000000000000000000000000004600000000pesign-obs-integration-10.2+git20240723.d344d91/debian/source/optionscompression = "gzip" 07070100000012000081ED000000000000000000000001669F469C00003D00000000000000000000000000000000000000003B00000000pesign-obs-integration-10.2+git20240723.d344d91/dh_signobs#!/bin/bash # SPDX-License-Identifier: GPL-2.0+ # Copyright: 2018 Luca Boccassi <bluca@debian.org> set -e # Build-Depend on dh-signobs. # Enable by using dh --with=signobs. # If the certificate is necessary at build time, for example to include in the kernel or shim, # annotate the Source stanza of debian/control with: # XS-Obs: needssslcertforbuild # Then it can be fetched in PEM format with: # dh_signobs_getcert DESTINATION # Append DER to retrieve it in binary format instead. # # This debhelper will run in 2 steps - first after the dh_install phase, when the source # package will have built and installed the unsigned binaries. The second step during the # followup build after OBS has signed the binaries, before dh_auto_install runs. # # During the first step dh_signobs_pack will be called to get the hashes (or kernel modules) # and pack them into a cpio archive in ../OTHER that OBS can use. At the same time a new # source package for the OBS followup build will be generated, either from a source-template # that can be specified by the package being signed or automatically generated by this debhelper. # # The source template can be in any form it wants, as long as it is placed in a directory # called "source-template" in the debian/ directory (can be a subdirectory, and it can be # static or generated). Also a files.json list of the binaries to sign must be placed in the # same PARENT directory with the following format: # {"unsigned-binary-package": { # "files": [ # {"sig_type": "efi", "file": "usr/lib/foo/bar.efi"}, # {"sig_type": "linux-module", "file": "lib/modules/1.2.3/baz.ko"} # ] # }} # The advantage of the templated build is that it can sign only a subset of files - for # example, a kernel build with CONFIG_MODULE_SIG_ALL=y does not need to sign the modules and # can save a lot of time by just signing the vmlinuz. # # The autogenerated package will simply look for any .efi, .ko or vmlinuz- file in the debian # directory (excluding debian/tmp) and considers the first subdirectory to be the package name # (IOW: it covers the common case where built files are first installed in debian/tmp/path and # then moved by dh_install into debian/pkg/path), and then generates a new source package that # unpacks the packages that contain them and repacks them after signing the binaries. # The files.json can be used also with the autogenerated package, simply to restrict the set # of files that get signed, or in case there is an uncommon build directory structure. # # During the second step dh_signobs_unpack will be called and it will unpack the signed # binaries that OBS places in the cpio archive in ../SOURCES and it will copy them to # debian/tmp/ respecting the subdirectories path they where picked from (eg: debian/tmp/boot/vmlinuz). # # Following common conventions, if an EFI binary has an .efi suffix, a .signed suffix will be # appended. Kernel modules and images will not be renamed. if [ "$(basename "$0")" = "dh_signobs_pack" ] && [ -d ../OTHER ] && ! ls ../SOURCES/*cpio.rsasign.sig &> /dev/null then # remove any dsc and other source artefacts, obs-build might place them there rm -rf ../OTHER/* # if a template is provided, create the directory tree and copy the sources # otherwise generate it on-the-fly SOURCE_TEMPLATE="$(find debian -type d -name source-template)" if [ -d "$SOURCE_TEMPLATE/debian" ] then SOURCE_PKG=$(cd "$SOURCE_TEMPLATE"; dpkg-parsechangelog -SSource) mkdir -p "../OTHER/$SOURCE_PKG/debian/signatures" cp -r "$SOURCE_TEMPLATE"/debian/* "../OTHER/$SOURCE_PKG/debian/" # inject dh_signobs if not present if ! grep -qs signobs "../OTHER/$SOURCE_PKG/debian/rules" then sed -i "s/dh \$@/dh \$@ --with signobs/" "../OTHER/$SOURCE_PKG/debian/rules" fi else SOURCE_PKG="$(dpkg-parsechangelog -S Source)-signed" distribution="$(dpkg-parsechangelog -S Distribution)" urgency="$(dpkg-parsechangelog -S Urgency)" # lintian will complain that the date is the same, so bump by 1 second, # we want to avoid build time dates to keep the build reproducible # requires dpkg-dev >= 1.18.8 for "-S Timestamp" date="$(date --rfc-2822 --date=@$(($(dpkg-parsechangelog -S Timestamp) + 1)))" version_binary="$(dpkg-parsechangelog -S Version)" # make the source package native by removing the "-" separator version_mangled="$(dpkg-parsechangelog -S Version | tr '-' '+')+signed" mkdir -p "../OTHER/$SOURCE_PKG/debian/signatures" mkdir -p "../OTHER/$SOURCE_PKG/debian/source" echo "3.0 (native)" > "../OTHER/$SOURCE_PKG/debian/source/format" # lintian will complain that there is no source, but it's in the previous build echo "$SOURCE_PKG: source-is-missing" > "../OTHER/$SOURCE_PKG/debian/source/lintian-overrides" echo "9" > "../OTHER/$SOURCE_PKG/debian/compat" cp debian/copyright "../OTHER/$SOURCE_PKG/debian/" # copy the changelog and add a new entry, changing the version to native cp debian/changelog "../OTHER/$SOURCE_PKG/debian/" sed -i "1i\\ " "../OTHER/$SOURCE_PKG/debian/changelog" sed -i "1i\\ -- OBS signing service <obssign@obs.service> $date" "../OTHER/$SOURCE_PKG/debian/changelog" sed -i "1i\\ " "../OTHER/$SOURCE_PKG/debian/changelog" sed -i "1i\\ * Sign version $version_binary" "../OTHER/$SOURCE_PKG/debian/changelog" sed -i "1i\\ " "../OTHER/$SOURCE_PKG/debian/changelog" sed -i "1i\\$SOURCE_PKG ($version_mangled) $distribution; urgency=$urgency" \ "../OTHER/$SOURCE_PKG/debian/changelog" # the dummy binary package is necessary otherwise dpkg-source will error out, # it will be removed during the followup build cat > "../OTHER/$SOURCE_PKG/debian/control" << EOF Source: $SOURCE_PKG Section: admin Priority: optional Maintainer: OBS signing service <obssign@obs.service> Standards-Version: 3.9.8 Build-Depends: debhelper (>= 9~), dh-signobs Package: $SOURCE_PKG-dummy Architecture: all EOF # the dh_auto_install override is there so that more actions # can be appended later after the install phase, when # the signatures get unpacked and reattached to the binaries # in order to generate the binary packages and remove the dummy # only when doing a binary build, rather than a source build, # per-signed-binary-package rules will be dynamically added later # so place a marker for easier substitution # # the changelog and copyright files will be copied from the unsigned package cat > "../OTHER/$SOURCE_PKG/debian/rules" << EOF #!/usr/bin/make -f SHELL := bash -e %: if [ -d ../SOURCES ] && ls ../SOURCES/*cpio.rsasign.sig &> /dev/null && grep -qs $SOURCE_PKG-dummy debian/control; then \\ sed -i "/Package:/d" debian/control; \\ sed -i "/Architecture:/d" debian/control; \\ fi #CONTROLMARKER dh \$@ --with signobs override_dh_gencontrol: #GENCONTROLMARKER override_dh_installchangelogs: override_dh_installdocs: override_dh_auto_install: dh_auto_install EOF chmod +x "../OTHER/$SOURCE_PKG/debian/rules" fi # pesign wants an empty certutil DB - use sql as legacy mode fails often nss_db="$PWD/nss-db" # certutil will fail if it's called twice rm -rf "$nss_db" mkdir -p "$nss_db" hashes certutil -N -d sql:"$nss_db" --empty-password # get hashes via pesign from kernel image and EFI binaries # store into directories named after the packages, and OBS will respect # the directory structure when we unpack after the signing declare -a UNSIGNED # if the source describes what files to sign, parse it, otherwise do everything JSON="$(find debian -type f -name files.json)" if [ -f "$JSON" ] then for PKG in $(jq --raw-output 'to_entries[]? | .key' < "$JSON") do for f in $(jq --raw-output ".\"$PKG\".files[]? | .file" < "$JSON") do UNSIGNED+=("$PKG/$f") done done else # shellcheck disable=SC2207 UNSIGNED=( $(find debian -path debian/tmp -prune -o -type f \( -name "*.efi" -o -name "vmlinuz-*" -o -name "*.ko" \) -printf '%P\n') ) fi for f in "${UNSIGNED[@]}" do mkdir -p "hashes/$(dirname "$f")" if [[ $(basename "$f") = *.ko ]] then # kernel modules have to be copied wholesale, cannot get just the hash cp "debian/$f" "hashes/$f" else pesign --force -n sql:"$nss_db" -i "debian/$f" -E "hashes/$f" fi # copy the unsigned binaries to be able to re-attach signatures later mkdir -p "../OTHER/$SOURCE_PKG/debian/signatures/$(dirname "$f")" cp "debian/$f" "../OTHER/$SOURCE_PKG/debian/signatures/$f" # if there is no template, generate the package-specific parts of the signed source if [ ! -d "$SOURCE_TEMPLATE/debian" ] then # generate the new package metadata, but only once, as multiple binaries # might be in one package if ! grep -qs "${f%%/*}" "../OTHER/$SOURCE_PKG/debian/rules" then # to ensure the signed package is identical to the unsigned one, # simply extract the content of the unsigned one, the signed # binaries will simply overwrite the unsigned ones echo " dpkg -x ../SOURCES/${f%%/*}_*.deb debian/${f%%/*}" >> "../OTHER/$SOURCE_PKG/debian/rules" echo " dpkg -e ../SOURCES/${f%%/*}_*.deb debian/${f%%/*}/DEBIAN" >> ."./OTHER/$SOURCE_PKG/debian/rules" echo " for script in debian/${f%%/*}/DEBIAN/*; do mv \$\$script debian/${f%%/*}.\$\${script##*/}; done" >> ."./OTHER/$SOURCE_PKG/debian/rules" # then delete the unsigned package, which the unpack step will copy # over echo " rm -f ../DEBS/${f%%/*}_*.deb" >> "../OTHER/$SOURCE_PKG/debian/rules" # generate rules to extract unsigned package control files sed -i "s|fi #CONTROLMARKER|mkdir -p debian/${f%%/*}/DEBIAN; dpkg -e ../SOURCES/${f%%/*}_*.deb debian/${f%%/*}/DEBIAN; \\\\\\n\\tfi #CONTROLMARKER|" "../OTHER/$SOURCE_PKG/debian/rules" # save version for gencontrol - pkg/DEBIAN will be cleaned up in-between sed -i "s@fi #CONTROLMARKER@grep 'Version:' debian/${f%%/*}/DEBIAN/control | sed 's/Version:\\\\s*//' > debian/${f%%/*}.version; \\\\\\n\\tfi #CONTROLMARKER@" "../OTHER/$SOURCE_PKG/debian/rules" # generate rule to prune unwanted metadata from unsigned control file sed -i "s|fi #CONTROLMARKER|sed -i '/Source/d' debian/${f%%/*}/DEBIAN/control; \\\\\\n\\tfi #CONTROLMARKER|" "../OTHER/$SOURCE_PKG/debian/rules" sed -i "s|fi #CONTROLMARKER|sed -i '/Version/d' debian/${f%%/*}/DEBIAN/control; \\\\\\n\\tfi #CONTROLMARKER|" "../OTHER/$SOURCE_PKG/debian/rules" sed -i "s|fi #CONTROLMARKER|sed -i '/Maintainer/d' debian/${f%%/*}/DEBIAN/control; \\\\\\n\\tfi #CONTROLMARKER|" "../OTHER/$SOURCE_PKG/debian/rules" sed -i "s|fi #CONTROLMARKER|sed -i '/Installed-Size/d' debian/${f%%/*}/DEBIAN/control; \\\\\\n\\tfi #CONTROLMARKER|" "../OTHER/$SOURCE_PKG/debian/rules" # generate rule to create signed package metadata from the unsigned one sed -i "s|fi #CONTROLMARKER|cat debian/control debian/${f%%/*}/DEBIAN/control > debian/control.tmp; mv debian/control.tmp debian/control; echo \"\" >> debian/control; \\\\\\n\\tfi #CONTROLMARKER|" "../OTHER/$SOURCE_PKG/debian/rules" # generate rule set the version from the unsigned one sed -i "s|#GENCONTROLMARKER|dh_gencontrol -p ${f%%/*} -- -v\$(shell cat debian/${f%%/*}.version); rm -f debian/${f%%/*}.version\\n\\t#GENCONTROLMARKER|" "../OTHER/$SOURCE_PKG/debian/rules" fi # special case: the conffiles lists the file in /etc, but it does # get regenerated and it does not prune duplicates, triggering a # Lintian error, so remove the old ones echo " rm -f debian/*.conffiles" >> "../OTHER/$SOURCE_PKG/debian/rules" # finally copy the signed binary in the package build dir # note that by convention bootloaders are renamed to .signed but # kernel modules and images are not if [[ $(basename "$f") = *.efi ]] then # unsigned bootloaders are installed by the unsigned package # so there must not be a conflict on the filesystem echo " rm -f debian/$f" >> "../OTHER/$SOURCE_PKG/debian/rules" echo " cp debian/tmp/${f#*/}.signed debian/${f%/*}" >> "../OTHER/$SOURCE_PKG/debian/rules" else echo " cp debian/tmp/${f#*/} debian/${f%/*}" >> "../OTHER/$SOURCE_PKG/debian/rules" fi fi done rm -rf "$nss_db" # pack everything into a CPIO archive and place it where OBS expects it pushd hashes find . -type f | cpio -H newc -o > "../../OTHER/$SOURCE_PKG.cpio.rsasign" popd rm -rf hashes # assemble the source package that OBS will build on the second pass pushd "../OTHER/$SOURCE_PKG" dpkg-buildpackage -uc -us -d -S popd elif [ "$(basename "$0")" = "dh_signobs_unpack" ] && [ -d ../SOURCES ] && ls ../SOURCES/*cpio.rsasign.sig &> /dev/null then # copy packages built on first pass, if any cp ../SOURCES/*.deb ../DEBS/ 2>/dev/null || : cp ../SOURCES/*.tar.* ../DEBS/ cp ../SOURCES/*.dsc ../DEBS/ cp ../SOURCES/*.changes ../DEBS/ # but not the current source package, otherwise build-recipe-dsc will fail rm -f ../DEBS/"$(dpkg-parsechangelog -SSource)"* # unpack in debian/signatures and create pesign db, where the template source expects them pushd debian/signatures cpio -idm < ../../../SOURCES/*.cpio.rsasign.sig # OBS signs a hash without certificate informations so it cannot simply be # attached to the PE binaries, certificate metadata has to be provided separately # so we need to create a certutil db and import the certificate manually rm -rf nss-db mkdir nss-db nss_db="$PWD/nss-db" certutil -N -d sql:"$nss_db" --empty-password certutil -A -d sql:"$nss_db" -n cert -t CT,CT,CT -i ../../../SOURCES/_projectcert.crt while read -r SIG do export infile="${SIG%.sig}" cpio -i --to-stdout "${infile}" < ../../../SOURCES/*.cpio.rsasign > "$(basename "${infile}").sattrs" test -s "$(basename "${infile}").sattrs" || exit 1 # install the signed file into debian/tmp so that the package can pick it up # remove the unsigned package name from the path DEST="../tmp/${SIG#*/}" # kernel images do not have the .signed prefix, only bootloaders do if [[ $(basename "$DEST") = vmlinuz* ]] then DEST="${DEST%%.sig}" else DEST="${DEST}ned" fi mkdir -p "../tmp/$(dirname "${DEST}")" # ensure the EFI hash matches before and after attaching the signature old_hash=$(pesign -n sql:"$nss_db" -h -P -i "${SIG%.sig}") pesign -n sql:"$nss_db" -c cert -i "${SIG%.sig}" -o "$DEST" -d sha256 -I "$(basename "${infile}").sattrs" -R "$SIG" new_hash=$(pesign -n sql:"$nss_db" -h -i "$DEST") if [ "$old_hash" != "$new_hash" ] then echo "Pesign hash mismatch error: $old_hash $new_hash" exit 1 fi rm -f "$(basename "${infile}").sattrs" "$SIG" "${SIG%.sig}" done < <(find . -type f \( -name '*efi.sig' -o -name 'vmlinuz*.sig' \) -printf '%P\n') rm -rf nss-db # the kernel-sign-file script wants DER format openssl x509 -in ../../../SOURCES/_projectcert.crt -inform pem -outform der -out _projectcert.der while read -r SIG do # install the signed file into debian/tmp so that the package can pick it up # remove the unsigned package name from the path DEST="../tmp/${SIG#*/}" DEST="${DEST%%.sig}" mkdir -p "../tmp/$(dirname "${DEST}")" /usr/lib/rpm/pesign/kernel-sign-file -i pkcs7 -s "$SIG" sha256 _projectcert.der "${SIG%.sig}" "${DEST}" rm -f "$SIG" "${SIG%.sig}" done < <(find . -type f -name '*ko.sig' -printf '%P\n') rm -f _projectcert.der popd elif [ "$(basename "$0")" = "dh_signobs_getcert" ] && [ -d ../SOURCES ] && [ -e ../SOURCES/_projectcert.crt ] then if [ "$#" -lt 1 ] then echo "Missing destination filename parameter!" exit 1 fi mkdir -p "$(dirname "$1")" if [ "$#" -ge 2 ] && [ "$2" = "DER" ] then openssl x509 -in ../SOURCES/_projectcert.crt -inform pem -outform der -out "$1" else cp ../SOURCES/_projectcert.crt "$1" fi fi 07070100000013000081A4000000000000000000000001669F469C00000CCD000000000000000000000000000000000000003D00000000pesign-obs-integration-10.2+git20240723.d344d91/dh_signobs.1.TH DH_SIGNOBS: "1" "April 2018" "dh_signobs" "User Commands" .SH NAME dh_signobs \- sign EFI/ko files when building on SUSE's OBS. .SH SYNOPSIS .B dh\_signobs_pack\fR .br .B dh\_signobs_unpack\fR .br .B dh\_signobs_getcert\fR .IR DESTINATION .RB "[ " .IR DER .RB "]" .br .SH DESCRIPTION .SS QUICK GUIDE FOR MAINTAINERS Build-Depend on \fBdh\-signobs\fR. .br Enable by using \fBdh \-\-with=signobs\fR. .br If the certificate is necessary at build time, for example to include in the kernel or shim, annotate the Source stanza of debian/control with: .br \fBXS\-Obs: needssslcertforbuild\fR .br Then it can be fetched in PEM format with: .br \fBdh\_signobs_getcert\fR .IR DESTINATION .br Append .IR DER to retrieve it in binary format instead. .SS NOTES This debhelper will run in 2 steps \- first after the dh_install phase, when the source package will have built and installed the unsigned binaries. The second step during the followup build after OBS has signed the binaries, before dh_auto_install runs. During the first step dh_signobs_pack will be called to get the hashes (or kernel modules) and pack them into a cpio archive in ../OTHER that OBS can use. At the same time a new source package for the OBS followup build will be generated, either from a source\-template that can be specified by the package being signed or automatically generated by this debhelper. The source template can be in any form it wants, as long as it is placed in a directory called \fBsource\-template\fR in the debian/ directory (can be a subdirectory, and it can be static or generated). Also a \fBfiles.json\fR list of the binaries to sign must be placed in the same \fBparent\fR directory with the following format: .br {"unsigned\-binary\-package": { .br "files": [ .br {"sig_type": "efi", "file": "usr/lib/foo/bar.efi"}, .br {"sig_type": "linux-module", "file": "lib/modules/1.2.3/baz.ko"} .br ] .br }} .br The advantage of the templated build is that it can sign only a subset of files \- for example, a kernel build with CONFIG_MODULE_SIG_ALL=y does not need to sign the modules and can save a lot of time by just signing the vmlinuz. The autogenerated package will simply look for any .efi, .ko or vmlinuz- file in the debian directory (excluding debian/tmp) and considers the first subdirectory to be the package name (IOW: it covers the common case where built files are first installed in debian/tmp/path and then moved by dh_install into debian/pkg/path), and then generates a new source package that unpacks the packages that contain them and repacks them after signing the binaries. The files.json can be used also with the autogenerated package, simply to restrict the set of files that get signed, or in case there is an uncommon build directory structure. During the second step dh_signobs_unpack will be called and it will unpack the signed binaries that OBS places in the cpio archive in ../SOURCES and it will copy them to debian/tmp/ respecting the subdirectories path they where picked from (eg: debian/tmp/boot/vmlinuz). Following common conventions, if an EFI binary has an .efi suffix, a .signed suffix will be appended. Kernel modules and images will not be renamed. .SH "SEE ALSO" \&\fIdh\fR\|(1) .SH AUTHOR .PP Luca Boccassi <bluca@debian.org> 07070100000014000081ED000000000000000000000001669F469C00000151000000000000000000000000000000000000003900000000pesign-obs-integration-10.2+git20240723.d344d91/gen-hmac#!/usr/bin/perl use strict; use warnings; use Getopt::Long; my $USAGE = "Usage: $0 [-r <build root>] <file>\n"; my $buildroot = ""; GetOptions("r|root=s" => \$buildroot) or die $USAGE; if (scalar(@ARGV) != 1) { die $USAGE; } if ($buildroot) { $buildroot .= "/"; } my $fn = shift @ARGV; system("fipshmac $buildroot$fn"); exit 0; 07070100000015000081ED000000000000000000000001669F469C0000458F000000000000000000000000000000000000004100000000pesign-obs-integration-10.2+git20240723.d344d91/kernel-sign-file#!/usr/bin/perl -w # # Sign a module file using the given key. # my $USAGE = "Usage: scripts/sign-file [-dkpv] [-i <id type>] <hash algo> <key> <x509 (DER format)> <module> [<dest>]\n" . " scripts/sign-file [-dkpv] [-i <id type>] -s <raw sig> <hash algo> <x509 (DER format)> <module> [<dest>]\n"; use strict; use FileHandle; use IPC::Open2; use Getopt::Std; my %opts; getopts('vkpdNPs:i:C:', \%opts) or die $USAGE; my $verbose = $opts{'v'}; my $signature_file = $opts{'s'}; my $use_keyid = $opts{'k'}; my $sign_only = $opts{'d'}; my $save_sig = $opts{'p'}; $save_sig = 1 if $sign_only; my $id_type_name = $opts{'i'}; my $certs_file = $opts{'C'}; # certs to include in pkcs7 signature (DER encoded) my $digest_algo_with_null = $opts{'N'}; # add NULL param to algo, like openssl does (see RFC 4055) my $save_signed_data = $opts{'P'}; # dump pkcs7 signed data in .p7sd die $USAGE if ($#ARGV > 4); die $USAGE if (!$signature_file && $#ARGV < 3 || $signature_file && $#ARGV < 2); my $dgst = shift @ARGV; my $private_key; if (!$signature_file) { $private_key = shift @ARGV; } my $x509 = shift @ARGV; my $module = shift @ARGV; my ($dest, $keep_orig); if (@ARGV) { $dest = $ARGV[0]; $keep_orig = 1; } else { $dest = $module . "~"; } die "Can't read private key\n" if (!$signature_file && !-r $private_key); die "Can't read signature file\n" if ($signature_file && !-r $signature_file); die "Can't read module\n" unless (-r $module); die "Can't read X.509 certs file\n" if ($certs_file && !-r $certs_file); # # Function to read the contents of a file into a variable. # sub read_file($) { my ($file) = @_; my $contents; my $len; open(FD, "<$file") || die $file; binmode FD; my @st = stat(FD); die $file if (!@st); $len = read(FD, $contents, $st[7]) || die $file; close(FD) || die $file; die "$file: Wanted length ", $st[7], ", got ", $len, "\n" if ($len != $st[7]); return $contents; } sub openssl_pipe($$) { my ($input, $cmd) = @_; my ($pid, $res); $pid = open2(*read_from, *write_to, $cmd) || die $cmd; binmode write_to; print write_to $input || die "pipe to $cmd"; close(write_to) || die "pipe to $cmd"; binmode read_from; read(read_from, $res, 4096) || die "pipe from $cmd"; close(read_from) || die "pipe from $cmd"; waitpid($pid, 0) || die; die "$cmd died: $?" if ($? >> 8); return $res; } ############################################################################### # # First of all, we have to parse the X.509 certificate to find certain details # about it. # # We read the DER-encoded X509 certificate and parse it to extract the Subject # name and Subject Key Identifier. Theis provides the data we need to build # the certificate identifier. # # The signer's name part of the identifier is fabricated from the commonName, # the organizationName or the emailAddress components of the X.509 subject # name. # # The subject key ID is used to select which of that signer's certificates # we're intending to use to sign the module. # ############################################################################### my $UNIV = 0 << 6; my $APPL = 1 << 6; my $CONT = 2 << 6; my $PRIV = 3 << 6; my $CONS = 0x20; my $BOOLEAN = 0x01; my $INTEGER = 0x02; my $BIT_STRING = 0x03; my $OCTET_STRING = 0x04; my $NULL = 0x05; my $OBJ_ID = 0x06; my $UTF8String = 0x0c; my $SEQUENCE = 0x10; my $SET = 0x11; my $UTCTime = 0x17; my $GeneralizedTime = 0x18; my %OIDs = ( pack("CCC", 85, 4, 3) => "commonName", pack("CCC", 85, 4, 6) => "countryName", pack("CCC", 85, 4, 10) => "organizationName", pack("CCC", 85, 4, 11) => "organizationUnitName", pack("CCCCCCCCC", 42, 134, 72, 134, 247, 13, 1, 1, 1) => "rsaEncryption", pack("CCCCCCCCC", 42, 134, 72, 134, 247, 13, 1, 1, 5) => "sha1WithRSAEncryption", pack("CCCCCCCCC", 42, 134, 72, 134, 247, 13, 1, 9, 1) => "emailAddress", pack("CCC", 85, 29, 35) => "authorityKeyIdentifier", pack("CCC", 85, 29, 14) => "subjectKeyIdentifier", pack("CCC", 85, 29, 19) => "basicConstraints" ); ############################################################################### # # Extract an ASN.1 element from a string and return information about it. # ############################################################################### sub asn1_extract($$@) { my ($cursor, $expected_tag, $optional) = @_; return [ -1 ] if ($cursor->[1] == 0 && $optional); die $x509, ": ", $cursor->[0], ": ASN.1 data underrun (elem ", $cursor->[1], ")\n" if ($cursor->[1] < 2); my ($tag, $len) = unpack("CC", substr(${$cursor->[2]}, $cursor->[0], 2)); if ($expected_tag != -1 && $tag != $expected_tag) { return [ -1 ] if ($optional); die $x509, ": ", $cursor->[0], ": ASN.1 unexpected tag (", $tag, " not ", $expected_tag, ")\n"; } $cursor->[0] += 2; $cursor->[1] -= 2; die $x509, ": ", $cursor->[0], ": ASN.1 long tag\n" if (($tag & 0x1f) == 0x1f); die $x509, ": ", $cursor->[0], ": ASN.1 indefinite length\n" if ($len == 0x80); if ($len > 0x80) { my $l = $len - 0x80; die $x509, ": ", $cursor->[0], ": ASN.1 data underrun (len len $l)\n" if ($cursor->[1] < $l); if ($l == 0x1) { $len = unpack("C", substr(${$cursor->[2]}, $cursor->[0], 1)); } elsif ($l == 0x2) { $len = unpack("n", substr(${$cursor->[2]}, $cursor->[0], 2)); } elsif ($l == 0x3) { $len = unpack("C", substr(${$cursor->[2]}, $cursor->[0], 1)) << 16; $len = unpack("n", substr(${$cursor->[2]}, $cursor->[0] + 1, 2)); } elsif ($l == 0x4) { $len = unpack("N", substr(${$cursor->[2]}, $cursor->[0], 4)); } else { die $x509, ": ", $cursor->[0], ": ASN.1 element too long (", $l, ")\n"; } $cursor->[0] += $l; $cursor->[1] -= $l; } die $x509, ": ", $cursor->[0], ": ASN.1 data underrun (", $len, ")\n" if ($cursor->[1] < $len); my $ret = [ $tag, [ $cursor->[0], $len, $cursor->[2] ] ]; $cursor->[0] += $len; $cursor->[1] -= $len; return $ret; } ############################################################################### # # Retrieve the data referred to by a cursor # ############################################################################### sub asn1_retrieve($) { my ($cursor) = @_; my ($offset, $len, $data) = @$cursor; return substr($$data, $offset, $len); } sub asn1_pack($@) { my ($tag, @data) = @_; my $ret = pack("C", $tag); my $data = join('', @data); my $l = length($data); return pack("CC", $tag, $l) . $data if $l < 127; my $ll = $l >> 8 ? $l >> 16 ? $l >> 24 ? 4 : 3 : 2 : 1; return pack("CCa*", $tag, $ll | 0x80, substr(pack("N", $l), -$ll)) . $data; } ############################################################################### # # Roughly parse the X.509 certificate # ############################################################################### sub parse_certificate($) { my ($x509_certificate) = @_; my $cursor = [ 0, length($x509_certificate), \$x509_certificate ]; my %result; my $cert = asn1_extract($cursor, $UNIV | $CONS | $SEQUENCE); my $tbs = asn1_extract($cert->[1], $UNIV | $CONS | $SEQUENCE); my $version = asn1_extract($tbs->[1], $CONT | $CONS | 0, 1); $result{serial_number} = asn1_extract($tbs->[1], $UNIV | $INTEGER); my $sig_type = asn1_extract($tbs->[1], $UNIV | $CONS | $SEQUENCE); $result{issuer} = asn1_extract($tbs->[1], $UNIV | $CONS | $SEQUENCE); my $validity = asn1_extract($tbs->[1], $UNIV | $CONS | $SEQUENCE); my $subject = asn1_extract($tbs->[1], $UNIV | $CONS | $SEQUENCE); my $key = asn1_extract($tbs->[1], $UNIV | $CONS | $SEQUENCE); my $issuer_uid = asn1_extract($tbs->[1], $CONT | $CONS | 1, 1); my $subject_uid = asn1_extract($tbs->[1], $CONT | $CONS | 2, 1); my $extension_list = asn1_extract($tbs->[1], $CONT | $CONS | 3, 1); $result{subject_key_id} = (); my $authority_key_id = (); # # Parse the extension list # if ($extension_list->[0] != -1) { my $extensions = asn1_extract($extension_list->[1], $UNIV | $CONS | $SEQUENCE); while ($extensions->[1]->[1] > 0) { my $ext = asn1_extract($extensions->[1], $UNIV | $CONS | $SEQUENCE); my $x_oid = asn1_extract($ext->[1], $UNIV | $OBJ_ID); my $x_crit = asn1_extract($ext->[1], $UNIV | $BOOLEAN, 1); my $x_val = asn1_extract($ext->[1], $UNIV | $OCTET_STRING); my $raw_oid = asn1_retrieve($x_oid->[1]); next if (!exists($OIDs{$raw_oid})); my $x_type = $OIDs{$raw_oid}; my $raw_value = asn1_retrieve($x_val->[1]); if ($x_type eq "subjectKeyIdentifier") { my $vcursor = [ 0, length($raw_value), \$raw_value ]; $result{subject_key_id} = asn1_extract($vcursor, $UNIV | $OCTET_STRING); } } } ############################################################################### # # Determine what we're going to use as the signer's name. In order of # preference, take one of: commonName, organizationName or emailAddress. # ############################################################################### my $org = ""; my $cn = ""; my $email = ""; while ($subject->[1]->[1] > 0) { my $rdn = asn1_extract($subject->[1], $UNIV | $CONS | $SET); my $attr = asn1_extract($rdn->[1], $UNIV | $CONS | $SEQUENCE); my $n_oid = asn1_extract($attr->[1], $UNIV | $OBJ_ID); my $n_val = asn1_extract($attr->[1], -1); my $raw_oid = asn1_retrieve($n_oid->[1]); next if (!exists($OIDs{$raw_oid})); my $n_type = $OIDs{$raw_oid}; my $raw_value = asn1_retrieve($n_val->[1]); if ($n_type eq "organizationName") { $org = $raw_value; } elsif ($n_type eq "commonName") { $cn = $raw_value; } elsif ($n_type eq "emailAddress") { $email = $raw_value; } } $result{signers_name} = $email; if ($org && $cn) { # Don't use the organizationName if the commonName repeats it if (length($org) <= length($cn) && substr($cn, 0, length($org)) eq $org) { $result{signers_name} = $cn; goto got_id_name; } # Or a signifcant chunk of it if (length($org) >= 7 && length($cn) >= 7 && substr($cn, 0, 7) eq substr($org, 0, 7)) { $result{signers_name} = $cn; goto got_id_name; } $result{signers_name} = $org . ": " . $cn; } elsif ($org) { $result{signers_name} = $org; } elsif ($cn) { $result{signers_name} = $cn; } got_id_name: die $x509, ": ", "X.509: Couldn't find the Subject Key Identifier extension\n" if (!$result{subject_key_id}); $result{key_identifier} = asn1_retrieve($result{subject_key_id}->[1]); return %result; } ############################################################################### # # Create and attach the module signature # ############################################################################### # # Signature parameters # my $algo = 1; # Public-key crypto algorithm: RSA my $hash = 0; # Digest algorithm my $id_type = 1; # Identifier type: X.509 if ($id_type_name) { if ($id_type_name eq 'x509') { $id_type = 1; # Identifier type: X.509 } elsif ($id_type_name eq 'pkcs7') { $id_type = 2; # Identifier type: PKCS7 } else { die("unknown id type: $id_type_name\n"); } } # # Digest the data # my $prologue; if ($dgst eq "sha1") { $prologue = pack("C*", 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2B, 0x0E, 0x03, 0x02, 0x1A, 0x05, 0x00, 0x04, 0x14); $hash = 2; } elsif ($dgst eq "sha224") { $prologue = pack("C*", 0x30, 0x2d, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x04, 0x05, 0x00, 0x04, 0x1C); $hash = 7; } elsif ($dgst eq "sha256") { $prologue = pack("C*", 0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x05, 0x00, 0x04, 0x20); $hash = 4; } elsif ($dgst eq "sha384") { $prologue = pack("C*", 0x30, 0x41, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x02, 0x05, 0x00, 0x04, 0x30); $hash = 5; } elsif ($dgst eq "sha512") { $prologue = pack("C*", 0x30, 0x51, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x03, 0x05, 0x00, 0x04, 0x40); $hash = 6; } else { die "Unknown hash algorithm: $dgst\n"; } my $unsigned_module = read_file($module); my $magic_number = "~Module signature appended~\n"; my $magic_len = length($magic_number); my $info_len = 12; # Truncate existing signarure, if any if (substr($unsigned_module, -$magic_len) eq $magic_number) { my $info = substr($unsigned_module, -$magic_len - $info_len, $info_len); my ($name_len, $key_len, $sig_len) = unpack("xxxCCxxxN", $info); my $subtract = $name_len + $key_len + $sig_len + $info_len + $magic_len; if ($subtract > length($unsigned_module)) { die "$module: Existing signature is malformed\n"; } $unsigned_module = substr($unsigned_module, 0, length($unsigned_module) - $subtract); } my $signature; if ($signature_file) { $signature = read_file($signature_file); } else { # # Generate the digest and read from openssl's stdout # my $digest = openssl_pipe($unsigned_module, "openssl dgst -$dgst -binary"); # # Generate the binary signature, which will be just the integer that # comprises the signature with no metadata attached. # $signature = openssl_pipe($prologue . $digest, "openssl rsautl -sign -inkey $private_key -keyform PEM"); } my %certdata; my $signers_name; my $key_identifier; my $x509_certificate; if ($id_type == 1) { die "Can't read X.509 certificate\n" unless (-r $x509); $x509_certificate = read_file($x509); %certdata = parse_certificate($x509_certificate); $signature = pack("n", length($signature)) . $signature, $signers_name = $certdata{signers_name}; $key_identifier = $certdata{key_identifier}; } elsif ($id_type == 2) { # create PKCS7 signature if ($x509) { die "Can't read X.509 certificate\n" unless (-r $x509); $x509_certificate = read_file($x509); } else { print "No certificate specified, assuming pre-built PKCS#7 signature.\n" if ($verbose); $x509_certificate = ''; } if ($x509_certificate) { my $certs = ''; if ($certs_file) { $certs = read_file($certs_file); $certs = asn1_pack($CONT | $CONS | 0, $certs); } %certdata = parse_certificate($x509_certificate); $signature = asn1_pack($UNIV | $OCTET_STRING, $signature); my $digest_algo = substr($prologue, 4, 2 + unpack('C', substr($prologue, 5, 1))); my $digest_algo_seq = asn1_pack($UNIV | $CONS | $SEQUENCE, $digest_algo, ($digest_algo_with_null ? asn1_pack($UNIV | $NULL) : '')); my $digest_algo_seq_set = asn1_pack($UNIV | $CONS | $SET, $digest_algo_seq); my $si_verstion = asn1_pack($UNIV | $INTEGER, pack('C', $use_keyid ? 3 : 1)); my $si_issuer = asn1_pack($certdata{issuer}->[0], asn1_retrieve($certdata{issuer}->[1])); my $si_serial = asn1_pack($certdata{serial_number}->[0], asn1_retrieve($certdata{serial_number}->[1])); my $si_issuer_serial = asn1_pack($UNIV | $CONS | $SEQUENCE, $si_issuer, $si_serial); my $si_keyid = asn1_pack($CONT | 0, asn1_retrieve($certdata{subject_key_id}->[1])); my $rsa_encryption = asn1_pack($UNIV | $OBJ_ID, pack("CCCCCCCCC", 42, 134, 72, 134, 247, 13, 1, 1, 1)); my $encryption_seq = asn1_pack($UNIV | $CONS | $SEQUENCE, $rsa_encryption, asn1_pack($UNIV | $NULL)); my $signer_identifier = $use_keyid ? $si_keyid : $si_issuer_serial; my $si = asn1_pack($UNIV | $CONS | $SEQUENCE, $si_verstion, $signer_identifier, $digest_algo_seq, $encryption_seq, $signature); my $si_set = asn1_pack($UNIV | $CONS | $SET, $si); my $sid_version = asn1_pack($UNIV | $INTEGER, pack('C', $use_keyid ? 3 : 1)); my $pkcs7_data = asn1_pack($UNIV | $OBJ_ID, pack("CCCCCCCCC", 42, 134, 72, 134, 247, 13, 1, 7, 1)); my $pkcs7_data_seq = asn1_pack($UNIV | $CONS | $SEQUENCE, $pkcs7_data); my $sid = asn1_pack($UNIV | $CONS | $SEQUENCE, $sid_version, $digest_algo_seq_set, $pkcs7_data_seq, $certs, $si_set); my $pkcs7_signed_data = asn1_pack($UNIV | $OBJ_ID, pack("CCCCCCCCC", 42, 134, 72, 134, 247, 13, 1, 7, 2)); $signature = asn1_pack($UNIV | $CONS | $SEQUENCE, $pkcs7_signed_data, asn1_pack($CONT | $CONS | 0, $sid)); if ($save_signed_data) { open(FD, ">$module.p7sd") || die "$module.p7sd"; binmode FD; print FD $sid; } } else { print "Certificate is empty, assuming pre-built PKCS#7 signature.\n" if ($verbose); } # zero out unneeded entries $signers_name = ''; $key_identifier = ''; $algo = $hash = 0; } else { die("unknown signature id type: $id_type\n"); } if ($save_sig) { open(FD, ">$module.p7s") || die "$module.p7s"; binmode FD; print FD $signature; } exit(0) if $sign_only; # # Build the signed binary # my $info = pack("CCCCCxxxN", $algo, $hash, $id_type, length($signers_name), length($key_identifier), length($signature)); # Make sure that $info_len value used above matches reality if (length($info) != $info_len) { die "Signature info size changed ($info_len -> @{[length($info)]}"; } if ($verbose) { print "Size of unsigned module: ", length($unsigned_module), "\n"; print "Size of signer's name : ", length($signers_name), "\n"; print "Size of key identifier : ", length($key_identifier), "\n"; print "Size of signature : ", length($signature), "\n"; print "Size of informaton : ", length($info), "\n"; print "Size of magic number : ", length($magic_number), "\n"; print "Signer's name : '", $signers_name, "'\n"; print "Digest : $dgst\n"; } open(FD, ">$dest") || die $dest; binmode FD; print FD $unsigned_module, $signers_name, $key_identifier, $signature, $info, $magic_number ; close FD || die $dest; if (!$keep_orig) { rename($dest, $module) || die $module; } 07070100000016000081ED000000000000000000000001669F469C000012D7000000000000000000000000000000000000004200000000pesign-obs-integration-10.2+git20240723.d344d91/modsign-repackage#!/bin/bash # Script to sign kernel modules and create new RPM packages with these # modules. Uses pesign-gen-repackage-spec for the repackaging. # # Copyright (c) 2013 SUSE Linux Products GmbH, Nuernberg, Germany. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA USAGE="$0 --key <private key> --certificate <x509 cert> rpm ..." options=`getopt -o hk:c:s: --long help,key:,certificate:,signatures: -- "$@"` if test $? -ne 0; then echo "$USAGE" >&2 exit 1 fi eval set -- "$options" key= cert= sig_dir= while :; do case "$1" in -k|--key) key=$2 shift 2 ;; -c|--certificate) cert=$2 shift 2 ;; -s|--signatures) sig_dir=$2 shift 2 ;; -h|--help) echo "$USAGE" exit ;; --) shift break esac done err= if test -n "$key" -a -n "$sig_dir"; then err="Cannot use both --key and --signatures" elif test -z "$key" -a -z "$sig_dir"; then err="Please specify either --key or --signatures" elif test -z "$cert"; then err="Please specify --certificate" elif test "$#" -eq 0; then err="No packages specified" fi if test -n "$err"; then echo "$0: $err" >&2 echo "$USAGE" >&2 exit 1 fi workdir="$PWD/rpm-files.$$" buildroot="$workdir/buildroot" rpmdir=RPMS srpmdir=SRPMS disturl= rpms=() rm -rf "$workdir" mkdir "$workdir" || exit mkdir -p "$rpmdir" "$srpmdir" || exit mkdir "$buildroot" echo "Unpacking original RPMs..." for rpm; do # XXX: Use a common script in pesign-repackage.spec.in and here case "$rpm" in *.src.rpm | *.nosrc.rpm) cp "$rpm" "$srpmdir/" continue ;; # Do not repackage debuginfo packages (bnc#806637) *-debuginfo-*.rpm | *-debugsource-*.rpm) dir="$rpmdir/$(rpm -qp --qf '%{arch}' "$rpm")" mkdir -p "$dir" cp "$rpm" "$dir" continue ;; esac # do not repackage baselibs packages # FIXME: needs more generic test (if architecture has different # bitness => skip) case "$(rpm -qp --qf '%{name}/%{arch}' "$rpm")" in *-32bit/x86_64 | *-32bit/s390x | *-32bit/ppc64 | \ *-64bit/ppc | *-x86/ia64 | *-64bit/aarch64_ilp32) mkdir -p "$rpmdir/$(rpm -qp --qf '%{arch}')/" cp "$rpm" "$_" continue esac rpm2cpio "$rpm" | (cd "$buildroot"; cpio -idm --quiet) || exit d=$(rpm -qp --qf '%{disturl}' "$rpm") if test -z "$disturl"; then disturl=$d fi if test "$disturl" != "$d"; then echo "Error: packages have different disturl: $d vs $disturl" exit 1 fi rpms=("${rpms[@]}" "$rpm") done set -e echo "Signing kernel modules..." if test ! -e "$cert.pub"; then openssl x509 -in "$cert" -inform DER -pubkey -noout > "$cert.pub" fi for module in $(find "$buildroot" -type f -name '*.ko' -printf '%P\n'); do if test -n "$key"; then /usr/lib/rpm/pesign/kernel-sign-file \ -i pkcs7 sha256 "$key" "$cert" "$buildroot/$module" else raw_sig="$sig_dir/$module.sig" if test ! -e "$raw_sig"; then echo "$module.sig not found in $sig_dir" >&2 exit 1 fi ver_err=$(openssl rsautl -verify -inkey "$cert.pub" -pubin -in "$raw_sig" 2>&1 | grep -i error) if [ -n "$ver_err" ]; then echo "$raw_sig signature can not be decrypted by $cert" >&2 exit 1 fi /usr/lib/rpm/pesign/kernel-sign-file \ -i pkcs7 -s "$raw_sig" sha256 "$cert" "$buildroot/$module" fi done rm "$cert.pub" # Add the certificate mkdir -p "$buildroot/etc/uefi/certs" h=$(openssl x509 -inform DER -fingerprint -noout -in "$cert") filename=/etc/uefi/certs/$(echo "$h" | \ sed -rn 's/^SHA1 Fingerprint=//; T; s/://g; s/(.{8}).*/\1/p').crt cp "$cert" "$buildroot/$filename" echo "Generating new specfile..." if ! test -e /usr/lib/rpm/kernel-cert-subpackage; then echo "/usr/lib/rpm/kernel-cert-subpackage missing" >&2 echo "please install the kernel-source package" >&2 exit 1 fi /usr/lib/rpm/pesign/pesign-gen-repackage-spec \ --cert-subpackage=/usr/lib/rpm/kernel-cert-subpackage \ --directory="$buildroot" --output="$workdir" "${rpms[@]}" echo "Running rpmbuild..." rpmbuild --define "buildroot $buildroot" --define "disturl $disturl" \ --define "_builddir $workdir" \ --define "_suse_insert_debug_package %{nil}" \ --define "_rpmdir $rpmdir" \ -bb "$workdir/repackage.spec" >"$workdir/log" 2>&1 grep 'RPMS/.*\.rpm$' "$workdir/log" echo "Cleaning up $workdir..." rm -r "$workdir" echo "Done." exit 0 07070100000017000081ED000000000000000000000001669F469C00004601000000000000000000000000000000000000003F00000000pesign-obs-integration-10.2+git20240723.d344d91/modsign-verify#!/usr/bin/perl # # Verify kernel module signature generated by /usr/src/linux/scripts/sign-file # # Parts of this script were copied from sign-file, written by David Howels # my $USAGE = "Usage: modsign-verify [-v] [-q] [--certificate <x509> | --cert-dir <dir>] <module>\n"; use strict; use warnings; use IPC::Open2; use Getopt::Long; use File::Temp qw(tempfile); use bigint; my $cert; my $cert_dir; my $verbose = 1; GetOptions( "certificate=s" => \$cert, "cert-dir=s" => \$cert_dir, "q|quiet" => sub { $verbose-- if $verbose; }, "v|verbose" => sub { $verbose++; }, "h|help" => sub { print $USAGE; print "Return codes: 0 good signature\n"; print " 1 bad signature\n"; print " 2 certificate not found\n"; print " 3 module not signed\n"; print " >3 other error\n"; exit(0); } ) or die($USAGE); sub _verbose { my $level = shift; return if $verbose < $level; print STDERR @_; } sub info { _verbose(1, @_); } sub verbose { _verbose(2, @_); } sub debug { _verbose(3, @_); } if (@ARGV > 1) { print STDERR "Excess arguments\n"; die($USAGE); } elsif (@ARGV < 1) { print STDERR "No module supplied\n"; die($USAGE); } elsif ($cert && $cert_dir) { print STDERR "Please specify either --certificate or --cert-dir, not both.\n"; die($USAGE); } my $module_name = shift(@ARGV); if (!$cert && !$cert_dir) { $cert_dir = "/etc/uefi/certs"; verbose("Using default certificate directory $cert_dir\n"); } my @certs; if ($cert) { push(@certs, $cert); } else { my $dh; if (!opendir($dh, $cert_dir)) { print STDERR "$cert_dir: $!\n"; exit(2); } while (my $entry = readdir($dh)) { next if $entry =~ /^\./; next if !-f "$cert_dir/$entry"; push(@certs, "$cert_dir/$entry"); } closedir($dh); if (!@certs) { print STDERR "No certificates found in $cert_dir\n"; exit(2); } } ############################################################################### ## ASN.1 code copied from kernel-sign-file ############################################################################### my $x509; my $UNIV = 0 << 6; my $APPL = 1 << 6; my $CONT = 2 << 6; my $PRIV = 3 << 6; my $CONS = 0x20; my $BOOLEAN = 0x01; my $INTEGER = 0x02; my $BIT_STRING = 0x03; my $OCTET_STRING = 0x04; my $NULL = 0x05; my $OBJ_ID = 0x06; my $UTF8String = 0x0c; my $SEQUENCE = 0x10; my $SET = 0x11; my $UTCTime = 0x17; my $GeneralizedTime = 0x18; sub encode_asn1_oid($) { my ($o1, $o2, @oid) = split(/\./, $_[0]); my @bytes; push @bytes, 40*$o1 + $o2; while (scalar(@oid) > 0) { my $c = $oid[0]; shift @oid; my @base128 = (); push @base128, ($c % 128); while ($c > 128) { $c /= 128; push @base128, (($c % 128) | 128); }; push @bytes, reverse(@base128); } return pack("C*", @bytes); } my %OIDs = ( # joint-iso-itu-t(2) ds(5) attributeType(4) encode_asn1_oid("2.5.4.3") => "commonName", encode_asn1_oid("2.5.4.6") => "countryName", encode_asn1_oid("2.5.4.10") => "organizationName", encode_asn1_oid("2.5.4.11") => "organizationUnitName", # iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) pkcs-1(1) encode_asn1_oid("1.2.840.113549.1.1.1") => "rsaEncryption", encode_asn1_oid("1.2.840.113549.1.1.5") => "sha1WithRSAEncryption", encode_asn1_oid("1.2.840.113549.1.9.1") => "emailAddress", # joint-iso-itu-t(2) ds(5) certificateExtension(29) encode_asn1_oid("2.5.29.35") => "authorityKeyIdentifier", encode_asn1_oid("2.5.29.14") => "subjectKeyIdentifier", encode_asn1_oid("2.5.29.19") => "basicConstraints", # iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) pkcs-7(7) encode_asn1_oid("1.2.840.113549.1.7.1") => "pkcs7-data", encode_asn1_oid("1.2.840.113549.1.7.2") => "pkcs7-signed-data", ); ############################################################################### # # Extract an ASN.1 element from a string and return information about it. # ############################################################################### my $ASN1_EXTRACT_MSG = "asn1_extract"; sub asn1_extract($$@) { my ($cursor, $expected_tag, $optional) = @_; return [ -1 ] if ($cursor->[1] == 0 && $optional); die $ASN1_EXTRACT_MSG, ": ", $cursor->[0], ": ASN.1 data underrun (elem ", $cursor->[1], ")\n" if ($cursor->[1] < 2); my ($tag, $len) = unpack("CC", substr(${$cursor->[2]}, $cursor->[0], 2)); if ($expected_tag != -1 && $tag != $expected_tag) { return [ -1 ] if ($optional); die $ASN1_EXTRACT_MSG, ": ", $cursor->[0], ": ASN.1 unexpected tag (", $tag, " not ", $expected_tag, ")\n"; } $cursor->[0] += 2; $cursor->[1] -= 2; die $ASN1_EXTRACT_MSG, ": ", $cursor->[0], ": ASN.1 long tag\n" if (($tag & 0x1f) == 0x1f); die $ASN1_EXTRACT_MSG, ": ", $cursor->[0], ": ASN.1 indefinite length\n" if ($len == 0x80); if ($len > 0x80) { my $l = $len - 0x80; die $ASN1_EXTRACT_MSG, ": ", $cursor->[0], ": ASN.1 data underrun (len len $l)\n" if ($cursor->[1] < $l); if ($l == 0x1) { $len = unpack("C", substr(${$cursor->[2]}, $cursor->[0], 1)); } elsif ($l == 0x2) { $len = unpack("n", substr(${$cursor->[2]}, $cursor->[0], 2)); } elsif ($l == 0x3) { $len = unpack("C", substr(${$cursor->[2]}, $cursor->[0], 1)) << 16; $len = unpack("n", substr(${$cursor->[2]}, $cursor->[0] + 1, 2)); } elsif ($l == 0x4) { $len = unpack("N", substr(${$cursor->[2]}, $cursor->[0], 4)); } else { die $ASN1_EXTRACT_MSG, ": ", $cursor->[0], ": ASN.1 element too long (", $l, ")\n"; } $cursor->[0] += $l; $cursor->[1] -= $l; } die $ASN1_EXTRACT_MSG, ": ", $cursor->[0], ": ASN.1 data underrun (", $len, ")\n" if ($cursor->[1] < $len); my $ret = [ $tag, [ $cursor->[0], $len, $cursor->[2] ] ]; $cursor->[0] += $len; $cursor->[1] -= $len; return $ret; } ############################################################################### # # Retrieve the data referred to by a cursor # ############################################################################### sub asn1_retrieve($) { my ($cursor) = @_; my ($offset, $len, $data) = @$cursor; return substr($$data, $offset, $len); } # 2's complement representation of ASN1_INTEGER sub asn1_int($) { my ($p) = @_; my @bytes = unpack("C*", $p); my $byte; my $neg = 0; my $v = 0; if (($bytes[0] & 0x80) != 0) { $neg = 1; $bytes[0] &= ~0x80; } foreach $byte (@bytes) { $v <<= 8; $v += $byte; } if ($neg) { $v -= (2 ** (8 * scalar(@bytes) - 1)); }; return $v; } sub asn1_pack($@) { my ($tag, @data) = @_; my $ret = pack("C", $tag); my $data = join('', @data); my $l = length($data); return pack("CC", $tag, $l) . $data if $l < 127; my $ll = $l >> 8 ? $l >> 16 ? $l >> 24 ? 4 : 3 : 2 : 1; return pack("CCa*", $tag, $ll | 0x80, substr(pack("N", $l), -$ll)) . $data; } my %hash_algos = ( # iso(1) identified-organization(3) oiw(14) secsig(3) algorithms(2) 2 => ["sha1", 160/8, encode_asn1_oid("1.3.14.3.2.26")], # joint-iso-itu-t(2) country(16) us(840) organization(1) gov(101) csor(3) nistAlgorithm(4) hashAlgs(2) 4 => ["sha256", 256/8, encode_asn1_oid("2.16.840.1.101.3.4.2.1")], 5 => ["sha384", 384/8, encode_asn1_oid("2.16.840.1.101.3.4.2.2")], 6 => ["sha512", 512/8, encode_asn1_oid("2.16.840.1.101.3.4.2.3")], 7 => ["sha224", 224/8, encode_asn1_oid("2.16.840.1.101.3.4.2.4")], ); sub hash_prologue($$) { my ($hash_len, $algo) = @_; my $obj = asn1_pack($UNIV | $OBJ_ID, $algo); my $seq = asn1_pack($UNIV | $CONS | $SEQUENCE, $obj . pack("CC", $NULL, 0)); my $tail = pack("CC", $OCTET_STRING, $hash_len); my $head = pack("CC", $UNIV | $CONS | $SEQUENCE, length($seq) + length($tail) + $hash_len); return $head . $seq . $tail; } sub find_hash_algo_by_oid($) { my ($oid) = @_; my $key; my $k; SEARCH: foreach $k (keys %hash_algos) { my ($_h, $_n, $_a) = @{$hash_algos{$k}}; if ($oid eq $_a) { $key = $k; last SEARCH; } } die "$module_name: unsupported hash algorithm OID=".sprintf("%v02x", $oid) if !defined($key); return $key; } ############################################################################### # # Roughly parse the X.509 certificate # ############################################################################### sub parse_x509_dn(@) { my ($parent, $cursor) = @_; my ($offset, $len, $data) = @$cursor; my %result = (); while ($cursor->[1]> 0) { my $_set = asn1_extract($cursor, $UNIV | $CONS | $SET); my $_seq = asn1_extract($_set->[1], $UNIV | $CONS | $SEQUENCE); my $_oid = asn1_extract($_seq->[1], $UNIV | $OBJ_ID); my $oid = asn1_retrieve($_oid->[1]); if (defined($OIDs{$oid})) { my $key = "$parent/$OIDs{$oid}"; my $_x = asn1_extract($_seq->[1], -1); # debug "found $key at $_seq->[1][0]\n"; $result{$key} = asn1_retrieve($_x->[1]); }; } return \%result; } sub parse_x509_der($) { my ($bytes) = @_; my $cursor = [ 0, length($bytes), \$bytes ]; my $cert = asn1_extract($cursor, $UNIV | $CONS | $SEQUENCE); my $tbs = asn1_extract($cert->[1], $UNIV | $CONS | $SEQUENCE); my $version = asn1_extract($tbs->[1], $CONT | $CONS | 0, 1); my $serial_number = asn1_extract($tbs->[1], $UNIV | $INTEGER); my $sig_type = asn1_extract($tbs->[1], $UNIV | $CONS | $SEQUENCE); my $issuer = asn1_extract($tbs->[1], $UNIV | $CONS | $SEQUENCE); my $issuer_dn = parse_x509_dn("issuer", $issuer->[1]); my $validity = asn1_extract($tbs->[1], $UNIV | $CONS | $SEQUENCE); my $subject = asn1_extract($tbs->[1], $UNIV | $CONS | $SEQUENCE); my $key = asn1_extract($tbs->[1], $UNIV | $CONS | $SEQUENCE); my $pubkey = asn1_pack($UNIV | $CONS | $SEQUENCE, asn1_retrieve($key->[1])); my $issuer_uid = asn1_extract($tbs->[1], $CONT | $CONS | 1, 1); my $subject_uid = asn1_extract($tbs->[1], $CONT | $CONS | 2, 1); my $extension_list = asn1_extract($tbs->[1], $CONT | $CONS | 3, 1); my $subject_key_id = (); my $authority_key_id = (); # # Parse the extension list # if ($extension_list->[0] != -1) { my $extensions = asn1_extract($extension_list->[1], $UNIV | $CONS | $SEQUENCE); while ($extensions->[1]->[1] > 0) { my $ext = asn1_extract($extensions->[1], $UNIV | $CONS | $SEQUENCE); my $x_oid = asn1_extract($ext->[1], $UNIV | $OBJ_ID); my $x_crit = asn1_extract($ext->[1], $UNIV | $BOOLEAN, 1); my $x_val = asn1_extract($ext->[1], $UNIV | $OCTET_STRING); my $raw_oid = asn1_retrieve($x_oid->[1]); next if (!exists($OIDs{$raw_oid})); my $x_type = $OIDs{$raw_oid}; my $raw_value = asn1_retrieve($x_val->[1]); if ($x_type eq "subjectKeyIdentifier") { my $vcursor = [ 0, length($raw_value), \$raw_value ]; $subject_key_id = asn1_extract($vcursor, $UNIV | $OCTET_STRING); } } } my %result = ( "subject_key_id" => asn1_retrieve($subject_key_id->[1]), "serial" => asn1_int(asn1_retrieve($serial_number->[1])), "pubkey" => $pubkey, %$issuer_dn, ); return \%result; } # # Function to read the contents of a file into a variable. # sub read_file($) { my ($file) = @_; my $contents; my $len; open(FD, "<$file") || die $file; binmode FD; my @st = stat(FD); die $file if (!@st); $len = read(FD, $contents, $st[7]) || die $file; close(FD) || die $file; die "$file: Wanted length ", $st[7], ", got ", $len, "\n" if ($len != $st[7]); return $contents; } sub openssl_pipe($$) { my ($input, $cmd) = @_; my ($pid, $res); $pid = open2(*read_from, *write_to, $cmd) || die $cmd; binmode write_to; if (defined($input) && $input ne "") { print write_to $input || return ""; } close(write_to) || die "$cmd: $!"; binmode read_from; read(read_from, $res, 4096) || return ""; close(read_from) || return ""; waitpid($pid, 0) || die; return "" if ($? >> 8); return $res; } sub cert_matches($$$$) { my ($cert, $subject_key_id, $issuer, $serial) = @_; my $bytes = read_file($cert); $ASN1_EXTRACT_MSG = $cert; my $cert_props = parse_x509_der($bytes); if (defined($subject_key_id)) { debug("$cert has key id " . unpack("H*", $cert_props->{"subject_key_id"}) . "\n"); if ($cert_props->{"subject_key_id"} eq $subject_key_id) { return $cert_props; } else { return 0; } } die "missing input data in cert_matches()" if (!defined($issuer) || !defined($serial)); if (!defined($cert_props->{"serial"}) || $cert_props->{"serial"} ne $serial) { debug "$cert: serial number mismatch: $serial != ". $cert_props->{"serial"}."\n"; return 0; } foreach my $k (keys(%$issuer)) { if (!defined($cert_props->{$k}) || $issuer->{$k} ne $cert_props->{$k}) { debug "$cert: $k does not match signature\n"; return 0; } } return $cert_props; } my $module = read_file($module_name); my $module_len = length($module); my $magic_number = "~Module signature appended~\n"; my $magic_len = length($magic_number); my $info_len = 12; sub eat { my $length = shift; if ($module_len < $length) { die "Module size too short\n"; } my $res = substr($module, -$length); $module = substr($module, 0, $module_len - $length); $module_len -= $length; return $res; } if (eat($magic_len) ne $magic_number) { print "$module_name: module not signed\n"; exit(3); } my $info = eat($info_len); my ($algo, $hash, $id_type, $name_len, $key_len, $sig_len) = unpack("CCCCCxxxN", $info); my $signature = eat($sig_len); # cert is identified either by subject key id, or by issuer DN + serial no my $issuer_dn; my $serial; my $key_id; my $name; if ($id_type == 1) { if (unpack("n", $signature) != $sig_len - 2) { die "Invalid signature format\n"; } $signature = substr($signature, 2); $key_id = eat($key_len); $name = eat($name_len); if ($algo != 1) { die "Unsupported signature algorithm\n"; } } elsif ($id_type == 2) { # PKCS7 signature $ASN1_EXTRACT_MSG = $module_name; my $cursor = [ 0, length($signature), \$signature ]; my $seq0 = asn1_extract($cursor, $UNIV | $CONS | $SEQUENCE); my $signed_data = asn1_extract($seq0->[1], $UNIV | $OBJ_ID); die "$module_name: no PKCS#7 signed_data structure\n" if $OIDs{asn1_retrieve($signed_data->[1])} !~ /^pkcs7-signed-data$/; my $ctx1 = asn1_extract($seq0->[1], $UNIV | $CONT | $CONS); my $seq1 = asn1_extract($ctx1->[1], $UNIV | $CONS | $SEQUENCE); my $sig_version = asn1_extract($seq1->[1], $UNIV | $INTEGER); my $digest_algo_seq_set = asn1_extract($seq1->[1], $UNIV | $CONS | $SET); my $digest_algo_seq = asn1_extract($digest_algo_seq_set->[1], $UNIV | $CONS | $SEQUENCE); my $digest_algo = asn1_extract($digest_algo_seq->[1], $UNIV | $OBJ_ID); $hash = find_hash_algo_by_oid(asn1_retrieve($digest_algo->[1])); my $seq2 = asn1_extract($seq1->[1], $UNIV | $CONS | $SEQUENCE); my $pkcs7_data = asn1_extract($seq2->[1], $UNIV | $OBJ_ID); die "$module_name: invalid PKCS#7 data" if $OIDs{asn1_retrieve($pkcs7_data->[1])} !~ /^pkcs7-data$/; my $si_set = asn1_extract($seq1->[1], $UNIV | $CONS | $SET); my $si_seq = asn1_extract($si_set->[1], $UNIV | $CONS | $SEQUENCE); my $si_version = asn1_extract($si_seq->[1], $UNIV | $INTEGER); my $_key_id = asn1_extract($si_seq->[1], -1); my $key_id; if ($_key_id->[0] == ($CONT | 0)) { # key_id: kernel-sign-file -k $key_id = asn1_extract($_key_id->[1], $CONT | 0); } else { # issuer / serial my $issuer = asn1_extract($_key_id->[1], $UNIV | $CONS | $SEQUENCE); my $_serial = asn1_extract($_key_id->[1], $UNIV | $INTEGER); $serial = asn1_int(asn1_retrieve($_serial->[1])); $issuer_dn = parse_x509_dn("issuer", $issuer->[1]); if (defined($issuer_dn->{"issuer/commonName"})) { $name = "cn=" . $issuer_dn->{"issuer/commonName"} . ",serial=$serial"; } } my $seq4 = asn1_extract($si_seq->[1], $UNIV | $CONS | $SEQUENCE); my $digest2 = asn1_extract($seq4->[1], $UNIV | $OBJ_ID); my $hash2 = find_hash_algo_by_oid(asn1_retrieve($digest2->[1])); die "$module_name: inconsistent hash" if $hash2 != $hash; my $seq5 = asn1_extract($si_seq->[1], $UNIV | $CONS | $SEQUENCE); my $enc = asn1_extract($seq5->[1], $UNIV | $OBJ_ID); die "$module_name: invalid encryption type". sprintf("%v02x", asn1_retrieve($enc->[1])) if $OIDs{asn1_retrieve($enc->[1])} ne "rsaEncryption"; my $_sig = asn1_extract($si_seq->[1], $UNIV | $OCTET_STRING); $signature = asn1_retrieve($_sig->[1]); } else { die "unsupported signature type $id_type"; } # # Digest the data # my ($prologue, $hash_len, $dgst, $oid); die "Unsupported hash algorithm\n" if not exists $hash_algos{$hash}; ($dgst, $hash_len, $oid) = @{$hash_algos{$hash}}; $prologue = hash_prologue($hash_len, $oid); verbose("Signature type: ", $id_type == 1 ? "legacy" : "pkcs#7", "\n"); verbose("Signed by: $name\n") if defined ($name); verbose("Key id: " . unpack("H*", $key_id) . "\n") if (defined($key_id)); verbose("Hash algorithm: $dgst\n"); my $digest = openssl_pipe($module, "openssl dgst -$dgst -binary"); my $original_message = $prologue . $digest; my $good = 0; my $matched = 0; for my $cert (sort @certs) { debug("Trying $cert\n"); my $cert_props = cert_matches($cert, $key_id, $issuer_dn, $serial); next unless $cert_props; verbose("Found matching certificate $cert\n"); $matched = $cert; my ($fh, $filename) = tempfile() or die "Cannot create temporary file: $!\n"; print $fh $cert_props->{"pubkey"}; close($fh); my $verified_message = openssl_pipe($signature, "openssl rsautl -verify -inkey $filename -keyform DER -pubin"); unlink($filename); if ($original_message ne $verified_message) { verbose "$module_name: signature validation failed for $cert\n"; next; } print "$module_name: good signature\n"; $good = 1; exit(0); } if (!$matched) { print "certificate not found\n"; exit(2); } else { print "$module_name: bad signature\n"; exit(1); } 07070100000018000081ED000000000000000000000001669F469C0000493D000000000000000000000000000000000000004A00000000pesign-obs-integration-10.2+git20240723.d344d91/pesign-gen-repackage-spec#!/usr/bin/perl # Given a set of rpm packages and directory with their new content, # generate a specfile that generates new packages # # Copyright (c) 2013 SUSE Linux Products GmbH, Nuernberg, Germany. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA use strict; use warnings; my $USAGE = "Usage: $0 --directory <payload directory> rpm...\n"; use Getopt::Long; use Fcntl qw(:mode :seek); use File::Basename qw(dirname); use File::Path qw(make_path); my $directory; my $output = "."; my $cert_subpackage; my $kmp_basename; my $compress = ""; my $macros_file = ""; my @rpms; $ENV{LC_ALL} = "en_US.UTF-8"; GetOptions( "help|h" => sub { print $USAGE; exit; }, "directory|d=s" => \$directory, "output|o=s" => \$output, "cert-subpackage|c=s" => \$cert_subpackage, "compress|C=s" => \$compress, "macros|M=s" => \$macros_file, ) or die $USAGE; @rpms = @ARGV; if (!@rpms) { print STDERR "$0: No packages given\n"; die $USAGE; } if (!$directory || substr($directory, 0, 1) ne '/' || ! -d $directory) { print STDERR "$0: --directory must be an absolute path\n"; die $USAGE; } sub query_array { my ($rpm, @tags) = @_; my @res; my $format = "[" . join("|", map { "\%{$_}" } @tags) . "\\n]"; open(my $fh, '-|', "rpm", "-qp", "--qf", $format, $rpm) or die "rpm: $!\n"; while (<$fh>) { chomp; my @t = split(/\|/, $_, -1); push(@res, \@t); } close($fh); return @res; } sub query_multiline_array { my ($rpm, $tag) = @_; my @res; my $delim = "|||"; # XXX - dangerous my $format = "[$delim\\n\%{$tag}\\n]"; open(my $fh, '-|', "rpm", "-qp", "--qf", $format, $rpm) or die "rpm: $!\n"; my $line = <$fh>; return unless $line; chomp($line); return if $line eq "(none)"; die "Expected \"$delim\" at beginning of rpm output, got \"$line\"" if $line ne $delim; my $cur = ""; while ($line = <$fh>) { chomp($line); if ($line eq $delim) { $cur = "" if $cur eq "\n"; push(@res, $cur); $cur = ""; } else { $cur .= $line . "\n"; } } $cur = "" if $cur eq "\n"; push(@res, $cur); close($fh); return @res; } sub query_single { my ($rpm, $tag) = @_; my $res; open(my $fh, '-|', "rpm", "-qp", "--qf", "\%{$tag}\\n", $rpm) or die "rpm: $!\n"; { local $/ = undef; $res = <$fh>; } chomp $res; if ($res eq "(none)") { $res = ""; } close($fh); return $res; } # specfile dependency => rpm tag name my %dep2tag = ( conflicts => "conflict", obsoletes => "obsolete", provides => "provide", requires => "require", suggests => "suggest", enhances => "enhance", recommends => "recommend", supplements => "supplement", orderwithrequires => "order", ); # specfile scriptlet => rpm tag name my %script2tag = ( pre => "prein", post => "postin", preun => "preun", postun => "postun", pretrans => "pretrans", posttrans => "posttrans", verifyscript => "verifyscript", # FIXME: triggers ); # compressor => specfile payload my %com2pl = ( gzip => "gzdio", bzip2 => "bzdio", xz => "xzdio", lzma => "lzdio", zstd => "zstdio", ); my %sense2tag = ( 0x10000 => 'triggerin', 0x20000 => 'triggerun', 0x40000 => 'triggerpostun', ); # tags which are printed verbatim in the specfile my @simple_tags = qw(epoch version release license group summary packager vendor url vcs distribution); my @payload_tags = qw(payloadcompressor payloadflags); sub load_package { my $rpm = shift; my %res; for my $tag (qw(name arch sourcerpm description), @simple_tags, @payload_tags) { $res{$tag} = query_single($rpm, $tag); } my @files; my @list = query_array($rpm, qw(filenames fileflags filemodes fileusername filegroupname filesizes filemtimes filelinktos fileverifyflags filelangs)); for my $file (@list) { my $new = { name => $file->[0], flags => $file->[1], mode => $file->[2], owner => $file->[3], group => $file->[4], size => $file->[5], mtime => $file->[6], target => $file->[7], verify => $file->[8], lang => $file->[9], }; push(@files, $new); if ($new->{name} =~ /\.ko$/ && S_ISREG($new->{mode})) { $res{is_kmp} = 1; } } $res{files} = \@files; while (my ($dep, $tag) = each(%dep2tag)) { my @deps; my @list = query_array($rpm, "${tag}name", "${tag}flags", "${tag}version"); for my $d (@list) { next if $d->[0] eq "(none)"; push(@deps, { name => $d->[0], flags => $d->[1], version => $d->[2], }); } $res{$dep} = \@deps; } while (my ($script, $tag) = each(%script2tag)) { my $interp = query_single($rpm, "${tag}prog"); next unless $interp; my $s = query_single($rpm, $tag); $res{$script} = { interp => $interp, script => $s, }; } my @triggers = query_array($rpm, qw(triggertype triggerscriptprog triggerconds)); my @triggerscripts = query_multiline_array($rpm, "triggerscripts"); if (scalar(@triggers) != scalar(@triggerscripts)) { die "# of %%{triggertype} tags (" . scalar(@triggers) . ") != # of %%{triggerscripts} tags (" . scalar(@triggerscripts) . ")"; } for (my $i = 0; $i < scalar(@triggers); $i++) { $res{triggers} ||= []; push(@{$res{triggers}}, { type => $triggers[$i]->[0], interp => $triggers[$i]->[1], conds => $triggers[$i]->[2], script => $triggerscripts[$i], }); } my @filetriggerprogs = query_array($rpm, qw(filetriggerscriptprog filetriggerscriptflags filetriggerpriorities)); my @filetriggerscripts = query_multiline_array($rpm, "filetriggerscripts"); my @filetriggers = query_array($rpm, qw(filetriggerindex filetriggername filetriggerversion filetriggerflags)); if (scalar(@filetriggerprogs) != scalar(@filetriggerscripts)) { die "# of %%{filetriggerscriptprog} tags (" . scalar(@filetriggerprogs) . ") != # of %%{filetriggerscripts} tags (" . scalar(@filetriggerscripts) . ")"; } my @filetriggeridx; for (my $i = 0; $i < scalar(@filetriggers); $i++) { push @{$filetriggeridx[$filetriggers[$i]->[0]]}, $i; } for (my $i = 0; $i < scalar(@filetriggerprogs); $i++) { my @idx = @{$filetriggeridx[$i] || []}; $res{filetriggers} ||= []; push(@{$res{filetriggers}}, { name => [ map {$filetriggers[$_]->[1]} @idx ], interp => $filetriggerprogs[$i]->[0], scriptflags => $filetriggerprogs[$i]->[1], version => [ map {$filetriggers[$_]->[2]} @idx ], sense => [ map {$filetriggers[$_]->[3]} @idx ], priority => $filetriggerprogs[$i]->[2], script => $filetriggerscripts[$i], }); } my @transfiletriggerprogs = query_array($rpm, qw(transfiletriggerscriptprog transfiletriggerscriptflags transfiletriggerpriorities)); my @transfiletriggerscripts = query_multiline_array($rpm, "transfiletriggerscripts"); my @transfiletriggers = query_array($rpm, qw(transfiletriggerindex transfiletriggername transfiletriggerversion transfiletriggerflags)); if (scalar(@transfiletriggerprogs) != scalar(@transfiletriggerscripts)) { die "# of %%{transfiletriggerscriptprog} tags (" . scalar(@transfiletriggerprogs) . ") != # of %%{transfiletriggerscripts} tags (" . scalar(@transfiletriggerscripts) . ")"; } my @transfiletriggeridx; for (my $i = 0; $i < scalar(@transfiletriggers); $i++) { push @{$transfiletriggeridx[$transfiletriggers[$i]->[0]]}, $i; } for (my $i = 0; $i < scalar(@transfiletriggerprogs); $i++) { my @idx = @{$transfiletriggeridx[$i] || []}; $res{transfiletriggers} ||= []; push(@{$res{transfiletriggers}}, { name => [ map {$transfiletriggers[$_]->[1]} @idx ], interp => $transfiletriggerprogs[$i]->[0], scriptflags => $transfiletriggerprogs[$i]->[1], version => [ map {$transfiletriggers[$_]->[2]} @idx ], sense => [ map {$transfiletriggers[$_]->[3]} @idx ], priority => $transfiletriggerprogs[$i]->[2], script => $transfiletriggerscripts[$i], }); } open(my $fh, '-|', "rpm", "-qp", "--changelog", $rpm) or die "rpm: $!\n"; { local $/ = undef; my $changelog = <$fh>; close($fh); $res{changelog} = $changelog; } return \%res; } # quote percent signs in text sub quote { my $text = shift; $text =~ s/%/%%/g; return $text; } sub print_script { my ($file, $script) = @_; return unless $script->{script}; open(my $fh, '>', "$output/$file") or die "$output/$file: $!\n"; print $fh quote($script->{script}); close($fh); print SPEC " -f $file"; } sub print_package { my ($p, $is_main) = @_; my $payloadstr = "w.ufdio"; if ($p->{payloadcompressor}) { my $payload = $com2pl{$p->{payloadcompressor}}; if ($payload) { $payloadstr = "w$p->{payloadflags}.$payload"; } else { die "Unknown compressor: $p->{payloadcompressor}"; } } print SPEC "\%define _binary_payload $payloadstr\n"; if ($is_main) { print SPEC "\%{load:\%_sourcedir/$macros_file}\n" if $macros_file ne ""; print SPEC "Name: $p->{name}\n"; print SPEC "Buildroot: $directory\n"; if ($p->{nosource}) { # We do not generate any no(src).rpm, but we want the # %{sourcerpm} tag in the binary packages to match. # So we add a dummy source and mark it as nosource. print SPEC "Source0: repackage.spec\n"; print SPEC "NoSource: 0\n"; } } else { print SPEC "\%package -n $p->{name}\n"; } for my $tag (@simple_tags) { next if $p->{$tag} eq ""; print SPEC "$tag: " . quote($p->{$tag}) . "\n"; } print SPEC "BuildArch: noarch\n" if $p->{arch} eq "noarch"; for my $dep (sort(keys(%dep2tag))) { print_deps($dep, $p->{$dep}); } if ($cert_subpackage && $p->{is_kmp}) { print SPEC "Requires: $kmp_basename-ueficert\n"; } print SPEC "\%description -n $p->{name}\n"; print SPEC quote($p->{description}) . "\n\n"; for my $script (sort(keys(%script2tag))) { next unless $p->{$script}; print SPEC "\%$script -p $p->{$script}{interp} -n $p->{name}"; print_script("$script-$p->{name}", $p->{$script}); print SPEC "\n"; } my $i = 0; for my $trigger (@{$p->{triggers}}) { print SPEC "\%trigger$trigger->{type} -p $trigger->{interp} -n $p->{name}"; print_script("trigger$i-$p->{name}", $trigger); print SPEC " -- $trigger->{conds}\n"; $i++; } for my $trigger (@{$p->{filetriggers}}) { my $sense = $trigger->{'sense'}->[0]; die("unsupported sense $sense\n") unless $sense2tag{$sense}; print SPEC "\%file$sense2tag{$sense}"; print SPEC " -P $trigger->{'priority'}" if $trigger->{'priority'} && $trigger->{'priority'} ne '(none)'; print SPEC " -p $trigger->{interp} -n $p->{name}"; print_script("trigger$i-$p->{name}", $trigger); print SPEC " -- ".join(' ', @{$trigger->{'name'}})."\n"; $i++; } for my $trigger (@{$p->{transfiletriggers}}) { my $sense = $trigger->{'sense'}->[0]; die("unsupported sense $sense\n") unless $sense2tag{$sense}; print SPEC "\%transfile$sense2tag{$sense}"; print SPEC " -P $trigger->{'priority'}" if $trigger->{'priority'} && $trigger->{'priority'} ne '(none)'; print SPEC " -p $trigger->{interp} -n $p->{name}"; print_script("trigger$i-$p->{name}", $trigger); print SPEC " -- ".join(' ', @{$trigger->{'name'}})."\n"; $i++; } if ($p->{files}) { print SPEC "\%files -n $p->{name}\n"; print_files($p->{files}); } print SPEC "\n"; } # /usr/include/rpm/rpmds.h my %deptypes = ( posttrans => (1 << 5), pretrans => (1 << 7), interp => (1 << 8), pre => (1 << 9), post => (1 << 10), preun => (1 << 11), postun => (1 << 12), verify => (1 << 13), ); my %depflags = ( "<" => (1 << 1), ">" => (1 << 2), "=" => (1 << 3), find_requires => (1 << 14), find_provides => (1 << 15), rpmlib => (1 << 24), config => (1 << 28), ); sub print_deps { my ($depname, $list) = @_; DEPLOOP: foreach my $d (@$list) { for my $flag (qw(rpmlib config find_requires find_provides)) { next DEPLOOP if ($d->{flags} & $depflags{$flag}); } print SPEC $depname; my @deptypes; while (my ($type, $bit) = each(%deptypes)) { push(@deptypes, $type) if $d->{flags} & $bit; } print SPEC "(", join(",", @deptypes), ")" if @deptypes; print SPEC ": "; print SPEC quote($d->{name}); if ($d->{version}) { print SPEC " "; for my $op (qw(< > =)) { print SPEC $op if $d->{flags} & $depflags{$op}; } print SPEC " " . quote($d->{version}); } print SPEC "\n"; } } # /usr/include/rpm/rpmfi.h my %filetypes = ( config => (1 << 0), doc => (1 << 1), missingok => (1 << 3), noreplace => (1 << 4), ghost => (1 << 6), license => (1 << 7), readme => (1 << 8), pubkey => (1 << 11), artifact => (1 << 12), ); my %verifyflags = ( filedigest=> (1 << 0), size => (1 << 1), link => (1 << 2), user => (1 << 3), group => (1 << 4), mtime => (1 << 5), mode => (1 << 6), rdev => (1 << 7), caps => (1 << 8), ); sub print_files { my $files = shift; my @tocompress; my $compress_ext = ""; my $compress_cmd = ""; if ($compress eq "xz") { $compress_ext = ".xz"; $compress_cmd = "xz --lzma2=dict=2MiB -f"; } elsif ($compress eq "gzip") { $compress_ext = ".gz"; $compress_cmd = "gzip -n -f"; } elsif ($compress eq "zstd") { $compress_ext = ".zst"; $compress_cmd = "zstd -T0 --rm -f -q"; } for my $f (@$files) { my $path = "$directory/$f->{name}"; my $attrs = ""; # Fix mtime of directories, which cpio -idm fails to preserve if (S_ISDIR($f->{mode})) { $attrs .= "\%dir "; utime($f->{mtime}, $f->{mtime}, $path); } if ($f->{flags} & $filetypes{config}) { $attrs .= "%config "; my @cfg_attrs; for my $attr (qw(missingok noreplace)) { next unless $f->{flags} & $filetypes{$attr}; push(@cfg_attrs, $attr); } $attrs .= "(" . join(",", @cfg_attrs) . ")" if @cfg_attrs; } for my $filetype (qw(doc license readme pubkey artifact)) { $attrs .= "%$filetype " if $f->{flags} & $filetypes{$filetype}; } if ($f->{flags} & $filetypes{ghost}) { $attrs .= "%ghost "; if (S_ISREG($f->{mode})) { make_path(dirname($path)); open(my $fh, '>', $path) or die "$path: $!\n"; if ($f->{size} > 0) { sysseek($fh, $f->{size} - 1, SEEK_SET); syswrite($fh, ' ', 1); } close($fh); utime($f->{mtime}, $f->{mtime}, $path); } elsif (S_ISDIR($f->{mode})) { make_path($path); } elsif (S_ISLNK($f->{mode})) { make_path(dirname($path)); symlink($f->{target}, $path); } } unless (S_ISLNK($f->{mode})) { $attrs .= sprintf('%%attr(%04o, %s, %s) ', ($f->{mode} & 07777), $f->{owner}, $f->{group}); } # mtime of symlinks is also not preserved by cpio if (S_ISLNK($f->{mode})) { # perl core does not provide lutimes()/utimensat() system("touch", "-h", "-d\@$f->{mtime}", $path); } my $verify_attrs = ""; for my $flag (sort(keys(%verifyflags))) { if (!($f->{verify} & $verifyflags{$flag})) { $verify_attrs .= "$flag "; } } if ($verify_attrs) { $attrs .= "%verify(not $verify_attrs) "; } if ($f->{lang} ne "") { $attrs .= sprintf('%%lang(%s) ', $f->{lang}); } if ($compress ne "" && $f->{name} =~ /\.ko$/ && S_ISREG($f->{mode})) { chmod($f->{mode}, $path); utime($f->{mtime}, $f->{mtime}, $path); push(@tocompress, $path); print SPEC "$attrs " . quote($f->{name}) . "$compress_ext\n"; } else { print SPEC "$attrs " . quote($f->{name}) . "\n"; } if (-e "$path.sig") { print SPEC "$attrs " . quote($f->{name}) . ".sig\n"; } } if ($#tocompress >= 0) { my $m = "$output/modulelist.txt"; open(M, '>', $m) or die "$m: $!\n"; print M join("\n", @tocompress); close(M); system("xargs -a $m -t -P 4 -n 1 $compress_cmd"); unlink($m); } } my %packages; for my $rpm (@rpms) { my $p = load_package($rpm); $packages{$p->{name}} = $p; } my $sourcerpm; for my $p (values(%packages)) { $sourcerpm = $p->{sourcerpm} unless $sourcerpm; if ($p->{sourcerpm} ne $sourcerpm) { die "Error: packages built from different source rpm: $sourcerpm vs $p->{sourcerpm}\n"; } } if ($sourcerpm !~ /^(.+)-([^-]+)-([^-]+)\.(no)?src\.rpm$/) { die "Error: malformed %{sourcerpm} tag: $sourcerpm\n"; } my ($main_name, $main_ver, $main_rel, $nosrc) = ($1, $2, $3, $4); if (!exists($packages{$main_name})) { # create an empty main package my $first = (sort(keys(%packages)))[0]; $packages{$main_name} = { name => $main_name, version => $main_ver, release => $main_rel, }; for my $tag (qw(description changelog), @simple_tags) { next if $packages{$main_name}->{$tag}; $packages{$main_name}->{$tag} = $packages{$first}->{$tag}; } my $main_arch = "noarch"; for my $subpack (keys(%packages)) { my $cur_arch = $packages{$subpack}->{'arch'}; $main_arch = $cur_arch if $cur_arch && $cur_arch ne "noarch"; } $packages{$main_name}->{'arch'} = $main_arch unless $packages{$main_name}->{'arch'}; } $packages{$main_name}->{nosource} = $nosrc ? 1 : 0; # Find out the basename of <name>-kmp-<flavor>, falling back to the # main package name for my $p (values(%packages)) { next unless $p->{is_kmp}; (my $n = $p->{name}) =~ s/-kmp-.*//; $kmp_basename = $n unless $kmp_basename; if ($n ne $kmp_basename) { $kmp_basename = undef; last; } } $kmp_basename = $main_name unless $kmp_basename; open(SPEC, '>', "$output/repackage.spec") or die "$output/repackage.spec: $!\n"; print_package($packages{$main_name}, 1); for my $name (sort(keys(%packages))) { next if $name eq $main_name; print_package($packages{$name}, 0); } if ($cert_subpackage) { my $certdir = "/etc/uefi/certs"; my $certs = ""; if (-d "$directory/$certdir") { opendir(my $dh, "$directory/$certdir") or die "$directory/$certdir"; while (my $cert = readdir($dh)) { next if $cert =~ /^\.\.?$/; if ($cert !~ /\.crt$/) { print STDERR "warning: Ignoring $directory/$certdir/$cert (no .crt suffix)\n"; next; } $cert =~ s{\.[^.]+$}{}; $certs .= " $cert"; } } if (!$certs) { print STDERR "warning: --cert-subpackage specified, but no certs found in $directory/$certdir\n"; } local $/ = undef; open(my $fh, '<', $cert_subpackage) or die "$cert_subpackage: $!\n"; my $template = <$fh>; close($fh); $template =~ s/\%\{-n\*}/$kmp_basename/g; $template =~ s/\@CERTS\@/$certs/g; print SPEC $template; } print SPEC "\%changelog\n"; print SPEC quote($packages{$main_name}->{changelog}); close(SPEC); 07070100000019000081A4000000000000000000000001669F469C0000394F000000000000000000000000000000000000004F00000000pesign-obs-integration-10.2+git20240723.d344d91/pesign-obs-integration.changes------------------------------------------------------------------- Mon Dec 21 03:50:35 UTC 2020 - Gary Ching-Pang Lin <glin@suse.com> - Update to version 10.2: * Fix the wrongly created noarch subpackages (issue#22, bsc#1180242) ------------------------------------------------------------------- Wed Oct 21 12:44:19 UTC 2020 - dmueller@suse.com - Update to version 10.1+1602850462: * Compress kernel modules in batch and in parallel * Forward _binary_payload to the repackaged rpm (bsc#1175882) - remove 0001-Forward-_binary_payload-to-the-repackaged-rpm.patch, parallel-compression.patch (upstream) ------------------------------------------------------------------- Thu Oct 15 21:13:24 UTC 2020 - dmueller@suse.com - Sync from git master directly - drop 0001-Add-support-for-kernel-module-compression.patch 0001-Enable-find_provides-and-requires.patch 0001-Initialize-compress-variable.patch 0001-Keep-the-files-in-the-OTHER-directory.patch 0001-Passthrough-license-tag.patch 0001-brp-99-compress-vmlinux-support-xz-compressed-vmlinu.patch 0001-sign-stage3.bin-from-s390-tools-with-sign-files-bsc-.patch pesign-sign-s390x-kernel.patch (upstream) - add parallel-compression.patch ------------------------------------------------------------------- Wed Sep 2 03:39:46 UTC 2020 - Gary Ching-Pang Lin <glin@suse.com> - Add 0001-Forward-_binary_payload-to-the-repackaged-rpm.patch to forward _binary_payload to the repackaged rpm (bsc#1175882) ------------------------------------------------------------------- Fri Jul 17 07:25:34 UTC 2020 - Gary Ching-Pang Lin <glin@suse.com> - Add 0001-Enable-find_provides-and-requires.patch (bsc#1114605) + Enable this patch again since virtualbox-kmp is split from the main package so the customized %find_provides for virtualbox-x11-guest won't be affected anymore. ------------------------------------------------------------------- Wed Feb 26 13:35:18 UTC 2020 - Marcus Meissner <meissner@suse.com> - pesign-sign-s390x-kernel.patch: Sign also the non-PE (e.g. s390x) kernels with just kernel-sign-file (bsc#1163524) ------------------------------------------------------------------- Wed Feb 19 14:25:32 UTC 2020 - Marcus Meissner <meissner@suse.com> - 0001-sign-stage3.bin-from-s390-tools-with-sign-files-bsc-.patch Hard code signing of stage3.bin of s390-tools (bsc#1163524) ------------------------------------------------------------------- Wed Nov 6 09:58:34 UTC 2019 - Jiri Slaby <jslaby@suse.com> - 0001-brp-99-compress-vmlinux-support-xz-compressed-vmlinu.patch to support xz-compressed vmlinux (bnc#1155921) ------------------------------------------------------------------- Wed Nov 6 03:52:16 UTC 2019 - Gary Ching-Pang Lin <glin@suse.com> - 0001-Keep-the-files-in-the-OTHER-directory.patch to keep the files in the OTHER directory (boo#1155474) ------------------------------------------------------------------- Wed Sep 4 12:18:39 UTC 2019 - Michal Suchanek <msuchanek@suse.com> - Require pesign on arm (boo#1134303). ------------------------------------------------------------------- Thu Aug 1 02:41:28 UTC 2019 - Gary Ching-Pang Lin <glin@suse.com> - Add 0001-Initialize-compress-variable.patch to initialize $compress in pesign-gen-repackage-spec to avoid warning ------------------------------------------------------------------- Wed May 29 06:01:20 UTC 2019 - Gary Ching-Pang Lin <glin@suse.com> - Add 0001-Add-support-for-kernel-module-compression.patch to support kernel module compression (bsc#1135854) ------------------------------------------------------------------- Fri May 17 14:00:08 UTC 2019 - Guillaume GARDET <guillaume.gardet@opensuse.org> - pesign is also available on %arm (boo#1134303). ------------------------------------------------------------------- Tue Apr 16 03:53:05 UTC 2019 - Gary Ching-Pang Lin <glin@suse.com> - Drop 0002-Enable-find_provides-and-requires.patch due to the build failure of virtualbox-guest-x11 ------------------------------------------------------------------- Thu Apr 11 03:45:03 UTC 2019 - Gary Ching-Pang Lin <glin@suse.com> - rpm: forward the missing rpm bits (bsc#1114605) + 0001-Passthrough-license-tag.patch + 0002-Enable-find_provides-and-requires.patch ------------------------------------------------------------------- Tue Dec 11 10:19:44 UTC 2018 - glin@suse.com - Version 10.1 - Add modsign-verify for the signature verification (bsc#1118953) ------------------------------------------------------------------- Wed Oct 31 10:11:48 UTC 2018 - glin@suse.com - rpm: properly forward dep flags (bsc#1114605) - Fix new Lintian Error from Debian 10 ------------------------------------------------------------------- Tue Jun 12 03:30:33 UTC 2018 - glin@suse.com - debhelper: restrict wildcard package unpacking ------------------------------------------------------------------- Mon Jun 11 03:17:37 UTC 2018 - glin@suse.com - debhelper: fix conffiles corner case ------------------------------------------------------------------- Fri Jun 8 03:08:29 UTC 2018 - glin@suse.com - Remove the unstable source url - Update the debian scripts ------------------------------------------------------------------- Mon Jun 4 10:23:24 UTC 2018 - glin@suse.com - Switch to tarball release ------------------------------------------------------------------- Thu Feb 22 09:16:35 UTC 2018 - glin@suse.com - Provide password file for 'certutil -A' due to the change in mozilla-nss 3.35 (boo#1082235) ------------------------------------------------------------------- Wed Nov 8 04:35:57 UTC 2017 - jlee@suse.com - Modified modsign-repackage, using certificate to try to decrypt the signature of kernel module. It can be used to verify the integrity of signature. ------------------------------------------------------------------- Wed Sep 27 10:53:39 UTC 2017 - jlee@suse.com - Michael Schröder improved the original kernel-sign-file script to support PKCS#7 kernel module signing. Replacing sign-file.c with new kernel-sign-file script. (bsc#1049122) ------------------------------------------------------------------- Sun Sep 24 09:20:31 UTC 2017 - coolo@suse.com - escape regexp in pesign-gen-repackage-spec for perl 5.26 ------------------------------------------------------------------- Wed Sep 6 02:47:26 UTC 2017 - jlee@suse.com - To support PKCS#7 kernel module signing, copy sign-file.c from SLE-15 v4.12 kernel source to replace the kernel-sign-file script to align upstream. (bsc#1049122) ------------------------------------------------------------------- Tue Nov 29 08:29:36 UTC 2016 - mmarek@suse.cz - Copy over any *.log files from the first build (bsc#1012422) ------------------------------------------------------------------- Thu Mar 3 10:17:32 UTC 2016 - glin@suse.com - Add aarch64 support since pesign also build on aarch64 ------------------------------------------------------------------- Thu Jan 22 15:56:41 UTC 2015 - mmarek@suse.cz - Add support for file verify flags (bnc#905420). ------------------------------------------------------------------- Thu Jan 22 15:55:26 UTC 2015 - mmarek@suse.cz - Sort the parts of the repackage spec file for easier debugging. ------------------------------------------------------------------- Tue Sep 16 17:08:36 CEST 2014 - mls@suse.de - fall back to project cert in the followup spec if it exists ------------------------------------------------------------------- Wed Sep 3 01:41:37 CEST 2014 - ro@suse.de - sanitize release line in specfile ------------------------------------------------------------------- Wed Aug 20 15:09:50 UTC 2014 - mmarek@suse.cz - brp-99-compress-vmlinux: Compress the vmlinux image after find-debuginfo (bnc#880848, bnc#884459) ------------------------------------------------------------------- Tue Aug 12 13:38:14 UTC 2014 - meissner@suse.com - switch gen-hmac to use fipscheck instead of sha256hmac ------------------------------------------------------------------- Mon Aug 4 12:52:40 UTC 2014 - mmarek@suse.cz - Set BRP_PESIGN_FILES="" in the repackage build to avoid loops. ------------------------------------------------------------------- Wed Jul 30 09:32:58 UTC 2014 - mmarek@suse.cz - Accept also rpmlintrc files without any <package>- prefix. ------------------------------------------------------------------- Mon Jul 28 14:14:39 UTC 2014 - mmarek@suse.cz - Use package's rpmlintrc files in the second build. ------------------------------------------------------------------- Thu Jul 3 14:01:24 UTC 2014 - mmarek@suse.cz - Drop support for signing firmware files (bnc#867199) ------------------------------------------------------------------- Thu Apr 24 09:25:18 UTC 2014 - mmarek@suse.cz - Fix matching /boot and /lib/firmware in pesign-repackage.spec ------------------------------------------------------------------- Wed Apr 23 22:28:05 UTC 2014 - mmarek@suse.com - Do not store the buildroot in the .*.hmac file. ------------------------------------------------------------------- Wed Apr 23 21:48:04 UTC 2014 - mmarek@suse.com - Regenerate the HMAC checksum when signing and EFI binary with a checksum (fate#316930, bnc#856310). ------------------------------------------------------------------- Wed Apr 23 21:38:42 UTC 2014 - mmarek@suse.com - Update README. ------------------------------------------------------------------- Wed Apr 23 19:49:09 UTC 2014 - mmarek@suse.cz - Add /usr/lib/rpm/pesign/gen-hmac tool to generate a hmac checksum for a given file (fate#316930, bnc#856310). ------------------------------------------------------------------- Thu Apr 3 12:01:54 CEST 2014 - ro@suse.de - pesign-gen-repackage-spec: switch to new rpm style handling of weak dependencies ------------------------------------------------------------------- Thu Jan 16 15:12:22 UTC 2014 - mmarek@suse.cz - Do not sign any files if BRP_PESIGN_FILES is set not an empty string (bnc#857599). ------------------------------------------------------------------- Tue Jan 7 09:50:58 UTC 2014 - mmarek@suse.cz - Fix a typo in the last change. ------------------------------------------------------------------- Mon Jan 6 22:08:41 UTC 2014 - mmarek@suse.cz - Default to BRP_PESIGN_FILES="*.ko /lib/firmware" (bnc#857599). ------------------------------------------------------------------- Mon Jan 6 16:35:30 UTC 2014 - mmarek@suse.cz - Add --signatures=<directory> option to modsign-repackage (bnc#841627). ------------------------------------------------------------------- Fri Jun 14 12:19:47 UTC 2013 - mmarek@suse.cz - Put debuginfo packages to %_topdir/OTHER (bnc#824971). ------------------------------------------------------------------- Thu Mar 28 15:55:10 UTC 2013 - mmarek@suse.cz - Version 10 - Add modsign-repackage tool to repackage RPMs outside the buildservice ------------------------------------------------------------------- Tue Mar 26 06:19:45 UTC 2013 - glin@suse.com - Calculate the digest of the padded data section to be consistent with the output file (bnc#808594, bnc#811325) ------------------------------------------------------------------- Fri Mar 15 06:19:39 UTC 2013 - coolo@suse.com - correct the license of the generated package to fix build ------------------------------------------------------------------- Tue Mar 5 08:23:48 UTC 2013 - mmarek@suse.cz - Do not repackage debuginfo package (bnc#806637) ------------------------------------------------------------------- Mon Mar 4 16:08:34 UTC 2013 - mmarek@suse.cz - Version 9 - Add support for triggers (bnc#806737) ------------------------------------------------------------------- Wed Feb 20 09:16:24 UTC 2013 - mmarek@suse.cz - Do not fail the build if %_topdir/OTHER cannot be created ------------------------------------------------------------------- Wed Feb 13 14:51:47 UTC 2013 - mmarek@suse.cz - Version 8 - Hide baselibs from post-build-checks ------------------------------------------------------------------- Wed Feb 13 09:34:27 UTC 2013 - mmarek@suse.cz - Do not repackage baselibs ------------------------------------------------------------------- Wed Feb 13 08:28:31 UTC 2013 - mmarek@suse.cz - Version 7 - Fix for scriptlets with empty body ------------------------------------------------------------------- Tue Feb 12 15:42:22 CET 2013 - mls@suse.de - reduce debugging as pesign is now fixed ------------------------------------------------------------------- Tue Feb 12 12:33:41 CET 2013 - mls@suse.de - add a bit of debug output to find out why the kernel signatures are bad ------------------------------------------------------------------- Wed Feb 6 13:24:14 CET 2013 - mls@suse.de - switch to normal brp hook - mv stuff in pesign directory instead of cluttering /usr/lib/rpm ------------------------------------------------------------------- Fri Feb 1 17:18:32 CET 2013 - mls@suse.de - fix pesign calls ------------------------------------------------------------------- Fri Feb 1 10:19:52 UTC 2013 - mmarek@suse.cz - Add some preliminary code to sign EFI binaries, marked with FIXMEs. ------------------------------------------------------------------- Wed Jan 30 09:47:25 UTC 2013 - mmarek@suse.cz - Version 6 - Fix handling packages with NoSource - Fix for multiple patterns in %sign_files ------------------------------------------------------------------- Tue Jan 29 13:44:43 UTC 2013 - mmarek@suse.cz - Version 5 - Use newc-style cpio archives, as required by the buildservice. - Use signing certificates provided by the buildservice. - Minor fixes. ------------------------------------------------------------------- Mon Jan 28 15:01:17 UTC 2013 - mmarek@suse.cz - Version 4 - Support for firmware signatures. - Expect the correct archive with signatures (<name>.cpio.rsasign.sig). - Minor fixes. ------------------------------------------------------------------- Wed Jan 23 22:01:40 UTC 2013 - mmarek@suse.cz - Version 3 - Switch to storing whole files in the *.cpio.rsasign archive. - Append the signatures to kernel modules. ------------------------------------------------------------------- Fri Jan 18 12:51:17 UTC 2013 - mmarek@suse.cz - Version 2 - Generates another specfile in pesign-repackage.spec to be able to copy nearly all RPM tags from the original packages. - Changed to only store sha256 hashes in the *.cpio.rsasign file, instead of whole files. ------------------------------------------------------------------- Thu Dec 13 12:06:00 UTC 2012 - mmarek@suse.com - Created package with macros and scripts to integrate kernel and bootloader signing into OBS (fate#314552). 0707010000001A000081A4000000000000000000000001669F469C00000A27000000000000000000000000000000000000004C00000000pesign-obs-integration-10.2+git20240723.d344d91/pesign-obs-integration.spec# # spec file for package pesign-obs-integration # # Copyright (c) 2024 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed # upon. The license for this file, and modifications and additions to the # file, is the same license as for the pristine package itself (unless the # license for the pristine package is not an Open Source License, in which # case the license is the MIT License). An "Open Source License" is a # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. # Please submit bugfixes or comments via https://bugs.opensuse.org/ # # needssslcertforbuild Name: pesign-obs-integration Version: 10.2 Release: 0 Summary: Macros and scripts to sign the kernel and bootloader License: GPL-2.0-or-later Group: Development/Tools/Other URL: https://en.opensuse.org/openSUSE:UEFI_Image_File_Sign_Tools Source0: %{name}-%{version}.tar.gz BuildRequires: openssl Requires: fipscheck Requires: mozilla-nss-tools Requires: openssl # suse-module-tools <= 15.0.10 contains modsign-verify Requires: suse-module-tools >= 15.0.10 %ifarch %{ix86} x86_64 ia64 aarch64 %{arm} riscv64 Requires: pesign %endif %description This package provides scripts and rpm macros to automate signing of the boot loader, kernel and kernel modules in the openSUSE Buildservice. %prep %autosetup -p1 %build %install mkdir -p %{buildroot}%{_prefix}/lib/rpm/brp-suse.d %{buildroot}%{_prefix}/lib/rpm/pesign install pesign-gen-repackage-spec kernel-sign-file gen-hmac %{buildroot}%{_prefix}/lib/rpm/pesign install brp-99-pesign %{buildroot}%{_prefix}/lib/rpm/brp-suse.d # brp-99-compress-vmlinux has nothing to do with signing. It is packaged in # pesign-obs-integration because this package is already used by the kernel # build install brp-99-compress-vmlinux %{buildroot}%{_prefix}/lib/rpm/brp-suse.d install -m644 pesign-repackage.spec.in %{buildroot}%{_prefix}/lib/rpm/pesign mkdir -p %{buildroot}%{_bindir} install modsign-repackage %{buildroot}%{_bindir}/ install -pm 755 modsign-verify %{buildroot}%{_bindir}/ if test -e _projectcert.crt; then openssl x509 -inform PEM -in _projectcert.crt \ -outform DER -out %{buildroot}%{_prefix}/lib/rpm/pesign/pesign-cert.x509 else echo "No buildservice project certificate available" fi %files %license COPYING %doc README %{_bindir}/modsign-repackage %{_bindir}/modsign-verify %{_prefix}/lib/rpm/* %changelog 0707010000001B000081A4000000000000000000000001669F469C00001E52000000000000000000000000000000000000004900000000pesign-obs-integration-10.2+git20240723.d344d91/pesign-repackage.spec.in#!/bin/bash # This specfile unpacks the original RPMs, runs pesign-gen-repackage-spec # to create a second repackage specfile, and runs another rpmbuild to # actually do the repackaging. # # Copyright (c) 2013 SUSE Linux Products GmbH, Nuernberg, Germany. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA # Do not generate any debug packages from the repackage specfile %undefine _build_create_debug Name: pesign-repackage Version: 1.0 Release: 1 BuildRequires: openssl mozilla-nss-tools %ifarch %ix86 x86_64 ia64 BuildRequires: pesign %endif License: GPL-2.0-or-later Group: Development/Tools/Other Summary: Rebuild RPMs with signatures URL: https://github.com/opensuse/pesign-obs-integration BuildRoot: %{_tmppath}/%{name}-%{version}-build %description Spec file to rebuild RPMs with signatures %prep %setup -c -T %build %install # avoid loops export BRP_PESIGN_FILES="" pushd %buildroot disturl= rpms=() for rpm in %_sourcedir/*.rpm; do case "$rpm" in *.src.rpm | *.nosrc.rpm) cp "$rpm" %_srcrpmdir/ continue ;; # Do not repackage debuginfo packages (bnc#806637) *-debuginfo-*.rpm | *-debugsource-*.rpm) mkdir -p "%_topdir/OTHER" cp "$rpm" "$_" continue ;; esac # do not repackage baselibs packages # FIXME: needs more generic test (if architecture has different # bitness => skip) case "$(rpm -qp --qf '%%{name}/%%{arch}' "$rpm")" in *-32bit/x86_64 | *-32bit/s390x | *-32bit/ppc64 | \ *-64bit/ppc | *-x86/ia64 | *-64bit/aarch64_ilp32) mkdir -p "%_topdir/OTHER" cp "$rpm" "$_" continue esac rpm2cpio "$rpm" | cpio -idm d=$(rpm -qp --qf '%%{disturl}' "$rpm") if test -z "$disturl"; then disturl=$d fi if test "$disturl" != "$d"; then echo "Error: packages have different disturl: $d vs $disturl" exit 1 fi rpms=("${rpms[@]}" "$rpm") done popd # Copy files other than the meta files and RPMs to %%_topdir/OTHER OTHER_FILES=`find %_sourcedir/ -maxdepth 1 -type f \ -not -regex '.*\.\(rpm\|spec\|changes\|rsasign\|sig\|crt\)' \ -not -regex '.*\rpmlintrc' \ -not -name "_buildenv" \ -not -name "_statistics" \ -not -name "logfile" \ -not -name "meta" \ -not -name "pesign-spec-macros" \ -not -name "source_files.cpio" \ -print` for file in $OTHER_FILES; do if test -e "$file"; then mkdir -p "%_topdir/OTHER" cp "$file" "$_" fi done if test -e %_sourcedir/source_files.cpio; then pushd %_sourcedir cpio -i < source_files.cpio popd fi mkdir rsasigned pushd rsasigned cpio -idm <%_sourcedir/@NAME@.cpio.rsasign.sig cat >cert.crt <<EOF @CERT@ EOF if test "$(wc -l <cert.crt)" -le 1 -a -s %_sourcedir/_projectcert.crt ; then cp %_sourcedir/_projectcert.crt cert.crt fi if test "$(wc -l <cert.crt)" -gt 1; then openssl x509 -inform PEM -in cert.crt -outform DER -out cert.x509 cert=cert.x509 else echo "warning: No buildservice project certificate found, add" echo "warning: # needssslcertforbuild to the specfile" echo "warning: Using /usr/lib/rpm/pesign/pesign-cert.x509 as fallback" cert=/usr/lib/rpm/pesign/pesign-cert.x509 fi mkdir nss-db nss_db=$PWD/nss-db echo foofoofoo > "$nss_db/passwd" certutil -N -d "$nss_db" -f "$nss_db/passwd" certutil -A -d "$nss_db" -f "$nss_db/passwd" -n cert -t CT,CT,CT -i "$cert" # Extract the public key of the certificate openssl x509 -in "$cert" -inform DER -pubkey -noout > "$cert.pub" sigs=($(find -type f -name '*.sig' -printf '%%P\n')) for sig in "${sigs[@]}"; do # Verify the signature with the public key of the certificate ver_err=$(openssl rsautl -verify -inkey "$cert.pub" -pubin -in "$sig" 2>&1 | grep -i error) || true if [ -n "$ver_err" ]; then echo "$sig signature can not be decrypted by $cert" >&2 exit 1 fi f=%buildroot/${sig%.sig} case "/$sig" in *.ko.sig|*.mod.sig) /usr/lib/rpm/pesign/kernel-sign-file -i pkcs7 -s "$sig" sha256 "$cert" "$f" ;; *.auth.sig) /usr/lib/rpm/pesign/kernel-sign-file -N -P -d -C "$cert" -i pkcs7 -s "$sig" sha256 "$cert" "$f" fbase="${f##*/}" fbase="${fbase%.auth}" fbase="${fbase%%-*}" perl -0777 -npe 's/\A(?:[\040-\176]\0)+.{18}\0\0.{14}\0\0//s' < "$f" > "$f.orig" sign-efi-sig-list -i "$f.p7sd" "$fbase" "$f.orig" "$f.tmp" mv "$f.tmp" "$f" rm -f "$f.p7s" "$f.p7sd" "$f.orig" ;; /boot/* | *.efi.sig | */lib/modules/*/vmlinu[xz].sig | */lib/modules/*/[Ii]mage.sig | */lib/modules/*/z[Ii]mage.sig) %ifarch %ix86 x86_64 aarch64 %arm riscv64 # PE style signature injection infile=${sig%.sig} cpio -i --to-stdout ${infile#./} <%_sourcedir/@NAME@.cpio.rsasign > ${infile}.sattrs test -s ${infile}.sattrs || exit 1 ohash=$(pesign -n "$nss_db" -h -P -i "$f") pesign -n "$nss_db" -c cert -i "$f" -o "$f.tmp" -d sha256 -I "${infile}.sattrs" -R "$sig" rm -f "${infile}.sattrs" mv "$f.tmp" "$f" nhash=$(pesign -n "$nss_db" -h -P -i "$f") if test "$ohash" != "$nhash" ; then echo "hash mismatch error: $ohash $nhash" exit 1 fi %else # appending to the file itself, e.g. for s390x. /usr/lib/rpm/pesign/kernel-sign-file -i pkcs7 -s "$sig" sha256 "$cert" "$f" %endif # Regenerate the HMAC if it exists hmac="${f%%/*}/.${f##*/}.hmac" if test -e "$hmac"; then /usr/lib/rpm/pesign/gen-hmac -r %buildroot "/${sig%.sig}" fi ;; *stage3.bin.sig) /usr/lib/rpm/pesign/kernel-sign-file -i pkcs7 -s "$sig" sha256 "$cert" "$f" ;; *grub.elf.sig) sig_size="$(wc -c < "$sig")" unsigned_grub_size="$(wc -c < "$f")" /usr/lib/rpm/pesign/kernel-sign-file -vpd -i pkcs7 -s "$sig" sha256 "$cert" "$f" sig_size="$(wc -c < "$f.p7s")" footer_size=40 # 12 bytes signature info structure, 28 bytes signature magic string grub_size="$(wc -c < "$f")" if ! [ $(expr "$sig_size" + "$footer_size") -le "@PESIGN_GRUB_RESERVATION@" ] ; then echo "size of '$f.p7s' ($sig_size) cannot fit into reservation @PESIGN_GRUB_RESERVATION@ (-$footer_size)" exit 1 fi sig_size="$(expr "@PESIGN_GRUB_RESERVATION@" - "$footer_size")" truncate -s $sig_size "$f.p7s" /usr/lib/rpm/pesign/kernel-sign-file -v -i pkcs7 -s "$f.p7s" sha256 "" "$f" rm "$f.p7s" grub_size="$(wc -c < "$f")" if ! [ "$(expr "$unsigned_grub_size" + "@PESIGN_GRUB_RESERVATION@")" -eq "$grub_size" ] ; then echo "The size of unsigned grub ($unsigned_grub_size) + reservation (@PESIGN_GRUB_RESERVATION@) does not add up to signed grub size ($grub_size)" exit 1 fi ;; *) echo "Warning: unhandled signature: $sig" >&2 esac done # Remove the public key file rm "$cert.pub" popd /usr/lib/rpm/pesign/pesign-gen-repackage-spec @PESIGN_REPACKAGE_COMPRESS@ @PESIGN_LOAD_SPEC_MACROS@ \ --directory=%buildroot "${rpms[@]}" rpmbuild --define "%%buildroot %buildroot" --define "%%disturl $disturl" \ --define "%%_builddir $PWD" \ --define "%%_binaries_in_noarch_packages_terminate_build 0" \ --define "%_suse_insert_debug_package %%{nil}" -bb repackage.spec # This is needed by the kernel packages. Ideally, we should not run _any_ brp # checks, because the RPMs passed them once already export NO_BRP_STALE_LINK_ERROR=yes # Make sure that our rpmbuild does not complain about unpackaged files rm -rf %buildroot mkdir %buildroot %changelog 0707010000001C000081A4000000000000000000000001669F469C0000010B000000000000000000000000000000000000003B00000000pesign-obs-integration-10.2+git20240723.d344d91/signobs.pm#!/usr/bin/perl # SPDX-License-Identifier: GPL-2.0+ # Copyright: 2018 Luca Boccassi <bluca@debian.org> use warnings; use strict; use Debian::Debhelper::Dh_Lib; insert_before('dh_auto_install', 'dh_signobs_unpack'); insert_after('dh_install', 'dh_signobs_pack'); 1 07070100000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000B00000000TRAILER!!!274 blocks
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor