public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/smartmontools] rawhide: use notify-send for notification for users with graphical sessions
@ 2026-08-16  6:53 Michal Hlavinka
  0 siblings, 0 replies; only message in thread
From: Michal Hlavinka @ 2026-08-16  6:53 UTC (permalink / raw)
  To: git-commits

A new commit has been pushed.

Repo   : rpms/smartmontools
Branch : rawhide
Commit : 787c09e3f1d3c468e9a0dfe7fcca9bc309cbe772
Author : Michal Hlavinka <mhlavink@redhat.com>
Date   : 2026-08-16T08:50:51+02:00
Stats  : +61/-5 in 3 file(s)
URL    : https://src.fedoraproject.org/rpms/smartmontools/c/787c09e3f1d3c468e9a0dfe7fcca9bc309cbe772?branch=rawhide

Log:
use notify-send for notification for users with graphical sessions

---
diff --git a/smartdnotify b/smartdnotify
index e0fd01e..cd49631 100644
--- a/smartdnotify
+++ b/smartdnotify
@@ -7,7 +7,21 @@ then
 fi
 
 # Notify desktop user
-MESSAGE="SMART Disk monitor:"
-echo "$MESSAGE
-$SMARTD_MESSAGE" | wall -n 2>/dev/null ||:
+MESSAGE="SMART Disk monitor:
+$SMARTD_MESSAGE"
+
+if which notify-send >/dev/null 2>&1
+then
+  loginctl list-sessions --no-legend --no-pager 2>/dev/null | while read -r SESSION_ID SESS_UID USER SEAT LEADER TYPE CLASS TTY IDLE STATE; do
+    SESSION_TYPE=$(loginctl show-session "$SESSION_ID" -p Type --value 2>/dev/null)
+    case "$SESSION_TYPE" in
+      x11|wayland)
+        DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/$SESS_UID/bus" \
+          runuser -u "$USER" -- notify-send -u critical -i drive-harddisk "SMART Disk Monitor" "$MESSAGE" 2>/dev/null ||:
+        ;;
+    esac
+  done
+fi
+
+echo "$MESSAGE" | wall -n 2>/dev/null ||:
 

diff --git a/smartmon.te b/smartmon.te
index 8975e84..861a645 100644
--- a/smartmon.te
+++ b/smartmon.te
@@ -1,4 +1,4 @@
-policy_module(smartmon, 1.13.0)
+policy_module(smartmon, 1.14.0)
 
 ########################################
 #
@@ -16,6 +16,10 @@ gen_tunable(smartmon_3ware, false)
 require {
         class capability dac_override;
         type tmpfs_t, fs_t, tty_device_t, user_devpts_t, system_mail_t, sssd_var_lib_t, systemd_logind_sessions_t, mail_home_t;
+        type kernel_t, sssd_public_t, sssd_t, devlog_t, systemd_logind_t, syslogd_var_run_t, unconfined_t;
+        type systemd_userdbd_runtime_t, systemd_homed_t, systemd_machined_t, systemd_userdbd_t;
+        type system_dbusd_t, system_dbusd_var_run_t;
+        type session_dbusd_tmp_t, user_tmp_t, unconfined_dbusd_t;
 }
 
 type fsdaemon_t;
@@ -51,11 +55,48 @@ allow smartdwarn_t smartdwarn_script_t:file execute_no_trans;
 init_read_utmp(smartdwarn_t)
 allow smartdwarn_t tty_device_t:chr_file { open write };
 allow smartdwarn_t user_devpts_t:chr_file { open write };
-allow smartdwarn_t self:capability { setgid dac_override };
+allow smartdwarn_t self:capability { setgid setuid dac_override };
 allow smartdwarn_t systemd_logind_sessions_t:dir { getattr open read search };
 allow smartdwarn_t systemd_logind_sessions_t:file { getattr open read };
+allow smartdwarn_t sssd_var_lib_t:dir search;
 allow smartdwarn_t sssd_var_lib_t:sock_file write;
 
+# for loginctl (sd_notify socket and system D-Bus)
+allow smartdwarn_t self:unix_dgram_socket { create getopt setopt connect write };
+allow smartdwarn_t kernel_t:unix_dgram_socket sendto;
+allow smartdwarn_t system_dbusd_var_run_t:dir search;
+allow smartdwarn_t system_dbusd_var_run_t:sock_file write;
+allow smartdwarn_t system_dbusd_t:unix_stream_socket connectto;
+allow smartdwarn_t system_dbusd_t:dbus send_msg;
+allow smartdwarn_t systemd_logind_t:dbus send_msg;
+allow smartdwarn_t unconfined_t:dbus send_msg;
+
+# for runuser (user lookup via SSSD)
+allow smartdwarn_t sssd_public_t:dir search;
+allow smartdwarn_t sssd_public_t:file { read open getattr map };
+allow smartdwarn_t sssd_t:unix_stream_socket connectto;
+
+# for runuser (user lookup via systemd-userdb)
+allow smartdwarn_t systemd_userdbd_runtime_t:dir { getattr open read search };
+allow smartdwarn_t systemd_userdbd_runtime_t:sock_file write;
+allow smartdwarn_t systemd_userdbd_runtime_t:lnk_file read;
+allow smartdwarn_t systemd_homed_t:unix_stream_socket connectto;
+allow smartdwarn_t systemd_machined_t:unix_stream_socket connectto;
+allow smartdwarn_t systemd_userdbd_t:unix_stream_socket connectto;
+
+# for runuser (PAM audit and syslog)
+allow smartdwarn_t self:netlink_audit_socket { create read write nlmsg_relay };
+allow smartdwarn_t self:process setsched;
+allow smartdwarn_t devlog_t:lnk_file read;
+allow smartdwarn_t devlog_t:sock_file write;
+allow smartdwarn_t syslogd_var_run_t:dir search;
+
+# for notify-send (user session D-Bus)
+allow smartdwarn_t user_tmp_t:dir search;
+allow smartdwarn_t session_dbusd_tmp_t:sock_file write;
+allow smartdwarn_t unconfined_dbusd_t:unix_stream_socket connectto;
+allow smartdwarn_t unconfined_dbusd_t:dbus send_msg;
+
 files_manage_generic_tmp_files(smartdwarn_t)
 term_open_unallocated_ttys(smartdwarn_t)
 term_search_ptys(smartdwarn_t)

diff --git a/smartmontools.spec b/smartmontools.spec
index aea5791..ac3fb0b 100644
--- a/smartmontools.spec
+++ b/smartmontools.spec
@@ -176,6 +176,7 @@ fi
 
 %changelog
 * Sat Aug 15 2026 Michal Hlavinka <mhlavink@redhat.com> - 1:7.5-9
+- use notify-send for notification for users with graphical sessions
 - smartd notify for all SMARTD_FAILTYPEs
 
 * Wed Jul 22 2026 Michal Hlavinka <mhlavink@redhat.com> - 1:7.5-8

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-08-16  6:53 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-16  6:53 [rpms/smartmontools] rawhide: use notify-send for notification for users with graphical sessions Michal Hlavinka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox