Commit Graph

48 Commits

Author SHA1 Message Date
Panu Matilainen 5517d26061 Rename addMacro() and delMacro() to rpmPushMacro() and rpmPopMacro()
These are not deprecated at all no matter what the header has been
saying for the past 15+ years, they're used by rpm itself all over
the place as rpmDefineMacro() serves a slightly different purpose
and there's no rpmUndefineMacro() anyway.

Lets make 'em into proper citizens and move them into rpm namespace,
and while at it, call the operations push and pop since that's much
closer to what actually happens.

Finally, add simple wrapper macros to keep external code compilable
while getting the non-namespaced stuff out of ABI.
2016-10-24 13:09:38 +03:00
Panu Matilainen 58711eb636 Eliminate last uses of rpmNewSignature() and rpmFreeSignature()
These are nothing but wrappers for headerNew() and headerFree(),
lets call things by their own names shall we?
2016-10-24 11:34:50 +03:00
Panu Matilainen 0cc5ee83f1 Bury the last remains of non-header signatures into lead
Header signatures were the new hot almost exactly twenty years ago, we
haven't supported anything else in a very, very, very, very very long time.
Drop the useless argument to rpmReadSignature() and bury the last remaining
related constant into rpmlead.c which is the only place that "needs" it.
No functional changes.
2016-10-24 08:41:32 +03:00
Thierry Vignaud 1aeddbc271 fix segfault when calling with args==NULL
the doc explicitely describe "args" as "signing parameters (or NULL for
defaults)"

This no more true since commit 6e9eab345a
As such, with rpm-4.13, some callers will segfault (eg: perl-RPM4's
testsuite)
2016-05-26 10:51:36 +02:00
Lubos Kardos 258e306568 Fix signing with non-ASCII uid keys (rhbz:1243963)
Removed setting LC_ALL to "C" because since commit [1] the gpg program
gets password by yourself from terminal so there is no sense in
setting LC_ALL to "C" if the terminal settings is e. g. UTF-8. That was
only confusing gpg program and it was not able to properly get and
display non-ASCII characters.

[1] 0bce5fcf27
2016-05-23 10:19:39 +02:00
Florian Festi eae65aad6f Drop const to fix compiler warning 2016-04-27 11:19:23 +02:00
Stefan Berger e065ea3b21 Fix various memory leaks in file signature related functions.
Fix various memory leaks in file signature related functions.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2016-04-26 15:22:23 +02:00
Stefan Berger 5cc41e45fb Fix indentation and formatting
Fix the indentation and formatting in signature related files.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2016-04-26 15:22:23 +02:00
Neal Gompa (ニール・ゴンパ) c67aeced99 Properly support BeeCrypt option in build system 2016-02-24 17:45:55 +01:00
Thierry Vignaud c080226a60 add short summaries to headers that miss one 2016-01-28 14:42:47 +01:00
Fionnuala Gunter 3e73013340 Fix file signatures issue with sig header size changes
When file signatures are added to a package the signature digests are
replaced. Sometimes the resulting signature header has a different size.
To solve this, gpg reserved space is omitted. This forces the rpm to be
rewritten when file signatures are added.

Changelog:
-no longer effects delsign
2015-09-01 10:48:54 +02:00
Florian Festi a2826033be Fix doc strings and though doxygen warnings 2015-09-01 10:48:08 +02:00
Mimi Zohar edd709e453 Add support for passing the file signing key password
The option to provide a password for signing an RPM package was
recently removed in favor of using the underlying mechanisms.

Requiring a user to enter a password for each file being signed,
however, is tedious. This patch adds support for prompting the
user for the password.

Dependency on ima-evm-utils version > "0.9"

Changelog:
- update get_fskpass() based on Dmitry's comments

Signed-off-by: Lubos Kardos <lkardos@redhat.com>
2015-08-12 14:23:31 +02:00
fin@linux.vnet.ibm.com 6e9eab345a Add file signature support to package signing
This patch modifies rpmSign to include file signatures in the header.
Since the header is altered, the package digest and package+archive
digest need to be recalculated and updated in the signature header.
Defer resigning the header digests to replaceSignature().

Changelog:
- removed extraneous semicolon - Mimi
- Update signature header digests only if necessary - Mimi
- deallocate sigp before it's overriden - Fin
- fix dependency on ima - Fin
- replace utd parameter with a local variable - Mimi
- fix sigsize - Fin
- calculate MD5 digest with SHA1 - Fin
- removed unused buffer - Fin

Signed-off-by: Lubos Kardos <lkardos@redhat.com>
2015-08-12 14:23:31 +02:00
fin@linux.vnet.ibm.com dd19c19572 Add file signature support to rpmsign command
This patch extends the rpmsign tool to sign package files. It defines a new
rpmsign option called "signfiles".

rpm --addsign [--signfiles] PACKAGE

Signfiles signs all the file digests included in the package and stores
the signatures in the package header. The file signing key, used to sign
the file digests, can be provided one the command line with --fskpath or
in a macro file with %_file_signing_key. After including file signatures,
the package is signed normally.

The package needs to be built with SHA-1 or SHA-2 digests before package
files are signed, this prerequisite is noted in rpmsign man page.

Changelog:
- throw argerror when --fskpath is used without --signfiles

Signed-off-by: Lubos Kardos <lkardos@redhat.com>
2015-08-12 14:23:31 +02:00
fin@linux.vnet.ibm.com 146fcc32c2 Subroutine for dumping immutable region of header
This patch creates a subroutine for dumping the immutable region of
a header.  It copies the header sections into a new header that can
be altered.

Changelog:
- deallocate old hdrp

Signed-off-by: Lubos Kardos <lkardos@redhat.com>
2015-08-12 13:57:46 +02:00
fin@linux.vnet.ibm.com e4664bf8bd Refactor copyFile to not close files
This patch refactors copyFile so that it doesn't close sfdp and tfdp,
since copyFile didn't open those files. Also, the caller to copyFile
closes these files. This patch also adds descriptions of copyFile
parameters.

Changelog:
- removed call to manageFile() since copyFile() arguments are open files

Signed-off-by: Lubos Kardos <lkardos@redhat.com>
2015-08-12 12:59:23 +02:00
Lubos Kardos 0bce5fcf27 Allow gpg to get passphrase by itself.
Remove rpm asking for passphrase and then passing this passphrase
to gpg via file descriptor (--passphrase-fd) but provide gpg with
access to unredirected stdin to get passphrase directly from user.

Remove also macro %__gpg_check_password_cmd because in this new signing
scheme has no sense. rpm doesn't handle passphrase in any way,
everything is done in gpg including checking of passphrase.

We did this modification because of changes in gpg behavior. Since
gpg-2.1 option "--passphrase-fd" doesn't work by default, only when
it is explicitly allowed in gpg.conf. (rhbz:#1228234)
2015-06-10 14:39:28 +02:00
Lubos Kardos 6a8924b4c9 Use named pipe instead of stdin as input for gpg
This enables running gpg with access to the shell the rpmsign command
is running in. This is needed to allow gpg to get passphrase by itself.
2015-06-10 14:37:22 +02:00
Panu Matilainen 2273916148 Shut up bogus warning about possible uninitialized use
- The way manageFile() is called, fmode can never be uninitialized
  but lets make gcc happy by adding a default case to the switch...
- Additionally make fmode const because it is
2014-06-30 11:20:19 +03:00
Panu Matilainen 3f2f483515 Use unified libtool version for all our libraries
- Our libraries are in reality so interdependent that its not even
  possible to use them independently of others, so having them
  all follow sort of independent versioning information just doesn't
  make any sense and is a PITA everytime I need to touch the data.
- This causes librpmsign soname bump with no good reason so its
  probably "evil" and all ... so sue me, its not as if anybody
  is actually using this library outside rpm itself.
2014-06-25 13:21:00 +03:00
Lubos Kardos 8090b1466d Error message with wrong filename was showed in case of error.
This was caused by commit 90833a57c5.

Signed-off-by: Panu Matilainen <pmatilai@redhat.com>
2014-05-27 12:08:16 +03:00
Lubos Kardos 1a8a5bade3 rpmSign() always returned -1 if signatures was inserted into original rpm
- This was caused by commit 90833a57c5 but
  because of another problem fixed in previous commit it didn't exhibit.

Signed-off-by: Panu Matilainen <pmatilai@redhat.com>
2014-05-27 12:08:15 +03:00
Lubos Kardos e1fd794253 rpmSign() returned value 0 (success) in case of failure
- Fixes regression from commit c0aad81e9b.
- That commit added line "res = replaceSignature(...)" that sets variable
  "res" to value 0. But error handling code following this line expects
  this variable set to -1. So in case of error value 0 (success) was
  returned but value -1 (failure) should have been returned.

Signed-off-by: Panu Matilainen <pmatilai@redhat.com>
2014-05-27 12:08:15 +03:00
Lubos Kardos 90833a57c5 Reserve space for gpg signature during building of package.
- During building of a package a dummy tag is added to the signature
header. This tag reserves some space for gpg signatures. So during
signing of the package the gpg signatures can be put in this reserved
space and it is not necessary to rewrite the whole package to make some
space for gpg signatures.

Signed-off-by: Panu Matilainen <pmatilai@redhat.com>
2014-05-21 13:02:44 +03:00
Lubos Kardos 75f7b0dcfa Function manageFile was modified to support also "r+.ufdio" mode.
Signed-off-by: Panu Matilainen <pmatilai@redhat.com>
2014-05-21 13:02:17 +03:00
Lubos Kardos 1aace27fb9 Passing data to sign to the gpg program by a pipe.
- This change shorten signing time beacause it is not necessary to
write data that should be signed, into a temporary file and then pass
this file to gpg program.

Signed-off-by: Panu Matilainen <pmatilai@redhat.com>
2014-05-21 10:47:41 +03:00
Lubos Kardos 1019fa396d There is no need to recalculate digests during signing.
Digests are not signatures even if they reside in "signature" header,
and signing a package must not affect the digests. So recalculating
digests on signing is not just wasteful, but also conceptually plain
wrong.

Signed-off-by: Panu Matilainen <pmatilai@redhat.com>
2014-05-21 10:46:08 +03:00
Lubos Kardos 175521cc54 Removed historical leftover.
Signed-off-by: Panu Matilainen <pmatilai@redhat.com>
2014-05-21 10:40:34 +03:00
Panu Matilainen ca7373f566 Plug ages old memleak on package signing 2014-05-19 16:44:36 +03:00
Panu Matilainen 3e9d8b6d36 Eliminate bogus switch-cases from rpmReadSignature() returns
- rpmReadSignature() returns failure on NULL header anyway, so the
  "No signature available" message is not only misleading but also
  can never happen.
2014-02-01 14:51:09 +02:00
Panu Matilainen 2077b3dc54 Update library current + age (ie libs are now 3.1.0)
- We haven't removed or changed any interfaces in a way that would
  require full soname bump, only a handful of new interfaces have
  been added.
- There aren't actually any new interfaces in librpmbuild or librpmsign
  but for sanity and consistency's sake they're all updated...
2012-11-05 10:22:50 +02:00
Panu Matilainen ac5e6cd521 Bump library sonames in preparation for new release
- This is stupid... only librpm and librpmio actually need the bump due
  to ABI breakage, librpmbuild and librpmsign are unchanged and could
  use just a revision bump. But just incrementing the revision (or age)
  would set us on collision course with maintenance updates to 4.9.x.
  Then again its not like you can actually use librpmbuild or librpmsign
  without also linking to librpm(io) so from everything needs rebuilding
  anyway. This all also pretty much makes the whole libtool library
  versioning a bit moot. Bah.
2012-03-20 09:56:30 +02:00
Panu Matilainen 6bced5bc08 Eliminate uses of pgpDig in package signing routines
- No functional changes, just eliminates pile of unnecessary allocations
  and other calls, simplifying the code a bit.
2011-11-09 13:57:34 +02:00
Panu Matilainen cde47f5945 Use pgpDigParamsAlgo() throughout the codebase
- Tedious but straightforward conversion to use the API instead
  of going to the struct directly.
- Remove digest.h includes where no longer necessary
2011-11-07 14:47:03 +02:00
Panu Matilainen 45c880304b Add an API for comparing two digest parameter containers
- Lift the digest parameter comparison from librpmsign to rpmpgp.c
  where it really belongs.
2011-11-07 13:29:29 +02:00
Panu Matilainen 598d059fc9 Eliminate direct pgpDig accesses from signing code 2011-11-07 12:56:03 +02:00
Panu Matilainen b8ad9ac920 Log an error on signing if we can't even parse the gpg-generated signature
- The error message is not very helpful but if pgpPrtPkts() fails
  we dont have a whole lot clue in the caller why it failed, spitting
  out at least *some* error is better than silently failing
  (RhBug:748116, RhBug:719154)
2011-10-23 14:26:42 +03:00
Panu Matilainen 78c95448a1 Further streamline & sanitize lead handling
- Never log anything from rpmLeadRead(), instead return an error message
  the callers can log if they see fit
- Add a return value for the lead type (which is the only bit of
  info from the lead we sometimes resort to using)
- Permit NULL pointers on all return values
- Eliminate rpmLeadCheck() and rpmLeadType() from the internal API,
  these are now combined into rpmLeadRead().
- Fix up the callers: only (re)signing needs the actual lead,
  signature verification only cares if its valid or not and
  package reading only wants the type from the lead (annoying but...)
2011-07-07 11:55:28 +03:00
Panu Matilainen da53e0d66e Make rpmLeadRead() return an allocated lead, fixup callers
- Requiring callers to allocate a lead "buffer" for reading into
  is just DUMB (greetings to self back in 2008, sigh). This avoids
  having to deal with freeing the lead in case the read failed, and
  allows getting rid of rpmLeadNew() completely.
2011-07-06 12:42:56 +03:00
Panu Matilainen 2a9a150290 Eliminate dead NULL-assignments at scope-end in librpmsign 2011-05-29 11:52:17 +03:00
Panu Matilainen d885361c84 Issue an error on failure to replace original package on signing
- Previously any failure on replacing the original package with the
  newly signed one would silently fail, causing rather confusing
  behavior when eg attempting to (re)sign readable but not writable
  packages.
2011-05-25 10:20:45 +03:00
Panu Matilainen eada0e3e47 Handle errors from moving target file into place in rpmSign()
- Signing isn't successful unless we manage to replace the original
  file with the signed one, take the stat() etc returns into count.
2011-04-21 11:09:28 +03:00
Panu Matilainen e393393ff7 headerPut() and headerDel() returns aren't interesting here 2011-04-21 10:55:00 +03:00
Panu Matilainen c798aed743 Remove redundant indentation block from rpmSign()
- No code changes, just formatting sanity/prettiness
2011-04-21 10:48:42 +03:00
Panu Matilainen 96e160d408 Mark the identical signature warning as translatable 2011-01-31 13:01:26 +02:00
Panu Matilainen bf1b4dede6 Eek.. librpmsign sources went missing in the move
- Re-adding the files that should've gotten moved (not removed) in
  commit 9f2c1bd909
- Mild wtf ... probably user (not git) error though. Too bad the
  broken state got pushed already :-/
2010-10-22 18:31:01 +03:00
Panu Matilainen 9f2c1bd909 Move librpmsign to its own subdirectory in the sources 2010-10-22 15:00:49 +03:00