[Pkg-libvirt-commits] [libguestfs] 20/61: customize: Add a --password option for setting user passwords.
Hilko Bengen
bengen at moszumanska.debian.org
Sat Mar 29 14:36:23 UTC 2014
This is an automated email from the git hooks/post-receive script.
bengen pushed a commit to branch experimental
in repository libguestfs.
commit 51834ad2192b1c90b74894421c2633c831ca1f4e
Author: Richard W.M. Jones <rjones at redhat.com>
Date: Wed Mar 19 13:16:53 2014 +0000
customize: Add a --password option for setting user passwords.
---
builder/cmdline.ml | 2 +-
customize/customize_run.ml | 3 +++
generator/customize.ml | 33 +++++++++++++++++++++++++++++++--
3 files changed, 35 insertions(+), 3 deletions(-)
diff --git a/builder/cmdline.ml b/builder/cmdline.ml
index 7cd3342..7fbce1d 100644
--- a/builder/cmdline.ml
+++ b/builder/cmdline.ml
@@ -299,7 +299,7 @@ read the man page virt-builder(1).
| `Command _ | `InstallPackages _ | `Script _ | `Update -> true
| `Delete _ | `Edit _ | `FirstbootCommand _ | `FirstbootPackages _
| `FirstbootScript _ | `Hostname _ | `Link _ | `Mkdir _
- | `RootPassword _ | `Scrub _ | `Timezone _ | `Upload _
+ | `Password _ | `RootPassword _ | `Scrub _ | `Timezone _ | `Upload _
| `Write _ -> false
) ops.ops in
if requires_execute_on_guest then (
diff --git a/customize/customize_run.ml b/customize/customize_run.ml
index dd98017..8a1df32 100644
--- a/customize/customize_run.ml
+++ b/customize/customize_run.ml
@@ -227,6 +227,9 @@ exec >>%s 2>&1
msg (f_"Making directory: %s") dir;
g#mkdir_p dir
+ | `Password (user, pw) ->
+ set_password user pw
+
| `RootPassword pw ->
set_password "root" pw
diff --git a/generator/customize.ml b/generator/customize.ml
index c87eeba..0b0580a 100644
--- a/generator/customize.ml
+++ b/generator/customize.ml
@@ -41,6 +41,7 @@ and op_type =
| StringList of string (* string,string,... *)
| TargetLinks of string (* target:link[:link...] *)
| PasswordSelector of string (* password selector *)
+| UserPasswordSelector of string (* user:selector *)
let ops = [
{ op_name = "delete";
@@ -150,6 +151,17 @@ Create a directory in the guest.
This uses S<C<mkdir -p>> so any intermediate directories are created,
and it also works if the directory already exists.";
};
+ { op_name = "password";
+ op_type = UserPasswordSelector "USER:SELECTOR";
+ op_discrim = "`Password";
+ op_shortdesc = "Set user password";
+ op_pod_longdesc = "\
+Set the password for C<USER>. (Note this option does I<not>
+create the user account).
+
+See L<virt-builder(1)/USERS AND PASSWORDS> for the format of
+the C<SELECTOR> field, and also how to set up user accounts.";
+ };
{ op_name = "root-password";
op_type = PasswordSelector "SELECTOR";
op_discrim = "`RootPassword";
@@ -476,6 +488,19 @@ let rec argspec ~prog () =
pr " s_\"%s\" ^ \" \" ^ s_\"%s\"\n" v shortdesc;
pr " ),\n";
pr " Some %S, %S;\n" v longdesc
+ | { op_type = UserPasswordSelector v; op_name = name; op_discrim = discrim;
+ op_shortdesc = shortdesc; op_pod_longdesc = longdesc } ->
+ pr " (\n";
+ pr " \"--%s\",\n" name;
+ pr " Arg.String (\n";
+ pr " fun s ->\n";
+ pr " let user, sel = split_string_pair \"%s\" s in\n" name;
+ pr " let sel = Password.parse_selector ~prog sel in\n";
+ pr " ops := %s (user, sel) :: !ops\n" discrim;
+ pr " ),\n";
+ pr " s_\"%s\" ^ \" \" ^ s_\"%s\"\n" v shortdesc;
+ pr " ),\n";
+ pr " Some %S, %S;\n" v longdesc
) ops;
List.iter (
@@ -539,6 +564,10 @@ type ops = {
op_name = name } ->
pr " | %s of Password.password_selector\n (* --%s %s *)\n"
discrim name v
+ | { op_type = UserPasswordSelector v; op_discrim = discrim;
+ op_name = name } ->
+ pr " | %s of string * Password.password_selector\n (* --%s %s *)\n"
+ discrim name v
) ops;
pr "]\n";
@@ -564,7 +593,7 @@ let generate_customize_synopsis_pod () =
| { op_type = Unit; op_name = n } ->
n, sprintf "[--%s]" n
| { op_type = String v | StringPair v | StringList v | TargetLinks v
- | PasswordSelector v;
+ | PasswordSelector v | UserPasswordSelector v;
op_name = n } ->
n, sprintf "[--%s %s]" n v
) ops @
@@ -604,7 +633,7 @@ let generate_customize_options_pod () =
| { op_type = Unit; op_name = n; op_pod_longdesc = ld } ->
n, sprintf "B<--%s>" n, ld
| { op_type = String v | StringPair v | StringList v | TargetLinks v
- | PasswordSelector v;
+ | PasswordSelector v | UserPasswordSelector v;
op_name = n; op_pod_longdesc = ld } ->
n, sprintf "B<--%s> %s" n v, ld
) ops @
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-libvirt/libguestfs.git
More information about the Pkg-libvirt-commits
mailing list