mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-17 13:50:06 +01:00
Do not link integritysetup and veritysetup with pwquality.
These tools do not read passphrases, no need to link to these libraries. Just move the helper code that introduced this dependence as a side-effect. Fixes: #677
This commit is contained in:
@@ -52,7 +52,6 @@ veritysetup_SOURCES = \
|
|||||||
src/utils_arg_names.h \
|
src/utils_arg_names.h \
|
||||||
src/utils_arg_macros.h \
|
src/utils_arg_macros.h \
|
||||||
src/utils_tools.c \
|
src/utils_tools.c \
|
||||||
src/utils_password.c \
|
|
||||||
src/veritysetup.c \
|
src/veritysetup.c \
|
||||||
src/veritysetup_args.h \
|
src/veritysetup_args.h \
|
||||||
src/veritysetup_arg_list.h \
|
src/veritysetup_arg_list.h \
|
||||||
@@ -61,8 +60,6 @@ veritysetup_SOURCES = \
|
|||||||
veritysetup_LDADD = $(LDADD) \
|
veritysetup_LDADD = $(LDADD) \
|
||||||
libcryptsetup.la \
|
libcryptsetup.la \
|
||||||
@POPT_LIBS@ \
|
@POPT_LIBS@ \
|
||||||
@PWQUALITY_LIBS@ \
|
|
||||||
@PASSWDQC_LIBS@ \
|
|
||||||
@BLKID_LIBS@
|
@BLKID_LIBS@
|
||||||
|
|
||||||
sbin_PROGRAMS += veritysetup
|
sbin_PROGRAMS += veritysetup
|
||||||
@@ -91,7 +88,6 @@ integritysetup_SOURCES = \
|
|||||||
src/utils_arg_names.h \
|
src/utils_arg_names.h \
|
||||||
src/utils_arg_macros.h \
|
src/utils_arg_macros.h \
|
||||||
src/utils_tools.c \
|
src/utils_tools.c \
|
||||||
src/utils_password.c \
|
|
||||||
src/utils_blockdev.c \
|
src/utils_blockdev.c \
|
||||||
src/integritysetup.c \
|
src/integritysetup.c \
|
||||||
src/integritysetup_args.h \
|
src/integritysetup_args.h \
|
||||||
@@ -101,8 +97,6 @@ integritysetup_SOURCES = \
|
|||||||
integritysetup_LDADD = $(LDADD) \
|
integritysetup_LDADD = $(LDADD) \
|
||||||
libcryptsetup.la \
|
libcryptsetup.la \
|
||||||
@POPT_LIBS@ \
|
@POPT_LIBS@ \
|
||||||
@PWQUALITY_LIBS@ \
|
|
||||||
@PASSWDQC_LIBS@ \
|
|
||||||
@UUID_LIBS@ \
|
@UUID_LIBS@ \
|
||||||
@BLKID_LIBS@
|
@BLKID_LIBS@
|
||||||
|
|
||||||
|
|||||||
@@ -318,59 +318,3 @@ void tools_passphrase_msg(int r)
|
|||||||
else if (r == -ENOENT)
|
else if (r == -ENOENT)
|
||||||
log_err(_("No usable keyslot is available."));
|
log_err(_("No usable keyslot is available."));
|
||||||
}
|
}
|
||||||
|
|
||||||
int tools_read_mk(const char *file, char **key, int keysize)
|
|
||||||
{
|
|
||||||
int fd = -1, r = -EINVAL;
|
|
||||||
|
|
||||||
if (keysize <= 0 || !key)
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
*key = crypt_safe_alloc(keysize);
|
|
||||||
if (!*key)
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
fd = open(file, O_RDONLY);
|
|
||||||
if (fd == -1) {
|
|
||||||
log_err(_("Cannot read keyfile %s."), file);
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (read_buffer(fd, *key, keysize) != keysize) {
|
|
||||||
log_err(_("Cannot read %d bytes from keyfile %s."), keysize, file);
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
r = 0;
|
|
||||||
out:
|
|
||||||
if (fd != -1)
|
|
||||||
close(fd);
|
|
||||||
|
|
||||||
if (r) {
|
|
||||||
crypt_safe_free(*key);
|
|
||||||
*key = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
int tools_write_mk(const char *file, const char *key, int keysize)
|
|
||||||
{
|
|
||||||
int fd, r = -EINVAL;
|
|
||||||
|
|
||||||
if (keysize <= 0 || !key)
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
fd = open(file, O_CREAT|O_EXCL|O_WRONLY, S_IRUSR);
|
|
||||||
if (fd < 0) {
|
|
||||||
log_err(_("Cannot open keyfile %s for write."), file);
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (write_buffer(fd, key, keysize) == keysize)
|
|
||||||
r = 0;
|
|
||||||
else
|
|
||||||
log_err(_("Cannot write to keyfile %s."), file);
|
|
||||||
|
|
||||||
close(fd);
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -493,3 +493,59 @@ int tools_reencrypt_progress(uint64_t size, uint64_t offset, void *usrptr)
|
|||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int tools_read_mk(const char *file, char **key, int keysize)
|
||||||
|
{
|
||||||
|
int fd = -1, r = -EINVAL;
|
||||||
|
|
||||||
|
if (keysize <= 0 || !key)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
*key = crypt_safe_alloc(keysize);
|
||||||
|
if (!*key)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
|
fd = open(file, O_RDONLY);
|
||||||
|
if (fd == -1) {
|
||||||
|
log_err(_("Cannot read keyfile %s."), file);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (read_buffer(fd, *key, keysize) != keysize) {
|
||||||
|
log_err(_("Cannot read %d bytes from keyfile %s."), keysize, file);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
r = 0;
|
||||||
|
out:
|
||||||
|
if (fd != -1)
|
||||||
|
close(fd);
|
||||||
|
|
||||||
|
if (r) {
|
||||||
|
crypt_safe_free(*key);
|
||||||
|
*key = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
int tools_write_mk(const char *file, const char *key, int keysize)
|
||||||
|
{
|
||||||
|
int fd, r = -EINVAL;
|
||||||
|
|
||||||
|
if (keysize <= 0 || !key)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
fd = open(file, O_CREAT|O_EXCL|O_WRONLY, S_IRUSR);
|
||||||
|
if (fd < 0) {
|
||||||
|
log_err(_("Cannot open keyfile %s for write."), file);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (write_buffer(fd, key, keysize) == keysize)
|
||||||
|
r = 0;
|
||||||
|
else
|
||||||
|
log_err(_("Cannot write to keyfile %s."), file);
|
||||||
|
|
||||||
|
close(fd);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user