יום שישי, יוני 30, 2023

GDBus.Error:org.freedesktop.ModemManager1.Error.Core.Unauthorized: PolicyKit authorization failed: not authorized

תודות ל policykit הנהדר, כברירת מחדל אם תנסו לבצע פעולות מרוחוקות על ציוד embdeded תקבלו את התושבה המדהימה הזאת.
 
אני הולך לפגוע פה באבטחה, ולאשר לבצע פעולות ע"ג ssh למשתמש מרוחק ,ניתן לבצע זאת ברמת משתמש בודד או קבוצה שלמה שהתחבר מרחוק.
 
זה מדיע לפתור בעיית הרשאות כמו: 
chatty-mm-chat[ 4908]:   DEBUG: mm_chat_send_message_cb():328: Error sending message: GDBus.Error:org.freedesktop.ModemManager1.Error.Core.Unauthorized: PolicyKit authorization failed: not authorized for 'org.freedesktop.ModemManager1.Messaging'
את השגיאה הזאת תקבלו אם תנסו להפעיל את chatty ע"ג ssh -X.

אחד הפתרונות לזה הוא לייצר קובץ הגדרות ל policy kit שיאפשר למשתמש שהתחבר לבצע את הפעולות גם מרחוק :
  cat /var/lib/polkit-1/localauthority/50-local.d/51-org.ssh-chatty-messaging.pkla 
[Remote SSH chatty]
Identity=unix-user:mobian
Action=org.freedesktop.ModemManager1.Messaging
ResultAny=yes
ResultInactive=yes
ResultActive=yes
לאחר שעורכים את הקובץ צריך להפעיל מחדש את השד של פוליסיקיט.

עכשיו ניתן להפעיל את chatty דרך ssh -X ע"י דרך הרשת:
  ssh -X mobian@mobian "GDK_BACKEND=x11 chatty"
11:36:14.6958   chatty-application[ 6386]: WARNING: Experimental features enabled
11:36:16.1449            GStreamer[ 6386]:CRITICAL: gst_element_message_full_with_details: assertion 'GST_IS_ELEMENT (element)' failed
11:36:16.1459            GStreamer[ 6386]:CRITICAL: gst_element_message_full_with_details: assertion 'GST_IS_ELEMENT (element)' failed
Oops, secure memory pool already initialized
11:36:21.2403                 GLib[ 6386]:CRITICAL: g_str_has_prefix: assertion 'str != NULL' failed
11:36:22.0671                 GLib[ 6386]:CRITICAL: g_str_has_prefix: assertion 'str != NULL' failed
11:36:22.6730                 GLib[ 6386]:CRITICAL: g_str_has_prefix: assertion 'str != NULL' failed
11:36:22.8483                 GLib[ 6386]:CRITICAL: g_str_has_prefix: assertion 'str != NULL' failed
11:36:23.0277                 GLib[ 6386]:CRITICAL: g_str_has_prefix: assertion 'str != NULL' failed
11:36:23.1551                 GLib[ 6386]:CRITICAL: g_str_has_prefix: assertion 'str != NULL' failed
11:36:23.1787                 GLib[ 6386]:CRITICAL: g_str_has_prefix: assertion 'str != NULL' failed
11:36:23.3065                 GLib[ 6386]:CRITICAL: g_str_has_prefix: assertion 'str != NULL' failed
11:36:23.4609                 GLib[ 6386]:CRITICAL: g_str_has_prefix: assertion 'str != NULL' failed
11:36:23.6109                 GLib[ 6386]:CRITICAL: g_str_has_prefix: assertion 'str != NULL' failed
11:36:23.7654                 GLib[ 6386]:CRITICAL: g_str_has_prefix: assertion 'str != NULL' failed
11:36:23.8896                 GLib[ 6386]:CRITICAL: g_str_has_prefix: assertion 'str != NULL' failed

  
ועכשיו ניתן לשלוח ולקבל סמסים דרך ssh דרך האורן  שלכם שנמצא בצד השני של העולם.

באותה הצורה ניתן גם לאפשר גישה כללית למודם עבור modemmanager בשביל לפתור התראות על org.freedesktop.ModemManager1.Device.Control ע"י יצרה של קובץ:
  cat /var/lib/polkit-1/localauthority/50-local.d/50-org.ssh-remote-device-control.pkla 
[Remote SSH device control]
Identity=unix-user:mobian
Action=org.freedesktop.ModemManager1.Device.Control
ResultAny=yes
ResultInactive=yes
ResultActive=yes

אין תגובות: