x11vnc-Server beim booten starten

oli1301

Active Member
Hallo zusammen,

wir stellen die Clients im Unternehmen von Ubuntu auf FreeBSD um. Dazu haben wir ein fertiges Jumpstart-Script. Geplant ist Slim + Xfce
Zur Fernwartung braucht man zwischen FreeBSD-Clients ja auch einen VNC-Server. Dieser soll beim booten automatisch gestartet werden. Das soll auch mit in das Jumpstart-Script rein, allerdings habe ich noch keine Lösung gefunden wie ich das anstelle. Unter Xfce gibt es die Möglichkeit "automatisch Startende Anwendungen" anzulegen allerdings werden die im Home angelegt. Für das Script müsste das allerdings an einem globalen Ort abgelegt werden.

Habs schon mit einem Eintrag in der rc.conf und einem dazugehörigen Script probiert welches ich im Netz gefunden und angepasst habe.

Code:
#!/bin/sh
#

# PROVIDE: x11vnc
# REQUIRE: DAEMON
# KEYWORD: shutdown

. /etc/rc.subr

name="x11vnc"
rcvar=`set rcvar`
load_rc_config $name
command="x11vnc -nopw -forever -viewonly -accept popup -display:0"

x11vnc_enable=${x11vnc_enable-"NO"}
x11vnc_pidfile=${x11vnc_pidfile-"/var/run/x11vnc.pid"}

pidfile="${x11vnc_pidfile}"

run_rc_command "$1"

Allerdings bekomme ich immer die Fehlermeldung


/usr/local/etc/rc.d/x11vnc: WARNING: run_rc_command: cannot run x11vnc -nopw -forever -viewonly -accept popup -display:0

Das ist der Artikel: https://forums.freebsd.org/threads/x11vnc-doesnt-run-from-startup-script.8786/
Allerdings nutzt der xdm. Am Ende des Artikels schreibt er, damits klappt hat er das Script nicht in
Code:
/usr/local/etc/rc.d/
sondern in
Code:
/usr/local/lib/X11/xdm/Xsetup_0

Ob das ganze jetzt vor dem Login oder danach gestartet wird ist letztendlich egal.

Mit freundlichen Grüßen

Oliver
 
Code:
command="x11vnc -nopw -forever -viewonly -accept popup -display:0"

Das ist falsch. Wenn es überhaupt mal funktionierte, dann nur aus Zufall. Der Autor von dem Script macht gleich zwei Fehler:
  • Das Kommando muss immer mit vollem Pfad angegeben werden.
  • Das Kommando ist wirklich nur das Kommando. Optionen kommen extra.
Dazu kommen noch einige Kleinigkeiten, z.B. sollte man rc-Variable immer explizit setzen. Korrekt wäre es z.B. so:

Code:
#!/bin/sh

# PROVIDE: x11vnc
# REQUIRE: DAEMON
# KEYWORD: shutdown

. /etc/rc.subr

name="x11vnc"
rcvar=x11vnc_enable

load_rc_config $name
: ${x11vnc_enable="NO"}

command="/usr/local/bin/x11vnc"
command_args="-nopw -forever -viewonly -accept popup -display:0"
pidfile="/var/run/x11vnc.pid"

run_rc_command "$1"

Das ist blind getippt und ungetestet.
 
Das bringt mich auf jedenfall schonmal einen Schritt weiter, allerdings tauchen neue Fehlermeldungen welche ich auch nach weiterer Suche nicht beheben kann.
Manuell ausgeführt funktioniert der Befehl und der VNC-Server startet. Will ich über "service x11vnc start" starten kommt folgendes :
Code:
Starting x11vnc.
02/02/2015 14:55:28 passing arg to libvncserver: -display:0
02/02/2015 14:55:28 passing arg to libvncserver: -autoport:5900
02/02/2015 14:55:28 x11vnc version: 0.9.13 lastmod: 2011-08-10  pid: 1313
02/02/2015 14:55:28 XOpenDisplay("") failed.
02/02/2015 14:55:28 Trying again with XAUTHLOCALHOSTNAME=localhost ...
02/02/2015 14:55:28
02/02/2015 14:55:28 *** XOpenDisplay failed. No -display or DISPLAY.
02/02/2015 14:55:28 *** Trying ":0" in 4 seconds.  Press Ctrl-C to abort.
02/02/2015 14:55:28 *** 1 2 3 4
No protocol specified
02/02/2015 14:55:32 XOpenDisplay(":0") failed.
02/02/2015 14:55:32 Trying again with XAUTHLOCALHOSTNAME=localhost ...
No protocol specified
02/02/2015 14:55:32 XOpenDisplay(":0") failed.
02/02/2015 14:55:32 Trying again with unset XAUTHLOCALHOSTNAME ...
No protocol specified
02/02/2015 14:55:32

02/02/2015 14:55:32 ***************************************
02/02/2015 14:55:32 *** 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.

Display ist auf =:0 gesetzt.
Beim ausführen von
ps wwwwaux | grep auth
kommt :
Code:
root        742   1,7  0,3 956992  53492  -  S     2:43pm   0:40,61 /usr/local/bin/X -nolisten tcp vt09 -auth /var/run/slim.auth (Xorg)
Hab das dann noch ins Script mit reingepackt dann meckert er folgendes :

Code:
Starting x11vnc.
02/02/2015 15:19:08 passing arg to libvncserver: -display:0
02/02/2015 15:19:08 passing arg to libvncserver: -autoport:5900
02/02/2015 15:19:08 x11vnc version: 0.9.13 lastmod: 2011-08-10  pid: 1509
02/02/2015 15:19:08 XOpenDisplay("") failed.
02/02/2015 15:19:08 Trying again with XAUTHLOCALHOSTNAME=localhost ...
02/02/2015 15:19:08
02/02/2015 15:19:08 *** XOpenDisplay failed. No -display or DISPLAY.
02/02/2015 15:19:08 *** Trying ":0" in 4 seconds.  Press Ctrl-C to abort.
02/02/2015 15:19:08 *** 1 2 3 4
02/02/2015 15:19:12 *** XOpenDisplay of ":0" successful.
02/02/2015 15:19:12
02/02/2015 15:19:12 Using X display :0
02/02/2015 15:19:12 rootwin: 0x267 reswin: 0x3400001 dpy: 0x4825000
02/02/2015 15:19:12
02/02/2015 15:19:12 ------------------ USEFUL INFORMATION ------------------
02/02/2015 15:19:12 X DAMAGE available on display, using it for polling hints.
02/02/2015 15:19:12   To disable this behavior use: '-noxdamage'
02/02/2015 15:19:12
02/02/2015 15:19:12   Most compositing window managers like 'compiz' or 'beryl'
02/02/2015 15:19:12   cause X DAMAGE to fail, and so you may not see any screen
02/02/2015 15:19:12   updates via VNC.  Either disable 'compiz' (recommended) or
02/02/2015 15:19:12   supply the x11vnc '-noxdamage' command line option.
02/02/2015 15:19:12
02/02/2015 15:19:12 Wireframing: -wireframe mode is in effect for window moves.
02/02/2015 15:19:12   If this yields undesired behavior (poor response, painting
02/02/2015 15:19:12   errors, etc) it may be disabled:
02/02/2015 15:19:12    - use '-nowf' to disable wireframing completely.
02/02/2015 15:19:12    - use '-nowcr' to disable the Copy Rectangle after the
02/02/2015 15:19:12      moved window is released in the new position.
02/02/2015 15:19:12   Also see the -help entry for tuning parameters.
02/02/2015 15:19:12   You can press 3 Alt_L's (Left "Alt" key) in a row to
02/02/2015 15:19:12   repaint the screen, also see the -fixscreen option for
02/02/2015 15:19:12   periodic repaints.
02/02/2015 15:19:12
02/02/2015 15:19:12 XFIXES available on display, resetting cursor mode
02/02/2015 15:19:12   to: '-cursor most'.
02/02/2015 15:19:12   to disable this behavior use: '-cursor arrow'
02/02/2015 15:19:12   or '-noxfixes'.
02/02/2015 15:19:12 using XFIXES for cursor drawing.
02/02/2015 15:19:12 GrabServer control via XTEST.
02/02/2015 15:19:12
02/02/2015 15:19:12 Scroll Detection: -scrollcopyrect mode is in effect to
02/02/2015 15:19:12   use RECORD extension to try to detect scrolling windows
02/02/2015 15:19:12   (induced by either user keystroke or mouse input).
02/02/2015 15:19:12   If this yields undesired behavior (poor response, painting
02/02/2015 15:19:12   errors, etc) it may be disabled via: '-noscr'
02/02/2015 15:19:12   Also see the -help entry for tuning parameters.
02/02/2015 15:19:12   You can press 3 Alt_L's (Left "Alt" key) in a row to
02/02/2015 15:19:12   repaint the screen, also see the -fixscreen option for
02/02/2015 15:19:12   periodic repaints.
02/02/2015 15:19:12
02/02/2015 15:19:12 XKEYBOARD:
02/02/2015 15:19:12 Switching to -xkb mode to recover these keysyms:
02/02/2015 15:19:12    xkb  noxkb   Keysym  ("X" means present)
02/02/2015 15:19:12    ---  -----   -----------------------------
02/02/2015 15:19:12     X           0x40  at
02/02/2015 15:19:12     X           0x5b  bracketleft
02/02/2015 15:19:12     X           0x5d  bracketright
02/02/2015 15:19:12     X           0x7b  braceleft
02/02/2015 15:19:12     X           0x7d  braceright
02/02/2015 15:19:12     X           0x7c  bar
02/02/2015 15:19:12     X           0x5c  backslash
02/02/2015 15:19:12
02/02/2015 15:19:12   If this makes the key mapping worse you can
02/02/2015 15:19:12   disable it with the "-noxkb" option.
02/02/2015 15:19:12
02/02/2015 15:19:12
02/02/2015 15:19:12 X FBPM extension not supported.
02/02/2015 15:19:12 X display is capable of DPMS.
02/02/2015 15:19:12 --------------------------------------------------------
02/02/2015 15:19:12
02/02/2015 15:19:12 Default visual ID: 0x21
02/02/2015 15:19:12 Read initial data from X display into framebuffer.
02/02/2015 15:19:12 initialize_screen: fb_depth/fb_bpp/fb_Bpl 24/32/7680
02/02/2015 15:19:12 *** unrecognized option(s) ***
02/02/2015 15:19:12     [1]  -display:0
02/02/2015 15:19:12     [2]  -autoport:5900
02/02/2015 15:19:12 For a list of options run: x11vnc -opts
02/02/2015 15:19:12 or for the full help: x11vnc -help
02/02/2015 15:19:12
02/02/2015 15:19:12 Here is a list of removed or obsolete options:
02/02/2015 15:19:12
02/02/2015 15:19:12 removed: -hints, -nohints
02/02/2015 15:19:12 removed: -cursorposall
02/02/2015 15:19:12 removed: -nofilexfer, now the default.
02/02/2015 15:19:12
02/02/2015 15:19:12 renamed: -old_copytile, use -onetile
02/02/2015 15:19:12 renamed: -mouse,   use -cursor
02/02/2015 15:19:12 renamed: -mouseX,  use -cursor X
02/02/2015 15:19:12 renamed: -X,       use -cursor X
02/02/2015 15:19:12 renamed: -nomouse, use -nocursor
02/02/2015 15:19:12 renamed: -old_pointer, use -pointer_mode 1
/usr/local/etc/rc.d/x11vnc: WARNING: failed to start x11vnc

Weiterhin hab ich auch das "-auth guess" mal versucht allerdings auch mit eher mäßigem Erfolg:

Code:
02/02/2015 15:41:30 passing arg to libvncserver: -display:0
02/02/2015 15:41:30 passing arg to libvncserver: -autoport:5900
02/02/2015 15:41:30 x11vnc version: 0.9.13 lastmod: 2011-08-10  pid: 2032
/tmp/fd.il6Kci: xauth: not found
02/02/2015 15:41:30 -auth guess: failed for display='unset'
02/02/2015 15:41:30 -auth guess: since we are root, retrying with FD_XDM=1
02/02/2015 15:41:31 -auth guess: failed for display='unset'
/usr/local/etc/rc.d/x11vnc: WARNING: failed to start x11vnc

LG

Oliver
 
Der VNC-Server wird keine Rechte haben, auf den X-Server zu verbinden. Du kannst testweise einmal alle Clients erlauben, in dem du in X Startscript per xhost alles freigibst:
Code:
xhost +
Das ist aber keine Dauerlösung, da dann wirklich jeder auf den X-Server verbinden kann und wird. Die korrekte Lösung geht über xauth, was allerdings ein wenig einlesen verlangt. Denn das verwendete Cookie-System ist nicht wirklich eingängig.
 
Hi,

ich hab das immer über xfce4 startfunktion gestartet, dadurch wird es mit den richtigen Benutzerrechten gestartet

x11vnc -usepw -forever -display :0

So sah das glaub ich aus!
 
Hi CommanderZed,
die Lösung hab ich wie oben beschrieben auch gefunden, allerdings ist geplant, dass das beim Installieren der ganzen Clients automatisch eingerichtet wird. Mit dieser Methode müsste man das an jedem einzelnen Client einrichten. Wenn das irgendwie global funktioniert, kann man das direkt mit ins fertige Script reinpacken und es besteht nicht die Möglichkeit, das man das mal bei nem neu installiertem Rechner vergisst.
 
Kenne das Autostartverhalten von XFCE jetzt nicht, aber kannst du nicht das Script irgendwo zentral ablegen und dann per ln reinpacken? Wenn alles automatisch verteilt wird kannst du doch auch das Script verteilen (oder zB in das Skeleton für neue Benutzer aufnehmen, dass es automatisch jedem Benutzer erzeugt wird).
 
Ich weiß ja nicht bei wie vielen Rechnern / Benutzerprofilen du das machen must ... bei mir waren das nur so 25 Rechner die wir mal Testweise anstelle von Windows-Rechner aufgestellt haben.

Das hab ich glaub ich so gemacht das ich das vorkonfiguriert habe und die entsprechenden Konfigurationsverzeichnisse einmalig in die jeweiligen $home Ordner kopiert hatte.

Sollten die auf nem NFS oder so liegen wärs natürlich noch einfacher ;)
 
1) Ich vermute Du kannst so x11vnc nicht beim Booten starten, weil ja zu dem Zeitpunkt noch gar keine X11-Session läuft. Schau mal hier
http://www.karlrunge.com/x11vnc/faq.html#faq-userlogin

2) Wenn Du x11vnc zusammen mit Xfce startest, kannst Du nur fernwarten, wenn jemand sich dort eingeloggt hat (mit Xfce arbeitet). Aber vielleicht reicht Euch das ja.
Um das zu erreichen könntest Du das in die .xinitrc eintragen.

3) Eine schöne Lösung ist das Ganze erst zu starten, wenn es gebraucht wird. Und zwar per ssh und ssh-Tunnel von Deiner Workstation aus:
Code:
# Dein Terminal 1, ssh-Tunnel aufbauen und auf dem Client x11vnc starten
$ ssh -t -L 5900:localhost:5900 clienthostname 'x11vnc -localhost -display :0'
# Dein Terminal 2, vncviewer verbinden mit dem Tunneleingang auf Deiner Workstation
$ vncviewer -encodings "copyrect tight zrle hextile" localhost:0
Das ist von hier: http://www.karlrunge.com/x11vnc/#tunnelling
Natürlich muss dazu der sshd auf den Clients laufen, aber das ist besser als überall den vnc-Dienst an zu haben.

4) Mit ssh kannst Du auch einfach ohne vnc auf dem Client arbeiten, wenn Du das mit „Fernwartung“ meinst:
Code:
$ ssh -Y clienthostname "firefox http://www.bsdforen.de"

Ich hoffe das hilft Dir weiter! Tolle Sache das „wir stellen die Clients im Unternehmen von Ubuntu auf FreeBSD um“, sowas muss unterstützt werden :)
 
Naja, wenn ein graphischer Loginmanager zum Einsatz kommt wäre es schon möglich, dann zieht der ja den XServer hoch.
 
eric>

Zu 3> Er meint wohl eher Büroarbeitsplätze so wie ich ihn verstanden habe, und da fällt das ssh flach da du dich ja afaik mit dem usernamen des angemeldeten Benutzer anmelden müsstest, den du ja u.U. nicht weißt - und Benutzernamen und Kennwörter von endusern abfragen ist nicht zwangsweise immer möglich

Zu4> Es geht wohl eher darum usern die angemeldet sind "Über die Schulter zu schauen" um denen zu helfen, da nützt das wenig. Funktioniert auch nur bei Verbindungen dtl. über 10Mbit in beide Richtungen, über ne DSL-Leitung, selbst mit 16k ist das schnarchen langsam

Goblin> Nein, das klappt wg. der Authentifizierung nicht (siehe yamagi)
 
Das wird's wahrscheinlich nicht sein, aber statt
# REQUIRE: DAEMON
sollte da
# REQUIRE: LOGIN

stehen, damit das Skript erst ganz spät ausgeführt wird.
 
Guten Morgen zusammen,

Code:
xhost +
Das ist aber keine Dauerlösung, da dann wirklich jeder auf den X-Server verbinden kann und wird. Die korrekte Lösung geht über xauth, was allerdings ein wenig einlesen verlangt. Denn das verwendete Cookie-System ist nicht wirklich eingängig.
Das funktioniert leider nicht. Bleibt immernoch bei der selben Fehlermeldung.

eric:
zu 2/4: Ja das würde reichen, die "Fernwartung" ist nur dazu gedacht, den Mitarbeitern bei Problemen zu helfen, die man auch vom Platz aus lösen kann. Von daher reicht das ssh -Y leider nicht aus. Die Xinitrc liegt auch in den homes der einzelnen Nutzer, die existieren bei der Installation noch gar nicht.

Man könnte das ganze auch im Anschluss per CSSH an alle Nutzer verteilen, aber da ist wieder die Sache, wenn mal ein Client hinüber ist und man einen neuen Installiert, das man das vergisst.

lme:
Ich werds mal ausprobieren
und auch mal nach xauth suchen ob ich darüber was nützliches finden kann.

LG
 
Hallo,

für den von dir beschriebenen Fall sollte es meiner Meinung nach reichen, wenn du ein Startskript mit Icon für den Benutzer anlegst.
Da ich davon ausgehe, dass du in Deutschland ansässig bist, würde sich der Betriebsrat mit Sicherheit dafür interessieren, wenn ein Admin dauerhaft unbemerkt vom Benutzer die Arbeit kontrollieren kann. Stichwort: Mitarbeiterüberwachung (Datenschutz).

Im Problemfall also Starten und wieder schließen und gut ist.
Wenn du für Wartungszwecke selbst drauf musst (ohne Benutzer), kannst du dir immer noch deinen "eigenen" VNC-Server starten - hier ist es ja egal, welchen Desktop du siehst.

Gruß
Markus
 
Noch ein Vorschlag:
Probier mal in der slim.conf aus, mit dem sessionstart_cmd den vnc-Server zu starten.

Code:
# login_cmd  exec /bin/sh - ~/.xinitrc %session
login_cmd  exec /bin/bash -login ~/.xinitrc %session

# Commands executed when starting and exiting a session.
# They can be used for registering a X11 session with
# sessreg. You can use the %user variable
#
# sessionstart_cmd   some command
# sessionstop_cmd   some command
 
Der VNC-Server wäre so eingestellt, dass die Benutzer ein Popup-Fenster angezeigt bekommen, welches sie annehmen oder ablehnen können. Abgesehen davon würde es glaube ich auffallen wenn der Cursor etwas anderes macht als der davorsitzende User "sagt". :-D

Mit der slim.conf habe ich mal ausprobiert
Code:
sessionstart_cmd    /usr/local/bin/x11vnc -nopw -forever -viewonly -accept popup -auth /var/run/slim.auth

Allerdings komme ich nicht auf die Arbeitsoberfläche nachdem ich die Login-Daten eingegeben habe. Die Eingabefelder verschwinden, aber ich bleibe im Slim-Screen hängen.
 
Allerdings komme ich nicht auf die Arbeitsoberfläche nachdem ich die Login-Daten eingegeben habe. Die Eingabefelder verschwinden, aber ich bleibe im Slim-Screen hängen.
Weil das sessionstart-Command wohl nie endet.

Vielleicht Option -bg "Go into the background after screen setup"? Schau Dir mal die command line options an. Man könnte es vielleicht auch in einem Script im Hintergrund starten mit &, oder exec davor schreiben?
 
Guten Morgen.

Eric, ich würde sagen "Bingo". ;-)
Das wars. Mit dem -bg Befehl startet er im Hintergrund und verhält sich im Anschluss genau so wie er soll.

Vielen Dank an alle für die zahlreichen Vorschläge und ein schönes Wochenende.

Gruß

Oliver
 
Zurück
Oben