This file is indexed.

/usr/sbin/update-java-alternatives is in java-common 0.47.

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
#! /bin/bash

shopt -s dotglob

prog=$(basename $0)

usage()
{
    rv=$1
    cat >&2 <<-EOF
	usage: $prog [--jre-headless] [--jre] [--plugin] [ -t|--test|-v|--verbose]
	           -l|--list [<jname>]
	           -s|--set <jname>
	           -a|--auto
	           -h|-?|--help
	EOF
    exit $rv
}

action=
uaopts='--quiet'

while [ "$#" -gt 0 ]; do
    case "$1" in
      -a|--auto)
	[ -z "$action" ] || usage 1
	action=auto;;
      -hl|--jre-headless)
	hlonly=yes;;
      -j|--jre)
	jreonly=yes;;
      --plugin)
	pluginonly=yes;;
      -l|--list)
	[ -z "$action" ] || usage 1
	action=list
	if [ "$#" -gt 0 ]; then
	    shift
	    jname=$1
	fi
	;;
      -s|--set)
	[ -z "$action" ] || usage 1
	action=set
	shift
	[ "$#" -gt 0 ] || usage 1
	jname=$1
	;;
      -t|--test)
	dryrun=yes
	uaopts="$uaopts --test";;
      -v|--verbose)
	verbose=yes
	uaopts="${uaopts/--quiet/}";;
      -h|-?|--help)
	usage 0;;
      -*)
	echo "X: $1"
	usage 1;;
      *)
	break;;
    esac
    shift
done

[ "$#" -eq 0 ] || usage 1
[ -n "$action" ] || usage 1

which='^(hl|jre|jdk|plugin|DUMMY) '
if [ -n "$hlonly$jreonly$pluginonly" ]; then
    which='^('
    [ -n "$hlonly" ] && which="${which}hl|"
    [ -n "$jreonly" ] && [ -n "$hlonly" ] && which="${which}jre|"
    [ -n "$jreonly" ] && [ -z "$hlonly" ] && which="${which}hl|jre|"
    [ -n "$pluginonly" ] && which="${which}plugin|"
    which="${which}DUMMY) "
fi

top=/usr/lib/jvm

if [ -n "$jname" ]; then
    arch=$(dpkg --print-architecture)
    if [ ! -x $top/$jname/bin/java ] && [ -x $top/$jname-$arch/bin/java ]; then
	echo >&2 "$prog: obsolete <jname>, please use $jname-$arch instead"
	jname=$jname-$arch
    fi
    case "$jname" in
	/*) jdir=$jname; jname=$(basename $jdir);;
	*)  jdir=$top/$jname
    esac
    if [ ! -d $jdir ]; then
	echo >&2 "$prog: directory does not exist: $jdir"
	exit 1
    fi
    if [ -f $top/.$jname.jinfo ]; then
	jinfo=$top/.$jname.jinfo
    elif [ -f $top/$jname.jinfo ]; then
	jinfo=$top/$jname.jinfo
    else
	echo >&2 "$prog: file does not exist: $top/.$jname.jinfo"
	exit 1
    fi
fi

vecho()
{
    [ -z "$verbose" ]  || echo >&2 "$@"
}

jinfo_files=

do_auto()
{
    vecho "resetting java alternatives"
    awk "/$which/ {print \$2}" $top/*.jinfo | sort -u \
	| \
    while read name; do
	update-alternatives $uaopts --auto $name
    done
}

do_list()
{
    vecho "listing java alternatives:"
    for i in ${jinfo:-$top/*.jinfo}; do
	alias=$(basename ${i%.jinfo})
	alias=${alias#.}
	prio=$(awk -F= '/priority=/ {print $2}' $i)
	echo $alias $prio $top/$alias
	[ -n "$verbose" ] && egrep "$which" $i
    done
}

do_set()
{
    do_auto

    awk "/$which/ {print}" $jinfo | sort -u \
	| \
    while read type name location; do
	if [ $type = jdk -a -z "$hlonly$jreonly$pluginonly" -a ! -f $location ]; then
	    echo >&2 "$prog: jdk alternative does not exist: $location"
	    continue
	fi
	if [ $type = plugin -a -z "$hlonly$jreonly" -a ! -f $location ]; then
	    echo >&2 "$prog: plugin alternative does not exist: $location"
	    continue
	fi
	update-alternatives $uaopts --set $name $location
    done
}

if [ "$action" != list ] && [ "$(id -u)" -ne 0 ]; then
    echo >&2 "$prog: no root privileges"
    exit 1
fi

do_$action