summaryrefslogtreecommitdiffstats
path: root/usr.sbin/sendmail/test
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/sendmail/test')
-rw-r--r--usr.sbin/sendmail/test/Results65
-rw-r--r--usr.sbin/sendmail/test/t_seteuid.c120
-rw-r--r--usr.sbin/sendmail/test/t_setreuid.c132
3 files changed, 317 insertions, 0 deletions
diff --git a/usr.sbin/sendmail/test/Results b/usr.sbin/sendmail/test/Results
new file mode 100644
index 0000000..d703fe4
--- /dev/null
+++ b/usr.sbin/sendmail/test/Results
@@ -0,0 +1,65 @@
+The following are results of running t_setreuid on various architectures.
+
+OPSYS VERSION STATUS DATE TESTER/NOTES
+===== ======= ====== ==== ============
+
+SunOS 4.1 OK 93.07.19 eric
+SunOS 4.1.2 OK 93.07.19 eric
+SunOS 4.1.3 OK 93.09.25 Robert Elz
+
+BSD 4.4 OK 93.07.19 eric (wierd results, but functional)
+BSD 4.3Utah OK 93.07.19 eric
+
+Ultrix 4.2A OK 93.07.19 eric
+Ultrix 4.3A OK 93.07.19 Allan Johannesen
+
+HP-UX 8.07 OK 93.07.19 eric (on 7xx series)
+HP-UX 8.02 OK 93.07.19 Michael Corrigan (on 8xx series)
+HP-UX 8.00 OK 93.07.21 Michael Corrigan (on 3xx/4xx series)
+HP-UX 9.01 OK 93.11.19 Cassidy (on 7xx series)
+
+Solaris 2.1
+Solaris 2.2 FAIL 93.07.19 Bill Wisner
+
+OSF/1 T1.3-4 OK 93.07.19 eric (on DEC Alpha)
+OSF/1 1.3 OK 94.12.10 Jeff A. Earickson (on Intel Paragon)
+
+CxOS 11.0 OK 93.01.21 Eric Schnoebelen (CxOS 11.0 beta 1)
+CxOS 10.x OK 93.01.21 Eric Schnoebelen
+
+AIX 3.1.5 FAIL 93.08.07 David J. N. Begley
+AIX 3.2.3e FAIL 93.07.26 Steve Bauer <sbauer@silver.sdsmt.edu>
+AIX 3.2.4 FAIL 93.10.07 David J. N. Begley
+AIX 3.2.5 FAIL 94.05.17 Steve Bauer <sbauer@hpcmmib.hpc.sdsmt.edu>
+
+IRIX 4.0.4 OK 93.09.25 Robert Elz
+IRIX 5.2 OK 94.12.06 Mark Andrews <mandrews@alias.com>
+IRIX 5.3 OK 94.12.06 Mark Andrews <mandrews@alias.com>
+
+SCO 3.2v4.0 OK 93.10.02 Peter Wemm (with -lsocket from 3.2v4 devsys)
+
+NeXT 2.1 OK 93.07.28 eric
+NeXT 3.0 OK 34.05.05 Kevin John Wang <kwang@lore.acs.calpoly.edu>
+
+Linux 0.99p10 OK 93.08.08 Karl London
+Linux 0.99p13 OK 93.09.27 Christian Kuhtz
+Linux 0.99p14 OK 93.11.30 Christian Kuhtz <chk@data-hh.Hanse.DE>
+Linux 1.0 OK 94.03.19 Shayne Smith <snsmith@rastus.brisnet.org.au>
+Linux 1.2.13 OK 95.11.02 Sven Neuhaus <sven@ping.de>
+
+BSD/386 1.0 OK 93.11.13 Tony Sanders
+
+DELL 2.2 OK 93.11.15 Peter Wemm (using -DSETEUID)
+
+Pyramid 5.0d OK 95.01.14 David Miller <davem@nadzieja.rutgers.edu>
+
+
+
+The following are results of running t_seteuid on various architectures.
+
+OPSYS VERSION STATUS DATE TESTER/NOTES
+===== ======= ====== ==== ============
+
+Solaris 2.4 OK 95.09.22 Thomas 'Mike' Michlmayr <mike@cosy.sbg.ac.at>
+
+Linux 1.2.13 FAIL 95.11.02 Sven Neuhaus <sven@ping.de>
diff --git a/usr.sbin/sendmail/test/t_seteuid.c b/usr.sbin/sendmail/test/t_seteuid.c
new file mode 100644
index 0000000..4dfe3d6
--- /dev/null
+++ b/usr.sbin/sendmail/test/t_seteuid.c
@@ -0,0 +1,120 @@
+/*
+** This program checks to see if your version of seteuid works.
+** Compile it, make it setuid root, and run it as yourself (NOT as
+** root). If it won't compile or outputs any MAYDAY messages, don't
+** define USESETEUID in conf.h.
+**
+** NOTE: It is not sufficient to have seteuid in your library.
+** You must also have saved uids that function properly.
+**
+** Compilation is trivial -- just "cc t_seteuid.c". Make it setuid,
+** root and then execute it as a non-root user.
+*/
+
+#include <sys/types.h>
+#include <unistd.h>
+#include <stdio.h>
+
+#ifdef __hpux
+#define seteuid(e) setresuid(-1, e, -1)
+#endif
+
+main()
+{
+ int fail = 0;
+ uid_t realuid = getuid();
+
+ printuids("initial uids", realuid, 0);
+
+ if (geteuid() != 0)
+ {
+ printf("SETUP ERROR: re-run setuid root\n");
+ exit(1);
+ }
+
+ if (getuid() == 0)
+ {
+ printf("SETUP ERROR: must be run by a non-root user\n");
+ exit(1);
+ }
+
+ if (seteuid(1) < 0)
+ printf("seteuid(1) failure\n");
+ printuids("after seteuid(1)", realuid, 1);
+
+ if (geteuid() != 1)
+ {
+ fail++;
+ printf("MAYDAY! Wrong effective uid\n");
+ }
+
+ /* do activity here */
+
+ if (seteuid(0) < 0)
+ {
+ fail++;
+ printf("seteuid(0) failure\n");
+ }
+ printuids("after seteuid(0)", realuid, 0);
+
+ if (geteuid() != 0)
+ {
+ fail++;
+ printf("MAYDAY! Wrong effective uid\n");
+ }
+ if (getuid() != realuid)
+ {
+ fail++;
+ printf("MAYDAY! Wrong real uid\n");
+ }
+ printf("\n");
+
+ if (seteuid(2) < 0)
+ {
+ fail++;
+ printf("seteuid(2) failure\n");
+ }
+ printuids("after seteuid(2)", realuid, 2);
+
+ if (geteuid() != 2)
+ {
+ fail++;
+ printf("MAYDAY! Wrong effective uid\n");
+ }
+
+ /* do activity here */
+
+ if (seteuid(0) < 0)
+ {
+ fail++;
+ printf("seteuid(0) failure\n");
+ }
+ printuids("after seteuid(0)", realuid, 0);
+
+ if (geteuid() != 0)
+ {
+ fail++;
+ printf("MAYDAY! Wrong effective uid\n");
+ }
+ if (getuid() != realuid)
+ {
+ fail++;
+ printf("MAYDAY! Wrong real uid\n");
+ }
+
+ if (fail)
+ {
+ printf("\nThis system cannot use seteuid\n");
+ exit(1);
+ }
+
+ exit(0);
+}
+
+printuids(str, r, e)
+ char *str;
+ int r, e;
+{
+ printf("%s (should be %d/%d): r/euid=%d/%d\n", str, r, e,
+ getuid(), geteuid());
+}
diff --git a/usr.sbin/sendmail/test/t_setreuid.c b/usr.sbin/sendmail/test/t_setreuid.c
new file mode 100644
index 0000000..ca9a06f
--- /dev/null
+++ b/usr.sbin/sendmail/test/t_setreuid.c
@@ -0,0 +1,132 @@
+/*
+** This program checks to see if your version of setreuid works.
+** Compile it, make it setuid root, and run it as yourself (NOT as
+** root). If it won't compile or outputs any MAYDAY messages, don't
+** define HASSETREUID in conf.h.
+**
+** Compilation is trivial -- just "cc t_setreuid.c". Make it setuid,
+** root and then execute it as a non-root user.
+*/
+
+#include <sys/types.h>
+#include <unistd.h>
+#include <stdio.h>
+
+#ifdef __hpux
+#define setreuid(r, e) setresuid(r, e, -1)
+#endif
+
+main()
+{
+ int fail = 0;
+ uid_t realuid = getuid();
+
+ printuids("initial uids", realuid, 0);
+
+ if (geteuid() != 0)
+ {
+ printf("SETUP ERROR: re-run setuid root\n");
+ exit(1);
+ }
+
+ if (getuid() == 0)
+ {
+ printf("SETUP ERROR: must be run by a non-root user\n");
+ exit(1);
+ }
+
+ if (setreuid(0, 1) < 0)
+ {
+ fail++;
+ printf("setreuid(0, 1) failure\n");
+ }
+ printuids("after setreuid(0, 1)", 0, 1);
+
+ if (geteuid() != 1)
+ {
+ fail++;
+ printf("MAYDAY! Wrong effective uid\n");
+ }
+
+ /* do activity here */
+
+ if (setreuid(-1, 0) < 0)
+ {
+ fail++;
+ printf("setreuid(-1, 0) failure\n");
+ }
+ printuids("after setreuid(-1, 0)", 0, 0);
+ if (setreuid(realuid, 0) < 0)
+ {
+ fail++;
+ printf("setreuid(%d, 0) failure\n", realuid);
+ }
+ printuids("after setreuid(realuid, 0)", realuid, 0);
+
+ if (geteuid() != 0)
+ {
+ fail++;
+ printf("MAYDAY! Wrong effective uid\n");
+ }
+ if (getuid() != realuid)
+ {
+ fail++;
+ printf("MAYDAY! Wrong real uid\n");
+ }
+ printf("\n");
+
+ if (setreuid(0, 2) < 0)
+ {
+ fail++;
+ printf("setreuid(0, 2) failure\n");
+ }
+ printuids("after setreuid(0, 2)", 0, 2);
+
+ if (geteuid() != 2)
+ {
+ fail++;
+ printf("MAYDAY! Wrong effective uid\n");
+ }
+
+ /* do activity here */
+
+ if (setreuid(-1, 0) < 0)
+ {
+ fail++;
+ printf("setreuid(-1, 0) failure\n");
+ }
+ printuids("after setreuid(-1, 0)", 0, 0);
+ if (setreuid(realuid, 0) < 0)
+ {
+ fail++;
+ printf("setreuid(%d, 0) failure\n", realuid);
+ }
+ printuids("after setreuid(realuid, 0)", realuid, 0);
+
+ if (geteuid() != 0)
+ {
+ fail++;
+ printf("MAYDAY! Wrong effective uid\n");
+ }
+ if (getuid() != realuid)
+ {
+ fail++;
+ printf("MAYDAY! Wrong real uid\n");
+ }
+
+ if (fail)
+ {
+ printf("\nThis system cannot use setreuid\n");
+ exit(1);
+ }
+
+ exit(0);
+}
+
+printuids(str, r, e)
+ char *str;
+ int r, e;
+{
+ printf("%s (should be %d/%d): r/euid=%d/%d\n", str, r, e,
+ getuid(), geteuid());
+}
OpenPOWER on IntegriCloud