Skip to content

Commit bd69b39

Browse files
committed
runtime(sudoers): improve recognized Runas_Spec and Tag_Spec items
Recognize colon-delimited second part of Runas_Spec that specifies permitted groups, e.g.: alan ALL = (root, bin : operator, system) ALL This implementation is sloppy because it accepts any amount of colons delimiting further Runas_Lists, but for now that's better than bailing out completely as soon as a colon is encountered (esp. given that the default sudoers uses these colons, breaking highlighting OOTB). Also, while at it, make Vim recognize all Tag_Spec items, not just {,NO}PASSWD closes: #15607 Signed-off-by: Ivan Shapovalov <intelfx@intelfx.name> Signed-off-by: Eisuke Kawashima <e-kwsm@users.noreply.github.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
1 parent 3d5065f commit bd69b39

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

runtime/syntax/sudoers.vim

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
" Language: sudoers(5) configuration files
33
" Maintainer: Eisuke Kawashima ( e.kawaschima+vim AT gmail.com )
44
" Previous Maintainer: Nikolai Weibull <now@bitwi.se>
5-
" Latest Revision: 2021 Mar 15
5+
" Latest Revision: 2024 Sep 02
66
" Recent Changes: Support for #include and #includedir.
77
" Added many new options (Samuel D. Leslie)
8+
" Update allowed Tag_Spec Runas_Spec syntax items
89

910
if exists("b:current_syntax")
1011
finish
@@ -22,7 +23,7 @@ syn match sudoersUserSpec '^' nextgroup=@sudoersUserInSpec skipwhite
2223

2324
syn match sudoersSpecEquals contained '=' nextgroup=@sudoersCmndSpecList skipwhite
2425

25-
syn cluster sudoersCmndSpecList contains=sudoersUserRunasBegin,sudoersPASSWD,@sudoersCmndInSpec
26+
syn cluster sudoersCmndSpecList contains=sudoersUserRunasBegin,sudoersTagSpec,@sudoersCmndInSpec
2627

2728
syn keyword sudoersTodo contained TODO FIXME XXX NOTE
2829

@@ -92,10 +93,11 @@ syn cluster sudoersUserList contains=sudoersUserListComma,sudoersUserLis
9293
syn match sudoersUserSpecComma contained ',' nextgroup=@sudoersUserInSpec skipwhite skipnl
9394
syn cluster sudoersUserSpec contains=sudoersUserSpecComma,@sudoersHostInSpec
9495

95-
syn match sudoersUserRunasBegin contained '(' nextgroup=@sudoersUserInRunas skipwhite skipnl
96+
syn match sudoersUserRunasBegin contained '(' nextgroup=@sudoersUserInRunas,sudoersUserRunasColon skipwhite skipnl
9697
syn match sudoersUserRunasComma contained ',' nextgroup=@sudoersUserInRunas skipwhite skipnl
97-
syn match sudoersUserRunasEnd contained ')' nextgroup=sudoersPASSWD,@sudoersCmndInSpec skipwhite skipnl
98-
syn cluster sudoersUserRunas contains=sudoersUserRunasComma,@sudoersUserInRunas,sudoersUserRunasEnd
98+
syn match sudoersUserRunasColon contained ':' nextgroup=@sudoersUserInRunas skipwhite skipnl
99+
syn match sudoersUserRunasEnd contained ')' nextgroup=sudoersTagSpec,@sudoersCmndInSpec skipwhite skipnl
100+
syn cluster sudoersUserRunas contains=sudoersUserRunasComma,sudoersUserRunasColon,@sudoersUserInRunas,sudoersUserRunasEnd
99101

100102

101103
syn match sudoersHostAliasEquals contained '=' nextgroup=@sudoersHostInList skipwhite skipnl
@@ -291,7 +293,7 @@ syn region sudoersStringValue contained start=+"+ skip=+\\"+ end=+"+ nextgroup
291293
syn match sudoersListValue contained '[^[:space:],:=\\]*\%(\\[[:space:],:=\\][^[:space:],:=\\]*\)*' nextgroup=sudoersParameterListComma skipwhite skipnl
292294
syn region sudoersListValue contained start=+"+ skip=+\\"+ end=+"+ nextgroup=sudoersParameterListComma skipwhite skipnl
293295

294-
syn match sudoersPASSWD contained '\%(NO\)\=PASSWD:' nextgroup=@sudoersCmndInSpec skipwhite
296+
syn match sudoersTagSpec contained '\%(NO\)\=\%(EXEC\|FOLLOW\|LOG_\%(INPUT\|OUTPUT\)\|MAIL\|INTERCEPT\|PASSWD\|SETENV\):' nextgroup=sudoersTagSpec,@sudoersCmndInSpec skipwhite
295297

296298
hi def link sudoersSpecEquals Operator
297299
hi def link sudoersTodo Todo
@@ -345,6 +347,7 @@ hi def link sudoersUserListColon Delimiter
345347
hi def link sudoersUserSpecComma Delimiter
346348
hi def link sudoersUserRunasBegin Delimiter
347349
hi def link sudoersUserRunasComma Delimiter
350+
hi def link sudoersUserRunasColon Delimiter
348351
hi def link sudoersUserRunasEnd Delimiter
349352
hi def link sudoersHostAliasEquals Operator
350353
hi def link sudoersHostListComma Delimiter
@@ -381,7 +384,7 @@ hi def link sudoersListParameterEquals Operator
381384
hi def link sudoersIntegerValue Number
382385
hi def link sudoersStringValue String
383386
hi def link sudoersListValue String
384-
hi def link sudoersPASSWD Special
387+
hi def link sudoersTagSpec Special
385388
hi def link sudoersInclude Statement
386389

387390
let b:current_syntax = "sudoers"

0 commit comments

Comments
 (0)