#include <ctime>
+/** \todo Fix duplicate define in PublicKey/KeyRing */
+#define GPG_BINARY "/usr/bin/gpg2"
+
using std::endl;
///////////////////////////////////////////////////////////////////
if ( _pimpl->_expires )
{
Date exp( _pimpl->_expires - Date::now() );
- return exp < 0 ? exp / Date::day - 1 : exp / Date::day;
+ int ret = exp / Date::day;
+ if ( exp < 0 ) ret -= 1;
+ return ret;
}
return INT_MAX;
}
{
std::vector<std::string> _words;
enum { pNONE, pPUB, pSIG, pFPR, pUID } _parseEntry;
+ bool _parseOff; // no 'sub:' key parsing
Impl()
: _parseEntry( pNONE )
+ , _parseOff( false )
{}
void scan( std::string & line_r, std::list<PublicKeyData> & keys_r )
if ( line_r.empty() )
return;
- // quick check for interesting entries
+ // quick check for interesting entries, no parsing in subkeys
_parseEntry = pNONE;
switch ( line_r[0] )
{
- #define DOTEST( C1, C2, C3, E ) case C1: if ( line_r[1] == C2 && line_r[2] == C3 && line_r[3] == ':' ) _parseEntry = E; break
- DOTEST( 'p', 'u', 'b', pPUB );
- DOTEST( 's', 'i', 'g', pSIG );
- DOTEST( 'f', 'p', 'r', pFPR );
- DOTEST( 'u', 'i', 'd', pUID );
- #undef DOTEST
+ case 'p':
+ if ( line_r[1] == 'u' && line_r[2] == 'b' && line_r[3] == ':' )
+ {
+ _parseEntry = pPUB;
+ _parseOff = false;
+ }
+ break;
+
+ case 'f':
+ if ( line_r[1] == 'p' && line_r[2] == 'r' && line_r[3] == ':' )
+ _parseEntry = pFPR;
+ break;
+
+ case 'u':
+ if ( line_r[1] == 'i' && line_r[2] == 'd' && line_r[3] == ':' )
+ _parseEntry = pUID;
+ break;
+
+ case 's':
+ if ( line_r[1] == 'i' && line_r[2] == 'g' && line_r[3] == ':' )
+ _parseEntry = pSIG;
+ else if ( line_r[1] == 'u' && line_r[2] == 'b' && line_r[3] == ':' )
+ _parseOff = true;
+ break;
+
+ default:
+ return;
}
- if ( _parseEntry == pNONE )
+ if ( _parseOff || _parseEntry == pNONE )
return;
if ( line_r[line_r.size()-1] == '\n' )
case pSIG:
// Update creation/modification date from signatures type "13x".
- if ( _words[_words.size()-2] == "13x" )
+ if ( ( _words.size() > 10 && _words[10] == "13x" )
+ || ( _words.size() > 12 && _words[12] == "13x" ) )
{
Date cdate(str::strtonum<Date::ValueType>(_words[5]));
if ( key->_pimpl->_created < cdate )
break;
case pNONE:
- break;
+ break; // intentionally no default:
}
}
};
static filesystem::TmpDir dir;
const char* argv[] =
{
- "gpg",
+ GPG_BINARY,
"-v",
"--no-default-keyring",
"--fixed-list-mode",
"--no-tty",
"--no-greeting",
"--batch",
- "--status-fd",
- "1",
+ "--status-fd", "1",
_dataFile.path().asString().c_str(),
NULL
};