Skip to content

Commit

Permalink
access log: better fix for logging secondary gids
Browse files Browse the repository at this point in the history
A previous attempt to fix secondary gids resulted in primary and
first secondary gids not being separated.

This patch fixes that issue.

Target: master
Patch: https://rb.dcache.org/r/8009/
Acked-by: Gerd Behrmann
Request: 2.12
Requires-notes: yes
Requires-book: no
  • Loading branch information
paulmillar committed Mar 24, 2015
1 parent 5b3c25d commit 54a81ea
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions modules/common/src/main/java/org/dcache/util/NetLoggerBuilder.java
Expand Up @@ -60,7 +60,6 @@ private static StringBuilder appendSubject(StringBuilder sb, Subject subject)

Long uid = null;
Long gid = null;
boolean hasSecondaryGid = false;
for (Principal principal : subject.getPrincipals()) {
if (principal instanceof UidPrincipal) {
if (((UidPrincipal) principal).getUid() == 0) {
Expand All @@ -70,8 +69,6 @@ private static StringBuilder appendSubject(StringBuilder sb, Subject subject)
} else if (principal instanceof GidPrincipal) {
if (((GidPrincipal) principal).isPrimaryGroup()) {
gid = ((GidPrincipal) principal).getGid();
} else {
hasSecondaryGid = true;
}
}
}
Expand All @@ -82,17 +79,10 @@ private static StringBuilder appendSubject(StringBuilder sb, Subject subject)
if (gid != null) {
sb.append(gid);
}
if (hasSecondaryGid) {
boolean firstLoop = true;
for (Principal principal : subject.getPrincipals()) {
if (principal instanceof GidPrincipal &&
!((GidPrincipal) principal).isPrimaryGroup()) {
if (!firstLoop) {
sb.append(',');
}
firstLoop = false;
sb.append(((GidPrincipal) principal).getGid());
}
for (Principal principal : subject.getPrincipals()) {
if (principal instanceof GidPrincipal &&
!((GidPrincipal) principal).isPrimaryGroup()) {
sb.append(',').append(((GidPrincipal) principal).getGid());
}
}
return sb;
Expand Down

0 comments on commit 54a81ea

Please sign in to comment.