From ff4739ceab9b04bdb9f1f6047e0c5da4c7d573bb Mon Sep 17 00:00:00 2001 From: Michael Kerrisk Date: Thu, 8 Aug 2013 15:44:17 +0200 Subject: [PATCH] setfsgid.2: Clarify description of return value More clearly describe the weirdness in the return value of this system call, and ote the problems it creates in in BUGS Reported-by: Oleg Nesterov Signed-off-by: Michael Kerrisk --- man2/setfsgid.2 | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/man2/setfsgid.2 b/man2/setfsgid.2 index caa26e7c1..ea7b872a0 100644 --- a/man2/setfsgid.2 +++ b/man2/setfsgid.2 @@ -28,7 +28,7 @@ .\" Modified, 27 May 2004, Michael Kerrisk .\" Added notes on capability requirements .\" -.TH SETFSGID 2 2010-11-22 "Linux" "Linux Programmer's Manual" +.TH SETFSGID 2 2013-08-08 "Linux" "Linux Programmer's Manual" .SH NAME setfsgid \- set group identity used for filesystem checks .SH SYNOPSIS @@ -67,12 +67,8 @@ matches either the real group ID, effective group ID, saved set-group-ID, or the current value of .IR fsgid . .SH RETURN VALUE -On success, the previous value of -.I fsgid -is returned. -On error, the current value of -.I fsgid -is returned. +On both success and failure, +this call returns the previous filesystem group ID of the caller. .SH VERSIONS This system call is present in Linux since version 1.2. .\" This system call is present since Linux 1.1.44 @@ -102,7 +98,16 @@ The glibc .BR setfsgid () wrapper function transparently deals with the variation across kernel versions. .SH BUGS -No error messages of any kind are returned to the caller. +No error indications of any kind are returned to the caller, +and the fact that both successful and unsuccessful calls return +the same value makes it impossible to directly determine +whether the call succeeded or failed. +Instead, the caller must resort to looking at the return value +from a further call such as +.IR setfsgid(\-1) +(which will always fail), in order to determine if a preceding call to +.BR setfsgid () +changed the filesystem group ID. At the very least, .B EPERM