mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
Remove ENOUSER and ENOGROUP.
The <pwd.h> and <grp.h> family of functions are supposed to return nothing with no error set if there is no matching entry.
This commit is contained in:
parent
7f9a62d916
commit
11be0007b8
11 changed files with 23 additions and 17 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2013 Jonas 'Sortie' Termansen.
|
* Copyright (c) 2013, 2021 Jonas 'Sortie' Termansen.
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
@ -24,6 +24,7 @@
|
||||||
|
|
||||||
struct group* getgrgid(gid_t gid)
|
struct group* getgrgid(gid_t gid)
|
||||||
{
|
{
|
||||||
|
int old_errno = errno;
|
||||||
static struct group result_object;
|
static struct group result_object;
|
||||||
static char* buf = NULL;
|
static char* buf = NULL;
|
||||||
static size_t buflen = 0;
|
static size_t buflen = 0;
|
||||||
|
@ -50,5 +51,6 @@ retry:
|
||||||
}
|
}
|
||||||
if ( errnum < 0 )
|
if ( errnum < 0 )
|
||||||
return errno = errnum, (struct group*) NULL;
|
return errno = errnum, (struct group*) NULL;
|
||||||
|
errno = old_errno;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2013, 2014 Jonas 'Sortie' Termansen.
|
* Copyright (c) 2013, 2014, 2021 Jonas 'Sortie' Termansen.
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
@ -44,5 +44,5 @@ int getgrgid_r(gid_t gid,
|
||||||
return *ret_ptr = *ret_ptr, 0;
|
return *ret_ptr = *ret_ptr, 0;
|
||||||
}
|
}
|
||||||
fclose(fgroup);
|
fclose(fgroup);
|
||||||
return *ret_ptr = NULL, errnum ? errnum : (errno = ENOGROUP);
|
return *ret_ptr = NULL, errnum ? errnum : 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2013 Jonas 'Sortie' Termansen.
|
* Copyright (c) 201, 20213 Jonas 'Sortie' Termansen.
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
@ -24,6 +24,7 @@
|
||||||
|
|
||||||
struct group* getgrnam(const char* groupname)
|
struct group* getgrnam(const char* groupname)
|
||||||
{
|
{
|
||||||
|
int old_errno = errno;
|
||||||
static struct group result_object;
|
static struct group result_object;
|
||||||
static char* buf = NULL;
|
static char* buf = NULL;
|
||||||
static size_t buflen = 0;
|
static size_t buflen = 0;
|
||||||
|
@ -50,5 +51,6 @@ retry:
|
||||||
}
|
}
|
||||||
if ( errnum < 0 )
|
if ( errnum < 0 )
|
||||||
return errno = errnum, (struct group*) NULL;
|
return errno = errnum, (struct group*) NULL;
|
||||||
|
errno = old_errno;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2013, 2014 Jonas 'Sortie' Termansen.
|
* Copyright (c) 2013, 2014, 2021 Jonas 'Sortie' Termansen.
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
@ -45,5 +45,5 @@ int getgrnam_r(const char* restrict groupname,
|
||||||
return *ret_ptr = *ret_ptr, 0;
|
return *ret_ptr = *ret_ptr, 0;
|
||||||
}
|
}
|
||||||
fclose(fgroup);
|
fclose(fgroup);
|
||||||
return *ret_ptr = NULL, errnum ? errnum : (errno = ENOGROUP);
|
return *ret_ptr = NULL, errnum ? errnum : 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,8 +94,6 @@
|
||||||
#define ENFILE 82
|
#define ENFILE 82
|
||||||
#define EPROTOTYPE 83
|
#define EPROTOTYPE 83
|
||||||
#define ENOLCK 84
|
#define ENOLCK 84
|
||||||
#define ENOUSER 85
|
|
||||||
#define ENOGROUP 86
|
|
||||||
#define ESIGPENDING 87
|
#define ESIGPENDING 87
|
||||||
#define ESTALE 88
|
#define ESTALE 88
|
||||||
#define EBADMSG 89
|
#define EBADMSG 89
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2013 Jonas 'Sortie' Termansen.
|
* Copyright (c) 2013, 2021 Jonas 'Sortie' Termansen.
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
@ -24,6 +24,7 @@
|
||||||
|
|
||||||
struct passwd* getpwnam(const char* username)
|
struct passwd* getpwnam(const char* username)
|
||||||
{
|
{
|
||||||
|
int old_errno = errno;
|
||||||
static struct passwd result_object;
|
static struct passwd result_object;
|
||||||
static char* buf = NULL;
|
static char* buf = NULL;
|
||||||
static size_t buflen = 0;
|
static size_t buflen = 0;
|
||||||
|
@ -50,5 +51,6 @@ retry:
|
||||||
}
|
}
|
||||||
if ( errnum < 0 )
|
if ( errnum < 0 )
|
||||||
return errno = errnum, (struct passwd*) NULL;
|
return errno = errnum, (struct passwd*) NULL;
|
||||||
|
errno = old_errno;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2013, 2014 Jonas 'Sortie' Termansen.
|
* Copyright (c) 2013, 2014, 2021 Jonas 'Sortie' Termansen.
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
@ -45,5 +45,5 @@ int getpwnam_r(const char* restrict username,
|
||||||
return *ret_ptr = *ret_ptr, 0;
|
return *ret_ptr = *ret_ptr, 0;
|
||||||
}
|
}
|
||||||
fclose(fpasswd);
|
fclose(fpasswd);
|
||||||
return *ret_ptr = NULL, errnum ? errnum : (errno = ENOUSER);
|
return *ret_ptr = NULL, errnum ? errnum : 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2013 Jonas 'Sortie' Termansen.
|
* Copyright (c) 2013, 2021 Jonas 'Sortie' Termansen.
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
@ -24,6 +24,7 @@
|
||||||
|
|
||||||
struct passwd* getpwuid(uid_t uid)
|
struct passwd* getpwuid(uid_t uid)
|
||||||
{
|
{
|
||||||
|
int old_errno = errno;
|
||||||
static struct passwd result_object;
|
static struct passwd result_object;
|
||||||
static char* buf = NULL;
|
static char* buf = NULL;
|
||||||
static size_t buflen = 0;
|
static size_t buflen = 0;
|
||||||
|
@ -50,5 +51,6 @@ retry:
|
||||||
}
|
}
|
||||||
if ( errnum < 0 )
|
if ( errnum < 0 )
|
||||||
return errno = errnum, (struct passwd*) NULL;
|
return errno = errnum, (struct passwd*) NULL;
|
||||||
|
errno = old_errno;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2013, 2014 Jonas 'Sortie' Termansen.
|
* Copyright (c) 2013, 2014, 2021 Jonas 'Sortie' Termansen.
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
@ -44,5 +44,5 @@ int getpwuid_r(uid_t uid,
|
||||||
return *ret_ptr = *ret_ptr, 0;
|
return *ret_ptr = *ret_ptr, 0;
|
||||||
}
|
}
|
||||||
fclose(fpasswd);
|
fclose(fpasswd);
|
||||||
return *ret_ptr = NULL, errnum ? errnum : (errno = ENOUSER);
|
return *ret_ptr = NULL, errnum ? errnum : 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,8 +97,6 @@ const char* sortix_strerror(int errnum)
|
||||||
case ENFILE: return "Too many open files in system";
|
case ENFILE: return "Too many open files in system";
|
||||||
case EPROTOTYPE: return "Wrong protocol type for socket";
|
case EPROTOTYPE: return "Wrong protocol type for socket";
|
||||||
case ENOLCK: return "No locks available";
|
case ENOLCK: return "No locks available";
|
||||||
case ENOUSER: return "No such user";
|
|
||||||
case ENOGROUP: return "No such group";
|
|
||||||
case ESIGPENDING: return "Signal is already pending";
|
case ESIGPENDING: return "Signal is already pending";
|
||||||
case ESTALE: return "Stale file handle";
|
case ESTALE: return "Stale file handle";
|
||||||
case EBADMSG: return "Bad message";
|
case EBADMSG: return "Bad message";
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2013 Jonas 'Sortie' Termansen.
|
* Copyright (c) 2013, 2021 Jonas 'Sortie' Termansen.
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
@ -44,6 +44,8 @@ int getlogin_r(char* buf, size_t size)
|
||||||
&passwd)) == ERANGE );
|
&passwd)) == ERANGE );
|
||||||
if ( errnum )
|
if ( errnum )
|
||||||
return free(pwdbuf), errno = errnum, -1;
|
return free(pwdbuf), errno = errnum, -1;
|
||||||
|
if ( !passwd )
|
||||||
|
return free(pwdbuf), errno = ENOENT, -1;
|
||||||
|
|
||||||
const char* username = passwd->pw_name;
|
const char* username = passwd->pw_name;
|
||||||
if ( size <= strlcpy(buf, username, size) )
|
if ( size <= strlcpy(buf, username, size) )
|
||||||
|
|
Loading…
Reference in a new issue