首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法摆脱x11vnc输出

无法摆脱x11vnc输出
EN

Unix & Linux用户
提问于 2016-05-20 15:28:47
回答 1查看 1.8K关注 0票数 3

我在一个Ubuntu系统上,它的触摸屏设置在显示器上:0。我想从Windows远程控制这个触摸屏,所以我设置了x11vnc。效果很好。但这是一个设置:

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

我遇到的问题是,x11vnc的输出非常嘈杂。特别是如果您不使用密码(我不使用),而且它是一个循环,所以它只会继续重复。通常这不会是一个问题,但不仅仅是将输出重定向到/dev/null不工作(下面将解释),而且当我通过ssh登录到另一个用户终端时,输出会出现在另一个用户的终端上(这真的很烦人,因为我使用这个帐户进行维护,并且当屏幕上充满了某个后台进程的输出时,不可能做任何事情。下面是我得到的输出的一个例子:

代码语言:javascript
复制
--- 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 > /dev/null 2>&1 &替换现有的命令x11vnc -loop &

这是零效果,输出仍然是在其他用户的终端,(显然)没有消失。

使用nohup

运行命令

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

这又一次完全没有效果。产出仍在那里。Nohup甚至没有创建一个nohup.out文件。至少我找不到。

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

将x11vnc作为守护进程

启动

在这里,我开始意识到我做错了什么。我想这可能是因为/home/restricted/.profile放这种东西的地方不对。因此,我在/etc/init.d中创建了一个脚本,以便在引导时运行,并按照框架文件的示例使用update-rc.d创建链接。

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

在屏幕

中启动x11vnc

我最后一次尝试修复这个东西是在屏幕会话中抛出这个命令。屏幕通常会为我解决这样的问题..。但这次不行。

/home/restricted/.profile中,我用screen -d -R x11vnc x11vnc -loop代替了x11vnc -loop &

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

同样,很明显,我对x11vnc或在引导时生成一个进程都不太了解。

正如您可以从上面得知的那样,我已经在此故障排除了一段时间了,并且在网上找不到任何关于这个问题的信息。所以这里的帮助会很棒的。提前谢谢。

EN

回答 1

Unix & Linux用户

发布于 2023-03-17 22:39:05

重定向输出的>&为我工作。

代码语言:javascript
复制
x11vnc -repeat -noxdamage -ncache 10 -forever -loop -rfbauth &> x11vnc.log
票数 0
EN
页面原文内容由Unix & Linux提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://unix.stackexchange.com/questions/284481

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档