LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 03-22-2021, 05:59 AM   #1
stormtracknole
Senior Member
 
Registered: Aug 2005
Distribution: Slackware, RHEL
Posts: 1,259

Rep: Reputation: 231Reputation: 231Reputation: 231
Question KDE Plasma notifications from cron


Greetings!

I am running into an issue with running a cron that uses notify-send. This scripts works on Gnome and XFCE. For whatever reason, I cannot get it to work on KDE Plasma (-current 5.21.3). From what I have been able to research, it seems to be related to DBUS_SESSION_BUS_ADDRESS not being set. I have tried all sorts of different variations to no avail. Even setting the DISPLAY value doesn't seem to work.

Any thoughts as to what else I am missing? Thanks!
 
Old 03-22-2021, 06:09 AM   #2
Tonus
Senior Member
 
Registered: Jan 2007
Location: Paris, France
Distribution: Slackware-15.0
Posts: 1,405
Blog Entries: 3

Rep: Reputation: 514Reputation: 514Reputation: 514Reputation: 514Reputation: 514Reputation: 514
Show script for us to suggest something
 
Old 03-22-2021, 06:18 AM   #3
stormtracknole
Senior Member
 
Registered: Aug 2005
Distribution: Slackware, RHEL
Posts: 1,259

Original Poster
Rep: Reputation: 231Reputation: 231Reputation: 231
Quote:
Originally Posted by Tonus View Post
Show script for us to suggest something
Code:
#!/bin/bash

DISPLAY=:1

notify-send -u critical "Remember to check for precip."
It doesn't work in Wayland or with Xorg. I thought it might have been a Wayland thing. This same script works with XFCE in Slackware and Fedora Gnome.
 
Old 03-22-2021, 06:40 AM   #4
LuckyCyborg
Senior Member
 
Registered: Mar 2010
Posts: 3,499

Rep: Reputation: 3308Reputation: 3308Reputation: 3308Reputation: 3308Reputation: 3308Reputation: 3308Reputation: 3308Reputation: 3308Reputation: 3308Reputation: 3308Reputation: 3308
Quote:
Originally Posted by stormtracknole View Post
Code:
#!/bin/bash

DISPLAY=:1

notify-send -u critical "Remember to check for precip."
It doesn't work in Wayland or with Xorg. I thought it might have been a Wayland thing. This same script works with XFCE in Slackware and Fedora Gnome.
I believe that your "issue" is of completely another nature.

In fact, you just demonstrate that there is a HUGE security issue on XFCE or even Fedora's GNOME, which permits to another user (i.e. the one used by CRON) to send notifications to another user desktop - so, I can imagine someone defacing somehow the "nobody" account then bombing everybody logged in the box with Viagra advertising on desktop popups.

Also, you just demonstrate that KDE Plasma5 has a superior security, and it is NOT VULNERABLE to this particular security issue.

I suggest you to not rely your work on existence of this particular security issue, which probably will be fixed sooner or later by the XFCE and GNOME developers.

Last edited by LuckyCyborg; 03-22-2021 at 06:45 AM.
 
Old 03-22-2021, 06:45 AM   #5
stormtracknole
Senior Member
 
Registered: Aug 2005
Distribution: Slackware, RHEL
Posts: 1,259

Original Poster
Rep: Reputation: 231Reputation: 231Reputation: 231
Quote:
Originally Posted by LuckyCyborg View Post
I believe that your "issue" is of another nature.

In fact, you just demonstrate that there is a HUGE security issue on XFCE or even Fedora's GNOME, which permits to another user (i.e. the one used by CRON) to send notifications to another user desktop - so, I can imagine someone defacing somehow the "nobody" account then bombing everybody logged in the box with Viagra advertising on desktop popups.

Also, you just demonstrate that KDE Plasma5 has a superior security, and it is NOT VULNERABLE at this particular security issue.

I suggest you to not rely your work on existence of this particular security issue, which probably will be fixed sooner or later by the XFCE and GNOME developers.
I'm running the cron as my own user while I'm logged in. I don't see how this would be a problem.
 
Old 03-22-2021, 06:52 AM   #6
LuckyCyborg
Senior Member
 
Registered: Mar 2010
Posts: 3,499

Rep: Reputation: 3308Reputation: 3308Reputation: 3308Reputation: 3308Reputation: 3308Reputation: 3308Reputation: 3308Reputation: 3308Reputation: 3308Reputation: 3308Reputation: 3308
Quote:
Originally Posted by stormtracknole View Post
I'm running the cron as my own user while I'm logged in. I don't see how this would be a problem.
This is a very important information, you should have been specified.

Then, you need to have somehow an DBUS session started on every console, for this to work with Plasma5.

You can look for the threads regarding PipeWire about our tries to use a DBUS SESSION on the systemd style, started at a whatever user login.

It's not that simple, so IF you do not need that for a greater scope (like running the PipeWire daemons on console), probably better leave at how it is.

Last edited by LuckyCyborg; 03-22-2021 at 06:55 AM.
 
2 members found this post helpful.
Old 03-22-2021, 06:55 AM   #7
gegechris99
Senior Member
 
Registered: Oct 2005
Location: France
Distribution: Slackware 15.0 64bit
Posts: 1,159
Blog Entries: 5

Rep: Reputation: 392Reputation: 392Reputation: 392Reputation: 392
Look at this thread how-to-use-slackpkg-check-updates-in-a-script for a way to get and set DBUS_SESSION_BUS_ADDRESS in a script before calling notify-send.
Code:
#!/bin/bash
/usr/bin/mkdir -p ~/.slackpkg
/usr/sbin/slackpkg check-updates | /usr/bin/sed -n '/available/ p' > ~/.slackpkg/updated-repo.txt
username=$(/usr/bin/whoami)
#pid=$(pgrep -u $username kded5)
pid=$(ps -u $username e | grep -m 1 DBUS_SESSION_BUS_ADDRESS | awk '{print $1}')
dbus=$(grep -z DBUS_SESSION_BUS_ADDRESS /proc/$pid/environ | sed 's/DBUS_SESSION_BUS_ADDRESS=//')
export DBUS_SESSION_BUS_ADDRESS=$dbus
[ -s ~/.slackpkg/updated-repo.txt ] && /usr/bin/notify-send -i dialog-warning "[ S L A C K P K G ]" "Available updates"
 
1 members found this post helpful.
Old 03-22-2021, 07:02 AM   #8
stormtracknole
Senior Member
 
Registered: Aug 2005
Distribution: Slackware, RHEL
Posts: 1,259

Original Poster
Rep: Reputation: 231Reputation: 231Reputation: 231
Quote:
Originally Posted by gegechris99 View Post
Look at this thread how-to-use-slackpkg-check-updates-in-a-script for a way to get and set DBUS_SESSION_BUS_ADDRESS in a script before calling notify-send.
Code:
#!/bin/bash
/usr/bin/mkdir -p ~/.slackpkg
/usr/sbin/slackpkg check-updates | /usr/bin/sed -n '/available/ p' > ~/.slackpkg/updated-repo.txt
username=$(/usr/bin/whoami)
#pid=$(pgrep -u $username kded5)
pid=$(ps -u $username e | grep -m 1 DBUS_SESSION_BUS_ADDRESS | awk '{print $1}')
dbus=$(grep -z DBUS_SESSION_BUS_ADDRESS /proc/$pid/environ | sed 's/DBUS_SESSION_BUS_ADDRESS=//')
export DBUS_SESSION_BUS_ADDRESS=$dbus
[ -s ~/.slackpkg/updated-repo.txt ] && /usr/bin/notify-send -i dialog-warning "[ S L A C K P K G ]" "Available updates"
Very nice!! Thank you. I'll try that and report back.

Quote:
Originally Posted by LuckyCyborg View Post
This is a very important information, you should have been specified.

Then, you need to have somehow an DBUS session started on every console, for this to work with Plasma5.

You can look for the threads regarding PipeWire about our tries to use a DBUS SESSION on the systemd style, started at a whatever user login.

It's not that simple, so IF you do not need that for a greater scope (like running the PipeWire daemons on console), probably better leave at how it is.
You are right. My apologies for that. I blame the fact that it is still early in the morning where I live and I have yet to have my coffee.
 
Old 03-22-2021, 07:45 AM   #9
stormtracknole
Senior Member
 
Registered: Aug 2005
Distribution: Slackware, RHEL
Posts: 1,259

Original Poster
Rep: Reputation: 231Reputation: 231Reputation: 231
Well, no matter what option I use, notify-send nor kdialog works. I even tried all the options in that thread. The script works fine of course when running from a terminal. I'm pretty stumped. This shouldn't be this difficult. :/
 
Old 03-22-2021, 08:02 AM   #10
gegechris99
Senior Member
 
Registered: Oct 2005
Location: France
Distribution: Slackware 15.0 64bit
Posts: 1,159
Blog Entries: 5

Rep: Reputation: 392Reputation: 392Reputation: 392Reputation: 392
Can you publish your script as well as the result of "crontab -l"?
Thanks.
 
Old 03-22-2021, 08:05 AM   #11
Chuck56
Member
 
Registered: Dec 2006
Location: Colorado, USA
Distribution: Slackware
Posts: 930

Rep: Reputation: 479Reputation: 479Reputation: 479Reputation: 479Reputation: 479
My sendmail server uses a procmail initiated script that notifies both Plasma/KDE5 desktop & Android phone for inbound email.

Here's the desktop function from the script:
Code:
desktop () {

  # local variables & arrays
  declare notify

  # args: [1]from [2]subject [3]user [4]system
  # use dbus, not display, sample:
  # DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-fO9P532lUo
  # ,guid=e39481e97ebfba51d679a1295ef5e9f5
  # get dbus-session & notify over ssh
  notify="dbus=\$(ps -u $3 -o cmd e \
    | grep '^/usr/bin/kded5' \
    | tr ' ' '\n' \
    | grep DBUS_SESSION_BUS_ADDRESS)
    export \$dbus
    notify-send -a Sendmail -t 10000 '$1' '$2'"
  bash_print "$notify" | ssh $3@$4 'bash -s'

  unset -f $FUNCNAME # unload function
} # END desktop
Hope that helps.
 
1 members found this post helpful.
Old 03-22-2021, 08:50 AM   #12
stormtracknole
Senior Member
 
Registered: Aug 2005
Distribution: Slackware, RHEL
Posts: 1,259

Original Poster
Rep: Reputation: 231Reputation: 231Reputation: 231
Ugh, my mistake.

Using:
Code:
username=$(/usr/bin/whoami)
export DBUS_SESSION_BUS_ADDRESS=$(ps -u $username e | grep -Eo 'dbus-daemon.*ADDRESS=unix:abstract=/tmp/dbus-[A-Za-z0-9]{10}' | tail -c35)
worked. I forgot to add export the first time around. Now this is working as intended. Thank you all for the help!
 
Old 03-22-2021, 09:02 AM   #13
stormtracknole
Senior Member
 
Registered: Aug 2005
Distribution: Slackware, RHEL
Posts: 1,259

Original Poster
Rep: Reputation: 231Reputation: 231Reputation: 231
One more thing that I should note is that kdialog does not work even with this environment. Only notify-send does. Perhaps kdialog requires some extra bit of configuration. Just wanted to note that for future reference.
 
Old 03-22-2021, 09:32 PM   #14
0XBF
Member
 
Registered: Nov 2018
Distribution: Slackware
Posts: 765

Rep: Reputation: 863Reputation: 863Reputation: 863Reputation: 863Reputation: 863Reputation: 863Reputation: 863
The way plasma is launched in slackware is incorrect imo and fails to set DBUS_SESSION_BUS_ADDRESS properly on launch. Its done correctly for xfce so thats why that works, no idea what happens in gnome because I'm not using that at the moment.

If you are launching plasma from init 3 you can edit your ~/.xinitrc file to correct the behaviour. Look for the line
Code:
dbus-launch --sh-syntax --exit-with-session startplasma-x11
and change it to
Code:
dbus-run-session startplasma-x11
or
Code:
eval `dbus-launch --sh-syntax --exit-with-session startplasma-x11`
or even
Code:
/usr/lib64/plasma-dbus-run-session-if-needed startplasma-x11
Any of the above will set the DBUS_SESSION_BUS_ADDRESS environment variable properly. The problem is that "dbus-launch --sh-syntax" echos syntax to set the DBUS_SESSION_BUS_ADDRESS when it completes but that still requires the "eval" to actually set it. The alternative dbus-run-session command does the same thing and sets the variable automatically. The last command checks if theres already a dbus and uses dbus-run-session if it needs to.

Same problem is in the wayland launching script "/usr/bin/startkwayland", you can apply the same fix there. Also applies to the init 4 lanuch of x11 plasma in " /usr/share/xsessions/plasma.desktop". Whichever you use just fix it there. Then you shouldn't have to resort to hacks to get the DBUS_SESSION_BUS_ADDRESS variable.

Been fixing this for a while now in my installs, hoping to see it fixed in slackware 15...
 
5 members found this post helpful.
Old 03-23-2021, 05:25 AM   #15
stormtracknole
Senior Member
 
Registered: Aug 2005
Distribution: Slackware, RHEL
Posts: 1,259

Original Poster
Rep: Reputation: 231Reputation: 231Reputation: 231
Quote:
Originally Posted by 0XBF View Post
The way plasma is launched in slackware is incorrect imo and fails to set DBUS_SESSION_BUS_ADDRESS properly on launch. Its done correctly for xfce so thats why that works, no idea what happens in gnome because I'm not using that at the moment.

If you are launching plasma from init 3 you can edit your ~/.xinitrc file to correct the behaviour. Look for the line
Code:
dbus-launch --sh-syntax --exit-with-session startplasma-x11
and change it to
Code:
dbus-run-session startplasma-x11
or
Code:
eval `dbus-launch --sh-syntax --exit-with-session startplasma-x11`
or even
Code:
/usr/lib64/plasma-dbus-run-session-if-needed startplasma-x11
Any of the above will set the DBUS_SESSION_BUS_ADDRESS environment variable properly. The problem is that "dbus-launch --sh-syntax" echos syntax to set the DBUS_SESSION_BUS_ADDRESS when it completes but that still requires the "eval" to actually set it. The alternative dbus-run-session command does the same thing and sets the variable automatically. The last command checks if theres already a dbus and uses dbus-run-session if it needs to.

Same problem is in the wayland launching script "/usr/bin/startkwayland", you can apply the same fix there. Also applies to the init 4 lanuch of x11 plasma in " /usr/share/xsessions/plasma.desktop". Whichever you use just fix it there. Then you shouldn't have to resort to hacks to get the DBUS_SESSION_BUS_ADDRESS variable.

Been fixing this for a while now in my installs, hoping to see it fixed in slackware 15...
Nice!! Thank you for pointing this out.
 
  


Reply

Tags
cron, kde, notifications, plasma



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: KDE Frameworks 5.55 Released for KDE Plasma 5.15, Improves Android Notifications LXer Syndicated Linux News 0 02-12-2019 09:51 AM
LXer: KDE Frameworks 5.54 Released for KDE Plasma 5.15, Adds Android Notifications LXer Syndicated Linux News 0 01-13-2019 05:42 PM
[SOLVED] Getting KDE Plasma 5 Notifications to stick around DJOtaku Linux - Desktop 3 11-03-2016 12:55 PM
Package power limit notifications & Core power limit notifications anon091 Linux - Newbie 6 12-14-2012 05:39 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 03:45 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration