Não consigo me livrar da saída x11vnc

Não consigo me livrar da saída x11vnc

Estou em um sistema Ubuntu que possui uma tela sensível ao toque configurada em exibição: 0. Eu queria poder controlar essa tela sensível ao toque remotamente no Windows, então configurei o x11vnc. Funciona muito bem. Mas aqui está a configuração:

Tenho dois usuários (excluindo root). Um usuário restrito (basicamente sem permissões e sem senha) que efetua login automaticamente na tela sensível ao toque e um usuário totalmente configurado com uma senha complexa, permissão sudo, etc. Eu realmente só me importo em iniciar o x11vnc quando o usuário restrito efetua login (tela sensível ao toque fica ativo), então coloquei o comando x11vnc -loop &no final do arquivo /home/restricted/.profile. Funciona bem. Observe, entretanto, que deve ser um processo em segundo plano porque há outros comandos que esse usuário deverá executar (ocultos do usuário humano) posteriormente.

O problema que estou tendo é que o x11vnc faz muito barulho em sua saída. Especialmente se você não usa uma senha (o que eu não uso), e é um loop que continua se repetindo. Normalmente isso não seria um problema, mas não apenas o redirecionamento da saída para /dev/null não está funcionando (explicado abaixo), mas a saída está aparecendo no terminal do outro usuário quando eu faço login via ssh nele (o que é realmente irritante porque eu uso essa conta para manutenção e é impossível fazer qualquer coisa quando sua tela está sendo preenchida com a saída de algum processo em segundo plano. Aqui está um exemplo da saída que recebo:

--- x11vnc loop: 1 ---

--- x11vnc loop: waiting for: 1551

###############################################################
#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#
#@                                                           @#
#@  **  WARNING  **  WARNING  **  WARNING  **  WARNING  **   @#
#@                                                           @#
#@        YOU ARE RUNNING X11VNC WITHOUT A PASSWORD!!        @#
#@                                                           @#
#@  This means anyone with network access to this computer   @#
#@  may be able to view and control your desktop.            @#
#@                                                           @#
#@ >>> If you did not mean to do this Press CTRL-C now!! <<< @#
#@                                                           @#
#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#
#@                                                           @#
#@  You can create an x11vnc password file by running:       @#
#@                                                           @#
#@       x11vnc -storepasswd password /path/to/passfile      @#
#@  or   x11vnc -storepasswd /path/to/passfile               @#
#@  or   x11vnc -storepasswd                                 @#
#@                                                           @#
#@  (the last one will use ~/.vnc/passwd)                    @#
#@                                                           @#
#@  and then starting x11vnc via:                            @#
#@                                                           @#
#@      x11vnc -rfbauth /path/to/passfile                    @#
#@                                                           @#
#@  an existing ~/.vnc/passwd file from another VNC          @#
#@  application will work fine too.                          @#
#@                                                           @#
#@  You can also use the -passwdfile or -passwd options.     @#
#@  (note -passwd is unsafe if local users are not trusted)  @#
#@                                                           @#
#@  Make sure any -rfbauth and -passwdfile password files    @#
#@  cannot be read by untrusted users.                       @#
#@                                                           @#
#@  Use x11vnc -usepw to automatically use your              @#
#@  ~/.vnc/passwd or ~/.vnc/passwdfile password files.       @#
#@  (and prompt you to create ~/.vnc/passwd if neither       @#
#@  file exists.)  Under -usepw, x11vnc will exit if it      @#
#@  cannot find a password to use.                           @#
#@                                                           @#
#@                                                           @#
#@  Even with a password, the subsequent VNC traffic is      @#
#@  sent in the clear.  Consider tunnelling via ssh(1):      @#
#@                                                           @#
#@    http://www.karlrunge.com/x11vnc/#tunnelling            @#
#@                                                           @#
#@  Or using the x11vnc SSL options: -ssl and -stunnel       @#
#@                                                           @#
#@  Please Read the documention for more info about          @#
#@  passwords, security, and encryption.                     @#
#@                                                           @#
#@    http://www.karlrunge.com/x11vnc/faq.html#faq-passwd    @#
#@                                                           @#
#@  To disable this warning use the -nopw option, or put     @#
#@  'nopw' on a line in your ~/.x11vncrc file.               @#
#@                                                           @#
#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#
###############################################################
20/05/2016 10:53:18 x11vnc version: 0.9.13 lastmod: 2011-08-10  pid: 1551
20/05/2016 10:53:18 XOpenDisplay("") failed.
20/05/2016 10:53:18 Trying again with XAUTHLOCALHOSTNAME=localhost ...
20/05/2016 10:53:18
20/05/2016 10:53:18 *** XOpenDisplay failed. No -display or DISPLAY.
20/05/2016 10:53:18 *** Trying ":0" in 4 seconds.  Press Ctrl-C to abort.
20/05/2016 10:53:18 *** 1 2 3 4
Invalid MIT-MAGIC-COOKIE-1 key20/05/2016 10:53:22 XOpenDisplay(":0") failed.
20/05/2016 10:53:22 Trying again with XAUTHLOCALHOSTNAME=localhost ...
Invalid MIT-MAGIC-COOKIE-1 key20/05/2016 10:53:22 XOpenDisplay(":0") failed.
20/05/2016 10:53:22 Trying again with unset XAUTHLOCALHOSTNAME ...
Invalid MIT-MAGIC-COOKIE-1 key20/05/2016 10:53:22

20/05/2016 10:53:22 ***************************************
20/05/2016 10:53:22 *** XOpenDisplay failed (:0)

*** x11vnc was unable to open the X DISPLAY: ":0", it cannot continue.
*** There may be "Xlib:" error messages above with details about the failure.

Some tips and guidelines:

** An X server (the one you wish to view) must be running before x11vnc is
   started: x11vnc does not start the X server.  (however, see the -create
   option if that is what you really want).

** You must use -display <disp>, -OR- set and export your $DISPLAY
   environment variable to refer to the display of the desired X server.
 - Usually the display is simply ":0" (in fact x11vnc uses this if you forget
   to specify it), but in some multi-user situations it could be ":1", ":2",
   or even ":137".  Ask your administrator or a guru if you are having
   difficulty determining what your X DISPLAY is.

** Next, you need to have sufficient permissions (Xauthority)
   to connect to the X DISPLAY.   Here are some Tips:

 - Often, you just need to run x11vnc as the user logged into the X session.
   So make sure to be that user when you type x11vnc.
 - Being root is usually not enough because the incorrect MIT-MAGIC-COOKIE
   file may be accessed.  The cookie file contains the secret key that
   allows x11vnc to connect to the desired X DISPLAY.
 - You can explicitly indicate which MIT-MAGIC-COOKIE file should be used
   by the -auth option, e.g.:
       x11vnc -auth /home/someuser/.Xauthority -display :0
       x11vnc -auth /tmp/.gdmzndVlR -display :0
   you must have read permission for the auth file.
   See also '-auth guess' and '-findauth' discussed below.

** If NO ONE is logged into an X session yet, but there is a greeter login
   program like "gdm", "kdm", "xdm", or "dtlogin" running, you will need
   to find and use the raw display manager MIT-MAGIC-COOKIE file.
   Some examples for various display managers:

     gdm:     -auth /var/gdm/:0.Xauth
              -auth /var/lib/gdm/:0.Xauth
     kdm:     -auth /var/lib/kdm/A:0-crWk72
              -auth /var/run/xauth/A:0-crWk72
     xdm:     -auth /var/lib/xdm/authdir/authfiles/A:0-XQvaJk
     dtlogin: -auth /var/dt/A:0-UgaaXa

   Sometimes the command "ps wwwwaux | grep auth" can reveal the file location.

   Starting with x11vnc 0.9.9 you can have it try to guess by using:

              -auth guess

   (see also the x11vnc -findauth option.)

   Only root will have read permission for the file, and so x11vnc must be run
   as root (or copy it).  The random characters in the filenames will of course
   change and the directory the cookie file resides in is system dependent.

See also: http://www.karlrunge.com/x11vnc/faq.html

 --- x11vnc loop: sleeping 2000 ms ---


 --- x11vnc loop: 2 ---

E isso se repete indefinidamente.

Está gritando comigo por não conseguir abrir a tela, mas funciona. Suponho que isso ocorre porque o usuário restrito já executou esse comando e conectou-se bem, mas agora esse usuário também está tentando fazer o mesmo, por isso não consegue se conectar.

Por que isso está acontecendo? Há claramente alguma lacuna no meu entendimento. Aqui estão as diferentes coisas que tentei:


Redirecionando a saída para /dev/null

No mesmo local, /home/restricted/.profiletentei substituir o comando existente x11vnc -loop &por x11vnc -loop > /dev/null 2>&1 &.

Isso teve efeito zero, a saída ainda estava no terminal de outro usuário e (obviamente) não desapareceu.


Executando comando com nohup

Novamente em /home/restricted/.profile, tentei substituir o comando existente x11vnc -loop &por nohup x11vnc -loop &.

Mais uma vez, isso não teve efeito algum. A saída ainda estava lá. Nohup nem criou um arquivo nohup.out. Pelo menos, não consegui encontrar.

Para completar, também tentei nohup x11vnc -loop > /dev/null 2>&1 &novamente, nada mudou.


Iniciando x11vnc como um daemon

Aqui, comecei a perceber que estava fazendo algo errado. Achei que talvez fosse porque /home/restricted/.profileera o lugar errado para colocar esse tipo de coisa. Então fiz um script /etc/init.dpara ser executado na inicialização e fiz o link seguindo update-rc.do exemplo do arquivo esqueleto.

Mais uma vez, o x11vnc funcionou, mas a saída estava em todos os meus terminais.


Iniciando x11vnc na tela

Minha última tentativa de consertar isso foi lançar o comando em uma sessão de tela. A tela geralmente corrige problemas como esse para mim... Mas não desta vez.

Em /home/restricted/.profile, eu substituí x11vnc -loop &porscreen -d -R x11vnc x11vnc -loop

Desta vez, o x11vnc não funcionou mais (não foi possível conectar via cliente Windows), mas a saída AINDA estava em todos os terminais.


Novamente, claramente há algo que não estou entendendo sobre o x11vnc ou sobre a geração de um processo na inicialização.

Como você deve ter percebido acima, estou nessa solução de problemas há algum tempo e não consigo encontrar mais nada na web sobre isso. Então, ajudar aqui seria incrível. Desde já, obrigado.

Responder1

A >&saída para redirecionar funcionou para mim.

x11vnc -repeat -noxdamage -ncache 10 -forever -loop -rfbauth &> x11vnc.log

informação relacionada