New user's registration have been closed due to high spamming and low trafic on this forum. Please contact forum admins directly if you need an account. Thanks !

update.php patch

Want new functionality in Bubba? Discuss it here.
Locked
Ubi
Posts: 1549
Joined: 17 Jul 2007, 09:01

update.php patch

Post by Ubi »

I noticed some users got into trouble by uncommenting their sources.php and subsequently do an update via the web interface. This can easily be avoided by having the update software check the uncommenting. Here's a quick patch for update.php that does this. Maybe an idea to implement this into future versions?

Code: Select all

9,15d8
<    #check if user messed up the sources file
<    $cmd="grep -v \"#\" /etc/apt/sources.list | grep deb | wc -l";
<    exec($cmd, $out, $ret);
<    if ($out[0] != 1) {
<        print "you messed with the sources.list. No updates for you!<br>";
<        flush();
<    } else {
36,37d28
<       };
<
Ubi
6feet5
Posts: 269
Joined: 13 Apr 2007, 17:32
Location: Gnesta, Sweden
Contact:

Post by 6feet5 »

A couple of months ago I managed to make a mess of it all after I forgot to restore 'sources.list'. And a week later I made the same mistake once again. I guess I'm one of those who never learn.
I then wrote a couple of scripts that will make it easier to change repositories but also restore it automatically to a safe state.

I have two files, named '/etc/apt/sources.excito' and '/etc/apt/sources.debian', that will include excito only or also debian. My '/etc/apt/sources.list' is a symlink that will point at one of these files depending on what I need. A script named 'set_repo' takes 'debian' or 'excito' as argument and will redirect the link when needed. This makes it easy to swap repository. Now, as a protection against my own stupidity and bad memory, I have an hourly cron job that will examine '/etc/apt/sources.list' and detect active (uncommented) debian repositories. If one or more are found, it will restore the symlink to point at the excito-file. This script also detects if any one is logged on, and if so aborts, so that it doesn't try to restore the link when I am logged in and actually want it to point at debian.

It's not fool proof like your solution, but at least one will probably get the upgrade without problems even if file was edited. There is still a window of opportunity, after a file change until the cron job kicks in and sorts it out, for mr Murphy to destroy it all. Running the cron job more often will make that window smaller, but I think one hour is safe enough. At least I haven't manage to make a mess of it yet :-)

/Johan
Locked