Monthly Archives: January 2012

git detaching head on latest commit of particular branch

I was following the answer of this SO question: http://stackoverflow.com/questions/1464642/git-merge-squash-repeatedly

It worked perfectly on my 11.10 machines (git 1.7.4.1), but would not work on a 10.04 machines (git 1.7.0.4)

The problem was this command: git checkout development@{0}
My git could not understand the curly braces – I guess it must be a git version problem, but I’ve got the most updated version of git for Ubuntu 10.04 from the Ubuntu repositories and I didn’t want to upgrade to see.

(Another post mentions use of the curly braces, like this: {now} – http://sitaramc.github.com/concepts/detached-head.html)

Anyway, solution: git checkout `git rev-parse development`

Paramiko sftp hanging with connections between machines on the same interface of a filtering pfsense box

Odd problem; I had the following set up:

[[machine with paramiko 10.100.x.x]] –|

                                                              | —–(int X) 10.100.x.x [[pfsense]] (int Y) 10.2.x.x —– | —— [[10.2.x.x machine B]]

[[machine A 10.100.x.x]] ——————|

 

I had a script on the paramiko machine connecting via ssh and sftp to machines A and B.  Connections to machine B had no problem whatsoever.  Connections to machine A, however, would work 5% of the time, and drop the rest of the time either when setting up the channel to execute a command over ssh, or when invoking the sftp subsystem on the remote machine.  Normal ssh and sftp connections (not using paramiko) had no problems whatsoever.  Also, when pfSense filtering was turned off, there were also no problems.

It turned out that pfsense was dropping a lot of packets sent by paramiko due to fragmentation (logs show TCP:PA, TCP:RA and TCP:A).  Unfortunately, tweaking pfsense settings didn’t help here (some people have reported that setting Firewall Optimization Options (under Advanced > Firewall/NAT) to conservative worked – that didn’t help me unfortunately – or disabling firewall scrub worked – which I couldn’t do as it’s required by NAT).

I haven’t been able to figure out exactly what the problem is.  The packets received by machine B and machine A (with filtering off) look exactly the same.  I’m tempted to think this is a pfsense problem, although I have no specific proof (I’ve tested with multiple machines in position of machine A by the way, compared ssh settings, ensured there were no other connectivity problems in the way).

In the end, I’ve set up another network (virtual one, since these are VMs – 10.100.x.x machines plus pfsense on one physical host, and 10.2.x.x on another) connecting these VMs directly to eachother, to bypass pfsense for these connections.

Enabling post requests to static (eg, html) pages using IIS 7

Firstly, it seems impossible to do this without installing a backend language to pass the files off to. IIS static file hander does not seem capable of handling post requests. This is silly, but unfortunately, if you’re working with a site with front-end only and need posts requests (for javascript, for example), the default installation of IIS 7 cannot do this.

If you have no backend languages to work with, the easiest thing will be using ASP (as it’s just a case of enabling it on your machine):

  1. Enable ASP and ISAPI modules
    In control panel > programs > turn windows features on or off, expand Internet Information Services > World Wide Web Services > Application Development Features, click on ASP, ISAPI Extensions and ISAPI Filters. Machine will probably tell you to restart.
  2. Delegate Handler Mappings
    In IIS manager, select the machine name from the left, click on Feature Delegation under Management in the middle section of the page. Select Handler Mappings from the list and select Read/Write from the right hand section of the page.
  3. Create new Handler Mapping
    In IIS manager, click on the web site name from the left hand side (probably called Default Web Site with a globe image next to it). Go into Handler Mappings. Add a Module Mapping (link on the right), with the following details:
         Request path: *.html
         Module: IsapiModule
         Executable: %windir%\system32\inetsrv\asp.dll
         Name: html
    In Request Restrictions box for this handler, have the following settings:
         Mapping: unticked
         Verbs: all verbs
         Access: none

You should not need to do the iisreset command – it should just start working now.

 

However, if you’re using PHP (I assume you’ve already install PHP and enabled CGI), do the following:

  1. Delegate Handler Mappings
    In IIS manager, select the machine name from the left, click on Feature Delegation under Management in the middle section of the page. Select Handler Mappings from the list and select Read/Write from the right hand section of the page.
  2. Create new Handler Mapping
    In IIS manager, click on the web site name from the left hand side (probably called Default Web Site with a globe image next to it). Go into Handler Mappings. Add a Module Mapping (link on the right). The details should be the same as with the mapping for the .php extension, but it will be something like this:
         Request path: *.html
         Module: FastCgiModule
         Executable: C:\Program Files (x86)\PHP\php-cgi.exe
         Name: html
    In Request Restrictions box for this handler, have the following settings:
         Mapping: unticked
         Verbs: all verbs
         Access: none

Bash script command not found while command line works

Lots of results on google say to make sure you have #!/bin/bash at the top of your file, and make sure the file is not in windows format (line endings could mess it up).

In my case, however, I had created a variable called PATH accidentally. This overwrites the built-in PATH environment variable that is responsible for giving the script access to commands, and without the commands available, you’ll get the command not found error.

Make sure to name your variables something else!