[systemd-commits] 2 commits - man/crypttab.xml shell-completion/bash src/cryptsetup
Zbigniew Jędrzejewski-Szmek
zbyszek at kemper.freedesktop.org
Thu Jan 8 13:34:14 PST 2015
man/crypttab.xml | 12 +++++++++
shell-completion/bash/systemd-nspawn | 40 +++++++++++++++++++++++++++----
src/cryptsetup/cryptsetup.c | 44 ++++++++++++++++++++++++++++++++---
3 files changed, 87 insertions(+), 9 deletions(-)
New commits:
commit 8c5463585df633ca302824559888b62de5b4ba20
Author: Carlos Morata Castillo <cmc809 at inlumine.ual.es>
Date: Thu Jan 8 21:51:49 2015 +0100
bash-completion: systemd-nspawn update
*Autocompletion for dirs, doesn't leave until you press space.
*Added tmpfs, volatile and network-macvlan options.
I tried with the SELinux options with seinfo(setools-console), but too
messy to get it right. Even Daniel Walsh haven't done it yet. :)
diff --git a/shell-completion/bash/systemd-nspawn b/shell-completion/bash/systemd-nspawn
index f911d1b..83e34ef 100644
--- a/shell-completion/bash/systemd-nspawn
+++ b/shell-completion/bash/systemd-nspawn
@@ -34,6 +34,20 @@ __get_slices() {
systemctl list-units -t slice --no-legend --no-pager | { while read a b; do echo " $a"; done; };
}
+__get_machines() {
+ local a b
+ machinectl list --no-legend --no-pager | { while read a b; do echo " $a"; done; };
+}
+
+__get_env() {
+ local a
+ env | { while read a; do echo " ${a%%=*}"; done; };
+}
+
+__get_interfaces(){
+ cut -f 1 -d ' ' /proc/net/dev | tail -n +3 | tr -s '\n' | tr -d ':' | xargs
+}
+
_systemd_nspawn() {
local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
local i verb comps
@@ -42,7 +56,8 @@ _systemd_nspawn() {
[STANDALONE]='-h --help --version --private-network -b --boot --read-only -q --quiet --share-system --keep-unit --network-veth -j'
[ARG]='-D --directory -u --user --uuid --capability --drop-capability --link-journal --bind --bind-ro -M --machine
-S --slice --setenv -Z --selinux-context -L --selinux-apifs-context --register --network-interface --network-bridge
- --personality -i --image'
+ --personality -i --image --tmpfs --volatile
+ --network-macvlan'
)
_init_completion || return
@@ -50,7 +65,8 @@ _systemd_nspawn() {
if __contains_word "$prev" ${OPTS[ARG]}; then
case $prev in
--directory|-D)
- comps=$(compgen -A directory -- "$cur" )
+ compopt -o nospace
+ comps=$(compgen -S/ -A directory -- "$cur" )
;;
--user|-u)
comps=$( __get_users )
@@ -72,16 +88,21 @@ _systemd_nspawn() {
comps='no auto guest host'
;;
--bind|--bind-ro)
- comps=''
+ compopt -o nospace
+ comps=$(compgen -S/ -A directory -- "$cur" )
+ ;;
+ --tmpfs)
+ compopt -o nospace
+ comps=$(compgen -S/ -A directory -- "$cur" )
;;
--machine|-M)
- comps=''
+ comps=$( __get_machines )
;;
--slice|-S)
comps=$( __get_slices )
;;
--setenv)
- comps=''
+ comps=$( __get_env )
;;
--selinux-context|-Z)
comps=''
@@ -93,15 +114,22 @@ _systemd_nspawn() {
comps='yes no'
;;
--network-interface)
- comps=''
+ comps=$(__get_interfaces)
;;
--network-bridge)
comps=''
;;
+ --network-macvlan)
+ comps=''
+ ;;
--personality)
comps='x86 x86-64'
;;
+ --volatile)
+ comps='yes state no'
+ ;;
--image|-i)
+ compopt -o nospace
comps=$( compgen -A file -- "$cur" )
;;
esac
commit 7376e835289a3f97174a641a1ca4b7dbda997030
Author: Andrey Chaser <chaser.andrey at gmail.com>
Date: Thu Jan 8 16:21:06 2015 -0500
cryptsetup: support header= option
https://bugs.freedesktop.org/show_bug.cgi?id=66396
diff --git a/man/crypttab.xml b/man/crypttab.xml
index 42caf34..737b232 100644
--- a/man/crypttab.xml
+++ b/man/crypttab.xml
@@ -142,6 +142,18 @@
</varlistentry>
<varlistentry>
+ <term><option>header=</option></term>
+
+ <listitem><para>Use a detached (separated)
+ metadata device or file where the LUKS header
+ is stored. This option is only relevant for
+ LUKS devices. See
+ <citerefentry><refentrytitle>cryptsetup</refentrytitle><manvolnum>8</manvolnum></citerefentry>
+ for possible values and the default value of
+ this option.</para></listitem>
+ </varlistentry>
+
+ <varlistentry>
<term><option>keyfile-offset=</option></term>
<listitem><para>Specifies the number of bytes to
diff --git a/src/cryptsetup/cryptsetup.c b/src/cryptsetup/cryptsetup.c
index 21b1260..15dea7b 100644
--- a/src/cryptsetup/cryptsetup.c
+++ b/src/cryptsetup/cryptsetup.c
@@ -43,6 +43,7 @@ static int arg_key_slot = CRYPT_ANY_SLOT;
static unsigned arg_keyfile_size = 0;
static unsigned arg_keyfile_offset = 0;
static char *arg_hash = NULL;
+static char *arg_header = NULL;
static unsigned arg_tries = 3;
static bool arg_readonly = false;
static bool arg_verify = false;
@@ -136,6 +137,23 @@ static int parse_one_option(const char *option) {
free(arg_hash);
arg_hash = t;
+ } else if (startswith(option, "header=")) {
+ arg_type = CRYPT_LUKS1;
+
+ if (!path_is_absolute(option+7)) {
+ log_error("Header path '%s' is not absolute, refusing.", option+7);
+ return -EINVAL;
+ }
+
+ if (arg_header) {
+ log_error("Duplicate header= options, refusing.");
+ return -EINVAL;
+ }
+
+ arg_header = strdup(option+7);
+ if (!arg_header)
+ return log_oom();
+
} else if (startswith(option, "tries=")) {
if (safe_atou(option+6, &arg_tries) < 0) {
@@ -375,6 +393,7 @@ static int attach_tcrypt(struct crypt_device *cd,
static int attach_luks_or_plain(struct crypt_device *cd,
const char *name,
const char *key_file,
+ const char *data_device,
char **passwords,
uint32_t flags) {
int r = 0;
@@ -384,8 +403,16 @@ static int attach_luks_or_plain(struct crypt_device *cd,
assert(name);
assert(key_file || passwords);
- if (!arg_type || streq(arg_type, CRYPT_LUKS1))
+ if (!arg_type || streq(arg_type, CRYPT_LUKS1)) {
r = crypt_load(cd, CRYPT_LUKS1, NULL);
+ if (r < 0) {
+ log_error("crypt_load() failed on device %s.\n", crypt_get_device_name(cd));
+ return r;
+ }
+
+ if (data_device)
+ r = crypt_set_data_device(cd, data_device);
+ }
if ((!arg_type && r < 0) || streq_ptr(arg_type, CRYPT_PLAIN)) {
struct crypt_params_plain params = {};
@@ -559,7 +586,12 @@ int main(int argc, char *argv[]) {
}
name = name_buffer ? name_buffer : argv[2];
- k = crypt_init(&cd, argv[3]);
+ if (arg_header) {
+ log_debug("LUKS header: %s", arg_header);
+ k = crypt_init(&cd, arg_header);
+ } else
+ k = crypt_init(&cd, argv[3]);
+
if (k) {
log_error_errno(k, "crypt_init() failed: %m");
goto finish;
@@ -610,7 +642,12 @@ int main(int argc, char *argv[]) {
if (streq_ptr(arg_type, CRYPT_TCRYPT))
k = attach_tcrypt(cd, argv[2], key_file, passwords, flags);
else
- k = attach_luks_or_plain(cd, argv[2], key_file, passwords, flags);
+ k = attach_luks_or_plain(cd,
+ argv[2],
+ key_file,
+ arg_header ? argv[3] : NULL,
+ passwords,
+ flags);
if (k >= 0)
break;
else if (k == -EAGAIN) {
@@ -661,6 +698,7 @@ finish:
free(arg_cipher);
free(arg_hash);
+ free(arg_header);
strv_free(arg_tcrypt_keyfiles);
return r;
More information about the systemd-commits
mailing list