elif [ -n "$DEVLINKS" ]; then for link in $DEVLINKS; do if [ "x$link" != "x$src" ]; then continue fi break 2 done
I'm still having trouble with this as I'm reading it :) Maybe my brain is just not in shell mode today, but I believe what we need to have happen here is:
- if $src matches one of the links in $DEVLINKS, we have a match and should mount this device.
- if $src matches none of the links in $DEVLINKS, and also doesn't match $1, skip this line and look for another match in crypttab.
The current patch appears to have the following wrong properties:
- if $DEVLINKS is set but the crypttab line matches the device name instead of one of the links, it will not be processed correctly (because we never get a chance to compare $1 and $src)
- if $src matches none of the links in $DEVLINKS, we'll hit the 'continue' each time through the for loop, so the break will never be hit and we'll (incorrectly) try to process the line
- if $src *does* match one of the links in $DEVLINKS, we will hit the 'break 2' and *not* process *any* more lines in crypttab.
So I think your patch usually works, but only as a side effect. I'll take a crack at the patch here.
elif [ -n "$DEVLINKS" ]; then
for link in $DEVLINKS; do
if [ "x$link" != "x$src" ]; then
continue
fi
break 2
done
I'm still having trouble with this as I'm reading it :) Maybe my brain is just not in shell mode today, but I believe what we need to have happen here is:
- if $src matches one of the links in $DEVLINKS, we have a match and should mount this device.
- if $src matches none of the links in $DEVLINKS, and also doesn't match $1, skip this line and look for another match in crypttab.
The current patch appears to have the following wrong properties:
- if $DEVLINKS is set but the crypttab line matches the device name instead of one of the links, it will not be processed correctly (because we never get a chance to compare $1 and $src)
- if $src matches none of the links in $DEVLINKS, we'll hit the 'continue' each time through the for loop, so the break will never be hit and we'll (incorrectly) try to process the line
- if $src *does* match one of the links in $DEVLINKS, we will hit the 'break 2' and *not* process *any* more lines in crypttab.
So I think your patch usually works, but only as a side effect. I'll take a crack at the patch here.