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

8 comments:

Jonathan-David SCHRODER said...

Thank you for your exposing the problem and the answer.
Happy New Year !
Sincerely,
Jonathan

Yehia A.Salam said...

save my life

Fikeis said...

me too...good job, man.

Diego said...

I'm having the same problem but with no luck... I think my problem is that Tortoise SVN is never asking for a user/pass?

on ubuntu, my user is already a member of subversion and subvenrsion is the owner of my /var/www/SVN folder with 777 permissions (I changed from 0770 to test)

Any other idea? thanks!

James Stroud said...

I ran into one of these problems: svn:
Can't open file 'xxx/.svn/lock': Permission denied
I tried several web remedies, but nothing worked. I think it had something to do with running svn as root when I checked out the repository. Answer? I just run commands in that dir as root. It is probably not the best way, but when you don't have time to debug the problem correctly, this may work for others as a catchall.

Marco Schlatter said...

Hi to everyone.

I had the same problem "Can't open file...: Permission denied"
After reviewing my log-File, I could see, that the permission on the format-File is wrong. For testing everything, i set the permissions on the whole svn folder on 777. Nothing worked.

After that, i used the command chcon (change context) because SELinux was enabled and changed it for the folder from home_root_t to httpd_sys_content_t. You can see that with ls -Z

So, the command was:
chcon -R -t httpd_sys_content_t %repos-name%

<a href="http://www.marcoschlatter.com>Regards Marco</a>

Anonymous said...

It helps me, thanks a lot !!!

Qays Poonawala said...

Thanks!
Using "sudo -u www-data cat format" and "sudo -u www-data cat /path/to/format" was great advice.
We used setfacl to give www-data permission to the higher directories as needed.
"setfacl -R -m user:www-data:rX /path/to/"