diff options
Diffstat (limited to 'src/libstddjb')
-rw-r--r-- | src/libstddjb/prot.c | 19 | ||||
-rw-r--r-- | src/libstddjb/prot_grps.c | 27 | ||||
-rw-r--r-- | src/libstddjb/prot_readgroups.c | 27 |
3 files changed, 0 insertions, 73 deletions
diff --git a/src/libstddjb/prot.c b/src/libstddjb/prot.c deleted file mode 100644 index 6714cfb..0000000 --- a/src/libstddjb/prot.c +++ /dev/null @@ -1,19 +0,0 @@ -/* ISC license. */ - -/* MT-unsafe */ - -#include <unistd.h> -#include <pwd.h> -#include <errno.h> -#include <skalibs/djbunix.h> - -int prot_setuidgid (char const *name) -{ - struct passwd *pw = getpwnam(name) ; - if (!pw) - { - if (!errno) errno = ESRCH ; - return 0 ; - } - return !prot_grps(name) && !setgid(pw->pw_gid) && !setuid(pw->pw_uid) ; -} diff --git a/src/libstddjb/prot_grps.c b/src/libstddjb/prot_grps.c deleted file mode 100644 index c5ea35b..0000000 --- a/src/libstddjb/prot_grps.c +++ /dev/null @@ -1,27 +0,0 @@ -/* ISC license. */ - -/* MT-unsafe */ - -#include <unistd.h> -#include <pwd.h> -#include <grp.h> -#include <limits.h> -#include <errno.h> -#include <skalibs/setgroups.h> -#include <skalibs/djbunix.h> - -int prot_grps (char const *name) -{ - gid_t tab[NGROUPS_MAX] ; - struct passwd *pw ; - int n = prot_readgroups(name, tab, NGROUPS_MAX) ; - if (n < 0) return n ; - errno = 0 ; - pw = getpwnam(name) ; - if (!pw) - { - if (!errno) errno = ENOENT ; - return -1 ; - } - return setgroups_and_gid(pw->pw_gid, n, tab) ; -} diff --git a/src/libstddjb/prot_readgroups.c b/src/libstddjb/prot_readgroups.c deleted file mode 100644 index 431cf1c..0000000 --- a/src/libstddjb/prot_readgroups.c +++ /dev/null @@ -1,27 +0,0 @@ -/* ISC license. */ - -/* MT-unsafe */ - -#include <grp.h> -#include <errno.h> -#include <string.h> -#include <skalibs/djbunix.h> - -int prot_readgroups (char const *name, gid_t *tab, unsigned int max) -{ - unsigned int n = 0 ; - for (;;) - { - struct group *gr ; - char **member ; - errno = 0 ; - if (n >= max) break ; - gr = getgrent() ; - if (!gr) break ; - for (member = gr->gr_mem ; *member ; member++) - if (!strcmp(name, *member)) break ; - if (*member) tab[n++] = gr->gr_gid ; - } - endgrent() ; - return errno ? -1 : n ; -} |