Bug 1680 - Match User/Group with no affirmative match does not work as expected
Summary: Match User/Group with no affirmative match does not work as expected
Status: CLOSED DUPLICATE of bug 1918
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: sshd (show other bugs)
Version: 6.6p1
Hardware: amd64 OpenBSD
: P2 normal
Assignee: Assigned to nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-12-03 18:01 AEDT by osshbugs
Modified: 2015-08-11 23:03 AEST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description osshbugs 2009-12-03 18:01:04 AEDT
Statements such as:
Match User !root
  ForceCommand /bin/rshell

or:
Match Group !root
  ForceCommand /bin/rshell

Will not work, due to (in my read) servconf.c
# } else if (ga_match_pattern_list(grps) != 1) {
and 
# if (match_pattern_list(user, arg, len, 0) != 1)

Both functions on an affirmatively negated match will return -1 (rather than 1, but still non zero), thus never being considered a "match" by either user or group negation processing.

In fact, for users, I'm not certain the processing will ever be correct for negation in any sane deploy (Match user steve !steve)?, though for groups it could make sense to return differing results based on the intersection of group1 & !group2

Since there is not a "ForceCommand no", and ForceCommand /bin/bash is not the same as login (obv.), I'm left at a bit of a puzzle to handle this one.

Or I could be misreading all this code, or its already fixed elsewhere and I missed it.

But I think its a bug anyhow...
Comment 1 osshbugs 2009-12-03 18:11:53 AEDT
ahh, an undocumented, but logical workaround:

If you force a positive match, it will work:

Match user *,!root

Perhaps just a fix in the manpages would suffice to save someone else hours on this one :-)
Comment 2 ED Fochler 2014-04-17 11:58:42 AEST
2014 April.  OpenBSD current.  Still true.  Man page still lacking details.  I was 10 minutes from filing this as a new bug, I'll just bump this one.

Match User "!carl" # not valid.
Match User "*,!carl" # works just fine.
Comment 3 Damien Miller 2015-04-17 14:57:41 AEST

*** This bug has been marked as a duplicate of bug 1918 ***
Comment 4 Damien Miller 2015-08-11 23:03:18 AEST
Set all RESOLVED bugs to CLOSED with release of OpenSSH 7.1