LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   etc-update for Slackware (https://www.linuxquestions.org/questions/slackware-14/etc-update-for-slackware-378673/)

uselpa 10-31-2005 01:33 PM

etc-update for Slackware
 
I have started developing something like etc-update (from Gentoo) for Slackware. The purpose of the script is to look for ".new" configuration files and to find out whether they are identical with the old version or not.
If you are interested in contributing ideas, feel free to download the script from here. I'd appreciate your feedback and ideas.

Alien Bob 10-31-2005 02:12 PM

You know that the Slackware packages only leave .new files when they are different from the originals? The install script deletes any .new files if they are identical to the file that is found already installed on the computer.

Eric

uselpa 10-31-2005 02:21 PM

No, I did not know that. Does this include checks of file modes, gid, uid in addition to contents?
When I did the upgrade from 10.1 to 10.2, I sure found some identical files if I am not mistaken.

rkelsen 10-31-2005 03:56 PM

Quote:

Originally posted by uselpa
No, I did not know that. Does this include checks of file modes, gid, uid in addition to contents?
When I did the upgrade from 10.1 to 10.2, I sure found some identical files if I am not mistaken.

It checks md5sums. There is no way any identical files were left on your system. They must have been different. Even if only slightly.

uselpa 10-31-2005 04:33 PM

Code:

root@slackw:/sbin$ grep -i md5sum *
installpkg:#  MD5SUM=`md5sum $package | cut -f 1 -d ' '`
installpkg:#  echo "PACKAGE MD5SUM: $MD5SUM" >> $ADM_DIR/packages/$shortname

The only reference I can find to md5 is in remarks. Can you tell me where the md5 check is performed?

rkelsen 10-31-2005 07:49 PM

Quote:

Originally posted by uselpa
The only reference I can find to md5 is in remarks.
That's because you're looking in the wrong spot. Look under /var/log/scripts and 'cat' the script of any package which installs files under /etc.

For example, this is an extract from the udev package script:
Code:

config() {
  NEW="$1"
  OLD="`dirname $NEW`/`basename $NEW .new`"
  # If there's no config file by that name, mv it over:
  if [ ! -r $OLD ]; then
    mv $NEW $OLD
  elif [ "`cat $OLD | md5sum`" = "`cat $NEW | md5sum`" ]; then # toss the redundant copy
    rm $NEW
  fi
  # Otherwise, we leave the .new copy for the admin to consider...
}
config etc/rc.d/rc.udev.new

HTH.

uselpa 11-01-2005 04:46 AM

OK, so it's not standard upgradepkg behaviour, but up to the post-install script. Thanks for the info.
Anyway, the case might happen for whatever reason so I want to be able to manage it.

Nobber 11-01-2005 05:04 AM

Off topic slightly, but does anyone know the probability that two different files will have the same MD5 checksum?

Nobber 11-01-2005 09:18 AM

OK, I'll assume that the "obvious" answer is the correct one: 1 in 2^128 (since MD5 generates a 128-bit checksum).

uselpa 11-01-2005 11:12 AM

Nobber, I don't know. What I know is that I don't trust md5. When I wrote a program to find duplicate files, I compared the files bytewise. All other programs I know of use hashed like md5 or sha1. In both, collisions exist.

Back to etc-update. As having completely identical files is obviously the exception, I added an 'act' mode. In act mode, you can compare and modify the config files. I guess it looks more like the Gentoo tool now.

Feedback is welcome. Have a look at the documentation for more explanation. And use with care.

The link is still the same

Nobber 11-01-2005 11:18 AM

Quote:

Originally posted by uselpa
All other programs I know of use hashed like md5 or sha1. In both, collisions exist.
True, but the probability of a collision is vanishingly small. You're far more likely to be abducted by aliens on a wet Tuesday in May than to find an MD5 hash collision in your lifetime!

uselpa 11-01-2005 11:23 AM

Quote:

Originally posted by Nobber
True, but the probability of a collision is vanishingly small. You're far more likely to be abducted by aliens on a wet Tuesday in May than to find an MD5 hash collision in your lifetime!
Here we go again.. why be less than certain if you can be 100% sure?

Nobber 11-01-2005 01:00 PM

Even a byte-by-byte comparison can give the wrong answer if there are hardware failures. ;)

uselpa 11-02-2005 11:44 AM

Getting back to the subject, I have released a new version that now uses vimdiff, i.e. vim, to visually manage the differences in the configuration files. I have also added a transcript of an interactive session to the doc and hence to the homepage.

I think that the script is now getting close to usable. I'll stop advertising it here, but I do appreciate all feedback, positive or negative, provided that "grep -i md5" and "grep -i alien" are empty.


All times are GMT -5. The time now is 03:11 PM.