2007-06-04 09:35:56 PDT
I ran apt-mirror as root to do the initial mirroring. Then I enabled the cron job. Apparently, it was failing, even though the log file (/var/spool/apt-mirror/var/cron.log) showed no error messages. The reason is that the cron job runs as user apt-mirror, and by running it initially as root, its repository files were owned by root. Then the process started by cron could not overwrite necessary files.
There are two problems here. First, an ordinary execution creates a bad situation without warning. Second, there are no error messages being recorded even though the subsequent mirror attempts were failing.
Let me suggest two fixes.
1) Refuse to run as root, or switch effective user ID to "apt-mirror".
2) Change the default cron entry so that error messages are recorded.
0 1 * * * apt-mirror /usr/bin/apt-mirror > /var/spool/apt-mirror/var/cron.log 2>&1
--- /usr/bin/apt-mirror 2006-09-08 06:39:41.000000000 -0700
+++ apt-mirror 2007-06-04 09:27:56.000000000 -0700
@@ -94,6 +94,24 @@
######################################################################################
+## Ensure we don't run as root
+
+unless ($>) {
+ my @aptmirrornam = getpwnam "apt-mirror";
+ if (@aptmirrornam == 0) {
+ die "apt-mirror: this program should not be run as root\nuse \"su - USERNAME -c apt-mirror\" or similar\n";
+ }
+ $> = $aptmirrornam[2];
+ if ($!) {
+ die "apt-mirror: unable to set effective user id to $aptmirrornam[2] (apt-mirror): $!\n";
+ }
+ $) = $aptmirrornam[3];
+ if ($!) {
+ die "apt-mirror: unable to set effective group id to $aptmirrornam[3]: $!\n";
+ }
+}
+
+######################################################################################
## Setting up $config_file variable
$config_file = "/etc/apt/mirror.list"; # Default value