Since this file contains secret enforce the read/write permission
limited to the owner only.
Signed-off-by: Daniel Wagner <dwagner@suse.de>
const char *revoke = "Revoke key from the keyring.";
_cleanup_file_ FILE *fd = NULL;
+ mode_t old_umask = 0;
int cnt, err = 0;
struct config {
else
mode = "w";
+ old_umask = umask(0);
+
fd = fopen(cfg.keyfile, mode);
if (!fd) {
nvme_show_error("Cannot open keyfile %s, error %d",
printf("revoking key\n");
}
+ if (old_umask != 0 && fd) {
+ umask(old_umask);
+ chmod(cfg.keyfile, 0600);
+ }
+
return err;
}