mirror of
https://github.com/angt/secret
synced 2024-11-16 19:48:05 +01:00
Locking the whole file is useless
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
This commit is contained in:
parent
ce473cdbbc
commit
505006583f
1 changed files with 7 additions and 9 deletions
16
secret.c
16
secret.c
|
@ -218,15 +218,6 @@ s_open_secret(int use_tty, int flags)
|
|||
if (s.hdr.version != S_VER_MAJOR)
|
||||
s_fatal("Unkown version %" PRIu8, s.hdr.version);
|
||||
|
||||
if (flags == O_RDWR) {
|
||||
struct flock fl = {
|
||||
.l_type = F_WRLCK,
|
||||
.l_whence = SEEK_SET,
|
||||
};
|
||||
if (fcntl(fd, F_SETLKW, &fl))
|
||||
s_fatal("Unable to lock %s", s.path);
|
||||
}
|
||||
|
||||
const char *agent = getenv(S_ENV_AGENT);
|
||||
int wfd = -1, rfd = -1;
|
||||
|
||||
|
@ -331,6 +322,13 @@ s_set_secret(int fd, const char *key, const unsigned char *secret, size_t slen)
|
|||
hydro_secretbox_encrypt(s.enc,
|
||||
&s.x.entry, sizeof(s.x.entry), 0,
|
||||
s.ctx_secret, s.x.key);
|
||||
struct flock fl = {
|
||||
.l_type = F_WRLCK,
|
||||
.l_whence = SEEK_CUR,
|
||||
.l_len = (off_t)sizeof(s.enc),
|
||||
};
|
||||
if (fcntl(fd, F_SETLK, &fl))
|
||||
s_fatal("Unable to lock %s", s.path);
|
||||
|
||||
s_write(fd, s.enc, sizeof(s.enc));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue