2 " Language: sudoers(5) configuration files
3 " Maintainer: Nikolai Weibull <now@bitwi.se>
4 " Latest Revision: 2006-04-19
6 if exists("b:current_syntax")
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
16 " TODO: treat 'ALL' like a special (yay, a bundle of new rules!!!)
18 syn match sudoersUserSpec '^' nextgroup=@sudoersUserInSpec skipwhite
20 syn match sudoersSpecEquals contained '=' nextgroup=@sudoersCmndSpecList skipwhite
22 syn cluster sudoersCmndSpecList contains=sudoersUserRunasBegin,sudoersPASSWD,@sudoersCmndInSpec
24 syn keyword sudoersTodo contained TODO FIXME XXX NOTE
26 syn region sudoersComment display oneline start='#' end='$' contains=sudoersTodo
28 syn keyword sudoersAlias User_Alias Runas_Alias nextgroup=sudoersUserAlias skipwhite skipnl
29 syn keyword sudoersAlias Host_Alias nextgroup=sudoersHostAlias skipwhite skipnl
30 syn keyword sudoersAlias Cmnd_Alias nextgroup=sudoersCmndAlias skipwhite skipnl
32 syn match sudoersUserAlias contained '\<\u[A-Z0-9_]*\>' nextgroup=sudoersUserAliasEquals skipwhite skipnl
33 syn match sudoersUserNameInList contained '\<\l\+\>' nextgroup=@sudoersUserList skipwhite skipnl
34 syn match sudoersUIDInList contained '#\d\+\>' nextgroup=@sudoersUserList skipwhite skipnl
35 syn match sudoersGroupInList contained '%\l\+\>' nextgroup=@sudoersUserList skipwhite skipnl
36 syn match sudoersUserNetgroupInList contained '+\l\+\>' nextgroup=@sudoersUserList skipwhite skipnl
37 syn match sudoersUserAliasInList contained '\<\u[A-Z0-9_]*\>' nextgroup=@sudoersUserList skipwhite skipnl
39 syn match sudoersUserName contained '\<\l\+\>' nextgroup=@sudoersParameter skipwhite skipnl
40 syn match sudoersUID contained '#\d\+\>' nextgroup=@sudoersParameter skipwhite skipnl
41 syn match sudoersGroup contained '%\l\+\>' nextgroup=@sudoersParameter skipwhite skipnl
42 syn match sudoersUserNetgroup contained '+\l\+\>' nextgroup=@sudoersParameter skipwhite skipnl
43 syn match sudoersUserAliasRef contained '\<\u[A-Z0-9_]*\>' nextgroup=@sudoersParameter skipwhite skipnl
45 syn match sudoersUserNameInSpec contained '\<\l\+\>' nextgroup=@sudoersUserSpec skipwhite skipnl
46 syn match sudoersUIDInSpec contained '#\d\+\>' nextgroup=@sudoersUserSpec skipwhite skipnl
47 syn match sudoersGroupInSpec contained '%\l\+\>' nextgroup=@sudoersUserSpec skipwhite skipnl
48 syn match sudoersUserNetgroupInSpec contained '+\l\+\>' nextgroup=@sudoersUserSpec skipwhite skipnl
49 syn match sudoersUserAliasInSpec contained '\<\u[A-Z0-9_]*\>' nextgroup=@sudoersUserSpec skipwhite skipnl
51 syn match sudoersUserNameInRunas contained '\<\l\+\>' nextgroup=@sudoersUserRunas skipwhite skipnl
52 syn match sudoersUIDInRunas contained '#\d\+\>' nextgroup=@sudoersUserRunas skipwhite skipnl
53 syn match sudoersGroupInRunas contained '%\l\+\>' nextgroup=@sudoersUserRunas skipwhite skipnl
54 syn match sudoersUserNetgroupInRunas contained '+\l\+\>' nextgroup=@sudoersUserRunas skipwhite skipnl
55 syn match sudoersUserAliasInRunas contained '\<\u[A-Z0-9_]*\>' nextgroup=@sudoersUserRunas skipwhite skipnl
57 syn match sudoersHostAlias contained '\<\u[A-Z0-9_]*\>' nextgroup=sudoersHostAliasEquals skipwhite skipnl
58 syn match sudoersHostNameInList contained '\<\l\+\>' nextgroup=@sudoersHostList skipwhite skipnl
59 syn match sudoersIPAddrInList contained '\%(\d\{1,3}\.\)\{3}\d\{1,3}' nextgroup=@sudoersHostList skipwhite skipnl
60 syn match sudoersNetworkInList contained '\%(\d\{1,3}\.\)\{3}\d\{1,3}\%(/\%(\%(\d\{1,3}\.\)\{3}\d\{1,3}\|\d\+\)\)\=' nextgroup=@sudoersHostList skipwhite skipnl
61 syn match sudoersHostNetgroupInList contained '+\l\+\>' nextgroup=@sudoersHostList skipwhite skipnl
62 syn match sudoersHostAliasInList contained '\<\u[A-Z0-9_]*\>' nextgroup=@sudoersHostList skipwhite skipnl
64 syn match sudoersHostName contained '\<\l\+\>' nextgroup=@sudoersParameter skipwhite skipnl
65 syn match sudoersIPAddr contained '\%(\d\{1,3}\.\)\{3}\d\{1,3}' nextgroup=@sudoersParameter skipwhite skipnl
66 syn match sudoersNetwork contained '\%(\d\{1,3}\.\)\{3}\d\{1,3}\%(/\%(\%(\d\{1,3}\.\)\{3}\d\{1,3}\|\d\+\)\)\=' nextgroup=@sudoersParameter skipwhite skipnl
67 syn match sudoersHostNetgroup contained '+\l\+\>' nextgroup=@sudoersParameter skipwhite skipnl
68 syn match sudoersHostAliasRef contained '\<\u[A-Z0-9_]*\>' nextgroup=@sudoersParameter skipwhite skipnl
70 syn match sudoersHostNameInSpec contained '\<\l\+\>' nextgroup=@sudoersHostSpec skipwhite skipnl
71 syn match sudoersIPAddrInSpec contained '\%(\d\{1,3}\.\)\{3}\d\{1,3}' nextgroup=@sudoersHostSpec skipwhite skipnl
72 syn match sudoersNetworkInSpec contained '\%(\d\{1,3}\.\)\{3}\d\{1,3}\%(/\%(\%(\d\{1,3}\.\)\{3}\d\{1,3}\|\d\+\)\)\=' nextgroup=@sudoersHostSpec skipwhite skipnl
73 syn match sudoersHostNetgroupInSpec contained '+\l\+\>' nextgroup=@sudoersHostSpec skipwhite skipnl
74 syn match sudoersHostAliasInSpec contained '\<\u[A-Z0-9_]*\>' nextgroup=@sudoersHostSpec skipwhite skipnl
76 syn match sudoersCmndAlias contained '\<\u[A-Z0-9_]*\>' nextgroup=sudoersCmndAliasEquals skipwhite skipnl
77 syn match sudoersCmndNameInList contained '[^[:space:],:=\\]\+\%(\\[[:space:],:=\\][^[:space:],:=\\]*\)*' nextgroup=@sudoersCmndList,sudoersCommandEmpty,sudoersCommandArgs skipwhite
78 syn match sudoersCmndAliasInList contained '\<\u[A-Z0-9_]*\>' nextgroup=@sudoersCmndList skipwhite skipnl
80 syn match sudoersCmndNameInSpec contained '[^[:space:],:=\\]\+\%(\\[[:space:],:=\\][^[:space:],:=\\]*\)*' nextgroup=@sudoersCmndSpec,sudoersCommandEmptyInSpec,sudoersCommandArgsInSpec skipwhite
81 syn match sudoersCmndAliasInSpec contained '\<\u[A-Z0-9_]*\>' nextgroup=@sudoersCmndSpec skipwhite skipnl
83 syn match sudoersUserAliasEquals contained '=' nextgroup=@sudoersUserInList skipwhite skipnl
84 syn match sudoersUserListComma contained ',' nextgroup=@sudoersUserInList skipwhite skipnl
85 syn match sudoersUserListColon contained ':' nextgroup=sudoersUserAlias skipwhite skipnl
86 syn cluster sudoersUserList contains=sudoersUserListComma,sudoersUserListColon
88 syn match sudoersUserSpecComma contained ',' nextgroup=@sudoersUserInSpec skipwhite skipnl
89 syn cluster sudoersUserSpec contains=sudoersUserSpecComma,@sudoersHostInSpec
91 syn match sudoersUserRunasBegin contained '(' nextgroup=@sudoersUserInRunas skipwhite skipnl
92 syn match sudoersUserRunasComma contained ',' nextgroup=@sudoersUserInRunas skipwhite skipnl
93 syn match sudoersUserRunasEnd contained ')' nextgroup=sudoersPASSWD,@sudoersCmndInSpec skipwhite skipnl
94 syn cluster sudoersUserRunas contains=sudoersUserRunasComma,@sudoersUserInRunas,sudoersUserRunasEnd
97 syn match sudoersHostAliasEquals contained '=' nextgroup=@sudoersHostInList skipwhite skipnl
98 syn match sudoersHostListComma contained ',' nextgroup=@sudoersHostInList skipwhite skipnl
99 syn match sudoersHostListColon contained ':' nextgroup=sudoersHostAlias skipwhite skipnl
100 syn cluster sudoersHostList contains=sudoersHostListComma,sudoersHostListColon
102 syn match sudoersHostSpecComma contained ',' nextgroup=@sudoersHostInSpec skipwhite skipnl
103 syn cluster sudoersHostSpec contains=sudoersHostSpecComma,sudoersSpecEquals
106 syn match sudoersCmndAliasEquals contained '=' nextgroup=@sudoersCmndInList skipwhite skipnl
107 syn match sudoersCmndListComma contained ',' nextgroup=@sudoersCmndInList skipwhite skipnl
108 syn match sudoersCmndListColon contained ':' nextgroup=sudoersCmndAlias skipwhite skipnl
109 syn cluster sudoersCmndList contains=sudoersCmndListComma,sudoersCmndListColon
111 syn match sudoersCmndSpecComma contained ',' nextgroup=@sudoersCmndSpecList skipwhite skipnl
112 syn match sudoersCmndSpecColon contained ':' nextgroup=@sudoersUserInSpec skipwhite skipnl
113 syn cluster sudoersCmndSpec contains=sudoersCmndSpecComma,sudoersCmndSpecColon
115 syn cluster sudoersUserInList contains=sudoersUserNegationInList,sudoersUserNameInList,sudoersUIDInList,sudoersGroupInList,sudoersUserNetgroupInList,sudoersUserAliasInList
116 syn cluster sudoersHostInList contains=sudoersHostNegationInList,sudoersHostNameInList,sudoersIPAddrInList,sudoersNetworkInList,sudoersHostNetgroupInList,sudoersHostAliasInList
117 syn cluster sudoersCmndInList contains=sudoersCmndNegationInList,sudoersCmndNameInList,sudoersCmndAliasInList
119 syn cluster sudoersUser contains=sudoersUserNegation,sudoersUserName,sudoersUID,sudoersGroup,sudoersUserNetgroup,sudoersUserAliasRef
120 syn cluster sudoersHost contains=sudoersHostNegation,sudoersHostName,sudoersIPAddr,sudoersNetwork,sudoersHostNetgroup,sudoersHostAliasRef
122 syn cluster sudoersUserInSpec contains=sudoersUserNegationInSpec,sudoersUserNameInSpec,sudoersUIDInSpec,sudoersGroupInSpec,sudoersUserNetgroupInSpec,sudoersUserAliasInSpec
123 syn cluster sudoersHostInSpec contains=sudoersHostNegationInSpec,sudoersHostNameInSpec,sudoersIPAddrInSpec,sudoersNetworkInSpec,sudoersHostNetgroupInSpec,sudoersHostAliasInSpec
124 syn cluster sudoersUserInRunas contains=sudoersUserNegationInRunas,sudoersUserNameInRunas,sudoersUIDInRunas,sudoersGroupInRunas,sudoersUserNetgroupInRunas,sudoersUserAliasInRunas
125 syn cluster sudoersCmndInSpec contains=sudoersCmndNegationInSpec,sudoersCmndNameInSpec,sudoersCmndAliasInSpec
127 syn match sudoersUserNegationInList contained '!\+' nextgroup=@sudoersUserInList skipwhite skipnl
128 syn match sudoersHostNegationInList contained '!\+' nextgroup=@sudoersHostInList skipwhite skipnl
129 syn match sudoersCmndNegationInList contained '!\+' nextgroup=@sudoersCmndInList skipwhite skipnl
131 syn match sudoersUserNegation contained '!\+' nextgroup=@sudoersUser skipwhite skipnl
132 syn match sudoersHostNegation contained '!\+' nextgroup=@sudoersHost skipwhite skipnl
134 syn match sudoersUserNegationInSpec contained '!\+' nextgroup=@sudoersUserInSpec skipwhite skipnl
135 syn match sudoersHostNegationInSpec contained '!\+' nextgroup=@sudoersHostInSpec skipwhite skipnl
136 syn match sudoersUserNegationInRunas contained '!\+' nextgroup=@sudoersUserInRunas skipwhite skipnl
137 syn match sudoersCmndNegationInSpec contained '!\+' nextgroup=@sudoersCmndInSpec skipwhite skipnl
139 syn match sudoersCommandArgs contained '[^[:space:],:=\\]\+\%(\\[[:space:],:=\\][^[:space:],:=\\]*\)*' nextgroup=sudoersCommandArgs,@sudoersCmndList skipwhite
140 syn match sudoersCommandEmpty contained '""' nextgroup=@sudoersCmndList skipwhite skipnl
142 syn match sudoersCommandArgsInSpec contained '[^[:space:],:=\\]\+\%(\\[[:space:],:=\\][^[:space:],:=\\]*\)*' nextgroup=sudoersCommandArgsInSpec,@sudoersCmndSpec skipwhite
143 syn match sudoersCommandEmptyInSpec contained '""' nextgroup=@sudoersCmndSpec skipwhite skipnl
145 syn keyword sudoersDefaultEntry Defaults nextgroup=sudoersDefaultTypeAt,sudoersDefaultTypeColon,sudoersDefaultTypeGreaterThan,@sudoersParameter skipwhite skipnl
146 syn match sudoersDefaultTypeAt contained '@' nextgroup=@sudoersHost skipwhite skipnl
147 syn match sudoersDefaultTypeColon contained ':' nextgroup=@sudoersUser skipwhite skipnl
148 syn match sudoersDefaultTypeGreaterThan contained '>' nextgroup=@sudoersUser skipwhite skipnl
150 " TODO: could also deal with special characters here
151 syn match sudoersBooleanParameter contained '!' nextgroup=sudoersBooleanParameter skipwhite skipnl
152 syn 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
153 syn keyword sudoersIntegerParameter contained passwd_tries loglinelen timestamp_timeout passwd_timeout umask nextgroup=sudoersIntegerParameterEquals skipwhite skipnl
154 syn 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
155 syn keyword sudoersListParameter contained env_check env_delete env_keep nextgroup=sudoersListParameterEquals skipwhite skipnl
157 syn match sudoersParameterListComma contained ',' nextgroup=@sudoersParameter skipwhite skipnl
159 syn cluster sudoersParameter contains=sudoersBooleanParameter,sudoersIntegerParameterEquals,sudoersStringParameter,sudoersListParameter
161 syn match sudoersIntegerParameterEquals contained '[+-]\==' nextgroup=sudoersIntegerValue skipwhite skipnl
162 syn match sudoersStringParameterEquals contained '[+-]\==' nextgroup=sudoersStringValue skipwhite skipnl
163 syn match sudoersListParameterEquals contained '[+-]\==' nextgroup=sudoersListValue skipwhite skipnl
165 syn match sudoersIntegerValue contained '\d\+' nextgroup=sudoersParameterListComma skipwhite skipnl
166 syn match sudoersStringValue contained '[^[:space:],:=\\]*\%(\\[[:space:],:=\\][^[:space:],:=\\]*\)*' nextgroup=sudoersParameterListComma skipwhite skipnl
167 syn region sudoersStringValue contained start=+"+ skip=+\\"+ end=+"+ nextgroup=sudoersParameterListComma skipwhite skipnl
168 syn match sudoersListValue contained '[^[:space:],:=\\]*\%(\\[[:space:],:=\\][^[:space:],:=\\]*\)*' nextgroup=sudoersParameterListComma skipwhite skipnl
169 syn region sudoersListValue contained start=+"+ skip=+\\"+ end=+"+ nextgroup=sudoersParameterListComma skipwhite skipnl
171 syn match sudoersPASSWD contained '\%(NO\)\=PASSWD:' nextgroup=@sudoersCmndInSpec skipwhite
173 hi def link sudoersSpecEquals Operator
174 hi def link sudoersTodo Todo
175 hi def link sudoersComment Comment
176 hi def link sudoersAlias Keyword
177 hi def link sudoersUserAlias Identifier
178 hi def link sudoersUserNameInList String
179 hi def link sudoersUIDInList Number
180 hi def link sudoersGroupInList PreProc
181 hi def link sudoersUserNetgroupInList PreProc
182 hi def link sudoersUserAliasInList PreProc
183 hi def link sudoersUserName String
184 hi def link sudoersUID Number
185 hi def link sudoersGroup PreProc
186 hi def link sudoersUserNetgroup PreProc
187 hi def link sudoersUserAliasRef PreProc
188 hi def link sudoersUserNameInSpec String
189 hi def link sudoersUIDInSpec Number
190 hi def link sudoersGroupInSpec PreProc
191 hi def link sudoersUserNetgroupInSpec PreProc
192 hi def link sudoersUserAliasInSpec PreProc
193 hi def link sudoersUserNameInRunas String
194 hi def link sudoersUIDInRunas Number
195 hi def link sudoersGroupInRunas PreProc
196 hi def link sudoersUserNetgroupInRunas PreProc
197 hi def link sudoersUserAliasInRunas PreProc
198 hi def link sudoersHostAlias Identifier
199 hi def link sudoersHostNameInList String
200 hi def link sudoersIPAddrInList Number
201 hi def link sudoersNetworkInList Number
202 hi def link sudoersHostNetgroupInList PreProc
203 hi def link sudoersHostAliasInList PreProc
204 hi def link sudoersHostName String
205 hi def link sudoersIPAddr Number
206 hi def link sudoersNetwork Number
207 hi def link sudoersHostNetgroup PreProc
208 hi def link sudoersHostAliasRef PreProc
209 hi def link sudoersHostNameInSpec String
210 hi def link sudoersIPAddrInSpec Number
211 hi def link sudoersNetworkInSpec Number
212 hi def link sudoersHostNetgroupInSpec PreProc
213 hi def link sudoersHostAliasInSpec PreProc
214 hi def link sudoersCmndAlias Identifier
215 hi def link sudoersCmndNameInList String
216 hi def link sudoersCmndAliasInList PreProc
217 hi def link sudoersCmndNameInSpec String
218 hi def link sudoersCmndAliasInSpec PreProc
219 hi def link sudoersUserAliasEquals Operator
220 hi def link sudoersUserListComma Delimiter
221 hi def link sudoersUserListColon Delimiter
222 hi def link sudoersUserSpecComma Delimiter
223 hi def link sudoersUserRunasBegin Delimiter
224 hi def link sudoersUserRunasComma Delimiter
225 hi def link sudoersUserRunasEnd Delimiter
226 hi def link sudoersHostAliasEquals Operator
227 hi def link sudoersHostListComma Delimiter
228 hi def link sudoersHostListColon Delimiter
229 hi def link sudoersHostSpecComma Delimiter
230 hi def link sudoersCmndAliasEquals Operator
231 hi def link sudoersCmndListComma Delimiter
232 hi def link sudoersCmndListColon Delimiter
233 hi def link sudoersCmndSpecComma Delimiter
234 hi def link sudoersCmndSpecColon Delimiter
235 hi def link sudoersUserNegationInList Operator
236 hi def link sudoersHostNegationInList Operator
237 hi def link sudoersCmndNegationInList Operator
238 hi def link sudoersUserNegation Operator
239 hi def link sudoersHostNegation Operator
240 hi def link sudoersUserNegationInSpec Operator
241 hi def link sudoersHostNegationInSpec Operator
242 hi def link sudoersUserNegationInRunas Operator
243 hi def link sudoersCmndNegationInSpec Operator
244 hi def link sudoersCommandArgs String
245 hi def link sudoersCommandEmpty Special
246 hi def link sudoersDefaultEntry Keyword
247 hi def link sudoersDefaultTypeAt Special
248 hi def link sudoersDefaultTypeColon Special
249 hi def link sudoersDefaultTypeGreaterThan Special
250 hi def link sudoersBooleanParameter Identifier
251 hi def link sudoersIntegerParameter Identifier
252 hi def link sudoersStringParameter Identifier
253 hi def link sudoersListParameter Identifier
254 hi def link sudoersParameterListComma Delimiter
255 hi def link sudoersIntegerParameterEquals Operator
256 hi def link sudoersStringParameterEquals Operator
257 hi def link sudoersListParameterEquals Operator
258 hi def link sudoersIntegerValue Number
259 hi def link sudoersStringValue String
260 hi def link sudoersListValue String
261 hi def link sudoersPASSWD Special
263 let b:current_syntax = "sudoers"
265 let &cpo = s:cpo_save