This file is indexed.

/usr/bin/ucfr is in ucf 3.0027+nmu1.

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
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
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
#! /bin/bash
#                               -*- Mode: Sh -*-
# ucfr ---
# Author           : Manoj Srivastava ( srivasta@glaurung.internal.golden-gryphon.com )
# Created On       : Tue Apr 11 11:09:15 2006
# Created On Node  : glaurung.internal.golden-gryphon.com
# Last Modified By : Manoj Srivastava
# Last Modified On : Tue Apr 11 13:50:58 2006
# Last Machine Used: glaurung.internal.golden-gryphon.com
# Update Count     : 43
# Status           : Unknown, Use with caution!
# HISTORY          :
# Description      :
#
# Register a configuration file as belonging to a package
#
# arch-tag: 6e1d33fe-a930-41ce-8d0f-c87f87b19918
#

# make sure we exit on error
set -e

# set the version and revision
progname=$(basename "$0")

######################################################################
########                                                     #########
########              Utility functions                      #########
########                                                     #########
######################################################################
setq() {
    # Variable Value Doc_string
    if [ "x$2" = "x" ]; then
	echo >&2 "$progname: Unable to determine $3"
	exit 1;
    else
	if [ "x$VERBOSE" != "x" ]; then
	    echo >&2 "$progname: $3 is $2";
	fi
	eval "$1=\"\$2\"";
    fi
}

withecho () {
        echo " $@" >&2
        "$@"
}


purge_from_registry () {
    if [ ! -e "$statedir/registry" ]; then
        echo >&2 "$progname: Internal error: $statedir/registry does not exist";
        exit 6;
    fi

    if [ $count -eq 0 ]; then
        if [ "X$VERBOSE" != "X" ]; then
            echo >&2 "$progname: Association already purged. No changes.";
        fi
        exit 0;
    fi
    old_pkg=$(egrep "[[:space:]]${safe_conf_file}$" "$statedir/registry" | \
        awk '{print $1;}' );
    if [ "$pkg" != "$old_pkg"  ]; then
        echo >&2 "ucfr: Association belongs to $old_pkg, not $pkg";
        if [ "X$FORCE" = "X" ]; then
            echo >&2 "ucfr: Aborting";
            exit 5;
        fi
    fi

    # OK, so we have something to purge.
    for i in $(/usr/bin/seq 6 -1 0); do
	if [ -e "${statedir}/registry.${i}" ]; then
	    if [ "X$docmd" = "XYES" ]; then
		cp -f "${statedir}/registry.${i}"  "${statedir}/registry.$(($i+1))"
	    else
		echo cp -f "${statedir}/registry.${i}" "${statedir}/registry.$(($i+1))"
	    fi
	fi
    done
    if [ "X$docmd" = "XYES" ]; then
	cp -f "$statedir/registry"  "$statedir/registry.0"
    else
	echo cp -f "$statedir/registry"  "$statedir/registry.0"
    fi
    if [ "X$docmd" = "XYES" ]; then
	set +e
	if [ "X$VERBOSE" != "X" ]; then
	    echo "egrep -v [[:space:]]${safe_conf_file}$ $statedir/registry >\\"
            echo "	$statedir/registry.tmp || true";
	fi
	#echo "egrep -v [[:space:]]${safe_conf_file}$ $statedir/registry"
	egrep -v "[[:space:]]${safe_conf_file}$" "$statedir/registry" > \
	    "$statedir/registry.tmp" || true;
	if [ "X$docmd" = "XYES" ]; then
	    mv -f "$statedir/registry.tmp"  "$statedir/registry"
	else
	    echo mv -f "$statedir/registry.tmp"  "$statedir/registry"
	fi
	set -e
    fi
}

replace_in_registry () {
    if [ ! -e "$statedir/registry" ]; then
        echo >&2 "$progname: Internal error: $statedir/registry does not exist";
        exit 6;
    fi
    if [ $count -eq 1 ]; then
        old_pkg=$(egrep "[[:space:]]${safe_conf_file}$" "$statedir/registry" | \
            awk '{print $1;}' );

        if [ "$pkg" != "$old_pkg" ]; then
            if [ "X$FORCE" = "X" ]; then
                echo >&2 "$progname: Attempt from package $pkg  to take ${conf_file} away from package $old_pkg";
                echo >&2 "ucfr: Aborting.";
                exit 4;
            fi
        else
            if [ "X$VERBOSE" != "X" ]; then
                echo >&2 "$progname: Association already recorded. No changes.";
            fi
            exit 0;
        fi
    fi

    for i in $(/usr/bin/seq 6 -1 0); do
	if [ -e "${statedir}/registry.${i}" ]; then
	    if [ "X$docmd" = "XYES" ]; then
		cp -f "${statedir}/registry.${i}" \
		    "${statedir}/registry.$(($i+1))"
	    else
		echo cp -f "${statedir}/registry.${i}" \
		    "${statedir}/registry.$(($i+1))"
	    fi
	fi
    done
    if [ "X$docmd" = "XYES" ]; then
	cp -f "$statedir/registry"  "$statedir/registry.0"
    else
	echo cp -f "$statedir/registry"  "$statedir/registry.0"
    fi
    if [ "X$docmd" = "XYES" ]; then
	set +e
	if [ "X$VERBOSE" != "X" ]; then
	    echo "egrep -v \"[[:space:]]${safe_conf_file}$\" \"$statedir/registry\"  \\"
            echo "	$statedir/registry.tmp || true"
	    echo "echo \"$pkg 	 $conf_file\" >> \"$statedir/registry.tmp\""
	    echo "mv -f  $statedir/registry.tmp $statedir/registry"
	fi
	egrep -v "[[:space:]]${safe_conf_file}$" "$statedir/registry" > \
	    "$statedir/registry.tmp" || true;
	echo "$pkg 	 $conf_file" >>   "$statedir/registry.tmp";
	mv -f "$statedir/registry.tmp"  "$statedir/registry"
	set -e
    else
	echo "egrep -v \"[[:space:]]${safe_conf_file}$\" \"$statedir/registry\"  \\"
        echo "	$statedir/registry.tmp || true"
	echo "echo \"$pkg 	 $conf_file\" >> \"$statedir/registry.tmp\""
	echo "mv -f  $statedir/registry.tmp $statedir/registry"
    fi
}


usageversion () {
        cat >&2 <<END
Debian GNU/Linux $progname $pversion.
           Copyright (C) 2002-2006 Manoj Srivastava.
This is free software; see the GNU General Public Licence for copying
conditions.  There is NO warranty.

Usage: $progname  [options] package_name path_for_configuration_file
Options:
     -h,     --help          print this message
     -f      --force         Force the association, even if another package
                             used to own the configuration file.
     -d [n], --debug    [n]  Set the Debug level to N
     -n,     --no-action     Dry run. No action is actually taken.
     -v,     --verbose       Make the script verbose
     -p,     --purge         Remove any reference to the package/file association
                             from the records
             --state-dir bar Set the state directory to bar instead of the
                             default '/var/lib/ucf'. Used mostly for testing.
END

}

######################################################################
########                                                     #########
########              Command line args                      #########
########                                                     #########
######################################################################
#
# Long term variables#
#
docmd='YES'
action='withecho'
action=
DEBUG=0
VERBOSE=''
statedir='/var/lib/ucf';
THREEWAY=

# Note that we use `"$@"' to let each command-line parameter expand to a
# separate word. The quotes around `$@' are essential!
# We need TEMP as the `eval set --' would nuke the return value of getopt.
TEMP=`getopt -a -o hd::D::fnvp -n "$progname" \
      --long help,debug::,DEBUG::,force,no-action,purge,verbose,state-dir: \
             -- "$@"`

if [ $? != 0 ] ; then
    echo "Error handling options.Terminating..." >&2 ;
    exit 1 ;
fi

# Note the quotes around `$TEMP': they are essential!
eval set -- "$TEMP"

while true ; do
    case "$1" in
	-h|--help) usageversion;                        exit 0  ;;
	-n|--no-action) action='echo'; docmd='NO';      shift   ;;
	-v|--verbose) VERBOSE=1;                        shift   ;;
	-f|--force)   FORCE=1;                          shift   ;;
	--state-dir)  opt_state_dir="$2";               shift 2 ;;
	-D|-d|--debug|--DEBUG)
            # d has an optional argument. As we are in quoted mode,
            # an empty parameter will be generated if its optional
            # argument is not found.
	    case "$2" in
		"") setq DEBUG 1    "The Debug value"; shift 2 ;;
		*)  setq DEBUG "$2" "The Debug value"; shift 2 ;;
	    esac ;;
        -p|--purge) PURGE=YES;                         shift   ;;
	--)  shift ;                                   break   ;;
	*) echo >&2 "$progname: Internal error!" ; exit 1 ;;
    esac
done
# Need to run as root, or else the
if test $(id -u) != 0; then
    if [ "$docmd" = "YES" ]; then
        echo "$progname: Need to be run as root." >&2
        echo "$progname: Setting up no action mode." >&2
        action='echo';
        docmd='NO';
    fi
fi

if [ $# != 2 ]; then
    echo >&2 "$progname: *** ERROR: Need exactly two arguments, got $#";
    echo >&2 ""
    usageversion;
    exit 3 ;
fi

setq pkg  "$1" "The Package name";
setq conf_file "$2" "The Configuration file";

safe_pkg=$(echo $pkg       | sed -e 's,+,\\+,')
safe_conf_file=$(echo $conf_file | sed -e 's,+,\\+,')

case $safe_conf_file in
    /*)
        : echo fine
        ;;
    *)
        echo >&2 "$progname: Need a fully qualified path for the file \"$safe_conf_file\""
        # Don't exit with an error for etch'
        exit 0;
esac

temp=$safe_conf_file
setq safe_conf_file "$(readlink -q -m $temp)" "The configuration file";

# Load site defaults and over rides.
if [ -f /etc/ucf.conf ]; then
    . /etc/ucf.conf
fi

# Command line, env variable, config file, or default
if [ ! "x$opt_state_dir" = "x" ]; then
    setq statedir "$opt_state_dir" "The State directory"
elif [ ! "x$UCF_STATE_DIR" = "x" ]; then
    setq statedir "$UCF_STATE_DIR" "The State directory"
elif [ ! "x$conf_state_dir" = "x" ]; then
    setq statedir "$conf_state_dir" "The State directory"
else
    setq statedir '/var/lib/ucf'  "The State directory"
fi

# VERBOSE of 0 is supposed to be the same as not setting VERBOSE
if [ "X$VERBOSE" = "X0" ]; then
    VERBOSE=''
fi

#
if [ -e "$statedir/registry" -a ! -w "$statedir/registry" ]; then
    echo >&2 "$progname: do not have write privilege to the registry data"
    if [ "X$docmd" = "XYES" ]; then
	exit 1;
    fi
fi

# test and see if this file exists in the database
if [ ! -d "$statedir" ]; then
    mkdir -p "$statedir"
fi

if [ ! -f "$statedir/registry" ]; then
    touch "$statedir/registry"
fi


if [ "X$VERBOSE" != "X" ]; then
    echo >&2 "$progname: The registry exists"
fi

# sanity check
count=$(egrep --count "[[:space:]]${safe_conf_file}$" "$statedir/registry") || true

if [ "$count" -ge 2 ]; then
    echo >&2 "$progname: Corrupt registry: Duplicate entries for ${conf_file}";
    egrep "[[:space:]]${safe_conf_file}$" "$statedir/registry";
    exit $count;
fi

if [ "X$PURGE" != "X" ]; then
    purge_from_registry $pkg $conf_file;
else
    replace_in_registry $pkg $conf_file;
fi


exit 0;