cryptsetup: Clean up includes

Split out of #37344.
This commit is contained in:
Daan De Meyer
2025-05-22 01:40:01 +09:00
committed by Yu Watanabe
parent abe7cc5678
commit 96fafb925c
13 changed files with 28 additions and 89 deletions
+2 -3
View File
@@ -1,9 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <errno.h>
#include <fcntl.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include "alloc-util.h"
#include "cryptsetup-util.h"
@@ -23,6 +21,7 @@
#include "specifier.h"
#include "string-util.h"
#include "strv.h"
#include "time-util.h"
#include "unit-name.h"
typedef struct crypto_device {
+1 -1
View File
@@ -3,9 +3,9 @@
#include "alloc-util.h"
#include "cryptsetup-keyfile.h"
#include "fileio.h"
#include "iovec-util.h"
#include "log.h"
#include "path-util.h"
#include "string-util.h"
#include "strv.h"
int find_key_file(const char *key_file, char **search_path, const char *bindname, struct iovec *ret_key) {
+1 -4
View File
@@ -1,9 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include <inttypes.h>
#include <sys/types.h>
#include "iovec-util.h"
#include "forward.h"
int find_key_file(const char *key_file, char **search_path, const char *bindname, struct iovec *ret_key);
+10 -16
View File
@@ -1,29 +1,16 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <fcntl.h>
#include <p11-kit/p11-kit.h>
#include <p11-kit/uri.h>
#include <sys/stat.h>
#include <unistd.h>
#include "sd-json.h"
#include "alloc-util.h"
#include "ask-password-api.h"
#include "cryptsetup-pkcs11.h"
#include "escape.h"
#include "fd-util.h"
#include "cryptsetup-util.h"
#include "fileio.h"
#include "format-util.h"
#include "hexdecoct.h"
#include "iovec-util.h"
#include "macro.h"
#include "memory-util.h"
#include "parse-util.h"
#include "log.h"
#include "pkcs11-util.h"
#include "random-util.h"
#include "stat-util.h"
#include "strv.h"
int decrypt_pkcs11_key(
const char *volume_name,
@@ -37,7 +24,7 @@ int decrypt_pkcs11_key(
AskPasswordFlags askpw_flags,
void **ret_decrypted_key,
size_t *ret_decrypted_key_size) {
#if HAVE_P11KIT
_cleanup_(pkcs11_crypt_device_callback_data_release) pkcs11_crypt_device_callback_data data = {
.friendly_name = friendly_name,
.askpw_flags = askpw_flags,
@@ -86,6 +73,9 @@ int decrypt_pkcs11_key(
*ret_decrypted_key_size = data.decrypted_key_size;
return 0;
#else
return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP), "PKCS#11 Token support not available.");
#endif
}
int find_pkcs11_auto_data(
@@ -95,6 +85,7 @@ int find_pkcs11_auto_data(
size_t *ret_encrypted_key_size,
int *ret_keyslot) {
#if HAVE_P11KIT
_cleanup_free_ char *uri = NULL;
_cleanup_free_ void *key = NULL;
int r, keyslot = -1;
@@ -170,4 +161,7 @@ int find_pkcs11_auto_data(
*ret_encrypted_key_size = key_size;
*ret_keyslot = keyslot;
return 0;
#else
return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP), "PKCS#11 Token support not available.");
#endif
}
+1 -40
View File
@@ -1,14 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include <sys/types.h>
#include "ask-password-api.h"
#include "cryptsetup-util.h"
#include "log.h"
#include "time-util.h"
#if HAVE_P11KIT
#include "forward.h"
int decrypt_pkcs11_key(
const char *volume_name,
@@ -29,35 +22,3 @@ int find_pkcs11_auto_data(
void **ret_encrypted_key,
size_t *ret_encrypted_key_size,
int *ret_keyslot);
#else
static inline int decrypt_pkcs11_key(
const char *volume_name,
const char *friendly_name,
const char *pkcs11_uri,
const char *key_file,
size_t key_file_size,
uint64_t key_file_offset,
const struct iovec *key_data,
usec_t until,
AskPasswordFlags askpw_flags,
void **ret_decrypted_key,
size_t *ret_decrypted_key_size) {
return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP),
"PKCS#11 Token support not available.");
}
static inline int find_pkcs11_auto_data(
struct crypt_device *cd,
char **ret_uri,
void **ret_encrypted_key,
size_t *ret_encrypted_key_size,
int *ret_keyslot) {
return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP),
"PKCS#11 Token support not available.");
}
#endif
@@ -1,14 +1,13 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <errno.h>
#include <libcryptsetup.h>
#include <string.h>
#include "sd-json.h"
#include "alloc-util.h"
#include "cryptsetup-token.h"
#include "cryptsetup-token-util.h"
#include "hexdecoct.h"
#include "json-util.h"
#include "luks2-fido2.h"
#include "memory-util.h"
#include "version.h"
@@ -1,6 +1,5 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <errno.h>
#include <libcryptsetup.h>
#include "sd-json.h"
@@ -8,7 +7,6 @@
#include "alloc-util.h"
#include "cryptsetup-token.h"
#include "cryptsetup-token-util.h"
#include "hexdecoct.h"
#include "luks2-pkcs11.h"
#include "memory-util.h"
#include "pkcs11-util.h"
@@ -1,6 +1,5 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <errno.h>
#include <libcryptsetup.h>
#include "alloc-util.h"
@@ -10,7 +9,7 @@
#include "json-util.h"
#include "luks2-tpm2.h"
#include "memory-util.h"
#include "strv.h"
#include "string-util.h"
#include "tpm2-util.h"
#include "version.h"
@@ -3,10 +3,8 @@
#pragma once
#include <libcryptsetup.h>
#include <stdbool.h>
#include <stddef.h>
#include "macro.h"
#include "forward.h"
/* crypt_dump() internal indentation magic */
#define CRYPT_DUMP_LINE_SEP "\n\t "
@@ -1,9 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include <stddef.h>
struct crypt_device;
#include "forward.h"
/* for more information see libcryptsetup.h crypt-tokens section */
@@ -2,9 +2,7 @@
#pragma once
#include <stddef.h>
struct crypt_device;
#include "forward.h"
int acquire_luks2_key(
struct crypt_device *cd,
+5 -4
View File
@@ -1,14 +1,13 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <errno.h>
#include <getopt.h>
#include <mntent.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include "sd-device.h"
#include "sd-event.h"
#include "sd-json.h"
#include "sd-messages.h"
@@ -21,10 +20,11 @@
#include "cryptsetup-pkcs11.h"
#include "cryptsetup-tpm2.h"
#include "cryptsetup-util.h"
#include "device-util.h"
#include "efi-api.h"
#include "efi-loader.h"
#include "efivars.h"
#include "env-util.h"
#include "errno-util.h"
#include "escape.h"
#include "extract-word.h"
#include "fileio.h"
@@ -42,10 +42,11 @@
#include "path-util.h"
#include "pkcs11-util.h"
#include "pretty-print.h"
#include "process-util.h"
#include "random-util.h"
#include "string-table.h"
#include "string-util.h"
#include "strv.h"
#include "time-util.h"
#include "tpm2-pcr.h"
#include "tpm2-util.h"
#include "verbs.h"
+2 -5
View File
@@ -7,14 +7,11 @@ endif
subdir('cryptsetup-tokens')
systemd_cryptsetup_sources = files(
'cryptsetup-keyfile.c',
'cryptsetup.c',
'cryptsetup-keyfile.c',
'cryptsetup-pkcs11.c',
)
if conf.get('HAVE_P11KIT') == 1
systemd_cryptsetup_sources += files('cryptsetup-pkcs11.c')
endif
executables += [
executable_template + {
'name' : 'systemd-cryptsetup',