diff -r -c mailx-5.3a/README mailx-5.3b/README *** mailx-5.3a/README Thu Apr 1 22:54:49 1993 --- mailx-5.3b/README Wed Jun 30 01:32:28 1993 *************** *** 1,4 **** --- 1,20 ---- + (Copyright (C) 1993 Ian Jackson. + Copyright (C) Scott Adkins. + Copyright (C) The Regents of the University of California, Berkeley. + This program, a derivative work of mailx-5.3a, itself a derivative of + BSD mailx, both of which are under the BSD copyright, is hereby placed + under the protection of the GNU General Public Licence, version 2 or + later, at your option. + + See the file COPYING in your Linux distribution and the copyright + notices at the top of the C source files for more details. + + Note that this program comes with NO WARRANTY. + + - Ian Jackson , 30th June 1993). + + Well, after getting sick of the original mail program that was supplied by the SLS distribution, and the fact that I prefer *not* to use menu operated mail programs such as Elm, I then decided to port the Berkeley Mail program, *************** *** 28,36 **** To install: 1) If you are just installing the binaries, then change to the "bin" ! directory (while su or root) and type "make install". The binaries ! were statically linked, so there should be no problems with the ! version of the shared libraries you are using. 2) If you wish to recompile the sources before installing, then change to the "src" directory and type "make". Once the sources --- 44,54 ---- To install: 1) If you are just installing the binaries, then change to the "bin" ! directory (while su or root) and type "make install". There ! is a statically linked binary (Mail-static), in case you have ! problems with the version of the shared libraries you are using. ! Otherwise I recommend you delete Mail-static and use the ! dynamically linked version - you'll need libc.4.3.3 or above. 2) If you wish to recompile the sources before installing, then change to the "src" directory and type "make". Once the sources *************** *** 61,66 **** --- 79,88 ---- 5) Added "set indentprefix" capability to the package, and also included it in the default Mail.rc files. + 6) Added code to main() and in lock.c to do allow safe (I hope!) + installation setgid to group mail. + - ijackson@nyx.cs.du.edu, 30th June 1993 + What this version expects: *************** *** 68,74 **** 2) The default editor is /usr/bin/vi. 3) The default shell is /bin/sh. 4) The default pager is /usr/bin/more. ! 5) It looks for the some files in /usr/lib: Mail.rc, Mail.help, and Mail.help.~ If you are using sendmail instead of smail, then the easiest thing to do --- 90,97 ---- 2) The default editor is /usr/bin/vi. 3) The default shell is /bin/sh. 4) The default pager is /usr/bin/more. ! 5) The mail spool is in /usr/spool/mail. ! 6) It looks for the some files in /usr/lib: Mail.rc, Mail.help, and Mail.help.~ If you are using sendmail instead of smail, then the easiest thing to do Binary files mailx-5.3a/bin/Mail and mailx-5.3b/bin/Mail differ Only in mailx-5.3b/bin: Mail-static Only in mailx-5.3a/bin: Mail.help.~ diff -r -c mailx-5.3a/bin/Makefile mailx-5.3b/bin/Makefile *** mailx-5.3a/bin/Makefile Tue Mar 30 11:09:50 1993 --- mailx-5.3b/bin/Makefile Wed Jun 30 00:57:39 1993 *************** *** 20,25 **** --- 20,27 ---- install: cp Mail /bin/Mail + chgrp mail /bin/Mail + chmod 2555 /bin/Mail cp Mail.* /usr/lib cp mail.1 /usr/man/man1 mv /bin/mail /bin/mail.old Only in mailx-5.3a/src: Mail.help.~ diff -r -c mailx-5.3a/src/Makefile mailx-5.3b/src/Makefile *** mailx-5.3a/src/Makefile Thu Apr 1 22:57:49 1993 --- mailx-5.3b/src/Makefile Wed Jun 30 01:06:38 1993 *************** *** 92,98 **** Mail: $S $(OBJS) $(RM) -f Mail @echo Loading ... ! @${CC} ${CFLAGS} ${LDFLAGS} -o Mail ${OBJS} ${LIBES} @size Mail shar: $S --- 92,98 ---- Mail: $S $(OBJS) $(RM) -f Mail @echo Loading ... ! ${CC} ${CFLAGS} ${LDFLAGS} -o Mail ${OBJS} ${LIBES} @size Mail shar: $S *************** *** 153,158 **** --- 153,160 ---- install: cp Mail /bin/Mail strip /bin/Mail + chgrp mail /bin/Mail + chmod 2555 /bin/Mail cp Mail.* /usr/lib cp mail.1 /usr/man/man1 mv /bin/mail /bin/mail.old diff -r -c mailx-5.3a/src/README mailx-5.3b/src/README *** mailx-5.3a/src/README Tue Nov 13 06:41:45 1990 --- mailx-5.3b/src/README Wed Jun 30 01:25:15 1993 *************** *** 1,3 **** --- 1,14 ---- + Copyright (C) 1993 Ian Jackson. + Copyright (C) Scott Adkins + Copyright (C) The Regents of the University of California, Berkeley. + + See the file README in the top-level directory for details of the + licensing conditions (basically, GNU GPL + BSD copyright). + + - Ian Jackson , 30th June 1993. + + ================================================== + This is the instruction file for compiling and installing UCB Mail on a Xenix system. It is intended that a semi-smart or smart mailer such as either smail or sendmail be available to perform some of the background diff -r -c mailx-5.3a/src/glob.h mailx-5.3b/src/glob.h *** mailx-5.3a/src/glob.h Tue Nov 13 06:41:45 1990 --- mailx-5.3b/src/glob.h Wed Jun 30 00:36:13 1993 *************** *** 71,76 **** --- 71,78 ---- int rmail; /* Being called as rmail */ int screenwidth; /* Screen width, or best guess */ int screenheight; /* Screen height, or best guess */ + gid_t effectivegid; /* Saved from when we started up */ + gid_t realgid; /* Saved from when we started up */ #include diff -r -c mailx-5.3a/src/lock.c mailx-5.3b/src/lock.c *** mailx-5.3a/src/lock.c Mon Mar 29 16:33:06 1993 --- mailx-5.3b/src/lock.c Wed Jun 30 01:28:17 1993 *************** *** 4,9 **** --- 4,22 ---- * Local hacks for mailbox access should be grafted here. * * $Log: lock.c,v $ + * + * Linux version 5.3b 30th June 1993 + * Added code to make setgid secure - hopefully! + * + * COPYRIGHT + * Unfortunately the copyright notice for to this file appears to + * have become separated from the file itself. + * Unless there are any prior claims to the contrary it is hereby + * placed under the protection of the GNU General Public License + * version 2 (or a later version, at your option). + * + * - Ian Jackson + * * Revision 1.2 88/08/30 16:13:14 network * Portability fixes from Ronald Karr . * *************** *** 82,87 **** --- 95,119 ---- } /*---------------------------------------------------------------------- + * Set the gid if the path is in the normal mail spool + */ + + static int perhaps_setgid(name, gid) + char *name; + gid_t gid; + { + char safepath[]= "/usr/spool/mail/"; + + if (strncmp(name,safepath,sizeof(safepath)-1) || + strchr(name+sizeof(safepath)-1,'/')) return 0; + + if (setgid(gid) == 0) return 0; + + syserr("can't change gid to %d",gid); + return -1; + } + + /*---------------------------------------------------------------------- * Sleep for the given number of seconds. */ *************** *** 420,427 **** if (tries) snooze(3); ! if ((fd = open(name, O_RDWR|O_CREAT|O_EXCL, 0)) >= 0) ! { (void) close(fd); if (debug) mesg("created lockfile %s\n", name); --- 452,464 ---- if (tries) snooze(3); ! if (perhaps_setgid(name, effectivegid)) return -1; ! ! fd = open(name, O_RDWR|O_CREAT|O_EXCL, 0); ! ! if (perhaps_setgid(name, realgid)) return -1; ! ! if (fd >= 0) { (void) close(fd); if (debug) mesg("created lockfile %s\n", name); *************** *** 447,453 **** remove_lockfile(name) char *name; { ! if (unlink(name) == -1) { syserr("can't remove lockfile %s", name); return -1; --- 484,498 ---- remove_lockfile(name) char *name; { ! int rv, e; ! ! if (perhaps_setgid(name,effectivegid)) return -1; ! ! rv= unlink(name); ! ! if (perhaps_setgid(name,realgid)) return -1; ! ! if (rv == -1) { syserr("can't remove lockfile %s", name); return -1; diff -r -c mailx-5.3a/src/main.c mailx-5.3b/src/main.c *** mailx-5.3a/src/main.c Mon Mar 29 16:32:12 1993 --- mailx-5.3b/src/main.c Wed Jun 30 01:28:17 1993 *************** *** 1,8 **** /* * Copyright (c) 1980 Regents of the University of California. ! * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that this notice is preserved and that due credit is given * to the University of California at Berkeley. The name of the University * may not be used to endorse or promote products derived from this --- 1,10 ---- /* + * Copyright (C) 1993 Ian Jackson * Copyright (c) 1980 Regents of the University of California. ! * All rights reserved * * Redistribution and use in source and binary forms are permitted + * under the terms of the GNU General Public License (version 2), * provided that this notice is preserved and that due credit is given * to the University of California at Berkeley. The name of the University * may not be used to endorse or promote products derived from this *************** *** 47,56 **** { register char *ef; register int i, argp; ! int mustsend, hdrstop(), f; void (*prevint)(); struct sgttyb tbuf; /* * Set up a reasonable environment. * Figure out whether we are being run interactively, set up --- 49,70 ---- { register char *ef; register int i, argp; ! int mustsend, hdrstop(), f; void (*prevint)(); struct sgttyb tbuf; + /* + * Absolutely the first thing we do is save our egid + * and set it to the rgid, so that we can safely run + * setgid. We use the sgid (saved set-gid) to allow ourselves + * to revert to the egid if we want (temporarily) to become + * priveliged. + */ + + effectivegid= getegid(); + realgid= getgid(); + if (setgid(realgid) <0) { perror("mailx: setgid real"); exit(1); } + /* * Set up a reasonable environment. * Figure out whether we are being run interactively, set up diff -r -c mailx-5.3a/src/v7.local.c mailx-5.3b/src/v7.local.c *** mailx-5.3a/src/v7.local.c Tue Nov 13 06:41:46 1990 --- mailx-5.3b/src/v7.local.c Wed Jun 30 01:01:50 1993 *************** *** 33,38 **** --- 33,43 ---- { strcpy(copy("/usr/spool/mail/", mailname), myname); + /* NOTE - DO NOT CHANGE THIS without also changing it in + * perhaps_setgid in lock.c ! + * Sorry, but that's the way things go it they don't give + * you a bloody #define for it ... + */ if (isdir(mailname)) { stradd(mailname, '/'); strcat(mailname, myname);