[PATCH] cryptsetup: fix close device in ctrl+c handler

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Clemens,

please could you apply this to upstream cryptsetup?

Thanks,
Milan
--
mbroz@xxxxxxxxxx
---

Fix signal handler to proper close device, otherwise if the descriptor
is 0, it keeps device open and temporary-cryptsetup-$PID mapping
is not removed (leaving device open and unusable).

---
 luks/keyencryption.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Index: cryptsetup.my/luks/keyencryption.c
===================================================================
--- cryptsetup.my.orig/luks/keyencryption.c	2008-09-03 13:26:53.000000000 +0200
+++ cryptsetup.my/luks/keyencryption.c	2008-09-03 13:27:31.000000000 +0200
@@ -97,12 +97,13 @@ static int clear_mapping(const char *nam
 /* I miss closures in C! */
 static struct setup_backend *cleaner_backend=NULL;
 static const char *cleaner_name=NULL; 
-static int devfd=0;
+static int devfd=-1;
 
 static void sigint_handler(int sig)
 {
-        if(devfd)
+        if(devfd >= 0)
                 close(devfd);
+        devfd = -1;
         if(cleaner_backend && cleaner_name) 
                 clear_mapping(cleaner_name, cleaner_backend);
         signal(SIGINT, SIG_DFL);
@@ -160,7 +161,7 @@ static int LUKS_endec_template(char *src
 	r = 0;
  out3:
 	close(devfd);
-	devfd = 0;
+	devfd = -1;
  out2:
 	clear_mapping(name,backend);
  out1:



---------------------------------------------------------------------
dm-crypt mailing list - http://www.saout.de/misc/dm-crypt/
To unsubscribe, e-mail: dm-crypt-unsubscribe@xxxxxxxx
For additional commands, e-mail: dm-crypt-help@xxxxxxxx


[Index of Archives]     [Device Mapper Devel]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite News]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux