homed: reuse openssl-util.h cleanup helpers

This commit is contained in:
Lennart Poettering
2023-08-18 13:44:19 +01:00
committed by Luca Boccassi
parent d7686126ea
commit 8fc798a9ad
2 changed files with 4 additions and 7 deletions
+1 -3
View File
@@ -37,6 +37,7 @@
#include "homed-varlink.h"
#include "io-util.h"
#include "mkdir.h"
#include "openssl-util.h"
#include "process-util.h"
#include "quota-util.h"
#include "random-util.h"
@@ -1392,8 +1393,6 @@ static int manager_load_key_pair(Manager *m) {
return 1;
}
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(EVP_PKEY_CTX*, EVP_PKEY_CTX_free, NULL);
static int manager_generate_key_pair(Manager *m) {
_cleanup_(EVP_PKEY_CTX_freep) EVP_PKEY_CTX *ctx = NULL;
_cleanup_(unlink_and_freep) char *temp_public = NULL, *temp_private = NULL;
@@ -1504,7 +1503,6 @@ int manager_sign_user_record(Manager *m, UserRecord *u, UserRecord **ret, sd_bus
}
DEFINE_PRIVATE_HASH_OPS_FULL(public_key_hash_ops, char, string_hash_func, string_compare_func, free, EVP_PKEY, EVP_PKEY_free);
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(EVP_PKEY*, EVP_PKEY_free, NULL);
static int manager_load_public_key_one(Manager *m, const char *path) {
_cleanup_(EVP_PKEY_freep) EVP_PKEY *pkey = NULL;
+3 -4
View File
@@ -3,9 +3,10 @@
#include <openssl/pem.h>
#include "fd-util.h"
#include "memstream-util.h"
#include "user-record-sign.h"
#include "fileio.h"
#include "memstream-util.h"
#include "openssl-util.h"
#include "user-record-sign.h"
static int user_record_signable_json(UserRecord *ur, char **ret) {
_cleanup_(user_record_unrefp) UserRecord *reduced = NULL;
@@ -28,8 +29,6 @@ static int user_record_signable_json(UserRecord *ur, char **ret) {
return json_variant_format(j, 0, ret);
}
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(EVP_MD_CTX*, EVP_MD_CTX_free, NULL);
int user_record_sign(UserRecord *ur, EVP_PKEY *private_key, UserRecord **ret) {
_cleanup_(memstream_done) MemStream m = {};
_cleanup_(json_variant_unrefp) JsonVariant *encoded = NULL, *v = NULL;