运维:固定虚拟PCI设备并补充过夜观察与电源策略
This commit is contained in:
1 parent
6f2ff67300
commit
65f92df8b7
42 files changed
+1705
No files matched your search
@@ -0,0 +1,64 @@
|
||||
diff --git a/app/streaming/input/keyboard.cpp b/app/streaming/input/keyboard.cpp
|
||||
index 29e218d..2b3911d 100644
|
||||
--- a/app/streaming/input/keyboard.cpp
|
||||
+++ b/app/streaming/input/keyboard.cpp
|
||||
@@ -182,6 +182,43 @@ void SdlInputHandler::performSpecialKeyCombo(KeyCombo combo)
|
||||
}
|
||||
}
|
||||
|
||||
+namespace {
|
||||
+
|
||||
+// The terminal is a kiosk. These keys can stop, restart, lock, or expose the
|
||||
+// guest session, so they must never be forwarded to any cloud desktop. The
|
||||
+// modifier tests intentionally apply to both key-down and key-up events so a
|
||||
+// blocked shortcut cannot leave a partial action in the guest.
|
||||
+static bool isBlockedPowerKeyEvent(const SDL_KeyboardEvent* event)
|
||||
+{
|
||||
+ const SDL_Keymod modifiers = static_cast<SDL_Keymod>(event->keysym.mod);
|
||||
+ const bool ctrlAlt = (modifiers & KMOD_CTRL) && (modifiers & KMOD_ALT);
|
||||
+ const bool alt = (modifiers & KMOD_ALT) != 0;
|
||||
+ const bool gui = (modifiers & KMOD_GUI) != 0;
|
||||
+
|
||||
+ switch (event->keysym.scancode) {
|
||||
+ case SDL_SCANCODE_SLEEP:
|
||||
+ // SDL2 maps the physical power/sleep button to this consumer code.
|
||||
+ return true;
|
||||
+ case SDL_SCANCODE_DELETE:
|
||||
+ // Windows secure attention and systemd's Ctrl+Alt+Del action.
|
||||
+ return ctrlAlt;
|
||||
+ case SDL_SCANCODE_F4:
|
||||
+ // On a desktop, Alt+F4 opens the shutdown dialog; it is also a
|
||||
+ // common way to close the only shell/application in a kiosk image.
|
||||
+ return alt;
|
||||
+ case SDL_SCANCODE_L:
|
||||
+ // Locking the guest breaks the kiosk session and can strand the user.
|
||||
+ return gui;
|
||||
+ case SDL_SCANCODE_X:
|
||||
+ // Windows quick-link menu contains shutdown/restart actions.
|
||||
+ return gui;
|
||||
+ default:
|
||||
+ return false;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+} // namespace
|
||||
+
|
||||
void SdlInputHandler::handleKeyEvent(SDL_KeyboardEvent* event)
|
||||
{
|
||||
short keyCode;
|
||||
@@ -189,6 +226,15 @@ void SdlInputHandler::handleKeyEvent(SDL_KeyboardEvent* event)
|
||||
char flags;
|
||||
bool shouldNotConvertToScanCodeOnServer = false;
|
||||
|
||||
+ if (isBlockedPowerKeyEvent(event)) {
|
||||
+ if (event->state == SDL_PRESSED) {
|
||||
+ SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
+ "Blocked guest power/session shortcut (scancode=%d)",
|
||||
+ event->keysym.scancode);
|
||||
+ }
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
if (event->repeat) {
|
||||
// Ignore repeat key down events
|
||||
SDL_assert(event->state == SDL_PRESSED);
|
||||
Reference in new issue
Block a user