Return to BSD News archive
Path: sserve!newshost.anu.edu.au!munnari.oz.au!news.Hawaii.Edu!ames!agate!howland.reston.ans.net!darwin.sura.net!news.dfn.de!urmel.informatik.rwth-aachen.de!acds.physik.rwth-aachen.de!kuku From: kuku@acds.physik.rwth-aachen.de (Christoph Kukulies) Newsgroups: comp.os.386bsd.questions Subject: Re: Tk/Tcl problems! (!!!!! kern_execve.c patch alert ******) Date: 15 Jul 1993 17:24:44 GMT Organization: I.Physikalisches Institut RWTH-Aachen Lines: 368 Distribution: world Message-ID: <2243ss$579@urmel.informatik.rwth-aachen.de> References: <CA5AF4.1Bw@cosy.sbg.ac.at> Reply-To: kuku@acds.physik.rwth-aachen.de NNTP-Posting-Host: acds.physik.rwth-aachen.de Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit In article <CA5AF4.1Bw@cosy.sbg.ac.at>, peter@cosy.sbg.ac.at (Peter Burgstaller) writes: >Hi folks! > >I have compiled tk3.2 and tcl6.7 for my 386bsd system. I had to >eliminate the setenv and putenv reimplementations in tclEnv.c ^^^^^^ ^^^^^ You will need these and leave them as they are otherwise TK/TCL won't work in many situations. >in order to compile the whole stuff. I got some warnings but >you know who cares so I ran some applications but >the line >#!/usr/local/bin/wish -f >doesn't work for me. I always get wish up but nothing else. See kern_execve.c patch below. I hope this patch works on top of a 0.2.4 patched systemand it makes it's way into the patchkit so we finally get rid of this everlasting #!/bin/wish -f problem. >However if I start a prog with >wish -f prog.tcl then everything works fine. > >My question is: Has anybody encountered the same problem >and if so has anybody solfed it?? >I already posted in comp.lang.tcl but the guys there don't have >a working answer! > >- Thanks to yall! > >- Peter >-- >/--------------------------------------------------------\ >| Peter Burgstaller| Student of Computerscience | >| (peter@cosy.sbg.ac.at)| in Salzburg, Austria (Europe) | >| "So Long, and Thanks for All the Fish" (Douglas Adams) | >\--------------------------------------------------------/ > --Chris Christoph P. U. Kukulies kuku@acds.physik.rwth-aachen.de *** Error code 1 ---------------------------- cut here ------------------------------- *** /sys/kern/kern_execve.c Fri Jun 25 09:50:29 1993 --- kern_execve.c Mon Jun 28 11:37:40 1993 *************** *** 55,69 **** * CURRENT PATCH LEVEL: 6 00165 * -------------------- ----- ---------------------- * ! * 05 Aug 92 Paul Kranenburg Fixed #! as a magic number ! * 29 Jul 92 Mark Tinguely Fixed execute permission enforcement * 15 Aug 92 Terry Lambert Fixed CMOS RAM size bug ! * 12 Dec 92 Julians Elischer Place argc into user address space ! * correctly ! * 10 Apr 93 Yoval Yarom Fix for busy text on executables ! * 20 Apr 93 markie Stop execution of a file open for write ! * Rodney W. Grimes Fix date on Yoval Yarom's patch ! * 01 Jun 93 Chris Demetriou Completed markie's patch for VTEXT busy */ #include "param.h" --- 55,71 ---- * CURRENT PATCH LEVEL: 6 00165 * -------------------- ----- ---------------------- * ! * 05 Aug 92 Paul Kranenburg Fixed #! as a magic number ! * 29 Jul 92 Mark Tinguely Fixed execute permission enforcement * 15 Aug 92 Terry Lambert Fixed CMOS RAM size bug ! * 12 Dec 92 Julians Elischer Place argc into user address space ! * correctly ! * 10 Apr 93 Yoval Yarom Fix for busy text on executables ! * 20 Apr 93 markie Stop execution of a file open for write ! * Rodney W. Grimes Fix date on Yoval Yarom's patch ! * 01 Jun 93 Chris Demetriou Completed markie's patch for VTEXT busy ! * 28 Jun 93 Chris Kukulies fix for #!/wish -f to be handled ! * properly. */ #include "param.h" *************** *** 114,120 **** struct vattr attr; struct vmspace *vs; caddr_t newframe; ! char shellname[MAXINTERP]; /* 05 Aug 92*/ union { char ex_shell[MAXINTERP]; /* #! and interpreter name */ struct exec ex_hdr; --- 116,123 ---- struct vattr attr; struct vmspace *vs; caddr_t newframe; ! char shellname[MAXINTERP]; ! char rest_of_line[MAXINTERP]; union { char ex_shell[MAXINTERP]; /* #! and interpreter name */ struct exec ex_hdr; *************** *** 128,159 **** ndp->ni_segflg = UIO_USERSPACE; ndp->ni_dirp = uap->fname; ! again: /* 05 Aug 92*/ ndp->ni_nameiop = LOOKUP | LOCKLEAF | FOLLOW | SAVENAME; /* is it there? */ if (rv = namei(ndp, p)) return (rv); ! ! if (ndp->ni_vp->v_writecount) { /* don't exec if file is busy */ ! rv = EBUSY; ! goto exec_fail; ! } /* does it have any attributes? */ rv = VOP_GETATTR(ndp->ni_vp, &attr, p->p_ucred, p); if (rv) goto exec_fail; ! if (ndp->ni_vp->v_mount->mnt_flag & MNT_NOEXEC) { /* no exec on fs ?*/ rv = EACCES; goto exec_fail; } /* is it executable, and a regular file? */ ! if ((ndp->ni_vp->v_mount->mnt_flag & MNT_NOEXEC) || /* 29 Jul 92*/ ! (VOP_ACCESS(ndp->ni_vp, VEXEC, p->p_ucred, p)) || ! ((attr.va_mode & 0111) == 0) || ! (attr.va_type != VREG)) { rv = EACCES; goto exec_fail; } --- 131,162 ---- ndp->ni_segflg = UIO_USERSPACE; ndp->ni_dirp = uap->fname; ! again: ndp->ni_nameiop = LOOKUP | LOCKLEAF | FOLLOW | SAVENAME; /* is it there? */ if (rv = namei(ndp, p)) return (rv); ! ! if (ndp->ni_vp->v_writecount) { /* don't exec if file is busy */ ! rv = EBUSY; ! goto exec_fail; ! } /* does it have any attributes? */ rv = VOP_GETATTR(ndp->ni_vp, &attr, p->p_ucred, p); if (rv) goto exec_fail; ! if (ndp->ni_vp->v_mount->mnt_flag & MNT_NOEXEC) {/* no exec on fs ? */ rv = EACCES; goto exec_fail; } /* is it executable, and a regular file? */ ! if ((ndp->ni_vp->u_mount_mnt_flag & MNT_NOEXEC) || /* 29 Jul 92*/ ! (VOP_ACCESS(ndp->ni_vp,VEXEC,p->p_ucred,p)) || ! ((attr.va_mode & 0111) == 0 || ! attr.va_type != VREG)) { rv = EACCES; goto exec_fail; } *************** *** 162,170 **** * Step 2. Does the file contain a format we can * understand and execute * - * XXX 05 Aug 92 * Read in first few bytes of file for segment sizes, magic number: ! * ZMAGIC = demand paged RO text * Also an ASCII line beginning with #! is * the file name of a ``shell'' and arguments may be prepended * to the argument list if given here. --- 165,172 ---- * Step 2. Does the file contain a format we can * understand and execute * * Read in first few bytes of file for segment sizes, magic number: ! * ZMAGIC = demand paged RO text * Also an ASCII line beginning with #! is * the file name of a ``shell'' and arguments may be prepended * to the argument list if given here. *************** *** 177,189 **** /* big enough to hold a header? */ if (rv) goto exec_fail; - if (exdata.ex_hdr.a_text != 0 && (ndp->ni_vp->v_flag & VTEXT) == 0 && - ndp->ni_vp->v_writecount != 0) { - rv = ETXTBSY; - goto exec_fail; - } - /* ... that we recognize? */ rv = ENOEXEC; --- 179,191 ---- /* big enough to hold a header? */ if (rv) goto exec_fail; + + if (exdata.ex_hdr.a_text != 0 && (ndp->ni_vp->v_flag & VTEXT) == 0 && + ndp->ni_vp->v_writecount != 0) { + rv = ETXTBSY; + goto exec_fail; + /* ... that we recognize? */ rv = ENOEXEC; *************** *** 207,213 **** if (*cp == '\t') *cp = ' '; } ! cp = &exdata.ex_shell[2]; /* get shell interpreter name */ while (*cp == ' ') cp++; --- 209,215 ---- if (*cp == '\t') *cp = ' '; } ! cp = &exdata.ex_shell[2]; /* get shell interpreter name */ while (*cp == ' ') cp++; *************** *** 215,226 **** while (*cp && *cp != ' ') *sp++ = *cp++; *sp = '\0'; ! ! indir = 1; /* indicate this is a script file */ vput(ndp->ni_vp); FREE(ndp->ni_pnbuf, M_NAMEI); ! ndp->ni_dirp = shellname; /* find shell interpreter */ ndp->ni_segflg = UIO_SYSSPACE; goto again; } --- 217,238 ---- while (*cp && *cp != ' ') *sp++ = *cp++; *sp = '\0'; ! ! if(*cp) { /* if there is something following the #!/shell */ ! while ( *cp == ' ' ) ! cp++; ! sp = rest_of_line; ! while (*cp) ! *sp++ = *cp++; ! *sp = '\0'; ! indir = 2; /* indicate this is a script file */ ! } ! else ! indir = 1; vput(ndp->ni_vp); FREE(ndp->ni_pnbuf, M_NAMEI); ! ndp->ni_dirp = shellname; /* find shell interpreter */ ndp->ni_segflg = UIO_SYSSPACE; goto again; } *************** *** 227,234 **** /* sanity check "ain't not such thing as a sanity clause" -groucho */ rv = ENOMEM; ! if (/*exdata.ex_hdr.a_text == 0 || */ exdata.ex_hdr.a_text > MAXTSIZ || ! exdata.ex_hdr.a_text % NBPG || exdata.ex_hdr.a_text > attr.va_size) goto exec_fail; if (exdata.ex_hdr.a_data == 0 || exdata.ex_hdr.a_data > DFLDSIZ --- 239,246 ---- /* sanity check "ain't not such thing as a sanity clause" -groucho */ rv = ENOMEM; ! if (/*exdata.ex_hdr.a_text == 0 || */ exdata.ex_hdr.a_text > MAXTSIZ ! || exdata.ex_hdr.a_text % NBPG || exdata.ex_hdr.a_text > attr.va_size) goto exec_fail; if (exdata.ex_hdr.a_data == 0 || exdata.ex_hdr.a_data > DFLDSIZ *************** *** 289,295 **** /* first, do (shell name if any then) args */ if (indir) { ep = shellname; ! twice: if (ep) { /* did we outgrow initial argbuf, if so, die */ if (argbufp >= (char **)stringbuf) { --- 301,307 ---- /* first, do (shell name if any then) args */ if (indir) { ep = shellname; ! threetimes: if (ep) { /* did we outgrow initial argbuf, if so, die */ if (argbufp >= (char **)stringbuf) { *************** *** 309,323 **** limitonargs -= stringlen; } ! if (indir) { indir = 0; /* orginal executable is 1st argument with scripts */ ep = uap->fname; ! goto twice; } /* terminate in case no more args to script */ suword(argbufp, 0); ! if (vectp = uap->argp) vectp++; /* manually doing the first argument with scripts */ } --- 321,340 ---- limitonargs -= stringlen; } ! if (indir == 2) { ! indir = 1; ! ep = rest_of_line; ! goto threetimes; ! } ! if (indir == 1) { indir = 0; /* orginal executable is 1st argument with scripts */ ep = uap->fname; ! goto threetimes; } /* terminate in case no more args to script */ suword(argbufp, 0); ! if (vectp = uap->argp) vectp++; /* manually doing the first argument with scripts */ } *************** *** 489,496 **** p->p_regs[SP] = (unsigned) (argbuf - 1); setregs(p, exdata.ex_hdr.a_entry); ! ndp->ni_vp->v_flag |= VTEXT; /* mark vnode pure text */ ! vput(ndp->ni_vp); FREE(ndp->ni_pnbuf, M_NAMEI); --- 506,513 ---- p->p_regs[SP] = (unsigned) (argbuf - 1); setregs(p, exdata.ex_hdr.a_entry); ! ndp->ni_up->v_flag |= VTEXT; ! vput(ndp->ni_vp); FREE(ndp->ni_pnbuf, M_NAMEI);