summaryrefslogtreecommitdiff
path: root/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/vm/0006-Bmcweb-handle-permission-denied-exception.patch
blob: efce3e72c1bdb6f89ed05b98568c99329e4a8f7c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
From e7018ea9e3ad1a17e096aec3717a4764c3feac2e Mon Sep 17 00:00:00 2001
From: Alicja Rybak <alicja.rybak@intel.com>
Date: Wed, 14 Apr 2021 16:26:59 +0200
Subject: [PATCH] Bmcweb handle permission denied exception

Add handling of permission denied exception (EPERM) that
can be thrown by VirtualMedia service during Mount/Unmount dbus operations.

Tested:
Verified that after mounting/unmounting HTTPS resource twice in a row in legacy mode,
VirtualMedia returns EPERM, which bmcweb handles as 403 status code.

Change-Id: Ibc18d5ec822c5072605b1fc4651389982002798b
Signed-off-by: Alicja Rybak <alicja.rybak@intel.com>
---
 redfish-core/lib/virtual_media.hpp | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/redfish-core/lib/virtual_media.hpp b/redfish-core/lib/virtual_media.hpp
index 4c475b7..8151ac0 100644
--- a/redfish-core/lib/virtual_media.hpp
+++ b/redfish-core/lib/virtual_media.hpp
@@ -1073,6 +1073,10 @@ class VirtualMediaActionInsertMedia : public Node
                             {
                                 messages::resourceInUse(asyncResp->res);
                             }
+                            else if (ec == boost::system::errc::permission_denied)
+                            {
+                                messages::accessDenied(asyncResp->res, "VirtualMedia.Insert");
+                            }
                             else
                             {
                                 messages::internalError(asyncResp->res);
@@ -1267,6 +1271,10 @@ class VirtualMediaActionEjectMedia : public Node
                             {
                                 messages::resourceInUse(asyncResp->res);
                             }
+                            else if (ec == boost::system::errc::permission_denied)
+                            {
+                                messages::accessDenied(asyncResp->res, "VirtualMedia.Eject");
+                            }
                             else
                             {
                                 messages::internalError(asyncResp->res);
-- 
2.17.1