libzypp  17.25.8
PublicKey.cc
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
12 #include <climits>
13 
14 #include <iostream>
15 #include <vector>
16 
17 #include <zypp/base/Gettext.h>
18 #include <zypp/base/String.h>
19 #include <zypp/base/Regex.h>
20 #include <zypp/PublicKey.h>
21 #include <zypp/ExternalProgram.h>
22 #include <zypp/TmpPath.h>
23 #include <zypp/PathInfo.h>
24 #include <zypp/base/Exception.h>
25 #include <zypp/base/LogTools.h>
26 #include <zypp/Date.h>
27 #include <zypp/KeyManager.h>
28 
29 #include <gpgme.h>
30 
31 using std::endl;
32 
33 #undef ZYPP_BASE_LOGGER_LOGGROUP
34 #define ZYPP_BASE_LOGGER_LOGGROUP "zypp::gpg"
35 
37 namespace zypp
38 {
40  namespace
41  {
42  inline bool isExpired( const Date & expires_r )
43  { return( expires_r && expires_r < Date::now() ); }
44 
45  inline int hasDaysToLive( const Date & expires_r )
46  {
47  if ( expires_r )
48  {
49  Date exp( expires_r - Date::now() );
50  int ret = exp / Date::day;
51  if ( exp < 0 ) ret -= 1;
52  return ret;
53  }
54  return INT_MAX;
55  }
56 
57  inline std::string expiresDetail( const Date & expires_r )
58  {
59  str::Str str;
60  if ( ! expires_r )
61  {
62  // translators: an annotation to a gpg keys expiry date
63  str << _("does not expire");
64  }
65  else if ( isExpired( expires_r ) )
66  {
67  // translators: an annotation to a gpg keys expiry date: "expired: 1999-04-12"
68  str << ( str::Format(_("expired: %1%") ) % expires_r.printDate() );
69  }
70  else
71  {
72  // translators: an annotation to a gpg keys expiry date: "expires: 2111-04-12"
73  str << ( str::Format(_("expires: %1%") ) % expires_r.printDate() );
74  }
75  return str;
76  }
77 
78  inline std::string expiresDetailVerbose( const Date & expires_r )
79  {
80  if ( !expires_r )
81  { // translators: an annotation to a gpg keys expiry date
82  return _("(does not expire)");
83  }
84  std::string ret( expires_r.asString() );
85  int ttl( hasDaysToLive( expires_r ) );
86  if ( ttl <= 90 )
87  {
88  ret += " ";
89  if ( ttl < 0 )
90  { // translators: an annotation to a gpg keys expiry date
91  ret += _("(EXPIRED)");
92  }
93  else if ( ttl == 0 )
94  { // translators: an annotation to a gpg keys expiry date
95  ret += _("(expires within 24h)");
96  }
97  else
98  { // translators: an annotation to a gpg keys expiry date
99  ret += str::form( PL_("(expires in %d day)", "(expires in %d days)", ttl ), ttl );
100  }
101  }
102  return ret;
103  }
104 
105  std::string keyAlgoName( const gpgme_subkey_t & key_r )
106  {
107  std::string ret;
108  if ( const char * n = ::gpgme_pubkey_algo_name( key_r->pubkey_algo ) )
109  ret = str::Str() << n << ' ' << key_r->length;
110  else
111  ret = "?";
112  return ret;
113  }
114  } //namespace
116 
117 
122 
124  {
125  std::string _id;
128 
129  public:
131  static shared_ptr<Impl> nullimpl();
132 
133  private:
134  friend Impl * rwcowClone<Impl>( const Impl * rhs );
136  Impl * clone() const;
137  };
138 
139  shared_ptr<zypp::PublicSubkeyData::Impl> PublicSubkeyData::Impl::nullimpl()
140  {
141  static shared_ptr<Impl> _nullimpl( new Impl );
142  return _nullimpl;
143  }
144 
146  {
147  return new Impl( *this );
148  }
149 
153 
155  : _pimpl( Impl::nullimpl() )
156  {}
157 
158  PublicSubkeyData::PublicSubkeyData(const _gpgme_subkey *rawSubKeyData)
159  : _pimpl (new Impl)
160  {
161  _pimpl->_created = zypp::Date(rawSubKeyData->timestamp);
162  _pimpl->_expires = zypp::Date(rawSubKeyData->expires);
163  _pimpl->_id = str::asString(rawSubKeyData->keyid);
164  }
165 
167  {}
168 
169  PublicSubkeyData::operator bool() const
170  { return !_pimpl->_id.empty(); }
171 
172  std::string PublicSubkeyData::id() const
173  { return _pimpl->_id; }
174 
176  { return _pimpl->_created; }
177 
179  { return _pimpl->_expires; }
180 
182  { return isExpired( _pimpl->_expires ); }
183 
185  { return hasDaysToLive( _pimpl->_expires ); }
186 
187  std::string PublicSubkeyData::asString() const
188  {
189  return str::Str() << id() << " " << created().printDate() << " [" << expiresDetail( expires() ) << "]";
190  }
191 
198  {
199  std::string _id;
200  std::string _name;
201  std::string _fingerprint;
202  std::string _algoName;
205 
206  std::vector<PublicSubkeyData> _subkeys;
207 
208  public:
209  bool hasSubkeyId( const std::string & id_r ) const;
210 
211  public:
213  static shared_ptr<Impl> nullimpl();
214  static shared_ptr<Impl> fromGpgmeKey(gpgme_key_t rawData);
215 
216  private:
217  friend Impl * rwcowClone<Impl>( const Impl * rhs );
219  Impl * clone() const;
220  };
221 
222  bool PublicKeyData::Impl::hasSubkeyId(const std::string &id_r) const
223  {
224  bool ret = false;
225  for ( const PublicSubkeyData & sub : _subkeys )
226  {
227  if ( sub.id() == id_r )
228  {
229  ret = true;
230  break;
231  }
232  }
233  return ret;
234  }
235 
236  shared_ptr<PublicKeyData::Impl> PublicKeyData::Impl::nullimpl()
237  {
238  static shared_ptr<Impl> _nullimpl( new Impl );
239  return _nullimpl;
240  }
241 
242  shared_ptr<PublicKeyData::Impl> PublicKeyData::Impl::fromGpgmeKey(gpgme_key_t rawData)
243  {
244  //gpgpme stores almost nothing in the top level key
245  //the information we look for is stored in the subkey, where subkey[0]
246  //is always the primary key
247  gpgme_subkey_t sKey = rawData->subkeys;
248  if (sKey) {
249  shared_ptr<PublicKeyData::Impl> data(new Impl);
250  //libzypp expects the date of the latest signature on the first uid
251  if ( rawData->uids && rawData->uids->signatures ) {
252  data->_created = zypp::Date(rawData->uids->signatures->timestamp);
253  // bsc#1179222: The keyring does not order the signatures when multiple
254  // versions of the same key are imported. We take the last signature here,
255  // the one GPGME_EXPORT_MODE_MINIMAL will later use in export.
256  for ( auto t = rawData->uids->signatures->next; t; t = t->next ) {
257  if ( t->timestamp > data->_created )
258  data->_created = t->timestamp;
259  }
260  }
261  else
262  data->_created = zypp::Date(sKey->timestamp);
263 
264  data->_expires = zypp::Date(sKey->expires);
265  data->_fingerprint = str::asString(sKey->fpr);
266  data->_algoName = keyAlgoName( sKey );
267  data->_id = str::asString(sKey->keyid);
268 
269  //get the primary user ID
270  if (rawData->uids) {
271  data->_name = str::asString(rawData->uids->uid);
272  }
273 
274  //the rest of the keys
275  sKey = sKey->next;
276  while (sKey) {
277  data->_subkeys.push_back( PublicSubkeyData(sKey) );
278  sKey = sKey->next;
279  }
280  return data;
281  }
282  return nullimpl();
283  }
284 
286  {
287  return new Impl( *this );
288  }
289 
293 
295  : _pimpl( Impl::nullimpl() )
296  {}
297 
298  PublicKeyData::PublicKeyData(shared_ptr<Impl> data)
299  : _pimpl( data )
300  {}
301 
303  {}
304 
306  { return PublicKeyData(Impl::fromGpgmeKey(data)); }
307 
308  PublicKeyData::operator bool() const
309  { return !_pimpl->_fingerprint.empty(); }
310 
311  std::string PublicKeyData::id() const
312  { return _pimpl->_id; }
313 
314  std::string PublicKeyData::name() const
315  { return _pimpl->_name; }
316 
317  std::string PublicKeyData::fingerprint() const
318  { return _pimpl->_fingerprint; }
319 
320  std::string PublicKeyData::algoName() const
321  { return _pimpl->_algoName; }
322 
324  { return _pimpl->_created; }
325 
327  { return _pimpl->_expires; }
328 
330  { return isExpired( _pimpl->_expires ); }
331 
333  { return hasDaysToLive( _pimpl->_expires ); }
334 
335  std::string PublicKeyData::expiresAsString() const
336  { return expiresDetailVerbose( _pimpl->_expires ); }
337 
339  { return _pimpl->_id.empty() ? _pimpl->_id : str::toLower( _pimpl->_id.substr(8,8) ); }
340 
342  { return _pimpl->_created ? str::hexstring( _pimpl->_created ).substr(2) : std::string(); }
343 
344  std::string PublicKeyData::rpmName() const
345  { return str::Format( "gpg-pubkey-%1%-%2%" ) % gpgPubkeyVersion() % gpgPubkeyRelease(); }
346 
347  std::string PublicKeyData::asString() const
348  {
349  str::Str str;
350  str << "[" << _pimpl->_id << "-" << gpgPubkeyRelease();
351  for ( auto && sub : _pimpl->_subkeys )
352  str << ", " << sub.id();
353  return str << "] [" << _pimpl->_name.c_str() << "] [" << expiresDetail( _pimpl->_expires ) << "]";
354  }
355 
357  { return !_pimpl->_subkeys.empty(); }
358 
360  { return makeIterable( &(*_pimpl->_subkeys.begin()), &(*_pimpl->_subkeys.end()) ); }
361 
362  bool PublicKeyData::providesKey( const std::string & id_r ) const
363  {
364  if ( id_r.size() == 8 ) // as a convenience allow to test the 8byte short ID rpm uses as gpg-pubkey version
365  return str::endsWithCI( _pimpl->_id, id_r );
366  return( id_r == _pimpl->_id || _pimpl->hasSubkeyId( id_r ) );
367  }
368 
370  { return AsciiArt( fingerprint(), algoName() ); }
371 
372  std::ostream & dumpOn( std::ostream & str, const PublicKeyData & obj )
373  {
374  str << "[" << obj.name() << "]" << endl;
375  str << " fpr " << obj.fingerprint() << endl;
376  str << " id " << obj.id() << endl;
377  str << " alg " << obj.algoName() << endl;
378  str << " cre " << Date::ValueType(obj.created()) << ' ' << obj.created() << endl;
379  str << " exp " << Date::ValueType(obj.expires()) << ' ' << obj.expiresAsString() << endl;
380  str << " ttl " << obj.daysToLive() << endl;
381  for ( auto && sub : obj._pimpl->_subkeys )
382  str << " sub " << sub << endl;
383  str << " rpm " << obj.gpgPubkeyVersion() << "-" << obj.gpgPubkeyRelease() << endl;
384  return str;
385  }
386 
387  bool operator==( const PublicKeyData & lhs, const PublicKeyData & rhs )
388  { return ( lhs.fingerprint() == rhs.fingerprint() && lhs.created() == rhs.created() ); }
389 
390 
396  {
398  {}
399 
400  Impl( const Pathname & keyFile_r )
401  : _dontUseThisPtrDirectly( new filesystem::TmpFile )
402  {
403  PathInfo info( keyFile_r );
404  MIL << "Taking pubkey from " << keyFile_r << " of size " << info.size() << " and sha1 " << filesystem::checksum(keyFile_r, "sha1") << endl;
405 
406  if ( !info.isExist() )
407  ZYPP_THROW(Exception("Can't read public key from " + keyFile_r.asString() + ", file not found"));
408 
409  if ( filesystem::hardlinkCopy( keyFile_r, path() ) != 0 )
410  ZYPP_THROW(Exception("Can't copy public key data from " + keyFile_r.asString() + " to " + path().asString() ));
411 
412  readFromFile();
413  }
414 
415  Impl( const filesystem::TmpFile & sharedFile_r )
416  : _dontUseThisPtrDirectly( new filesystem::TmpFile( sharedFile_r ) )
417  { readFromFile(); }
418 
419  // private from keyring
420  Impl( const filesystem::TmpFile & sharedFile_r, const PublicKeyData & keyData_r )
421  : _dontUseThisPtrDirectly( new filesystem::TmpFile( sharedFile_r ) )
422  , _keyData( keyData_r )
423  {
424  if ( ! keyData_r )
425  {
426  WAR << "Invalid PublicKeyData supplied: scanning from file" << endl;
427  readFromFile();
428  }
429  }
430 
431  // private from keyring
432  Impl( const PublicKeyData & keyData_r )
433  : _keyData( keyData_r )
434  {}
435 
436  public:
437  const PublicKeyData & keyData() const
438  { return _keyData; }
439 
440  Pathname path() const
441  { return( /*the one and only intended use*/_dontUseThisPtrDirectly ? _dontUseThisPtrDirectly->path() : Pathname() ); }
442 
443  const std::list<PublicKeyData> & hiddenKeys() const
444  { return _hiddenKeys; }
445 
446  protected:
448  {
449  PathInfo info( path() );
450  MIL << "Reading pubkey from " << info.path() << " of size " << info.size() << " and sha1 " << filesystem::checksum(info.path(), "sha1") << endl;
451 
452  std::list<PublicKeyData> keys = KeyManagerCtx::createForOpenPGP().readKeyFromFile( path() );
453  switch ( keys.size() )
454  {
455  case 0:
456  ZYPP_THROW( BadKeyException( "File " + path().asString() + " doesn't contain public key data" , path() ) );
457  break;
458 
459  case 1:
460  // ok.
461  _keyData = keys.back();
462  _hiddenKeys.clear();
463  break;
464 
465  default:
466  WAR << "File " << path().asString() << " contains multiple keys: " << keys << endl;
467  _keyData = keys.back();
468  keys.pop_back();
469  _hiddenKeys.swap( keys );
470  break;
471  }
472 
473  MIL << "Read pubkey from " << info.path() << ": " << _keyData << endl;
474  }
475 
476  private:
477  shared_ptr<filesystem::TmpFile> _dontUseThisPtrDirectly; // shared_ptr ok because TmpFile itself is a refernce type (no COW)
479  std::list<PublicKeyData> _hiddenKeys;
480 
481  public:
483  static shared_ptr<Impl> nullimpl()
484  {
485  static shared_ptr<Impl> _nullimpl( new Impl );
486  return _nullimpl;
487  }
488 
489  private:
490  friend Impl * rwcowClone<Impl>( const Impl * rhs );
492  Impl * clone() const
493  { return new Impl( *this ); }
494  };
496 
498  // class PublicKey
501  : _pimpl( Impl::nullimpl() )
502  {}
503 
505  : _pimpl( new Impl( file ) )
506  {}
507 
509  : _pimpl( new Impl( sharedfile ) )
510  {}
511 
512  PublicKey::PublicKey( const filesystem::TmpFile & sharedfile, const PublicKeyData & keyData_r )
513  : _pimpl( new Impl( sharedfile, keyData_r ) )
514  {}
515 
516  PublicKey::PublicKey( const PublicKeyData & keyData_r )
517  : _pimpl( new Impl( keyData_r ) )
518  {}
519 
521  {}
522 
524  { return _pimpl->keyData(); }
525 
527  { return _pimpl->path(); }
528 
529  const std::list<PublicKeyData> & PublicKey::hiddenKeys() const
530  { return _pimpl->hiddenKeys(); }
531 
532  std::string PublicKey::id() const
533  { return keyData().id(); }
534 
535  std::string PublicKey::name() const
536  { return keyData().name(); }
537 
538  std::string PublicKey::fingerprint() const
539  { return keyData().fingerprint(); }
540 
541  std::string PublicKey::algoName() const
542  { return keyData().algoName(); }
543 
545  { return keyData().created(); }
546 
548  { return keyData().expires(); }
549 
550  bool PublicKey::expired() const
551  { return keyData().expired(); }
552 
554  { return keyData().daysToLive(); }
555 
556  std::string PublicKey::expiresAsString() const
557  { return keyData().expiresAsString(); }
558 
559  std::string PublicKey::gpgPubkeyVersion() const
560  { return keyData().gpgPubkeyVersion(); }
561 
562  std::string PublicKey::gpgPubkeyRelease() const
563  { return keyData().gpgPubkeyRelease(); }
564 
565  std::string PublicKey::asString() const
566  { return keyData().asString(); }
567 
568  std::string PublicKey::rpmName() const
569  { return keyData().rpmName(); }
570 
571  bool PublicKey::operator==( const PublicKey & rhs ) const
572  { return rhs.keyData() == keyData(); }
573 
574  bool PublicKey::operator==( const std::string & sid ) const
575  { return sid == id(); }
576 
577  std::ostream & dumpOn( std::ostream & str, const PublicKey & obj )
578  { return dumpOn( str, obj.keyData() ); }
579 
580 
581 
582 
584 } // namespace zypp
zypp::PublicKey::Impl::readFromFile
void readFromFile()
Definition: PublicKey.cc:447
ExternalProgram.h
zypp::PublicKey::name
std::string name() const
Definition: PublicKey.cc:535
zypp::PublicKey::Impl::_dontUseThisPtrDirectly
shared_ptr< filesystem::TmpFile > _dontUseThisPtrDirectly
Definition: PublicKey.cc:477
zypp::PublicKeyData::Impl::_expires
Date _expires
Definition: PublicKey.cc:204
zypp::filesystem::PathInfo::path
const Pathname & path() const
Return current Pathname.
Definition: PathInfo.h:246
zypp::str::hexstring
std::string hexstring(char n, int w=4)
Definition: String.h:321
TmpPath.h
PathInfo.h
zypp::filesystem::PathInfo::isExist
bool isExist() const
Return whether valid stat info exists.
Definition: PathInfo.h:281
zypp::PublicKeyData::Impl::_name
std::string _name
Definition: PublicKey.cc:200
zypp::PublicSubkeyData::created
Date created() const
Creation date.
Definition: PublicKey.cc:175
zypp::Exception
Base class for Exception.
Definition: Exception.h:146
zypp::PublicKeyData::expired
bool expired() const
Whether the key has expired.
Definition: PublicKey.cc:329
zypp::PublicKey::hiddenKeys
const std::list< PublicKeyData > & hiddenKeys() const
Additional keys data in case the ASCII armored blob containes multiple keys.
Definition: PublicKey.cc:529
zypp::filesystem::PathInfo::size
off_t size() const
Definition: PathInfo.h:368
zypp::PublicKey::Impl::Impl
Impl()
Definition: PublicKey.cc:397
zypp::PublicKey::id
std::string id() const
Definition: PublicKey.cc:532
zypp::PublicKeyData::Impl::clone
Impl * clone() const
clone for RWCOW_pointer
Definition: PublicKey.cc:285
zypp::PublicKey::keyData
const PublicKeyData & keyData() const
The public keys data (.
Definition: PublicKey.cc:523
zypp::Date::day
static const ValueType day
Definition: Date.h:44
zypp::PublicKeyData::expires
Date expires() const
Expiry date, or Date() if the key never expires.
Definition: PublicKey.cc:326
PL_
#define PL_(MSG1, MSG2, N)
Definition: Gettext.h:40
zypp::PublicSubkeyData
Class representing a GPG Public Keys subkeys.
Definition: PublicKey.h:79
zypp::PublicKeyData::asString
std::string asString() const
Simple string representation.
Definition: PublicKey.cc:347
zypp::PublicKeyData
Class representing one GPG Public Keys data.
Definition: PublicKey.h:140
zypp::PublicKeyData::~PublicKeyData
~PublicKeyData()
Definition: PublicKey.cc:302
zypp::PublicSubkeyData::asString
std::string asString() const
Simple string representation.
Definition: PublicKey.cc:187
zypp::PublicSubkeyData::Impl::_id
std::string _id
Definition: PublicKey.cc:125
MIL
#define MIL
Definition: Logger.h:79
zypp::PublicKey::~PublicKey
~PublicKey()
Definition: PublicKey.cc:520
zypp::PublicKey::Impl::Impl
Impl(const filesystem::TmpFile &sharedFile_r, const PublicKeyData &keyData_r)
Definition: PublicKey.cc:420
zypp::PublicSubkeyData::daysToLive
int daysToLive() const
Number of days (24h) until the key expires (or since it exired).
Definition: PublicKey.cc:184
zypp::PublicKeyData::created
Date created() const
Creation / last modification date (latest selfsig).
Definition: PublicKey.cc:323
zypp::PublicSubkeyData::_pimpl
RWCOW_pointer< Impl > _pimpl
Definition: PublicKey.h:118
zypp::PublicSubkeyData::PublicSubkeyData
PublicSubkeyData()
Default constructed: empty data.
Definition: PublicKey.cc:154
ZYPP_THROW
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
Definition: Exception.h:392
zypp::operator==
bool operator==(const SetRelation::Enum &lhs, const SetCompare &rhs)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: SetRelationMixin.h:84
zypp::ResolverNamespace::language
@ language
language support
zypp::PublicSubkeyData::expired
bool expired() const
Whether the key has expired.
Definition: PublicKey.cc:181
zypp::PublicKey::Impl::_hiddenKeys
std::list< PublicKeyData > _hiddenKeys
Definition: PublicKey.cc:479
zypp::PublicSubkeyData::expires
Date expires() const
Expiry date, or Date() if the key never expires.
Definition: PublicKey.cc:178
zypp::PublicKeyData::Impl::_created
Date _created
Definition: PublicKey.cc:203
zypp::Date::printDate
std::string printDate(DateFormat dateFormat_r=DateFormat::calendar, TimeBase base_r=TB_LOCALTIME) const
Convenience for printing the date only ['2014-02-07'] The default is DateFormat::calendar and TB_LOCA...
Definition: Date.h:192
zypp::PublicKeyData::subkeys
Iterable< SubkeyIterator > subkeys() const
Iterate any subkeys.
Definition: PublicKey.cc:359
zypp::PublicKeyData::_pimpl
RWCOW_pointer< Impl > _pimpl
Definition: PublicKey.h:239
zypp::KeyManagerCtx::readKeyFromFile
std::list< PublicKeyData > readKeyFromFile(const Pathname &file)
Returns a list of all PublicKeyData found in file.
Definition: KeyManager.cc:318
zypp::PublicKeyData::Impl
PublicKeyData implementation.
Definition: PublicKey.cc:198
zypp::PublicKeyData::gpgPubkeyRelease
std::string gpgPubkeyRelease() const
Gpg-pubkey release as computed by rpm (hexencoded created)
Definition: PublicKey.cc:341
zypp::PublicKey::expiresAsString
std::string expiresAsString() const
Definition: PublicKey.cc:556
zypp::PublicKeyData::Impl::fromGpgmeKey
static shared_ptr< Impl > fromGpgmeKey(gpgme_key_t rawData)
Definition: PublicKey.cc:242
zypp::PublicKey::daysToLive
int daysToLive() const
Definition: PublicKey.cc:553
zypp::PublicSubkeyData::Impl
PublicSubkeyData implementation.
Definition: PublicKey.cc:124
zypp::PublicKey::operator==
bool operator==(const PublicKey &rhs) const
Definition: PublicKey.cc:571
bool
zypp::PublicKeyData::expiresAsString
std::string expiresAsString() const
Definition: PublicKey.cc:335
PublicKey.h
zypp::PublicKey::rpmName
std::string rpmName() const
Definition: PublicKey.cc:568
zypp::base::DrunkenBishop
Random art fingerprint visualization Visualize fingerprint data on a [17x9] (SSH) or [19x11] (GPG) or...
Definition: DrunkenBishop.h:62
zypp::PublicKeyData::PublicKeyData
PublicKeyData()
Default constructed: empty data.
Definition: PublicKey.cc:294
LogTools.h
Exception.h
zypp::filesystem::PathInfo
Wrapper class for ::stat/::lstat.
Definition: PathInfo.h:221
zypp::KeyManagerCtx::createForOpenPGP
static KeyManagerCtx createForOpenPGP()
Creates a new KeyManagerCtx for PGP using a volatile temp.
Definition: KeyManager.cc:238
zypp::filesystem::TmpFile
Provide a new empty temporary file and delete it when no longer needed.
Definition: TmpPath.h:128
zypp::PublicKeyData::algoName
std::string algoName() const
Key algorithm string like RSA 2048
Definition: PublicKey.cc:320
zypp::PublicKey::expires
Date expires() const
Definition: PublicKey.cc:547
zypp::PublicSubkeyData::Impl::nullimpl
static shared_ptr< Impl > nullimpl()
Offer default Impl.
Definition: PublicKey.cc:139
zypp::PublicSubkeyData::Impl::clone
Impl * clone() const
clone for RWCOW_pointer
Definition: PublicKey.cc:145
zypp::PublicKeyData::Impl::nullimpl
static shared_ptr< Impl > nullimpl()
Offer default Impl.
Definition: PublicKey.cc:236
zypp::PublicKey::gpgPubkeyVersion
std::string gpgPubkeyVersion() const
Definition: PublicKey.cc:559
zypp::PublicKey::_pimpl
RWCOW_pointer< Impl > _pimpl
Pointer to implementation.
Definition: PublicKey.h:366
WAR
#define WAR
Definition: Logger.h:80
zypp::PublicKey::Impl::Impl
Impl(const Pathname &keyFile_r)
Definition: PublicKey.cc:400
zypp::PublicKeyData::name
std::string name() const
Key name.
Definition: PublicKey.cc:314
zypp::filesystem::checksum
std::string checksum(const Pathname &file, const std::string &algorithm)
Compute a files checksum.
Definition: PathInfo.cc:1013
zypp::PublicKeyData::Impl::_subkeys
std::vector< PublicSubkeyData > _subkeys
Definition: PublicKey.cc:206
zypp::PublicKeyData::daysToLive
int daysToLive() const
Number of days (24h) until the key expires (or since it exired).
Definition: PublicKey.cc:332
_
#define _(MSG)
Definition: Gettext.h:37
zypp::str::form
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
Definition: String.cc:36
Date.h
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2
zypp::PublicKey::Impl::_keyData
PublicKeyData _keyData
Definition: PublicKey.cc:478
zypp::PublicSubkeyData::Impl::_created
Date _created
Definition: PublicKey.cc:126
zypp::str::toLower
std::string toLower(const std::string &s)
Return lowercase version of s.
Definition: String.cc:177
zypp::PublicKey::PublicKey
PublicKey()
Default ctor.
Definition: PublicKey.cc:500
Regex.h
zypp::PublicSubkeyData::~PublicSubkeyData
~PublicSubkeyData()
Definition: PublicKey.cc:166
zypp::PublicKeyData::Impl::_algoName
std::string _algoName
Definition: PublicKey.cc:202
zypp::str::Str
Convenient building of std::string via std::ostringstream Basically a std::ostringstream autoconverti...
Definition: String.h:209
zypp::PublicKeyData::providesKey
bool providesKey(const std::string &id_r) const
Whether id_r is the id of the primary key or of a subkey.
Definition: PublicKey.cc:362
zypp::PublicKey::Impl
PublicKey implementation.
Definition: PublicKey.cc:396
zypp::PublicKey::Impl::clone
Impl * clone() const
clone for RWCOW_pointer
Definition: PublicKey.cc:492
zypp::PublicKey::Impl::Impl
Impl(const PublicKeyData &keyData_r)
Definition: PublicKey.cc:432
zypp::PublicSubkeyData::Impl::_expires
Date _expires
Definition: PublicKey.cc:127
zypp::PublicKey::created
Date created() const
Definition: PublicKey.cc:544
zypp::PublicKeyData::Impl::hasSubkeyId
bool hasSubkeyId(const std::string &id_r) const
Definition: PublicKey.cc:222
zypp::PublicKey::expired
bool expired() const
Definition: PublicKey.cc:550
zypp::PublicKeyData::Impl::_fingerprint
std::string _fingerprint
Definition: PublicKey.cc:201
Gettext.h
Interface to gettext.
zypp::PublicKey::fingerprint
std::string fingerprint() const
Definition: PublicKey.cc:538
zypp::PublicKey
Class representing one GPG Public Key (PublicKeyData + ASCII armored in a tempfile).
Definition: PublicKey.h:276
zypp::PublicKey::gpgPubkeyRelease
std::string gpgPubkeyRelease() const
Definition: PublicKey.cc:562
zypp::PublicKeyData::fingerprint
std::string fingerprint() const
Key fingerprint.
Definition: PublicKey.cc:317
zypp::Date
Store and operate on date (time_t).
Definition: Date.h:33
zypp::PublicKey::path
Pathname path() const
File containig the ASCII armored key.
Definition: PublicKey.cc:526
zypp::BadKeyException
Exception thrown when the supplied key is not a valid gpg key.
Definition: PublicKey.h:48
zypp::str::asString
const std::string & asString(const std::string &t)
Global asString() that works with std::string too.
Definition: String.h:136
zypp::PublicKeyData::Impl::_id
std::string _id
Definition: PublicKey.cc:199
zypp::PublicKeyData::fromGpgmeKey
static PublicKeyData fromGpgmeKey(_gpgme_key *data)
Definition: PublicKey.cc:305
zypp::str::endsWithCI
bool endsWithCI(const C_Str &str_r, const C_Str &prefix_r)
Definition: String.h:1091
zypp::PublicKeyData::hasSubkeys
bool hasSubkeys() const
Whether subkeys is not empty.
Definition: PublicKey.cc:356
zypp::Date::now
static Date now()
Return the current time.
Definition: Date.h:78
zypp::PublicKey::Impl::path
Pathname path() const
Definition: PublicKey.cc:440
String.h
zypp::filesystem::Pathname
Pathname.
Definition: Pathname.h:45
zypp::PublicSubkeyData::id
std::string id() const
Subkey ID.
Definition: PublicKey.cc:172
zypp::PublicKeyData::asciiArt
AsciiArt asciiArt() const
Random art fingerprint visualization (base::DrunkenBishop).
Definition: PublicKey.cc:369
zypp::PublicKey::asString
std::string asString() const
Definition: PublicKey.cc:565
zypp::PublicKey::Impl::nullimpl
static shared_ptr< Impl > nullimpl()
Offer default Impl.
Definition: PublicKey.cc:483
zypp::Date::ValueType
time_t ValueType
Definition: Date.h:38
zypp::str::Format
Convenient building of std::string with boost::format.
Definition: String.h:250
str
String related utilities and Regular expression matching.
zypp::PublicKey::Impl::Impl
Impl(const filesystem::TmpFile &sharedFile_r)
Definition: PublicKey.cc:415
zypp::PublicKeyData::rpmName
std::string rpmName() const
Gpg-pubkey name as computed by rpm.
Definition: PublicKey.cc:344
zypp::filesystem::hardlinkCopy
int hardlinkCopy(const Pathname &oldpath, const Pathname &newpath)
Create newpath as hardlink or copy of oldpath.
Definition: PathInfo.cc:845
zypp::PublicKey::Impl::hiddenKeys
const std::list< PublicKeyData > & hiddenKeys() const
Definition: PublicKey.cc:443
zypp::filesystem::Pathname::asString
const std::string & asString() const
String representation.
Definition: Pathname.h:91
zypp::PublicKeyData::gpgPubkeyVersion
std::string gpgPubkeyVersion() const
Gpg-pubkey version as computed by rpm (trailing 8 byte id)
Definition: PublicKey.cc:338
zypp::dumpOn
std::ostream & dumpOn(std::ostream &str, const Capability &obj)
Definition: Capability.cc:444
KeyManager.h
zypp::PublicKey::algoName
std::string algoName() const
Definition: PublicKey.cc:541
zypp::PublicKey::Impl::keyData
const PublicKeyData & keyData() const
Definition: PublicKey.cc:437
zypp::Iterable
Definition: Iterable.h:37
zypp::PublicKeyData::AsciiArt
base::DrunkenBishop AsciiArt
Random art fingerprint visualization type (base::DrunkenBishop).
Definition: PublicKey.h:228
zypp::PublicKeyData::id
std::string id() const
Key ID.
Definition: PublicKey.cc:311