Skip to content

Commit

Permalink
[FIXED JENKINS-13526] use '@' prefix to force PAM to interpret the us…
Browse files Browse the repository at this point in the history
…er/group as a group

Originally-Committed-As: db1b7eef1a9a67b5f08e73d349230e0cec5a485d
  • Loading branch information
Rob Petti authored and kohsuke committed Apr 26, 2012
1 parent 585e731 commit 1772173
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
12 changes: 9 additions & 3 deletions core/src/main/java/hudson/security/PAMSecurityRealm.java
Expand Up @@ -104,12 +104,18 @@ private static GrantedAuthority[] toAuthorities(UnixUser u) {

@Override
public GroupDetails loadGroupByGroupname(final String groupname) throws UsernameNotFoundException, DataAccessException {
if(CLibrary.libc.getgrnam(groupname)==null)
throw new UsernameNotFoundException(groupname);
final String group;
if(groupname.startsWith("@")) {
group = groupname.substring(1);
} else {
group = groupname;
}
if(CLibrary.libc.getgrnam(group)==null)
throw new UsernameNotFoundException(group);
return new GroupDetails() {
@Override
public String getName() {
return groupname;
return group;
}
};
}
Expand Down
Expand Up @@ -5,7 +5,13 @@

<p>
This mode will also allow you to use Unix groups for authorization. For example,
you can say "everyone in the 'developers' group will have the administrator access".
you can say "everyone in the 'developers' group will have the administrator access".

<p>
Unix allows an user and a group to have the same name. If you need to disambiguate,
you can use the '@' prefix to force the name to be interpreted as a group. For example,
'@dev' would mean the 'dev' group and not the 'dev' user, while 'dev' would be interpreted
as an user if you indeed have the user of that name.

<p>
This is done through a library called <a href="http://en.wikipedia.org/wiki/Pluggable_Authentication_Modules">PAM</a>,
Expand Down

0 comments on commit 1772173

Please sign in to comment.