When having problems with Gitosis on Ubuntu

Problems with gitosis

While working on my Ubuntu server with the Gitosis default setup, I ran into some problems along the way when trying to commit some changes:

  1. Lost ability to update the gitosis-admin repository
  2. Various python errors
  3. Expected changes to gitosis.conf file but they were not being applied

Below is a description of what I did to trace down the error(s) and try to fix them.

Gitosis debug

Setting the debug into the gitosis.conf file really helped me out. To achieve this, you must have the following in your gitosis.conf file:

[gitosis]
loglevel = DEBUG

After this has been setup, you can run your push command to get a better idea of what is going wrong. Some of the problems I got are listed below with a explanation of what I did to try and resolve the issue:

gitosis.conf not updated after a push

This was a mystery. I cloned off the files from the gitosis-admin repo and then made some changes to the gitosis.conf file. Then after pushing them to the origin master, I noticed my changes did not take effect when looking at the file:

cat /srv/gitosis/.gitosis.conf

I noticed that there is a hook file in the directory of

/srv/gitosis/repositories/gitosis-admin.git/hooks/

with the filename of:

/usr/share/pyshared/gitosis/templates/admin/hooks/post-update

(Small note here, take note of the directory of where this file is because the part of /usr/share/pyshared is what you need for setting your PYTHONPATH) Running the above script occurs after applying a push to the gitosis-admin repository. I figured this was where the hold up was. After running this script manually, I got more errors (which I don’t have any more) and here is what you need to do to run this script:

sudo su
su gitosis
export set GIT_DIR="/srv/gitosis/repositories/gitosis-admin.git"
export set PYTHONPATH="/usr/share/pyshared"
/usr/share/pyshared/gitosis/templates/admin/hooks/post-update

That is, goto root account with sudo. Change users to gitosis. Set some variables (GIT_DIR, and PYTHONPATH). Then run script. This might give you more insight of to why the gitosis.conf file is not being updated.

Lost access to gitosis.conf file

This happened to me. Any commit I made to the gitosis-admin repo resulted in a permissions denied. So I logged on to my server, changed directories over to /srv/gitosis and edited the

.gitosis.conf

file and all was okay.

PERMISSION problems

Most of the time this was because the files in /srv/gitosis were not group writeable by the group of ‘gitosis’, or my account did not belong to the group ‘gitosis’, or that the ssh configuration file did not allow my account to login via ssh.

conclusion

Most of the time gitosis worked great. But sometimes, it did not work out. I hope this document will save me in the future as well as others. A really nice resource for gitosis can be found at http://ao2.it/wiki/How_to_setup_a_GIT_server_with_gitosis_and_gitweb

Cheers,

Aaron

Verifying all entries in /etc/shells are not more permissive than 755

I wanted to make sure that all the files listed in /etc/shells were not more permissive than 755, but I kept running into a problem of trying to analyze the permissions on a file that is a link. After digging around, I found out about a command called

readlink

which prints the full path of the file that the link is point at. So I came up with some bash shell code to do the job:

 Bash Script checking permissions

for f in `cat /etc/shells`
do
	#echo "checking $f"
	if [ -e $f ]; then

	if [ -L $f ]; then
		f=`readlink -f $f`
		results=`stat -c "%a" $f`
	else
		results=`stat -c "%a" $f`
	fi

	if [[ "$results" -le "755"  ]]; then
		echo "--- passed => $results - $f"
	else
		echo "-X- Failed => $results - $f"
	fi

	else
	echo "missing"
	fi
done

Explanation of bash script checking permissions

For all the text lines returned from “cat /etc/shells”, process a loop while setting each line from the text file /etc/shells as a variable of “f”. The first if statement checks to see if the file exists. The second if statement checks if the file in “f” is a link and if so, reassign the variable “f” to the returned value from running “readlink -f $f” then process the file with stat to get the octal value of permissions. If the file is not a link, try to process the file with stat to get the octal value. The next if statement checks to see the file in $f is less than or equal to 755. If the octal value is less than or equal to 755, a line will be printed indicating the file has passed the test. If the octal value is more than 755, a line will be printed indicating the file has not passed the test.

Here is a sample output from one of my servers:

--- passed => 755 - /bin/bash
--- passed => 755 - /bin/bash
--- passed => 755 - /sbin/nologin
--- passed => 755 - /bin/ash
--- passed => 755 - /bin/ash
--- passed => 755 - /bin/ksh
--- passed => 755 - /bin/ksh
--- passed => 755 - /bin/ksh
--- passed => 755 - /bin/tcsh
--- passed => 755 - /bin/tcsh
--- passed => 755 - /bin/zsh

RedMine due date with offset value

Another RedMine plugin of mine to automatically set the due date with a specified offset. So here is my github repo with the plugin necessary to fill in the due date for all projects. I have some plans to improve the plugin into being a module for custom project based settings. Perhaps some settings of setting the offset value in a field and a checkbox for making sure it falls on a weekday or not.

Redmine-due-date-offset