Bug 100287

Summary: /etc/rc.subr cannot deal properly with interpreted daemons whos shebang uses /usr/bin/env
Product: Base System Reporter: Rob Pitt <rob>
Component: binAssignee: Yar Tikhiy <yar>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Unspecified   
Hardware: Any   
OS: Any   

Description Rob Pitt 2006-07-14 11:40:16 UTC
When you create a script to manage starting and stopping a daemon written in an interpreted language then you supply command_interpreter to set the interpreter being used to execute the daemon (i.e. /usr/local/bin/python). If the interpreted daemon uses a shebang referencing /usr/bin/env to locate it's interpreter (a good practice for a multi-platform daemon), i.e.:

#!/usr/bin/env python

Then the rc.subr script gets confused because it thinks the interpreter is "/usr/bin/env " (including that last space).

You can work around this by changing the daemons shebang to point at the actual location of the interpreter, i.e.:

#!/usr/local/bin/python

However, while trivial this is far from ideal because it means additional, unnecessary patching and the rc.subr script could be made to handle this gracefully.

Fix: 

The rc.subr script could assume that "foobar" is the correct interpreter value when it sees "#!/usr/bin/env foobar"
How-To-Repeat: 1. See description
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2006-07-14 14:59:48 UTC
Responsible Changed
From-To: freebsd-bugs->freebsd-rc

Over to maintainer(s).
Comment 2 dfilter service freebsd_committer freebsd_triage 2006-12-31 11:07:36 UTC
yar         2006-12-31 11:07:29 UTC

  FreeBSD src repository

  Modified files:
    etc                  rc.subr 
  Log:
  Allow for /usr/bin/env when parsing the shebang line from an
  interpreted $command.  Some "portable" sofware packages use such a
  line to skip the task of figuring out the absolute pathname of the
  interpreter at install time, e.g.:
  
          #!/usr/bin/env python
  
  It is insecure, but a popular book on Python seems to have advised
  it to a wide audience.  Hence a number of such scripts in the ports,
  mostly written in Python.
  
  PR:             bin/100287
  MFC after:      1 week
  
  Revision  Changes    Path
  1.73      +5 -0      src/etc/rc.subr
_______________________________________________
cvs-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/cvs-all
To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
Comment 3 Yar Tikhiy freebsd_committer freebsd_triage 2006-12-31 11:07:44 UTC
State Changed
From-To: open->patched

Fixed in CURRENT; MFC is due in 1 week.  Thanks! 


Comment 4 Yar Tikhiy freebsd_committer freebsd_triage 2006-12-31 11:07:44 UTC
Responsible Changed
From-To: freebsd-rc->yar

Fixed in CURRENT; MFC is due in 1 week.  Thanks!
Comment 5 dfilter service freebsd_committer freebsd_triage 2007-03-10 13:53:10 UTC
yar         2007-03-10 13:53:04 UTC

  FreeBSD src repository

  Modified files:        (Branch: RELENG_6)
    etc                  rc.subr 
  Log:
  MFC rev. 1.73: Allow for interpreted scripts using env(1)
  in their shebang lines.
  
  PR:     bin/100287
  
  Revision   Changes    Path
  1.34.2.19  +5 -0      src/etc/rc.subr
_______________________________________________
cvs-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/cvs-all
To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
Comment 6 Yar Tikhiy freebsd_committer freebsd_triage 2007-03-10 13:53:26 UTC
State Changed
From-To: patched->closed

Sorry, I delayed the MFC terribly. 
Now the bug is fixed in both active branches.