]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
Restore umask after opening file.
authorSimon Josefsson <simon@josefsson.org>
Tue, 20 May 2008 04:59:52 +0000 (06:59 +0200)
committerSimon Josefsson <simon@josefsson.org>
Tue, 20 May 2008 04:59:52 +0000 (06:59 +0200)
Suggested by Daniel Kahn Gillmor <dkg-debian.org@fifthhorseman.net>.

src/certtool.c

index c6aeb2c59a90ccdaaf72da6126872347829e982e..bf0990f7a7f8ab0689cc757fc6894f99e9844373 100644 (file)
@@ -821,12 +821,22 @@ update_signed_certificate (void)
 
 FILE* safe_open_rw(const char* file)
 {
-      if (info.privkey_op != 0) 
-        {
-         umask(S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH);
-        }
+  mode_t oldmask;
+  FILE *fh;
+
+  if (info.privkey_op != 0)
+    {
+      oldmask = umask (S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH);
+    }
+
+  fh = fopen (file, "wb");
+
+  if (info.privkey_op != 0)
+    {
+      umask (oldmask);
+    }
 
-      return fopen (file, "wb");
+  return fh;
 }
 
 void