aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAurelian R <arusanu@gmail.com>2026-03-29 15:06:35 +0300
committerAurelian R <arusanu@gmail.com>2026-03-29 15:06:35 +0300
commit1590ac7a9534262dc2c4db40009f0a347266f92e (patch)
tree33c0de8d0e4fc56a38c68ee335aaac04bd447c45
parent0f6422ebf63c0398fd0f625fa67dd2e24e9a117f (diff)
downloadmsec-1590ac7a9534262dc2c4db40009f0a347266f92e.tar
msec-1590ac7a9534262dc2c4db40009f0a347266f92e.tar.gz
msec-1590ac7a9534262dc2c4db40009f0a347266f92e.tar.bz2
msec-1590ac7a9534262dc2c4db40009f0a347266f92e.tar.xz
msec-1590ac7a9534262dc2c4db40009f0a347266f92e.zip
Workaround desktop notifications (mga#35261)
If "sudo", and gdbus or notify-send are available, use them to send messages because s2u fails to work with Wayland desktops.
-rwxr-xr-xcron-sh/functions.sh47
1 files changed, 41 insertions, 6 deletions
diff --git a/cron-sh/functions.sh b/cron-sh/functions.sh
index 9c534ba..5bd6ade 100755
--- a/cron-sh/functions.sh
+++ b/cron-sh/functions.sh
@@ -192,14 +192,49 @@ EOF
}
Notifylog() {
- if [[ ${NOTIFY_WARN} == yes ]]; then
- message=${1}
- DBUS_SEND=`which dbus-send 2>/dev/null`
- if [ -x "$DBUS_SEND" ]; then
- $DBUS_SEND --system --type=signal /org/mageia/user org.mageia.user.security_notification string:"$message"
+ if [[ ${NOTIFY_WARN} == yes ]]; then
+ message=${1}
+
+ SUDO=$(which sudo 2>/dev/null)
+ NOTIFY_SEND=$(which notify-send 2>/dev/null)
+ GDBUS=$(which gdbus 2>/dev/null)
+ USE_DBUS_SEND=YES
+ DBUS_SEND=$(which dbus-send 2>/dev/null)
+
+ if [ -x "$SUDO" ]; then
+ # Send messages to X11/Wayland using either gdbus or notify-send
+ for user in $(who | awk '{print $1}' | sort -u ); do
+ uid=$(id -u "${user}")
+ if [ -n "${uid}" ]; then
+ if [ -x "$GDBUS" ]; then
+ sudo -u "${user}" DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/${uid}/bus" \
+ $GDBUS call --session --dest=org.freedesktop.Notifications \
+ --object-path=/org/freedesktop/Notifications \
+ --method=org.freedesktop.Notifications.Notify \
+ " MSEC" 0 "security-medium" "Security Alert" "${message}" \
+ '[]' '{"urgency": <2>}' 3500 2>/dev/null
+ USE_DBUS_SEND=NO
+ elif [ -x "$NOTIFY_SEND" ]; then
+ sudo -u "${user}" DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/${uid}/bus" \
+ $NOTIFY_SEND " MSEC" "${message}" 2>/dev/null
+ USE_DBUS_SEND=NO
+ ##elif [ -x "$DBUS_SEND" ]; then
+ ## sudo -u "$user" DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/${uid}/bus" \
+ ## $DBUS_SEND --session --dest=org.freedesktop.Notifications /org/freedesktop/Notifications \
+ ## org.freedesktop.Notifications.Notify \
+ ## string:" MSEC" uint32:0 string:"security-medium" string:"Security Alert" \
+ ## string:"$message" array:string: array:dict:string,variant: \
+ ## dict:string,variant:"urgency",variant:uint32:2 uint32:3500 2>/dev/null
+ fi
fi
+ done
fi
-}
+ # Use s2u notification as backup
+ if [ -x "$DBUS_SEND" ] && [ "$USE_DBUS_SEND" = "YES" ]; then
+ $DBUS_SEND --system --type=signal /org/mageia/user org.mageia.user.security_notification string:"$message"
+ fi
+ fi
+}
##################