This file is indexed.

/usr/share/migration-assistant/ma-script-utils is in ubiquity 2.10.16.

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

. /usr/share/debconf/confmodule

newns () {
	[ "$OS_PROBER_NEWNS" ] || exec /usr/lib/os-prober/newns "$0" "$@"
}

error () {
    logger -t migration-assistant "error: $@"
}

log () {
    logger -t migration-assistant "info: $@"
}

ostype=""
set_os_type () {
# Rather than test for every distro possible in the shortname, we test
# the bootloader type for 'linux.'  This *should* be fine as we're only
# working with user's home directories.

    if [ ${1##*:} = "linux" ]; then
	ostype="linux"
	return 0
    fi
    
    case `LC_ALL=C expr match "$1" '.*:.*:\(.*\):.*'` in
	"Windows" )
	ostype="windowsxp"
        return 0
	;;

        Windows[0-9] )
        ostype="windowsxp"
        return 0
        ;;

	"Windows9xMe" )
	ostype="windows9x"
        return 0
	;;

	"MacOSX" )
	ostype="macosx"
        return 0
	;;

    *)
    echo "Unknown ostype from $1" 1>&2
    return 1
    ;;
    esac
}
mountpoint="/mnt/migrationassistant"

unmount_os() {
    # If we didn't mount the device ourselves, don't unmount it.
    [ "$mountpoint" = "/mnt/migrationassistant" ] || return 0
    unmount_previously_run=
    device="$1"

    if [ -f /etc/mtab ]; then
        MTAB=/etc/mtab
    else
        MTAB=/proc/mounts
    fi

    while :; do
        failed=
        
	ISMOUNTED=
	if [ "$device" ]; then
		ISMOUNTED=$(grep "^$device " $MTAB) || ISMOUNTED=
	else
		ISMOUNTED=$(grep " $mountpoint " $MTAB) || ISMOUNTED=
	fi
        if [ -z "$ISMOUNTED" ]; then
	        break
        fi
        HOME=$(grep " $mountpoint/home " $MTAB) || HOME=
        if [ "$HOME" ]; then
            umount "$mountpoint/home" || failed="$mountpoint/home"
        fi
        if [ -z "$failed" ]; then
            if [ -z "$device" ]; then
                umount $mountpoint || failed="$mountpoint"
            else
                umount $device || failed="$device"
            fi
        fi

        if [ -z "$failed" ]; then
            break
        fi
        # lets try waiting briefly once before we completely give up on
        # unmounting the partition and dump the problem on the user.
        if [ -z "$unmount_previously_run" ]; then
            unmount_previously_run=1
            sleep 15
            continue
        fi

        db_reset migration-assistant/failed-unmount
        db_subst migration-assistant/failed-unmount MOUNTED "$failed"
        db_input critical migration-assistant/failed-unmount || true
        db_go || exit 10
        db_get migration-assistant/failed-unmount
        [ "$RET" = true ] || exit 10
    done
}

mount_os () {
    ostype="$1"
    device="$2"

    if [ "$1" = "linux" ]; then
        mkdir -p $mountpoint
        unmount_os $device
        if ! mount $device $mountpoint; then
            error "Failed to mount $device"
            exit 1
        fi
        if [ -f "$mountpoint/etc/fstab" ]; then
            while read uuid mp rest; do
                echo "$uuid" | grep -q '^#' && continue
                if [ "$mp" != "/home" ]; then
                    continue
                fi
                devname=
                if [ -n "${uuid#*=}" ]; then
                    if [ "${uuid%=*}" = "UUID" ]; then
                        devname="/dev/disk/by-uuid/${uuid#*=}"
                    elif [ "${uuid%=*}" = "LABEL" ]; then
                        devname="/dev/disk/by-label/${uuid#*=}"
                    fi
                fi
                if [ -n "$devname" ]; then
                    uuid=$(readlink -e "$devname") || uuid=
                    if [ -z "$uuid"]; then
                        error "$devname does not exist."
                        return 1
                    fi
                else
                    error "couldn't understand $uuid."
                    return 1
                fi
                
                if [ ! -e "$uuid" ]; then
                    # This happens when the IDE driver in the old OS
                    # doesn't match the driver in the installer.  The old
                    # /home might be mounted on /dev/hda3 which could now
                    # be /dev/sda3 or something entirely different.  Since
                    # there's no way to determine what the device is
                    # without the old kernel loaded, we fail gracefully so
                    # that we can continue to the next OS.
                    error "$uuid does not exist."
                    return 1
                fi
                if ! mount $uuid "$mountpoint/home"; then
                    unmount_os "$uuid"
                    if ! mount $uuid "$mountpoint/home"; then
                        error "failed to mount $uuid"
                        return 1
                    fi
                fi
                break
            done < "$mountpoint/etc/fstab"
        fi
    elif [ "$1" = "windowsxp" ]; then
        # Since we don't have to worry about separate partitions making up the
        # whole system in Windows (yet), we can allow already mounted
        # partitions.  This may fix some corner cases.  At any rate, it's
        # required for Wubi to function properly.
        mnt=$(grep "$device" /proc/mounts | head -n1 | cut -d " " -f 2)
        [ -z "$mnt" ] && [ -f /etc/mtab ] && mnt=$(grep "$device" /etc/mtab | head -n1 | cut -d " " -f 2)
        [ -n "$mnt" ] && mountpoint=$mnt && return 0

        mkdir -p $mountpoint
        unmount_os $device
        if ! mount -t ntfs $device $mountpoint -o umask=0022,nls=utf8 3>&-; then
            log "Mounting $device to $mountpoint with NTFS failed."
            if ! mount -t vfat $device $mountpoint -o umask=0022,utf8; then
                log "Mounting $device to $mountpoint with VFAT failed."
                return 1
            fi
        fi
    fi
}

ROOT=/target
add_user() {
    local username
    local fullname
    local password

    username="$1"
    fullname="$2"
    password="$3"

    chroot=chroot

# Taken from user-setup/user-setup-apply

	# Add the user
	if [ -x $ROOT/usr/sbin/adduser ]; then
		$chroot $ROOT adduser --disabled-password --gecos \
		"$fullname" "$username" >/dev/null || true
	else
		$chroot $ROOT useradd -c "$fullname" -m "$username" >/dev/null || true
	fi

	# Set the password
	$chroot $ROOT chpasswd <<EOF
$username:$password
EOF

	# Add the user to groups
	if [ -n "$username" ]; then
		db_get passwd/user-default-groups
		for group in $RET; do
			log $chroot $ROOT adduser "$USER" $group >/dev/null 2>&1 || true
		done
	fi
}
# vim:ai:et:sts=4:tw=80:sw=4: