*BSD News Article 81668


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!news.cs.su.oz.au!inferno.mpx.com.au!news.unimelb.EDU.AU!munnari.OZ.AU!news.ecn.uoknor.edu!feed1.news.erols.com!arclight.uoregon.edu!nntp.primenet.com!nntp.uio.no!nntp.zit.th-darmstadt.de!fu-berlin.de!uniol!uni-erlangen.de!news.tu-chemnitz.de!irz401!orion.sax.de!uriah.heep!news
From: j@uriah.heep.sax.de (J Wunsch)
Newsgroups: comp.unix.bsd.freebsd.misc
Subject: Re: su in rc.local core
Date: 25 Oct 1996 09:01:26 GMT
Organization: Private BSD site, Dresden
Lines: 47
Message-ID: <54pvl6$897@uriah.heep.sax.de>
References: <54lhnn$e9@kauss.rhein-main.de> <Dzr1FE.oC@nemeton.com.au>
Reply-To: joerg_wunsch@uriah.heep.sax.de (Joerg Wunsch)
NNTP-Posting-Host: localhost.heep.sax.de
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Newsreader: knews 0.9.6
X-Phone: +49-351-2012 669
X-PGP-Fingerprint: DC 47 E6 E4 FF A6 E9 8F  93 21 E0 7D F9 12 D6 4E

giles@nemeton.com.au (Giles Lean) wrote:

> ska@kauss.rhein-main.de (Stephan Kauss) writes:
> 
> >I have the problem that I have to start up some programs at start time from
> >the rc.local. The program has to run with the user permission.
> 
> I had a similar problem with NetBSD-1.1; this turned out to be a
> coredump in setenv(3) which was called by su(1).  This could be
> the same problem (but equally might not be :).

It is.  Here's the proper fix (against FreeBSD 2.1.5):

Index: /usr/src/usr.bin/su/su.c
===================================================================
RCS file: /home/cvs/src/usr.bin/su/su.c,v
retrieving revision 1.6.4.4
retrieving revision 1.6.4.5
diff -u -u -r1.6.4.4 -r1.6.4.5
--- su.c	1996/06/23 14:07:40	1.6.4.4
+++ su.c	1996/10/07 10:02:48	1.6.4.5
@@ -42,7 +42,7 @@
 static char sccsid[] = "@(#)su.c	8.3 (Berkeley) 4/2/94";
 */
 static const char rcsid[] =
-	"$Id: su.c,v 1.6.4.4 1996/06/23 14:07:40 markm Exp $";
+	"$Id: su.c,v 1.6.4.5 1996/10/07 10:02:48 joerg Exp $";
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -293,7 +293,8 @@
 			cleanenv[0] = NULL;
 			environ = cleanenv;
 			(void)setenv("PATH", _PATH_DEFPATH, 1);
-			(void)setenv("TERM", p, 1);
+			if (p)
+				(void)setenv("TERM", p, 1);
 			if (chdir(pwd->pw_dir) < 0)
 				errx(1, "no directory");
 		}

-- 
cheers, J"org

joerg_wunsch@uriah.heep.sax.de -- http://www.sax.de/~joerg/ -- NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)