xref: /vim-8.2.3635/runtime/syntax/sudoers.vim (revision 044b68f4)
1" Vim syntax file
2" Language:         sudoers(5) configuration files
3" Maintainer:       Nikolai Weibull <[email protected]>
4" Latest Revision:  2006-04-19
5
6if exists("b:current_syntax")
7  finish
8endif
9
10let s:cpo_save = &cpo
11set cpo&vim
12
13" TODO: instead of 'skipnl', we would like to match a specific group that would
14" match \\$ and then continue with the nextgroup, actually, the skipnl doesn't
15" work...
16" TODO: treat 'ALL' like a special (yay, a bundle of new rules!!!)
17
18syn match   sudoersUserSpec '^' nextgroup=@sudoersUserInSpec skipwhite
19
20syn match   sudoersSpecEquals         contained '=' nextgroup=@sudoersCmndSpecList skipwhite
21
22syn cluster sudoersCmndSpecList       contains=sudoersUserRunasBegin,sudoersPASSWD,@sudoersCmndInSpec
23
24syn keyword sudoersTodo               contained TODO FIXME XXX NOTE
25
26syn region  sudoersComment            display oneline start='#' end='$' contains=sudoersTodo
27
28syn keyword sudoersAlias              User_Alias Runas_Alias nextgroup=sudoersUserAlias skipwhite skipnl
29syn keyword sudoersAlias              Host_Alias nextgroup=sudoersHostAlias skipwhite skipnl
30syn keyword sudoersAlias              Cmnd_Alias nextgroup=sudoersCmndAlias skipwhite skipnl
31
32syn match   sudoersUserAlias          contained '\<\u[A-Z0-9_]*\>'  nextgroup=sudoersUserAliasEquals  skipwhite skipnl
33syn match   sudoersUserNameInList     contained '\<\l\+\>'          nextgroup=@sudoersUserList        skipwhite skipnl
34syn match   sudoersUIDInList          contained '#\d\+\>'           nextgroup=@sudoersUserList        skipwhite skipnl
35syn match   sudoersGroupInList        contained '%\l\+\>'           nextgroup=@sudoersUserList        skipwhite skipnl
36syn match   sudoersUserNetgroupInList contained '+\l\+\>'           nextgroup=@sudoersUserList        skipwhite skipnl
37syn match   sudoersUserAliasInList    contained '\<\u[A-Z0-9_]*\>'  nextgroup=@sudoersUserList        skipwhite skipnl
38
39syn match   sudoersUserName           contained '\<\l\+\>'          nextgroup=@sudoersParameter       skipwhite skipnl
40syn match   sudoersUID                contained '#\d\+\>'           nextgroup=@sudoersParameter       skipwhite skipnl
41syn match   sudoersGroup              contained '%\l\+\>'           nextgroup=@sudoersParameter       skipwhite skipnl
42syn match   sudoersUserNetgroup       contained '+\l\+\>'           nextgroup=@sudoersParameter       skipwhite skipnl
43syn match   sudoersUserAliasRef       contained '\<\u[A-Z0-9_]*\>'  nextgroup=@sudoersParameter       skipwhite skipnl
44
45syn match   sudoersUserNameInSpec     contained '\<\l\+\>'          nextgroup=@sudoersUserSpec        skipwhite skipnl
46syn match   sudoersUIDInSpec          contained '#\d\+\>'           nextgroup=@sudoersUserSpec        skipwhite skipnl
47syn match   sudoersGroupInSpec        contained '%\l\+\>'           nextgroup=@sudoersUserSpec        skipwhite skipnl
48syn match   sudoersUserNetgroupInSpec contained '+\l\+\>'           nextgroup=@sudoersUserSpec        skipwhite skipnl
49syn match   sudoersUserAliasInSpec    contained '\<\u[A-Z0-9_]*\>'  nextgroup=@sudoersUserSpec        skipwhite skipnl
50
51syn match   sudoersUserNameInRunas    contained '\<\l\+\>'          nextgroup=@sudoersUserRunas       skipwhite skipnl
52syn match   sudoersUIDInRunas         contained '#\d\+\>'           nextgroup=@sudoersUserRunas       skipwhite skipnl
53syn match   sudoersGroupInRunas       contained '%\l\+\>'           nextgroup=@sudoersUserRunas       skipwhite skipnl
54syn match   sudoersUserNetgroupInRunas contained '+\l\+\>'          nextgroup=@sudoersUserRunas       skipwhite skipnl
55syn match   sudoersUserAliasInRunas   contained '\<\u[A-Z0-9_]*\>'  nextgroup=@sudoersUserRunas       skipwhite skipnl
56
57syn match   sudoersHostAlias          contained '\<\u[A-Z0-9_]*\>'  nextgroup=sudoersHostAliasEquals  skipwhite skipnl
58syn match   sudoersHostNameInList     contained '\<\l\+\>'          nextgroup=@sudoersHostList        skipwhite skipnl
59syn match   sudoersIPAddrInList       contained '\%(\d\{1,3}\.\)\{3}\d\{1,3}' nextgroup=@sudoersHostList skipwhite skipnl
60syn match   sudoersNetworkInList      contained '\%(\d\{1,3}\.\)\{3}\d\{1,3}\%(/\%(\%(\d\{1,3}\.\)\{3}\d\{1,3}\|\d\+\)\)\=' nextgroup=@sudoersHostList skipwhite skipnl
61syn match   sudoersHostNetgroupInList contained '+\l\+\>'           nextgroup=@sudoersHostList        skipwhite skipnl
62syn match   sudoersHostAliasInList    contained '\<\u[A-Z0-9_]*\>'  nextgroup=@sudoersHostList        skipwhite skipnl
63
64syn match   sudoersHostName           contained '\<\l\+\>'          nextgroup=@sudoersParameter       skipwhite skipnl
65syn match   sudoersIPAddr             contained '\%(\d\{1,3}\.\)\{3}\d\{1,3}' nextgroup=@sudoersParameter skipwhite skipnl
66syn match   sudoersNetwork            contained '\%(\d\{1,3}\.\)\{3}\d\{1,3}\%(/\%(\%(\d\{1,3}\.\)\{3}\d\{1,3}\|\d\+\)\)\=' nextgroup=@sudoersParameter skipwhite skipnl
67syn match   sudoersHostNetgroup       contained '+\l\+\>'           nextgroup=@sudoersParameter       skipwhite skipnl
68syn match   sudoersHostAliasRef       contained '\<\u[A-Z0-9_]*\>'  nextgroup=@sudoersParameter       skipwhite skipnl
69
70syn match   sudoersHostNameInSpec     contained '\<\l\+\>'          nextgroup=@sudoersHostSpec        skipwhite skipnl
71syn match   sudoersIPAddrInSpec       contained '\%(\d\{1,3}\.\)\{3}\d\{1,3}' nextgroup=@sudoersHostSpec skipwhite skipnl
72syn match   sudoersNetworkInSpec      contained '\%(\d\{1,3}\.\)\{3}\d\{1,3}\%(/\%(\%(\d\{1,3}\.\)\{3}\d\{1,3}\|\d\+\)\)\=' nextgroup=@sudoersHostSpec skipwhite skipnl
73syn match   sudoersHostNetgroupInSpec contained '+\l\+\>'           nextgroup=@sudoersHostSpec        skipwhite skipnl
74syn match   sudoersHostAliasInSpec    contained '\<\u[A-Z0-9_]*\>'  nextgroup=@sudoersHostSpec        skipwhite skipnl
75
76syn match   sudoersCmndAlias          contained '\<\u[A-Z0-9_]*\>'  nextgroup=sudoersCmndAliasEquals  skipwhite skipnl
77syn match   sudoersCmndNameInList     contained '[^[:space:],:=\\]\+\%(\\[[:space:],:=\\][^[:space:],:=\\]*\)*' nextgroup=@sudoersCmndList,sudoersCommandEmpty,sudoersCommandArgs skipwhite
78syn match   sudoersCmndAliasInList    contained '\<\u[A-Z0-9_]*\>'  nextgroup=@sudoersCmndList        skipwhite skipnl
79
80syn match   sudoersCmndNameInSpec     contained '[^[:space:],:=\\]\+\%(\\[[:space:],:=\\][^[:space:],:=\\]*\)*' nextgroup=@sudoersCmndSpec,sudoersCommandEmptyInSpec,sudoersCommandArgsInSpec skipwhite
81syn match   sudoersCmndAliasInSpec    contained '\<\u[A-Z0-9_]*\>'  nextgroup=@sudoersCmndSpec        skipwhite skipnl
82
83syn match   sudoersUserAliasEquals  contained '=' nextgroup=@sudoersUserInList  skipwhite skipnl
84syn match   sudoersUserListComma    contained ',' nextgroup=@sudoersUserInList  skipwhite skipnl
85syn match   sudoersUserListColon    contained ':' nextgroup=sudoersUserAlias    skipwhite skipnl
86syn cluster sudoersUserList         contains=sudoersUserListComma,sudoersUserListColon
87
88syn match   sudoersUserSpecComma    contained ',' nextgroup=@sudoersUserInSpec  skipwhite skipnl
89syn cluster sudoersUserSpec         contains=sudoersUserSpecComma,@sudoersHostInSpec
90
91syn match   sudoersUserRunasBegin   contained '(' nextgroup=@sudoersUserInRunas skipwhite skipnl
92syn match   sudoersUserRunasComma   contained ',' nextgroup=@sudoersUserInRunas skipwhite skipnl
93syn match   sudoersUserRunasEnd     contained ')' nextgroup=sudoersPASSWD,@sudoersCmndInSpec skipwhite skipnl
94syn cluster sudoersUserRunas        contains=sudoersUserRunasComma,@sudoersUserInRunas,sudoersUserRunasEnd
95
96
97syn match   sudoersHostAliasEquals  contained '=' nextgroup=@sudoersHostInList  skipwhite skipnl
98syn match   sudoersHostListComma    contained ',' nextgroup=@sudoersHostInList  skipwhite skipnl
99syn match   sudoersHostListColon    contained ':' nextgroup=sudoersHostAlias    skipwhite skipnl
100syn cluster sudoersHostList         contains=sudoersHostListComma,sudoersHostListColon
101
102syn match   sudoersHostSpecComma    contained ',' nextgroup=@sudoersHostInSpec  skipwhite skipnl
103syn cluster sudoersHostSpec         contains=sudoersHostSpecComma,sudoersSpecEquals
104
105
106syn match   sudoersCmndAliasEquals  contained '=' nextgroup=@sudoersCmndInList  skipwhite skipnl
107syn match   sudoersCmndListComma    contained ',' nextgroup=@sudoersCmndInList  skipwhite skipnl
108syn match   sudoersCmndListColon    contained ':' nextgroup=sudoersCmndAlias    skipwhite skipnl
109syn cluster sudoersCmndList         contains=sudoersCmndListComma,sudoersCmndListColon
110
111syn match   sudoersCmndSpecComma    contained ',' nextgroup=@sudoersCmndSpecList skipwhite skipnl
112syn match   sudoersCmndSpecColon    contained ':' nextgroup=@sudoersUserInSpec  skipwhite skipnl
113syn cluster sudoersCmndSpec         contains=sudoersCmndSpecComma,sudoersCmndSpecColon
114
115syn cluster sudoersUserInList       contains=sudoersUserNegationInList,sudoersUserNameInList,sudoersUIDInList,sudoersGroupInList,sudoersUserNetgroupInList,sudoersUserAliasInList
116syn cluster sudoersHostInList       contains=sudoersHostNegationInList,sudoersHostNameInList,sudoersIPAddrInList,sudoersNetworkInList,sudoersHostNetgroupInList,sudoersHostAliasInList
117syn cluster sudoersCmndInList       contains=sudoersCmndNegationInList,sudoersCmndNameInList,sudoersCmndAliasInList
118
119syn cluster sudoersUser             contains=sudoersUserNegation,sudoersUserName,sudoersUID,sudoersGroup,sudoersUserNetgroup,sudoersUserAliasRef
120syn cluster sudoersHost             contains=sudoersHostNegation,sudoersHostName,sudoersIPAddr,sudoersNetwork,sudoersHostNetgroup,sudoersHostAliasRef
121
122syn cluster sudoersUserInSpec       contains=sudoersUserNegationInSpec,sudoersUserNameInSpec,sudoersUIDInSpec,sudoersGroupInSpec,sudoersUserNetgroupInSpec,sudoersUserAliasInSpec
123syn cluster sudoersHostInSpec       contains=sudoersHostNegationInSpec,sudoersHostNameInSpec,sudoersIPAddrInSpec,sudoersNetworkInSpec,sudoersHostNetgroupInSpec,sudoersHostAliasInSpec
124syn cluster sudoersUserInRunas      contains=sudoersUserNegationInRunas,sudoersUserNameInRunas,sudoersUIDInRunas,sudoersGroupInRunas,sudoersUserNetgroupInRunas,sudoersUserAliasInRunas
125syn cluster sudoersCmndInSpec       contains=sudoersCmndNegationInSpec,sudoersCmndNameInSpec,sudoersCmndAliasInSpec
126
127syn match   sudoersUserNegationInList contained '!\+' nextgroup=@sudoersUserInList  skipwhite skipnl
128syn match   sudoersHostNegationInList contained '!\+' nextgroup=@sudoersHostInList  skipwhite skipnl
129syn match   sudoersCmndNegationInList contained '!\+' nextgroup=@sudoersCmndInList  skipwhite skipnl
130
131syn match   sudoersUserNegation       contained '!\+' nextgroup=@sudoersUser        skipwhite skipnl
132syn match   sudoersHostNegation       contained '!\+' nextgroup=@sudoersHost        skipwhite skipnl
133
134syn match   sudoersUserNegationInSpec contained '!\+' nextgroup=@sudoersUserInSpec  skipwhite skipnl
135syn match   sudoersHostNegationInSpec contained '!\+' nextgroup=@sudoersHostInSpec  skipwhite skipnl
136syn match   sudoersUserNegationInRunas contained '!\+' nextgroup=@sudoersUserInRunas skipwhite skipnl
137syn match   sudoersCmndNegationInSpec contained '!\+' nextgroup=@sudoersCmndInSpec  skipwhite skipnl
138
139syn match   sudoersCommandArgs      contained '[^[:space:],:=\\]\+\%(\\[[:space:],:=\\][^[:space:],:=\\]*\)*' nextgroup=sudoersCommandArgs,@sudoersCmndList skipwhite
140syn match   sudoersCommandEmpty     contained '""' nextgroup=@sudoersCmndList skipwhite skipnl
141
142syn match   sudoersCommandArgsInSpec contained '[^[:space:],:=\\]\+\%(\\[[:space:],:=\\][^[:space:],:=\\]*\)*' nextgroup=sudoersCommandArgsInSpec,@sudoersCmndSpec skipwhite
143syn match   sudoersCommandEmptyInSpec contained '""' nextgroup=@sudoersCmndSpec skipwhite skipnl
144
145syn keyword sudoersDefaultEntry Defaults nextgroup=sudoersDefaultTypeAt,sudoersDefaultTypeColon,sudoersDefaultTypeGreaterThan,@sudoersParameter skipwhite skipnl
146syn match   sudoersDefaultTypeAt          contained '@' nextgroup=@sudoersHost skipwhite skipnl
147syn match   sudoersDefaultTypeColon       contained ':' nextgroup=@sudoersUser skipwhite skipnl
148syn match   sudoersDefaultTypeGreaterThan contained '>' nextgroup=@sudoersUser skipwhite skipnl
149
150" TODO: could also deal with special characters here
151syn match   sudoersBooleanParameter contained '!' nextgroup=sudoersBooleanParameter skipwhite skipnl
152syn keyword sudoersBooleanParameter contained long_opt_prompt ignore_dot mail_always mail_badpass mail_no_user mail_no_perms tty_tickets lecture authenticate root_sudo log_host log_year shell_noargs set_home always_set_home path_info preserve_groups fqdn insults requiretty env_editor rootpw runaspw targetpw set_logname stay_setuid env_reset use_loginclass nextgroup=sudoersParameterListComma skipwhite skipnl
153syn keyword sudoersIntegerParameter contained passwd_tries loglinelen timestamp_timeout passwd_timeout umask nextgroup=sudoersIntegerParameterEquals skipwhite skipnl
154syn keyword sudoersStringParameter  contained mailsub badpass_message timestampdir timestampowner passprompt runas_default syslog_goodpri syslog_badpri editor logfile syslog mailerpath mailerflags mailto exempt_group verifypw listpw nextgroup=sudoersStringParameterEquals skipwhite skipnl
155syn keyword sudoersListParameter    contained env_check env_delete env_keep nextgroup=sudoersListParameterEquals skipwhite skipnl
156
157syn match   sudoersParameterListComma contained ',' nextgroup=@sudoersParameter skipwhite skipnl
158
159syn cluster sudoersParameter        contains=sudoersBooleanParameter,sudoersIntegerParameterEquals,sudoersStringParameter,sudoersListParameter
160
161syn match   sudoersIntegerParameterEquals contained '[+-]\==' nextgroup=sudoersIntegerValue skipwhite skipnl
162syn match   sudoersStringParameterEquals  contained '[+-]\==' nextgroup=sudoersStringValue  skipwhite skipnl
163syn match   sudoersListParameterEquals    contained '[+-]\==' nextgroup=sudoersListValue    skipwhite skipnl
164
165syn match   sudoersIntegerValue contained '\d\+' nextgroup=sudoersParameterListComma skipwhite skipnl
166syn match   sudoersStringValue  contained '[^[:space:],:=\\]*\%(\\[[:space:],:=\\][^[:space:],:=\\]*\)*' nextgroup=sudoersParameterListComma skipwhite skipnl
167syn region  sudoersStringValue  contained start=+"+ skip=+\\"+ end=+"+ nextgroup=sudoersParameterListComma skipwhite skipnl
168syn match   sudoersListValue    contained '[^[:space:],:=\\]*\%(\\[[:space:],:=\\][^[:space:],:=\\]*\)*' nextgroup=sudoersParameterListComma skipwhite skipnl
169syn region  sudoersListValue    contained start=+"+ skip=+\\"+ end=+"+ nextgroup=sudoersParameterListComma skipwhite skipnl
170
171syn match   sudoersPASSWD                   contained '\%(NO\)\=PASSWD:' nextgroup=@sudoersCmndInSpec skipwhite
172
173hi def link sudoersSpecEquals               Operator
174hi def link sudoersTodo                     Todo
175hi def link sudoersComment                  Comment
176hi def link sudoersAlias                    Keyword
177hi def link sudoersUserAlias                Identifier
178hi def link sudoersUserNameInList           String
179hi def link sudoersUIDInList                Number
180hi def link sudoersGroupInList              PreProc
181hi def link sudoersUserNetgroupInList       PreProc
182hi def link sudoersUserAliasInList          PreProc
183hi def link sudoersUserName                 String
184hi def link sudoersUID                      Number
185hi def link sudoersGroup                    PreProc
186hi def link sudoersUserNetgroup             PreProc
187hi def link sudoersUserAliasRef             PreProc
188hi def link sudoersUserNameInSpec           String
189hi def link sudoersUIDInSpec                Number
190hi def link sudoersGroupInSpec              PreProc
191hi def link sudoersUserNetgroupInSpec       PreProc
192hi def link sudoersUserAliasInSpec          PreProc
193hi def link sudoersUserNameInRunas          String
194hi def link sudoersUIDInRunas               Number
195hi def link sudoersGroupInRunas             PreProc
196hi def link sudoersUserNetgroupInRunas      PreProc
197hi def link sudoersUserAliasInRunas         PreProc
198hi def link sudoersHostAlias                Identifier
199hi def link sudoersHostNameInList           String
200hi def link sudoersIPAddrInList             Number
201hi def link sudoersNetworkInList            Number
202hi def link sudoersHostNetgroupInList       PreProc
203hi def link sudoersHostAliasInList          PreProc
204hi def link sudoersHostName                 String
205hi def link sudoersIPAddr                   Number
206hi def link sudoersNetwork                  Number
207hi def link sudoersHostNetgroup             PreProc
208hi def link sudoersHostAliasRef             PreProc
209hi def link sudoersHostNameInSpec           String
210hi def link sudoersIPAddrInSpec             Number
211hi def link sudoersNetworkInSpec            Number
212hi def link sudoersHostNetgroupInSpec       PreProc
213hi def link sudoersHostAliasInSpec          PreProc
214hi def link sudoersCmndAlias                Identifier
215hi def link sudoersCmndNameInList           String
216hi def link sudoersCmndAliasInList          PreProc
217hi def link sudoersCmndNameInSpec           String
218hi def link sudoersCmndAliasInSpec          PreProc
219hi def link sudoersUserAliasEquals          Operator
220hi def link sudoersUserListComma            Delimiter
221hi def link sudoersUserListColon            Delimiter
222hi def link sudoersUserSpecComma            Delimiter
223hi def link sudoersUserRunasBegin           Delimiter
224hi def link sudoersUserRunasComma           Delimiter
225hi def link sudoersUserRunasEnd             Delimiter
226hi def link sudoersHostAliasEquals          Operator
227hi def link sudoersHostListComma            Delimiter
228hi def link sudoersHostListColon            Delimiter
229hi def link sudoersHostSpecComma            Delimiter
230hi def link sudoersCmndAliasEquals          Operator
231hi def link sudoersCmndListComma            Delimiter
232hi def link sudoersCmndListColon            Delimiter
233hi def link sudoersCmndSpecComma            Delimiter
234hi def link sudoersCmndSpecColon            Delimiter
235hi def link sudoersUserNegationInList       Operator
236hi def link sudoersHostNegationInList       Operator
237hi def link sudoersCmndNegationInList       Operator
238hi def link sudoersUserNegation             Operator
239hi def link sudoersHostNegation             Operator
240hi def link sudoersUserNegationInSpec       Operator
241hi def link sudoersHostNegationInSpec       Operator
242hi def link sudoersUserNegationInRunas      Operator
243hi def link sudoersCmndNegationInSpec       Operator
244hi def link sudoersCommandArgs              String
245hi def link sudoersCommandEmpty             Special
246hi def link sudoersDefaultEntry             Keyword
247hi def link sudoersDefaultTypeAt            Special
248hi def link sudoersDefaultTypeColon         Special
249hi def link sudoersDefaultTypeGreaterThan   Special
250hi def link sudoersBooleanParameter         Identifier
251hi def link sudoersIntegerParameter         Identifier
252hi def link sudoersStringParameter          Identifier
253hi def link sudoersListParameter            Identifier
254hi def link sudoersParameterListComma       Delimiter
255hi def link sudoersIntegerParameterEquals   Operator
256hi def link sudoersStringParameterEquals    Operator
257hi def link sudoersListParameterEquals      Operator
258hi def link sudoersIntegerValue             Number
259hi def link sudoersStringValue              String
260hi def link sudoersListValue                String
261hi def link sudoersPASSWD                   Special
262
263let b:current_syntax = "sudoers"
264
265let &cpo = s:cpo_save
266unlet s:cpo_save
267