runit

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit 0dbfdb9d8587fcbaf9adc2801b8d56b8163e63c0
parent a604bba3aae48efa317aa6f9154c122ebcd6d73c
Author: Morel BĂ©renger <berengermorel76@gmail.com>
Date:   Sun,  6 Oct 2024 17:32:35 +0200

swap prot_uid and setuid

Diffstat:
Msrc/chpst.c | 3+--
Msrc/librunit.ninja | 2--
Dsrc/prot.c | 18------------------
Dsrc/prot.h | 11-----------
4 files changed, 1 insertion(+), 33 deletions(-)

diff --git a/src/chpst.c b/src/chpst.c @@ -10,7 +10,6 @@ #include "strerr.h" #include "str.h" #include "uidgid.h" -#include "prot.h" #include "strerr.h" #include "scan.h" #include "fmt.h" @@ -81,7 +80,7 @@ void suidgid(char *user, unsigned int ext) { } if (setgroups(ugid.gids, ugid.gid) == -1) fatal("unable to setgroups"); if (setgid(*ugid.gid) == -1) fatal("unable to setgid"); - if (prot_uid(ugid.uid) == -1) fatal("unable to setuid"); + if (setuid(ugid.uid) == -1) fatal("unable to setuid"); } void euidgid(char *user, unsigned int ext) { diff --git a/src/librunit.ninja b/src/librunit.ninja @@ -3,7 +3,6 @@ SRC = ./src/ DST = ./build/$PROJECT/src/ #build $DST/fifo.c.o: cc $SRC/fifo.c -build $DST/prot.c.o: cc $SRC/prot.c build $DST/uidgid.c.o: cc $SRC/uidgid.c build $DST/pathexec_env.c.o: cc $SRC/pathexec_env.c build $DST/pathexec_run.c.o: cc $SRC/pathexec_run.c @@ -75,7 +74,6 @@ build $DST/lock_ex.c.o: cc $SRC/lock_ex.c # $DST/fifo.c.o $ build $DST/../$PROJECT.a: ar $ - $DST/prot.c.o $ $DST/uidgid.c.o $ $DST/pathexec_env.c.o $ $DST/pathexec_run.c.o $ diff --git a/src/prot.c b/src/prot.c @@ -1,18 +0,0 @@ -/* Public domain. */ - -#include "prot.h" - -#include <sys/types.h> -#include <unistd.h> -#include <grp.h> - -int prot_gid(gid_t gid) -{ - if (setgroups(1,&gid) == -1) return -1; - return setgid(gid); /* _should_ be redundant, but on some systems it isn't */ -} - -int prot_uid(uid_t uid) -{ - return setuid(uid); -} diff --git a/src/prot.h b/src/prot.h @@ -1,11 +0,0 @@ -/* Public domain. */ - -#ifndef PROT_H -#define PROT_H - -#include <sys/types.h> - -extern int prot_gid(gid_t); -extern int prot_uid(uid_t); - -#endif