libzypp  17.1.1
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  {
294  enum { pNONE, pPUB, pSIG, pFPR, pUID, pSUB } _parseEntry;
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() )
383  _keyDataPtr->_fingerprint = _words[9];
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  : _dontUseThisPtrDirectly( new filesystem::TmpFile )
434  {
435  PathInfo info( keyFile_r );
436  MIL << "Taking pubkey from " << keyFile_r << " of size " << info.size() << " and sha1 " << filesystem::checksum(keyFile_r, "sha1") << endl;
437 
438  if ( !info.isExist() )
439  ZYPP_THROW(Exception("Can't read public key from " + keyFile_r.asString() + ", file not found"));
440 
441  if ( filesystem::hardlinkCopy( keyFile_r, path() ) != 0 )
442  ZYPP_THROW(Exception("Can't copy public key data from " + keyFile_r.asString() + " to " + path().asString() ));
443 
444  readFromFile();
445  }
446 
447  Impl( const filesystem::TmpFile & sharedFile_r )
448  : _dontUseThisPtrDirectly( new filesystem::TmpFile( sharedFile_r ) )
449  { readFromFile(); }
450 
451  Impl( const filesystem::TmpFile & sharedFile_r, const PublicKeyData & keyData_r )
452  : _dontUseThisPtrDirectly( new filesystem::TmpFile( sharedFile_r ) )
453  , _keyData( keyData_r )
454  {
455  if ( ! keyData_r )
456  {
457  WAR << "Invalid PublicKeyData supplied: scanning from file" << endl;
458  readFromFile();
459  }
460  }
461 
462  Impl( const PublicKeyData & keyData_r )
463  : _keyData( keyData_r )
464  {}
465 
466  public:
467  const PublicKeyData & keyData() const
468  { return _keyData; }
469 
470  Pathname path() const
471  { return( /*the one and only intended use*/_dontUseThisPtrDirectly ? _dontUseThisPtrDirectly->path() : Pathname() ); }
472 
473  const std::list<PublicKeyData> & hiddenKeys() const
474  { return _hiddenKeys; }
475 
476  protected:
477  std::string _initHomeDir()
478  { Pathname ret( zypp::myTmpDir() / "PublicKey" ); filesystem::assert_dir( ret ); return ret.asString(); }
479 
481  {
482  PathInfo info( path() );
483  MIL << "Reading pubkey from " << info.path() << " of size " << info.size() << " and sha1 " << filesystem::checksum(info.path(), "sha1") << endl;
484 
485  static std::string tmppath( _initHomeDir() );
486  std::string datapath( path().asString() );
487 
488  const char* argv[] =
489  {
490  GPG_BINARY,
491  "-v",
492  "--no-default-keyring",
493  "--fixed-list-mode",
494  "--with-fingerprint",
495  "--with-colons",
496  "--homedir",
497  tmppath.c_str(),
498  "--quiet",
499  "--no-tty",
500  "--no-greeting",
501  "--batch",
502  "--status-fd", "1",
503  datapath.c_str(),
504  NULL
505  };
506  ExternalProgram prog( argv, ExternalProgram::Discard_Stderr, false, -1, true );
507 
508  PublicKeyScanner scanner;
509  for ( std::string line = prog.receiveLine(); !line.empty(); line = prog.receiveLine() )
510  {
511  scanner.scan( line );
512  }
513  int ret = prog.close();
514 
515  switch ( scanner._keys.size() )
516  {
517  case 0:
518  if ( ret == 129 )
519  ZYPP_THROW( Exception( std::string("Can't read public key data: ") + GPG_BINARY + " is not installed!" ) );
520  else
521  ZYPP_THROW( BadKeyException( "File " + path().asString() + " doesn't contain public key data" , path() ) );
522  break;
523 
524  case 1:
525  // ok.
526  _keyData = scanner._keys.back();
527  _hiddenKeys.clear();
528  break;
529 
530  default:
531  WAR << "File " << path().asString() << " contains multiple keys: " << scanner._keys << endl;
532  _keyData = scanner._keys.back();
533  scanner._keys.pop_back();
534  _hiddenKeys.swap( scanner._keys );
535  break;
536  }
537 
538  MIL << "Read pubkey from " << info.path() << ": " << _keyData << endl;
539  }
540 
541  private:
542  shared_ptr<filesystem::TmpFile> _dontUseThisPtrDirectly; // shared_ptr ok because TmpFile itself is a refernce type (no COW)
544  std::list<PublicKeyData> _hiddenKeys;
545 
546  public:
548  static shared_ptr<Impl> nullimpl()
549  {
550  static shared_ptr<Impl> _nullimpl( new Impl );
551  return _nullimpl;
552  }
553 
554  private:
555  friend Impl * rwcowClone<Impl>( const Impl * rhs );
557  Impl * clone() const
558  { return new Impl( *this ); }
559  };
561 
563  // class PublicKey
566  : _pimpl( Impl::nullimpl() )
567  {}
568 
570  : _pimpl( new Impl( file ) )
571  {}
572 
574  : _pimpl( new Impl( sharedfile ) )
575  {}
576 
577  PublicKey::PublicKey( const filesystem::TmpFile & sharedfile, const PublicKeyData & keyData_r )
578  : _pimpl( new Impl( sharedfile, keyData_r ) )
579  {}
580 
581  PublicKey::PublicKey( const PublicKeyData & keyData_r )
582  : _pimpl( new Impl( keyData_r ) )
583  {}
584 
586  {}
587 
589  { return _pimpl->keyData(); }
590 
592  { return _pimpl->path(); }
593 
594  const std::list<PublicKeyData> & PublicKey::hiddenKeys() const
595  { return _pimpl->hiddenKeys(); }
596 
597  std::string PublicKey::id() const
598  { return keyData().id(); }
599 
600  std::string PublicKey::name() const
601  { return keyData().name(); }
602 
603  std::string PublicKey::fingerprint() const
604  { return keyData().fingerprint(); }
605 
607  { return keyData().created(); }
608 
610  { return keyData().expires(); }
611 
612  bool PublicKey::expired() const
613  { return keyData().expired(); }
614 
616  { return keyData().daysToLive(); }
617 
618  std::string PublicKey::expiresAsString() const
619  { return keyData().expiresAsString(); }
620 
621  std::string PublicKey::gpgPubkeyVersion() const
622  { return keyData().gpgPubkeyVersion(); }
623 
624  std::string PublicKey::gpgPubkeyRelease() const
625  { return keyData().gpgPubkeyRelease(); }
626 
627  std::string PublicKey::asString() const
628  { return keyData().asString(); }
629 
630  bool PublicKey::operator==( const PublicKey & rhs ) const
631  { return rhs.keyData() == keyData(); }
632 
633  bool PublicKey::operator==( const std::string & sid ) const
634  { return sid == id(); }
635 
636  std::ostream & dumpOn( std::ostream & str, const PublicKey & obj )
637  { return dumpOn( str, obj.keyData() ); }
638 
640 } // namespace zypp
std::string asString() const
Simple string representation.
Definition: PublicKey.cc:159
Impl * clone() const
clone for RWCOW_pointer
Definition: PublicKey.cc:126
static const ValueType day
Definition: Date.h:44
int assert_dir(const Pathname &path, unsigned mode)
Like &#39;mkdir -p&#39;.
Definition: PathInfo.cc:320
Interface to gettext.
#define MIL
Definition: Logger.h:64
Impl(const filesystem::TmpFile &sharedFile_r, const PublicKeyData &keyData_r)
Definition: PublicKey.cc:451
int daysToLive() const
Number of days (24h) until the key expires (or since it exired).
Definition: PublicKey.cc:156
Pathname path() const
Definition: PublicKey.cc:470
#define GPG_BINARY
Definition: PublicKey.cc:29
const Pathname & path() const
Return current Pathname.
Definition: PathInfo.h:246
const std::list< PublicKeyData > & hiddenKeys() const
Additional keys data in case the ASCII armored blob containes multiple keys.
Definition: PublicKey.cc:594
std::string asString(const DefaultIntegral< Tp, TInitial > &obj)
std::list< PublicKeyData > _hiddenKeys
Definition: PublicKey.cc:544
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
Definition: Exception.h:392
const PublicKeyData & keyData() const
The public keys data (.
Definition: PublicKey.cc:588
std::string _initHomeDir()
Definition: PublicKey.cc:477
std::string name() const
Definition: PublicKey.cc:600
RWCOW_pointer< Impl > _pimpl
Definition: PublicKey.h:113
std::string gpgPubkeyRelease() const
Gpg-pubkey release as computed by rpm (hexencoded created)
Definition: PublicKey.cc:249
std::list< PublicKeyData > _keys
Extracted keys.
Definition: PublicKey.h:262
PublicSubkeyData implementation.
Definition: PublicKey.cc:109
Class representing one GPG Public Keys data.
Definition: PublicKey.h:133
bool expired() const
Whether the key has expired.
Definition: PublicKey.cc:153
std::string asString() const
Simple string representation.
Definition: PublicKey.cc:252
const PublicKeyData & keyData() const
Definition: PublicKey.cc:467
Exception thrown when the supplied key is not a valid gpg key.
Definition: PublicKey.h:42
PublicSubkeyData()
Default constructed: empty data.
Definition: PublicKey.cc:134
std::string id() const
Definition: PublicKey.cc:597
std::string name() const
Key name.
Definition: PublicKey.cc:225
String related utilities and Regular expression matching.
PublicKeyData::Impl * _keyDataPtr
Definition: PublicKey.cc:296
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:265
Date created() const
Creation date.
Definition: PublicKey.cc:147
PublicKeyScanner implementation.
Definition: PublicKey.cc:292
int daysToLive() const
Definition: PublicKey.cc:615
Impl * clone() const
clone for RWCOW_pointer
Definition: PublicKey.cc:204
Provide a new empty temporary file and delete it when no longer needed.
Definition: TmpPath.h:126
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
Definition: String.cc:36
Iterable< SubkeyIterator > subkeys() const
Iterate any subkeys.
Definition: PublicKey.cc:264
PublicKeyData()
Default constructed: empty data.
Definition: PublicKey.cc:212
#define PL_(MSG1, MSG2, N)
Definition: Gettext.h:30
std::string expiresAsString() const
Definition: PublicKey.cc:618
std::string gpgPubkeyVersion() const
Gpg-pubkey version as computed by rpm (trailing 8 byte id)
Definition: PublicKey.cc:246
const std::list< PublicKeyData > & hiddenKeys() const
Definition: PublicKey.cc:473
std::string id() const
Subkey ID.
Definition: PublicKey.cc:144
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
Date expires() const
Definition: PublicKey.cc:609
bool operator==(const PublicKey &rhs) const
Definition: PublicKey.cc:630
std::string expiresAsString() const
Definition: PublicKey.cc:243
int daysToLive() const
Number of days (24h) until the key expires (or since it exired).
Definition: PublicKey.cc:240
RWCOW_pointer< Impl > _pimpl
Pointer to implementation.
Definition: PublicKey.h:365
Store and operate on date (time_t).
Definition: Date.h:32
Date created() const
Creation / last modification date (latest selfsig).
Definition: PublicKey.cc:231
PublicKeyData _keyData
Definition: PublicKey.cc:543
Convenient building of std::string via std::ostringstream Basically a std::ostringstream autoconverti...
Definition: String.h:210
Impl(const Pathname &keyFile_r)
Definition: PublicKey.cc:432
Execute a program and give access to its io An object of this class encapsulates the execution of an ...
std::string gpgPubkeyVersion() const
Definition: PublicKey.cc:621
const std::string & asString() const
String representation.
Definition: Pathname.h:90
bool isExist() const
Return whether valid stat info exists.
Definition: PathInfo.h:281
#define WAR
Definition: Logger.h:65
std::ostream & dumpOn(std::ostream &str, const PublicKey &obj)
Definition: PublicKey.cc:636
int hardlinkCopy(const Pathname &oldpath, const Pathname &newpath)
Create newpath as hardlink or copy of oldpath.
Definition: PathInfo.cc:836
Pathname myTmpDir()
Global access to the zypp.TMPDIR (created on demand, deleted when libzypp is unloaded) ...
Definition: ZYppImpl.cc:223
shared_ptr< filesystem::TmpFile > _dontUseThisPtrDirectly
Definition: PublicKey.cc:542
static shared_ptr< Impl > nullimpl()
Offer default Impl.
Definition: PublicKey.cc:548
#define nullptr
Definition: Easy.h:54
#define _(MSG)
Definition: Gettext.h:29
std::string receiveLine()
Read one line from the input stream.
Scan abstract from &#39;gpg –with-colons&#39; key listings.
Definition: PublicKey.h:253
std::string toLower(const std::string &s)
Return lowercase version of s.
Definition: String.cc:175
Impl(const PublicKeyData &keyData_r)
Definition: PublicKey.cc:462
PublicKey()
Default ctor.
Definition: PublicKey.cc:565
std::vector< std::string > _words
Definition: PublicKey.cc:295
PublicKey implementation.
Definition: PublicKey.cc:427
std::string fingerprint() const
Key fingerprint.
Definition: PublicKey.cc:228
int close()
Wait for the progamm to complete.
bool expired() const
Whether the key has expired.
Definition: PublicKey.cc:237
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 gpgPubkeyRelease() const
Definition: PublicKey.cc:624
Class representing a GPG Public Keys subkeys.
Definition: PublicKey.h:73
Class representing one GPG Public Key (PublicKeyData + ASCII armored in a tempfile).
Definition: PublicKey.h:282
Date expires() const
Expiry date, or Date() if the key never expires.
Definition: PublicKey.cc:150
Date created() const
Definition: PublicKey.cc:606
Base class for Exception.
Definition: Exception.h:145
Pathname path() const
File containig the ASCII armored key.
Definition: PublicKey.cc:591
std::string id() const
Key ID.
Definition: PublicKey.cc:222
Impl(const filesystem::TmpFile &sharedFile_r)
Definition: PublicKey.cc:447
static Date now()
Return the current time.
Definition: Date.h:78
std::string checksum(const Pathname &file, const std::string &algorithm)
Compute a files checksum.
Definition: PathInfo.cc:1004
RWCOW_pointer< Impl > _pimpl
Definition: PublicKey.h:215
std::string fingerprint() const
Definition: PublicKey.cc:603
static shared_ptr< Impl > nullimpl()
Offer default Impl.
Definition: PublicKey.cc:195
std::string asString() const
Definition: PublicKey.cc:627
bool expired() const
Definition: PublicKey.cc:612
void scan(std::string &line_r, std::list< PublicKeyData > &keys_r)
Definition: PublicKey.cc:303
time_t ValueType
Definition: Date.h:38
PublicKeyData implementation.
Definition: PublicKey.cc:168
Wrapper class for ::stat/::lstat.
Definition: PathInfo.h:220
std::string printDate(DateFormat dateFormat_r=DateFormat::calendar, TimeBase base_r=TB_LOCALTIME) const
Convenience for printing the date only [&#39;2014-02-07&#39;] The default is DateFormat::calendar and TB_LOCA...
Definition: Date.h:192
bool hasSubkeyId(const std::string &id_r) const
Definition: PublicKey.cc:179
static shared_ptr< Impl > nullimpl()
Offer default Impl.
Definition: PublicKey.cc:117
friend std::ostream & dumpOn(std::ostream &str, const PublicKeyData &obj)
Definition: PublicKey.cc:270
std::vector< PublicSubkeyData > _subkeys
Definition: PublicKey.cc:176
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
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
Date expires() const
Expiry date, or Date() if the key never expires.
Definition: PublicKey.cc:234
std::string hexstring(char n, int w=4)
Definition: String.h:340
bool hasSubkeys() const
Whether subkeys is not empty.
Definition: PublicKey.cc:261
Impl * clone() const
clone for RWCOW_pointer
Definition: PublicKey.cc:557
bool operator==(const PublicKeyData &lhs, const PublicKeyData &rhs)
Definition: PublicKey.cc:284