Require CAP_SEEK if both O_APPEND and O_TRUNC flags are absent.

In other words we don't require CAP_SEEK if either O_APPEND or O_TRUNC flag is
given, because O_APPEND doesn't allow to overwrite existing data and O_TRUNC
requires CAP_FTRUNCATE already.

Sponsored by:	The FreeBSD Foundation
This commit is contained in:
Pawel Jakub Dawidek 2013-03-16 23:19:13 +00:00
parent b48fdae147
commit 943c3bb968

View File

@ -971,7 +971,7 @@ flags_to_rights(int flags)
/* FALLTHROUGH */
case O_WRONLY:
rights |= CAP_WRITE;
if (!(flags & O_APPEND))
if (!(flags & (O_APPEND | O_TRUNC)))
rights |= CAP_SEEK;
break;
}