Warn is passphrase file is world-readable
This commit is contained in:
parent
41a74402f0
commit
a3079f5eda
11
puer.c
11
puer.c
|
@ -546,6 +546,17 @@ ssize_t passphrase_prompt(unsigned char *passphrase, size_t size, const char *pr
|
|||
ssize_t passphrase_file(char *passfilepath, unsigned char passphrase[], size_t size) {
|
||||
int file = open(passfilepath, O_RDONLY);
|
||||
|
||||
// Check permissions
|
||||
struct stat statbuf;
|
||||
if (fstat(file, &statbuf) != 0) {
|
||||
perror("Could not stat passphrase file");
|
||||
close(file);
|
||||
return -1;
|
||||
}
|
||||
if (statbuf.st_mode & S_IROTH) {
|
||||
fprintf(stderr, "Warning: Passphrase file is world-readable\n");
|
||||
}
|
||||
|
||||
// Read until newline
|
||||
size_t index = 0;
|
||||
for (;;) {
|
||||
|
|
Loading…
Reference in New Issue