Wednesday, February 13, 2008

SVN: Can't open file '/format' Permission denied

I setup a Subversion repository on my Ubuntu system yesterday. Everything went smoothly for the most part.

I installed the Subversion package with the following command. Included in the package was svn, svnadmin, & svnserve.
sudo apt-get install subversion

I added a new subversion user & group. I added the new subversion user, and myself, to the subversion group.
sudo useradd --password pass subversion
sudo groupadd subversion
sudo adduser subversion subversion
sudo adduser me subversion

I created a repository, changed ownerships, & permissions.
sudo svnadmin create /svn/myrepos
sudo chown -R me:subversion /svn/myrepos
sudo chmod -R 0770 /svn/myrepos

I modified the repositories conf/passwd and conf/svnserv.conf files to allow read-only access by anonymous users & write access for me.

I went in and modified certain files like conf/passwd & conf.svnserv.conf to 0440 (owner & group read-only)

I started svnserve in the /svn directory as the subversion user.
sudo su subversion
svnserve -d -r /svn

But when trying to checkout the repository with Tortoise SVN on my Windows machine, I kept getting an error similar to the following.
Error Can't open file '/svn/format': Permission denied

Even when I chmod'ed the format file to 0777, I still got the error.

Come to find out, it really had little to do with that file directly. What it did have to do with was the permissions of the user that started svnserve & the directory svnserve was told to use as the repository root.

/svn had 0760 permissions, as soon as I gave my subversion group execute permissions so the subversion user who is a member of the subversion group & is starting the server could execute, it worked like a charm.
sudo chmod 0770 /svn

Tuesday, February 5, 2008

Hello World C Application On Ubuntu

Working with PHP has been a good way for me to become more familiar with C programming. It seems that alot of the syntax carries over between the two. Same with standard function names, like fopen for instance.
My biggest issue with picking up C was that I always became fustrated with trying to setup and understand compilers & the tools that come with them. I couldn't even get a Hello World application written in C to work.

I decided to give C Programming another try on my Ubuntu box. All of my previous attempts had been on Windows, and now that I've become familiar with Ubuntu it seemed like somthing worth trying.

It was actually alot easier than I thought it was going to be. Since I don't have a monitor hooked up to my Ubuntu computer I used PuTTy to run commands, and FTP for file editing.

First thing I did was use PuTTy to create a foo directory in my home directory, then I put some files in the foo directory.
me@box:~$ mkdir /home/me/foo
me@box:~$ cd /home/me/foo
me@box:~/foo$ touch .deps
me@box:~/foo$ touch Makefile
me@box:~/foo$ touch hello.c

I opened hello.c in my text editor, and typed the following.
#include <stdio.h>

puts("Hello World!");
return 0;

After I saved hello.c and placed it on the server with FTP I ran the following command.
me@box:~/foo$ make hello

Which output the following before going back to the prompt.
cc     hello.c   -o hello

That's it. I ran the application from the prompt & out popped "Hello World!".
me@box:~/foo$ ./hello
Hello World!