Thursday, September 24, 2009

Convert p4 cygwin commands to p4 win commands

Here’s a simple little script which allows me to use p4.exe from cygwin.  Perforce actually releases a p4.exe for cygwin, but I wanted my p4win and p4.exe to be able to use the same client spec.  This isn’t possible when one requires a root starting with “C:\” and the other requires “/cygdrive/c/”.  

 

This script works by expanding and window-izing all arguments after the p4 command.

 

Here is a series which shows the transformation.

  • p4 edit README
  • p4 edit /home/gwarner/foo/README (where foo is a symbolic link)
  • p4 edit /cygdrive/c/perforceRoot/blah/blah/blah/README
  • p4 edit C:\perforceRoot\blah\blah\blah\README

 

Ta da!

 

1.     #!/usr/bin/python

2.     import sys

3.     from subprocess import *

4.      

5.     def win32Path(path):                                                                                       path = path.replace('/cygdrive/c/','C:\\')

6.         path = path.replace('/','\\')

7.         return '"%s"' % path.strip()                                                                       

8.     if __name__ == '__main__':

9.         p4command = sys.argv[1]

10.      fullFiles = []

11.                 

12.      for file in sys.argv[2:]:

13.          fullPath = Popen(['readlink.exe -f ' + file], stdout=PIPE, shell=True).communicate()[0]

14.          fullFiles.append(win32Path(fullPath))

15.   

16.      newCommand = 'p4 %s %s' % (p4command, ' '.join(fullFiles))

17.   

18.      print newCommand

19.      check_call(newCommand, shell=True)

20.      print 'done.'

 

 

Wednesday, September 02, 2009

The Trickyness that is called xhost, xauth, and X in general

Goal: Export a display from a linux client to a RHEL x-server with xauth security

I don't cover all of the details below, but just cover some gotchas.  For some good details on xhost and xauth, see here:

Here are some things that might get in your way:

1) iptables

RHEL blocks most ports out of the box.  The iptables configuration is found here: /etc/sysconfig/iptables.  After making changes, it can be reloaded by issuing this command: "service iptables restart".  

I noticed that ssh was connecting just fine, so I copied the line allowing port 22 connections and changed it to allow port 6000 (x11) connections.  

2) xhost

To disable host checking, issue the following: "xhost +".  Warning: This opens up your system completely as well as disables xauth.

To reenable: "xhost -"

To grant a host permission: "xhost +hostname"

3) xauth

Note: for xauth to work, xhost cannot be disabled.  Also, if xhost is granting permission to your client, it won't bother to check with xauth.  Moral of the story: Enable xhost, but don't add anything to it.

To make sure xauth is being used on the x-server, issue the following: "ps aux | grep auth" and look at the output.  You should see an .Xauthority (or similar file) being referenced.

Both the client and the server must have the cookie for xauth to work.  Run "xauth" and issue the command "list" at the prompt.  On the server, things should be in terms of the server's hostname.  On the client they should also be in terms of the server's hostname.






Some errors related to the above gotchas:
No protocol specified
Xt error: Can't open display ip:0.0




Pyjamas