[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Libguestfs] [PATCH 3/3] sysprep: Check --{keep, remove}-user-accounts parameters are not used when operation is disabled (RHBZ#1141157).



You will see an error like this:

$ virt-sysprep --remove-user-accounts foo,bar -a /dev/null
virt-sysprep: error: user-accounts: --remove-user-accounts parameter was
used, but the "user-account" operation is not enabled
---
 sysprep/sysprep_operation_user_account.ml | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/sysprep/sysprep_operation_user_account.ml b/sysprep/sysprep_operation_user_account.ml
index c514286..2d231cd 100644
--- a/sysprep/sysprep_operation_user_account.ml
+++ b/sysprep/sysprep_operation_user_account.ml
@@ -134,6 +134,11 @@ This option can be specified multiple times."
       };
     ];
     perform_on_filesystems = Some user_account_perform;
+    not_enabled_check_args = fun () ->
+      if not (StringSet.is_empty !keep_users) then
+        error ~prog (f_"user-accounts: --keep-user-accounts parameter was used, but the \"user-account\" operation is not enabled");
+      if not (StringSet.is_empty !remove_users) then
+        error ~prog (f_"user-accounts: --remove-user-accounts parameter was used, but the \"user-account\" operation is not enabled");
 }
 
 let () = register_operation op
-- 
2.0.4


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]