![]() |
[Solved]dbus-send --type=method_call --dest=org.freedesktop.Notifications - problem with root privileges
1 Attachment(s)
Hello, and excuse me in advance, if this was covered before - ho ever, despite extensive searching, I wasn't able to find an answer. This explanation is going to be quite long, but I want to provide as much info as I can.
I develop some simple script (showing certain "glance" info derived from i2cget, based on shadowjk's bq27200 script), which put output to screen as maemo native notify. Basically, script contains 2 part - one for gathering and calculating info - based (mostly) on work by shadowjk - and second, forwarding output to screen. For printing output, I use: Code:
dbus-send --type=method_call --dest=org.freedesktop.Notifications /org/freedesktop/Notifications org.freedesktop.Notifications.SystemNoteDialog string:"content-here-blablabla" uint32:0 string:"" Side note: I was using this method before to show notification info, derived from bq27x00 module (cat sys/class/power_supply/bq27200 etc.), and it worked like a charm - thanks to Nicolai, who helped me to understand calling upon notifications. Gathering data from i2cget require root privileges - and here, the problem begin. For unknown reason, script works as it should when called from terminal, after "root" command (via rootsh package), but refuse to work when privileges were gained by "sudo gainroot". Furthermore, adding script as .sudoers result in same output, as when called after "sudo gainroot" - it prove that sudoers file is created properly (I think), but doesn't solve problem. When called after "root", no errors, and notification info pop-out with correct data. When called after "sudo gainroot", or with "sudo" after .sudoers created, output in terminal is: Code:
Failed to open connection to "session" message bus: (null) What even more strange, bq27200.sh (script by shadowjk, that I used as base) works flawlessly with "sudo" after creating .sudoer for it. Also, using notification pop-up method (dbus-send etc), inside script that doesn't contain parts requiring root access (so, in my case, particularly parts from bq27200.sh, that works stand-alone) also result in no-problem. So, I got troubles only, when using script that contain *BOTH* gathering data requiring root, and displaying via aforementioned dbus-send method. As result, I can't use this script from any kind of shortcut (desktop, hardware, whatever) - only from terminal, after "root". I've searched solid few days for possible solution - hence the "discovery" about it performing well with "root", but failing after "sudo gainroot" - but I'm still scratching my head clueless. I'm attaching current version of script here (renamed to .sh.txt, to upload via forum mechanism), in case anyone want to try on her/his device (it may be little messy, it's developing version :P ). Any help/clues *really* much appreciated. |
Re: dbus-send --type=method_call --dest=org.freedesktop.Notifications - problem with root privileges
Prefix dbus-send with run-standalone.sh
Code:
run-standalone.sh dbus-send --type=method_call --dest=org.freedesktop.Notifications /org/freedesktop/Notifications org.freedesktop.Notifications.SystemNoteDialog string:"Voltage: $VOLT |
Re: dbus-send --type=method_call --dest=org.freedesktop.Notifications - problem with root privileges
that is true you need
run-standalone.sh before the script cause when you type root it runs that script [standalone] with anything also in user but not with sudo gainroot you can also : Code:
sudo run-standalone.sh dbus-send --type=method_call --dest=org.freedesktop.Notifications /org/freedesktop/Notifications Code:
echo "user ALL=(ALL) NOPASSWD: ALL" >> everybody.sudoers also double root is possible |
Re: dbus-send --type=method_call --dest=org.freedesktop.Notifications - problem with root privileges
Quote:
Quote:
|
Re: dbus-send --type=method_call --dest=org.freedesktop.Notifications - problem with root privileges
Thank You MohammadAG, obviously, it works like a charm now!
I must write this - it keeps me amazed how knowledgeable and competitive some people here are. Really, no sugar-coating - I could probably search for this +- forever without *any* success, and You MohammadAG "just" throw answer out of Your head. --- Anyway, possibly last question on this topic - I like to learn when I've a chance - is there a way to run sh script with "sudo" via .desktop shortcut *without* terminal window flashing (turning on and closing after executing)? I know, this one is probably simple newbie thing, but I've searched many threads about shortcut making on forum (not to mention wiki), and while .sh scripts that doesn't need root privileges run just fine without terminal, when invoked via "Exec=" in .desktop, the best thing I could achieve to run root things was to Code:
Exec=/usr/bin/osso-xterm 'sudo bnf' Every attempts with "bnf.sh | sudo gainroot", busybox sh -c 'usr/bin/bnf.sh | sudo gainroot' etc., failed miserably. Thanks in advance for help, and really, enormous thanks for last one, I'm really impressed. // Edit Also thanks Karam, although I really would not like to open system for everything, just for this little script :) Nevertheless, thanks for trying to help. |
Re: dbus-send --type=method_call --dest=org.freedesktop.Notifications - problem with root privileges
What happens if you use Exec=sudo script.sh?
(You'll need an entry in sudoers.d, limit it to your script only of course). If you're seeing a black window, that's the fake window hildon-desktop creates when an icon is clicked, so a real window replaces it later on, you can disable this by adding Code:
X-App-Loading-Image=none |
Re: dbus-send --type=method_call --dest=org.freedesktop.Notifications - problem with root privileges
Thanks for answer, ho ever, using Exec=sudo script.sh does nothing. Literally nothing, just nothing happens. That was the first thing I've tried after creating entry in sudoers.d :p I also got X-App-Loading-Image=none set.
When I execute "sudo script.sh" from terminal, it works as it should, so, probably, sudoers entry is ok. // Edit I've also tried to save terminal output from running desktop file, by: Exec=sudo script.sh > /home/user/MyDocs/scriptlog.txt (I've found it, while searching for solution - I don't know if it's right command) ...and scriptlog.txt was created, ho ever, contained nothing inside. |
Re: dbus-send --type=method_call --dest=org.freedesktop.Notifications - problem with root privileges
Quote:
hmm would you please explain more Mohammad ? didn't really get it Quote:
ok then i see but personally never faced security problem doing that what might happen especially for a device like N900 ? oh and you know something i'm really happy because i see an arabic person has a great knowledge about something might be really Sophisticated for a lot of people :) i wish you would never visit syria you will loose your mind because of the knowledge of it's people -_- |
Re: dbus-send --type=method_call --dest=org.freedesktop.Notifications - problem with root privileges
Quote:
|
Re: dbus-send --type=method_call --dest=org.freedesktop.Notifications - problem with root privileges
Sorry for bumping, but maybe anyone have idea about it?:
Quote:
Code:
sudo bnf.sh For reference, I'm attaching actual version of script, + (more important for current problem, I think) .desktop file. Could anyone knowledgeable check it inside device? Maybe it's just "my" problem, not code problem? Note: Currently, there is: Code:
Exec=sudo bnf.sh Code:
Exec='sudo bnf.sh' I can get it to (semi) work by: Code:
Exec=osso-xterm -e "sudo bnf.sh" // Edit Using ShortcutD, I can set: Code:
sudo bnf.sh I got plans for some (maybe) useful and more complicated scripts, that would be handy with desktop shortcuts for them, but every single one require root. I have no idea why the heck it doesn't want to work with: Exec=sudo <name>.sh (Actual version is here: http://talk.maemo.org/showpost.php?p...3&postcount=17) |
All times are GMT. The time now is 04:04. |
vBulletin® Version 3.8.8