Blame SOURCES/0041-Add-a-lens-for-etc-shadow-file-format.patch

ab36df
From 864bb50f577b719411ca47bb088e342d8e89f498 Mon Sep 17 00:00:00 2001
ab36df
From: "Lorenzo M. Catucci" <lorenzo@sancho.ccd.uniroma2.it>
ab36df
Date: Sat, 10 May 2014 15:35:15 +0200
ab36df
Subject: [PATCH] Add a lens for /etc/shadow file format
ab36df
ab36df
and wire-up its test to the runner's list in Makefile.am
ab36df
ab36df
Also add a mock /etc/shadow in tests/root
ab36df
ab36df
(cherry picked from commit 03f24b24ed13fb1d01717a9247bf8a2cea5f0b71)
ab36df
ab36df
Add a little bit of ducumentation
ab36df
ab36df
for both the shadow and the gshadow lenses
ab36df
ab36df
(cherry picked from commit b6090f1782e6093666f60d60ad7d79fd488cc8d0)
ab36df
ab36df
Conflicts:
ab36df
	lenses/gshadow.aug
ab36df
---
ab36df
 doc/naturaldocs/conf/lenses/Menu.txt |  1 +
ab36df
 lenses/shadow.aug                    | 72 ++++++++++++++++++++++++++++++++++++
ab36df
 lenses/tests/test_shadow.aug         | 45 ++++++++++++++++++++++
ab36df
 tests/Makefile.am                    |  1 +
ab36df
 tests/root/etc/shadow                | 19 ++++++++++
ab36df
 5 files changed, 138 insertions(+)
ab36df
 create mode 100644 lenses/shadow.aug
ab36df
 create mode 100644 lenses/tests/test_shadow.aug
ab36df
 create mode 100644 tests/root/etc/shadow
ab36df
ab36df
diff --git a/doc/naturaldocs/conf/lenses/Menu.txt b/doc/naturaldocs/conf/lenses/Menu.txt
ab36df
index af0d421..fbbcfed 100644
ab36df
--- a/doc/naturaldocs/conf/lenses/Menu.txt
ab36df
+++ b/doc/naturaldocs/conf/lenses/Menu.txt
ab36df
@@ -145,6 +145,7 @@ Group: Specific Modules  {
ab36df
    File: Rsyslog  (rsyslog.aug)
ab36df
    File: Schroot  (schroot.aug)
ab36df
    File: Services  (services.aug)
ab36df
+   File: Shadow  (shadow.aug)
ab36df
    File: Shells  (shells.aug)
ab36df
    File: Shellvars  (shellvars.aug)
ab36df
    File: Simplelines  (simplelines.aug)
ab36df
diff --git a/lenses/shadow.aug b/lenses/shadow.aug
ab36df
new file mode 100644
ab36df
index 0000000..dc2ace3
ab36df
--- /dev/null
ab36df
+++ b/lenses/shadow.aug
ab36df
@@ -0,0 +1,72 @@
ab36df
+(*
ab36df
+ Module: Shadow
ab36df
+ Parses /etc/shadow
ab36df
+
ab36df
+ Author: Lorenzo M. Catucci <catucci@ccd.uniroma2.it>
ab36df
+
ab36df
+ Original Author: Free Ekanayaka <free@64studio.com>
ab36df
+
ab36df
+ About: Reference
ab36df
+
ab36df
+   - man 5 shadow
ab36df
+   - man 3 getspnam
ab36df
+
ab36df
+ About: License
ab36df
+   This file is licensed under the LGPL v2+, like the rest of Augeas.
ab36df
+
ab36df
+ About:
ab36df
+
ab36df
+ Each line in the shadow files represents the additional shadow-defined attributes
ab36df
+ for the corresponding user, as defined in the passwd file.
ab36df
+
ab36df
+*)
ab36df
+
ab36df
+module Shadow =
ab36df
+
ab36df
+   autoload xfm
ab36df
+
ab36df
+(************************************************************************
ab36df
+ *                           USEFUL PRIMITIVES
ab36df
+ *************************************************************************)
ab36df
+
ab36df
+let eol        = Util.eol
ab36df
+let comment    = Util.comment
ab36df
+let empty      = Util.empty
ab36df
+let dels       = Util.del_str
ab36df
+
ab36df
+let colon      = Sep.colon
ab36df
+
ab36df
+let word       = Rx.word
ab36df
+let integer    = Rx.integer
ab36df
+
ab36df
+let sto_to_col = Passwd.sto_to_col
ab36df
+let sto_to_eol = Passwd.sto_to_eol
ab36df
+
ab36df
+(************************************************************************
ab36df
+ * Group:                        ENTRIES
ab36df
+ *************************************************************************)
ab36df
+
ab36df
+(* View: entry *)
ab36df
+let entry   = [ key word
ab36df
+                . colon
ab36df
+                . [ label "password"          . sto_to_col?    . colon ]
ab36df
+                . [ label "lastchange_date"   . store integer? . colon ]
ab36df
+                . [ label "minage_days"       . store integer? . colon ]
ab36df
+                . [ label "maxage_days"       . store integer? . colon ]
ab36df
+                . [ label "warn_days"         . store integer? . colon ]
ab36df
+                . [ label "inactive_days"     . store integer? . colon ]
ab36df
+                . [ label "expire_date"       . store integer? . colon ]
ab36df
+                . [ label "flag"              . store integer? ]
ab36df
+                . eol ]
ab36df
+
ab36df
+(************************************************************************
ab36df
+ *                                LENS
ab36df
+ *************************************************************************)
ab36df
+
ab36df
+let lns        = (comment|empty|entry) *
ab36df
+
ab36df
+let filter
ab36df
+               = incl "/etc/shadow"
ab36df
+               . Util.stdexcl
ab36df
+
ab36df
+let xfm        = transform lns filter
ab36df
diff --git a/lenses/tests/test_shadow.aug b/lenses/tests/test_shadow.aug
ab36df
new file mode 100644
ab36df
index 0000000..44b5a94
ab36df
--- /dev/null
ab36df
+++ b/lenses/tests/test_shadow.aug
ab36df
@@ -0,0 +1,45 @@
ab36df
+module Test_Shadow =
ab36df
+
ab36df
+let conf = "root:x:0:0:999999:7:::
ab36df
+libuuid:*:0:0:0::::
ab36df
+expired:$6$INVALID:0:0:0:::100:
ab36df
+locked:!$6$INVALID:0:0:0::::
ab36df
+"
ab36df
+
ab36df
+test Shadow.lns get conf =
ab36df
+  { "root"
ab36df
+    { "password" = "x" }
ab36df
+    { "lastchange_date" = "0" }
ab36df
+    { "minage_days" = "0" }
ab36df
+    { "maxage_days" = "999999" }
ab36df
+    { "warn_days" = "7" }
ab36df
+    { "inactive_days" = "" }
ab36df
+    { "expire_date" = "" }
ab36df
+    { "flag" = "" } }
ab36df
+  { "libuuid"
ab36df
+    { "password" = "*" }
ab36df
+    { "lastchange_date" = "0" }
ab36df
+    { "minage_days" = "0" }
ab36df
+    { "maxage_days" = "0" }
ab36df
+    { "warn_days" = "" }
ab36df
+    { "inactive_days" = "" }
ab36df
+    { "expire_date" = "" }
ab36df
+    { "flag" = "" } }
ab36df
+  { "expired"
ab36df
+    { "password" = "$6$INVALID" }
ab36df
+    { "lastchange_date" = "0" }
ab36df
+    { "minage_days" = "0" }
ab36df
+    { "maxage_days" = "0" }
ab36df
+    { "warn_days" = "" }
ab36df
+    { "inactive_days" = "" }
ab36df
+    { "expire_date" = "100" }
ab36df
+    { "flag" = "" } }
ab36df
+  { "locked"
ab36df
+    { "password" = "!$6$INVALID" }
ab36df
+    { "lastchange_date" = "0" }
ab36df
+    { "minage_days" = "0" }
ab36df
+    { "maxage_days" = "0" }
ab36df
+    { "warn_days" = "" }
ab36df
+    { "inactive_days" = "" }
ab36df
+    { "expire_date" = "" }
ab36df
+    { "flag" = "" } }
ab36df
diff --git a/tests/Makefile.am b/tests/Makefile.am
ab36df
index 7b06472..9f6b5c1 100644
ab36df
--- a/tests/Makefile.am
ab36df
+++ b/tests/Makefile.am
ab36df
@@ -158,6 +158,7 @@ lens_tests =			\
ab36df
   lens-samba.sh			\
ab36df
   lens-securetty.sh     \
ab36df
   lens-services.sh		\
ab36df
+  lens-shadow.sh		\
ab36df
   lens-shells.sh		\
ab36df
   lens-shellvars.sh		\
ab36df
   lens-shellvars_list.sh	\
ab36df
diff --git a/tests/root/etc/shadow b/tests/root/etc/shadow
ab36df
new file mode 100644
ab36df
index 0000000..fe6fd3f
ab36df
--- /dev/null
ab36df
+++ b/tests/root/etc/shadow
ab36df
@@ -0,0 +1,19 @@
ab36df
+root:$5$rounds=1000$TMTRLLOM$h24vGZsHaf6aNdz3dsUuE4z/fy5at1Luuu.FBI6D6M:16200::999999:7:::
ab36df
+bin:x:16200::999999:7:::
ab36df
+daemon:x:16200::999999:7:::
ab36df
+adm:x:16200::999999:7:::
ab36df
+lp:x:16200::999999:7:::
ab36df
+sync:x:16200::999999:7:::
ab36df
+shutdown:x:16200::999999:7:::
ab36df
+halt:x:16200::999999:7:::
ab36df
+mail:x:16200::999999:7:::
ab36df
+uucp:x:16200::999999:7:::
ab36df
+operator:x:16200::999999:7:::
ab36df
+games:x:16200::999999:7:::
ab36df
+gopher:x:16200::999999:7:::
ab36df
+ftp:x:16200::999999:7:::
ab36df
+nobody:x:16200::999999:7:::
ab36df
+vcsa:x:16200::999999:7:::
ab36df
+rpc:x:16200::999999:7:::
ab36df
+rpcuser:x:16200::999999:7:::
ab36df
+nfsnobody:x:16200::999999:7:::