-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Running a program with root privileges resulted in the runtime error: invalid memory address or nil pointer dereference #3120
Comments
Would you mind sharing the stack trace as well? Without it, we don’t know what or where it is crashing. Also, I would suggest against running |
Oh, I'm sorry, there is stack trace:
And thanks for the advice. |
Hmm. It looks to me like the crash is in https://github.com/godbus/dbus. Does the same crash happen if you remove the system tray? If it doesn't you can try sending a notification (using |
My guess would be that due to a security model the root user cannot connect to the dbus service. |
Yeah, everything works fine without system tray. As you said, I checked app.SendNotification() with root privileges, and it casted the error:
Example code:package main
import (
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/widget"
)
func main() {
a := app.New()
w := a.NewWindow("SysTray")
a.SendNotification(fyne.NewNotification("foo", "bar"))
w.SetContent(widget.NewLabel("Fyne System Tray"))
w.SetCloseIntercept(func() {
w.Hide()
})
w.ShowAndRun()
} |
Thanks for helping us narrowing down the issue. I suspect that there is some check that notifications are doing but systray doesn't. |
The notification code is slightly simpler as it is only a one of call. So it connect and check the connection before each notification. Less trouble there. It might be possible to have a process running as root access the same dbus path, but really it doesn't feel right. I would recommend building things in a two process way. One not root running the UI and one running as root, and making them communicate via some kind of protocol (could be the input/output of a process, a socket, ...). That would be a bit more align with Linux security practice. |
Fixed on develop |
Describe the bug:
I need to run program with root privileges for execution some bash command in runtime, but if program has system tray support It crushes.
To Reproduce:
Example code:
Device (please complete the following information):
The text was updated successfully, but these errors were encountered: