Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
504
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.38 KB | None | 0 0
  1. (*
  2. Module: Nsswitch
  3. Parses /etc/nsswitch.conf
  4.  
  5. Author: Raphael Pinson <raphink@gmail.com>
  6.  
  7. About: Reference
  8. This lens tries to keep as close as possible to `man nsswitch.conf` where possible.
  9.  
  10. About: Licence
  11. This file is licensed under the LGPLv2+, like the rest of Augeas.
  12.  
  13. About: Lens Usage
  14.  
  15. About: Configuration files
  16. This lens applies to /etc/nsswitch.conf. See <filter>.
  17. *)
  18.  
  19. module Nsswitch =
  20. autoload xfm
  21.  
  22. (************************************************************************
  23. * Group: USEFUL PRIMITIVES
  24. *************************************************************************)
  25.  
  26. (* View: comment *)
  27. let comment = Util.comment
  28.  
  29. (* View: empty *)
  30. let empty = Util.empty
  31.  
  32. (* View: sep_colon
  33. The separator for database entries *)
  34. let sep_colon = del /:[ \t]*/ ": "
  35.  
  36. (* View: service
  37. The service specification like `files', `db', or `nis' *)
  38. let service = [ label "service" . store Rx.word ]
  39.  
  40. (* View: reaction
  41. The reaction on lookup result like `[NOTFOUND=return]' *)
  42. let reaction =
  43. let status_kw = /success/i
  44. | /notfound/i
  45. | /unavail/i
  46. | /tryagain/i
  47. in let action_kw = /return/i
  48. | /continue/i
  49. in let negate = [ Util.del_str "!" . label "negate" ]
  50. in let reaction_entry = [ label "status" . negate?
  51. . store status_kw
  52. . Util.del_str "="
  53. . [ label "action" . store action_kw ] ]
  54. in Util.del_str "["
  55. . [ label "reaction"
  56. . (Build.opt_list reaction_entry Sep.space) ]
  57. . Util.del_str "]"
  58.  
  59. (* View: database *)
  60. let database =
  61. let database_kw = "aliases"
  62. | "ethers"
  63. | "group"
  64. | "hosts"
  65. | "netgroup"
  66. | "networks"
  67. | "passwd"
  68. | "protocols"
  69. | "publickey"
  70. | "rpc"
  71. | "services"
  72. | "shadow"
  73. in [ label "database" . store database_kw
  74. . sep_colon
  75. . (Build.opt_list
  76. (service|reaction)
  77. Sep.space)
  78. . Util.eol ]
  79.  
  80. (* View: lns *)
  81. let lns = ( empty | comment | database )*
  82.  
  83. (* Variable: filter *)
  84. let filter = (incl "/etc/resolv.conf")
  85. . Util.stdexcl
  86.  
  87. let xfm = transform lns filter
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement