Commit Graph

263 Commits

Author SHA1 Message Date
Panu Matilainen c25894e3b9 Honor RPMTRANS_FLAG_TEST in rpmtsImportPubkey() 2012-02-03 12:23:31 +02:00
Panu Matilainen 120fd698c3 Remove the arbitrary limitation on transaction keyring change
- There are some situations where switching keyrings might be wanted,
  especially as long as we dont export a way to pass keyring as
  an argument to package reading/verification functions. Since thereäs
  no technical reason to disallow it, might as well allow it...
2012-02-02 19:13:03 +02:00
Panu Matilainen 290fcbbe6b Never load ts keyring if signature checking is disabled
- Loading the pubkeys from database numerous often unwanted side-effects,
  if signature checking is disabled then there's no point loading
  the keys either.
- Commit cad147070e did this for
  rpmReadPackageFile() specifically but we really want it honored
  for all operations including headerCheck() and friends, handle
  it centrally in loadKeys() for simplicity.
2012-02-02 14:18:50 +02:00
Ales Kozumplik 7a530738ca remove the 'path' parameter of rpmtsSELabelInit()
- It is always selinux_file_context_path() anyway.
2012-01-12 14:27:36 +01:00
Ales Kozumplik 7a8b75d266 selinux: reopen label between transactions if necessary (RhBug: 746073) 2012-01-12 14:27:36 +01:00
Panu Matilainen eae6715564 Update internal callers to use headerExport(), no functional changes 2011-11-30 11:03:54 +02:00
Panu Matilainen 3a75a9f6c4 Make gpg-pubkey headers properly verifiable
- The pubkey headers have been rpm v3 all the way until now, whoops :)
  Pull the actual key part of the header into immutable region and
  stomp a sha1 digest on the result, allowing a (much) better
  verification on loading. This part inspired by stumbling on a
  related discussion on rpm5.org mailing list so credits where...
- Since we only insert either literally constant data or data retrieved
  from the actual key into the immutable part of the header, the
  calculated digest is constant for a given key regardless of where
  and when it was imported. This gives some added verification and/or
  cross-checking possibilities (eg was the imported key exactly the
  same as what shipped etc)
2011-11-24 11:58:44 +02:00
Panu Matilainen 66d6987120 Sanitize makePubkeyHeader() calling semantics
- Create the header in makePubkeyHeader() as the name suggests,
  return the newly created header to caller on success.
- Move the installtime & -tid addition to the "install" part,
  makePubkeyHeader() only does the part that is specific to pubkey
  headers, again as the name suggests.
- No functional changes
2011-11-24 11:28:15 +02:00
Panu Matilainen 4c6397507b Make gpg-pubkey buildtime reflect the public key create time
- Pubkey buildtime has until now been the time of import, which equals
  install time/tid. Which is of course the time when that header
  does get created, but it seems rather redundant to have the same
  thing recorded in three places. Having the key creation time
  easily (easier than un-hexifying the version string, duh)
  available seems like a potentially useful thing. Buildtime is
  "wrong" for this, but ... so is everything.
- With this change, the "meat" of the pubkey headers is now constant
  and repeatable regardless of where and when a key gets imported,
  so we could stomp a digest on it and it'd be unique for that
  particular key everywhere.
2011-11-24 11:25:53 +02:00
Panu Matilainen 6b871c5337 Add key userid into gpg-pubkey headers as "packager"
- The userid has only been available in a mildly obfuscated format
  through summary, but this seems like a useful thing to have in
  a directly usable format without requiring callers to parse out
  the gpg() wrapping around it.
- Yes its a wonky mapping, but so is everything else wrt
  gpg-pubkeys, and adding a tag just for this also seems silly.
  Using vendor tag could be another possibility, dunno.
2011-11-24 11:21:41 +02:00
Panu Matilainen 1e0e3e01d2 Doh, somehow managed to miss the warnings from these missing includes :(
- Should've been in commit 70f063cb77
2011-11-10 08:46:59 +02:00
Panu Matilainen 70f063cb77 Make base64 encoding/decoding part of rpmio public API
- Base64 is present in headers and all, it's only reasonable that
  our API users have access to this functionality without having
  to link to other libraries. Even if we didn't want to carry the
  implementation forever in our codebase, we should provide a wrapping
  for this (much like the other crypto stuff) for the reason stated above.
- A bigger issue is that our dirty little (badly hidden) secret was using
  non-namespaced function names, clashing with at least beecrypt. And we
  couldn't have made these internal-only symbols even on platforms that
  support it, because they are used all over the place outside rpmio.
  So... rename the b64 functions to rpmLikeNamingStyle and make 'em public.
  No functional changes, just trivial renaming despite touching numerous
  places.
2011-11-09 15:16:28 +02:00
Panu Matilainen c8fe64dbc6 Eliminate direct pgpDig accesses from pubkey importing 2011-11-07 12:55:27 +02:00
Panu Matilainen 86b5c818e0 Remove reamining dead assignments from rpmtsiFree() in transaction code
- Not all of these are at the end of local scope and in many cases
  the iterator pointer is reused, but the logic in all these is
  straightforward enough (no jumps etc) that there's no much
  chance of mistakenly using already freed iterator.
2011-05-31 12:43:15 +03:00
Panu Matilainen 7c036b9ca3 Eliminate dead NULL-assignments at scope-end in librpm, part V
- Remove NULL-assignments of local variables at the end of scope
  in transaction and database code
2011-05-29 11:49:46 +03:00
Panu Matilainen 9db2544707 Remove unused return code variable
- None of the error exits from rpmdbSetIteratorRE() apply to the
  use in rpmtsInitIterator() so there's no point storing or checking
  its return
2011-03-04 13:38:34 +02:00
Panu Matilainen d10b403011 Make rpmplugins.h private for now
- We'll probably want to make some changes to the plugin type system
  before considered "ready", the current plugin slots are limited
  to 32 and Meego folks apparently want to use a largish number
  of slots. So we might want something like separate plugin type
  (collection, security... etc) and then have 32 slots per each type.
  Making this private for now to avoid having to potentially break
  the API shortly after introduction.
2010-12-22 13:11:40 +02:00
Panu Matilainen 626e78429f A bit of sanity checking in rpmtsRebuildDB()
- Don't permit rebuilddb on populated transaction as rebuild can
  and usually does change header instance numbering.
2010-12-03 15:31:01 +02:00
Panu Matilainen 0715b04664 Change all internal uses of rpmtsInitIterator() to use DBI tags 2010-10-22 11:49:52 +03:00
Panu Matilainen a68f648cf1 Change rpmdb internals and iterator APIs to use the appropriate tag types
- The actual indexes are rpmDbiTags, and the tag passed to
  rpmtsInitIterator() and rpmdbInitIterator() always refers to a
  database index, not arbitrary header tag. The tag passed to
  rpmdbSetIteratorRE() however /does/ refer to a header tag. This rather
  important distinction can actually be expressed in the API.
- As the indexes are generated from header tags of the same value,
  most of these need to use the TagVal types instead of actual enums
  to avoid mismatches - the value is what counts, not it being an enum.
- Several places still have variables misleadingly named "rpmtag" when
  they refer to dbi tags, but leaving them for now to avoid excessive
  changes at once.
2010-10-22 11:15:22 +03:00
Panu Matilainen e3e69b44e5 Return explicit NULL from various fooFree() functions everywhere 2010-09-21 14:26:29 +03:00
Panu Matilainen 147f41bcc1 Differentiate between the possible te types and iterator selector values
- Transaction elements can only be of one type (hence the enum),
  but the transaction set iteration permits selecting more than
  one. Add a new typedef dummy for this purpose only.
2010-09-21 12:15:44 +03:00
Panu Matilainen 92c12d1a8e Eliminate all fooUnlink() functions out of the API
- These are internal helpers only, all refcount users need to use
  fooFree() or similar for correct operation. Add fwd declarations
  where necessary to avoid moving code around unnecessarily.
- We could add these back later as aliases to fooFree() but for now,
  just get them out of the way.
2010-09-13 13:08:33 +03:00
Panu Matilainen 511beb3757 Fix some broken fooUnlink() usages
- unreferencing should always go through fooFree() which does
  the real refcounting and frees when references go out
2010-09-13 13:05:55 +03:00
Panu Matilainen 9ee219093a Return NULL from rpmtsProblems() if no problems exist
- Avoids callers having to separately test for number of problems
  and freeing when no problems exist
2010-09-02 14:12:42 +03:00
Panu Matilainen cf802b677e ...and finally eliminate the spec crapola from transaction set for good 2010-09-01 17:20:48 +03:00
Steve Lawrence 34b5d67c2d Use selabel interfaces instead of matchpathcon
This replaces the old matchpathcon interfaces with the new selabel
interfaces for relabeling files, storing an selabel handle in the
transaction set.

With this change, also comes an added distinction between --nocontexts
being specified and a failure to read the load file contexts.
Previously, there was no distinction, and both cases used the
RPMTRANS_FLAG_NOCONTEXTS flag.

However, with the new policy plugin, it is necessary to make such a
distinction. This is because matchpathcon_init (now selabel interfaces)
can fail at the beginning of the transaction, but succeed later after
new policy is installed. Because of this, we may need to enable/disable
RPMTRANS_FLAG_NOCONTEXTS multiple times. However, because this flag
could also mean --nocontexts, we cannot do that. By storing the selabel
handle in the rpmts, we can easily keep track if the handle has been
successfully created, rather than overloading RPMTRANS_FLAG_NOCONTEXTS
with two meanings.
2010-09-01 09:30:51 +03:00
Steve Lawrence 883f13c8b7 Update the plugin architecture to allow for remembering state
This moves most of the plugin logic to a new rpmplugins file with a
struct and functions for managing plugins, allowing for plugins to carry
state. This also adds init and cleanup hooks for plugins to initialize
and cleanup their state, and a new 'open te' hook allowing plugins to
read and save information from transaction elements.

This also generalizes the plugin architecture a bit so it isn't so
specific to collections.
2010-09-01 09:04:05 +03:00
Panu Matilainen d3bebf2656 Lose the now unnecessary rpmtsSELinuxEnabled() function
- it never was anything more than a cached value of is_selinux_enabled()
  and caching this fairly expensive result is no longer needed as
  scriptlet execution wrt selinux contexts is now conditionalized on
  RPMTRANS_FLAG_NOCONTEXTS instead
2010-08-13 17:24:12 +03:00
Panu Matilainen 4ee9296757 numAddedPackages is unused since rpm 4.8.0, eliminate 2010-06-22 12:22:04 +03:00
Panu Matilainen ddec80b614 Don't return errors on trying to import duplicate keys
- On the principle of "no news is good news", if we already have the
  keys to be imported, then everything is ok. The former behavior is
  just confusing as witnessed in RhBug:462979
2010-06-01 10:41:09 +03:00
Panu Matilainen f2bfa2edfc Use the new chroot API everywhere, eliminate old related goo 2010-05-31 14:11:12 +03:00
Panu Matilainen be1c4872c1 Dont crash on NULL ts to rpmtsInitIterator() 2010-05-28 10:27:01 +03:00
Panu Matilainen 6fc3cbefee Fix breakage from removedPackages changing to hash
- tsmem->delta is still needed for tsmem->order reallocation,
  zero delta causes funny effects on larger package sets (test suite
  doesnt trigger this)
2010-05-07 20:22:53 +03:00
Florian Festi 70e9b035ff Convert tsmem->removedPackages to a hash table and remove rpmdbPruneIterator from the API 2010-05-06 16:07:56 +02:00
Panu Matilainen a9cb04fe1c Unexport rpmteNew() and rpmteFree()
- the only meaningful way to create transaction elements is by adding things
  to a transaction through rpmtsAddFooElement(), there's no need to
  expose these and restrict our ability to change the API when needed
2010-05-06 14:09:41 +03:00
Panu Matilainen f2c4eebae0 Doh, dont shadow the rpmtsVerifyDB() return value 2010-04-29 15:51:41 +03:00
Panu Matilainen efe0ebcbc1 Protect rpmtsVerifyDB() with transaction lock
- BDB docs state that db->verify() doesn't perform any locking even
  when used within an environment, and should only be used on files
  that are not being modified by another thread of control. Grabbing
  the transaction lock while verifying mostly ensures nobodys writing
  to the db behind our back.
2010-04-22 13:48:58 +03:00
Panu Matilainen e7b0d96900 Make transaction lock path per-transaction
- Although it doesn't really happen in practise, rpm's API permits several
  transactions with possibly differing roots within process lifetime.
  Previously the lock path was calculated just once globally so we could
  easily be locking in a completely wrong place (eg locking in a previously
  accessed chroot when system rpmdb should be transaction-locked)
2010-04-22 12:23:24 +03:00
Panu Matilainen 1f625e69e9 Further generalize the rpmlock interface
- Move transaction lock path handling into rpmts.c, export new low
  level rpmlockAcquire() function to actually grab a lock
- Rename rpmtsFreeLock() to rpmlockFree() and return NULL in the
  general rpm style
2010-04-22 11:01:27 +03:00
Panu Matilainen 35c563af8c Make rpmlock type visible inside rpm, use instead of void* 2010-04-22 10:37:51 +03:00
Panu Matilainen 037538f00f Eliminate the headerCheck() foo from rpmdbAdd/Remove()
- for rpmdbRemove() these have been completely unused, and for rpmdbAdd()
  the higher levels have had more than one chance of verifying the
  header if checking is enabled in the transaction set
2010-04-07 12:12:51 +03:00
Panu Matilainen f40ea7e359 Move header INSTALLTID manipulation out of rpmdbAdd() 2010-04-07 08:35:14 +03:00
Panu Matilainen 997954f793 Use rpmpsMerge() for collecting element problems in rpmtsProblems() 2010-03-26 09:21:06 +02:00
Panu Matilainen d71964bda5 Lose the useless rpmio refcounting debug junk
- the rpmio API always had this goo, should've gotten rid of it
  back in commit dbdbe8010c but .. oh well
2010-03-22 13:25:57 +02:00
Panu Matilainen e307f8df46 Lose the useless rpmts refcounting debug messages + debug switches
- get the debug messages out of API, this is what should've been in commit
  dbdbe8010c - just wtf have I been thinking?
- also tolerate NULL passed to rpmtsLink() and rpmtsUnlink()
2010-03-22 12:40:27 +02:00
Panu Matilainen e4f77b4010 Lose deprecated rpmtsFindPubkey()
- unused in rpm since 4.6.0, and even before that this wasn't really useful
  outside rpm internals
2010-03-18 12:37:35 +02:00
Panu Matilainen 9722257b24 Default to "not found" for rpmtsSolve() + comment behavior
- this fixes the behavior when (as normally is the case) there is no
  depsolve callback set
2010-03-14 11:31:45 +02:00
Panu Matilainen 1f46534b54 Add internal API for depsolve callback
- rpmts struct is now fully opaque within depends.c
2010-03-12 20:40:05 +02:00
Panu Matilainen e696b409fe Record problems into the transaction elements causing them
- Any problem found in transaction processing is caused, or at least
  triggered by, some transaction element. Having the problems in
  elements lets API users easily determine which package caused which
  problem instead of having to parse problem strings in vain.
- No problem set stored in transaction set itself now, rpmtsProblems() API p
  reserved by making it collect problems from our transaction elements
  into a new set. The problem set fiddling in rpmtsRun() wrt %pretrans
  and all is a bit crazy - always was, now its just more visible...
- Make rpmtsCheck() pass the associated transaction elements into
  the lower level functions. rpmdsProblem() removed from API, it's
  not particularly useful outside rpmtsCheck() internals.
- rpmts struct is now opaque within depends.c except for solve callback
- This breaks --badreloc, need to figure out something saner for the
  problem filtering
2010-03-12 19:46:06 +02:00