Skip to content

Commit

Permalink
Append audit log entry in the critical section of inode lock.
Browse files Browse the repository at this point in the history
Perform audit log entry append operation in the close method of
MasterAuditContext.

Use a separate thread to perform flushing.
  • Loading branch information
riversand9 committed Aug 21, 2017
1 parent 5ad51c3 commit 7270199
Show file tree
Hide file tree
Showing 2 changed files with 133 additions and 165 deletions.
Expand Up @@ -323,87 +323,4 @@ public void close() {
} }
} }
} }

@NotThreadSafe
public final class MasterAuditContext implements AuditContext {
private final AsyncUserAccessAuditLogWriter mAsyncAuditLogWriter;
private boolean mAllowed;
private String mCommand;
private String mSrcPath;
private String mDstPath;
private String mUser;
private String mIp;
private String mSrcPathOwner;
private String mSrcPathGroup;
private short mSrcPathMode;

@Override
public MasterAuditContext setAllowed(boolean allowed) {
mAllowed = allowed;
return this;
}

public MasterAuditContext setCommand(String command) {
mCommand = command;
return this;
}

public MasterAuditContext setSrcPath(String srcPath) {
mSrcPath = srcPath;
return this;
}

public MasterAuditContext setDstPath(String dstPath) {
mDstPath = dstPath;
return this;
}

public MasterAuditContext setUser(String user) {
mUser = user;
return this;
}

public MasterAuditContext setIp(String ip) {
mIp = ip;
return this;
}

public MasterAuditContext setSrcPathOwner(String owner) {
mSrcPathOwner = owner;
return this;
}

public MasterAuditContext setSrcPathGroup(String group) {
mSrcPathGroup = group;
return this;
}

public MasterAuditContext setSrcPathMode(short mode) {
mSrcPathMode = mode;
return this;
}

private MasterAuditContext(AsyncUserAccessAuditLogWriter asyncAuditLogWriter) {
mAsyncAuditLogWriter = asyncAuditLogWriter;
mAllowed = true;
}

@Override
public void append() {
if (mAsyncAuditLogWriter != null) {
mAsyncAuditLogWriter.append(this);
}
}

@Override
public void close() {}

@Override
public String toString() {
return String.format("allowed=%b\tuser=%s\tip=%s\tcmd=%s\tsrc=%s\tdst=%s\tperm=%s:%s:%d",
mAllowed, mUser, mIp, mCommand, mSrcPath, mDstPath, mSrcPathOwner, mSrcPathGroup, mSrcPathMode);
}
}

protected AuditContext createAuditContext() { return new MasterAuditContext(mAsyncAuditLogWriter); }
} }

0 comments on commit 7270199

Please sign in to comment.