|
|
ffd6ed |
From 9ceaf6ec6b9feb254f88fb3fd6c96d339dcd674b Mon Sep 17 00:00:00 2001
|
|
|
ffd6ed |
From: Pino Toscano <ptoscano@redhat.com>
|
|
|
ffd6ed |
Date: Wed, 1 Jul 2015 14:53:31 +0200
|
|
|
ffd6ed |
Subject: [PATCH] sysprep: rework and fix cron-spool operation (RHBZ#1229305)
|
|
|
ffd6ed |
|
|
|
ffd6ed |
When cleaning the directories with cron/at jobs, remove only files
|
|
|
ffd6ed |
there, as subdirectories might be used by other systems; for example
|
|
|
ffd6ed |
in Debian under /var/spool/cron/ there is the atjobs subdirectory with
|
|
|
ffd6ed |
the actual at queue.
|
|
|
ffd6ed |
|
|
|
ffd6ed |
Make sure to not remove .SEQ files anymore, as they represent the at job
|
|
|
ffd6ed |
counter which is needed by the at daemon. Instead, reset these files to
|
|
|
ffd6ed |
0.
|
|
|
ffd6ed |
|
|
|
ffd6ed |
Furthermore, add also the path to the .SEQ location in Debian-based
|
|
|
ffd6ed |
systems.
|
|
|
ffd6ed |
|
|
|
ffd6ed |
(cherry picked from commit 261be1f952aa984b460ff8d88d962c490df4ffcf)
|
|
|
ffd6ed |
---
|
|
|
ffd6ed |
sysprep/sysprep_operation_cron_spool.ml | 28 +++++++++++++++++++++-------
|
|
|
ffd6ed |
1 file changed, 21 insertions(+), 7 deletions(-)
|
|
|
ffd6ed |
|
|
|
ffd6ed |
diff --git a/sysprep/sysprep_operation_cron_spool.ml b/sysprep/sysprep_operation_cron_spool.ml
|
|
|
ffd6ed |
index 9a78e85..ebf745c 100644
|
|
|
ffd6ed |
--- a/sysprep/sysprep_operation_cron_spool.ml
|
|
|
ffd6ed |
+++ b/sysprep/sysprep_operation_cron_spool.ml
|
|
|
ffd6ed |
@@ -18,19 +18,33 @@
|
|
|
ffd6ed |
|
|
|
ffd6ed |
open Sysprep_operation
|
|
|
ffd6ed |
open Common_gettext.Gettext
|
|
|
ffd6ed |
+open Common_utils
|
|
|
ffd6ed |
|
|
|
ffd6ed |
module G = Guestfs
|
|
|
ffd6ed |
|
|
|
ffd6ed |
let cron_spool_perform ~verbose ~quiet (g : Guestfs.guestfs) root side_effects =
|
|
|
ffd6ed |
- Array.iter g#rm_rf (g#glob_expand "/var/spool/cron/*");
|
|
|
ffd6ed |
+ let is_seq path =
|
|
|
ffd6ed |
+ let basename =
|
|
|
ffd6ed |
+ match last_part_of path '/' with
|
|
|
ffd6ed |
+ | Some x -> x
|
|
|
ffd6ed |
+ | None -> path in
|
|
|
ffd6ed |
+ basename = ".SEQ" in
|
|
|
ffd6ed |
+ let reset f =
|
|
|
ffd6ed |
+ if g#is_file f then
|
|
|
ffd6ed |
+ (* This should overwrite the file in-place, as it's a very
|
|
|
ffd6ed |
+ * small buffer which will be handled using internal_write.
|
|
|
ffd6ed |
+ * This way, existing attributes like SELinux labels are
|
|
|
ffd6ed |
+ * preserved.
|
|
|
ffd6ed |
+ *)
|
|
|
ffd6ed |
+ g#write f "00000\n" in
|
|
|
ffd6ed |
+
|
|
|
ffd6ed |
+ rm_rf_only_files g ~filter:is_seq "/var/spool/cron/";
|
|
|
ffd6ed |
+ reset "/var/spool/cron/atjobs/.SEQ";
|
|
|
ffd6ed |
Array.iter g#rm (g#glob_expand "/var/spool/atjobs/*");
|
|
|
ffd6ed |
- Array.iter g#rm (g#glob_expand "/var/spool/atjobs/.SEQ");
|
|
|
ffd6ed |
+ reset "/var/spool/atjobs/.SEQ";
|
|
|
ffd6ed |
Array.iter g#rm (g#glob_expand "/var/spool/atspool/*");
|
|
|
ffd6ed |
- Array.iter
|
|
|
ffd6ed |
- (fun path -> if not (g#is_dir path) then g#rm path)
|
|
|
ffd6ed |
- (g#glob_expand "/var/spool/at/*");
|
|
|
ffd6ed |
- Array.iter g#rm (g#glob_expand "/var/spool/at/.SEQ");
|
|
|
ffd6ed |
- Array.iter g#rm (g#glob_expand "/var/spool/at/spool/*")
|
|
|
ffd6ed |
+ rm_rf_only_files g ~filter:is_seq "/var/spool/at/";
|
|
|
ffd6ed |
+ reset "/var/spool/at/.SEQ"
|
|
|
ffd6ed |
|
|
|
ffd6ed |
let op = {
|
|
|
ffd6ed |
defaults with
|
|
|
ffd6ed |
--
|
|
|
ffd6ed |
1.8.3.1
|
|
|
ffd6ed |
|