1" Vim syntax file 2" Language: sudoers(5) configuration files. 3" Maintainer: Nikolai Weibull <[email protected]> 4" URL: http://www.pcppopper.org/ 5" Latest Revision: 2004-12-17 6" arch-tag: 02fc3bc8-4308-466f-b83e-718a7487b198 7 8if version < 600 9 syntax clear 10elseif exists("b:current_syntax") 11 finish 12endif 13 14" TODO: instead of 'skipnl', we would like to match a specific group that would 15" match \\$ and then continue with the nextgroup, actually, the skipnl doesn't 16" work... 17" TODO: treat 'ALL' like a special (yay, a bundle of new rules!!!) 18 19" User Specs 20syn match sudoersUserSpec '^' nextgroup=@sudoersUserInSpec skipwhite 21 22syn match sudoersSpecEquals contained '=' nextgroup=@sudoersCmndSpecList skipwhite 23 24syn cluster sudoersCmndSpecList contains=sudoersUserRunasBegin,sudoersPASSWD,@sudoersCmndInSpec 25 26" Todo 27syn keyword sudoersTodo contained TODO FIXME XXX NOTE 28 29" Comments 30syn region sudoersComment matchgroup=sudoersComment start='#' end='$' contains=sudoersTodo 31 32" Aliases 33syn keyword sudoersAlias User_Alias Runas_Alias nextgroup=sudoersUserAlias skipwhite skipnl 34syn keyword sudoersAlias Host_Alias nextgroup=sudoersHostAlias skipwhite skipnl 35syn keyword sudoersAlias Cmnd_Alias nextgroup=sudoersCmndAlias skipwhite skipnl 36 37" Names 38syn match sudoersUserAlias contained '\<\u[A-Z0-9_]*\>' nextgroup=sudoersUserAliasEquals skipwhite skipnl 39syn match sudoersUserNameInList contained '\<\l\+\>' nextgroup=@sudoersUserList skipwhite skipnl 40syn match sudoersUIDInList contained '#\d\+\>' nextgroup=@sudoersUserList skipwhite skipnl 41syn match sudoersGroupInList contained '%\l\+\>' nextgroup=@sudoersUserList skipwhite skipnl 42syn match sudoersUserNetgroupInList contained '+\l\+\>' nextgroup=@sudoersUserList skipwhite skipnl 43syn match sudoersUserAliasInList contained '\<\u[A-Z0-9_]*\>' nextgroup=@sudoersUserList skipwhite skipnl 44 45syn match sudoersUserName contained '\<\l\+\>' nextgroup=@sudoersParameter skipwhite skipnl 46syn match sudoersUID contained '#\d\+\>' nextgroup=@sudoersParameter skipwhite skipnl 47syn match sudoersGroup contained '%\l\+\>' nextgroup=@sudoersParameter skipwhite skipnl 48syn match sudoersUserNetgroup contained '+\l\+\>' nextgroup=@sudoersParameter skipwhite skipnl 49syn match sudoersUserAliasRef contained '\<\u[A-Z0-9_]*\>' nextgroup=@sudoersParameter skipwhite skipnl 50 51syn match sudoersUserNameInSpec contained '\<\l\+\>' nextgroup=@sudoersUserSpec skipwhite skipnl 52syn match sudoersUIDInSpec contained '#\d\+\>' nextgroup=@sudoersUserSpec skipwhite skipnl 53syn match sudoersGroupInSpec contained '%\l\+\>' nextgroup=@sudoersUserSpec skipwhite skipnl 54syn match sudoersUserNetgroupInSpec contained '+\l\+\>' nextgroup=@sudoersUserSpec skipwhite skipnl 55syn match sudoersUserAliasInSpec contained '\<\u[A-Z0-9_]*\>' nextgroup=@sudoersUserSpec skipwhite skipnl 56 57syn match sudoersUserNameInRunas contained '\<\l\+\>' nextgroup=@sudoersUserRunas skipwhite skipnl 58syn match sudoersUIDInRunas contained '#\d\+\>' nextgroup=@sudoersUserRunas skipwhite skipnl 59syn match sudoersGroupInRunas contained '%\l\+\>' nextgroup=@sudoersUserRunas skipwhite skipnl 60syn match sudoersUserNetgroupInRunas contained '+\l\+\>' nextgroup=@sudoersUserRunas skipwhite skipnl 61syn match sudoersUserAliasInRunas contained '\<\u[A-Z0-9_]*\>' nextgroup=@sudoersUserRunas skipwhite skipnl 62 63syn match sudoersHostAlias contained '\<\u[A-Z0-9_]*\>' nextgroup=sudoersHostAliasEquals skipwhite skipnl 64syn match sudoersHostNameInList contained '\<\l\+\>' nextgroup=@sudoersHostList skipwhite skipnl 65syn match sudoersIPAddrInList contained '\%(\d\{1,3}\.\)\{3}\d\{1,3}' nextgroup=@sudoersHostList skipwhite skipnl 66syn match sudoersNetworkInList contained '\%(\d\{1,3}\.\)\{3}\d\{1,3}\%(/\%(\%(\d\{1,3}\.\)\{3}\d\{1,3}\|\d\+\)\)\=' nextgroup=@sudoersHostList skipwhite skipnl 67syn match sudoersHostNetgroupInList contained '+\l\+\>' nextgroup=@sudoersHostList skipwhite skipnl 68syn match sudoersHostAliasInList contained '\<\u[A-Z0-9_]*\>' nextgroup=@sudoersHostList skipwhite skipnl 69 70syn match sudoersHostName contained '\<\l\+\>' nextgroup=@sudoersParameter skipwhite skipnl 71syn match sudoersIPAddr contained '\%(\d\{1,3}\.\)\{3}\d\{1,3}' nextgroup=@sudoersParameter skipwhite skipnl 72syn match sudoersNetwork contained '\%(\d\{1,3}\.\)\{3}\d\{1,3}\%(/\%(\%(\d\{1,3}\.\)\{3}\d\{1,3}\|\d\+\)\)\=' nextgroup=@sudoersParameter skipwhite skipnl 73syn match sudoersHostNetgroup contained '+\l\+\>' nextgroup=@sudoersParameter skipwhite skipnl 74syn match sudoersHostAliasRef contained '\<\u[A-Z0-9_]*\>' nextgroup=@sudoersParameter skipwhite skipnl 75 76syn match sudoersHostNameInSpec contained '\<\l\+\>' nextgroup=@sudoersHostSpec skipwhite skipnl 77syn match sudoersIPAddrInSpec contained '\%(\d\{1,3}\.\)\{3}\d\{1,3}' nextgroup=@sudoersHostSpec skipwhite skipnl 78syn match sudoersNetworkInSpec contained '\%(\d\{1,3}\.\)\{3}\d\{1,3}\%(/\%(\%(\d\{1,3}\.\)\{3}\d\{1,3}\|\d\+\)\)\=' nextgroup=@sudoersHostSpec skipwhite skipnl 79syn match sudoersHostNetgroupInSpec contained '+\l\+\>' nextgroup=@sudoersHostSpec skipwhite skipnl 80syn match sudoersHostAliasInSpec contained '\<\u[A-Z0-9_]*\>' nextgroup=@sudoersHostSpec skipwhite skipnl 81 82syn match sudoersCmndAlias contained '\<\u[A-Z0-9_]*\>' nextgroup=sudoersCmndAliasEquals skipwhite skipnl 83syn match sudoersCmndNameInList contained '[^[:space:],:=\\]\+\%(\\[[:space:],:=\\][^[:space:],:=\\]*\)*' nextgroup=@sudoersCmndList,sudoersCommandEmpty,sudoersCommandArgs skipwhite 84syn match sudoersCmndAliasInList contained '\<\u[A-Z0-9_]*\>' nextgroup=@sudoersCmndList skipwhite skipnl 85 86syn match sudoersCmndNameInSpec contained '[^[:space:],:=\\]\+\%(\\[[:space:],:=\\][^[:space:],:=\\]*\)*' nextgroup=@sudoersCmndSpec,sudoersCommandEmptyInSpec,sudoersCommandArgsInSpec skipwhite 87syn match sudoersCmndAliasInSpec contained '\<\u[A-Z0-9_]*\>' nextgroup=@sudoersCmndSpec skipwhite skipnl 88 89" Delimiters 90syn match sudoersUserAliasEquals contained '=' nextgroup=@sudoersUserInList skipwhite skipnl 91syn match sudoersUserListComma contained ',' nextgroup=@sudoersUserInList skipwhite skipnl 92syn match sudoersUserListColon contained ':' nextgroup=sudoersUserAlias skipwhite skipnl 93syn cluster sudoersUserList contains=sudoersUserListComma,sudoersUserListColon 94 95syn match sudoersUserSpecComma contained ',' nextgroup=@sudoersUserInSpec skipwhite skipnl 96syn cluster sudoersUserSpec contains=sudoersUserSpecComma,@sudoersHostInSpec 97 98syn match sudoersUserRunasBegin contained '(' nextgroup=@sudoersUserInRunas skipwhite skipnl 99syn match sudoersUserRunasComma contained ',' nextgroup=@sudoersUserInRunas skipwhite skipnl 100syn match sudoersUserRunasEnd contained ')' nextgroup=sudoersPASSWD,@sudoersCmndInSpec skipwhite skipnl 101syn cluster sudoersUserRunas contains=sudoersUserRunasComma,@sudoersUserInRunas,sudoersUserRunasEnd 102 103 104syn match sudoersHostAliasEquals contained '=' nextgroup=@sudoersHostInList skipwhite skipnl 105syn match sudoersHostListComma contained ',' nextgroup=@sudoersHostInList skipwhite skipnl 106syn match sudoersHostListColon contained ':' nextgroup=sudoersHostAlias skipwhite skipnl 107syn cluster sudoersHostList contains=sudoersHostListComma,sudoersHostListColon 108 109syn match sudoersHostSpecComma contained ',' nextgroup=@sudoersHostInSpec skipwhite skipnl 110syn cluster sudoersHostSpec contains=sudoersHostSpecComma,sudoersSpecEquals 111 112 113syn match sudoersCmndAliasEquals contained '=' nextgroup=@sudoersCmndInList skipwhite skipnl 114syn match sudoersCmndListComma contained ',' nextgroup=@sudoersCmndInList skipwhite skipnl 115syn match sudoersCmndListColon contained ':' nextgroup=sudoersCmndAlias skipwhite skipnl 116syn cluster sudoersCmndList contains=sudoersCmndListComma,sudoersCmndListColon 117 118syn match sudoersCmndSpecComma contained ',' nextgroup=@sudoersCmndSpecList skipwhite skipnl 119syn match sudoersCmndSpecColon contained ':' nextgroup=@sudoersUserInSpec skipwhite skipnl 120syn cluster sudoersCmndSpec contains=sudoersCmndSpecComma,sudoersCmndSpecColon 121 122" Lists 123syn cluster sudoersUserInList contains=sudoersUserNegationInList,sudoersUserNameInList,sudoersUIDInList,sudoersGroupInList,sudoersUserNetgroupInList,sudoersUserAliasInList 124syn cluster sudoersHostInList contains=sudoersHostNegationInList,sudoersHostNameInList,sudoersIPAddrInList,sudoersNetworkInList,sudoersHostNetgroupInList,sudoersHostAliasInList 125syn cluster sudoersCmndInList contains=sudoersCmndNegationInList,sudoersCmndNameInList,sudoersCmndAliasInList 126 127syn cluster sudoersUser contains=sudoersUserNegation,sudoersUserName,sudoersUID,sudoersGroup,sudoersUserNetgroup,sudoersUserAliasRef 128syn cluster sudoersHost contains=sudoersHostNegation,sudoersHostName,sudoersIPAddr,sudoersNetwork,sudoersHostNetgroup,sudoersHostAliasRef 129 130syn cluster sudoersUserInSpec contains=sudoersUserNegationInSpec,sudoersUserNameInSpec,sudoersUIDInSpec,sudoersGroupInSpec,sudoersUserNetgroupInSpec,sudoersUserAliasInSpec 131syn cluster sudoersHostInSpec contains=sudoersHostNegationInSpec,sudoersHostNameInSpec,sudoersIPAddrInSpec,sudoersNetworkInSpec,sudoersHostNetgroupInSpec,sudoersHostAliasInSpec 132syn cluster sudoersUserInRunas contains=sudoersUserNegationInRunas,sudoersUserNameInRunas,sudoersUIDInRunas,sudoersGroupInRunas,sudoersUserNetgroupInRunas,sudoersUserAliasInRunas 133syn cluster sudoersCmndInSpec contains=sudoersCmndNegationInSpec,sudoersCmndNameInSpec,sudoersCmndAliasInSpec 134 135" Operators 136syn match sudoersUserNegationInList contained '!\+' nextgroup=@sudoersUserInList skipwhite skipnl 137syn match sudoersHostNegationInList contained '!\+' nextgroup=@sudoersHostInList skipwhite skipnl 138syn match sudoersCmndNegationInList contained '!\+' nextgroup=@sudoersCmndInList skipwhite skipnl 139 140syn match sudoersUserNegation contained '!\+' nextgroup=@sudoersUser skipwhite skipnl 141syn match sudoersHostNegation contained '!\+' nextgroup=@sudoersHost skipwhite skipnl 142 143syn match sudoersUserNegationInSpec contained '!\+' nextgroup=@sudoersUserInSpec skipwhite skipnl 144syn match sudoersHostNegationInSpec contained '!\+' nextgroup=@sudoersHostInSpec skipwhite skipnl 145syn match sudoersUserNegationInRunas contained '!\+' nextgroup=@sudoersUserInRunas skipwhite skipnl 146syn match sudoersCmndNegationInSpec contained '!\+' nextgroup=@sudoersCmndInSpec skipwhite skipnl 147 148" Arguments 149syn match sudoersCommandArgs contained '[^[:space:],:=\\]\+\%(\\[[:space:],:=\\][^[:space:],:=\\]*\)*' nextgroup=sudoersCommandArgs,@sudoersCmndList skipwhite 150syn match sudoersCommandEmpty contained '""' nextgroup=@sudoersCmndList skipwhite skipnl 151 152syn match sudoersCommandArgsInSpec contained '[^[:space:],:=\\]\+\%(\\[[:space:],:=\\][^[:space:],:=\\]*\)*' nextgroup=sudoersCommandArgsInSpec,@sudoersCmndSpec skipwhite 153syn match sudoersCommandEmptyInSpec contained '""' nextgroup=@sudoersCmndSpec skipwhite skipnl 154 155" Default Entries 156syn keyword sudoersDefaultEntry Defaults nextgroup=sudoersDefaultTypeAt,sudoersDefaultTypeColon,sudoersDefaultTypeGreaterThan,@sudoersParameter skipwhite skipnl 157syn match sudoersDefaultTypeAt contained '@' nextgroup=@sudoersHost skipwhite skipnl 158syn match sudoersDefaultTypeColon contained ':' nextgroup=@sudoersUser skipwhite skipnl 159syn match sudoersDefaultTypeGreaterThan contained '>' nextgroup=@sudoersUser skipwhite skipnl 160 161" TODO: could also deal with special characters here 162syn 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 163syn keyword sudoersIntegerParameter contained passwd_tries loglinelen timestamp_timeout passwd_timeout umask nextgroup=sudoersIntegerParameterEquals skipwhite skipnl 164syn 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 165syn keyword sudoersListParameter contained env_check env_delete env_keep nextgroup=sudoersListParameterEquals skipwhite skipnl 166 167syn match sudoersParameterListComma contained ',' nextgroup=@sudoersParameter skipwhite skipnl 168 169syn cluster sudoersParameter contains=sudoersBooleanParameter,sudoersIntegerParameterEquals,sudoersStringParameter,sudoersListParameter 170 171syn match sudoersIntegerParameterEquals contained '[+-]\==' nextgroup=sudoersIntegerValue skipwhite skipnl 172syn match sudoersStringParameterEquals contained '[+-]\==' nextgroup=sudoersStringValue skipwhite skipnl 173syn match sudoersListParameterEquals contained '[+-]\==' nextgroup=sudoersListValue skipwhite skipnl 174 175syn match sudoersIntegerValue contained '\d\+' nextgroup=sudoersParameterListComma skipwhite skipnl 176syn match sudoersStringValue contained '[^[:space:],:=\\]*\%(\\[[:space:],:=\\][^[:space:],:=\\]*\)*' nextgroup=sudoersParameterListComma skipwhite skipnl 177syn region sudoersStringValue contained start=+"+ skip=+\\"+ end=+"+ nextgroup=sudoersParameterListComma skipwhite skipnl 178syn match sudoersListValue contained '[^[:space:],:=\\]*\%(\\[[:space:],:=\\][^[:space:],:=\\]*\)*' nextgroup=sudoersParameterListComma skipwhite skipnl 179syn region sudoersListValue contained start=+"+ skip=+\\"+ end=+"+ nextgroup=sudoersParameterListComma skipwhite skipnl 180 181" Special for specs 182syn match sudoersPASSWD contained '\%(NO\)\=PASSWD:' nextgroup=@sudoersCmndInSpec skipwhite 183 184" Define the default highlighting. 185" For version 5.7 and earlier: only when not done already 186" For version 5.8 and later: only when an item doesn't have highlighting yet 187if version >= 508 || !exists("did_sudoers_syn_inits") 188 if version < 508 189 let did_sudoers_syn_inits = 1 190 command -nargs=+ HiLink hi link <args> 191 else 192 command -nargs=+ HiLink hi def link <args> 193 endif 194 195 HiLink sudoersSpecEquals Operator 196 HiLink sudoersTodo Todo 197 HiLink sudoersComment Comment 198 HiLink sudoersAlias Keyword 199 HiLink sudoersUserAlias Identifier 200 HiLink sudoersUserNameInList String 201 HiLink sudoersUIDInList Number 202 HiLink sudoersGroupInList PreProc 203 HiLink sudoersUserNetgroupInList PreProc 204 HiLink sudoersUserAliasInList PreProc 205 HiLink sudoersUserName String 206 HiLink sudoersUID Number 207 HiLink sudoersGroup PreProc 208 HiLink sudoersUserNetgroup PreProc 209 HiLink sudoersUserAliasRef PreProc 210 HiLink sudoersUserNameInSpec String 211 HiLink sudoersUIDInSpec Number 212 HiLink sudoersGroupInSpec PreProc 213 HiLink sudoersUserNetgroupInSpec PreProc 214 HiLink sudoersUserAliasInSpec PreProc 215 HiLink sudoersUserNameInRunas String 216 HiLink sudoersUIDInRunas Number 217 HiLink sudoersGroupInRunas PreProc 218 HiLink sudoersUserNetgroupInRunas PreProc 219 HiLink sudoersUserAliasInRunas PreProc 220 HiLink sudoersHostAlias Identifier 221 HiLink sudoersHostNameInList String 222 HiLink sudoersIPAddrInList Number 223 HiLink sudoersNetworkInList Number 224 HiLink sudoersHostNetgroupInList PreProc 225 HiLink sudoersHostAliasInList PreProc 226 HiLink sudoersHostName String 227 HiLink sudoersIPAddr Number 228 HiLink sudoersNetwork Number 229 HiLink sudoersHostNetgroup PreProc 230 HiLink sudoersHostAliasRef PreProc 231 HiLink sudoersHostNameInSpec String 232 HiLink sudoersIPAddrInSpec Number 233 HiLink sudoersNetworkInSpec Number 234 HiLink sudoersHostNetgroupInSpec PreProc 235 HiLink sudoersHostAliasInSpec PreProc 236 HiLink sudoersCmndAlias Identifier 237 HiLink sudoersCmndNameInList String 238 HiLink sudoersCmndAliasInList PreProc 239 HiLink sudoersCmndNameInSpec String 240 HiLink sudoersCmndAliasInSpec PreProc 241 HiLink sudoersUserAliasEquals Operator 242 HiLink sudoersUserListComma Delimiter 243 HiLink sudoersUserListColon Delimiter 244 HiLink sudoersUserSpecComma Delimiter 245 HiLink sudoersUserRunasBegin Delimiter 246 HiLink sudoersUserRunasComma Delimiter 247 HiLink sudoersUserRunasEnd Delimiter 248 HiLink sudoersHostAliasEquals Operator 249 HiLink sudoersHostListComma Delimiter 250 HiLink sudoersHostListColon Delimiter 251 HiLink sudoersHostSpecComma Delimiter 252 HiLink sudoersCmndAliasEquals Operator 253 HiLink sudoersCmndListComma Delimiter 254 HiLink sudoersCmndListColon Delimiter 255 HiLink sudoersCmndSpecComma Delimiter 256 HiLink sudoersCmndSpecColon Delimiter 257 HiLink sudoersUserNegationInList Operator 258 HiLink sudoersHostNegationInList Operator 259 HiLink sudoersCmndNegationInList Operator 260 HiLink sudoersUserNegation Operator 261 HiLink sudoersHostNegation Operator 262 HiLink sudoersUserNegationInSpec Operator 263 HiLink sudoersHostNegationInSpec Operator 264 HiLink sudoersUserNegationInRunas Operator 265 HiLink sudoersCmndNegationInSpec Operator 266 HiLink sudoersCommandArgs String 267 HiLink sudoersCommandEmpty Special 268 HiLink sudoersDefaultEntry Keyword 269 HiLink sudoersDefaultTypeAt Special 270 HiLink sudoersDefaultTypeColon Special 271 HiLink sudoersDefaultTypeGreaterThan Special 272 HiLink sudoersBooleanParameter Identifier 273 HiLink sudoersIntegerParameter Identifier 274 HiLink sudoersStringParameter Identifier 275 HiLink sudoersListParameter Identifier 276 HiLink sudoersParameterListComma Delimiter 277 HiLink sudoersIntegerParameterEquals Operator 278 HiLink sudoersStringParameterEquals Operator 279 HiLink sudoersListParameterEquals Operator 280 HiLink sudoersIntegerValue Number 281 HiLink sudoersStringValue String 282 HiLink sudoersListValue String 283 HiLink sudoersPASSWD Special 284 285 delcommand HiLink 286endif 287 288let b:current_syntax = "sudoers" 289 290" vim: set sts=2 sw=2: 291