1" Vim syntax file 2" Language: sudoers(5) configuration files 3" Previous Maintainer: Nikolai Weibull <[email protected]> 4" Latest Revision: 2011-02-24 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 skipwhite skipnl 153 \ always_set_home 154 \ authenticate 155 \ closefrom_override 156 \ env_editor 157 \ env_reset 158 \ fqdn 159 \ ignore_dot 160 \ ignore_local_sudoers 161 \ insults 162 \ log_host 163 \ log_year 164 \ long_otp_prompt 165 \ mail_always 166 \ mail_badpass 167 \ mail_no_host 168 \ mail_no_perms 169 \ mail_no_user 170 \ noexec 171 \ path_info 172 \ passprompt_override 173 \ preserve_groups 174 \ requiretty 175 \ root_sudo 176 \ rootpw 177 \ runaspw 178 \ set_home 179 \ set_logname 180 \ setenv 181 \ shell_noargs 182 \ stay_setuid 183 \ targetpw 184 \ tty_tickets 185 \ visiblepw 186 187syn keyword sudoersIntegerParameter contained 188 \ nextgroup=sudoersIntegerParameterEquals 189 \ skipwhite skipnl 190 \ closefrom 191 \ passwd_tries 192 \ loglinelen 193 \ passwd_timeout 194 \ timestamp_timeout 195 \ umask 196 197syn keyword sudoersStringParameter contained 198 \ nextgroup=sudoersStringParameterEquals 199 \ skipwhite skipnl 200 \ badpass_message 201 \ editor 202 \ mailsub 203 \ noexec_file 204 \ passprompt 205 \ runas_default 206 \ syslog_badpri 207 \ syslog_goodpri 208 \ sudoers_locale 209 \ timestampdir 210 \ timestampowner 211 \ askpass 212 \ env_file 213 \ exempt_group 214 \ lecture 215 \ lecture_file 216 \ listpw 217 \ logfile 218 \ mailerflags 219 \ mailerpath 220 \ mailfrom 221 \ mailto 222 \ secure_path 223 \ syslog 224 \ verifypw 225 226syn keyword sudoersListParameter contained 227 \ nextgroup=sudoersListParameterEquals 228 \ skipwhite skipnl 229 \ env_check 230 \ env_delete 231 \ env_keep 232 233syn match sudoersParameterListComma contained ',' nextgroup=@sudoersParameter skipwhite skipnl 234 235syn cluster sudoersParameter contains=sudoersBooleanParameter,sudoersIntegerParameter,sudoersStringParameter,sudoersListParameter 236 237syn match sudoersIntegerParameterEquals contained '[+-]\==' nextgroup=sudoersIntegerValue skipwhite skipnl 238syn match sudoersStringParameterEquals contained '[+-]\==' nextgroup=sudoersStringValue skipwhite skipnl 239syn match sudoersListParameterEquals contained '[+-]\==' nextgroup=sudoersListValue skipwhite skipnl 240 241syn match sudoersIntegerValue contained '\d\+' nextgroup=sudoersParameterListComma skipwhite skipnl 242syn match sudoersStringValue contained '[^[:space:],:=\\]*\%(\\[[:space:],:=\\][^[:space:],:=\\]*\)*' nextgroup=sudoersParameterListComma skipwhite skipnl 243syn region sudoersStringValue contained start=+"+ skip=+\\"+ end=+"+ nextgroup=sudoersParameterListComma skipwhite skipnl 244syn match sudoersListValue contained '[^[:space:],:=\\]*\%(\\[[:space:],:=\\][^[:space:],:=\\]*\)*' nextgroup=sudoersParameterListComma skipwhite skipnl 245syn region sudoersListValue contained start=+"+ skip=+\\"+ end=+"+ nextgroup=sudoersParameterListComma skipwhite skipnl 246 247syn match sudoersPASSWD contained '\%(NO\)\=PASSWD:' nextgroup=@sudoersCmndInSpec skipwhite 248 249hi def link sudoersSpecEquals Operator 250hi def link sudoersTodo Todo 251hi def link sudoersComment Comment 252hi def link sudoersAlias Keyword 253hi def link sudoersUserAlias Identifier 254hi def link sudoersUserNameInList String 255hi def link sudoersUIDInList Number 256hi def link sudoersGroupInList PreProc 257hi def link sudoersUserNetgroupInList PreProc 258hi def link sudoersUserAliasInList PreProc 259hi def link sudoersUserName String 260hi def link sudoersUID Number 261hi def link sudoersGroup PreProc 262hi def link sudoersUserNetgroup PreProc 263hi def link sudoersUserAliasRef PreProc 264hi def link sudoersUserNameInSpec String 265hi def link sudoersUIDInSpec Number 266hi def link sudoersGroupInSpec PreProc 267hi def link sudoersUserNetgroupInSpec PreProc 268hi def link sudoersUserAliasInSpec PreProc 269hi def link sudoersUserNameInRunas String 270hi def link sudoersUIDInRunas Number 271hi def link sudoersGroupInRunas PreProc 272hi def link sudoersUserNetgroupInRunas PreProc 273hi def link sudoersUserAliasInRunas PreProc 274hi def link sudoersHostAlias Identifier 275hi def link sudoersHostNameInList String 276hi def link sudoersIPAddrInList Number 277hi def link sudoersNetworkInList Number 278hi def link sudoersHostNetgroupInList PreProc 279hi def link sudoersHostAliasInList PreProc 280hi def link sudoersHostName String 281hi def link sudoersIPAddr Number 282hi def link sudoersNetwork Number 283hi def link sudoersHostNetgroup PreProc 284hi def link sudoersHostAliasRef PreProc 285hi def link sudoersHostNameInSpec String 286hi def link sudoersIPAddrInSpec Number 287hi def link sudoersNetworkInSpec Number 288hi def link sudoersHostNetgroupInSpec PreProc 289hi def link sudoersHostAliasInSpec PreProc 290hi def link sudoersCmndAlias Identifier 291hi def link sudoersCmndNameInList String 292hi def link sudoersCmndAliasInList PreProc 293hi def link sudoersCmndNameInSpec String 294hi def link sudoersCmndAliasInSpec PreProc 295hi def link sudoersUserAliasEquals Operator 296hi def link sudoersUserListComma Delimiter 297hi def link sudoersUserListColon Delimiter 298hi def link sudoersUserSpecComma Delimiter 299hi def link sudoersUserRunasBegin Delimiter 300hi def link sudoersUserRunasComma Delimiter 301hi def link sudoersUserRunasEnd Delimiter 302hi def link sudoersHostAliasEquals Operator 303hi def link sudoersHostListComma Delimiter 304hi def link sudoersHostListColon Delimiter 305hi def link sudoersHostSpecComma Delimiter 306hi def link sudoersCmndAliasEquals Operator 307hi def link sudoersCmndListComma Delimiter 308hi def link sudoersCmndListColon Delimiter 309hi def link sudoersCmndSpecComma Delimiter 310hi def link sudoersCmndSpecColon Delimiter 311hi def link sudoersUserNegationInList Operator 312hi def link sudoersHostNegationInList Operator 313hi def link sudoersCmndNegationInList Operator 314hi def link sudoersUserNegation Operator 315hi def link sudoersHostNegation Operator 316hi def link sudoersUserNegationInSpec Operator 317hi def link sudoersHostNegationInSpec Operator 318hi def link sudoersUserNegationInRunas Operator 319hi def link sudoersCmndNegationInSpec Operator 320hi def link sudoersCommandArgs String 321hi def link sudoersCommandEmpty Special 322hi def link sudoersDefaultEntry Keyword 323hi def link sudoersDefaultTypeAt Special 324hi def link sudoersDefaultTypeColon Special 325hi def link sudoersDefaultTypeGreaterThan Special 326hi def link sudoersBooleanParameter Identifier 327hi def link sudoersIntegerParameter Identifier 328hi def link sudoersStringParameter Identifier 329hi def link sudoersListParameter Identifier 330hi def link sudoersParameterListComma Delimiter 331hi def link sudoersIntegerParameterEquals Operator 332hi def link sudoersStringParameterEquals Operator 333hi def link sudoersListParameterEquals Operator 334hi def link sudoersIntegerValue Number 335hi def link sudoersStringValue String 336hi def link sudoersListValue String 337hi def link sudoersPASSWD Special 338 339let b:current_syntax = "sudoers" 340 341let &cpo = s:cpo_save 342unlet s:cpo_save 343