[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gtk-app-devel
Subject:    Re: No protocol specified error
From:       Felipe Borges <felipe10borges () gmail ! com>
Date:       2017-10-20 11:33:00
Message-ID: CAM8h4FPeZSmA0j79pPoaEPAHQs2as-cxhSrX6z8-gb2maOMfJA () mail ! gmail ! com
[Download RAW message or body]

On Fri, Oct 20, 2017 at 1:18 PM, Lokesh Chakka
<lvenkatakumarchakka@gmail.com> wrote:
> Dear Felipe,
>
> Thanks for the information.
> Is it possible to login with my credentials and execute as sudo ./a.out.
>
> Can u help me how to make it work ?

Running GUI applications as root is hardly discouraged.

What you should be going for is to develop an application which runs
as a normal user and uses PolicyKit[0] to gain administrator
privileges whenever is necessary.

[0] https://www.freedesktop.org/software/polkit/docs/latest/polkit.8.html

>
>
>
>
> Thanks & Regards
> --
> Lokesh Chakka,
> Mobile: 9731023458
>
> On Fri, Oct 20, 2017 at 4:43 PM, Felipe Borges <felipe10borges@gmail.com>
> wrote:
>>
>> On Fri, Oct 20, 2017 at 1:01 PM, Lokesh Chakka
>> <lvenkatakumarchakka@gmail.com> wrote:
>> > Hello,
>> >
>> > I am using simple program
>> >
>> > #include <gtk/gtk.h>
>> >
>> > int main(int argc, char *argv[])
>> > {
>> >     GtkWidget *window;
>> >     gtk_init(NULL, NULL);
>> >     window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
>> >     gtk_widget_show(window);
>> >     g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit),
>> > NULL);
>> >     gtk_main();
>> >     return 0;
>> > }
>> >
>> > I compiled it using gcc simple.c `pkg-config --cflags gtk+-3.0 --libs`
>> > if I do ./a.out, GUI is showing up.
>> >
>> > but if I do "sudo ./a.out", I am seeing the following error :
>> >
>> > ================================================
>> > $ sudo ./a.out
>> > No protocol specified
>> > Unable to init server: Could not connect: Connection refused
>> >
>> > (a.out:7961): Gtk-WARNING **: cannot open display: :0
>> > ================================================
>> >
>> > As my application back end needs root privileges, I need to open the GUI
>> > using sudo only.
>> > Can some one help in fixing this issue ?
>> >
>> > The same code was working fine in Ubuntu 17.04. But I am facing this
>> > issue
>> > after upgrading to Ubuntu 17.10.
>>
>> Ubuntu 17.10 has switched to the Wayland display server, which is
>> designed to fix the security issues existent in X.
>>
>> Wayland only allows the user who started the X server to connect clients
>> to it.
>>
>> For more info, see https://bugzilla.redhat.com/1266771
>>
>> >
>> > Thanks
>> > --
>> > Lokesh Chakka,
>> > Mobile: 9731023458
>> > _______________________________________________
>> > gtk-app-devel-list mailing list
>> > gtk-app-devel-list@gnome.org
>> > https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
>
>
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic