source: trunk/server/common/oursrc/execsys/execsys-binfmt @ 1338

Last change on this file since 1338 was 1338, checked in by geofft, 15 years ago
execsys: Have binfmt_misc detect executable PHP scripts via magic, not extension. For PHP scripts run over the web, suexec runs php explicitly (and regardless of the .php file's executable bit), so this change isn't relevant. A recent kernel change reordered the binfmt_script and binfmt_misc priority; this allows executable PHP scripts that begin with <?php to continue being run via binfmt_misc, but those that begin with #! to use the interpreter they specify. PHP scripts that don't begin with <?php are assumed to be web pages, not scripts you'd explicitly exec. This is a slightly smaller hammer than removing the binfmt_misc line for PHP entirely, but really, you should be using a #! line if you intend to be able to exec your PHP script.
File size: 1.0 KB
Line 
1#!/bin/sh
2#
3# execsys-binfmt: test1
4#
5# chkconfig: 2345 2 98
6# description: test2
7#
8### BEGIN INIT INFO
9# Provides:          execsys-binfmt
10# Required-Start:    $syslog
11# Required-Stop:     $syslog
12# Should-Start:      $local_fs
13# Should-Stop:       $local_fs
14# Default-Start:     2 3 4 5
15# Default-Stop:      0 1 6
16# Short-Description: Start scripts.mit.edu execsys system
17# Description:       Decides what interpreter to use to execute files
18### END INIT INFO
19
20stop ()
21{
22    echo "-1" > /proc/sys/fs/binfmt_misc/status
23    umount /proc/sys/fs/binfmt_misc
24}
25
26start ()
27{
28    mount -t binfmt_misc none /proc/sys/fs/binfmt_misc
29    cat > /proc/sys/fs/binfmt_misc/register <<REGISTER
30:pl:E::pl::/usr/bin/perl:
31:php:M::<?php::/usr/bin/php-cgi:
32:py:E::py::/usr/bin/python:
33:exe:E::exe::/usr/bin/mono:
34REGISTER
35}
36
37case "$1" in
38start)
39    stop 2>/dev/null || :
40    start
41    ;;
42stop)
43    stop
44    ;;
45force-reload)
46    stop
47    start
48    ;;
49restart)
50    stop
51    start
52    ;;
53*)
54    echo "Usage: $0 [start|stop|restart|force-reload]" >&2
55    exit 2
56    ;;
57esac
58
59exit $?
Note: See TracBrowser for help on using the repository browser.