Subject: Re: pkg/7076: "install" scripts are not working in
To: Hubert Feyrer <hubert.feyrer@rz.uni-regensburg.de>
From: Greg A. Woods <woods@most.weird.com>
List: netbsd-bugs
Date: 03/03/1999 12:05:04
[ On Wednesday, March 3, 1999 at 12:25:05 (+0100), Hubert Feyrer wrote: ]
> Subject: Re: pkg/7076: "install" scripts are not working in  pkg_install-19990119
>
> On Wed, 3 Mar 1999, Greg A. Woods wrote:
> > So I finally peeked in the source.  First off I was dumbfounded to
> > discover that there were already "chmod +x" calls in all the right
> > places.  Then I was further dumbfounded to find that these scripts were
> > being invoked by system(3), which presumably still uses "/bin/sh -c
> > 'ARGS'".
> 
> Hehe, glad to see you at the same state of confusion that I am. 8-)

I'm completely baffled indeed, perhaps even more so now.

> Can you try running ktrace on this, maybe it gives some hint?

It only seems to confirm that the "permission denied" message is indeed
coming from the shell and directly as a result of a failed execve().

This is starting where the shell fired up by system() is just about to
fork() to run the command it was given.  Note that all previous calls to
system(), including the system("chmod +x +INSTALL") just prior to this
point, have worked fine.

 29114 sh       CALL  fork
 29114 sh       RET   fork 29115/0x71bb
 29114 sh       CALL  getpgrp
 29114 sh       RET   getpgrp 29105/0x71b1
 29114 sh       CALL  wait4(0xffffffff,0xefbfd57c,0x2,0)
 29115 sh       RET   fork 0
 29115 sh       CALL  execve(0x4b810,0x4b84c,0x4b85c)
 29115 sh       NAMI  "./+INSTALL"
 29115 sh       RET   execve -1 errno 13 Permission denied
 29115 sh       CALL  write(0x2,0x4f080,0x1e)
 29115 sh       GIO   fd 2 wrote 30 bytes
       "./+INSTALL: permission denied
       "
 29115 sh       RET   write 30/0x1e
 29115 sh       CALL  exit(0x7e)
 29114 sh       RET   wait4 29115/0x71bb
 29114 sh       CALL  exit(0x7e)
 29105 pkg_add  RET   wait4 29114/0x71ba
 29105 pkg_add  CALL  sigprocmask(0x3,0)
 29105 pkg_add  RET   sigprocmask 524288/0x80000
 29105 pkg_add  CALL  sigaction(0x2,0xefbfbdcc,0xefbfbdc0)
 29105 pkg_add  RET   sigaction 0
 29105 pkg_add  CALL  sigaction(0x3,0xefbfbdc4,0xefbfbdb8)
 29105 pkg_add  RET   sigaction 0
 29105 pkg_add  CALL  write(0x2,0xefbfb6b0,0x9)
 29105 pkg_add  GIO   fd 2 wrote 9 bytes
       "pkg_add: "
 29105 pkg_add  RET   write 9
 29105 pkg_add  CALL  write(0x2,0xefbfb6c8,0x24)
 29105 pkg_add  GIO   fd 2 wrote 36 bytes
       "install script returned error status"
 29105 pkg_add  RET   write 36/0x24


With the original 1.3.3 pkg_add command in place it works just fine:

 51651   14126 sh       CALL  fork
 51652   14126 sh       RET   fork 14127/0x372f
 51653   14126 sh       CALL  getpgrp
 51654   14126 sh       RET   getpgrp 14117/0x3725
 51655   14126 sh       CALL  wait4(0xffffffff,0xefbfdb60,0x2,0)
 51656   14127 sh       RET   fork 0
 51657   14127 sh       CALL  execve(0x4b810,0x4b84c,0x4b85c)
 51658   14127 sh       NAMI  "./+INSTALL"
 51659   14127 sh       NAMI  "/bin/sh"
 51660   14127 sh       EMUL  "netbsd"
 51661   14127 sh       RET   execve JUSTRETURN
 51662   14127 sh       CALL  getpid
 51663   14127 sh       RET   getpid 14127/0x372f
 51664   14127 sh       CALL  geteuid
 51665   14127 sh       RET   geteuid 0
 51666   14127 sh       CALL  __sysctl(0xefbfdc00,0x2,0x4b7a0,0xefbfdc08,0,0)
 51667   14127 sh       RET   __sysctl 0
 51668   14127 sh       CALL  break(0x4c3fc)
 51669   14127 sh       RET   break 0
 51670   14127 sh       CALL  break(0x4cffc)
 51671   14127 sh       RET   break 0
 51672   14127 sh       CALL  break(0x4dffc)
 51673   14127 sh       RET   break 0
 51674   14127 sh       CALL  __stat13(0x4b7ac,0xefbfdbc0)
 51675   14127 sh       NAMI  "/var/mail/woods"
 51676   14127 sh       RET   __stat13 -1 errno 2 No such file or directory
 51677   14127 sh       CALL  open(0xefbfdd28,0,0xefbfdcd8)
 51678   14127 sh       NAMI  "./+INSTALL"
 51679   14127 sh       RET   open 3
 51680   14127 sh       CALL  fcntl(0x3,0,0xa)
 51681   14127 sh       RET   fcntl 10/0xa
 51682   14127 sh       CALL  close(0x3)

 . . .  and so on as it reads and executes the script . . .

-- 
							Greg A. Woods

+1 416 218-0098      VE3TCP      <gwoods@acm.org>      <robohack!woods>
Planix, Inc. <woods@planix.com>; Secrets of the Weird <woods@weird.com>