- bump the augeas requirement to 1.2.0, and drop an old hack - add a small helper in the generator Pino Toscano (3): build: raise augeas requirement to 1.2.0 appliance: remove custom Shadow augeas lens daemon: implement OptString for OCaml APIs appliance/Makefile.am | 6 +-- appliance/guestfs_shadow.aug | 72 ------------------------------------ daemon/augeas.c | 21 +---------- docs/guestfs-building.pod | 2 +- generator/daemon.ml | 18 ++++++++- m4/guestfs-libraries.m4 | 4 +- 6 files changed, 23 insertions(+), 100 deletions(-) delete mode 100644 appliance/guestfs_shadow.aug -- 2.21.0
Pino Toscano
2019-May-29 09:59 UTC
[Libguestfs] [PATCH 1/3] build: raise augeas requirement to 1.2.0
It is widely available also on older distributions.
---
docs/guestfs-building.pod | 2 +-
m4/guestfs-libraries.m4 | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/docs/guestfs-building.pod b/docs/guestfs-building.pod
index 47efe34a5..94ec079a5 100644
--- a/docs/guestfs-building.pod
+++ b/docs/guestfs-building.pod
@@ -164,7 +164,7 @@ I<Required>.
I<Required>.
-=item augeas E<ge> 1.0.0
+=item augeas E<ge> 1.2.0
I<Required>.
diff --git a/m4/guestfs-libraries.m4 b/m4/guestfs-libraries.m4
index 0941140bd..7643c04b3 100644
--- a/m4/guestfs-libraries.m4
+++ b/m4/guestfs-libraries.m4
@@ -248,8 +248,8 @@ PKG_CHECK_MODULES([PCRE], [libpcre], [], [
PCRE_LIBS=`$PCRE_CONFIG --libs`
])
-dnl Check for Augeas >= 1.0.0 (required).
-PKG_CHECK_MODULES([AUGEAS],[augeas >= 1.0.0])
+dnl Check for Augeas >= 1.2.0 (required).
+PKG_CHECK_MODULES([AUGEAS],[augeas >= 1.2.0])
dnl Check for aug_source function, added in Augeas 1.8.0.
old_LIBS="$LIBS"
--
2.21.0
Pino Toscano
2019-May-29 09:59 UTC
[Libguestfs] [PATCH 2/3] appliance: remove custom Shadow augeas lens
Now that augeas 1.2.0 is required, assume the Shadow lens is available
there, and thus drop the local copy.
---
appliance/Makefile.am | 6 +--
appliance/guestfs_shadow.aug | 72 ------------------------------------
daemon/augeas.c | 21 +----------
3 files changed, 3 insertions(+), 96 deletions(-)
delete mode 100644 appliance/guestfs_shadow.aug
diff --git a/appliance/Makefile.am b/appliance/Makefile.am
index fc424b1d0..a5fc90a79 100644
--- a/appliance/Makefile.am
+++ b/appliance/Makefile.am
@@ -32,7 +32,6 @@ include $(top_srcdir)/subdir-rules.mk
EXTRA_DIST = \
99-guestfs-serial.rules \
excludefiles.in \
- guestfs_shadow.aug \
hostfiles.in \
init \
libguestfs-make-fixed-appliance.in \
@@ -86,12 +85,11 @@ packagelist: packagelist.in Makefile
cmp -s $@ $@-t || mv $@-t $@
rm -f $@-t
-supermin.d/daemon.tar.gz: ../daemon/guestfsd guestfs_shadow.aug
+supermin.d/daemon.tar.gz: ../daemon/guestfsd
rm -f $@ $@-t
rm -rf tmp-d
- mkdir -p tmp-d$(DAEMON_SUPERMIN_DIR) tmp-d/etc tmp-d/usr/share/guestfs
+ mkdir -p tmp-d$(DAEMON_SUPERMIN_DIR) tmp-d/etc
ln ../daemon/guestfsd tmp-d$(DAEMON_SUPERMIN_DIR)/guestfsd
- ln $(srcdir)/guestfs_shadow.aug tmp-d/usr/share/guestfs/guestfs_shadow.aug
( cd tmp-d && tar zcf - * ) > $@-t
rm -r tmp-d
mv $@-t $@
diff --git a/appliance/guestfs_shadow.aug b/appliance/guestfs_shadow.aug
deleted file mode 100644
index 2fbf455d5..000000000
--- a/appliance/guestfs_shadow.aug
+++ /dev/null
@@ -1,72 +0,0 @@
-(*
- Module: Shadow
- Parses /etc/shadow
-
- Author: Lorenzo M. Catucci <catucci@ccd.uniroma2.it>
-
- Original Author: Free Ekanayaka <free@64studio.com>
-
- About: Reference
-
- - man 5 shadow
- - man 3 getspnam
-
- About: License
- This file is licensed under the LGPL v2+, like the rest of Augeas.
-
- About:
-
- Each line in the shadow files represents the additional shadow-defined
attributes
- for the corresponding user, as defined in the passwd file.
-
-*)
-
-module Guestfs_Shadow -
- autoload xfm
-
-(************************************************************************
- * USEFUL PRIMITIVES
- *************************************************************************)
-
-let eol = Util.eol
-let comment = Util.comment
-let empty = Util.empty
-let dels = Util.del_str
-
-let colon = Sep.colon
-
-let word = Rx.word
-let integer = Rx.integer
-
-let sto_to_col = Passwd.sto_to_col
-let sto_to_eol = Passwd.sto_to_eol
-
-(************************************************************************
- * Group: ENTRIES
- *************************************************************************)
-
-(* View: entry *)
-let entry = [ key word
- . colon
- . [ label "password" . sto_to_col? .
colon ]
- . [ label "lastchange_date" . store integer? .
colon ]
- . [ label "minage_days" . store integer? .
colon ]
- . [ label "maxage_days" . store integer? .
colon ]
- . [ label "warn_days" . store integer? .
colon ]
- . [ label "inactive_days" . store integer? .
colon ]
- . [ label "expire_date" . store integer? .
colon ]
- . [ label "flag" . store integer? ]
- . eol ]
-
-(************************************************************************
- * LENS
- *************************************************************************)
-
-let lns = (comment|empty|entry) *
-
-let filter
- = incl "/shadow"
- . Util.stdexcl
-
-let xfm = transform lns filter
diff --git a/daemon/augeas.c b/daemon/augeas.c
index 453251337..b34222ab5 100644
--- a/daemon/augeas.c
+++ b/daemon/augeas.c
@@ -134,7 +134,7 @@ do_aug_init (const char *root, int flags)
}
/* Pass AUG_NO_ERR_CLOSE so we can display detailed errors. */
- aug = aug_init (buf, "/usr/share/guestfs/", flags |
AUG_NO_ERR_CLOSE);
+ aug = aug_init (buf, NULL, flags | AUG_NO_ERR_CLOSE);
if (!aug) {
reply_with_error ("augeas initialization failed");
@@ -148,25 +148,6 @@ do_aug_init (const char *root, int flags)
return -1;
}
- if (!augeas_is_version (1, 2, 1)) {
- int r = aug_transform (aug, "guestfs_shadow",
"/etc/shadow",
- 0 /* = included */);
- if (r == -1) {
- AUGEAS_ERROR ("aug_transform");
- aug_close (aug);
- aug = NULL;
- return -1;
- }
-
- /* If aug_load was implicitly called, reload the handle. */
- if ((flags & AUG_NO_LOAD) == 0) {
- if (aug_load (aug) == -1) {
- AUGEAS_ERROR ("aug_load");
- return -1;
- }
- }
- }
-
return 0;
}
--
2.21.0
Pino Toscano
2019-May-29 09:59 UTC
[Libguestfs] [PATCH 3/3] daemon: implement OptString for OCaml APIs
It is already considered as string option, so create an option string
value in the C glue for OptString parameters.
---
generator/daemon.ml | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/generator/daemon.ml b/generator/daemon.ml
index a4e136aaa..c2b7c79a2 100644
--- a/generator/daemon.ml
+++ b/generator/daemon.ml
@@ -600,6 +600,22 @@ let generate_daemon_caml_stubs () #include
\"actions.h\"
#include \"daemon-c.h\"
+static CAMLprim value
+Val_optstring (const char *s)
+{
+ CAMLparam0 ();
+ CAMLlocal2 (optv, v);
+
+ if (s) { /* Return Some val */
+ v = caml_copy_string (s);
+ optv = caml_alloc (1, 0);
+ Field (optv, 0) = v;
+ } else /* Return None */
+ optv = Val_int (0);
+
+ CAMLreturn (optv);
+}
+
";
(* Implement code for returning structs and struct lists. *)
@@ -797,7 +813,7 @@ let generate_daemon_caml_stubs () | String
((Mountable|Mountable_or_Path), n) ->
pr "guestfs_int_daemon_copy_mountable (%s)" n
| String _ -> assert false
- | OptString _ -> assert false
+ | OptString n -> pr "Val_optstring (%s)" n
| StringList _ -> assert false
| BufferIn _ -> assert false
| Pointer _ -> assert false
--
2.21.0
Richard W.M. Jones
2019-May-29 10:02 UTC
Re: [Libguestfs] [PATCH 3/3] daemon: implement OptString for OCaml APIs
ACK series. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-builder quickly builds VMs from scratch http://libguestfs.org/virt-builder.1.html
Apparently Analagous Threads
- [PATCH 0/3] Simple augeas-related changes
- [PATCH 1/4] php: fix invalid memory access with OptString
- [PATCH 0/5] RFC: switch augeas APIs to OCaml
- [PATCH] ocaml: Change calls to caml_named_value() to cope with const value* return.
- [PATCH v11 02/10] daemon: Embed the ocaml-augeas library in the daemon.