This file is indexed.

/usr/share/grub/grub-mkconfig_lib is in grub-common 1.99-27+deb7u3.

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
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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
# Helper library for grub-mkconfig
# Copyright (C) 2007,2008,2009,2010  Free Software Foundation, Inc.
#
# GRUB 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.
#
# GRUB 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 GRUB.  If not, see <http://www.gnu.org/licenses/>.

transform="s,x,x,"

prefix="/usr"
exec_prefix="${prefix}"
datarootdir="${prefix}/share"
datadir="${datarootdir}"
bindir="${exec_prefix}/bin"
sbindir="${exec_prefix}/sbin"
pkgdatadir="${datadir}/`echo "grub" | sed "${transform}"`"

if test "x$grub_probe" = x; then
  grub_probe="${sbindir}/`echo grub-probe | sed "${transform}"`"
fi
if test "x$grub_mkrelpath" = x; then
  grub_mkrelpath="${bindir}/`echo grub-mkrelpath | sed "${transform}"`"
fi

if $(which gettext >/dev/null 2>/dev/null) ; then
  gettext="gettext"
else
  gettext="echo"
fi

grub_warn ()
{
  echo "Warning: $@" >&2
}

make_system_path_relative_to_its_root ()
{
  "${grub_mkrelpath}" "$1"
}

is_path_readable_by_grub ()
{
  path="$1"

  # abort if path doesn't exist
  if test -e "$path" ; then : ;else
    return 1
  fi

  # abort if file is in a filesystem we can't read
  if "${grub_probe}" -t fs "$path" > /dev/null 2>&1 ; then : ; else
    return 1
  fi

  # ... or if we can't figure out the abstraction module, for example if
  # memberlist fails on an LVM volume group.
  if ${grub_probe} -t abstraction $path > /dev/null 2>&1 ; then : ; else
    return 1
  fi

  return 0
}

convert_system_path_to_grub_path ()
{
  path="$1"

  grub_warn "convert_system_path_to_grub_path() is deprecated.  Use prepare_grub_to_access_device() instead."

  # abort if GRUB can't access the path
  if is_path_readable_by_grub "${path}" ; then : ; else
    return 1
  fi

  if drive="`"${grub_probe}" -t drive "$path"`" ; then : ; else
    return 1
  fi

  if relative_path="`make_system_path_relative_to_its_root "$path"`" ; then : ; else
    return 1
  fi

  echo "${drive}${relative_path}"
}

save_default_entry ()
{
  if [ "x${GRUB_SAVEDEFAULT}" = "xtrue" ] ; then
    cat << EOF
savedefault
EOF
  fi
}

prepare_grub_to_access_device ()
{
  device="$1"

  loop_file=
  case ${device} in
    /dev/loop/*|/dev/loop[0-9])
      grub_loop_device="${device#/dev/}"
      loop_file=`losetup "${device}" | sed -e "s/^[^(]*(\([^)]\+\)).*/\1/"`
      case $loop_file in
        /dev/*) ;;
        *)
          loop_device="${device}"
          device=`"${grub_probe}" --target=device "${loop_file}"`
        ;;
      esac
    ;;
  esac

  if dmsetup status $device 2>/dev/null | grep -q 'crypt[[:space:]]$'; then
    grub_warn \
      "$device is a crypto device, which GRUB cannot read directly.  Some" \
      "necessary modules may be missing from /boot/grub/grub.cfg.  You may" \
      "need to list them in GRUB_PRELOAD_MODULES in /etc/default/grub.  See" \
      "http://bugs.debian.org/542165 for details."
    return 0
  fi

  # Abstraction modules aren't auto-loaded.
  abstraction="`"${grub_probe}" --device "${device}" --target=abstraction`"
  for module in ${abstraction} ; do
    echo "insmod ${module}"
  done

  partmap="`"${grub_probe}" --device "${device}" --target=partmap`"
  for module in ${partmap} ; do
    case "${module}" in
      netbsd | openbsd)
        echo "insmod part_bsd";;
      *)
        echo "insmod part_${module}";;
    esac
  done

  fs="`"${grub_probe}" --device "${device}" --target=fs`"
  for module in ${fs} ; do
    echo "insmod ${module}"
  done

  # If there's a filesystem UUID that GRUB is capable of identifying, use it;
  # otherwise set root as per value in device.map.
  echo "set root='`"${grub_probe}" --device "${device}" --target=drive`'"
  if fs_uuid="`"${grub_probe}" --device "${device}" --target=fs_uuid 2> /dev/null`" ; then
    echo "search --no-floppy --fs-uuid --set=root ${fs_uuid}"
  fi

  if [ "x${loop_file}" != x ]; then
    loop_mountpoint="$(awk '"'${loop_file}'" ~ "^"$2 && $2 != "/" { print $2 }' /proc/mounts | tail -n1)"
    if [ "x${loop_mountpoint}" != x ]; then
      echo "loopback ${grub_loop_device} ${loop_file#$loop_mountpoint}"
      echo "set root=(${grub_loop_device})"
    fi
  fi
}

grub_file_is_not_garbage ()
{
  if test -f "$1" ; then
    case "$1" in
      *.dpkg-*) return 1 ;; # debian dpkg
      README*|*/README*)  return 1 ;; # documentation
    esac
  else
    return 1
  fi
  return 0
}

version_test_numeric ()
{
  local a="$1"
  local cmp="$2"
  local b="$3"
  if [ "$a" = "$b" ] ; then
    case "$cmp" in
      ge|eq|le) return 0 ;;
      gt|lt) return 1 ;;
    esac
  fi
  if [ "$cmp" = "lt" ] ; then
    c="$a"
    a="$b"
    b="$c"
  fi
  if (echo "$a" ; echo "$b") | sort -n | head -n 1 | grep -qx "$b" ; then
    return 0
  else
    return 1
  fi
}

version_test_gt ()
{
  local sedexp="s/[^-]*-//;s/[._-]\(pre\|rc\|test\|git\|old\|trunk\)/~\1/g"
  local a="`echo "$1" | sed -e "$sedexp"`"
  local b="`echo "$2" | sed -e "$sedexp"`"
  local cmp=gt
  if [ "x$b" = "x" ] ; then
    return 0
  fi
  case "$a:$b" in
    *.old:*.old) ;;
    *.old:*) a="`echo -n "$a" | sed -e 's/\.old$//'`" ; cmp=gt ;;
    *:*.old) b="`echo -n "$b" | sed -e 's/\.old$//'`" ; cmp=ge ;;
  esac
  dpkg --compare-versions "$a" $cmp "$b"
  return "$?"
}

version_find_latest ()
{
  local a=""
  for i in "$@" ; do
    if version_test_gt "$i" "$a" ; then
      a="$i"
    fi
  done
  echo "$a"
}

# One layer of quotation is eaten by "", the second by sed, and the third by
# printf; so this turns ' into \'.  Note that you must use the output of
# this function in a printf format string.
gettext_quoted () {
  "$gettext" "$@" | sed "s/'/'\\\\\\\\''/g"
}

# Run the first argument through gettext_quoted, and then pass that and all
# remaining arguments to printf.  This is a useful abbreviation and tends to
# be easier to type.
gettext_printf () {
  local format="$1"
  shift
  printf "$(gettext_quoted "$format")" "$@"
}

uses_abstraction () {
  device="$1"

  abstraction="`"${grub_probe}" --device "${device}" --target=abstraction`"
  for module in ${abstraction}; do
    if test "x${module}" = "x$2"; then
      return 0
    fi
  done
  return 1
}