# Headless Xorg XDCMP Conifg? Anyone got any tips?



## SimonGriffiths (Nov 7, 2009)

Hi There,

I've been banging my head against a brick wall for a few weeks now when i get the urge to  configure X and xdm for headless config.

So does anyone has any pointers on how to go about this as i've read so many tutorials, man pages, how to's my head is swimming.

Cheers,

Si


----------



## mickey (Nov 8, 2009)

SimonGriffiths said:
			
		

> So does anyone has any pointers on how to go about this as i've read so many tutorials, man pages, how to's my head is swimming.



It must have been more than a decade, since I last put up such a configuration... but what exactly is the problem you are having in setting this up?

Basically you would configure xdm on the headless machine, to not start any local X server. This should be configured in /usr/local/etc/X11/xdm/Xservers i guess. Also you would configure the set of remote machines, that is supposed to have access to it. And then connect to the headless machine from another machine via XDMCP.


----------



## SimonGriffiths (Nov 8, 2009)

Thanks for you reply.

The main problem is that because I dont really know XDM (mainly setup Xorg for local graphics) that well I am struggling to find a prescribed way of setting this up.

I've played around with various files in /usr/local/lib/X11/xdm including the Xservers file you mentioned but some tutorials tell me to put entries in there and others say it should be blank...  Also most tutorials are very specific and have local X servers up and running.  Finding it all very confusing!

The end game here is to get a windows X server (cygwin im testing with) to connect to a bunch of freebsd boxes here.  Its not critical but a nice to have and wondered if anyone had any sample configs or pointers in the right direction 

I'll have another go this coming weekend and see how close i can get and post back with specifics.

Cheers,

Si


----------



## mickey (Nov 9, 2009)

SimonGriffiths said:
			
		

> I've played around with various files in /usr/local/lib/X11/xdm including the Xservers file you mentioned but some tutorials tell me to put entries in there and others say it should be blank...  Also most tutorials are very specific and have local X servers up and running.



In the 'normal' case, where you would use xdm to provide you with a local graphical login screen, you would of course put something into the Xservers file, as this file (as the name suggests), specifies the X servers (and their options), which shall be started and maintained by xdm.

In your specific case, you don't need/want any local X server running, so it should list none.

The other file you should have a look at, is called Xaccess (if I remember it correctly), which configures, what other hosts are allowed to connect and how. I believe there are several ways of allowing/disallowing access, either for single hosts, or subnets, or using wildcards. The Xaccess file, that is installed by default, should have some examples within the comment sections.

There's also the possibility to use a host chooser menu via indirect XDMCP queries, which could come in handy, if you want to manage multiple headless machines.


----------



## mickey (Nov 9, 2009)

I had a quick look at configuring xdm for headless XDMCP access. First I must say, that I was a bit confused as to where the configuration files are supposed to be located. The xdm(1) man page states, the default location would be /usr/local/share/examples/xdm. Actually xdm rather seems to use the files in /usr/local/lib/X11/xdm, and I would find it quite strange, to keep an active configuration in an 'examples' directory.

So here's the deal:

1) Edit the Xservers file and comment out the line for starting an X server on the local display:

```
#:0 local /usr/local/bin/X :0
```

2) Edit the Xaccess file and uncomment the following two lines, in order to allow access via XDMCP and the chooser:

```
*                                       #any host can get a login window

*               CHOOSER BROADCAST       #any indirect host can get a chooser
```

3) Edit the xdm-config file and comment out the DisplayManager.requestPort line, as suggested by the comments. This is necessary, as xdm would otherwise not listen to XDMCP requests at all:

```
! SECURITY: do not listen for XDMCP or Chooser requests
! Comment out this line if you want to manage X terminals with xdm
#DisplayManager.requestPort:    0
```

This should get you started.

For testing purposes, you may find it useful at first, to start xdm with:

```
xdm -nodaemon -debug 1
```
This way you will see what xdm is doing on the console you started it from.

When you got xdm running on the server machine, you can try to connect to it from a remote client with something like:

```
X -query <your_server>
```
to directly get a login window, or:

```
X -indirect <your_server>
```
to get the chooser window, with a list of hosts, willing to provide an XDMCP session.


----------



## SimonGriffiths (Nov 15, 2009)

Thanks for this.  I had a similar config to this so started again rewriting the example files back into /usr/local/lib/X11/xdm and started again.  Since I couldn't remember the last error message that made me stop I felt this was sensible.

I found some time today to revisit this and now know I am getting the same error message as before which is Decline No Valid Address.

Here is the output from xdm -nodaemon -debug 1 when I connect with XWin -query <ip>


```
DisplayManager.errorLogFile/DisplayManager.ErrorLogFile value  /var/log/xdm.log
DisplayManager.daemonMode/DisplayManager.DaemonMode value  false
DisplayManager.pidFile/DisplayManager.PidFile value  /var/run/xdm.pid
DisplayManager.lockPidFile/DisplayManager.LockPidFile value true
DisplayManager.authDir/DisplayManager.authDir value /usr/local/lib/X11/xdm
DisplayManager.autoRescan/DisplayManager.AutoRescan value true
DisplayManager.removeDomainname/DisplayManager.RemoveDomainname value true
DisplayManager.keyFile/DisplayManager.KeyFile value  /usr/local/lib/X11/xdm/xdm-keys
DisplayManager.accessFile/DisplayManager.AccessFile value  /usr/local/lib/X11/xdm/Xaccess
DisplayManager.exportList/DisplayManager.ExportList value
DisplayManager.randomDevice/DisplayManager.RandomDevice value /dev/urandom
DisplayManager.greeterLib/DisplayManager.GreeterLib value /usr/local/lib/X11/xdm/libXdmGreet.so
DisplayManager.choiceTimeout/DisplayManager.ChoiceTimeout value 15
DisplayManager.sourceAddress/DisplayManager.SourceAddress value false
DisplayManager.willing/DisplayManager.Willing value  su -m nobody -c /usr/local/lib/X11/xdm/Xwilling
Created chooser socket 4
creating socket to listen on port 177 of address 192.168.1.20
WaitForSomething
select returns 1.  Rescan: 0  ChildReady: 0
ProcessRequestSocket
header: 1 2 1
Query respond 1
ConvertAddr returning 0 for family 2
all_query_respond: conntype=0, addr=192.168.1.69, len=4
Send willing  1 user, load: 0.00, 0.15, 0.11
signals blocked
WaitForSomething
select returns 1.  Rescan: 0  ChildReady: 0
ProcessRequestSocket
header: 1 7 52
Request respond 52
Decline No valid address
WaitForSomething
```

I am guessing this is an X authority issue but have no idea how to proceed.  The only searches on the internet i can find refer to third party software, e.g. kdm, xnest etc.  

My options seem to be,

1. xdm is miss configured on my box and needs extra info to continue.
2. Cygwin's X port is borked in this fasion.  Ironically I use the same build at work connecting to a RHEL box (<rant>although xdmcp works bugger all else does in any sensible fasion, </rant>)
3. I have no idea what I'm doing.... (yep its a winner) 

heh!

Si.


----------



## mickey (Nov 16, 2009)

SimonGriffiths said:
			
		

> Here is the output from xdm -nodaemon -debug 1 when I connect with XWin -query <ip>
> 
> 
> ```
> ...



This could indeed be an authorization issue with Cygwin's X server. You might try to invoke it with the _-ac_ flag, effectively disabling all authorization, and see if that helps.

Do you have by chance the possibility to connect to XDM using a FreeBSD Xorg server, to see if that works?


----------



## mickey (Nov 16, 2009)

Now that's odd ...
I just downloaded and installed Cygwin/X onto my W2k box. To my surprise, I can connect to my xdm server, using _X -query <hostname>_ or _X -indirect <hostname>_, without any problems.

But something seems different:

```
WaitForSomething
select returns 1.  Rescan: 0  ChildReady: 0
ProcessRequestSocket
header: 1 7 60
Request respond 60
FindProtoDisplay
NewProtoDisplay
NewProtoDisplay 0x28419380
Got 0x28418020 (18 MIT-MAGIC-COOKIE-1)
Accept Session ID 247120001
```


----------



## SimonGriffiths (Nov 17, 2009)

Hmm, interesting indeed.

Well i've confirmed the local X server is listening on port 6000, had at a look at the xdm source and the noValidAddr is set in xdcmp.c and it looks like something is blocking the communications back to X.

The only thing I can come up with, since this works for you on win2k is that vista and win7 do something that blocks the comms comming back.

The cygwin/x FAQ says to add a -from option to XWin.exe which I've tried but get the same error so lost now.

Ho hum, its no great shakes just dont like to give up when thinks dont work as I want them to.

Thank you very much for you help with this Mickey.  We have at least proven its something wrong with my windows X server rather than freebsd.

If i do find a work around for this I'll post back here.

Cheers,

Si.


----------



## mickey (Nov 18, 2009)

SimonGriffiths said:
			
		

> Well i've confirmed the local X server is listening on port 6000, had at a look at the xdm source and the noValidAddr is set in xdcmp.c and it looks like something is blocking the communications back to X.


Does your cygwin/X server abort, when the remote xdm rejects the session setup request, possibly with an error message, too?

If this is the case, this would indicate, that the communications channel is working in both directions. If the communication would be blocked in the reverse direction, I would assume, that your cygwin/X server would block at least until some timeout expires.

The real thing of course, would be to use wireshark, to have a look at the protocol exchange. Not sure, but I guess, wireshark should have some protocol dissector for XDMCP, so one could look at the individual header fields for oddities.

I tried google for that specific xdm error message, but none of the results seemed to be related to cygwin/X. There have been similar problems though with Xvnc, but no viable solution either. The only clue was, that this may be caused by an incomplete header, missing some field.

Thinking about this, I wonder what these three numbers are, that xdm outputs in the context of the request, and whether the last number is possibly the length of the request or header. My log has a 60 in that place, yours has 52, which makes 8 bytes less, if my assumption is correct. But I needed to take a look at the xdm sources, to find an answer to that question :\


----------



## SimonGriffiths (Nov 21, 2009)

*[Solved]  Headless Xorg XDCMP Conifg? Anyone got any tips?*

Hey Mickey,

This as it turns out is a problem with the version of cygwin I was using (1.5.25-15) and windows Vista/7 as both OS's presented the same problems.  I can only guess that on win2k/XP cygwin worked as expected and something has changed in vista/7.

I noticed cygwin is beta testing a 1.7 build and after deleting my entire cygwin installation and re-installing using the beta 1.7 setup.exe I can now connect.  I get a login screen that works, now all i need to do is setup Xsessions to fire me a window manager and I'm set ))

Good stuff,

Thanks for you help with this Mickey, all the best,

Si.


----------

