|
Packit Service |
a2ae7a |
(*
|
|
Packit Service |
a2ae7a |
Module: Sudoers
|
|
Packit Service |
a2ae7a |
Parses /etc/sudoers
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
Author: Raphael Pinson <raphink@gmail.com>
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
About: Reference
|
|
Packit Service |
a2ae7a |
This lens tries to keep as close as possible to `man sudoers` where possible.
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
For example, recursive definitions such as
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
> Cmnd_Spec_List ::= Cmnd_Spec |
|
|
Packit Service |
a2ae7a |
> Cmnd_Spec ',' Cmnd_Spec_List
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
are replaced by
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
> let cmnd_spec_list = cmnd_spec . ( sep_com . cmnd_spec )*
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
since Augeas cannot deal with recursive definitions.
|
|
Packit Service |
a2ae7a |
The definitions from `man sudoers` are put as commentaries for reference
|
|
Packit Service |
a2ae7a |
throughout the file. More information can be found in the manual.
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
About: License
|
|
Packit Service |
a2ae7a |
This file is licensed under the LGPL v2+, like the rest of Augeas.
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
About: Lens Usage
|
|
Packit Service |
a2ae7a |
Sample usage of this lens in augtool
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
* Set first Defaults to apply to the "LOCALNET" network alias
|
|
Packit Service |
a2ae7a |
> set /files/etc/sudoers/Defaults[1]/type "@LOCALNET"
|
|
Packit Service |
a2ae7a |
* List all user specifications applying explicitly to the "admin" Unix group
|
|
Packit Service |
a2ae7a |
> match /files/etc/sudoers/spec/user "%admin"
|
|
Packit Service |
a2ae7a |
* Remove the full 3rd user specification
|
|
Packit Service |
a2ae7a |
> rm /files/etc/sudoers/spec[3]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
About: Configuration files
|
|
Packit Service |
a2ae7a |
This lens applies to /etc/sudoers. See <filter>.
|
|
Packit Service |
a2ae7a |
*)
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
module Sudoers =
|
|
Packit Service |
a2ae7a |
autoload xfm
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(************************************************************************
|
|
Packit Service |
a2ae7a |
* Group: USEFUL PRIMITIVES
|
|
Packit Service |
a2ae7a |
*************************************************************************)
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* Group: Generic primitives *)
|
|
Packit Service |
a2ae7a |
(* Variable: eol *)
|
|
Packit Service |
a2ae7a |
let eol = Util.eol
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* Variable: indent *)
|
|
Packit Service |
a2ae7a |
let indent = Util.indent
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* Group: Separators *)
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* Variable: sep_spc *)
|
|
Packit Service |
a2ae7a |
let sep_spc = Sep.space
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* Variable: sep_cont *)
|
|
Packit Service |
a2ae7a |
let sep_cont = Sep.cl_or_space
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* Variable: sep_cont_opt *)
|
|
Packit Service |
a2ae7a |
let sep_cont_opt = Sep.cl_or_opt_space
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* Variable: sep_cont_opt_build *)
|
|
Packit Service |
a2ae7a |
let sep_cont_opt_build (sep:string) =
|
|
Packit Service |
a2ae7a |
del (Rx.cl_or_opt_space . sep . Rx.cl_or_opt_space) (" " . sep . " ")
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* Variable: sep_com *)
|
|
Packit Service |
a2ae7a |
let sep_com = sep_cont_opt_build ","
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* Variable: sep_eq *)
|
|
Packit Service |
a2ae7a |
let sep_eq = sep_cont_opt_build "="
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* Variable: sep_col *)
|
|
Packit Service |
a2ae7a |
let sep_col = sep_cont_opt_build ":"
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* Variable: sep_dquote *)
|
|
Packit Service |
a2ae7a |
let sep_dquote = Util.del_str "\""
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* Group: Negation expressions *)
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(************************************************************************
|
|
Packit Service |
a2ae7a |
* View: del_negate
|
|
Packit Service |
a2ae7a |
* Delete an even number of '!' signs
|
|
Packit Service |
a2ae7a |
*************************************************************************)
|
|
Packit Service |
a2ae7a |
let del_negate = del /(!!)*/ ""
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(************************************************************************
|
|
Packit Service |
a2ae7a |
* View: negate_node
|
|
Packit Service |
a2ae7a |
* Negation of boolean values for <defaults>. Accept one optional '!'
|
|
Packit Service |
a2ae7a |
* and produce a 'negate' node if there is one.
|
|
Packit Service |
a2ae7a |
*************************************************************************)
|
|
Packit Service |
a2ae7a |
let negate_node = [ del "!" "!" . label "negate" ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(************************************************************************
|
|
Packit Service |
a2ae7a |
* View: negate_or_value
|
|
Packit Service |
a2ae7a |
* A <del_negate>, followed by either a negated key, or a key/value pair
|
|
Packit Service |
a2ae7a |
*************************************************************************)
|
|
Packit Service |
a2ae7a |
let negate_or_value (key:lens) (value:lens) =
|
|
Packit Service |
a2ae7a |
[ del_negate . (negate_node . key | key . value) ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* Group: Stores *)
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* Variable: sto_to_com_cmnd
|
|
Packit Service |
a2ae7a |
sto_to_com_cmnd does not begin or end with a space *)
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let sto_to_com_cmnd = del_negate . negate_node? . (
|
|
Packit Service |
a2ae7a |
let alias = Rx.word - /(NO)?(PASSWD|EXEC|SETENV)/
|
|
Packit Service |
a2ae7a |
in let non_alias = /[\/a-z]([^,:#()\n\\]|\\\\[=:,\\])*[^,=:#() \t\n\\]|[^,=:#() \t\n\\]/
|
|
Packit Service |
a2ae7a |
in store (alias | non_alias))
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* Variable: sto_to_com
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
There could be a \ in the middle of a command *)
|
|
Packit Service |
a2ae7a |
let sto_to_com = store /([^,=:#() \t\n\\][^,=:#()\n]*[^,=:#() \t\n\\])|[^,=:#() \t\n\\]/
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* Variable: sto_to_com_host *)
|
|
Packit Service |
a2ae7a |
let sto_to_com_host = store /[^,=:#() \t\n\\]+/
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* Variable: sto_to_com_user
|
|
Packit Service |
a2ae7a |
Escaped spaces and NIS domains and allowed*)
|
|
Packit Service |
a2ae7a |
let sto_to_com_user =
|
|
Packit Service |
a2ae7a |
let nis_re = /([A-Z]([-A-Z0-9]|(\\\\[ \t]))*+\\\\\\\\)/
|
|
Packit Service |
a2ae7a |
in let user_re = /[%+@a-z]([-A-Za-z0-9._+]|(\\\\[ \t]))*/
|
|
Packit Service |
a2ae7a |
in let alias_re = /[A-Z_]+/
|
|
Packit Service |
a2ae7a |
in store ((nis_re? . user_re) | alias_re)
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* Variable: to_com_chars *)
|
|
Packit Service |
a2ae7a |
let to_com_chars = /[^",=#() \t\n\\]+/ (* " relax emacs *)
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* Variable: to_com_dquot *)
|
|
Packit Service |
a2ae7a |
let to_com_dquot = /"[^",=#()\n\\]+"/ (* " relax emacs *)
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* Variable: sto_to_com_dquot *)
|
|
Packit Service |
a2ae7a |
let sto_to_com_dquot = store (to_com_chars|to_com_dquot)
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* Variable: sto_to_com_col *)
|
|
Packit Service |
a2ae7a |
let sto_to_com_col = store to_com_chars
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* Variable: sto_to_eq *)
|
|
Packit Service |
a2ae7a |
let sto_to_eq = store /[^,=:#() \t\n\\]+/
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* Variable: sto_to_spc *)
|
|
Packit Service |
a2ae7a |
let sto_to_spc = store /[^", \t\n\\]+|"[^", \t\n\\]+"/
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* Variable: sto_to_spc_no_dquote *)
|
|
Packit Service |
a2ae7a |
let sto_to_spc_no_dquote = store /[^",# \t\n\\]+/ (* " relax emacs *)
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* Variable: sto_integer *)
|
|
Packit Service |
a2ae7a |
let sto_integer = store /[0-9]+/
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* Group: Comments and empty lines *)
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: comment
|
|
Packit Service |
a2ae7a |
Map comments in "#comment" nodes *)
|
|
Packit Service |
a2ae7a |
let comment =
|
|
Packit Service |
a2ae7a |
let sto_to_eol = store (/([^ \t\n].*[^ \t\n]|[^ \t\n])/ - /include(dir)?.*/) in
|
|
Packit Service |
a2ae7a |
[ label "#comment" . del /[ \t]*#[ \t]*/ "# " . sto_to_eol . eol ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: comment_eol
|
|
Packit Service |
a2ae7a |
Requires a space before the # *)
|
|
Packit Service |
a2ae7a |
let comment_eol = Util.comment_generic /[ \t]+#[ \t]*/ " # "
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: comment_or_eol
|
|
Packit Service |
a2ae7a |
A <comment_eol> or <eol> *)
|
|
Packit Service |
a2ae7a |
let comment_or_eol = comment_eol | (del /([ \t]+#\n|[ \t]*\n)/ "\n")
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: empty
|
|
Packit Service |
a2ae7a |
Map empty lines *)
|
|
Packit Service |
a2ae7a |
let empty = [ del /[ \t]*#?[ \t]*\n/ "\n" ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: includedir *)
|
|
Packit Service |
a2ae7a |
let includedir =
|
|
Packit Service |
a2ae7a |
[ key /#include(dir)?/ . Sep.space . store Rx.fspath . eol ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(************************************************************************
|
|
Packit Service |
a2ae7a |
* Group: ALIASES
|
|
Packit Service |
a2ae7a |
*************************************************************************)
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(************************************************************************
|
|
Packit Service |
a2ae7a |
* View: alias_field
|
|
Packit Service |
a2ae7a |
* Generic alias field to gather all Alias definitions
|
|
Packit Service |
a2ae7a |
*
|
|
Packit Service |
a2ae7a |
* Definition:
|
|
Packit Service |
a2ae7a |
* > User_Alias ::= NAME '=' User_List
|
|
Packit Service |
a2ae7a |
* > Runas_Alias ::= NAME '=' Runas_List
|
|
Packit Service |
a2ae7a |
* > Host_Alias ::= NAME '=' Host_List
|
|
Packit Service |
a2ae7a |
* > Cmnd_Alias ::= NAME '=' Cmnd_List
|
|
Packit Service |
a2ae7a |
*
|
|
Packit Service |
a2ae7a |
* Parameters:
|
|
Packit Service |
a2ae7a |
* kw:string - the label string
|
|
Packit Service |
a2ae7a |
* sto:lens - the store lens
|
|
Packit Service |
a2ae7a |
*************************************************************************)
|
|
Packit Service |
a2ae7a |
let alias_field (kw:string) (sto:lens) = [ label kw . sto ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: alias_list
|
|
Packit Service |
a2ae7a |
List of <alias_fields>, separated by commas *)
|
|
Packit Service |
a2ae7a |
let alias_list (kw:string) (sto:lens) =
|
|
Packit Service |
a2ae7a |
Build.opt_list (alias_field kw sto) sep_com
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(************************************************************************
|
|
Packit Service |
a2ae7a |
* View: alias_name
|
|
Packit Service |
a2ae7a |
* Name of an <alias_entry_single>
|
|
Packit Service |
a2ae7a |
*
|
|
Packit Service |
a2ae7a |
* Definition:
|
|
Packit Service |
a2ae7a |
* > NAME ::= [A-Z]([A-Z][0-9]_)*
|
|
Packit Service |
a2ae7a |
*************************************************************************)
|
|
Packit Service |
a2ae7a |
let alias_name
|
|
Packit Service |
a2ae7a |
= [ label "name" . store /[A-Z][A-Z0-9_]*/ ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(************************************************************************
|
|
Packit Service |
a2ae7a |
* View: alias_entry_single
|
|
Packit Service |
a2ae7a |
* Single <alias_entry>, named using <alias_name> and listing <alias_list>
|
|
Packit Service |
a2ae7a |
*
|
|
Packit Service |
a2ae7a |
* Definition:
|
|
Packit Service |
a2ae7a |
* > Alias_Type NAME = item1, item2, ...
|
|
Packit Service |
a2ae7a |
*
|
|
Packit Service |
a2ae7a |
* Parameters:
|
|
Packit Service |
a2ae7a |
* field:string - the field name, passed to <alias_list>
|
|
Packit Service |
a2ae7a |
* sto:lens - the store lens, passed to <alias_list>
|
|
Packit Service |
a2ae7a |
*************************************************************************)
|
|
Packit Service |
a2ae7a |
let alias_entry_single (field:string) (sto:lens)
|
|
Packit Service |
a2ae7a |
= [ label "alias" . alias_name . sep_eq . alias_list field sto ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(************************************************************************
|
|
Packit Service |
a2ae7a |
* View: alias_entry
|
|
Packit Service |
a2ae7a |
* Alias entry, a list of comma-separated <alias_entry_single> fields
|
|
Packit Service |
a2ae7a |
*
|
|
Packit Service |
a2ae7a |
* Definition:
|
|
Packit Service |
a2ae7a |
* > Alias_Type NAME = item1, item2, item3 : NAME = item4, item5
|
|
Packit Service |
a2ae7a |
*
|
|
Packit Service |
a2ae7a |
* Parameters:
|
|
Packit Service |
a2ae7a |
* kw:string - the alias keyword string
|
|
Packit Service |
a2ae7a |
* field:string - the field name, passed to <alias_entry_single>
|
|
Packit Service |
a2ae7a |
* sto:lens - the store lens, passed to <alias_entry_single>
|
|
Packit Service |
a2ae7a |
*************************************************************************)
|
|
Packit Service |
a2ae7a |
let alias_entry (kw:string) (field:string) (sto:lens)
|
|
Packit Service |
a2ae7a |
= [ indent . key kw . sep_cont . alias_entry_single field sto
|
|
Packit Service |
a2ae7a |
. ( sep_col . alias_entry_single field sto )* . comment_or_eol ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* TODO: go further in user definitions *)
|
|
Packit Service |
a2ae7a |
(* View: user_alias
|
|
Packit Service |
a2ae7a |
User_Alias, see <alias_field> *)
|
|
Packit Service |
a2ae7a |
let user_alias = alias_entry "User_Alias" "user" sto_to_com
|
|
Packit Service |
a2ae7a |
(* View: runas_alias
|
|
Packit Service |
a2ae7a |
Run_Alias, see <alias_field> *)
|
|
Packit Service |
a2ae7a |
let runas_alias = alias_entry "Runas_Alias" "runas_user" sto_to_com
|
|
Packit Service |
a2ae7a |
(* View: host_alias
|
|
Packit Service |
a2ae7a |
Host_Alias, see <alias_field> *)
|
|
Packit Service |
a2ae7a |
let host_alias = alias_entry "Host_Alias" "host" sto_to_com
|
|
Packit Service |
a2ae7a |
(* View: cmnd_alias
|
|
Packit Service |
a2ae7a |
Cmnd_Alias, see <alias_field> *)
|
|
Packit Service |
a2ae7a |
let cmnd_alias = alias_entry "Cmnd_Alias" "command" sto_to_com_cmnd
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(************************************************************************
|
|
Packit Service |
a2ae7a |
* View: alias
|
|
Packit Service |
a2ae7a |
* Every kind of Alias entry,
|
|
Packit Service |
a2ae7a |
* see <user_alias>, <runas_alias>, <host_alias> and <cmnd_alias>
|
|
Packit Service |
a2ae7a |
*
|
|
Packit Service |
a2ae7a |
* Definition:
|
|
Packit Service |
a2ae7a |
* > Alias ::= 'User_Alias' User_Alias (':' User_Alias)* |
|
|
Packit Service |
a2ae7a |
* > 'Runas_Alias' Runas_Alias (':' Runas_Alias)* |
|
|
Packit Service |
a2ae7a |
* > 'Host_Alias' Host_Alias (':' Host_Alias)* |
|
|
Packit Service |
a2ae7a |
* > 'Cmnd_Alias' Cmnd_Alias (':' Cmnd_Alias)*
|
|
Packit Service |
a2ae7a |
*************************************************************************)
|
|
Packit Service |
a2ae7a |
let alias = user_alias | runas_alias | host_alias | cmnd_alias
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(************************************************************************
|
|
Packit Service |
a2ae7a |
* Group: DEFAULTS
|
|
Packit Service |
a2ae7a |
*************************************************************************)
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(************************************************************************
|
|
Packit Service |
a2ae7a |
* View: default_type
|
|
Packit Service |
a2ae7a |
* Type definition for <defaults>
|
|
Packit Service |
a2ae7a |
*
|
|
Packit Service |
a2ae7a |
* Definition:
|
|
Packit Service |
a2ae7a |
* > Default_Type ::= 'Defaults' |
|
|
Packit Service |
a2ae7a |
* > 'Defaults' '@' Host_List |
|
|
Packit Service |
a2ae7a |
* > 'Defaults' ':' User_List |
|
|
Packit Service |
a2ae7a |
* > 'Defaults' '!' Cmnd_List |
|
|
Packit Service |
a2ae7a |
* > 'Defaults' '>' Runas_List
|
|
Packit Service |
a2ae7a |
*************************************************************************)
|
|
Packit Service |
a2ae7a |
let default_type =
|
|
Packit Service |
a2ae7a |
let value = store /[@:!>][^ \t\n\\]+/ in
|
|
Packit Service |
a2ae7a |
[ label "type" . value ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(************************************************************************
|
|
Packit Service |
a2ae7a |
* View: parameter_flag
|
|
Packit Service |
a2ae7a |
* A flag parameter for <defaults>
|
|
Packit Service |
a2ae7a |
*
|
|
Packit Service |
a2ae7a |
* Flags are implicitly boolean and can be turned off via the '!' operator.
|
|
Packit Service |
a2ae7a |
* Some integer, string and list parameters may also be used in a boolean
|
|
Packit Service |
a2ae7a |
* context to disable them.
|
|
Packit Service |
a2ae7a |
*************************************************************************)
|
|
Packit Service |
a2ae7a |
let parameter_flag_kw = "always_set_home" | "authenticate" | "env_editor"
|
|
Packit Service |
a2ae7a |
| "env_reset" | "fqdn" | "ignore_dot"
|
|
Packit Service |
a2ae7a |
| "ignore_local_sudoers" | "insults" | "log_host"
|
|
Packit Service |
a2ae7a |
| "log_year" | "long_otp_prompt" | "mail_always"
|
|
Packit Service |
a2ae7a |
| "mail_badpass" | "mail_no_host" | "mail_no_perms"
|
|
Packit Service |
a2ae7a |
| "mail_no_user" | "noexec" | "path_info"
|
|
Packit Service |
a2ae7a |
| "passprompt_override" | "preserve_groups"
|
|
Packit Service |
a2ae7a |
| "requiretty" | "root_sudo" | "rootpw" | "runaspw"
|
|
Packit Service |
a2ae7a |
| "set_home" | "set_logname" | "setenv"
|
|
Packit Service |
a2ae7a |
| "shell_noargs" | "stay_setuid" | "targetpw"
|
|
Packit Service |
a2ae7a |
| "tty_tickets" | "visiblepw" | "closefrom_override"
|
|
Packit Service |
a2ae7a |
| "closefrom_override" | "compress_io" | "fast_glob"
|
|
Packit Service |
a2ae7a |
| "log_input" | "log_output" | "pwfeedback"
|
|
Packit Service |
a2ae7a |
| "umask_override" | "use_pty" | "match_group_by_gid"
|
|
Packit Service |
a2ae7a |
| "always_query_group_plugin"
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let parameter_flag = [ del_negate . negate_node?
|
|
Packit Service |
a2ae7a |
. key parameter_flag_kw ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(************************************************************************
|
|
Packit Service |
a2ae7a |
* View: parameter_integer
|
|
Packit Service |
a2ae7a |
* An integer parameter for <defaults>
|
|
Packit Service |
a2ae7a |
*************************************************************************)
|
|
Packit Service |
a2ae7a |
let parameter_integer_nobool_kw = "passwd_tries"
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let parameter_integer_nobool = [ key parameter_integer_nobool_kw . sep_eq
|
|
Packit Service |
a2ae7a |
. del /"?/ "" . sto_integer
|
|
Packit Service |
a2ae7a |
. del /"?/ "" ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let parameter_integer_bool_kw = "loglinelen" | "passwd_timeout"
|
|
Packit Service |
a2ae7a |
| "timestamp_timeout" | "umask"
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let parameter_integer_bool =
|
|
Packit Service |
a2ae7a |
negate_or_value
|
|
Packit Service |
a2ae7a |
(key parameter_integer_bool_kw)
|
|
Packit Service |
a2ae7a |
(sep_eq . del /"?/ "" . sto_integer . del /"?/ "")
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let parameter_integer = parameter_integer_nobool
|
|
Packit Service |
a2ae7a |
| parameter_integer_bool
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(************************************************************************
|
|
Packit Service |
a2ae7a |
* View: parameter_string
|
|
Packit Service |
a2ae7a |
* A string parameter for <defaults>
|
|
Packit Service |
a2ae7a |
*
|
|
Packit Service |
a2ae7a |
* An odd number of '!' operators negate the value of the item;
|
|
Packit Service |
a2ae7a |
* an even number just cancel each other out.
|
|
Packit Service |
a2ae7a |
*************************************************************************)
|
|
Packit Service |
a2ae7a |
let parameter_string_nobool_kw = "badpass_message" | "editor" | "mailsub"
|
|
Packit Service |
a2ae7a |
| "noexec_file" | "passprompt" | "runas_default"
|
|
Packit Service |
a2ae7a |
| "syslog_badpri" | "syslog_goodpri"
|
|
Packit Service |
a2ae7a |
| "timestampdir" | "timestampowner" | "secure_path"
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let parameter_string_nobool = [ key parameter_string_nobool_kw . sep_eq
|
|
Packit Service |
a2ae7a |
. sto_to_com_dquot ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let parameter_string_bool_kw = "exempt_group" | "lecture" | "lecture_file"
|
|
Packit Service |
a2ae7a |
| "listpw" | "logfile" | "mailerflags"
|
|
Packit Service |
a2ae7a |
| "mailerpath" | "mailto" | "mailfrom"
|
|
Packit Service |
a2ae7a |
| "syslog" | "verifypw"
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let parameter_string_bool =
|
|
Packit Service |
a2ae7a |
negate_or_value
|
|
Packit Service |
a2ae7a |
(key parameter_string_bool_kw)
|
|
Packit Service |
a2ae7a |
(sep_eq . sto_to_com_dquot)
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let parameter_string = parameter_string_nobool
|
|
Packit Service |
a2ae7a |
| parameter_string_bool
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(************************************************************************
|
|
Packit Service |
a2ae7a |
* View: parameter_lists
|
|
Packit Service |
a2ae7a |
* A single list parameter for <defaults>
|
|
Packit Service |
a2ae7a |
*
|
|
Packit Service |
a2ae7a |
* All lists can be used in a boolean context
|
|
Packit Service |
a2ae7a |
* The argument may be a double-quoted, space-separated list or a single
|
|
Packit Service |
a2ae7a |
* value without double-quotes.
|
|
Packit Service |
a2ae7a |
* The list can be replaced, added to, deleted from, or disabled
|
|
Packit Service |
a2ae7a |
* by using the =, +=, -=, and ! operators respectively.
|
|
Packit Service |
a2ae7a |
* An odd number of '!' operators negate the value of the item;
|
|
Packit Service |
a2ae7a |
* an even number just cancel each other out.
|
|
Packit Service |
a2ae7a |
*************************************************************************)
|
|
Packit Service |
a2ae7a |
let parameter_lists_kw = "env_check" | "env_delete" | "env_keep"
|
|
Packit Service |
a2ae7a |
let parameter_lists_value = [ label "var" . sto_to_spc_no_dquote ]
|
|
Packit Service |
a2ae7a |
let parameter_lists_value_dquote = [ label "var"
|
|
Packit Service |
a2ae7a |
. del /"?/ "" . sto_to_spc_no_dquote
|
|
Packit Service |
a2ae7a |
. del /"?/ "" ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let parameter_lists_values = parameter_lists_value_dquote
|
|
Packit Service |
a2ae7a |
| ( sep_dquote . parameter_lists_value
|
|
Packit Service |
a2ae7a |
. ( sep_cont . parameter_lists_value )+
|
|
Packit Service |
a2ae7a |
. sep_dquote )
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let parameter_lists_sep = sep_cont_opt
|
|
Packit Service |
a2ae7a |
. ( [ del "+" "+" . label "append" ]
|
|
Packit Service |
a2ae7a |
| [ del "-" "-" . label "remove" ] )?
|
|
Packit Service |
a2ae7a |
. del "=" "=" . sep_cont_opt
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let parameter_lists =
|
|
Packit Service |
a2ae7a |
negate_or_value
|
|
Packit Service |
a2ae7a |
(key parameter_lists_kw)
|
|
Packit Service |
a2ae7a |
(parameter_lists_sep . parameter_lists_values)
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(************************************************************************
|
|
Packit Service |
a2ae7a |
* View: parameter
|
|
Packit Service |
a2ae7a |
* A single parameter for <defaults>
|
|
Packit Service |
a2ae7a |
*
|
|
Packit Service |
a2ae7a |
* Definition:
|
|
Packit Service |
a2ae7a |
* > Parameter ::= Parameter '=' Value |
|
|
Packit Service |
a2ae7a |
* > Parameter '+=' Value |
|
|
Packit Service |
a2ae7a |
* > Parameter '-=' Value |
|
|
Packit Service |
a2ae7a |
* > '!'* Parameter
|
|
Packit Service |
a2ae7a |
*
|
|
Packit Service |
a2ae7a |
* Parameters may be flags, integer values, strings, or lists.
|
|
Packit Service |
a2ae7a |
*
|
|
Packit Service |
a2ae7a |
*************************************************************************)
|
|
Packit Service |
a2ae7a |
let parameter = parameter_flag | parameter_integer
|
|
Packit Service |
a2ae7a |
| parameter_string | parameter_lists
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(************************************************************************
|
|
Packit Service |
a2ae7a |
* View: parameter_list
|
|
Packit Service |
a2ae7a |
* A list of comma-separated <parameters> for <defaults>
|
|
Packit Service |
a2ae7a |
*
|
|
Packit Service |
a2ae7a |
* Definition:
|
|
Packit Service |
a2ae7a |
* > Parameter_List ::= Parameter |
|
|
Packit Service |
a2ae7a |
* > Parameter ',' Parameter_List
|
|
Packit Service |
a2ae7a |
*************************************************************************)
|
|
Packit Service |
a2ae7a |
let parameter_list = parameter . ( sep_com . parameter )*
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(************************************************************************
|
|
Packit Service |
a2ae7a |
* View: defaults
|
|
Packit Service |
a2ae7a |
* A Defaults entry
|
|
Packit Service |
a2ae7a |
*
|
|
Packit Service |
a2ae7a |
* Definition:
|
|
Packit Service |
a2ae7a |
* > Default_Entry ::= Default_Type Parameter_List
|
|
Packit Service |
a2ae7a |
*************************************************************************)
|
|
Packit Service |
a2ae7a |
let defaults = [ indent . key "Defaults" . default_type? . sep_cont
|
|
Packit Service |
a2ae7a |
. parameter_list . comment_or_eol ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(************************************************************************
|
|
Packit Service |
a2ae7a |
* Group: USER SPECIFICATION
|
|
Packit Service |
a2ae7a |
*************************************************************************)
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(************************************************************************
|
|
Packit Service |
a2ae7a |
* View: runas_spec
|
|
Packit Service |
a2ae7a |
* A runas specification for <spec>, using <alias_list> for listing
|
|
Packit Service |
a2ae7a |
* users and/or groups used to run a command
|
|
Packit Service |
a2ae7a |
*
|
|
Packit Service |
a2ae7a |
* Definition:
|
|
Packit Service |
a2ae7a |
* > Runas_Spec ::= '(' Runas_List ')' |
|
|
Packit Service |
a2ae7a |
* > '(:' Runas_List ')' |
|
|
Packit Service |
a2ae7a |
* > '(' Runas_List ':' Runas_List ')'
|
|
Packit Service |
a2ae7a |
*************************************************************************)
|
|
Packit Service |
a2ae7a |
let runas_spec_user = alias_list "runas_user" sto_to_com
|
|
Packit Service |
a2ae7a |
let runas_spec_group = Util.del_str ":" . indent
|
|
Packit Service |
a2ae7a |
. alias_list "runas_group" sto_to_com
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let runas_spec_usergroup = runas_spec_user . indent . runas_spec_group
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let runas_spec = Util.del_str "("
|
|
Packit Service |
a2ae7a |
. (runas_spec_user
|
|
Packit Service |
a2ae7a |
| runas_spec_group
|
|
Packit Service |
a2ae7a |
| runas_spec_usergroup )
|
|
Packit Service |
a2ae7a |
. Util.del_str ")" . sep_cont_opt
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(************************************************************************
|
|
Packit Service |
a2ae7a |
* View: tag_spec
|
|
Packit Service |
a2ae7a |
* Tag specification for <spec>
|
|
Packit Service |
a2ae7a |
*
|
|
Packit Service |
a2ae7a |
* Definition:
|
|
Packit Service |
a2ae7a |
* > Tag_Spec ::= ('NOPASSWD:' | 'PASSWD:' | 'NOEXEC:' | 'EXEC:' |
|
|
Packit Service |
a2ae7a |
* > 'SETENV:' | 'NOSETENV:')
|
|
Packit Service |
a2ae7a |
*************************************************************************)
|
|
Packit Service |
a2ae7a |
let tag_spec =
|
|
Packit Service |
a2ae7a |
[ label "tag" . store /(NO)?(PASSWD|EXEC|SETENV)/ . sep_col ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(************************************************************************
|
|
Packit Service |
a2ae7a |
* View: cmnd_spec
|
|
Packit Service |
a2ae7a |
* Command specification for <spec>,
|
|
Packit Service |
a2ae7a |
* with optional <runas_spec> and any amount of <tag_specs>
|
|
Packit Service |
a2ae7a |
*
|
|
Packit Service |
a2ae7a |
* Definition:
|
|
Packit Service |
a2ae7a |
* > Cmnd_Spec ::= Runas_Spec? Tag_Spec* Cmnd
|
|
Packit Service |
a2ae7a |
*************************************************************************)
|
|
Packit Service |
a2ae7a |
let cmnd_spec =
|
|
Packit Service |
a2ae7a |
[ label "command" . runas_spec? . tag_spec* . sto_to_com_cmnd ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(************************************************************************
|
|
Packit Service |
a2ae7a |
* View: cmnd_spec_list
|
|
Packit Service |
a2ae7a |
* A list of comma-separated <cmnd_specs>
|
|
Packit Service |
a2ae7a |
*
|
|
Packit Service |
a2ae7a |
* Definition:
|
|
Packit Service |
a2ae7a |
* > Cmnd_Spec_List ::= Cmnd_Spec |
|
|
Packit Service |
a2ae7a |
* > Cmnd_Spec ',' Cmnd_Spec_List
|
|
Packit Service |
a2ae7a |
*************************************************************************)
|
|
Packit Service |
a2ae7a |
let cmnd_spec_list = Build.opt_list cmnd_spec sep_com
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(************************************************************************
|
|
Packit Service |
a2ae7a |
* View: spec_list
|
|
Packit Service |
a2ae7a |
* Group of hosts with <cmnd_spec_list>
|
|
Packit Service |
a2ae7a |
*************************************************************************)
|
|
Packit Service |
a2ae7a |
let spec_list = [ label "host_group" . alias_list "host" sto_to_com_host
|
|
Packit Service |
a2ae7a |
. sep_eq . cmnd_spec_list ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(************************************************************************
|
|
Packit Service |
a2ae7a |
* View: spec
|
|
Packit Service |
a2ae7a |
* A user specification, listing colon-separated <spec_lists>
|
|
Packit Service |
a2ae7a |
*
|
|
Packit Service |
a2ae7a |
* Definition:
|
|
Packit Service |
a2ae7a |
* > User_Spec ::= User_List Host_List '=' Cmnd_Spec_List \
|
|
Packit Service |
a2ae7a |
* > (':' Host_List '=' Cmnd_Spec_List)*
|
|
Packit Service |
a2ae7a |
*************************************************************************)
|
|
Packit Service |
a2ae7a |
let spec = [ label "spec" . indent
|
|
Packit Service |
a2ae7a |
. alias_list "user" sto_to_com_user . sep_cont
|
|
Packit Service |
a2ae7a |
. Build.opt_list spec_list sep_col
|
|
Packit Service |
a2ae7a |
. comment_or_eol ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(************************************************************************
|
|
Packit Service |
a2ae7a |
* Group: LENS & FILTER
|
|
Packit Service |
a2ae7a |
*************************************************************************)
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: lns
|
|
Packit Service |
a2ae7a |
The sudoers lens, any amount of
|
|
Packit Service |
a2ae7a |
* <empty> lines
|
|
Packit Service |
a2ae7a |
* <comments>
|
|
Packit Service |
a2ae7a |
* <includedirs>
|
|
Packit Service |
a2ae7a |
* <aliases>
|
|
Packit Service |
a2ae7a |
* <defaults>
|
|
Packit Service |
a2ae7a |
* <specs>
|
|
Packit Service |
a2ae7a |
*)
|
|
Packit Service |
a2ae7a |
let lns = ( empty | comment | includedir | alias | defaults | spec )*
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: filter *)
|
|
Packit Service |
a2ae7a |
let filter = (incl "/etc/sudoers")
|
|
Packit Service |
a2ae7a |
. (incl "/usr/local/etc/sudoers")
|
|
Packit Service |
a2ae7a |
. (incl "/etc/sudoers.d/*")
|
|
Packit Service |
a2ae7a |
. (incl "/usr/local/etc/sudoers.d/*")
|
|
Packit Service |
a2ae7a |
. (incl "/opt/csw/etc/sudoers")
|
|
Packit Service |
a2ae7a |
. (incl "/etc/opt/csw/sudoers")
|
|
Packit Service |
a2ae7a |
. Util.stdexcl
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let xfm = transform lns filter
|