nightmaremail

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

commit f7b6124770eb34b2e8ff835928cf30e8f6e8d976
parent b75af9b4adebaa3208029df33a82f5fdabf230b0
Author: Alan Post <adp@prgmr.com>
Date:   Mon, 22 Jul 2019 08:40:07 -0600

remove HASSHORTSETGROUPS test, use system headers and types instead.

Diffstat:
MCHANGES | 1+
MMakefile | 19+------------------
MTARGETS | 3---
Mauto_uids.h | 22++++++++++++----------
Dchkshsgr.c | 9---------
Mgid.c | 2+-
Mhier.c | 3++-
Minstcheck.c | 24++++++++++++------------
Minstchown.c | 11++++++-----
Minstpackage.c | 23++++++++++++-----------
Minstuidgid.c | 13+++++++------
Mprot.c | 16+++++-----------
Mqmail-lspawn.c | 10+++++-----
Mqmail-queue.c | 8++++----
Mqmail-rspawn.c | 2+-
Mqmail-showctl.c | 20++++++++++----------
Mqmail-start.c | 12++++++------
Dtryshsgr.c | 14--------------
Muid.c | 2+-
Muidgid.h | 6++++--
Dwarn-shsgr | 3---
21 files changed, 90 insertions(+), 133 deletions(-)

diff --git a/CHANGES b/CHANGES @@ -1,3 +1,4 @@ +20200511 code: remove tryshsgr.c and use uid_t, gid_t types. 20200511 add first unittest, run with "make test" 20191227 fixed possible overflow in alloc() with allocations close to 4GiB 20191226 add missing return types to main() diff --git a/Makefile b/Makefile @@ -332,14 +332,6 @@ check: \ it man ./instcheck -chkshsgr: \ -load chkshsgr.o - ./load chkshsgr - -chkshsgr.o: \ -compile chkshsgr.c exit.h - ./compile chkshsgr.c - chkspawn: \ load chkspawn.o substdio.a error.a str.a fs.a auto_spawn.o ./load chkspawn substdio.a error.a str.a fs.a auto_spawn.o @@ -687,15 +679,6 @@ trysgprm.c compile load && echo \#define HASSIGPROCMASK 1 || exit 0 ) > hassgprm.h rm -f trysgprm.o trysgprm -hasshsgr.h: \ -chkshsgr warn-shsgr tryshsgr.c compile load - ./chkshsgr || ( cat warn-shsgr; exit 1 ) - ( ( ./compile tryshsgr.c \ - && ./load tryshsgr && ./tryshsgr ) >/dev/null 2>&1 \ - && echo \#define HASSHORTSETGROUPS 1 || exit 0 ) > \ - hasshsgr.h - rm -f tryshsgr.o tryshsgr - haswaitp.h: \ trywaitp.c compile load ( ( ./compile trywaitp.c && ./load trywaitp ) >/dev/null \ @@ -1055,7 +1038,7 @@ proc+df.sh conf-qmail chmod 755 proc+df prot.o: \ -compile prot.c hasshsgr.h prot.h +compile prot.c prot.h ./compile prot.c qail: \ diff --git a/TARGETS b/TARGETS @@ -137,9 +137,6 @@ auto_spawn.c auto_spawn.o chkspawn spawn.o -chkshsgr.o -chkshsgr -hasshsgr.h prot.o coe.o cdb_hash.o diff --git a/auto_uids.h b/auto_uids.h @@ -1,16 +1,18 @@ #ifndef AUTO_UIDS_H #define AUTO_UIDS_H -extern int auto_uida; -extern int auto_uidd; -extern int auto_uidl; -extern int auto_uido; -extern int auto_uidp; -extern int auto_uidq; -extern int auto_uidr; -extern int auto_uids; +#include <sys/types.h> -extern int auto_gidn; -extern int auto_gidq; +extern uid_t auto_uida; +extern uid_t auto_uidd; +extern uid_t auto_uidl; +extern uid_t auto_uido; +extern uid_t auto_uidp; +extern uid_t auto_uidq; +extern uid_t auto_uidr; +extern uid_t auto_uids; + +extern gid_t auto_gidn; +extern gid_t auto_gidq; #endif diff --git a/chkshsgr.c b/chkshsgr.c @@ -1,9 +0,0 @@ -#include "exit.h" -void main() -{ - short x[4]; - - x[0] = x[1] = 0; - if (getgroups(1,x) == 0) if (setgroups(1,x) == -1) _exit(1); - _exit(0); -} diff --git a/gid.c b/gid.c @@ -5,7 +5,7 @@ #include "subfd.h" #include "substdio.h" -int +gid_t initgid(char *group) { struct group *gr; diff --git a/hier.c b/hier.c @@ -1,3 +1,4 @@ +#include <sys/types.h> #include "auto_qmail.h" #include "auto_split.h" #include "auto_uids.h" @@ -9,7 +10,7 @@ char buf[100 + FMT_ULONG]; void dsplit(base,uid,mode) char *base; /* must be under 100 bytes */ -int uid; +uid_t uid; int mode; { char *x; diff --git a/instcheck.c b/instcheck.c @@ -18,8 +18,8 @@ char *prefix2; char *prefix3; char *file; int type; -int uid; -int gid; +uid_t uid; +gid_t gid; int mode; { struct stat st; @@ -46,8 +46,8 @@ int mode; void h(home,uid,gid,mode) char *home; -int uid; -int gid; +uid_t uid; +gid_t gid; int mode; { perm("","","",home,S_IFDIR,uid,gid,mode); @@ -56,8 +56,8 @@ int mode; void d(home,subdir,uid,gid,mode) char *home; char *subdir; -int uid; -int gid; +uid_t uid; +gid_t gid; int mode; { if (chdir(home) == -1) @@ -68,8 +68,8 @@ int mode; void p(home,fifo,uid,gid,mode) char *home; char *fifo; -int uid; -int gid; +uid_t uid; +gid_t gid; int mode; { if (chdir(home) == -1) @@ -81,8 +81,8 @@ void c(home,subdir,file,uid,gid,mode) char *home; char *subdir; char *file; -int uid; -int gid; +uid_t uid; +gid_t gid; int mode; { if (chdir(home) == -1) @@ -100,8 +100,8 @@ void z(home,file,len,uid,gid,mode) char *home; char *file; int len; -int uid; -int gid; +uid_t uid; +gid_t gid; int mode; { if (chdir(home) == -1) diff --git a/instchown.c b/instchown.c @@ -1,4 +1,5 @@ #include <sys/stat.h> +#include <sys/types.h> #include <string.h> #include <unistd.h> #include "strerr.h" @@ -10,7 +11,7 @@ extern void hier(); #define FATAL "instchown: fatal: " -void h(char *home, int uid, int gid, int mode) +void h(char *home, uid_t uid, gid_t gid, int mode) { if (chown(home,uid,gid) == -1) strerr_die4sys(111,FATAL,"unable to chown ",home,": "); @@ -18,7 +19,7 @@ void h(char *home, int uid, int gid, int mode) strerr_die4sys(111,FATAL,"unable to chmod ",home,": "); } -void d(char *home, char *subdir, int uid, int gid, int mode) +void d(char *home, char *subdir, uid_t uid, gid_t gid, int mode) { if (chdir(home) == -1) strerr_die4sys(111,FATAL,"unable to switch to ",home,": "); @@ -28,7 +29,7 @@ void d(char *home, char *subdir, int uid, int gid, int mode) strerr_die6sys(111,FATAL,"unable to chmod ",home,"/",subdir,": "); } -void p(char *home, char *fifo, int uid, int gid, int mode) +void p(char *home, char *fifo, uid_t uid, gid_t gid, int mode) { if (chdir(home) == -1) strerr_die4sys(111,FATAL,"unable to switch to ",home,": "); @@ -38,7 +39,7 @@ void p(char *home, char *fifo, int uid, int gid, int mode) strerr_die6sys(111,FATAL,"unable to chmod ",home,"/",fifo,": "); } -void c(char *home, char *subdir, char *file, int uid, int gid, int mode) +void c(char *home, char *subdir, char *file, uid_t uid, gid_t gid, int mode) { if (chdir(home) == -1) strerr_die4sys(111,FATAL,"unable to switch to ",home,": "); @@ -58,7 +59,7 @@ void c(char *home, char *subdir, char *file, int uid, int gid, int mode) strerr_die6sys(111,FATAL,"unable to chmod .../",subdir,"/",file,": "); } -void z(char *home, char *file, int len, int uid, int gid, int mode) +void z(char *home, char *file, int len, uid_t uid, gid_t gid, int mode) { if (chdir(home) == -1) strerr_die4sys(111,FATAL,"unable to switch to ",home,": "); diff --git a/instpackage.c b/instpackage.c @@ -1,4 +1,5 @@ #include <sys/stat.h> +#include <sys/types.h> #include <string.h> #include <unistd.h> #include "substdio.h" @@ -53,7 +54,7 @@ static int mkdir_p(char *home, int mode) return mkdir(home,mode); } -void h(char *home, int uid, int gid, int mode) +void h(char *home, uid_t uid, gid_t gid, int mode) { stralloc dh = { 0 }; ddhome(&dh, home); @@ -66,7 +67,7 @@ void h(char *home, int uid, int gid, int mode) alloc_free(dh.s); } -void d(char *home, char *subdir, int uid, int gid, int mode) +void d(char *home, char *subdir, uid_t uid, gid_t gid, int mode) { stralloc dh = { 0 }; ddhome(&dh, home); @@ -81,7 +82,7 @@ void d(char *home, char *subdir, int uid, int gid, int mode) alloc_free(dh.s); } -void p(char *home, char *fifo, int uid, int gid, int mode) +void p(char *home, char *fifo, uid_t uid, gid_t gid, int mode) { stralloc dh = { 0 }; ddhome(&dh, home); @@ -101,7 +102,7 @@ char outbuf[SUBSTDIO_OUTSIZE]; substdio ssin; substdio ssout; -void c(char *home, char *subdir, char *file, int uid, int gid, int mode) +void c(char *home, char *subdir, char *file, uid_t uid, gid_t gid, int mode) { int fdin; int fdout; @@ -164,7 +165,7 @@ void c(char *home, char *subdir, char *file, int uid, int gid, int mode) alloc_free(dh.s); } -void z(char *home, char *file, int len, int uid, int gid, int mode) +void z(char *home, char *file, int len, uid_t uid, gid_t gid, int mode) { int fdout; stralloc dh = { 0 }; @@ -196,13 +197,13 @@ void z(char *home, char *file, int len, int uid, int gid, int mode) } /* these are ignored, but hier() passes them to h() and friends */ -int auto_uida = -1; -int auto_uido = -1; -int auto_uidq = -1; -int auto_uidr = -1; -int auto_uids = -1; +uid_t auto_uida = -1; +uid_t auto_uido = -1; +uid_t auto_uidq = -1; +uid_t auto_uidr = -1; +uid_t auto_uids = -1; -int auto_gidq = -1; +gid_t auto_gidq = -1; void main() { diff --git a/instuidgid.c b/instuidgid.c @@ -1,14 +1,15 @@ +#include <sys/types.h> #include "uidgid.h" #include "auto_uids.h" #include "auto_users.h" -int auto_uida; -int auto_uido; -int auto_uidq; -int auto_uidr; -int auto_uids; +uid_t auto_uida; +uid_t auto_uido; +uid_t auto_uidq; +uid_t auto_uidr; +uid_t auto_uids; -int auto_gidq; +gid_t auto_gidq; void init_uidgid() diff --git a/prot.c b/prot.c @@ -1,21 +1,15 @@ -#include "hasshsgr.h" +#include <sys/types.h> +#include <unistd.h> +#include <grp.h> #include "prot.h" -/* XXX: there are more portability problems here waiting to leap out at me */ - -int prot_gid(gid) int gid; +int prot_gid(gid) gid_t gid; { -#ifdef HASSHORTSETGROUPS - short x[2]; - x[0] = gid; x[1] = 73; /* catch errors */ - if (setgroups(1,x) == -1) return -1; -#else if (setgroups(1,&gid) == -1) return -1; -#endif return setgid(gid); /* _should_ be redundant, but on some systems it isn't */ } -int prot_uid(uid) int uid; +int prot_uid(uid) uid_t uid; { return setuid(uid); } diff --git a/qmail-lspawn.c b/qmail-lspawn.c @@ -20,10 +20,10 @@ char *aliasempty; -int auto_uidp; -int auto_uidq; +uid_t auto_uidp; +uid_t auto_uidq; -int auto_gidn; +gid_t auto_gidn; void initialize(argc,argv) int argc; @@ -190,8 +190,8 @@ char *s; char *r; int at; char *(args[11]); unsigned long u; int n; - int uid; - int gid; + uid_t uid; + gid_t gid; char *x; unsigned int xlen; diff --git a/qmail-queue.c b/qmail-queue.c @@ -30,7 +30,7 @@ struct substdio ssout; datetime_sec starttime; struct datetime dt; unsigned long mypid; -unsigned long uid; +uid_t uid; char *pidfn; struct stat pidst; unsigned long messnum; @@ -42,9 +42,9 @@ int intdfd; int flagmademess = 0; int flagmadeintd = 0; -int auto_uida; -int auto_uidd; -int auto_uids; +uid_t auto_uida; +uid_t auto_uidd; +uid_t auto_uids; void cleanup() { diff --git a/qmail-rspawn.c b/qmail-rspawn.c @@ -10,7 +10,7 @@ #include "auto_users.h" #include "env.h" -int auto_uidq; +uid_t auto_uidq; void initialize(argc,argv) int argc; diff --git a/qmail-showctl.c b/qmail-showctl.c @@ -24,17 +24,17 @@ int meok; stralloc line = {0}; char num[FMT_ULONG]; -int auto_uida; -int auto_uidd; -int auto_uidl; -int auto_uido; -int auto_uidp; -int auto_uidq; -int auto_uidr; -int auto_uids; +uid_t auto_uida; +uid_t auto_uidd; +uid_t auto_uidl; +uid_t auto_uido; +uid_t auto_uidp; +uid_t auto_uidq; +uid_t auto_uidr; +uid_t auto_uids; -int auto_gidn; -int auto_gidq; +gid_t auto_gidn; +gid_t auto_gidq; void safeput(buf,len) char *buf; diff --git a/qmail-start.c b/qmail-start.c @@ -21,13 +21,13 @@ int pi4[2]; int pi5[2]; int pi6[2]; -int auto_uidl; -int auto_uidq; -int auto_uidr; -int auto_uids; +uid_t auto_uidl; +uid_t auto_uidq; +uid_t auto_uidr; +uid_t auto_uids; -int auto_gidn; -int auto_gidq; +gid_t auto_gidn; +gid_t auto_gidq; void close23456() { close(2); close(3); close(4); close(5); close(6); } diff --git a/tryshsgr.c b/tryshsgr.c @@ -1,14 +0,0 @@ -void main() -{ - short x[4]; - - x[0] = x[1] = 1; - if (getgroups(1,x) == 0) if (setgroups(1,x) == -1) _exit(1); - - if (getgroups(1,x) == -1) _exit(1); - if (x[1] != 1) _exit(1); - x[1] = 2; - if (getgroups(1,x) == -1) _exit(1); - if (x[1] != 2) _exit(1); - _exit(0); -} diff --git a/uid.c b/uid.c @@ -5,7 +5,7 @@ #include "subfd.h" #include "substdio.h" -int +uid_t inituid(char *user) { struct passwd *pw; diff --git a/uidgid.h b/uidgid.h @@ -1,7 +1,9 @@ #ifndef UIDGID_H #define UIDGID_H -extern int inituid(char *uid); -extern int initgid(char *gid); +#include <sys/types.h> + +extern uid_t inituid(char *uid); +extern gid_t initgid(char *gid); #endif diff --git a/warn-shsgr b/warn-shsgr @@ -1,3 +0,0 @@ -Oops. Your getgroups() returned 0, and setgroups() failed; this means -that I can't reliably do my shsgr test. Please either ``make'' as root -or ``make'' while you're in one or more supplementary groups.