const char* pakfire_key_get_email(struct pakfire_key* key);
const char* pakfire_key_get_pubkey_algo(struct pakfire_key* key);
size_t pakfire_key_get_pubkey_length(struct pakfire_key* key);
+int pakfire_key_has_secret(struct pakfire_key* key);
time_t pakfire_key_get_created(struct pakfire_key* key);
time_t pakfire_key_get_expires(struct pakfire_key* key);
int pakfire_key_is_revoked(struct pakfire_key* key);
return 0;
}
+PAKFIRE_EXPORT int pakfire_key_has_secret(struct pakfire_key* key) {
+ if (key->gpgkey)
+ return key->gpgkey->secret;
+
+ return 0;
+}
+
PAKFIRE_EXPORT time_t pakfire_key_get_created(struct pakfire_key* key) {
if (key->gpgkey->subkeys)
return key->gpgkey->subkeys->timestamp;
return 1;
}
+ // Make files with secret keys non-world-readable
+ if (pakfire_key_has_secret(key)) {
+ r = chmod(path, 0600);
+ if (r) {
+ ERROR(key->pakfire, "Could not chmod %s: %m\n", path);
+ fclose(f);
+ return r;
+ }
+ }
+
// Write key to file
r = pakfire_key_export(key, f, 0);
if (r) {