This file is indexed.

/etc/init.d/ntop is in ntop 3:4.1.0+dfsg1-1.

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
#! /bin/sh
### BEGIN INIT INFO
# Provides:          ntop
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Should-Start:      $network
# Should-Stop:       $network
# Short-Description: Start ntop daemon
### END INIT INFO

DAEMON="/usr/sbin/ntop"
NAME="ntop"
DESC="network top daemon"
INIT="/etc/default/$NAME"
DEBCONFINIT="/var/lib/ntop/init.cfg"
HOMEDIR="/var/lib/ntop"
LOGDIR="/var/log/ntop"
SCRIPTNAME=/etc/init.d/$NAME

# Workaround for a rrd problem, see #471862.
export LANG=C
# end of workaround

test -f $DAEMON || exit 0

. /lib/lsb/init-functions

test -f $INIT || exit 0

. $INIT

test -f $DEBCONFINIT || exit 0

. $DEBCONFINIT

[ "$ENABLED" = "0" -o "$ENABLED" = "no" -o "$ENABLED" = "n" ] && exit 0

sanity_check() {
# Sanity check, we expect USER And INTERFACES to be defined
# (we could also set defaults for them before calling INIT...)
	if [ -z "$USER" ] ; then
		log_failure_msg "$NAME: USER is not defined, please run 'dpkg-reconfigure ntop'" >&2
		return 1
	fi
	if [ -z "$INTERFACES" ] ; then
		log_failure_msg "$NAME: INTERFACES is not defined, please run 'dpkg-reconfigure ntop'" >&2
		return 1
	fi
	return 0
}

check_log_dir() {
# Does the logging directory belong to the User running the application
        # If we cannot determine the logdir return without error
        # (we will not check it)
        [ -n "$LOGDIR" ] || return 0
        [ -n "$USER" ] || return 0
        if [ ! -e "$LOGDIR" ] ; then
                log_failure_msg "$NAME: logging directory $LOGDIR does not exist"
                return 1
        elif [ ! -d "$LOGDIR" ] ; then
                log_failure_msg "$NAME: logging directory $LOGDIR does not exist"
                return 1
        else
                real_log_user=`stat -c %U $LOGDIR`
        # An alternative way is to check if the the user can create
        # a file there...
                if [ "$real_log_user" != "$USER" ] ; then
                        log_failure_msg "$NAME: logging directory $LOGDIR does not belong to the user $USER"
                        return 1
                fi
        fi
        return 0
}

check_interfaces() {
# Check the interface status, abort with error if a configured one is not
# available
	[ -z "$INTERFACES" ] && return 0
	for iface in $(echo $INTERFACES | awk -F , '{ for(i=1;i<=NF;i++) print $i }')
	do
		if [ "$iface" != "none" ] && ! netstat -i | grep "$iface" >/dev/null; then
			log_failure_msg "$NAME: interface $iface is down"
			return 1
		fi
	done
	return 0
}

ntop_start() {
  retval=$(
    {
      { start-stop-daemon --start --quiet --name $NAME --exec $DAEMON -- \
	  -d -L -u $USER -P $HOMEDIR \
	  --access-log-file=$LOGDIR/access.log -i "$INTERFACES" \
	  -p /etc/ntop/protocol.list \
	  -O $LOGDIR $GETOPT 2>&1; echo -n $? >&2 ;
      } | logger -p daemon.info -t ntop;
    } 2>&1 )
  if [ "$retval" -eq 1 ]; then
    log_progress_msg "already running"
    return 0
  fi
  if pidof $DAEMON > /dev/null ; then
    return 0
  else
  # WARNING: This might introduce a race condition in some (fast) systems
  # Wait for a sec an try again
    sleep 1
    if pidof $DAEMON > /dev/null ; then
      return 0
    else
      return 1
    fi
  fi
}

ntop_stop() {
  start-stop-daemon --stop --quiet --oknodo --name $NAME --user $USER --retry 9
  if pidof $DAEMON > /dev/null ; then
  # WARNING: This might introduce a race condition in some (fast) systems
  # Wait for a sec an try again
    sleep 1
    if pidof $DAEMON > /dev/null ; then
      return 1
    else
      return 0
    fi
  else
    return 0
  fi
}

case "$1" in
start)
  if ! sanity_check || ! check_log_dir || ! check_interfaces; then
    return 1
  fi
  log_daemon_msg "Starting $DESC" "$NAME"
  if ntop_start; then
    log_end_msg 0
  else
    log_end_msg 1
  fi
  ;;
stop)
  log_daemon_msg "Stopping $DESC" "$NAME"
  if ntop_stop; then
    log_end_msg 0
  else
    log_end_msg 1
  fi
  ;;
restart | force-reload)
  if ! sanity_check || ! check_log_dir || ! check_interfaces; then
    return 1
  fi
  log_daemon_msg "Restarting $DESC" "$NAME"
  if ntop_stop && ntop_start; then
    log_end_msg 0
  else
    log_end_msg 1
  fi
  ;;
reload | try-restart)
  log_action_msg "Usage: $SCRIPTNAME {start|stop|restart|force-reload}"
  exit 3
  ;;
*)
  log_action_msg "Usage: $SCRIPTNAME {start|stop|restart|force-reload}"
  exit 1
  ;;
esac
exit 0