This file is indexed.

/etc/init.d/weborf is in weborf-daemon 0.13-3.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
#!/bin/bash
# Copyright (C) 2008  Salvo "LtWorf" Tomaselli
#
# Relation is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
# author Salvo "LtWorf" Tomaselli <tiposchi@tiscali.it>


### BEGIN INIT INFO
# Provides:          weborf
# Required-Start:    $network $local_fs $syslog $remote_fs
# Required-Stop:     $remote_fs
# Should-Start:      $named
# Should-Stop:
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Fast and small webserver
# Description:       Weborf is a configurationless webserver mainly meant to allow users
#                    to easily share their directories over the web.
#                    It also supports php5-cgi.
### END INIT INFO
function clear_cache {
    CDIR=`cat /etc/weborf.conf | egrep "^cachedir=" | cut -d= -f2`
    rm -rf $CDIR/*
}

function status {
    if ! test -e $PIDFILE
        then
            echo "Weborf doesn't appear to be running"
        else
            echo "Weborf appears to be running"
    fi
}

function stopWeborf {
    #Stops all the running weborf servers (the ones started with init)

    if ! test -e $PIDFILE
    then
        echo "Weborf is not running or it was not started by init"
        exit 0
    fi

    echo -n "Stopping weborf "    
    for i in `cat $PIDFILE`
    do
        echo -n ..
        kill $i
    done
    echo " done"
    rm -f $PIDFILE
}

function startWeborf {
    #This function will start all the needed processes for weborf
    if test -e $PIDFILE
    then
        echo "Weborf already running, if you're sure it is not running, delete $PIDFILE"
        exit 2
    fi
    
    if test -n "$AUTH_BIN"
    then
        echo "Starting authentication server for weborf"
        nohup $AUTH_BIN > /dev/null 2> /dev/null &
        echo ${!} >> $PIDFILE # Writes PID so it will be terminated
    fi

    virtuals=`cat /etc/weborf.conf | egrep ^virtual`
    if test -z "$virtuals"
    then
        echo "Starting weborf"
        nohup $DAEMON $DAEMON_OPTS $CACHE_DIR $AUTH_SOCKET $MIME $CGI $CGI_BIN -p80 -u $USERID -b $BASEDIR -I $INDEXES >/dev/null 2> /dev/null &
        echo ${!} >> $PIDFILE # Writes PID so weborf can be terminated
    else #Virtual hosts
    
        for i in $virtuals
            do
                PORT=`echo $i | cut -d# -f2`
                CMDLINE=`echo $i | cut -d# -f3`
                echo "Starting weborf on port $PORT"
                nohup $DAEMON $DAEMON_OPTS $CACHE_DIR $AUTH_SOCKET $MIME $CGI $CGI_BIN -p $PORT -u $USERID -b $BASEDIR -I $INDEXES -V "$CMDLINE" > /dev/null 2> /dev/null &
                echo $! >> $PIDFILE # Writes PID so weborf can be terminated
            done
    fi
}


PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/bin/weborf                    # Introduce the server's location here
NAME=weborf                               # Introduce the short server's name here
PIDFILE=/var/run/$NAME.pid

test -x $DAEMON || exit 0

. /lib/lsb/init-functions

# Default options, these can be overriden by the information
# at /etc/default/$NAME
DAEMON_OPTS=""          # Additional options given to the server

DIETIME=3               # Time to wait for the server to die, in seconds
                        # If this value is set too low you might not
                        # let some servers to die gracefully and
                        # 'restart' will not work

#STARTTIME=2             # Time to wait for the server to start, in seconds
                        # If this value is set each time the server is
                        # started (on start or restart) the script will
                        # stall to try to determine if it is running
                        # If it is not set and the server takes time
                        # to setup a pid file the log message might
                        # be a false positive (says it did not start
                        # when it actually did)

LOGFILE=$LOGDIR/$NAME.log  # Server logfile

# Include defaults if available
if [ -f /etc/default/$NAME ] ; then
    . /etc/default/$NAME
fi

USERNAME=`cat /etc/weborf.conf | egrep "^user=" | cut -d= -f2`
BASEDIR=`cat /etc/weborf.conf | egrep "^basedir=" | cut -d= -f2`
USERID=`cat /etc/passwd | fgrep $USERNAME | cut -d: -f3` #Gets the userid
INDEXES=`cat /etc/weborf.conf | egrep "^indexes=" | cut -d= -f2`
USE_CGI=`cat /etc/weborf.conf | egrep "^use-cgi=" | cut -d= -f2`
USE_MIME=`cat /etc/weborf.conf | egrep "^use-mime=" | cut -d= -f2`
CGI_BIN=`cat /etc/weborf.conf | egrep "^cgi=" | cut -d= -f2`
CACHE_DIR=`cat /etc/weborf.conf | egrep "^cachedir=" | cut -d= -f2`

# Authentication
AUTH_BIN=`cat /etc/weborf.conf | grep "^auth-bin=" | cut -d= -f2`
AUTH_SOCKET=`cat /etc/weborf.conf | grep "^auth-socket=" | cut -d= -f2`

if test -z "$USERNAME" || test "$USERNAME" = "root"
then
    logger -s -perror "You are trying to run weborf as root!"
    exit 0 #LSB requires 0 termination in each case
fi

if test -n "$CACHE_DIR"
then
        if ! test -d $CACHE_DIR
        then
            #Does not exist or it is not a directory
            rm -rf $CACHE_DIR
            mkdir -m700 $CACHE_DIR
            
        fi

        chown $USERNAME $CACHE_DIR
        CACHE_DIR="-C $CACHE_DIR"
fi

if test -n "$AUTH_SOCKET"
then
        AUTH_SOCKET="-a $AUTH_SOCKET"
fi

if test -n "$CGI_BIN"
then
    CGI_BIN=-c $CGI_BIN
fi

if test $USE_CGI = "false"
then
    CGI="-x"
fi

if test $USE_MIME = "true"
then
    MIME="-m"
fi

if test -z $USERID
then
    echo "Unable to find user $USERNAME"
    echo "Check your configuration"
    exit 1
fi
case $1 in
    start)
        startWeborf;;
    stop)
        stopWeborf;;
    restart)
        stopWeborf
        startWeborf;;
    force-reload)
        stopWeborf
        startWeborf;;
    status)
        status;;
    clearcache)
        clear_cache;;
    * )
        echo "Usage: $0 {start|stop|restart|force-reload|status|clearcache}";;
esac