Skip to content

Commit 66ec476

Browse files
committed
chpst: remove dependency on prot.h
prot.c provides two functions: prot_gid and prot_uid. prot_gid is fully unused, and depends on {chk,try}shsgr, both of which must be run at build-time and require that the user has additional groups. They are not needed by anything else and their removal gets rid of cross-compilation jank. prot_uid is used (once) by chpst, but since it is a no-op wrapper around setuid(), its use can be replaced by a normal call to setuid(). Solves the big questions from void-linux#11
1 parent 2b8000f commit 66ec476

File tree

10 files changed

+4
-100
lines changed

10 files changed

+4
-100
lines changed

src/Makefile

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -170,12 +170,6 @@ byte_diff.o: byte.h byte_diff.c compile
170170
byte_rchr.o: byte.h byte_rchr.c compile
171171
./compile byte_rchr.c
172172

173-
chkshsgr: chkshsgr.o load
174-
./load chkshsgr
175-
176-
chkshsgr.o: chkshsgr.c compile
177-
./compile chkshsgr.c
178-
179173
choose: choose.sh warn-auto.sh
180174
rm -f choose
181175
cat warn-auto.sh choose.sh \
@@ -232,11 +226,6 @@ hassgact.h: choose compile hassgact.h1 hassgact.h2 load trysgact.c
232226
hassgprm.h: choose compile hassgprm.h1 hassgprm.h2 load trysgprm.c
233227
./choose cl trysgprm hassgprm.h1 hassgprm.h2 > hassgprm.h
234228

235-
hasshsgr.h: chkshsgr choose compile hasshsgr.h1 hasshsgr.h2 load \
236-
tryshsgr.c warn-shsgr
237-
./chkshsgr || ( cat warn-shsgr; exit 1 )
238-
./choose clr tryshsgr hasshsgr.h1 hasshsgr.h2 > hasshsgr.h
239-
240229
haswaitp.h: choose compile haswaitp.h1 haswaitp.h2 load trywaitp.c
241230
./choose cl trywaitp haswaitp.h1 haswaitp.h2 > haswaitp.h
242231

@@ -292,9 +281,6 @@ pathexec_run.o: compile env.h error.h gen_alloc.h pathexec.h \
292281
pathexec_run.c str.h stralloc.h
293282
./compile pathexec_run.c
294283

295-
prot.o: compile hasshsgr.h prot.c prot.h
296-
./compile prot.c
297-
298284
readclose.o: compile error.h gen_alloc.h readclose.c readclose.h \
299285
stralloc.h
300286
./compile readclose.c
@@ -372,7 +358,7 @@ subgetopt.o: compile subgetopt.c subgetopt.h
372358
./compile subgetopt.c
373359

374360
sysdeps: compile direntry.h hasflock.h hasmkffo.h hassgact.h \
375-
hassgprm.h hasshsgr.h haswaitp.h iopause.h load select.h systype \
361+
hassgprm.h haswaitp.h iopause.h load select.h systype \
376362
uint64.h reboot_system.h uw_tmp.h socket.lib
377363
rm -f sysdeps
378364
cat systype compile load socket.lib >>sysdeps
@@ -385,7 +371,6 @@ uint64.h reboot_system.h uw_tmp.h socket.lib
385371
grep sysdep iopause.h >>sysdeps
386372
grep sysdep hasmkffo.h >>sysdeps
387373
grep sysdep hasflock.h >>sysdeps
388-
grep sysdep hasshsgr.h >>sysdeps
389374
grep sysdep reboot_system.h >>sysdeps
390375
grep sysdep uw_tmp.h >>sysdeps
391376
cat sysdeps
@@ -444,7 +429,7 @@ buffer_get.o buffer_put.o buffer_read.o buffer_write.o coe.o env.o \
444429
error.o error_str.o fd_copy.o fd_move.o fifo.o lock_ex.o lock_exnb.o \
445430
makelib ndelay_off.o ndelay_on.o open_append.o open_read.o \
446431
open_trunc.o open_write.o openreadclose.o pathexec_env.o \
447-
pathexec_run.o prot.o readclose.o seek_set.o sgetopt.o sig.o \
432+
pathexec_run.o readclose.o seek_set.o sgetopt.o sig.o \
448433
sig_block.o sig_catch.o sig_pause.o stralloc_cat.o stralloc_catb.o \
449434
stralloc_cats.o stralloc_eady.o stralloc_opyb.o stralloc_opys.o \
450435
stralloc_pend.o strerr_die.o strerr_sys.o subgetopt.o wait_nohang.o \
@@ -454,7 +439,7 @@ wait_pid.o
454439
coe.o env.o error.o error_str.o fd_copy.o fd_move.o fifo.o lock_ex.o \
455440
lock_exnb.o ndelay_off.o ndelay_on.o open_append.o open_read.o \
456441
open_trunc.o open_write.o openreadclose.o pathexec_env.o \
457-
pathexec_run.o prot.o readclose.o seek_set.o sgetopt.o sig.o \
442+
pathexec_run.o readclose.o seek_set.o sgetopt.o sig.o \
458443
sig_block.o sig_catch.o sig_pause.o stralloc_cat.o stralloc_catb.o \
459444
stralloc_cats.o stralloc_eady.o stralloc_opyb.o stralloc_opys.o \
460445
stralloc_pend.o strerr_die.o strerr_sys.o subgetopt.o wait_nohang.o \
@@ -465,4 +450,3 @@ wait_nohang.o: compile haswaitp.h wait_nohang.c
465450

466451
wait_pid.o: compile error.h haswaitp.h wait_pid.c
467452
./compile wait_pid.c
468-

src/TARGETS

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ byte_copy.o
4949
byte_cr.o
5050
byte_diff.o
5151
byte_rchr.o
52-
chkshsgr
53-
chkshsgr.o
5452
choose
5553
coe.o
5654
compile
@@ -68,7 +66,6 @@ hasflock.h
6866
hasmkffo.h
6967
hassgact.h
7068
hassgprm.h
71-
hasshsgr.h
7269
haswaitp.h
7370
iopause.h
7471
iopause.o
@@ -85,7 +82,6 @@ open_write.o
8582
openreadclose.o
8683
pathexec_env.o
8784
pathexec_run.o
88-
prot.o
8985
readclose.o
9086
scan_ulong.o
9187
seek_set.o

src/chkshsgr.c

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/chpst.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#include "strerr.h"
99
#include "str.h"
1010
#include "uidgid.h"
11-
#include "prot.h"
1211
#include "strerr.h"
1312
#include "scan.h"
1413
#include "fmt.h"
@@ -80,7 +79,7 @@ void suidgid(char *user, unsigned int ext) {
8079
}
8180
if (setgroups(ugid.gids, ugid.gid) == -1) fatal("unable to setgroups");
8281
if (setgid(*ugid.gid) == -1) fatal("unable to setgid");
83-
if (prot_uid(ugid.uid) == -1) fatal("unable to setuid");
82+
if (setuid(ugid.uid) == -1) fatal("unable to setuid");
8483
}
8584

8685
void euidgid(char *user, unsigned int ext) {

src/hasshsgr.h1

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/hasshsgr.h2

Lines changed: 0 additions & 4 deletions
This file was deleted.

src/prot.c

Lines changed: 0 additions & 25 deletions
This file was deleted.

src/prot.h

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/tryshsgr.c

Lines changed: 0 additions & 16 deletions
This file was deleted.

src/warn-shsgr

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)