This file is indexed.

/usr/sbin/ocs-tux-postprocess is in clonezilla 3.5.2-2.

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
#!/bin/bash
# License: GPL 
# Author: Steven Shiau <steven _at_ nchc org tw>, Thomas Tsai <thomas _at_ nchc org tw>.
# Description: Program to clean some hardware record, e.g. NIC MAC address.

#
DRBL_SCRIPT_PATH="${DRBL_SCRIPT_PATH:-/usr/share/drbl}"
. $DRBL_SCRIPT_PATH/sbin/drbl-conf-functions
. /etc/drbl/drbl-ocs.conf
. $DRBL_SCRIPT_PATH/sbin/ocs-functions

#
USAGE() {
    echo "$ocs - To remove the Linux udev persistent files"
    echo "Usage:"
    echo "To run $ocs:"
    echo "$ocs [OPTION] [PARTITION]"
    echo "Options:"
    echo "-c, --cd-only    Remove Linux udev persistent CD file only."
    echo "-n, --net-only   Remove Linux udev persistent net file only."
    echo "PARTITION is the FAT partition device name, e.g. sda1, sdb1... If it's not assigned, all the partitions on the system will be searched."
    echo "By default both CD and net persistent files will be removed."
    echo "Ex:"
    echo "To remove both CD and net persistent files in disk sda1, run"
    echo "   $ocs sda1"
    echo
} # end of USAGE

# check available partitions
rm_udev_persistent_record() {
  local selected_dev="$*"  # selected_dev is like "sda1 sda2"
  local fs target_p

  if [ -z "$selected_dev" ]; then
    # Here we also search LVM, since udev persistent record could be inside that.
    get_partition_list true
    # partition_list is got from get_partition_list
    selected_dev="$partition_list"
  fi

  echo "Trying to remove udev persistent files. The devices to be searched: $selected_dev... "
  for ipartition in $selected_dev; do
    target_p="/dev/$ipartition"
    # Skip swap, FAT, NTFS, HFS+ partition...
    fs="$(LC_ALL=C ocs-get-part-info $target_p filesystem)"
    case "$fs" in
      fat*|vfat*|FAT*|VFAT*|ntfs|hfs|hfs+|hfsplus|ufs|vmfs|swap|"")
        [ -z "$fs" ] && fs="No file system. Extended partition?"
	echo "Skip $target_p ($fs)."
	;;
      *)
        echo "Now searching possible device $target_p..."
        hd_img="$(mktemp -d /tmp/hd_img.XXXXXX)"
        mount $target_p $hd_img >/dev/null 2>&1
        mrc=$?
	if [ "$mrc" -gt 0 ]; then
          [ -d "$hd_img" -a -n "$hd_img" ] && rmdir $hd_img
	  continue
        fi
	for inet in `get-nic-devs`; do
          # If MAC address is not found in 70-persistent-net.rules, it means the image is not restored to the same machine, therefore remove it. Even just one does not match.
          imac="$(LC_ALL=C drbl-get-macadd $inet)"
          if [ -e "$hd_img/etc/udev/rules.d/70-persistent-net.rules" -a \
          	"$remove_udev_nic" = "true" ]; then
             if ! grep -q -Ei "^SUBSYSTEM.*${imac}" $hd_img/etc/udev/rules.d/70-persistent-net.rules 2>/dev/null; then
               echo "MAC address $imac of $inet was not found in $hd_img/etc/udev/rules.d/70-persistent-net.rules. This persistent net file does not fit the hardware. Remove it."
               LC_ALL=C rm -fv $hd_img/etc/udev/rules.d/70-persistent-net.rules
	       break
             fi
          fi
        done
	for inet in `get-nic-devs`; do
          # If MAC address is not found in /etc/sysconfig/network-scripts/ifcfg-eth*, it means the image is not restored to the same machine, therefore remove it. Even just one does not match.
          imac="$(LC_ALL=C drbl-get-macadd $inet)"
	  if ! grep -q -Ei "^HWADDR=$imac" $hd_img/etc/sysconfig/network-scripts/ifcfg-eth* 2>/dev/null; then
            if ls $hd_img/etc/sysconfig/network-scripts/ifcfg-eth* &>/dev/null; then
              echo "MAC address $imac of $inet was not found in $hd_img/etc/sysconfig/network-scripts/ifcfg-eth*. This MAC data does not fit the hardware. Comment it."
              LC_ALL=C perl -pi -e 's/(^HWADDR=.*)/#$1 # Commented by Clonezilla/g' $hd_img/etc/sysconfig/network-scripts/ifcfg-eth*
	      break
            fi
          fi
        done
        if [ -e "$hd_img/etc/udev/rules.d/70-persistent-cd.rules" -a \
		"$remove_udev_cd" = "true" ]; then
          rm -fv $hd_img/etc/udev/rules.d/70-persistent-cd.rules
        fi
        [ "$mrc" -eq 0 ] && unmount_wait_and_try $target_p
        [ -d "$hd_img" -a -n "$hd_img" ] && rmdir $hd_img
	;;
    esac
  done
  echo "done!"
} # end of rm_udev_persistent_record
#

####################
### Main program ###
####################

ocs_file="$0"
ocs=`basename $ocs_file`

# Default settings
remove_udev_cd="true"
remove_udev_nic="true"
#
while [ $# -gt 0 ]; do
 case "$1" in
   -c|--cd-only) remove_udev_cd="true"
                 remove_udev_nic="false"
	         shift;;
   -n|--nic-only) 
	         remove_udev_cd="false"
                 remove_udev_nic="true"
	         shift;;
   -*)     echo "${0}: ${1}: invalid option" >&2
           USAGE >& 2
           exit 2 ;;
   *)      break ;;
 esac
done

ocs_hw_record_dev="$*"

#
check_if_root
ask_and_load_lang_set

#
echo "Trying to remove udev hardware record in the restored OS..."
if [ -n "$ocs_hw_record_dev" ]; then
  echo "The specified destination device: $ocs_hw_record_dev"
fi
rm_udev_persistent_record $ocs_hw_record_dev