diff options
| author | Quentin Carbonneaux | 2022-04-07 11:54:55 +0200 |
|---|---|---|
| committer | Quentin Carbonneaux | 2022-04-07 11:54:55 +0200 |
| commit | fd0859f12150ec535224bffccadc808b3e3b9b7c (patch) | |
| tree | b167dcc7a89f80d2786964071d0ab40de6e25324 | |
| parent | 12d614a845913b79129507e477aba757c81e8c73 (diff) | |
use safer premissions for sdar keys
| -rw-r--r-- | sdar/main.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/sdar/main.c b/sdar/main.c index d07891f..3086f4a 100644 --- a/sdar/main.c +++ b/sdar/main.c @@ -165,23 +165,21 @@ cmd_keygen(int argc, char *argv[]) { char *path, *pass; FILE *f; - int flagf; + mode_t mask; - flagf = 0; ARGBEGIN { - case 'f': - flagf = 1; - break; default: - err("usage: keygen [-h] [-f]"); + err("usage: keygen [-h]"); return 1; } ARGEND path = keypath(); - if (!flagf && access(path, F_OK) == 0) { - err("key file exists, use -f to overwrite"); + if (access(path, F_OK) == 0) { + err("%s already exists", path); return 1; } + mask = umask(0077); f = fopen(path, "w"); + umask(mask); if (!f) { err("could not write key file %s", path); return 1; |
