libzypp  16.20.4
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 
29 #define GPG_BINARY "/usr/bin/gpg2"
30 
31 using std::endl;
32 
34 namespace zypp
35 {
37  namespace
38  {
39  inline bool isExpired( const Date & expires_r )
40  { return( expires_r && expires_r < Date::now() ); }
41 
42  inline int hasDaysToLive( const Date & expires_r )
43  {
44  if ( expires_r )
45  {
46  Date exp( expires_r - Date::now() );
47  int ret = exp / Date::day;
48  if ( exp < 0 ) ret -= 1;
49  return ret;
50  }
51  return INT_MAX;
52  }
53 
54  inline std::string expiresDetail( const Date & expires_r )
55  {
56  str::Str str;
57  if ( ! expires_r )
58  {
59  // translators: an annotation to a gpg keys expiry date
60  str << _("does not expire");
61  }
62  else if ( isExpired( expires_r ) )
63  {
64  // translators: an annotation to a gpg keys expiry date: "expired: 1999-04-12"
65  str << ( str::Format(_("expired: %1%") ) % expires_r.printDate() );
66  }
67  else
68  {
69  // translators: an annotation to a gpg keys expiry date: "expires: 2111-04-12"
70  str << ( str::Format(_("expires: %1%") ) % expires_r.printDate() );
71  }
72  return str;
73  }
74 
75  inline std::string expiresDetailVerbose( const Date & expires_r )
76  {
77  if ( !expires_r )
78  { // translators: an annotation to a gpg keys expiry date
79  return _("(does not expire)");
80  }
81  std::string ret( expires_r.asString() );
82  int ttl( hasDaysToLive( expires_r ) );
83  if ( ttl <= 90 )
84  {
85  ret += " ";
86  if ( ttl < 0 )
87  { // translators: an annotation to a gpg keys expiry date
88  ret += _("(EXPIRED)");
89  }
90  else if ( ttl == 0 )
91  { // translators: an annotation to a gpg keys expiry date
92  ret += _("(expires within 24h)");
93  }
94  else
95  { // translators: an annotation to a gpg keys expiry date
96  ret += str::form( PL_("(expires in %d day)", "(expires in %d days)", ttl ), ttl );
97  }
98  }
99  return ret;
100  }
101 
102  } //namespace
104 
110  {
111  std::string _id;
114 
115  public:
117  static shared_ptr<Impl> nullimpl()
118  {
119  static shared_ptr<Impl> _nullimpl( new Impl );
120  return _nullimpl;
121  }
122 
123  private:
124  friend Impl * rwcowClone<Impl>( const Impl * rhs );
126  Impl * clone() const
127  { return new Impl( *this ); }
128  };
129 
133 
135  : _pimpl( Impl::nullimpl() )
136  {}
137 
139  {}
140 
141  PublicSubkeyData::operator bool() const
142  { return !_pimpl->_id.empty(); }
143 
144  std::string PublicSubkeyData::id() const
145  { return _pimpl->_id; }
146 
148  { return _pimpl->_created; }
149 
151  { return _pimpl->_expires; }
152 
154  { return isExpired( _pimpl->_expires ); }
155 
157  { return hasDaysToLive( _pimpl->_expires ); }
158 
159  std::string PublicSubkeyData::asString() const
160  {
161  return str::Str() << id() << " " << created().printDate() << " [" << expiresDetail( expires() ) << "]";
162  }
163 
169  {
170  std::string _id;
171  std::string _name;
172  std::string _fingerprint;
175 
176  std::vector<PublicSubkeyData> _subkeys;
177 
178  public:
179  bool hasSubkeyId( const std::string & id_r ) const
180  {
181  bool ret = false;
182  for ( const PublicSubkeyData & sub : _subkeys )
183  {
184  if ( sub.id() == id_r )
185  {
186  ret = true;
187  break;
188  }
189  }
190  return ret;
191  }
192 
193  public:
195  static shared_ptr<Impl> nullimpl()
196  {
197  static shared_ptr<Impl> _nullimpl( new Impl );
198  return _nullimpl;
199  }
200 
201  private:
202  friend Impl * rwcowClone<Impl>( const Impl * rhs );
204  Impl * clone() const
205  { return new Impl( *this ); }
206  };
207 
211 
213  : _pimpl( Impl::nullimpl() )
214  {}
215 
217  {}
218 
219  PublicKeyData::operator bool() const
220  { return !_pimpl->_fingerprint.empty(); }
221 
222  std::string PublicKeyData::id() const
223  { return _pimpl->_id; }
224 
225  std::string PublicKeyData::name() const
226  { return _pimpl->_name; }
227 
228  std::string PublicKeyData::fingerprint() const
229  { return _pimpl->_fingerprint; }
230 
232  { return _pimpl->_created; }
233 
235  { return _pimpl->_expires; }
236 
238  { return isExpired( _pimpl->_expires ); }
239 
241  { return hasDaysToLive( _pimpl->_expires ); }
242 
243  std::string PublicKeyData::expiresAsString() const
244  { return expiresDetailVerbose( _pimpl->_expires ); }
245 
247  { return _pimpl->_id.empty() ? _pimpl->_id : str::toLower( _pimpl->_id.substr(8,8) ); }
248 
250  { return _pimpl->_created ? str::hexstring( _pimpl->_created ).substr(2) : std::string(); }
251 
252  std::string PublicKeyData::asString() const
253  {
254  str::Str str;
255  str << "[" << _pimpl->_id << "-" << gpgPubkeyRelease();
256  for ( auto && sub : _pimpl->_subkeys )
257  str << ", " << sub.id();
258  return str << "] [" << _pimpl->_name.c_str() << "] [" << expiresDetail( _pimpl->_expires ) << "]";
259  }
260 
262  { return !_pimpl->_subkeys.empty(); }
263 
265  { return makeIterable( &(*_pimpl->_subkeys.begin()), &(*_pimpl->_subkeys.end()) ); }
266 
267  bool PublicKeyData::providesKey( const std::string & id_r ) const
268  { return( id_r == _pimpl->_id || _pimpl->hasSubkeyId( id_r ) ); }
269 
270  std::ostream & dumpOn( std::ostream & str, const PublicKeyData & obj )
271  {
272  str << "[" << obj.name() << "]" << endl;
273  str << " fpr " << obj.fingerprint() << endl;
274  str << " id " << obj.id() << endl;
275  str << " cre " << Date::ValueType(obj.created()) << ' ' << obj.created() << endl;
276  str << " exp " << Date::ValueType(obj.expires()) << ' ' << obj.expiresAsString() << endl;
277  str << " ttl " << obj.daysToLive() << endl;
278  for ( auto && sub : obj._pimpl->_subkeys )
279  str << " sub " << sub << endl;
280  str << " rpm " << obj.gpgPubkeyVersion() << "-" << obj.gpgPubkeyRelease() << endl;
281  return str;
282  }
283 
284  bool operator==( const PublicKeyData & lhs, const PublicKeyData & rhs )
285  { return ( lhs.fingerprint() == rhs.fingerprint() && lhs.created() == rhs.created() ); }
286 
287 
293  {
295  std::vector<std::string> _words;
297 
299  : _parseEntry( pNONE )
300  , _keyDataPtr( nullptr )
301  {}
302 
303  void scan( std::string & line_r, std::list<PublicKeyData> & keys_r )
304  {
305  // pub:-:1024:17:A84EDAE89C800ACA:971961473:1214043198::-:SuSE Package Signing Key <build@suse.de>:
306  // fpr:::::::::79C179B2E1C820C1890F9994A84EDAE89C800ACA:
307  // sig:::17:A84EDAE89C800ACA:1087899198:::::[selfsig]::13x:
308  // sig:::17:9E40E310000AABA4:980442706::::[User ID not found]:10x:
309  // sig:::1:77B2E6003D25D3D9:980443247::::[User ID not found]:10x:
310  // sig:::17:A84EDAE89C800ACA:1318348291:::::[selfsig]::13x:
311  // sub:-:2048:16:197448E88495160C:971961490:1214043258::: [expires: 2008-06-21]
312  // sig:::17:A84EDAE89C800ACA:1087899258:::::[keybind]::18x:
313  if ( line_r.empty() )
314  return;
315 
316  // quick check for interesting entries, no parsing in subkeys
317  _parseEntry = pNONE;
318  switch ( line_r[0] )
319  {
320  case 'p':
321  if ( line_r[1] == 'u' && line_r[2] == 'b' && line_r[3] == ':' )
322  {
323  _parseEntry = pPUB;
324  keys_r.push_back( PublicKeyData() ); // reset upon new key
325  _keyDataPtr = keys_r.back()._pimpl.get();
326  }
327  break;
328 
329  case 'f':
330  if ( line_r[1] == 'p' && line_r[2] == 'r' && line_r[3] == ':' )
331  _parseEntry = pFPR;
332  break;
333 
334  case 'u':
335  if ( line_r[1] == 'i' && line_r[2] == 'd' && line_r[3] == ':' )
336  _parseEntry = pUID;
337  break;
338 
339  case 's':
340  if ( line_r[1] == 'i' && line_r[2] == 'g' && line_r[3] == ':' )
341  _parseEntry = pSIG;
342  else if ( line_r[1] == 'u' && line_r[2] == 'b' && line_r[3] == ':' )
343  _parseEntry = pSUB;
344  break;
345 
346  default:
347  return;
348  }
349  if ( _parseEntry == pNONE )
350  return;
351  if ( ! ( _keyDataPtr->_subkeys.empty() || _parseEntry == pSUB ) )
352  return; // collecting subkeys only
353 
354  if ( line_r[line_r.size()-1] == '\n' )
355  line_r.erase( line_r.size()-1 );
356  //DBG << line_r << endl;
357 
358  _words.clear();
359  str::splitFields( line_r, std::back_inserter(_words), ":" );
360 
361  switch ( _parseEntry )
362  {
363  case pPUB:
364  _keyDataPtr->_id = _words[4];
365  _keyDataPtr->_name = str::replaceAll( _words[9], "\\x3a", ":" );
366  _keyDataPtr->_created = Date(str::strtonum<Date::ValueType>(_words[5]));
367  _keyDataPtr->_expires = Date(str::strtonum<Date::ValueType>(_words[6]));
368  break;
369 
370  case pSIG:
371  // Update creation/modification date from signatures type "13x".
372  if ( ( _words.size() > 10 && _words[10] == "13x" && !_words[9].empty() && _words[9] != "[User ID not found]" )
373  || ( _words.size() > 12 && _words[12] == "13x" /* [selfsig] */) )
374  {
375  Date cdate(str::strtonum<Date::ValueType>(_words[5]));
376  if ( _keyDataPtr->_created < cdate )
377  _keyDataPtr->_created = cdate;
378  }
379  break;
380 
381  case pFPR:
382  if ( _keyDataPtr->_fingerprint.empty() )
384  break;
385 
386  case pUID:
387  if ( ! _words[9].empty() && _words[9] != "[User ID not found]" )
388  _keyDataPtr->_name = str::replaceAll( _words[9], "\\x3a", ":" );
389  break;
390 
391  case pSUB:
392  _keyDataPtr->_subkeys.push_back( PublicSubkeyData() );
393  {
394  PublicSubkeyData::Impl * subPtr = _keyDataPtr->_subkeys.back()._pimpl.get();
395  subPtr->_id = _words[4];
396  subPtr->_created = Date(str::strtonum<Date::ValueType>(_words[5]));
397  subPtr->_expires = Date(str::strtonum<Date::ValueType>(_words[6]));
398  }
399  break;
400 
401  case pNONE:
402  break; // intentionally no default:
403  }
404  }
405  };
407 
409  // class PublicKeyScanner
411 
413  : _pimpl( new Impl )
414  {}
415 
417  {}
418 
419  void PublicKeyScanner::scan( std::string line_r )
420  { _pimpl->scan( line_r, _keys ); }
421 
422 
428  {
430  {}
431 
432  Impl( const Pathname & keyFile_r )
433  {
434  PathInfo info( keyFile_r );
435  MIL << "Taking pubkey from " << keyFile_r << " of size " << info.size() << " and sha1 " << filesystem::checksum(keyFile_r, "sha1") << endl;
436 
437  if ( !info.isExist() )
438  ZYPP_THROW(Exception("Can't read public key from " + keyFile_r.asString() + ", file not found"));
439 
440  if ( filesystem::hardlinkCopy( keyFile_r, _dataFile.path() ) != 0 )
441  ZYPP_THROW(Exception("Can't copy public key data from " + keyFile_r.asString() + " to " + _dataFile.path().asString() ));
442 
443  readFromFile();
444  }
445 
446  Impl( const filesystem::TmpFile & sharedFile_r )
447  : _dataFile( sharedFile_r )
448  { readFromFile(); }
449 
450  Impl( const filesystem::TmpFile & sharedFile_r, const PublicKeyData & keyData_r )
451  : _dataFile( sharedFile_r )
452  , _keyData( keyData_r )
453  {
454  if ( ! keyData_r )
455  {
456  WAR << "Invalid PublicKeyData supplied: scanning from file" << endl;
457  readFromFile();
458  }
459  }
460 
461  public:
462  const PublicKeyData & keyData() const
463  { return _keyData; }
464 
465  Pathname path() const
466  { return _dataFile.path(); }
467 
468  const std::list<PublicKeyData> & hiddenKeys() const
469  { return _hiddenKeys; }
470 
471  protected:
472  std::string _initHomeDir()
473  { Pathname ret( zypp::myTmpDir() / "PublicKey" ); filesystem::assert_dir( ret ); return ret.asString(); }
474 
476  {
477  PathInfo info( _dataFile.path() );
478  MIL << "Reading pubkey from " << info.path() << " of size " << info.size() << " and sha1 " << filesystem::checksum(info.path(), "sha1") << endl;
479 
480  static std::string tmppath( _initHomeDir() );
481  std::string datapath( _dataFile.path().asString() );
482 
483  const char* argv[] =
484  {
485  GPG_BINARY,
486  "-v",
487  "--no-default-keyring",
488  "--fixed-list-mode",
489  "--with-fingerprint",
490  "--with-colons",
491  "--homedir",
492  tmppath.c_str(),
493  "--quiet",
494  "--no-tty",
495  "--no-greeting",
496  "--batch",
497  "--status-fd", "1",
498  datapath.c_str(),
499  NULL
500  };
501  ExternalProgram prog( argv, ExternalProgram::Discard_Stderr, false, -1, true );
502 
503  PublicKeyScanner scanner;
504  for ( std::string line = prog.receiveLine(); !line.empty(); line = prog.receiveLine() )
505  {
506  scanner.scan( line );
507  }
508  int ret = prog.close();
509 
510  switch ( scanner._keys.size() )
511  {
512  case 0:
513  if ( ret == 129 )
514  ZYPP_THROW( Exception( std::string("Can't read public key data: ") + GPG_BINARY + " is not installed!" ) );
515  else
516  ZYPP_THROW( BadKeyException( "File " + _dataFile.path().asString() + " doesn't contain public key data" , _dataFile.path() ) );
517  break;
518 
519  case 1:
520  // ok.
521  _keyData = scanner._keys.back();
522  _hiddenKeys.clear();
523  break;
524 
525  default:
526  WAR << "File " << _dataFile.path().asString() << " contains multiple keys: " << scanner._keys << endl;
527  _keyData = scanner._keys.back();
528  scanner._keys.pop_back();
529  _hiddenKeys.swap( scanner._keys );
530  break;
531  }
532 
533  MIL << "Read pubkey from " << info.path() << ": " << _keyData << endl;
534  }
535 
536  private:
539  std::list<PublicKeyData> _hiddenKeys;
540 
541  public:
543  static shared_ptr<Impl> nullimpl()
544  {
545  static shared_ptr<Impl> _nullimpl( new Impl );
546  return _nullimpl;
547  }
548 
549  private:
550  friend Impl * rwcowClone<Impl>( const Impl * rhs );
552  Impl * clone() const
553  { return new Impl( *this ); }
554  };
556 
558  // class PublicKey
561  : _pimpl( Impl::nullimpl() )
562  {}
563 
565  : _pimpl( new Impl( file ) )
566  {}
567 
569  : _pimpl( new Impl( sharedfile ) )
570  {}
571 
572  PublicKey::PublicKey( const filesystem::TmpFile & sharedfile, const PublicKeyData & keydata )
573  : _pimpl( new Impl( sharedfile, keydata ) )
574  {}
575 
577  {}
578 
580  { return _pimpl->keyData(); }
581 
583  { return _pimpl->path(); }
584 
585  const std::list<PublicKeyData> & PublicKey::hiddenKeys() const
586  { return _pimpl->hiddenKeys(); }
587 
588  std::string PublicKey::id() const
589  { return keyData().id(); }
590 
591  std::string PublicKey::name() const
592  { return keyData().name(); }
593 
594  std::string PublicKey::fingerprint() const
595  { return keyData().fingerprint(); }
596 
598  { return keyData().created(); }
599 
601  { return keyData().expires(); }
602 
603  bool PublicKey::expired() const
604  { return keyData().expired(); }
605 
607  { return keyData().daysToLive(); }
608 
609  std::string PublicKey::expiresAsString() const
610  { return keyData().expiresAsString(); }
611 
612  std::string PublicKey::gpgPubkeyVersion() const
613  { return keyData().gpgPubkeyVersion(); }
614 
615  std::string PublicKey::gpgPubkeyRelease() const
616  { return keyData().gpgPubkeyRelease(); }
617 
618  std::string PublicKey::asString() const
619  { return keyData().asString(); }
620 
621  bool PublicKey::operator==( const PublicKey & rhs ) const
622  { return rhs.keyData() == keyData(); }
623 
624  bool PublicKey::operator==( const std::string & sid ) const
625  { return sid == id(); }
626 
627  std::ostream & dumpOn( std::ostream & str, const PublicKey & obj )
628  { return dumpOn( str, obj.keyData() ); }
629 
631 } // namespace zypp
#define nullptr
Definition: Easy.h:54
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
Definition: Exception.h:350
Interface to gettext.
#define PL_(MSG1, MSG2, N)
Definition: Gettext.h:30
#define _(MSG)
Definition: Gettext.h:29
#define MIL
Definition: Logger.h:64
#define WAR
Definition: Logger.h:65
#define GPG_BINARY
Definition: PublicKey.cc:29
Exception thrown when the supplied key is not a valid gpg key.
Definition: PublicKey.h:42
Store and operate on date (time_t).
Definition: Date.h:33
static const ValueType day
Definition: Date.h:44
time_t ValueType
Definition: Date.h:38
static Date now()
Return the current time.
Definition: Date.h:78
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
Base class for Exception.
Definition: Exception.h:144
Execute a program and give access to its io An object of this class encapsulates the execution of an ...
int close()
Wait for the progamm to complete.
Class representing one GPG Public Keys data.
Definition: PublicKey.h:133
Date created() const
Creation / last modification date (latest selfsig).
Definition: PublicKey.cc:231
bool expired() const
Whether the key has expired.
Definition: PublicKey.cc:237
std::string name() const
Key name.
Definition: PublicKey.cc:225
Iterable< SubkeyIterator > subkeys() const
Iterate any subkeys.
Definition: PublicKey.cc:264
int daysToLive() const
Number of days (24h) until the key expires (or since it exired).
Definition: PublicKey.cc:240
bool hasSubkeys() const
Whether subkeys is not empty.
Definition: PublicKey.cc:261
PublicKeyData()
Default constructed: empty data.
Definition: PublicKey.cc:212
Date expires() const
Expiry date, or Date() if the key never expires.
Definition: PublicKey.cc:234
RWCOW_pointer< Impl > _pimpl
Definition: PublicKey.h:210
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:267
std::string id() const
Key ID.
Definition: PublicKey.cc:222
std::string fingerprint() const
Key fingerprint.
Definition: PublicKey.cc:228
std::string gpgPubkeyRelease() const
Gpg-pubkey release as computed by rpm (hexencoded created)
Definition: PublicKey.cc:249
std::string gpgPubkeyVersion() const
Gpg-pubkey version as computed by rpm (trailing 8 byte id)
Definition: PublicKey.cc:246
std::string expiresAsString() const
Definition: PublicKey.cc:243
std::string asString() const
Simple string representation.
Definition: PublicKey.cc:252
Class representing one GPG Public Key (PublicKeyData + ASCII armored in a tempfile).
Definition: PublicKey.h:278
Pathname path() const
File containig the ASCII armored key.
Definition: PublicKey.cc:582
std::string expiresAsString() const
Definition: PublicKey.cc:609
bool operator==(const PublicKey &rhs) const
Definition: PublicKey.cc:621
RWCOW_pointer< Impl > _pimpl
Pointer to implementation.
Definition: PublicKey.h:355
Date created() const
Definition: PublicKey.cc:597
PublicKey()
Default ctor.
Definition: PublicKey.cc:560
bool expired() const
Definition: PublicKey.cc:603
const std::list< PublicKeyData > & hiddenKeys() const
Additional keys data in case the ASCII armored blob containes multiple keys.
Definition: PublicKey.cc:585
std::string name() const
Definition: PublicKey.cc:591
Date expires() const
Definition: PublicKey.cc:600
const PublicKeyData & keyData() const
The public keys data (.
Definition: PublicKey.cc:579
std::string gpgPubkeyRelease() const
Definition: PublicKey.cc:615
std::string asString() const
Definition: PublicKey.cc:618
std::string fingerprint() const
Definition: PublicKey.cc:594
std::string id() const
Definition: PublicKey.cc:588
int daysToLive() const
Definition: PublicKey.cc:606
std::string gpgPubkeyVersion() const
Definition: PublicKey.cc:612
Class representing a GPG Public Keys subkeys.
Definition: PublicKey.h:73
RWCOW_pointer< Impl > _pimpl
Definition: PublicKey.h:112
std::string id() const
Subkey ID.
Definition: PublicKey.cc:144
PublicSubkeyData()
Default constructed: empty data.
Definition: PublicKey.cc:134
int daysToLive() const
Number of days (24h) until the key expires (or since it exired).
Definition: PublicKey.cc:156
Date expires() const
Expiry date, or Date() if the key never expires.
Definition: PublicKey.cc:150
std::string asString() const
Simple string representation.
Definition: PublicKey.cc:159
Date created() const
Creation date.
Definition: PublicKey.cc:147
bool expired() const
Whether the key has expired.
Definition: PublicKey.cc:153
std::string receiveLine()
Read one line from the input stream.
Wrapper class for ::stat/::lstat.
Definition: PathInfo.h:221
bool isExist() const
Return whether valid stat info exists.
Definition: PathInfo.h:281
const Pathname & path() const
Return current Pathname.
Definition: PathInfo.h:246
const std::string & asString() const
String representation.
Definition: Pathname.h:90
Provide a new empty temporary file and delete it when no longer needed.
Definition: TmpPath.h:127
Pathname path() const
Definition: TmpPath.cc:146
String related utilities and Regular expression matching.
std::string checksum(const Pathname &file, const std::string &algorithm)
Compute a files checksum.
Definition: PathInfo.cc:1004
int assert_dir(const Pathname &path, unsigned mode)
Like 'mkdir -p'.
Definition: PathInfo.cc:320
int hardlinkCopy(const Pathname &oldpath, const Pathname &newpath)
Create newpath as hardlink or copy of oldpath.
Definition: PathInfo.cc:836
std::string & replaceAll(std::string &str_r, const std::string &from_r, const std::string &to_r)
Replace all occurrences of from_r with to_r in str_r (inplace).
Definition: String.cc:328
unsigned splitFields(const C_Str &line_r, TOutputIterator result_r, const C_Str &sepchars_r=":")
Split line_r into fields.
Definition: String.h:708
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
Definition: String.cc:36
std::string hexstring(char n, int w=4)
Definition: String.h:340
std::string toLower(const std::string &s)
Return lowercase version of s.
Definition: String.cc:175
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2
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...
Pathname myTmpDir()
Global access to the zypp.TMPDIR (created on demand, deleted when libzypp is unloaded)
Definition: ZYppImpl.cc:223
std::ostream & dumpOn(std::ostream &str, const Capability &obj)
Definition: Capability.cc:444
PublicKeyData implementation.
Definition: PublicKey.cc:169
Impl * clone() const
clone for RWCOW_pointer
Definition: PublicKey.cc:204
std::vector< PublicSubkeyData > _subkeys
Definition: PublicKey.cc:176
static shared_ptr< Impl > nullimpl()
Offer default Impl.
Definition: PublicKey.cc:195
bool hasSubkeyId(const std::string &id_r) const
Definition: PublicKey.cc:179
PublicKeyScanner implementation.
Definition: PublicKey.cc:293
void scan(std::string &line_r, std::list< PublicKeyData > &keys_r)
Definition: PublicKey.cc:303
PublicKeyData::Impl * _keyDataPtr
Definition: PublicKey.cc:296
std::vector< std::string > _words
Definition: PublicKey.cc:295
enum zypp::PublicKeyScanner::Impl::@1 _parseEntry
Scan abstract from 'gpg –with-colons' key listings.
Definition: PublicKey.h:249
std::list< PublicKeyData > _keys
Extracted keys.
Definition: PublicKey.h:257
void scan(std::string line_r)
Feed gpg output line by line into scan.
Definition: PublicKey.cc:419
RW_pointer< Impl, rw_pointer::Scoped< Impl > > _pimpl
Definition: PublicKey.h:260
PublicKey implementation.
Definition: PublicKey.cc:428
Impl(const Pathname &keyFile_r)
Definition: PublicKey.cc:432
filesystem::TmpFile _dataFile
Definition: PublicKey.cc:537
Pathname path() const
Definition: PublicKey.cc:465
std::string _initHomeDir()
Definition: PublicKey.cc:472
Impl * clone() const
clone for RWCOW_pointer
Definition: PublicKey.cc:552
const std::list< PublicKeyData > & hiddenKeys() const
Definition: PublicKey.cc:468
std::list< PublicKeyData > _hiddenKeys
Definition: PublicKey.cc:539
static shared_ptr< Impl > nullimpl()
Offer default Impl.
Definition: PublicKey.cc:543
Impl(const filesystem::TmpFile &sharedFile_r)
Definition: PublicKey.cc:446
Impl(const filesystem::TmpFile &sharedFile_r, const PublicKeyData &keyData_r)
Definition: PublicKey.cc:450
PublicKeyData _keyData
Definition: PublicKey.cc:538
const PublicKeyData & keyData() const
Definition: PublicKey.cc:462
PublicSubkeyData implementation.
Definition: PublicKey.cc:110
static shared_ptr< Impl > nullimpl()
Offer default Impl.
Definition: PublicKey.cc:117
Impl * clone() const
clone for RWCOW_pointer
Definition: PublicKey.cc:126
Convenient building of std::string via std::ostringstream Basically a std::ostringstream autoconverti...
Definition: String.h:211