Tftpd upgrade deleted /var/tftpboot

As the title said, during the tftpd upgrade, the update script deleted /var/tftpboot directory (iPXE scripts, pxelinux.cfg scripts, various GNU/Linux installations that are mounted via NFS, everything)

-bash-5.2$ ps -ef|grep tftp
root     32303 28676  0 23:33 pts/1    00:00:00 sh -c cd /opt/pakfire/tmp && NAME=tftpd ./update.sh >> /opt/pakfire/logs/update-tftpd.log 2>&1

-bash-5.2$ cd /opt/pakfire/tmp
-bash-5.2$ cat update.sh
#!/bin/bash
. /opt/pakfire/lib/functions.sh
extract_backup_includes
./uninstall.sh <---
./install.sh

-bash-5.2$ cat uninstall.sh

#!/bin/bash
. /opt/pakfire/lib/functions.sh
stop_service tftpd
make_backup ${NAME}
remove_files <---
rm -rf /etc/rc.d/rc*.d/*tftpd

-bash-5.2$ view /opt/pakfire/lib/functions.sh

. /etc/sysconfig/rc
. $rc_functions

TAR_OPTIONS=(
        --acls
        --xattrs
        --xattrs-include='*'
        --no-overwrite-dir
        --no-delay-directory-restore
        --preserve-permissions
        --numeric-owner
)

extract_files() {
        echo "Extracting files..."
        tar -xavf /opt/pakfire/tmp/files* "${TAR_OPTIONS[@]}" -C /
        sync
        echo "...Finished."
}

extract_backup_includes() {
        echo "Extracting backup includes..."
        tar xavf /opt/pakfire/tmp/files* "${TAR_OPTIONS[@]}" -C / \
                var/ipfire/backup/addons/includes
        sync
        echo "...Finished."
}

remove_files() { <---
        echo "Removing files..."
        for i in $(cat /opt/pakfire/db/rootfiles/${NAME}); do
            rm -rfv /${i}
        done
        echo "...Finished."
}

-bash-5.2$ cat /opt/pakfire/db/rootfiles/tftp

etc/rc.d/init.d/tftpd
usr/bin/tftp
usr/sbin/tftpd
var/tftpboot

There’s nothing here that I cannot recover from because all scripts are in my self-hosted gitea instance and I can just debootstrap the GNU/Linux installs again anyway but there are a couple of issues here:

  1. tftpd addon doesn’t come with it’s own /var/ipfire/backup/addons/includes file
  2. If an includes file is made part of the tftpd addon, should it even include the /var/tftpboot? I ask this because the make_backup function backs up everything from the includes file of an addon. Given that the /var/tftpboot will potentially have lots of files and is ideally on a separate disk from the iPFire installation - in my case it’s on an NFS mount - which will not only prolong the upgrade but more importantly fill up the IPFire filesystem

And lastly, do changes done manually to files in /var/ipfire/backup/addons/includes remain after an addon gets upgraded?

Looking at the rootfile and the install/uninstall scripts then yes that would happen. The /var/tftpboot directory was added into the rootfile just over two years ago as before that tftpd kept throwing a “missing Directory” error on startup.

No one has flagged anything up since then but then also there hasn’t been any update of the program so normally no upgrade would happen but in Core Update 188 tftpd had to be shipped (causes an upgrade cycle) due to having to fix the build of tftpd (and some other addons) with GCC 14. That may have been what caused the loss of that directory from your system. Of course the same thing will happen if tftpd gets updated with a new version.

I have looked through the IPFire git repo and yes you are correct. No-one has flagged this up before or raised a bug about it so it was not known about.

Based on what you are saying, having the addon backup include /var/tftpboot/ would not seem like a good idea but then it is also not clear how to deal with this.

If the directory is commented out in the rootfile then it will not be removed during an upgrade but there will then be error messages about the directory being missing when tftpd is started.

I will raise this as an agenda topic for our next development video call to discuss and see how to overcome this.

If by manually, you mean mean adding extra lines to the includes file, then those will be lost during an upgrade as the includes file, if existing, would also be replaced.

However, there is a way around. There is a file

/var/ipfire/backup/include.user

where you can specify the directories/files that you want to be backed up as part of the general .ipfire backup file.

I have mine with the following content specified

home/user1
home/fcronuser/
etc/sudoers
etc/fcron.conf
etc/fcron.allow
var/spool/cron/fcronuser*
etc/sudoers.d/01-user1
etc/sudoers.d/02-fcronuser

and these are files/directories that contain additional or changed settings. Adding them to the include.user file makes sure they are backed up.

So until a conclusion can be reached about the tftpd includes file, you could add what you want to the include.user file.

2 Likes

Thanks for the prompt reply. One more thing, while fiddling around I also noticed that lcdproc has an empty /var/ipfire/backup/addons/includes/lcdproc file hence no backup for the addon is created. I added /etc/lcdproc to /var/ipfire/backup/include.user for now.