Skip to content

Commit

Permalink
Shadow: allow NIS entries
Browse files Browse the repository at this point in the history
Add support for the NIS default entry + and the nis default entry with
overrides +::::::::

Based on hercules-team#237
  • Loading branch information
stoicbo authored and lutter committed May 22, 2015
1 parent dc62b24 commit 071175d
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 13 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ Contributions by:
Nicolas Valcárcel Scerpella <[email protected]>
Gonzalo Servat <[email protected]>
Nahum Shalman <nshalman elys com>
Borislav Stoichkov <[email protected]>
Tim Stoop <[email protected]>
Laine Stump <[email protected]>
Jiri Suchomel <[email protected]>
Expand Down
35 changes: 22 additions & 13 deletions lenses/shadow.aug
Original file line number Diff line number Diff line change
Expand Up @@ -45,25 +45,34 @@ let sto_to_eol = Passwd.sto_to_eol
(************************************************************************
* Group: ENTRIES
*************************************************************************)

(* Common for entry and nisdefault *)
let common = [ 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? ]

(* 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 ]
let entry = [ key word
. colon
. [ label "password" . sto_to_col? . colon ]
. common
. eol ]

let nisdefault =
let overrides =
colon
. [ label "password" . store word? . colon ]
. common in
[ dels "+" . label "@nisdefault" . overrides? . eol ]

(************************************************************************
* LENS
*************************************************************************)

let lns = (comment|empty|entry) *
let lns = (comment|empty|entry|nisdefault) *

let filter
= incl "/etc/shadow"
Expand Down
36 changes: 36 additions & 0 deletions lenses/tests/test_shadow.aug
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,39 @@ test Shadow.lns get conf =
{ "inactive_days" = "" }
{ "expire_date" = "" }
{ "flag" = "" } }

test Shadow.lns get "+\n" =
{ "@nisdefault" }

test Shadow.lns get "+::::::::\n" =
{ "@nisdefault"
{ "password" = "" }
{ "lastchange_date" = "" }
{ "minage_days" = "" }
{ "maxage_days" = "" }
{ "warn_days" = "" }
{ "inactive_days" = "" }
{ "expire_date" = "" }
{ "flag" = "" } }

test Shadow.lns put "+\n" after
set "@nisdefault/password" "";
set "@nisdefault/lastchange_date" "";
set "@nisdefault/minage_days" "";
set "@nisdefault/maxage_days" "";
set "@nisdefault/warn_days" "";
set "@nisdefault/inactive_days" "";
set "@nisdefault/expire_date" "";
set "@nisdefault/flag" ""
= "+::::::::\n"

test Shadow.lns put "+::::::::\n" after
rm "@nisdefault/password";
rm "@nisdefault/lastchange_date";
rm "@nisdefault/minage_days";
rm "@nisdefault/maxage_days";
rm "@nisdefault/warn_days";
rm "@nisdefault/inactive_days";
rm "@nisdefault/expire_date";
rm "@nisdefault/flag"
= "+\n"

0 comments on commit 071175d

Please sign in to comment.