From: John L. Hammond Date: Fri, 28 Aug 2015 18:03:52 +0000 (-0500) Subject: LU-7057 utils: use stronger flags when opening volatile files X-Git-Tag: 2.7.60~54 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=refs%2Fchanges%2F26%2F16126%2F2;p=fs%2Flustre-release.git LU-7057 utils: use stronger flags when opening volatile files Existing files with volatile-ish names may be accidentally opened by llapi_create_volatile(). This is not the intent so disallow this behavior by adding O_EXCL and O_NOFOLLOW to the flags to open(). Signed-off-by: John L. Hammond Change-Id: I4246ec7660b154ea2aeca6c28a4704ddd9d429f8 Reviewed-on: http://review.whamcloud.com/16126 Tested-by: Jenkins Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: Jinshan Xiong --- diff --git a/lustre/utils/liblustreapi.c b/lustre/utils/liblustreapi.c index ea68c7e..5cab621 100644 --- a/lustre/utils/liblustreapi.c +++ b/lustre/utils/liblustreapi.c @@ -4645,7 +4645,9 @@ int llapi_create_volatile_idx(char *directory, int idx, int open_flags) if (rc >= sizeof(file_path)) return -E2BIG; - fd = open(file_path, O_RDWR | O_CREAT | open_flags, S_IRUSR | S_IWUSR); + fd = open(file_path, + O_RDWR | O_CREAT | O_EXCL | O_NOFOLLOW | open_flags, + S_IRUSR | S_IWUSR); if (fd < 0) { llapi_error(LLAPI_MSG_ERROR, errno, "Cannot create volatile file '%s' in '%s'",