]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 2766] ntp-keygen output files should not be world-readable
authorHarlan Stenn <stenn@ntp.org>
Sat, 28 Feb 2015 11:28:04 +0000 (11:28 +0000)
committerHarlan Stenn <stenn@ntp.org>
Sat, 28 Feb 2015 11:28:04 +0000 (11:28 +0000)
bk: 54f1a644dvmU_20LIYcuNn9Tw3XFeA

ChangeLog
util/ntp-keygen.c

index 8c722fb6ccf79a788b519f043bd7085853de2c78..8f880f4ee5f9af169ca23d3b5e0a6d2193f450cb 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,7 @@
 * [Bug 2756] ntpd hangs in startup with gcc 3.3.5 on ARM.
 * [Bug 2757] Quiet compiler warnings.
 * [Bug 2759] Expose nonvolatile/clk_wander_threshold to ntpq.
+* [Bug 2766] ntp-keygen output files should not be world-readable.
 ---
 (4.2.8p1) 2015/02/04 Released by Harlan Stenn <stenn@ntp.org>
 
index c16902161297e550c5022c7f369e244ef7bb4c45..7eb15abee2bd64e922964c50d5a92e38b6578774 100644 (file)
@@ -2170,10 +2170,14 @@ fheader (
        FILE    *str;           /* file handle */
        char    linkname[MAXFILENAME]; /* link name */
        int     temp;
+        mode_t  orig_umask;
 
        snprintf(filename, sizeof(filename), "ntpkey_%s_%s.%u", file,
            owner, fstamp); 
-       if ((str = fopen(filename, "w")) == NULL) {
+        orig_umask = umask( S_IWGRP | S_IRWXO );
+        str = fopen(filename, "w");
+        (void) umask(orig_umask);
+       if (str == NULL) {
                perror("Write");
                exit (-1);
        }