File: debian-changes

package info (click to toggle)
anacron 2.3-43
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 420 kB
  • sloc: ansic: 2,530; makefile: 125; sh: 67
file content (1387 lines) | stat: -rw-r--r-- 43,166 bytes parent folder | download
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
Subject: collected Debian patches for anacron package
Author: Peter Eisentraut <petere@debian.org>
Forwarded: not-needed

The packaging for anacron is maintained in Git.  This makes it complex to
separate the changes into individual patches.  They are therefore all
included in a single Debian patch.

For full commit history and separated commits, see the packaging Git
repository.
--- anacron-2.3.orig/ChangeLog
+++ anacron-2.3/ChangeLog
@@ -1,3 +1,8 @@
+   Changes in Anacron 2.3.1
+   ------------------------
+* documentation no longer suggests adding local directories to the PATH
+
+
    Changes in Anacron 2.3
    ----------------------
 * anacron can now read an arbitrary anacrontab file, use the -t option
--- anacron-2.3.orig/Makefile
+++ anacron-2.3/Makefile
@@ -22,7 +22,7 @@
 PREFIX = 
 BINDIR = $(PREFIX)/usr/sbin
 MANDIR = $(PREFIX)/usr/man
-CFLAGS = -Wall -pedantic -O2
+CFLAGS += -Wall -pedantic
 #CFLAGS = -Wall -O2 -g -DDEBUG
 
 # If you change these, please update the man-pages too
--- anacron-2.3.orig/README
+++ anacron-2.3/README
@@ -5,9 +5,9 @@
    Anacron is a periodic command scheduler.  It executes commands at
 intervals specified in days.  Unlike cron, it does not assume that the
 system is running continuously.  It can therefore be used to control
-the execution of daily, weekly and monthly jobs (or anything with a
-period of n days), on systems that don't run 24 hours a day.  When
-installed and configured properly, Anacron will make sure that the
+the execution of daily, weekly, monthly and yearly jobs (or anything
+with a period of n days), on systems that don't run 24 hours a day.
+When installed and configured properly, Anacron will make sure that the
 commands are run at the specified intervals as closely as
 machine-uptime permits.
 
@@ -40,7 +40,8 @@ scripts are scheduled to run on Sundays.
 off for the night or for the weekend, these scripts rarely get run.
 
    Anacron solves this problem.  These jobs can simply be scheduled as
-Anacron-jobs with periods of 1, 7 and 30 days.
+Anacron-jobs with periods of 1, 7 and special target period names:
+@monthly and @yearly.
 
 
      What Anacron is not ?
@@ -90,7 +91,7 @@ scripts, from cron-jobs, or explicitly.
      Setup
      -----
 
-1. Locate your system's daily, weekly and monthly cron-jobs.
+1. Locate your system's daily, weekly, monthly and yearly cron-jobs.
    See your cron documentation for more details.
 
 2. Decide which of these jobs should be controlled by Anacron.
@@ -109,11 +110,12 @@ scripts, from cron-jobs, or explicitly.
 -----Cut
 # /etc/anacrontab example
 SHELL=/bin/sh
-PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
+PATH=/sbin:/bin:/usr/sbin:/usr/bin
 # format: period delay job-identifier command
 1       5       cron.daily      run-parts /etc/cron.daily
 7       10      cron.weekly     run-parts /etc/cron.weekly
-30      15      cron.monthly    run-parts /etc/cron.monthly
+@monthly      15      cron.monthly    run-parts /etc/cron.monthly
+@yearly       20      cron.yearly     run-parts /etc/cron.yearly
 -----Cut
 
 5. Put the command "anacron -s" somewhere in your boot-scripts.
@@ -125,9 +127,9 @@ PATH=/usr/local/sbin:/usr/local/bin:/sbi
 
 That's it.
 
-It is a good idea to check what your daily, weekly and monthly scripts
-actually do, and disable any parts that may be irrelevant for your
-system.
+It is a good idea to check what your daily, weekly, monthly and yearly
+scripts actually do, and disable any parts that may be irrelevant for
+your system.
 
 
      Credits
--- anacron-2.3.orig/TODO
+++ anacron-2.3/TODO
@@ -1,6 +1,3 @@
-anacron runs jobs twice in a 31 day month
-add hostname to emails sent to admin
-allow user anacrontabs
 make manpages match #defines automagically --> sed fu
 full ANSI / POSIX compliance
 code cleaning
--- anacron-2.3.orig/anacron.8
+++ anacron-2.3/anacron.8
@@ -1,147 +1,205 @@
-.TH ANACRON 8 2000-06-22 "Sean 'Shaleh' Perry" "Anacron Users' Manual"
+.TH ANACRON 8 2018-11-30 "The Debian Project" "Anacron Users' Manual"
 .SH NAME
 anacron \- runs commands periodically
 .SH SYNOPSIS
-.B anacron \fR[\fB-s\fR] [\fB-f\fR] [\fB-n\fR] [\fB-d\fR] [\fB-q\fR]
-[\fB-t anacrontab\fR] [\fIjob\fR] ...
+.B anacron \fR[\fB\-s\fR] [\fB\-f\fR] [\fB\-n\fR] [\fB\-d\fR] [\fB\-q\fR]
+[\fB\-t anacrontab\fR] [\fB\-S spooldir\fR] [\fIjob\fR] ...
 .br
-.B anacron -u [\fB-t anacrontab\fR] \fR[\fIjob\fR] ...
+.B anacron [\fB\-S spooldir\fR] \-u [\fB\-t anacrontab\fR] \fR[\fIjob\fR] ...
 .br
-.B anacron \fR[\fB-V\fR|\fB-h\fR]
+.B anacron \fR[\fB\-V\fR|\fB\-h\fR]
+.br
+.B anacron \-T [\fB\-t anacrontab\fR]
 .SH DESCRIPTION
-Anacron
-can be used to execute commands periodically, with a
-frequency specified in days.  Unlike \fBcron(8)\fR,
-it does not assume that the machine is running continuously.  Hence,
-it can be used on machines that aren't running 24 hours a day,
-to control daily, weekly, and monthly jobs that are
-usually controlled by \fBcron\fR.
+Anacron can be used to execute commands periodically, with a frequency
+specified in days.\&
+Unlike \fBcron\fR(8), it does not assume that the machine is running
+continuously.\&
+Hence, it can be used on machines that aren't running 24 hours a day,
+to control daily, weekly, and monthly jobs that are usually controlled by
+\fBcron\fR.\&
 .PP
 When executed, Anacron reads a list of jobs from a configuration file, normally
 .I /etc/anacrontab
-(see \fBanacrontab(5)\fR).  This file
-contains the list of jobs that Anacron controls.  Each
-job entry specifies a period in days, 
-a delay in minutes, a unique
-job identifier, and a shell command.
-.PP
-For each job, Anacron checks whether
-this job has been executed in the last n days, where n is the period specified
-for that job.  If not, Anacron runs the job's shell command, after waiting
-for the number of minutes specified as the delay parameter.
-.PP
-After the command exits, Anacron records the date in a special
-timestamp file for that job, so it can know when to execute it again.  Only
-the date is used for the time
-calculations.  The hour is not used.
-.PP
-When there are no more jobs to be run, Anacron exits.
-.PP
-Anacron only considers jobs whose identifier, as
-specified in the \fIanacrontab\fR matches any of
-the
+(see \fBanacrontab\fR(5)).\&
+This file contains the list of jobs that Anacron controls.\&
+Each job entry specifies a period in days, a delay in minutes, a unique job
+identifier, and a shell command.\&
+.PP
+For each job, Anacron checks whether this job has been executed in the last
+n days, where n is the period specified for that job.\&
+If not, Anacron runs the job's shell command, after waiting for the number of
+minutes specified as the delay parameter.\&
+.PP
+After the command exits, Anacron records the date in a special timestamp file
+for that job, so it can know when to execute it again.\&
+Only the date is used for the time calculations.\&
+The hour is not used.\&
+.PP
+When there are no more jobs to be run, Anacron exits.\&
+.PP
+Anacron only considers jobs whose identifier, as specified in the
+\fIanacrontab\fR matches any of the
 .I job
-command-line arguments.  The
+command-line arguments.\&
+The
 .I job
-arguments can be shell wildcard patterns (be sure to protect them from
-your shell with adequate quoting).  Specifying no
+arguments can be shell wildcard patterns (be sure to protect them from your
+shell with adequate quoting).\&
+Specifying no
 .I job
-arguments, is equivalent to specifying "*"  (That is, all jobs will be
-considered).
+arguments, is equivalent to specifying "*".\&
+(That is, all jobs will be considered).\&
 .PP
-Unless the \fB-d\fR option is given (see below), Anacron forks to the
-background when it starts, and the parent process exits
-immediately.
-.PP
-Unless the \fB-s\fR or \fB-n\fR options are given, Anacron starts jobs
-immediately when their delay is over.  The execution of different jobs is
-completely independent.
-.PP
-If a job generates any output on its standard output or standard error,
-the output is mailed to the user running Anacron (usually root).
-.PP
-Informative messages about what Anacron is doing are sent to \fBsyslogd(8)\fR
-under facility \fBcron\fR, priority \fBnotice\fR.  Error messages are sent at
-priority \fBerror\fR.
-.PP
-"Active" jobs (i.e. jobs that Anacron already decided
-to run and now wait for their delay to pass, and jobs that are currently
-being executed by
-Anacron), are "locked", so that other copies of Anacron won't run them
-at the same time.
+Unless the \fB\-d\fR option is given (see below), Anacron forks to the
+background when it starts, and the parent process exits immediately.\&
+.PP
+Unless the \fB\-s\fR or \fB\-n\fR options are given, Anacron starts jobs
+immediately when their delay is over.\&
+The execution of different jobs is completely independent.\&
+.PP
+If a job generates any output on its standard output or standard error, the
+output is mailed to the user running Anacron (usually root), or to the address
+contained by the MAILTO environment variable in the /etc/anacrontab file, if
+such exists.\&
+.PP
+Informative messages about what Anacron is doing are sent to \fBsyslogd\fR(8)
+under facility \fBcron\fR, priority \fBnotice\fR.\&
+Error messages are sent at priority \fBerror\fR.\&
+.PP
+"Active" jobs (i.e.\& jobs that Anacron already decided to run and now wait for
+their delay to pass, and jobs that are currently being executed by Anacron),
+are "locked", so that other copies of Anacron won't run them at the same
+time.\&
 .SH OPTIONS
 .TP
-.B -f
-Force execution of the jobs, ignoring the timestamps.
+.B \-f
+Force execution of the jobs, ignoring the timestamps.\&
 .TP
-.B -u
+.B \-u
 Only update the timestamps of the jobs, to the current date, but
-don't run anything.
-.TP
-.B -s
-Serialize execution of jobs.  Anacron will not start a new job before the
-previous one finished.
+don't run anything.\&
 .TP
-.B -n
-Run jobs now.  Ignore the delay specifications in the
+.B \-s
+Serialize execution of jobs.\&
+Anacron will not start a new job before the previous one finished.\&
+.TP
+.B \-n
+Run jobs now.\&
+Ignore the delay specifications in the
 .I /etc/anacrontab
-file.  This options implies \fB-s\fR.
-.TP
-.B -d
-Don't fork to the background.  In this mode, Anacron will output informational
-messages to standard error, as well as to syslog.  The output of jobs
-is mailed as usual.
+file.\&
+This options implies \fB\-s\fR.\&
 .TP
-.B -q
-Suppress messages to standard error.  Only applicable with \fB-d\fR.
+.B \-d
+Don't fork to the background.\&
+In this mode, Anacron will output informational messages to standard error, as
+well as to syslog.\&
+The output of jobs is mailed as usual.\&
+.TP
+.B \-q
+Suppress messages to standard error.\&
+Only applicable with \fB\-d\fR.\&
+.TP
+.B \-t anacrontab
+Use specified anacrontab, rather than the default.\&
+.TP
+.B \-T
+Anacrontab testing.\&
+The configuration file will be tested for validity.\&
+If there is an error in the file, an error will be shown and anacron will
+return 1.\&
+Valid anacrontabs will return 0.\&
+.TP
+.B \-S spooldir
+Use the specified spooldir to store timestamps in.\&
+This option is required for users who wish to run anacron themselves.\&
 .TP
-.B -t anacrontab
-Use specified anacrontab, rather than the default
+.B \-V
+Print version information, and exit.\&
 .TP
-.B -V
-Print version information, and exit.
-.TP
-.B -h
-Print short usage message, and exit.
+.B \-h
+Print short usage message, and exit.\&
 .SH SIGNALS
-After receiving a \fBSIGUSR1\fR signal, Anacron waits for running
-jobs, if any, to finish and then exits.  This can be used to stop
-Anacron cleanly.
+After receiving a \fBSIGUSR1\fR signal, Anacron waits for running jobs, if any,
+to finish and then exits.\&
+This can be used to stop Anacron cleanly.\&
 .SH NOTES
-Make sure that the time-zone is set correctly before Anacron is
-started.  (The time-zone affects the date).  This is usually accomplished
-by setting the TZ environment variable, or by installing a
+Make sure that the time-zone is set correctly before Anacron is started.\&
+(The time-zone affects the date).\&
+This is usually accomplished by setting the \fBTZ\fR environment variable, or
+by installing a
 .I /usr/lib/zoneinfo/localtime
-file.  See
-.B tzset(3)
-for more information.
+file.\&
+See \fBtzset\fR(3) for more information.\&
+.PP
+Timestamp files are created in the spool directory for each job in
+anacrontab.\&
+These are never removed automatically by anacron, and should be removed by
+hand if a job is no longer being scheduled.\&
+.SH DEBIAN-SPECIFIC CONFIGURATION
+On Debian-based systems, anacron will be activated hourly every day from 07:30
+local time to 23:30 local time through cron job (on non-systemd systems where
+cron is installed and enabled) or systemd timer (on systemd-based systems).\&
+On activation, anacron will check if it missed some jobs.\&
+If yes, it will start those jobs after a short period of time.\&
+.PP
+By default, the hourly activation of anacron will not take place when the
+system is using battery and no AC power is connected to the computer.\&
+It is meant to reduce power usage and extend battery life, but such design
+might lead to unwanted results.\&
+Users may disable this feature and let anacron run regardless of power
+supply.\&
+.PP
+Please read Debian-specific documentation in
+.I /usr/share/doc/anacron/README.Debian
+file for detailed instruction in how to change such behaviour.\&
 .SH FILES
 .TP
 .I /etc/anacrontab
-Contains specifications of jobs.  See \fBanacrontab(5)\fR for a complete
-description.
+Contains specifications of jobs.
+See \fBanacrontab\fR(5) for a complete description.\&
 .TP
 .I /var/spool/anacron
-This directory is used by Anacron for storing timestamp files.
+This directory is used by Anacron for storing timestamp files.\&
+.TP
+.I /lib/systemd/system/anacron.service
+This file provides systemd service for anacron.\&
+.TP
+.I /lib/systemd/system/anacron.timer
+This file provides systemd timer for anacron.
+Currently the service is triggered hourly through systemd timer.\&
 .SH "SEE ALSO"
-.B anacrontab(5), cron(8), tzset(3)
+\fBanacrontab\fR(5), \fBcron\fR(8), \fBtzset\fR(3)
 .PP
 The Anacron
 .I README
-file.
+file.\&
+.PP
+For Debian-specific modifications, please read
+.I /usr/share/doc/anacron/README.Debian
+file for detailed information.\&
 .SH BUGS
-Anacron never removes timestamp files.  Remove unused files manually.
+Anacron never removes timestamp files. Remove unused files manually.\&
 .PP
-Anacron
-uses up to two file descriptors for each active job.  It may run out of
-descriptors if there are more than about 125 active jobs (on normal kernels).
+Anacron uses up to two file descriptors for each active job.\&
+It may run out of descriptors if there are more than about 125 active jobs
+(on normal kernels).\&
 .PP
-Mail comments, suggestions and bug reports to Sean 'Shaleh' Perry <shaleh@(debian.org|valinux.com)>.
+Mail comments, suggestions and bug reports to Debian's BTS for Anacron by
+emailing \%submit@bugs.debian.org>.\&
 .SH AUTHOR
 Anacron was originally conceived and implemented by Christian Schwarz
-<schwarz@monet.m.isar.de>.
-.PP
-The current implementation is a complete rewrite by Itai Tzur
-<itzur@actcom.co.il>.
+\%<schwarz@monet.m.isar.de>.\&
+The current implementation is a complete rewrite by
+Itai Tzur \%<itzur@actcom.co.il>.\&
+.PP
+The code base was maintained by Sean \&'Shaleh'\& Perry
+\%<shaleh@(debian.org|valinux.com)>.\&
+During 2004\(en2006, it was maintained by Pascal Hakim
+\%<pasc@(debian.org|redellipse.net)>.\&
+During 2009\(en2014, it was maintained by Peter Eisentraut
+\%<petere@debian.org>.\&
 .PP
-The code base is currently maintained by Sean 'Shaleh' Perry <shaleh@(debian.org|valinux.com)>.
+Nowadays anacron in Debian is co-maintained by various developers from Debian
+Project.\&
--- /dev/null
+++ anacron-2.3/anacron.apm
@@ -0,0 +1,19 @@
+#! /bin/sh
+
+# This script makes anacron jobs start to run when the machine is
+# plugged into AC power, or woken up.  For a laptop, these are the 
+# closest parallels to turning on a desktop.
+
+# The /etc/init.d/anacron script now normally tries to avoid running
+# anacron unless on AC power, so as to avoid running down the battery.
+# (Things like the slocate updatedb cause a lot of IO.)  Rather than
+# trying to second-guess which events reflect having or not having
+# power, we just try to run anacron every time and let it abort if
+# there's no AC.  You'll see a message on the cron syslog facility 
+# (typically /var/log/cron) if it does run.
+
+case "$1,$2" in
+change,power|resume,*)
+    /etc/init.d/anacron start >/dev/null
+    ;;
+esac
--- anacron-2.3.orig/anacrontab.5
+++ anacron-2.3/anacrontab.5
@@ -1,28 +1,40 @@
-.TH ANACRONTAB 5 1998-02-02 "Itai Tzur" "Anacron Users' Manual"
+.TH ANACRONTAB 5 2004-07-11 "Pascal Hakim" "Anacron Users' Manual"
 .SH NAME
 /etc/anacrontab \- configuration file for anacron
 .SH DESCRIPTION
 The file
 .I /etc/anacrontab
-describes the jobs controlled by \fBanacron(8)\fR.  Its lines can be of
-three kinds:  job-description lines, environment
-assignments, or empty lines.
+describes the jobs controlled by \fBanacron\fR(8).\&
+Its lines can be of three kinds:  job-description lines, environment
+assignments, or empty lines.\&
 .PP
-Job-description lines are of the form:
+Job-description lines are of one of these two forms:
 .PP
    period  delay  job-identifier  command
 .PP
+   @period_name delay job-identify command
+.PP
 The
 .I period
 is specified in days, the
 .I delay
-in minutes.  The
+in minutes.\&
+The
 .I job-identifier
-can contain any non-blank character, except slashes.  It is used to identify
-the job in Anacron messages,
-and as the name for the job's timestamp file.  The
+can contain any non-blank character, except slashes.\&
+It is used to identify the job in Anacron messages, and as the name for the
+job's timestamp file.\&
+The
 .I command
-can be any shell command.
+can be any shell command.\&
+The fields can be separated by blank spaces or tabs.\&
+.I period_name
+can be set to
+.B monthly
+or
+.BR yearly .\&
+This will ensure jobs are only run once a month, no matter the number of days
+in this month, or the previous month; or analogously for the year.\&
 .PP
 Environment assignment lines are of the form:
 .PP
@@ -30,19 +42,24 @@ Environment assignment lines are of the
 .PP
 Spaces around
 .I VAR
-are removed.  No spaces around
+are removed.\&
+No spaces around
 .I VALUE
-are allowed (unless you want them to be part of the value).  The assignment
-takes effect from the next line to the end of the file, or to the next
-assignment of the same variable.
+are allowed \%(unless you want them to be part of the value).\&
+The assignment takes effect from the next line to the end of the file, or to
+the next assignment of the same variable.\&
 .PP
-Empty lines are either blank lines, line containing white-space only, or
-lines with white-space followed by a '#' followed by an arbitrary comment.
+Empty lines are either blank lines, line containing white-space only, or lines
+with white-space followed by a \&'#'\& followed by an arbitrary comment.\&
+.PP
+You can continue a line onto the next line by ending it with a \&'\e'.\&
 .SH "SEE ALSO"
-.B anacron(8)
+\fBanacron\fR(8)
 .PP
 The Anacron
 .I README
-file.
+file.\&
 .SH AUTHOR
-Itai Tzur <itzur@actcom.co.il>
+Itai Tzur \%<itzur@actcom.co.il>
+.PP
+Currently maintained by Lance Lin \%<lq27267@gmail.com>.\&
--- anacron-2.3.orig/global.h
+++ anacron-2.3/global.h
@@ -2,6 +2,7 @@
     Anacron - run commands periodically
     Copyright (C) 1998  Itai Tzur <itzur@actcom.co.il>
     Copyright (C) 1999  Sean 'Shaleh' Perry <shaleh@debian.org>
+    Copyright (C) 2004  Pascal Hakim <pasc@redellipse.net>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -53,9 +54,12 @@ typedef struct env_rec1 env_rec;
 
 struct job_rec1 {
    int period;
+   int named_period;
    int delay;
    char *ident;
    char *command;
+   char *mailto;
+   char *temp_file_path;
 
    int tab_line;
    int arg_num;
@@ -75,9 +79,10 @@ typedef struct job_rec1 job_rec;
 extern pid_t primary_pid;
 extern char *program_name;
 extern char *anacrontab;
+extern char *spooldir;
 extern int old_umask;
 extern sigset_t old_sigmask;
-extern int serialize,force,update_only,now,no_daemon,quiet;
+extern int serialize,force,update_only,now,no_daemon,quiet,testing_only;
 extern int day_now;
 extern int year,month,day_of_month;
 extern int in_background;
@@ -93,6 +98,9 @@ extern job_rec **job_array;
 
 extern int running_jobs,running_mailers;
 
+extern int complaints;
+
+extern char *mail_charset;
 
 /* Function prototypes */
 
@@ -121,7 +129,7 @@ void xcloselog();
 #endif /* not DEBUG */
 
 /* readtab.c */
-void read_tab();
+void read_tab(int cwd);
 void arrange_jobs();
 
 /* lock.c */
--- anacron-2.3.orig/gregor.c
+++ anacron-2.3/gregor.c
@@ -2,6 +2,7 @@
     Anacron - run commands periodically
     Copyright (C) 1998  Itai Tzur <itzur@actcom.co.il>
     Copyright (C) 1999  Sean 'Shaleh' Perry <shaleh@debian.org>
+    Copyright (C) 2004  Pascal Hakim <pasc@redellipse.net>
  
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -23,6 +24,7 @@
 
 
 #include <limits.h>
+#include <time.h>
 #include "gregor.h"
 
 const static int
@@ -65,7 +67,7 @@ day_num(int year, int month, int day)
 {
     int dn;
     int i;
-    const int isleap; /* save three calls to leap() */
+    int isleap; /* save three calls to leap() */
 
     /* Some validity checks */
 
@@ -114,3 +116,66 @@ leap(int year)
     /* but not by 400 */
     return (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
 }
+
+int
+days_last_month (void)
+/* How many days did last month have? */
+{
+    struct tm time_record;
+    time_t current_time;
+    time (&current_time);
+    localtime_r (&current_time, &time_record);
+
+    switch (time_record.tm_mon) {
+	case 0: return days_in_month[11];
+	case 2: return days_in_month[1] + (leap (time_record.tm_year + 1900) ? 1 : 0);
+	default: return days_in_month[time_record.tm_mon - 1];
+    }
+}
+
+int
+days_this_month (void)
+/* How many days does this month have? */
+{
+    struct tm time_record;
+    time_t current_time;
+    time (&current_time);
+    localtime_r (&current_time, &time_record);
+
+    switch (time_record.tm_mon) {
+	case 1: return days_in_month[1] + (leap (time_record.tm_year + 1900) ? 1 : 0);
+	default: return days_in_month[time_record.tm_mon];
+    }
+}
+
+int
+days_last_year (void)
+/* How many days this last year have? */
+{
+    struct tm time_record;
+    time_t current_time;
+    time (&current_time);
+    localtime_r (&current_time, &time_record);
+
+    if (leap(time_record.tm_year - 1 + 1900)) {
+	return 366;
+    }
+
+    return 365;
+}
+
+int
+days_this_year (void)
+/* How many days does this year have */
+{
+     struct tm time_record;
+    time_t current_time;
+    time (&current_time);
+    localtime_r (&current_time, &time_record);
+
+    if (leap(time_record.tm_year + 1900)) {
+	return 366;
+    }
+
+    return 365;
+}
--- anacron-2.3.orig/gregor.h
+++ anacron-2.3/gregor.h
@@ -2,6 +2,7 @@
     Anacron - run commands periodically
     Copyright (C) 1998  Itai Tzur <itzur@actcom.co.il>
     Copyright (C) 1999  Sean 'Shaleh' Perry <shaleh@debian.org>
+    Copyright (C) 2004  Pascal Hakim <pasc@redellipse.net>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -23,3 +24,7 @@
 
 
 int day_num(int year, int month, int day);
+int days_last_month (void);
+int days_this_month (void);
+int days_last_year (void);
+int days_this_year (void);
--- anacron-2.3.orig/lock.c
+++ anacron-2.3/lock.c
@@ -2,6 +2,7 @@
     Anacron - run commands periodically
     Copyright (C) 1998  Itai Tzur <itzur@actcom.co.il>
     Copyright (C) 1999  Sean 'Shaleh' Perry <shaleh@debian.org>
+    Copyirght (C) 2004  Pascal Hakim <pasc@redellipse.net>
  
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -111,6 +112,34 @@ consider_job(job_rec *jr)
 	    xclose(jr->timestamp_fd);
 	    return 0;
 	}
+
+	/*
+	 * Check to see if it's a named period, in which case we need 
+	 * to figure it out.
+	 */
+	if (jr->named_period)
+	{
+	    int period = 0, bypass = 0;
+	    switch (jr->named_period)
+	    {
+		case 1:
+		    period = days_last_month ();
+		    bypass = days_this_month ();
+		    break;
+		case 2:
+		    period = days_last_year ();
+		    bypass = days_this_year ();
+		    break;
+		default:
+		    die ("Unknown named period for %s (%d)", jr->ident, jr->named_period);
+	    }
+	    if (day_delta < period && day_delta != bypass)
+	    {
+		/* Job is still too young */
+		xclose (jr->timestamp_fd);
+		return 0;
+	    }
+	}
     }
 
     /* no! try to grab the lock */
--- anacron-2.3.orig/log.c
+++ anacron-2.3/log.c
@@ -2,6 +2,7 @@
     Anacron - run commands periodically
     Copyright (C) 1998  Itai Tzur <itzur@actcom.co.il>
     Copyright (C) 1999  Sean 'Shaleh' Perry <shaleh@debian.org>
+    Copyright (C) 2004  Pascal Hakim <pasc@redellipse.net>
  
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -42,12 +43,16 @@
 #include <signal.h>
 #include <sys/types.h>
 #include <string.h>
+#include <stdlib.h> /* for exit() */
 #include "global.h"
 
 static char truncated[] = " (truncated)";
 static char msg[MAX_MSG + 1];
 static int log_open = 0;
 
+/* Number of complaints that we've seen */
+int complaints = 0;
+
 static void
 xopenlog()
 {
@@ -79,7 +84,7 @@ make_msg(const char *fmt, va_list args)
 }
 
 static void
-log(int priority, const char *fmt, va_list args)
+log_default(int priority, const char *fmt, va_list args)
 /* Log a message, described by "fmt" and "args", with the specified
  * "priority". */
 {
@@ -96,7 +101,7 @@ log(int priority, const char *fmt, va_li
 }
 
 static void
-log_e(int priority, const char *fmt, va_list args)
+log_error(int priority, const char *fmt, va_list args)
 /* Same as log(), but also appends an error description corresponding
  * to "errno". */
 {
@@ -123,7 +128,7 @@ explain(const char *fmt, ...)
     va_list args;
 
     va_start(args, fmt);
-    log(EXPLAIN_LEVEL, fmt, args);
+    log_default(EXPLAIN_LEVEL, fmt, args);
     va_end(args);
 }
 
@@ -134,7 +139,7 @@ explain_e(const char *fmt, ...)
     va_list args;
 
     va_start(args, fmt);
-    log_e(EXPLAIN_LEVEL, fmt, args);
+    log_error(EXPLAIN_LEVEL, fmt, args);
     va_end(args);
 }
 
@@ -145,8 +150,10 @@ complain(const char *fmt, ...)
     va_list args;
 
     va_start(args, fmt);
-    log(COMPLAIN_LEVEL, fmt, args);
+    log_default(COMPLAIN_LEVEL, fmt, args);
     va_end(args);
+
+    complaints += 1;
 }
 
 void
@@ -156,8 +163,10 @@ complain_e(const char *fmt, ...)
     va_list args;
 
     va_start(args, fmt);
-    log_e(COMPLAIN_LEVEL, fmt, args);
+    log_error(COMPLAIN_LEVEL, fmt, args);
     va_end(args);
+
+    complaints += 1;
 }
 
 void
@@ -167,7 +176,7 @@ die(const char *fmt, ...)
     va_list args;
 
     va_start(args, fmt);
-    log(COMPLAIN_LEVEL, fmt, args);
+    log_default(COMPLAIN_LEVEL, fmt, args);
     va_end(args);
     if (getpid() == primary_pid) complain("Aborted");
 
@@ -181,7 +190,7 @@ die_e(const char *fmt, ...)
     va_list args;
 
     va_start(args, fmt);
-    log_e(COMPLAIN_LEVEL, fmt, args);
+    log_error(COMPLAIN_LEVEL, fmt, args);
     va_end(args);
     if (getpid() == primary_pid) complain("Aborted");
 
@@ -199,7 +208,7 @@ xdebug(const char *fmt, ...)
     va_list args;
 
     va_start(args, fmt);
-    log(DEBUG_LEVEL, fmt, args);
+    log_default(DEBUG_LEVEL, fmt, args);
     va_end(args);
 }
 
@@ -209,7 +218,7 @@ xdebug_e(const char *fmt, ...)
     va_list args;
 
     va_start(args, fmt);
-    log_e(DEBUG_LEVEL, fmt, args);
+    log_error(DEBUG_LEVEL, fmt, args);
     va_end(args);
 }
 
--- anacron-2.3.orig/main.c
+++ anacron-2.3/main.c
@@ -2,6 +2,7 @@
     Anacron - run commands periodically
     Copyright (C) 1998  Itai Tzur <itzur@actcom.co.il>
     Copyright (C) 1999  Sean 'Shaleh' Perry <shaleh@debian.org>
+    Copyright (C) 2004  Pascal Hakim <pasc@redellipse.net>
  
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -30,6 +31,9 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <string.h>
+#include <stdlib.h> /* for exit() */
+#include <langinfo.h>
+#include <locale.h>
 #include "global.h"
 #include "gregor.h"
 
@@ -39,8 +43,9 @@ int year, month, day_of_month;
 
 char *program_name;
 char *anacrontab;
+char *spooldir;
 int serialize, force, update_only, now,
-    no_daemon, quiet;                            /* command-line options */
+    no_daemon, quiet, testing_only;            /* command-line options */
 char **args;                       /* vector of "job" command-line arguments */
 int nargs;                                     /* number of these */
 char *defarg = "*";
@@ -51,6 +56,8 @@ sigset_t old_sigmask;
 job_rec *first_job_rec;
 env_rec *first_env_rec;
 
+char *mail_charset;
+
 static time_t start_sec;                       /* time anacron started */
 static volatile int got_sigalrm, got_sigchld, got_sigusr1;
 int running_jobs, running_mailers;              /* , number of */
@@ -61,17 +68,19 @@ print_version()
     printf("Anacron " RELEASE "\n"
 	   "Copyright (C) 1998  Itai Tzur <itzur@actcom.co.il>\n"
 	   "Copyright (C) 1999  Sean 'Shaleh' Perry <shaleh@debian.org>\n"
+	   "Copyright (C) 2004  Pascal Hakim <pasc@redellipse.net>\n"
 	   "\n"
-	   "Mail comments, suggestions and bug reports to <shaleh@debian.org>."
+	   "Mail comments, suggestions and bug reports to <pasc@redellipse.net>."
 	   "\n\n");
 }
 
 static void
 print_usage()
 {
-    printf("Usage:  anacron [-s] [-f] [-n] [-d] [-q] [-t anacrontab] [job] ...\n"
-	   "        anacron -u [job] ...\n"
+    printf("Usage:  anacron [-s] [-f] [-n] [-d] [-q] [-t anacrontab] [-S spooldir] [job] ...\n"
+	   "        anacron [-S spooldir] -u [job] ...\n"
 	   "        anacron [-V|-h]\n"
+	   "        anacron -T [-t anacrontab]\n"
 	   "\n"
 	   " -s  Serialize execution of jobs\n"
 	   " -f  Force execution of jobs, even before their time\n"
@@ -82,6 +91,8 @@ print_usage()
 	   " -t  Use this anacrontab\n"
 	   " -V  Print version information\n"
 	   " -h  Print this message\n"
+	   " -T  Test an anacrontab\n"
+	   " -S  Select a different spool directory\n"
 	   "\n"
 	   "See the manpage for more details.\n"
 	   "\n");
@@ -95,7 +106,7 @@ parse_opts(int argc, char *argv[])
 
     quiet = no_daemon = serialize = force = update_only = now = 0;
     opterr = 0;
-    while ((opt = getopt(argc, argv, "sfundqt:Vh")) != EOF)
+    while ((opt = getopt(argc, argv, "sfundqt:TS:Vh")) != EOF)
     {
 	switch (opt)
 	{
@@ -120,6 +131,12 @@ parse_opts(int argc, char *argv[])
 	case 't':
 	    anacrontab = strdup(optarg);
 	    break;
+	case 'T':
+	    testing_only = 1;
+	    break;
+	case 'S':
+	    spooldir = strdup(optarg);
+	    break;
 	case 'V':
 	    print_version();
 	    exit(0);
@@ -213,19 +230,19 @@ go_background()
 }
 
 void
-handle_sigalrm()
+handle_sigalrm(int sig)
 {
     got_sigalrm = 1;
 }
 
 void
-handle_sigchld()
+handle_sigchld(int sig)
 {
     got_sigchld = 1;
 }
 
 void
-handle_sigusr1()
+handle_sigusr1(int sig)
 {
     got_sigusr1 = 1;
 }
@@ -351,7 +368,7 @@ record_start_time()
     day_of_month = tm_now->tm_mday;
     day_now = day_num(year, month, day_of_month);
     if (day_now == -1) die("Invalid date (this is really embarrassing)");
-    if (!update_only)
+    if (!update_only && !testing_only)
 	explain("Anacron " RELEASE " started on %04d-%02d-%02d",
 		year, month, day_of_month);
 }
@@ -414,21 +431,44 @@ main(int argc, char *argv[])
 {
     int j;
 
+    int cwd;
+    char *cs;
+
     anacrontab = NULL;
+    spooldir = NULL;
 
     if((program_name = strrchr(argv[0], '/')) == NULL)
 	program_name = argv[0];
     else
 	++program_name; /* move pointer to char after '/' */
 
+    /* Get the default locale character set for the mail
+     * "Content-Type: ...; charset=" header
+     */
+    setlocale(LC_CTYPE, "");
+    /* "US-ASCII" is preferred to "ANSI_X3.4-1968" in MIME, even
+     * though "ANSI_X3.4-1968" is the official charset name. */
+    if ((cs = nl_langinfo(CODESET)) && strcmp(cs, "ANSI_X3.4-1968") != 0)
+	mail_charset = strdup(cs);
+    else
+	mail_charset = "US-ASCII";
+    setlocale(LC_CTYPE, "C");
+
     parse_opts(argc, argv);
 
     if (anacrontab == NULL)
 	anacrontab = strdup(ANACRONTAB);
 
+    if (spooldir == NULL)
+	spooldir = strdup(SPOOLDIR);
+
+    if ((cwd = open ("./", O_RDONLY)) == -1) {
+	die_e ("Can't save current directory");
+    }
+
     in_background = 0;
 
-    if (chdir(SPOOLDIR)) die_e("Can't chdir to " SPOOLDIR);
+    if (chdir(spooldir)) die_e("Can't chdir to %s", spooldir );
 
     old_umask = umask(0);
 
@@ -437,15 +477,23 @@ main(int argc, char *argv[])
     if (fclose(stdin)) die_e("Can't close stdin");
     xopen(0, "/dev/null", O_RDONLY);
 
-    if (!no_daemon)
+    if (!no_daemon && !testing_only)
 	go_background();
     else
 	primary_pid = getpid();
 
     record_start_time();
-    read_tab();
+    read_tab(cwd);
+    close(cwd);
     arrange_jobs();
 
+    if (testing_only)
+    {
+	if (complaints) exit (1);
+	
+	exit (0);
+    }
+
     if (update_only)
     {
 	fake_jobs();
@@ -462,6 +510,6 @@ main(int argc, char *argv[])
 	launch_job(job_array[j]);
     }
     wait_children();
-    explain("Normal exit (%d jobs run)", njobs);
+    explain("Normal exit (%d job%s run)", njobs, (njobs == 1 ? "" : "s"));
     exit(0);
 }
--- anacron-2.3.orig/matchrx.c
+++ anacron-2.3/matchrx.c
@@ -26,6 +26,7 @@
 #include <regex.h>
 #include <stdarg.h>
 #include <stdlib.h>
+#include <string.h> /* for memset() */
 #include "matchrx.h"
 
 int
--- anacron-2.3.orig/readtab.c
+++ anacron-2.3/readtab.c
@@ -2,6 +2,7 @@
     Anacron - run commands periodically
     Copyright (C) 1998  Itai Tzur <itzur@actcom.co.il>
     Copyright (C) 1999  Sean 'Shaleh' Perry <shaleh@debian.org>
+    Copyright (C) 2004  Pascal Hakim <pasc@redellipse.net>
  
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -83,11 +84,23 @@ read_tab_line ()
 Return NULL if no more lines.
  */
 {
-    int c;
+    int c, prev=0;
 
     if (feof(tab)) return NULL;
-    while ((c = getc(tab)) != EOF && c != '\n')
-	obstack_1grow(&input_o, c);
+    while (1)
+    {
+	c = getc(tab);
+	if ((c == '\n' && prev != '\\') || c == EOF)
+	{
+	    if (0 != prev) obstack_1grow(&input_o, prev);
+	    break;
+	}
+
+	if ('\\' != prev && 0 != prev && '\n' != prev) obstack_1grow(&input_o, prev);
+	else if ('\n' == prev) obstack_1grow(&input_o, ' ');
+
+	prev = c;
+    }
     if (ferror(tab)) die_e("Error reading %s", anacrontab);
     obstack_1grow(&input_o, '\0');
     return obstack_finish(&input_o);
@@ -95,7 +108,7 @@ Return NULL if no more lines.
 
 static int
 job_arg_num(const char *ident)
-/* Return the command-line-argument number refering to this job-identifier.
+/* Return the command-line-argument number referring to this job-identifier.
  * If it isn't specified, return -1.
  */
 {
@@ -153,6 +166,7 @@ register_job(const char *periods, const
     }
     jr = obstack_alloc(&tab_o, sizeof(job_rec));
     jr->period = period;
+    jr->named_period = 0;
     jr->delay = delay;
     jr->tab_line = line_num;
     jr->ident = obstack_alloc(&tab_o, ident_len + 1);
@@ -171,6 +185,53 @@ register_job(const char *periods, const
 }
 
 static void
+register_period_job(const char *periods, const char *delays,
+		    const char *ident, char *command)
+/* Store a job definition with a named period */
+{
+    int delay;
+    job_rec *jr;
+    int ident_len, command_len;
+
+    ident_len = strlen(ident);
+    command_len = strlen(command);
+    jobs_read++;
+    delay = conv2int(delays);
+    if (delay < 0)
+    {
+	complain("%s: number out of range on line %d, skipping",
+		 anacrontab, line_num);
+	return;
+    }
+
+    jr = obstack_alloc(&tab_o, sizeof(job_rec));
+    if (!strncmp ("@monthly", periods, 7)) {
+	jr->named_period = 1;
+    } else if (!strncmp("@yearly", periods, 7)) {
+	jr->named_period = 2;
+    } else {
+	complain("%s: Unknown named period on line %d, skipping",
+		 anacrontab, line_num);
+    }
+    jr->period = 0;
+    jr->delay = delay;
+    jr->tab_line = line_num;
+    jr->ident = obstack_alloc(&tab_o, ident_len + 1);
+    strcpy(jr->ident, ident);
+    jr->arg_num = job_arg_num(ident);
+    jr->command = obstack_alloc(&tab_o, command_len + 1);
+    strcpy(jr->command, command);
+    jr->job_pid = jr->mailer_pid = 0;
+    if (last_job_rec != NULL) last_job_rec->next = jr;
+    else first_job_rec = jr;
+    last_job_rec = jr;
+    jr->prev_env_rec = last_env_rec;
+    jr->next = NULL;
+    Debug(("Read job - period %d, delay=%d, ident%s, command=%s",
+	  jr->named_period, jr->delay, jr->ident, jr->command));
+}
+
+static void
 parse_tab_line(char *line)
 {
     int r;
@@ -210,6 +271,18 @@ parse_tab_line(char *line)
 	register_job(periods, delays, ident, command);
 	return;
     }
+
+    /* A period job? */
+    r = match_rx("^[ \t]*(@[^ \t]+)[ \t]+([[:digit:]]+)[ \t]+"
+		 "([^ \t/]+)[ \t]+([^ \t].*)$",
+		 line, 4, &periods, &delays, &ident, &command);
+    if (r == -1) goto reg_err;
+    if (r)
+    {
+	register_period_job(periods, delays, ident, command);
+	return;
+    }
+
     complain("Invalid syntax in %s on line %d - skipping this line",
 	     anacrontab, line_num);
     return;
@@ -219,7 +292,7 @@ parse_tab_line(char *line)
 }
 
 void
-read_tab()
+read_tab(int cwd)
 /* Read the anacrontab file into memory */
 {
     char *tab_line;
@@ -229,7 +302,10 @@ read_tab()
     jobs_read = 0;
     line_num = 0;
     /* Open the anacrontab file */
+    if (fchdir (cwd)) die_e("Can't fchdir to %s", cwd);
     tab = fopen(anacrontab, "r");
+    if (chdir(spooldir)) die_e("Can't chdir to %s", spooldir);
+
     if (tab == NULL) die_e("Error opening %s", anacrontab);
     /* Initialize the obstacks */
     obstack_init(&input_o);
@@ -271,7 +347,7 @@ arrange_jobs()
     njobs = 0;
     while (j != NULL)
     {
-	if (j->arg_num != -1 && (update_only || consider_job(j)))
+	if (j->arg_num != -1 && (update_only || testing_only || consider_job(j)))
 	{
 	    njobs++;
 	    obstack_grow(&tab_o, &j, sizeof(j));
--- anacron-2.3.orig/runjob.c
+++ anacron-2.3/runjob.c
@@ -36,29 +36,30 @@
 #include "global.h"
 
 static int
-temp_file()
+temp_file(job_rec *jr)
 /* Open a temporary file and return its file descriptor */
 {
     const int max_retries = 50;
     char *name;
+    char template[] = "/tmp/anacron-XXXXXXX";
     int fd, i;
 
-    i = 0;
     name = NULL;
+    i = 0;
     do
     {
-	i++;
-	free(name);
-	name = tempnam(NULL, NULL);
-	if (name == NULL) die("Can't find a unique temporary filename");
-	fd = open(name, O_RDWR | O_CREAT | O_EXCL | O_APPEND,
-		  S_IRUSR | S_IWUSR);
+        i++;
+        free(name);
+        name = mktemp(template);
+        if (name == NULL) die("Can't find a unique temporary filename");
+        fd = open(name, O_RDWR | O_CREAT | O_EXCL | O_APPEND,
+            S_IRUSR | S_IWUSR);
+
 	/* I'm not sure we actually need to be so persistent here */
     } while (fd == -1 && errno == EEXIST && i < max_retries);
     
-    if (fd == -1) die_e("Can't open temporary file");
-    if (unlink(name)) die_e("Can't unlink temporary file");
-    free(name);
+    if (fd == -1) die_e("Failed to create and open unique temporary filename");
+    jr->temp_file_path = strdup(name);
     fcntl(fd, F_SETFD, 1);    /* set close-on-exec flag */
     return fd;
 }
@@ -84,7 +85,7 @@ username()
 }
 
 static void
-xputenv(const char *s)
+xputenv(char *s)
 {
     if (putenv(s)) die_e("Can't set the environment");
 }
@@ -109,7 +110,6 @@ static void
 run_job(const job_rec *jr)
 /* This is called to start the job, after the fork */
 {
-    setup_env(jr);
     /* setup stdout and stderr */
     xclose(1);
     xclose(2);
@@ -153,6 +153,14 @@ static void
 launch_mailer(job_rec *jr)
 {
     pid_t pid;
+    struct stat buf;
+
+    /* Check that we have a way of sending mail. */
+    if(stat(SENDMAIL, &buf))
+    {
+	complain("Can't find sendmail at %s, not mailing output", SENDMAIL);
+	return;
+    }
 
     pid = xfork();
     if (pid == 0)
@@ -173,7 +181,7 @@ launch_mailer(job_rec *jr)
 	 * options, which don't seem to be appropriate here.
 	 * Hopefully, this will keep all the MTAs happy. */
 	execl(SENDMAIL, SENDMAIL, "-FAnacron", "-odi",
-	      username(), (char *)NULL);
+	      jr->mailto, (char *)NULL);
 	die_e("Can't exec " SENDMAIL);
     }
     /* parent */
@@ -187,7 +195,7 @@ tend_mailer(job_rec *jr, int status)
 {
     if (WIFEXITED(status) && WEXITSTATUS(status) != 0)
 	complain("Tried to mail output of job `%s', "
-		 "but mailer process (" SENDMAIL ") exited with ststus %d",
+		 "but mailer process (" SENDMAIL ") exited with status %d",
 		 jr->ident, WEXITSTATUS(status));
     else if (!WIFEXITED(status) && WIFSIGNALED(status))
 	complain("Tried to mail output of job `%s', "
@@ -207,19 +215,47 @@ launch_job(job_rec *jr)
 {
     pid_t pid;
     int fd;
+    char hostname[512];
+    char *mailto;
+
+    /* get hostname */
+    if (gethostname(hostname, 512)) {
+      strcpy (hostname,"unknown machine");
+    }
+
+    setup_env(jr);
+   
+    /* Get the destination email address if set, or current user otherwise */
+    mailto = getenv("MAILTO");
+
+    if (mailto)
+	    jr->mailto = mailto;
+    else
+	    jr->mailto = username ();
 
     /* create temporary file for stdout and stderr of the job */
-    fd = jr->output_fd = temp_file();
+    fd = jr->output_fd = temp_file(jr);
     /* write mail header */
     xwrite(fd, "From: ");
+    xwrite(fd, "Anacron <");
     xwrite(fd, username());
-    xwrite(fd, " (Anacron)\n");
+    xwrite(fd, ">\n");
     xwrite(fd, "To: ");
-    xwrite(fd, username());
+    if (mailto) {
+       xwrite(fd, mailto);
+    } else {
+       xwrite(fd, username());
+    }
     xwrite(fd, "\n");
     xwrite(fd, "Subject: Anacron job '");
     xwrite(fd, jr->ident);
-    xwrite(fd, "'\n\n");
+    xwrite(fd, "' on ");
+    xwrite(fd, hostname);
+    xwrite(fd, "\n");
+    xwrite(fd, "Content-Type: text/plain; charset=");
+    xwrite(fd, mail_charset);
+    xwrite(fd, "\n\n");
+
     jr->mail_header_size = file_size(fd);
 
     pid = xfork();
@@ -263,6 +299,7 @@ tend_job(job_rec *jr, int status)
     jr->job_pid = 0;
     running_jobs--;
     if (mail_output) launch_mailer(jr);
+    if (unlink(jr->temp_file_path)) die_e("Can't unlink temporary file");
     xclose(jr->output_fd);
 }