Commit Graph

29 Commits (c6a2ebffe5812bf45a17d90208d9bb1044b6dba0)

Author SHA1 Message Date
Đoàn Trần Công Danh 09d2a1605b remove bashism in various boot scripts
When using dash as initramfs shell, the boot process is broken.

Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
2019-01-07 12:01:55 +01:00
Lukas Nykryn 3aa37cafde all: fix issues found by shellcheck
Error: SHELLCHECK_WARNING:
/usr/lib/dracut/dracut-init.sh:939:20: error: Argument to implicit -n is always true due to literal strings. [SC2157]
  937|   dracut_kernel_post() {
  938|       for _f in modules.builtin.bin modules.builtin modules.order; do
  939|->         [[ $srcmods/$_f ]] && inst_simple "$srcmods/$_f" "/lib/modules/$kernel/$_f"
  940|       done
  941|

Error: SHELLCHECK_WARNING:
/usr/lib/dracut/modules.d/98syslog/parse-syslog-opts.sh:18:12: error: This expression is constant. Did you forget a $ somewhere? [SC2078]
   16|       elif [ -e /sbin/syslogd ]; then
   17|           syslogtype="syslogd"
   18|->     elif [ /sbin/syslog-ng ]; then
   19|           syslogtype="syslog-ng"
   20|       else

Error: SHELLCHECK_WARNING:
/usr/lib/dracut/modules.d/90crypt/crypt-lib.sh:15:29: error: Since you double quoted this, it will not word split, and the loop will only run once. [SC2066]
   13|               strstr "$d" "${luks##luks-}" && return 0
   14|               if [ -n "$dev" ]; then
   15|->                 for _dev in "$(devnames $d)"; do
   16|                       [ "$dev" -ef "$_dev" ] && return 0
   17|                   done
2018-03-02 13:41:43 +01:00
Alexander Tsoy 643be55570 crypt: actually put block_uuid.map into initramfs
Also change path to /etc/block_uuid.map.

Fixes: c3b6970394
2018-02-02 11:40:29 +01:00
Harald Hoyer 2187b3d097 crypt-loop: cleanup cleanup procedures
Using initqueue --finished to cleanup stuff is not what the
initqueue/finished hook was meant for.

Move stuff to the real cleanup hook.
2017-07-28 10:43:39 +02:00
Julian Wolf c3b6970394 90crypt: Fixed crypttab_contains() to also work with device path in /etc/crypttab
blkid is not available when this function is called, so block_uuid.map is put into
the initrd, mapping block devices from /etc/crypttab to UUIDs.

This fixes a bug where udev rules were created by mistake as crypttab_contains()
returned false for devices specified by path in /etc/crypttab which resulted in
error messages during boot.

Signed-off-by: Julian Wolf <juwolf@suse.de>
2017-06-27 16:43:47 +02:00
Moritz Maxeiner 1fc68b989d crypt: Support keyfiles embedded in the initrd
For rd.luks.key=keypath:keydev:luksdev, keydev being '/' will
assume the initrd contains the keyfile.
2017-03-30 02:14:31 +02:00
Harald Hoyer 968280e370 crypt: skip crypttab entries with the same device
It was only checked, if the name of the crypttab entry matched.
This patch adds checking, if the device matches.
2015-07-13 10:44:27 +02:00
Harald Hoyer 27c9d1f20f Merge remote-tracking branch 'github/master' 2015-05-18 13:28:00 +02:00
Rusty Bird 04ba461045
Fix ask_for_password bug breaking bash without plymouth
If crypt-lib.sh is sourced from any #!/bin/sh script, a POSIX shell
quirk is in effect that causes variable assignments to "special
builtins" (such as "shift") to leak to their context. So the buggy
code works even despite the missing semicolons.

But if it is sourced by "bash acting under its own name", i.e. from
any #!/bin/bash script, the quirk is disabled, tty_cmd/tty_prompt are
undefined, and ask_for_password doesn't do anything if plymouth is not
present.
2015-04-30 03:25:14 +00:00
Harald Hoyer 6d58fa27a4 change "while read x" to cope with EOF without newline
while read x || [ -n "$x" ]

should do the trick
2015-04-28 11:39:15 +02:00
Harald Hoyer 967cc19ab1 remove all vim and emacs code format comments 2014-08-29 13:38:47 +02:00
Harald Hoyer a13bf117d5 crypt: only manually activate systemd-cryptsetup, if not in crypttab
Only additional rd.luks.UUID have to be manually activated.
2013-08-13 10:26:29 +02:00
Harald Hoyer ca2c693679 Do not call plymouth with full path 2013-04-11 16:08:26 +02:00
Leho Kraav e88e3b2797 91crypt-loop: replace basename calls with string matching 2012-07-25 10:31:43 +02:00
Leho Kraav df68781fca 91crypt-loop: use initqueue for cleanup strategy 2012-07-25 10:31:43 +02:00
Leho Kraav c5758f2090 90crypt: enhance crypt-lib keydev mounting
Combining $keydev and $keypath should result in a unique, re-usable keydev
mountpoint. mkuniqdir doesn't seem to have any an advantage here and lacks
reusability. Is there ever a use case where these are true:

 * there are more than one rd.luks.key=$keypath:$keydev
 * one is actually different from the other
2012-07-25 10:31:43 +02:00
Leho Kraav 3e9b4330a9 90crypt: recognize .img as loop key container 2012-07-25 10:31:43 +02:00
Harald Hoyer 1939a4f96e 99fs-lib/fs-lib.sh: accept "UUID=" and "LABEL=" for fsck_single
with the reuse of crypt-lib.sh devnames() and putting it in
dracut-lib.sh, fsck_single() can use more generic names from /etc/fstab
2011-12-15 08:54:48 +01:00
Amadeusz Żołnowski 581dd40e73 90crypt: ask_for_password pings plymouthd
If plymouthd is not started, ask_for_password shouldn't try to prompt
for password with GUI and should use text prompt instead.
2011-08-19 15:18:04 +02:00
Harald Hoyer 4a049ce556 add x-bit to *.sh 2011-08-12 16:29:28 +02:00
Amadeusz Żołnowski b52294d00b crypt: dropped plymouth --has-active-vt check on passwd prompt
As Ray Strode explains, plymouth --has-active-vt may fail if the user
passes console=ttyS0 or something other not corresponding to
console=tty0, because plymouth is outputing to the serial console and
not a VT in this case.
2011-07-01 10:15:26 +02:00
Harald Hoyer 565f6fb675 crypt/crypt-lib.sh: s/.console.lock/.console_lock/g
In the initrd, the init script and the sbin/cryptroot-ask script use
flock with different lock files for the console: /.console_lock and
/.console.lock respectively
2011-06-17 13:44:08 +02:00
Harald Hoyer 3b403b32fc removed trailing whitespaces 2011-05-10 11:56:09 +02:00
Amadeusz Żołnowski 3909d7edfc crypt: functions for ask-for-password and reading key
Asking for password and reading key parts are moved to separate
functions in crypt-lib.sh: ask_for_password and readkey.
2011-05-06 12:23:52 +02:00
Amadeusz Żołnowski 2f95d699dc crypt-lib.sh: 'command -v' preferred over 'type' 2011-05-06 12:23:51 +02:00
Harald Hoyer c9f1e3d1f4 check for getarg() function before sourcing dracut-lib.sh
make use of "type getarg" to check, if we really need to source
dracut-lib.sh
2011-03-25 16:10:46 +01:00
Amadeusz Żołnowski b20ff981c4 crypt-lib.sh: moved IFS=: from before 'read' to before 'while'
Some versions of dash don't behave as expected with code like this:

while IFS=: read a b c; do
    blah
done

Thanks to Eric Mertens who identified the issue.
2011-03-07 13:56:41 +01:00
Harald Hoyer 91f4d45f93 crypt: change /tmp/luks.keys seperator from "|" to ":"
Do it like on the kernel command line, so we only have one forbidden
character.
2010-11-12 14:11:33 +01:00
Amadeusz Żołnowski 8844cd6b6c 90crypt: probe for keydev asynchronously; changed kernel arg
New kernel argument syntax for LUKS-keydev is introduced:

  rd.luks.key=<key_path>[:<key_dev>[:<luks_dev>]]

Unfolding <key_dev> in BNF:

  <key_dev> ::= "UUID=" <uuid> | "LABEL=" <label> | <kname>

Where <kname> matches following regular expression:

  ^/dev/.*

<kname> need to be a character device and not a symlink for now.

For every rd.luks.key argument udev rule is created.  That rule runs
test to check whether matching device contains <key_path>.  If it does
it's applied to matching <luks_dev>.
2010-11-12 14:08:08 +01:00