无法摆脱 x11vnc 输出

无法摆脱 x11vnc 输出

我使用的是 Ubuntu 系统,该系统的显示屏上设置了触摸屏:0。我希望能够从 Windows 远程控制该触摸屏,因此我设置了 x11vnc。效果很好。但这是设置:

我有两个用户(不包括root)。一名自动登录触摸屏的受限制用户(基本上没有权限,也没有密码),以及一名具有复杂密码、sudo 权限等的完全配置用户。我只关心当受限制用户登录(触摸屏)时启动 x11vnc变为活动状态),所以我将命令放在x11vnc -loop &文件末尾/home/restricted/.profile。工作正常。但请注意,它必须是后台进程,因为该用户稍后必须运行其他命令(对人类用户隐藏)。

我遇到的问题是 x11vnc 的输出噪音很大。特别是如果您不使用密码(我不使用密码),并且这是一个循环,因此它会不断重复。通常这不会成为问题,但不仅将输出重定向到 /dev/null 不起作用(如下所述),而且当我通过 ssh 登录时输出出现在其他用户的终端上(这实际上是很烦人,因为我使用该帐户进行维护,并且当屏幕上充满了某些后台进程的输出时,它无法执行任何操作,这是我得到的输出示例:

--- 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 ---

这只是不断重复。

它对我大喊无法打开显示屏,但它可以工作。我猜测这是因为受限用户已经运行了此命令并且连接正常,但现在该用户也尝试这样做,因此无法连接。

为什么会发生这种情况?我的理解显然存在一些漏洞。以下是我尝试过的不同方法:


将输出重定向到 /dev/null

在同一位置,/home/restricted/.profile我尝试将现有命令替换x11vnc -loop &x11vnc -loop > /dev/null 2>&1 &.

这具有零影响,输出仍然在其他用户的终端上并且(显然)没有消失。


使用 nohup 运行命令

再次在 中/home/restricted/.profile,我尝试将现有命令替换x11vnc -loop &nohup x11vnc -loop &

再一次,这根本没有任何效果。输出仍然存在。 Nohup 甚至没有创建 nohup.out 文件。至少,我没找到。

为了完成,我又试了nohup x11vnc -loop > /dev/null 2>&1 &一遍,没有任何改变。


将 x11vnc 作为守护进程启动

在这里,我开始意识到我做错了什么。我想,也许是因为/home/restricted/.profile这种东西放错了地方。因此,我制作了一个在启动时运行的脚本,并按照框架文件的示例/etc/init.d进行了链接。update-rc.d

x11vnc 再次工作,但输出出现在我的所有终端上。


在屏幕中启动 x11vnc

我最后一次尝试修复这个问题是将命令放入屏幕会话中。 Screen 通常会为我解决这样的问题...但这次不行。

在 中/home/restricted/.profile,我替换x11vnc -loop &screen -d -R x11vnc x11vnc -loop

这次,x11vnc 不再工作(无法通过 Windows 客户端连接),但所有终端上仍然有输出。


再说一遍,显然我对 x11vnc 或在启动时生成进程有些不理解。

正如您可能从上面的内容中看出的那样,我已经进行此故障排除一段时间了,并且在网络上找不到任何与此相关的其他内容。所以这里的帮助会很棒。提前致谢。

答案1

重定向>&输出对我有用。

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

相关内容