This file is indexed.

/usr/share/fwbuilder-5.1.0.3599/configlets/bsd/update_vlans is in fwbuilder-common 5.1.0-4.

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

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
## -*- mode: shell-script; -*- 
##
## To be able to make changes to the part of configuration created
## from this configlet you need to copy this file to the directory
## fwbuilder/configlets/bsd/ in your home directory and modify it.
## Double "##" comments are removed during processing but single "#"
## comments are be retained and appear in the generated script. Empty
## lines are removed as well.  
##
## Configlets support simple macro language with these constructs:
## {{$var}} is variable expansion
## {{if var}} is conditional operator.
##
############ VLAN ##############################################

## arguments:
##
## $1:  vlan_name:vlan_id@<parent_name>    e.g.  vlan8101:101@em1
## $2:  command, can be "add" or "rem"
##
missing_vlan() {
    vlan=$1
    cmd=$2

    oldIFS=$IFS
    IFS="@:"
    set $vlan
    subint=$1
    vlan_id=$2
    parent=$3
    IFS=$oldIFS

    test "$cmd" = "add" && {
        echo "# Adding VLAN interface $subint (vlan id: $vlan_id parent: $parent)"
        $FWBDEBUG $IFCONFIG $subint vlan $vlan_id vlandev $parent || exit 1
        $FWBDEBUG $IFCONFIG $subint up || exit 1
    }
    test "$cmd" = "rem" && {
        echo "# Removing VLAN interface $subint (vlan id: $vlan_id parent: $parent)"
        $FWBDEBUG $IFCONFIG $subint vlan $vlan_id -vlandev || exit 1
        $FWBDEBUG $IFCONFIG $subint destroy || exit 1
    }
}

parse_fwb_vlans() {
    set $1 
    vlan_parent=$1 
    shift

    FWB_VLANS=$(
      for subint in $*; do
        echo "${subint}@$vlan_parent"
      done | sort
    )
    echo $FWB_VLANS
}

parse_current_vlans() {
    vlan_parent=$1
    $IFCONFIG {{if openbsd}}-A{{endif}} | grep -E 'vlan[^ ]*:' | paste - - | \
        sed 's/flags=.*vlan://;s/://g;s/parent interface//' | \
    while read vlan_subint vlan_id parent
    do
       test "$parent" = "$vlan_parent" && echo "$vlan_subint:$vlan_id@$parent"
    done | sort
}

##
## Call format:
##
##  update_vlans_of_interface "pcn0 vlan101 vlan104"
##
##
update_vlans_of_interface() {
    args="$1"
    set $1 
    vlan_parent=$1 

    FWB_VLANS=$(parse_fwb_vlans "$args")
    CURRENT_VLANS=$(parse_current_vlans $vlan_parent)

    $IFCONFIG $vlan_parent up || exit 1
    diff_intf missing_vlan "$FWB_VLANS" "$CURRENT_VLANS" add
    diff_intf missing_vlan "$CURRENT_VLANS" "$FWB_VLANS" rem
}

sync_vlan_interfaces() {
    $IFCONFIG {{if openbsd}}-A{{endif}} | awk -v IGNORED="$*" \
        'BEGIN {
           split(IGNORED,ignored_arr);
           for (a in ignored_arr) {ii=ignored_arr[a]":"; ignored_dict[ii]=1;}
         }
         ($1 ~ /^vlan[0-9]/ && !($1 in ignored_dict)) {print $1;}' | sed 's/://' |\
         while read intf; do
            echo "# Deleting vlan interface $intf"
             $FWBDEBUG $IFCONFIG $intf destroy || exit 1
         done

    for intf in $*; do
        $IFCONFIG $intf >/dev/null 2>&1 || {
            echo "# Creating vlan interface $intf"
            $FWBDEBUG $IFCONFIG $intf create || exit 1
        }
    done
}