diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2018-08-01 20:26:05 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2018-08-01 20:26:05 +0000 |
commit | 7bf3e29007350897cb708da01df845f4d58b4173 (patch) | |
tree | 7f6ecb1b4706d955d9bf52f2b3aa7aff11419109 /src | |
parent | e8fe8ed8117bb1a58cd588b295352875d3c08c1a (diff) | |
download | skalibs-7bf3e29007350897cb708da01df845f4d58b4173.tar.xz |
Remove prot
Diffstat (limited to 'src')
-rw-r--r-- | src/include/skalibs/djbunix.h | 6 | ||||
-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 |
4 files changed, 0 insertions, 79 deletions
diff --git a/src/include/skalibs/djbunix.h b/src/include/skalibs/djbunix.h index b8bb85c..d39df3f 100644 --- a/src/include/skalibs/djbunix.h +++ b/src/include/skalibs/djbunix.h @@ -71,12 +71,6 @@ extern void xpathexec0_run (char const *const *, char const *const *) gccattr_no extern void xpathexec (char const *const *) gccattr_noreturn ; extern void xpathexec0 (char const *const *) gccattr_noreturn ; -#define prot_gid(gid) setgid(gid) -#define prot_uid(uid) setuid(uid) -extern int prot_readgroups (char const *, gid_t *, unsigned int) ; -extern int prot_grps (char const *) ; -extern int prot_setuidgid (char const *) ; - extern pid_t wait_nointr (int *) ; extern pid_t waitpid_nointr (pid_t, int *, int) ; #define wait_pid(pid, wstat) waitpid_nointr(pid, (wstat), 0) 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 ; -} |