Skip to contentSkip to conversation

Cryptroot-ask.sh: Use variables consistently

PATCH In review Till Maas 3 participants 4 messages Feb 9, 2014 2 messages not in the archive

lore
Share & tools
lore

Till Maas

author
#0 lore raw

PATCH 1/1 Cryptroot-ask.sh: Use variables consistently

- Always use $luksname instead of sometimes $2
- define $asked_file instead of using the same path twice

---
 modules.d/90crypt/cryptroot-ask.sh | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
modules.d/90crypt/cryptroot-ask.sh +8 -6
index 9665e48..1ab03bc 100755
@@ -8,19 +8,21 @@ NEWROOT=${NEWROOT:-"/sysroot"}
 # do not ask, if we already have root
 [ -f $NEWROOT/proc ] && exit 0
 
+# default luksname - luks-UUID
+luksname=$2
+
 # check if destination already exists
-[ -b /dev/mapper/$2 ] && exit 0
+[ -b /dev/mapper/luksname ] && exit 0
 
 # we already asked for this device
-[ -f /tmp/cryptroot-asked-$2 ] && exit 0
+asked_file=/tmp/cryptroot-asked-$luksname
+[ -f $asked_file ] && exit 0
 
 # load dm_crypt if it is not already loaded
 [ -d /sys/module/dm_crypt ] || modprobe dm_crypt
 
 . /lib/dracut-crypt-lib.sh
 
-# default luksname - luks-UUID
-luksname=$2
 
 # fallback to passphrase
 ask_passphrase=1
@@ -45,7 +47,7 @@ if [ -f /etc/crypttab ] && getargbool 1 rd.luks.crypttab -d -n rd_NO_CRYPTTAB; t
 
         # UUID used in crypttab
         if [ "${dev%%=*}" = "UUID" ]; then
-            if [ "luks-${dev##UUID=}" = "$2" ]; then
+            if [ "luks-${dev##UUID=}" = "$luksname" ]; then
                 luksname="$name"
                 break
             fi
@@ -157,7 +159,7 @@ fi
 unset device luksname luksfile
 
 # mark device as asked
->> /tmp/cryptroot-asked-$2
+>> $asked_file
 
 need_shutdown
 udevsettle
Signature · 1 line
1.8.3.1

A message that is not in the archive (sent off-list or not yet received): 1391933322-17308-1-git-send-email-opensource-44rtNO6TQJOzQB+pC5nmwQ@public.gmane.org

#2 lore raw
Quoted 6 lines · Till Maas

- Always use $luksname instead of sometimes $2
- define $asked_file instead of using the same path twice

---
 modules.d/90crypt/cryptroot-ask.sh | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

Thanks! Pushed.

A message that is not in the archive (sent off-list or not yet received): [email protected]

author
#4 lore raw
Quoted 9 lines · Harald Hoyer
Quoted 6 lines · Till Maas

- Always use $luksname instead of sometimes $2
- define $asked_file instead of using the same path twice

---
 modules.d/90crypt/cryptroot-ask.sh | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

Thanks! Pushed.

Thank you. Unluckily the patch did not apply as intended since someone else did some similar changes since I created the patch. Please apply the patch I just sent to the mailing list to clean this up. Sorry for the trouble.

Regards
Till

#5 lore raw
In reply to a message not in the archive
Quoted 17 lines · On Sun Feb  9 12:08:42 2014 Till Maas <opensource-44rtNO6TQJOzQB+pC5nmwQ@publi…

- Always use $luksname instead of sometimes $2
- define $asked_file instead of using the same path twice
---
  modules.d/90crypt/cryptroot-ask.sh | 14 ++++++++------

   1 file changed, 8 insertions(+), 6 deletions(-)
(quoted diff) +0 -0

b/modules.d/90crypt/cryptroot-ask.sh index 9665e48..1ab03bc 100755

modules.d/90crypt/cryptroot-ask.sh +0 -0
@@ -8,19 +8,21 @@ NEWROOT=${NEWROOT:-"/sysroot"}
    # do not ask, if we already have root

  [ -f $NEWROOT/proc ] && exit 0

modules.d/90crypt/cryptroot-ask.sh +3 -0
+# default luksname - luks-UUID
+luksname=$2
+
Quoted 3 lines
   # check if destination already exists
-[ -b /dev/mapper/$2 ] && exit 0
+[ -b /dev/mapper/luksname ] && exit 0

Here is a typo.

[ -b /dev/mapper/$luksname ] && exit 0

Quoted 41 lines

   # we already asked for this device
-[ -f /tmp/cryptroot-asked-$2 ] && exit 0
+asked_file=/tmp/cryptroot-asked-$luksname
+[ -f $asked_file ] && exit 0
   
   # load dm_crypt if it is not already loaded
   [ -d /sys/module/dm_crypt ] || modprobe dm_crypt
   
   . /lib/dracut-crypt-lib.sh
   
modules.d/90crypt/cryptroot-ask.sh +0 -2
-# default luksname - luks-UUID
-luksname=$2

   # fallback to passphrase
   ask_passphrase=1
modules.d/90crypt/cryptroot-ask.sh +0 -0
@@ -45,7 +47,7 @@ if [ -f /etc/crypttab ] && getargbool 1

rd.luks.crypttab -d -n rd_NO_CRYPTTAB; t
                  # UUID used in crypttab
                  if [ "${dev%%=*}" = "UUID" ]; then
-                      if [ "luks-${dev##UUID=}" = "$2" ]; then +                      if [ "luks-${dev##UUID=}" = "$luksname" ]; then luksname="$name"
                                  break
                          fi

modules.d/90crypt/cryptroot-ask.sh +0 -0
@@ -157,7 +159,7 @@ fi

  unset device luksname luksfile

   # mark device as asked
->> /tmp/cryptroot-asked-$2
+>> $asked_file
   
   need_shutdown
   udevsettle
Signature · 6 lines
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe initramfs" in
the body of a message to [email protected]
More majordomo info at   http://vger.kernel.org/majordomo-info.html
Signature · 1 line
Alexander Tsoy