This file is indexed.

/etc/network/ifupdown-scripts-zg2.d/address is in ifupdown-scripts-zg2 0.6-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
#!/bin/bash
# $Header$

# IFACE      = Logical interface name
# MODE       = start | stop
# METHOD     = manual, otherwise exit!
# IF_ADDRESS = address/prefix
# IF_DEVICE  = physical interface name
# IF_SCOPE   = scope of address
# IF_BRD     = broadcast address (all1 default, all0/none allowed)
# IF_FLAGS   = "secondary"
# IF_LABEL   = set label (1 default)
# IF_FORCE_IPV6_RD  = force IPv6 Router Discovery before initializing
# IF_WAIT_TENTATIVE = wait for non-tentative IP addresses (1 default)
# IF_PREFLFT = preferred lifetime

. /etc/network/ifupdown-scripts-zg2.d/common-functions

# check that an address has been configured for this interface
[ -z "${IF_ADDRESS:-}" ] && exit 0
ADDRTYPE="$(addrtype $IF_ADDRESS)"
if [ "$ADDRTYPE" != "v4" ] && [ "$ADDRTYPE" != "v6" ]; then
  abort "address $IF_ADDRESS does not look like an IP address"
fi

case "$MODE" in
  start)

    # send IPv6 router discovery, making sure that we learn addresses
    if [ "${IF_FORCE_IPV6_RD:-0}" = "1" ]; then
      if command -v rdisc6 > /dev/null; then
        loop=2
        while ! rdisc6 --retry 1 --wait 2000 --single --quiet $IF_DEVICE >/dev/null 2>/dev/null; do
	  if [ $loop -eq 2 ]; then
            verbose "retrying IPv6 RD"
          fi
          if [ $loop -eq 0 ]; then
            verbose "giving up on IPv6 RD"
	    rdisc6 --retry 1 --wait 2000 --single $IF_DEVICE 
	    break
          fi
          sleep 1
          loop=$(($loop-1))
        done
      else
        abort "force-ipv6-rd needs the ndisc6 package"
      fi
    fi

    # build address parameters, parse flags
  
    ADDRPARM="dev $IF_DEVICE"
    if [ "$IF_DEVICE" != "$IFACE" ]; then
      # if logical device name differs from physical, label interface
      if [ "${IF_LABEL:-1}" != "0" ]; then
        ADDRPARM="$ADDRPARM label $IF_DEVICE:$IFACE"
      fi
    fi
    if [ "$(addrtype $IF_ADDRESS)" = "v4" ]; then
      IF_BRD=${IF_BRD:="all1"}
      case "$IF_BRD" in
        none) : ;;
        all1) ADDRPARM="$ADDRPARM broadcast +";;
        all0) ADDRPARM="$ADDRPARM broadcast -";;
        *)    ADDRPARM="$ADDRPARM broadcast $IF_BRD";;
      esac
    fi

    ADDRPARM="$ADDRPARM $IF_ADDRESS"
    ADDRPARM="$ADDRPARM ${IF_SCOPE:+scope $IF_SCOPE}"
    ADDRPARM="$ADDRPARM ${IF_PREFLFT:+preferred_lft $IF_PREFLFT}"

    SECONDARY=""
    if echo $IF_FLAGS | grep -s -q -i "secondary"; then
      SECONDARY="1"
    fi

    # initialize interface

    cmd "ip addr add $ADDRPARM"

    # check if primary or secondary IP
    # primary / secondary IP addresses need to be addresed differently since
    # taking down a primary IP also removes the secondaries. This can have
    # unwanted effects to network connectivity and wrecks our interface state.
    
    if ip addr show dev "$IF_DEVICE" secondary | \
    				grep -s -q "$IF_ADDRESS"; then
      # $IF_ADDRESS has become secondary IP
      if [ -z "${SECONDARY:-}" ]; then
      	# $IF_ADDRESS is not marked as secondary
	# take away IP again
	ip addr del "$ADDRPARM"
	abort "secondary IP not marked as such in /etc/network/interface"
      fi
    elif ip addr show dev "$IF_DEVICE" primary | \
    				grep -s -q "$IF_ADDRESS"; then
      # $IF_ADDRESS has become primary IP
      if [ -n "$SECONDARY" ]; then
        # $IF_ADDRESS is marked as secondary
	# take away IP again
	ip addr del "$ADDRPARM"
	abort "secondary IP came up as primary. Bring up primary before bringing up secondaries."
      fi
    fi

    if [ "${IF_WAIT_TENTATIVE:-1}" != "1" ]; then
      loop=30
      while ip --oneline addr show dev "$IF_DEVICE" | grep --quiet tentative; do
        if [ $loop -eq 30 ]; then
          verbose "waiting for IPv6 address to leave tentative state"
        fi
        if [ $loop -eq 0 ]; then
          verbose "giving up on tentative IPv6 address"
	  cmd "ip --oneline addr show dev $IF_DEVICE"
	  break
        fi
        sleep 1
        loop=$(($loop-1))
      done
    fi

    add_down "address" "addr del $ADDRPARM"
    add_down "ip-address" "$IF_ADDRESS"
    add_down "ip-dev" "$IF_DEVICE"

    ;;
  stop)
    ADDR=$(state_entry ip-address)
    DEV=$(state_entry ip-dev)
    exec_down "ip-address" ""
    exec_down "ip-dev" ""
    if [ -n "$DEV" ]; then
      if ip addr show dev "$DEV" primary | \
                                grep -s -q "$ADDR"; then
        # we are trying to take down a primary IP address
        if ip addr show dev "$DEV" secondary | \
      				grep -s -q inet[^6]; then
 	  # there are still secondary IPs present
 	  abort "take down secondary IPs before taking down primary IPs."
        fi
      fi
    fi

    exec_down "address" "ip"
    ;;
  *)
    ;;
esac

# end of file