Skip to content

Commit fd10cf0

Browse files
committed
upstream: Move checks for lists of users or groups into their own
function. This is a no-op on OpenBSD but will make things easier in -portable, eg on systems where these checks should be case-insensitive. ok djm@ OpenBSD-Commit-ID: 8bc9c8d98670e23f8eaaaefe29c1f98e7ba0487e
1 parent ab5fee8 commit fd10cf0

File tree

4 files changed

+21
-14
lines changed

4 files changed

+21
-14
lines changed

Diff for: groupaccess.c

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $OpenBSD: groupaccess.c,v 1.16 2015/05/04 06:10:48 djm Exp $ */
1+
/* $OpenBSD: groupaccess.c,v 1.17 2019/03/06 22:14:23 dtucker Exp $ */
22
/*
33
* Copyright (c) 2001 Kevin Steves. All rights reserved.
44
*
@@ -103,11 +103,8 @@ ga_match_pattern_list(const char *group_pattern)
103103
int i, found = 0;
104104

105105
for (i = 0; i < ngroups; i++) {
106-
#ifndef HAVE_CYGWIN
107-
switch (match_pattern_list(groups_byname[i], group_pattern, 0)) {
108-
#else
109-
switch (match_pattern_list(groups_byname[i], group_pattern, 1)) {
110-
#endif
106+
switch (match_usergroup_pattern_list(groups_byname[i],
107+
group_pattern)) {
111108
case -1:
112109
return 0; /* Negated match wins */
113110
case 0:

Diff for: match.c

+14-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $OpenBSD: match.c,v 1.38 2018/07/04 13:49:31 djm Exp $ */
1+
/* $OpenBSD: match.c,v 1.39 2019/03/06 22:14:23 dtucker Exp $ */
22
/*
33
* Author: Tatu Ylonen <[email protected]>
44
* Copyright (c) 1995 Tatu Ylonen <[email protected]>, Espoo, Finland
@@ -174,6 +174,19 @@ match_pattern_list(const char *string, const char *pattern, int dolower)
174174

175175
#endif
176176

177+
/* Match a list representing users or groups. */
178+
int
179+
match_usergroup_pattern_list(const char *string, const char *pattern)
180+
{
181+
#ifndef HAVE_CYGWIN
182+
/* Case sensitive match */
183+
return match_pattern_list(string, pattern, 0);
184+
#else
185+
/* Case insensitive match */
186+
return match_pattern_list(string, pattern, 1);
187+
#endif
188+
}
189+
177190
/*
178191
* Tries to match the host name (which must be in all lowercase) against the
179192
* comma-separated sequence of subpatterns (each possibly preceded by ! to

Diff for: match.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $OpenBSD: match.h,v 1.18 2018/07/04 13:49:31 djm Exp $ */
1+
/* $OpenBSD: match.h,v 1.19 2019/03/06 22:14:23 dtucker Exp $ */
22

33
/*
44
* Author: Tatu Ylonen <[email protected]>
@@ -16,6 +16,7 @@
1616

1717
int match_pattern(const char *, const char *);
1818
int match_pattern_list(const char *, const char *, int);
19+
int match_usergroup_pattern_list(const char *, const char *);
1920
int match_hostname(const char *, const char *);
2021
int match_host_and_ip(const char *, const char *, const char *);
2122
int match_user(const char *, const char *, const char *, const char *);

Diff for: servconf.c

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
/* $OpenBSD: servconf.c,v 1.348 2019/01/24 02:34:52 dtucker Exp $ */
2+
/* $OpenBSD: servconf.c,v 1.349 2019/03/06 22:14:23 dtucker Exp $ */
33
/*
44
* Copyright (c) 1995 Tatu Ylonen <[email protected]>, Espoo, Finland
55
* All rights reserved
@@ -1049,11 +1049,7 @@ match_cfg_line(char **condition, int line, struct connection_info *ci)
10491049
}
10501050
if (ci->user == NULL)
10511051
match_test_missing_fatal("User", "user");
1052-
#ifndef HAVE_CYGWIN
1053-
if (match_pattern_list(ci->user, arg, 0) != 1)
1054-
#else
1055-
if (match_pattern_list(ci->user, arg, 1) != 1)
1056-
#endif
1052+
if (match_usergroup_pattern_list(ci->user, arg) != 1)
10571053
result = 0;
10581054
else
10591055
debug("user %.100s matched 'User %.100s' at "

0 commit comments

Comments
 (0)