Skip to content
Snippets Groups Projects
Commit 92b1a8da authored by Sebastien Ponce's avatar Sebastien Ponce Committed by Steven Murray
Browse files

Fixed error handling. Set serrno in all cases

parent a8e3a291
Branches
Tags
No related merge requests found
......@@ -14,6 +14,7 @@
#include <grp.h>
#include <Cglobals.h>
#include <errno.h>
#include <serrno.h>
#include <Cgrp.h>
#include <osdep.h>
......@@ -49,7 +50,9 @@ CONST char *name;
serrno = SEINTERNAL;
return(NULL);
}
errno = 0;
rc = getgrnam_r(name,grp,grpbuf,grpbuflen,&result);
serrno = ENOENT==errno?SEGROUPUNKN:SEINTERNAL;
return(result);
#endif
}
......@@ -85,7 +88,9 @@ gid_t gid;
serrno = SEINTERNAL;
return(NULL);
}
errno = 0;
rc = getgrgid_r(gid,grp,grpbuf,grpbuflen,&result);
serrno = ENOENT==errno?SEGROUPUNKN:SEINTERNAL;
return(result);
#endif
}
......
......@@ -10,16 +10,26 @@
.P
.BI "struct group *Cgetgrgid(gid_t " gid ");"
.SH ERRORS
If the \fBCthread\fP interface is chosen and activated, the errors value are in the \fBserrno\fP variable.
.SH DESCRIPTION
\fBCgrp\fP is a common Thread-Safe API interface to get entries in the group file vs.
\fBCgrp\fP is a common Thread-Safe API interface to get entries in the group file by
.BI name
or
.BI gid.
.SH RETURN VALUE
These routines return a group struct for the given name/gid.
In case of error, 0 is returned and the \fBserrno\fP variable is set.
.SH ERRORS
possible values for serrno and their meaning :
.TP 1.2i
.B SEGROUPUNKN
the requested group/gid was not found
.TP
.B SEINTERNAL
an error occured while attempting to retrieve the group structure. More details are given in the errno variable.
.SH SEE ALSO
\fBserrno\fP, \fBgetgrnam\fP, \fBgetgrgid\fP
......
......@@ -10,16 +10,26 @@
.P
.BI "struct passwd *Cgetpwuid(uid_t " uid ");"
.SH ERRORS
If the \fBCthread\fP interface is chosen and activated, the errors value are in the \fBserrno\fP variable.
.SH DESCRIPTION
\fBCpwd\fP is a common Thread-Safe API interface to get entries in the password file vs.
\fBCpwd\fP is a common Thread-Safe API interface to get entries in the password file by
.BI name
or
.BI uid.
.SH RETURN VALUE
These routines return a passwd struct for the given name/uid.
In case of error, 0 is returned and the \fBserrno\fP variable is set.
.SH ERRORS
possible values for serrno and their meaning :
.TP 1.2i
.B SEUSERUNKN
the requested user/uid was not found
.TP
.B SEINTERNAL
an error occured while attempting to retrieve the passwd structure. More details are given in the errno variable.
.SH SEE ALSO
\fBserrno\fP, \fBgetpwnam\fP, \fBgetpwuid\fP
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment