[Libguestfs] [PATCH 2/3] appliance: remove custom Shadow augeas lens

Pino Toscano ptoscano at redhat.com
Wed May 29 09:59:46 UTC 2019


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 at ccd.uniroma2.it>
-
- Original Author: Free Ekanayaka <free at 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




More information about the Libguestfs mailing list