DM-Crypt Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [dm-crypt] [PATCH] When reading no single byte for the key abort.
@ 2009-09-25  7:21 Ludwig Nussel
  2009-09-28 18:51 ` Milan Broz
  0 siblings, 1 reply; 6+ messages in thread
From: Ludwig Nussel @ 2009-09-25  7:21 UTC (permalink / raw)
  To: dm-crypt; +Cc: Ludwig Nussel

Allows keyscripts that pipe into cryptsetup to quit due to e.g. a
timeout or user pressing ^D.

Signed-off-by: Ludwig Nussel <ludwig.nussel@suse.de>
---
 lib/utils.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/lib/utils.c b/lib/utils.c
index 05d33cd..25f7714 100644
--- a/lib/utils.c
+++ b/lib/utils.c
@@ -490,6 +490,8 @@ void get_key(char *prompt, char **key, unsigned int *passLen, int key_size,
 		}
 		if(key_file)
 			close(fd);
+		if(!i) // we didn't read anything, user pressed ^D?
+			goto out_err;
 		pass[i] = 0;
 		*key = pass;
 		*passLen = i;
-- 
1.6.2.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [dm-crypt] [PATCH] When reading no single byte for the key abort.
  2009-09-25  7:21 [dm-crypt] [PATCH] When reading no single byte for the key abort Ludwig Nussel
@ 2009-09-28 18:51 ` Milan Broz
  2009-09-29  9:25   ` Ludwig Nussel
  2009-09-29 10:03   ` anton ivanov
  0 siblings, 2 replies; 6+ messages in thread
From: Milan Broz @ 2009-09-28 18:51 UTC (permalink / raw)
  To: Ludwig Nussel; +Cc: dm-crypt

Ludwig Nussel wrote:
> Allows keyscripts that pipe into cryptsetup to quit due to e.g. a
> timeout or user pressing ^D.

> @@ -490,6 +490,8 @@ void get_key(char *prompt, char **key, unsigned int *passLen, int key_size,
>  		}
>  		if(key_file)
>  			close(fd);
> +		if(!i) // we didn't read anything, user pressed ^D?
> +			goto out_err;

there are two situations which with this patch fails now:

if the key-file is empty (but regular) file, it should not fail here, I mean:
	touch empty
	cryptsetup luksOpen ... --key-file=empty

You probably mean to fix only this situation (it should fail if piped input is closed
and not try empty passphrase)
	$(sleep 1) | cryptsetup luksOpen ...

I committed modified patch (see svn), please verify that it fixes reported problem.

Thanks,
Milan
--
mbroz@redhat.com

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dm-crypt] [PATCH] When reading no single byte for the key abort.
  2009-09-28 18:51 ` Milan Broz
@ 2009-09-29  9:25   ` Ludwig Nussel
  2009-09-29 10:03   ` anton ivanov
  1 sibling, 0 replies; 6+ messages in thread
From: Ludwig Nussel @ 2009-09-29  9:25 UTC (permalink / raw)
  To: dm-crypt

Milan Broz wrote:
> Ludwig Nussel wrote:
> > Allows keyscripts that pipe into cryptsetup to quit due to e.g. a
> > timeout or user pressing ^D.
> 
> > @@ -490,6 +490,8 @@ void get_key(char *prompt, char **key, unsigned int *passLen, int key_size,
> >  		}
> >  		if(key_file)
> >  			close(fd);
> > +		if(!i) // we didn't read anything, user pressed ^D?
> > +			goto out_err;
> 
> there are two situations which with this patch fails now:
> 
> if the key-file is empty (but regular) file, it should not fail here, I mean:
> 	touch empty
> 	cryptsetup luksOpen ... --key-file=empty

Hmm, does an empty key file have any use in practice?

cu
Ludwig

-- 
 (o_   Ludwig Nussel
 //\   
 V_/_  http://www.suse.de/
SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nuernberg)

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dm-crypt] [PATCH] When reading no single byte for the key abort.
  2009-09-28 18:51 ` Milan Broz
  2009-09-29  9:25   ` Ludwig Nussel
@ 2009-09-29 10:03   ` anton ivanov
  2009-09-29 10:04     ` anton ivanov
  2009-09-29 10:23     ` Milan Broz
  1 sibling, 2 replies; 6+ messages in thread
From: anton ivanov @ 2009-09-29 10:03 UTC (permalink / raw)
  To: Milan Broz, dm-crypt

Hey,

what are you talking about? I tried with empty file as passphrase,
surely not working :)

On Mon, Sep 28, 2009 at 9:51 PM, Milan Broz <mbroz@redhat.com> wrote:
> Ludwig Nussel wrote:
>> Allows keyscripts that pipe into cryptsetup to quit due to e.g. a
>> timeout or user pressing ^D.
>
>> @@ -490,6 +490,8 @@ void get_key(char *prompt, char **key, unsigned int *passLen, int key_size,
>>               }
>>               if(key_file)
>>                       close(fd);
>> +             if(!i) // we didn't read anything, user pressed ^D?
>> +                     goto out_err;
>
> there are two situations which with this patch fails now:
>
> if the key-file is empty (but regular) file, it should not fail here, I mean:
>        touch empty
>        cryptsetup luksOpen ... --key-file=empty
>
> You probably mean to fix only this situation (it should fail if piped input is closed
> and not try empty passphrase)
>        $(sleep 1) | cryptsetup luksOpen ...
>
> I committed modified patch (see svn), please verify that it fixes reported problem.
>
> Thanks,
> Milan
> --
> mbroz@redhat.com
>
> _______________________________________________
> dm-crypt mailing list
> dm-crypt@saout.de
> http://www.saout.de/mailman/listinfo/dm-crypt
>



-- 
ai.

http://biwwy.com/
last.fm: littlewizard

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dm-crypt] [PATCH] When reading no single byte for the key abort.
  2009-09-29 10:03   ` anton ivanov
@ 2009-09-29 10:04     ` anton ivanov
  2009-09-29 10:23     ` Milan Broz
  1 sibling, 0 replies; 6+ messages in thread
From: anton ivanov @ 2009-09-29 10:04 UTC (permalink / raw)
  To: Milan Broz, dm-crypt

Oh, sorry, not get used for mailing list :)

On Tue, Sep 29, 2009 at 1:03 PM, anton ivanov
<run.into.flowers@gmail.com> wrote:
> Hey,
>
> what are you talking about? I tried with empty file as passphrase,
> surely not working :)
>
> On Mon, Sep 28, 2009 at 9:51 PM, Milan Broz <mbroz@redhat.com> wrote:
>> Ludwig Nussel wrote:
>>> Allows keyscripts that pipe into cryptsetup to quit due to e.g. a
>>> timeout or user pressing ^D.
>>
>>> @@ -490,6 +490,8 @@ void get_key(char *prompt, char **key, unsigned int *passLen, int key_size,
>>>               }
>>>               if(key_file)
>>>                       close(fd);
>>> +             if(!i) // we didn't read anything, user pressed ^D?
>>> +                     goto out_err;
>>
>> there are two situations which with this patch fails now:
>>
>> if the key-file is empty (but regular) file, it should not fail here, I mean:
>>        touch empty
>>        cryptsetup luksOpen ... --key-file=empty
>>
>> You probably mean to fix only this situation (it should fail if piped input is closed
>> and not try empty passphrase)
>>        $(sleep 1) | cryptsetup luksOpen ...
>>
>> I committed modified patch (see svn), please verify that it fixes reported problem.
>>
>> Thanks,
>> Milan
>> --
>> mbroz@redhat.com
>>
>> _______________________________________________
>> dm-crypt mailing list
>> dm-crypt@saout.de
>> http://www.saout.de/mailman/listinfo/dm-crypt
>>
>
>
>
> --
> ai.
>
> http://biwwy.com/
> last.fm: littlewizard
>



-- 
ai.

http://biwwy.com/
last.fm: littlewizard

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dm-crypt] [PATCH] When reading no single byte for the key abort.
  2009-09-29 10:03   ` anton ivanov
  2009-09-29 10:04     ` anton ivanov
@ 2009-09-29 10:23     ` Milan Broz
  1 sibling, 0 replies; 6+ messages in thread
From: Milan Broz @ 2009-09-29 10:23 UTC (permalink / raw)
  To: anton ivanov; +Cc: dm-crypt

anton ivanov wrote:
> what are you talking about? I tried with empty file as passphrase,
> surely not working :)

I didn't say that empty keyfile can be used as real passphrase (in luksFormat),
but the verification (luksOpen) will fail with "No key available with this passphrase"
and with the patch it fails with different error - error during reading key.

I can imagine that some scripts can depend on this behaviour and
there is no real need to change it.
When you enter empty string from terminal, it does the same.

Milan

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-09-29 10:23 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-25  7:21 [dm-crypt] [PATCH] When reading no single byte for the key abort Ludwig Nussel
2009-09-28 18:51 ` Milan Broz
2009-09-29  9:25   ` Ludwig Nussel
2009-09-29 10:03   ` anton ivanov
2009-09-29 10:04     ` anton ivanov
2009-09-29 10:23     ` Milan Broz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox