LinuxHappy's Weblog

Failures and Successes of Linux-based Development

Archive for January, 2008

Sucess: svn + apache2 + SSL + ubuntu 7.10/8.04 + users + part 2: trac

Posted by linuxhappy on January 21, 2008


UPDATE: 6/22/08

I tried using these instructions on Ubuntu 8.04 and everything still works.  I’m not sure why someone commented saying that the instructions don’t work.. I’m curious.


Wow, This was super easy to get going:

The link over on the trac website is pretty spot on, but I had to modify it a little bit.. Credits:

This is a continuation of my previous post. This post definitely depends on the last one, so if you haven’t checked it out, go for it.

Install trac

sudo apt-get install trac

Make a directory for trac to live in

sudo mkdir /var/lib/trac
 sudo chown www-data:www-data /var/lib/trac

Setup Apache2:

cd /etc/apache2/sites-available/
sudo touch trac
sudo gedit trac

Enter, or copy the following stuff in (be careful with the ServerName): (modified on march 2nd to make sure the ssl is enabled)

<VirtualHost *:443>
        ServerAdmin webmaster@localhost
        ServerName monkfish
        DocumentRoot /usr/share/trac/cgi-bin/
        <Directory /usr/share/trac/cgi-bin/>
                Options Indexes FollowSymLinks MultiViews ExecCGI
                AllowOverride All
                Order allow,deny
                allow from all
        Alias /trac "/usr/share/trac/htdocs"

        <Location /trac.cgi>
            SetEnv TRAC_ENV "/var/lib/trac"

        <Location "/">
            AuthType Basic
            AuthName "Trac"
            AuthUserFile /etc/apache2/dav_svn.passwd
            Require valid-user

        DirectoryIndex trac.cgi
        ErrorLog /var/log/apache2/error.trac.log
        CustomLog /var/log/apache2/access.trac.log combined
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/apache.pem
SSLProtocol all


Modify /etc/apache2/apache2.conf to have the following line(s):

# To use CGI scripts outside /cgi-bin/:
AddHandler cgi-script .cgi

Disable the default virtual host, enable trac and restart apache2

sudo a2dissite default
sudo a2ensite trac
sudo /etc/init.d/apache2 restart

Since we have already setup a svn repository in /var/lib/svn, we can just go ahead and continue to use trac-admin

sudo trac-admin /var/lib/trac initenv

This will basically ask you a bunch of questions... here's how I filled mine out:

jwoo@monkfish:/var/lib/trac$ sudo trac-admin /var/lib/trac initenv
Creating a new Trac environment at /var/lib/trac

Trac will first ask a few questions about your environment
in order to initalize and prepare the project database.

 Please enter the name of your project.
 This name will be used in page titles and descriptions.

Project Name [My Project]> linuxhappy

 Please specify the connection string for the database to use.
 By default, a local SQLite database is created in the environment
 directory. It is also possible to use an already existing
 PostgreSQL database (check the Trac documentation for the exact
 connection string syntax).

Database connection string [sqlite:db/trac.db]> 

 Please specify the type of version control system,
 By default, it will be svn.

 If you don't want to use Trac with version control integration,
 choose the default here and don't specify a repository directory.
 in the next question.

Repository type [svn]> 

 Please specify the absolute path to the version control
 repository, or leave it blank to use Trac without a repository.
 You can also set the repository location later.

Path to repository [/path/to/repos]> /var/lib/svn 

 Please enter location of Trac page templates.
 Default is the location of the site-wide templates installed with Trac.

Templates directory [/usr/share/trac/templates]> 

Creating and Initializing Project
 Installing default wiki pages
 /usr/share/trac/wiki-default/TracChangeset => TracChangeset
 /usr/share/trac/wiki-default/TracStandalone => TracStandalone
 /usr/share/trac/wiki-default/TracSearch => TracSearch
 /usr/share/trac/wiki-default/CamelCase => CamelCase
 /usr/share/trac/wiki-default/TracPlugins => TracPlugins
 /usr/share/trac/wiki-default/RecentChanges => RecentChanges
 /usr/share/trac/wiki-default/WikiRestructuredText => WikiRestructuredText
 /usr/share/trac/wiki-default/TracTickets => TracTickets
 /usr/share/trac/wiki-default/InterWiki => InterWiki
 /usr/share/trac/wiki-default/WikiPageNames => WikiPageNames
 /usr/share/trac/wiki-default/TracUnicode => TracUnicode
 /usr/share/trac/wiki-default/WikiNewPage => WikiNewPage
 /usr/share/trac/wiki-default/WikiProcessors => WikiProcessors
 /usr/share/trac/wiki-default/TracLinks => TracLinks
 /usr/share/trac/wiki-default/WikiMacros => WikiMacros
 /usr/share/trac/wiki-default/TracUpgrade => TracUpgrade
 /usr/share/trac/wiki-default/TracQuery => TracQuery
 /usr/share/trac/wiki-default/WikiStart => WikiStart
 /usr/share/trac/wiki-default/TracRoadmap => TracRoadmap
 /usr/share/trac/wiki-default/TracLogging => TracLogging
 /usr/share/trac/wiki-default/TracAdmin => TracAdmin
 /usr/share/trac/wiki-default/TracBackup => TracBackup
 /usr/share/trac/wiki-default/TracFastCgi => TracFastCgi
 /usr/share/trac/wiki-default/WikiHtml => WikiHtml
 /usr/share/trac/wiki-default/TracRss => TracRss
 /usr/share/trac/wiki-default/TracAccessibility => TracAccessibility
 /usr/share/trac/wiki-default/InterMapTxt => InterMapTxt
 /usr/share/trac/wiki-default/WikiRestructuredTextLinks => WikiRestructuredTextLinks
 /usr/share/trac/wiki-default/TracInterfaceCustomization => TracInterfaceCustomization
 /usr/share/trac/wiki-default/TracTimeline => TracTimeline
 /usr/share/trac/wiki-default/TracPermissions => TracPermissions
 /usr/share/trac/wiki-default/TracEnvironment => TracEnvironment
 /usr/share/trac/wiki-default/TracReports => TracReports
 /usr/share/trac/wiki-default/TracRevisionLog => TracRevisionLog
 /usr/share/trac/wiki-default/TracTicketsCustomFields => TracTicketsCustomFields
 /usr/share/trac/wiki-default/WikiFormatting => WikiFormatting
 /usr/share/trac/wiki-default/TracGuide => TracGuide
 /usr/share/trac/wiki-default/TracIni => TracIni
 /usr/share/trac/wiki-default/TracModPython => TracModPython
 /usr/share/trac/wiki-default/TracSyntaxColoring => TracSyntaxColoring
 /usr/share/trac/wiki-default/TracCgi => TracCgi
 /usr/share/trac/wiki-default/TracBrowser => TracBrowser
 /usr/share/trac/wiki-default/SandBox => SandBox
 /usr/share/trac/wiki-default/TracSupport => TracSupport
 /usr/share/trac/wiki-default/InterTrac => InterTrac
 /usr/share/trac/wiki-default/TitleIndex => TitleIndex
 /usr/share/trac/wiki-default/TracWiki => TracWiki
 /usr/share/trac/wiki-default/TracInstall => TracInstall
 /usr/share/trac/wiki-default/TracImport => TracImport
 /usr/share/trac/wiki-default/WikiDeletePage => WikiDeletePage
 /usr/share/trac/wiki-default/TracNotification => TracNotification
 Indexing repository

Project environment for 'linuxhappy' created.

You may now configure the environment by editing the file:


If you'd like to take this new project environment for a test drive,
try running the Trac standalone web server `tracd`:

  tracd --port 8000 /var/lib/trac

Then point your browser to http://localhost:8000/trac.
There you can also browse the documentation for your installed
version of Trac, including information on further setup (such as
deploying Trac to a real web server).

The latest documentation can also always be found on the project


Since we ran that as sudo, we’ll need to change some permissions:

cd /var/lib
sudo chown www-data:www-data trac/ -Rf
sudo /etc/init.d/apache2 restart

At this point you should be home free and be able to visit https://yoursite/ and login with the same users as were setup with the svn (setup in the previous post).
Once logging in, you should see the trac homepage.

This worked fine and dandy for me!


Posted in Ubuntu, Uncategorized | Tagged: , , , , , , , | 4 Comments »

Sucess: Subversion, apache2, SSL, ubuntu 7.10/8.04, with users

Posted by linuxhappy on January 21, 2008


UPDATE: 6/21/08

I followed my instructions for Ubuntu 8.04 and everything seems to work a-ok!  Make sure if you’re on ubuntu 8.04, do all the security updates before you start!


I’m setting up a subversion source control server at home because I need some sort of version control system. I know there’s lots of tutorials out there on doing this, but none of them seemed to work start to finish from a super uber fresh ubuntu 7.10 machine… It’s understandable, most people already have live systems running.. So after all subversion/ssl/apache research, I’m basing this post on two (very exceptional) tutorials:

HOWTO – Apache2 + Subversion + SSL

Subversion over Apache 2 on Ubuntu

I’m going to take the approach that you’ve just installed Ubuntu 7.10 Gutsy Gibbon and starting out fresh. This setup is overkill for one guy using one source control server, but, in case one day I want to setup an Enterprise Subversion server.. well I can say that I have done it.. sooo here we go!

Apache + Subversion + SSL + Certificates + users
.. just for me.. ha ha ha ha

 - Boot your freshly installed Ubuntu machine

 - Install all the updates with that handy dandy popup that ubuntu gives you in the upper
right hand corner and then grab a beverage of choice:
 [ beer | wine | box juice | mineral water | coffee | tea ]

 - Reboot if needed, then open a shell!

Install openssh-server

sudo apt-get install openssh-server

Install apache2

sudo apt-get install apache2

Install subversion

sudo apt-get install subversion

Install libapache2-svn

sudo apt-get install libapache2-svn

Restarting apache

sudo /etc/init.d/apache2 restart

Now lets enable SSL

sudo a2enmod ssl

At this point if you cat the file /etc/apache2/ports.conf, it should say the following:

jwoo@monkfish:~$ cat /etc/apache2/ports.conf
Listen 80
<IfModule mod_ssl.c>
    Listen 443

Ok, now we have to run this apache2-ssl-certificate, here’s what I did:

mkdir temp
cd temp
tar -xzvf apache2-ssl.tar.gz
sudo cp ssleay.cnf /usr/share/apache2/.
sudo mkdir /etc/apache2/ssl
sudo ./apache-ssl-certificate
[ Fill in your custom information ]

Modify your own ssl site (/etc/apache2/sites-available/myown-ssl)

cd /etc/apache2/sites-available
sudo cp default myown-ssl
sudo gedit myown-ssl

Change this from: NameVirtualHost *
To:                       NameVirtualHost *:443

Change this from: <VirtualHost *>
To:                       <VirtualHost *:443>

Right before </VirtualHost>, add in:

SSLEngine on
SSLCertificateFile /etc/apache2/ssl/apache.pem
SSLProtocol all
	(save, quit)


sudo a2ensite myown-ssl
sudo /etc/init.d/apache2 restart

Now modify your dav_svn.conf file

sudo gedit /etc/apache2/mods-available/dav_svn.conf
<Location /svn>
	DAV svn
	SVNPath /var/lib/svn
	AuthType Basic
	AuthName "Subversion Repository"
	AuthUserFile /etc/apache2/dav_svn.passwd
	Require valid-user

(save and exit)

Now lets create the directory that svn will use

sudo mkdir /var/lib/svn
sudo svnadmin create /var/lib/svn
sudo chown -R www-data /var/lib/svn

Now to create a user, use the following:

sudo htpasswd -cm /etc/apache2/dav_svn.passwd jwoo
	(use any user name you want, don't use mine.. unless you have the same name as me)

Now, restart!

sudo /etc/init.d/apache2 restart

Ok. now at this point, you should be able to use firefox to go to:


and login with the user name and password you just created

So, now we can start adding in a structure for our source control server.

svn mkdir https://yourserver/svn/project -m "new project"
svn mkdir https://yourserver/svn/project/trunk -m "trunk"
svn mkdir https://yourserver/svn/project/branches -m "branches"
svn mkdir https://yourserver/svn/project/tags -m "tags"

Part 2, I’ll get trac going.

Posted in Ubuntu | Tagged: , , , , , , | 15 Comments »

Fun: C API for Expect in an hour

Posted by linuxhappy on January 15, 2008

Ok, I’ve got about an hour or two before I have to sleep, so the goal of this blog is to get familiar with the C API for Expect ( before I go zZzzzz. Lets get something straight:
1. I’ve never used tcl/tk (nor do I know what it is really capable of)
2. I’ve never used expect
3. This exercise is purely for just getting myself familiar with this C API, perhaps dig into tcl/tk, and perhaps dig into expect a little bit… Ultimately learning *something* new.
4. I’m not a http protocol expert
5. After googling around I noticed that I couldn’t find too many articles about using the C API for expect…. So here’s my attempt.

I’m developing on my trusty Ubuntu 7.10 laptop which is working out just spiffy… I decided it was finally time to get the gcc man pages… Crediting the following page ( I got all the doc/man pages/info pages I needed:

sudo apt-get install gcc-doc manpages-dev manpages-posix-dev

Now I can do silly things like `man 3 write` to answer my silly questions like, “oh wait, what does write return again?”

Ok, so first, we gotta get Tcl and expect. I guess I don’t need to install tk because I don’t plan on controlling anything X related.. Ok, so after a couple of tries, I came up with the following:

#Set up a working directory and download files
mkdir ~/expect
cd ~/expect
tar -xzvf expect.tar.gz
tar -xzvf tcl8.4.17-src.tar.gz

#Compiling tcl
cd tcl8.4.17/unix
./configure --prefix=~/expect/tcl-install --enable-shared
make install
make install-private-headers
cd ../../

#Compiling expect
cd expect-5.43
#Note: use your own home dir ;)
./configure --prefix=/home/jwoo/expect/tcl-install/ --with-tcl=/home/jwoo/expect/tcl-install/lib \
  --with-tclinclude=/home/jwoo/expect/tcl-install/include/  --enable-shared
make install

If that doesn’t work, then maybe I’ve got something on my build system that you don’t, but it is pretty straightforward on how to compile and install. Also you might have noticed that I installed tcl and expect in my home directory. I tend to do this because I rather not mix nice and neat ubuntu/debian packages with these source installed tar.gz’s. Now it’s time to link your own custom user space application against the expect library and the tcl library! In this case I have decided to create a simple telnet session that simply requests for an (html) webpage, and dumps it to a screen. hooray! haha.

mkdir ~/expect/htmlrip && cd ~/expect/htmlrip
touch ~/expect/htmlrip/htmlrip.c
touch ~/expect/htmlrip/Makefile

Inside my makefile I have the following:


CFLAGS=-I../tcl-install/include -L../tcl-install/lib -lexpect5.43 -ltclstub8.4
        gcc  -o htmlrip htmlrip.c $(CFLAGS)

        rm htmlrip -f

Inside my C file, I’ve got a request, to request


#include <stdio.h>
#include <string.h>

#include "expect.h"
#define APPNAME "htmlrip"
int main()
  int fd;
  int i=0;
  int retval=0;
  //Thank you wireshark ;)
  char getstr[] = "GET / HTTP/1.1\r\nHost:\r\nUser-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv: Gecko/20071204 Ubuntu/7.10 (gutsy) Firefox/\r\nAccept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5\r\nAccept-Language: en-us,en;q=0.5\r\nAccept-Encoding: gzip,deflate\r\nAccept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\nKeep-Alive: 300\r\nConnection: keep-alive\r\n";

  unsigned char rcv_buf[4096]__attribute__((aligned(4)));

  printf("Starting htmlrip\n");
  fd = exp_spawnl("telnet", "telnet", "", "http", (char *)0);
  retval = write(fd, getstr, strlen(getstr));
  if (retval < 0)
      printf("%s: Failed to write to telnet session: %d\n", APPNAME, retval);
      return retval;
    printf("%s: Wrote %d bytes to fd=%d\n", APPNAME, retval, fd);

  printf("Printing out html\n");
  while (retval !=-1)
      memset(rcv_buf, 0, sizeof(rcv_buf));
      retval = read(fd, rcv_buf, sizeof(rcv_buf));
      for(i =0; i < retval; i++)
          printf("%c", rcv_buf[i]);
  return 0;

Finally to Build/Compile/Run:

cd ~/expect/htmlrip/
LD_LIBRARY_PATH=../tcl-install/lib ./htmlrip

Ok ok. here’s some warning: when you run it this program, it’ll request the google webpage, and at the end, it’ll say: “Your client has issued a malformed or illegal request”… I’m pretty certain I screwed up the HTTP request some how, because the same http request works for simple html pages. Maybe someone can fill me in on what I’m doing wrong… but.. the focus of this project was to explore the expect C api (not the http protocol.)

Posted in Uncategorized | Tagged: , , , , | 1 Comment »

Success: QEMU connex with two ethernet ports

Posted by linuxhappy on January 8, 2008

Ever since I’ve been using virtual box to virtualize windows on Ubuntu, I’ve been really curious about the internals of hardware emulation. I took a quick peek into the QEMU stuff and was surprised to find that someone had tried to emulate a Gumstix Connex board on QEMU. Having one of these development boards handy, I figure I dig in take it for a test drive.

Turns out that the latest version of software only supported only one Ethernet port… This is different than my hardware configuration, where I have two Ethernet ports (netDuo-mmc). Well anyways, long story short, I dug into some code and matched it up with the hardware and found a way to get two ethernet ports working in a pretty short amount of time.

Next thing on my plate is that I want the MMC slot properly emulated.. I can’t seem to get that working quite right. If anyone out there has some hints, pass them along please!

Posted in Virtualization | Tagged: , , , , | 3 Comments »