Martin Peřina has uploaded a new change for review.

Change subject: core: Fix username for commands executed from Quartz jobs
......................................................................

core: Fix username for commands executed from Quartz jobs

Set username for audit log to "engine@internal" for commands which are
executed from Quartz jobs (those commands are not bound to any logged in
user).

Change-Id: Ibc7bae0be74d3a5f7c5b7cfc4f3827a1dcfda8b7
Bug-Url: https://bugzilla.redhat.com/1203735
Signed-off-by: Martin Perina <mper...@redhat.com>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandBase.java
1 file changed, 7 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/86/39786/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandBase.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandBase.java
index 8d50bfd..dc4af00 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandBase.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandBase.java
@@ -166,7 +166,13 @@
         if (user != null) {
             setCurrentUser(user);
         }
-        
setUserName(SessionDataContainer.getInstance().getUserName(cmdContext.getEngineContext().getSessionId()));
+        if 
(SessionDataContainer.getInstance().getPrincipalName(cmdContext.getEngineContext().getSessionId())
 == null) {
+            // command was most probably executed from Quartz job, so session 
doesn't contain any user info
+            // we need to set username to fake internal user so audit logs 
will not contain "null@N/A" as username
+            setUserName("engine@internal");
+        } else {
+            
setUserName(SessionDataContainer.getInstance().getUserName(cmdContext.getEngineContext().getSessionId()));
+        }
         ExecutionContext executionContext = cmdContext.getExecutionContext();
         if (executionContext.getJob() != null) {
             setJobId(executionContext.getJob().getId());


-- 
To view, visit https://gerrit.ovirt.org/39786
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibc7bae0be74d3a5f7c5b7cfc4f3827a1dcfda8b7
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Martin Peřina <mper...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to