Commit b1a2da0a authored by Lennart Poettering's avatar Lennart Poettering
Browse files

cryptsetup: show udev device name when asking for password

parent 24a35973
...@@ -773,10 +773,12 @@ systemd_cryptsetup_SOURCES = \ ...@@ -773,10 +773,12 @@ systemd_cryptsetup_SOURCES = \
systemd_cryptsetup_CFLAGS = \ systemd_cryptsetup_CFLAGS = \
$(LIBCRYPTSETUP_CFLAGS) \ $(LIBCRYPTSETUP_CFLAGS) \
$(UDEV_CFLAGS) \
$(AM_CFLAGS) $(AM_CFLAGS)
systemd_cryptsetup_LDADD = \ systemd_cryptsetup_LDADD = \
$(LIBCRYPTSETUP_LIBS) \ $(LIBCRYPTSETUP_LIBS) \
$(UDEV_LIBS) \
libsystemd-basic.la libsystemd-basic.la
systemd_cryptsetup_generator_SOURCES = \ systemd_cryptsetup_generator_SOURCES = \
......
...@@ -57,8 +57,6 @@ ...@@ -57,8 +57,6 @@
* when processes remain in a service even though the start command failed enter active * when processes remain in a service even though the start command failed enter active
* parse early boot time env var from dracut RD_TIMEOUT, drop RD_xxx
* add seperate man page for [Install] settings * add seperate man page for [Install] settings
* only add quotacheck deps to .mount units which mention grpquota/usrquota in the mount flags * only add quotacheck deps to .mount units which mention grpquota/usrquota in the mount flags
...@@ -75,8 +73,6 @@ ...@@ -75,8 +73,6 @@
* isolate multi-user.target doesn't start a getty@tty1 if we run it from graphical.target * isolate multi-user.target doesn't start a getty@tty1 if we run it from graphical.target
* read description string from device in crypttsetup
External: External:
* make cryptsetup lower --iter-time * make cryptsetup lower --iter-time
...@@ -89,8 +85,6 @@ External: ...@@ -89,8 +85,6 @@ External:
* pam_securetty should honour console= * pam_securetty should honour console=
* sysctl should support sysctl.conf.d directory
* procps, psmisc, sysvinit-tools, hostname → util-linux-ng * procps, psmisc, sysvinit-tools, hostname → util-linux-ng
https://bugzilla.redhat.com/show_bug.cgi?id=614245 -- plymouth https://bugzilla.redhat.com/show_bug.cgi?id=614245 -- plymouth
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <sys/mman.h> #include <sys/mman.h>
#include <libcryptsetup.h> #include <libcryptsetup.h>
#include <libudev.h>
#include "log.h" #include "log.h"
#include "util.h" #include "util.h"
...@@ -140,11 +141,47 @@ static void log_glue(int level, const char *msg, void *usrptr) { ...@@ -140,11 +141,47 @@ static void log_glue(int level, const char *msg, void *usrptr) {
log_debug("%s", msg); log_debug("%s", msg);
} }
static char *disk_description(const char *path) {
struct udev *udev = NULL;
struct udev_device *device = NULL;
struct stat st;
char *description = NULL;
const char *model;
assert(path);
if (stat(path, &st) < 0)
return NULL;
if (!S_ISBLK(st.st_mode))
return NULL;
if (!(udev = udev_new()))
return NULL;
if (!(device = udev_device_new_from_devnum(udev, 'b', st.st_rdev)))
goto finish;
if ((model = udev_device_get_property_value(device, "ID_MODEL_FROM_DATABASE")) ||
(model = udev_device_get_property_value(device, "ID_MODEL")))
description = strdup(model);
finish:
if (device)
udev_device_unref(device);
if (udev)
udev_unref(udev);
return description;
}
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
int r = EXIT_FAILURE; int r = EXIT_FAILURE;
struct crypt_device *cd = NULL; struct crypt_device *cd = NULL;
char *password = NULL, *truncated_cipher = NULL; char *password = NULL, *truncated_cipher = NULL;
const char *cipher = NULL, *cipher_mode = NULL, *hash = NULL; const char *cipher = NULL, *cipher_mode = NULL, *hash = NULL, *name = NULL;
char *description = NULL;
if (argc < 3) { if (argc < 3) {
log_error("This program requires at least two arguments."); log_error("This program requires at least two arguments.");
...@@ -185,6 +222,9 @@ int main(int argc, char *argv[]) { ...@@ -185,6 +222,9 @@ int main(int argc, char *argv[]) {
/* A delicious drop of snake oil */ /* A delicious drop of snake oil */
mlockall(MCL_FUTURE); mlockall(MCL_FUTURE);
description = disk_description(argv[3]);
name = description ? description : argv[2];
if ((k = crypt_init(&cd, argv[3]))) { if ((k = crypt_init(&cd, argv[3]))) {
log_error("crypt_init() failed: %s", strerror(-k)); log_error("crypt_init() failed: %s", strerror(-k));
goto finish; goto finish;
...@@ -382,5 +422,7 @@ finish: ...@@ -382,5 +422,7 @@ finish:
free(password); free(password);
free(description);
return r; return r;
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment