Page 1 of 2 12 LastLast
Results 1 to 10 of 17

Thread: Create a process with fork and launch a gui process , getting error No protocol specified

  1. #1

    Default Create a process with fork and launch a gui process , getting error No protocol specified

    I have a service which invoke a process say cust, In cust i did fork and exec to run firefox or any gui application. I am using path for firefox /usr/bin/X11/firefox.
    When i run my application and invoke fork to run firefox, i am getting below errors. 1.No protocol specified 2.Error: cannot open display: :0.0
    With different forum readings i found that X11 environment is not set. I tried to set environmental variables in service,process but nothing is help me.
    i tried to set XAUTHORITY=$HOME/.Xauthority and DISPLAY=:0.0 variables.
    I am using OpenSuSE 12.3 with GNOME.
    Service and application cust running as a root user.

    Please help to solve this issue.
    Thanks in advance.

  2. #2

    Default Re: Create a process with fork and launch a gui process , getting error No protocol specified

    And how do you run it as root?
    Normally programs run as root are not allowed to open windows on your user's X display.

    Try to use gnomesu to start your program as root, that should take care of the environment and authentication.

  3. #3

    Default Re: Create a process with fork and launch a gui process , getting error No protocol specified

    PS: See also this thread: https://forums.opensuse.org/english/...-programs.html (especially page 4)

    Basically you would have to grant root access to your display with "xhost" and you need to pass the "DISPLAY" environment variable so the process knows where to open the window.

    But a word of warning here: it is really not the best idea to run firefox as root...

  4. #4

    Default Re: Create a process with fork and launch a gui process , getting error No protocol specified

    Quote Originally Posted by wolfi323 View Post
    PS: See also this thread: https://forums.opensuse.org/english/...-programs.html (especially page 4)

    Basically you would have to grant root access to your display with "xhost" and you need to pass the "DISPLAY" environment variable so the process knows where to open the window.

    But a word of warning here: it is really not the best idea to run firefox as root...

    Thanks for valuable information.

    My service is running as a root.
    if i want to do fork and then do exec to launch firefox application for a logged in user(setuid() can use) or root,
    should i use execl("gnomesu", /usr/bin/X11/firefox",NULL ); or first call "xhost +local:root" later require application.
    Since i am not using shell to execute this commands, I am doing with programmatic way.

    Another thing i understood, make any non-root user powerful so that not ask for password(using file
    /etc/sudoers).

    Still i did not get clear picture , how can i use these in my application.


  5. #5

    Default Re: Create a process with fork and launch a gui process , getting error No protocol specified

    Quote Originally Posted by enggjiten View Post
    My service is running as a root.
    if i want to do fork and then do exec to launch firefox application for a logged in user(setuid() can use) or root,
    should i use execl("gnomesu", /usr/bin/X11/firefox",NULL );
    I got it that your service runs as root. But how do you start it, so it runs as root?
    What I proposed was to run your service by using "gnomesu". Calling execl("gnomesu", /usr/bin/X11/firefox",NULL ); in your service won't help you in any way, since the service is already running as root, not as user.

    or first call "xhost +local:root" later require application.
    You have to run xhost before that application tries to open a window. And you have to run xhost on the user's X display with the user's rights (not root!), so no use in calling it from inside your service.
    And it's "xhost +si:localuser:root" actually. "xhost +local:root" would grant access to ALL users on the local machine... (well, should be no problem if there aren't any others )

    Still i did not get clear picture , how can i use these in my application.
    That's a good question. Running the service with "gnomesu" should pass anything necessary to the service and later on through to that GUI application hopefully. (but I'm not sure, never tried that...)

    I still don't think it's wise to run a GUI application from that root service (and especially not a web browser).
    What are you trying to achieve exactly?

    I guess if you run the GUI program as the currently logged in user and pass a correctly set DISPLAY environment variable, it should work (even without xhost). But how would you know which user is logged in to an X session currently?

  6. #6
    Join Date
    Feb 2009
    Location
    Spain
    Posts
    25,547

    Default Re: Create a process with fork and launch a gui process , gettingerror No protocol specified

    On 2013-09-02 14:46, enggjiten wrote:

    > My service is running as a root.
    > if i want to do fork and then do exec to launch firefox application for
    > a logged in user(setuid() can use) or root,


    I don't remember I'd ever seen a service open directly any type of
    window or gui application. In Windows, yes, maybe, but not in Linux.

    Typically you ask user, in the documentation, to open separately firefox
    or whatever, after the service is started. A service does not display
    anything, it is silent. Instead a service logs output on files or syslog.


    On the other hand, there is a programming subforum here where you can
    ask all kinds of programming questions. You may ask a moderator to move
    this thread there - use the report button below and ask.


    --
    Cheers / Saludos,

    Carlos E. R.
    (from 12.3 x86_64 "Dartmouth" at Telcontar)

  7. #7
    Join Date
    Jun 2008
    Location
    Podunk
    Posts
    26,814
    Blog Entries
    15

    Default Re: Create a process with fork and launch a gui process , gettingerror No protocol specified

    On Mon 02 Sep 2013 11:56:02 AM CDT, enggjiten wrote:


    I have a service which invoke a process say cust, In cust i did fork and
    exec to run firefox or any gui application. I am using path for firefox
    /usr/bin/X11/firefox.
    When i run my application and invoke fork to run firefox, i am getting
    below errors. 1.No protocol specified 2.Error: cannot open display: :0.0
    With different forum readings i found that X11 environment is not set. I
    tried to set environmental variables in service,process but nothing is
    help me.
    i tried to set XAUTHORITY=$HOME/.Xauthority and DISPLAY=:0.0 variables.
    I am using OpenSuSE 12.3 with GNOME.
    Service and application cust running as a root user.
    Please help to solve this issue.
    Thanks in advance.


    Hi
    So does firefox need to be visible, or just running? I ask this because
    I had a radius monitoring program that needed to run in a GUI (as root)
    but no display, Xvfb came to the rescue here....

    Your not seeing an MIT-MAGIC-COOKIE error when you try to run your
    service?

    --
    Cheers Malcolm °¿° SUSE Knowledge Partner (Linux Counter #276890)
    openSUSE 12.3 (x86_64) GNOME 3.8.4 Kernel 3.7.10-1.16-desktop
    If you find this post helpful and are logged into the web interface,
    show your appreciation and click on the star below...


  8. #8

    Default Re: Create a process with fork and launch a gui process , getting error No protocol specified

    I guess if you run the GUI program as the currently logged in user and pass a correctly set DISPLAY environment variable, it should work (even without xhost). But how would you know which user is logged in to an X session currently?[/QUOTE]

    Let me explain you scenario.
    1. My service is just check for a process whether it is running or not, if some how it has stopped or exited service will revoke the process.
    2. Process is binary which is running many functionalists, one of that is run any binary. When i send binary name it should run it.
    3. firefox is just an example , i can pass wireshark or calc anything which is installed on desktop. For achieve this scenario i tried (in child mode): execlp(pX11Cmd,pX11Cmd,pArg,NULL); (pX11Cmd = /usr/bin/X11/firefox or /usr/bin/X11/wireshark).
    If i want to run netstat then output should come in some window. For window output i tried
    execl("/usr/bin/xterm","/usr/bin/xterm","-hold","-e", "bash", "-c",pCmd,pArg,(char*)0);

    4. For changing root session to non-root session, i tried setuid and setgid function to change the scope of the child process.
    5. Goal to achieve whatever binary name passed , that should display.

    6. Service and process should run for all users so that whatever user logged in he can use my application.

    Correct me i am doing something wrong.

  9. #9

    Default Re: Create a process with fork and launch a gui process , gettingerror No protocol specified

    Quote Originally Posted by robin_listas View Post
    On 2013-09-02 14:46, enggjiten wrote:

    > My service is running as a root.
    > if i want to do fork and then do exec to launch firefox application for
    > a logged in user(setuid() can use) or root,


    I don't remember I'd ever seen a service open directly any type of
    window or gui application. In Windows, yes, maybe, but not in Linux.

    Typically you ask user, in the documentation, to open separately firefox
    or whatever, after the service is started. A service does not display
    anything, it is silent. Instead a service logs output on files or syslog.


    On the other hand, there is a programming subforum here where you can
    ask all kinds of programming questions. You may ask a moderator to move
    this thread there - use the report button below and ask.


    --
    Cheers / Saludos,

    Carlos E. R.
    (from 12.3 x86_64 "Dartmouth" at Telcontar)

    Thanks for comment.
    I explained the scenario in comment#8.
    Service launch another process to do other thing.Process should launch the any application.
    If i move my process to some user mode will it help me to launch any application in gui format ?

  10. #10
    Join Date
    Aug 2010
    Location
    Chicago suburbs
    Posts
    12,608
    Blog Entries
    3

    Default Re: Create a process with fork and launch a gui process , getting error No protocol specified

    Quote Originally Posted by enggjiten View Post
    i tried to set XAUTHORITY=$HOME/.Xauthority and DISPLAY=:0.0 variables.
    I am using OpenSuSE 12.3 with GNOME.
    I'm pretty sure that Gnome does not use $HOME/.Xauthority -- it uses a temporary file somewhere. Check "$XAUTHORITY" when you are next logged into Gnome.
    openSUSE Leap 15.1; KDE Plasma 5;
    testing Leap 15.2Alpha

Page 1 of 2 12 LastLast

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •