Skip to content

Commit a39d7c2

Browse files
bbatsovchrisbra
authored andcommitted
runtime(sudoers): highlight usernames with hyphens, digits, underscores
The username/group/netgroup patterns used \l\+ which only matched lowercase letters. Linux usernames commonly contain hyphens, digits, and underscores (e.g. www-data, deploy01, test_user). Update the pattern to \l[-a-z0-9_]* to allow matching the additional characters "-_" and numbers. fixes: #18963 closes: #19396 Signed-off-by: Bozhidar Batsov <[email protected]> Signed-off-by: Christian Brabandt <[email protected]>
1 parent 9fe5a1d commit a39d7c2

1 file changed

Lines changed: 15 additions & 14 deletions

File tree

runtime/syntax/sudoers.vim

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
" Previous Maintainer: Nikolai Weibull <[email protected]>
55
" Latest Revision: 2024 Sep 02
66
" Recent Changes: Support for #include and #includedir.
7-
" Added many new options (Samuel D. Leslie)
8-
" Update allowed Tag_Spec Runas_Spec syntax items
7+
" 2018 Aug 28 by Vim project Added many new options (Samuel D. Leslie)
8+
" 2024 Sep 09 by Vim project Update allowed Tag_Spec Runas_Spec syntax items
9+
" 2026 Feb 13 by Vim project update regex for matching usernames #19396
910

1011
if exists("b:current_syntax")
1112
finish
@@ -35,28 +36,28 @@ syn keyword sudoersAlias Host_Alias nextgroup=sudoersHostAlias skip
3536
syn keyword sudoersAlias Cmnd_Alias nextgroup=sudoersCmndAlias skipwhite skipnl
3637

3738
syn match sudoersUserAlias contained '\<\u[A-Z0-9_]*\>' nextgroup=sudoersUserAliasEquals skipwhite skipnl
38-
syn match sudoersUserNameInList contained '\<\l\+\>' nextgroup=@sudoersUserList skipwhite skipnl
39+
syn match sudoersUserNameInList contained '\<\l[-a-z0-9_]*\>' nextgroup=@sudoersUserList skipwhite skipnl
3940
syn match sudoersUIDInList contained '#\d\+\>' nextgroup=@sudoersUserList skipwhite skipnl
40-
syn match sudoersGroupInList contained '%\l\+\>' nextgroup=@sudoersUserList skipwhite skipnl
41-
syn match sudoersUserNetgroupInList contained '+\l\+\>' nextgroup=@sudoersUserList skipwhite skipnl
41+
syn match sudoersGroupInList contained '%\l[-a-z0-9_]*\>' nextgroup=@sudoersUserList skipwhite skipnl
42+
syn match sudoersUserNetgroupInList contained '+\l[-a-z0-9_]*\>' nextgroup=@sudoersUserList skipwhite skipnl
4243
syn match sudoersUserAliasInList contained '\<\u[A-Z0-9_]*\>' nextgroup=@sudoersUserList skipwhite skipnl
4344

44-
syn match sudoersUserName contained '\<\l\+\>' nextgroup=@sudoersParameter skipwhite skipnl
45+
syn match sudoersUserName contained '\<\l[-a-z0-9_]*\>' nextgroup=@sudoersParameter skipwhite skipnl
4546
syn match sudoersUID contained '#\d\+\>' nextgroup=@sudoersParameter skipwhite skipnl
46-
syn match sudoersGroup contained '%\l\+\>' nextgroup=@sudoersParameter skipwhite skipnl
47-
syn match sudoersUserNetgroup contained '+\l\+\>' nextgroup=@sudoersParameter skipwhite skipnl
47+
syn match sudoersGroup contained '%\l[-a-z0-9_]*\>' nextgroup=@sudoersParameter skipwhite skipnl
48+
syn match sudoersUserNetgroup contained '+\l[-a-z0-9_]*\>' nextgroup=@sudoersParameter skipwhite skipnl
4849
syn match sudoersUserAliasRef contained '\<\u[A-Z0-9_]*\>' nextgroup=@sudoersParameter skipwhite skipnl
4950

50-
syn match sudoersUserNameInSpec contained '\<\l\+\>' nextgroup=@sudoersUserSpec skipwhite skipnl
51+
syn match sudoersUserNameInSpec contained '\<\l[-a-z0-9_]*\>' nextgroup=@sudoersUserSpec skipwhite skipnl
5152
syn match sudoersUIDInSpec contained '#\d\+\>' nextgroup=@sudoersUserSpec skipwhite skipnl
52-
syn match sudoersGroupInSpec contained '%\l\+\>' nextgroup=@sudoersUserSpec skipwhite skipnl
53-
syn match sudoersUserNetgroupInSpec contained '+\l\+\>' nextgroup=@sudoersUserSpec skipwhite skipnl
53+
syn match sudoersGroupInSpec contained '%\l[-a-z0-9_]*\>' nextgroup=@sudoersUserSpec skipwhite skipnl
54+
syn match sudoersUserNetgroupInSpec contained '+\l[-a-z0-9_]*\>' nextgroup=@sudoersUserSpec skipwhite skipnl
5455
syn match sudoersUserAliasInSpec contained '\<\u[A-Z0-9_]*\>' nextgroup=@sudoersUserSpec skipwhite skipnl
5556

56-
syn match sudoersUserNameInRunas contained '\<\l\+\>' nextgroup=@sudoersUserRunas skipwhite skipnl
57+
syn match sudoersUserNameInRunas contained '\<\l[-a-z0-9_]*\>' nextgroup=@sudoersUserRunas skipwhite skipnl
5758
syn match sudoersUIDInRunas contained '#\d\+\>' nextgroup=@sudoersUserRunas skipwhite skipnl
58-
syn match sudoersGroupInRunas contained '%\l\+\>' nextgroup=@sudoersUserRunas skipwhite skipnl
59-
syn match sudoersUserNetgroupInRunas contained '+\l\+\>' nextgroup=@sudoersUserRunas skipwhite skipnl
59+
syn match sudoersGroupInRunas contained '%\l[-a-z0-9_]*\>' nextgroup=@sudoersUserRunas skipwhite skipnl
60+
syn match sudoersUserNetgroupInRunas contained '+\l[-a-z0-9_]*\>' nextgroup=@sudoersUserRunas skipwhite skipnl
6061
syn match sudoersUserAliasInRunas contained '\<\u[A-Z0-9_]*\>' nextgroup=@sudoersUserRunas skipwhite skipnl
6162

6263
syn match sudoersHostAlias contained '\<\u[A-Z0-9_]*\>' nextgroup=sudoersHostAliasEquals skipwhite skipnl

0 commit comments

Comments
 (0)