Bazaar Smart server setup falied in Linux

Asked by Vijaya Kumar

Hi all,

I’m trying to setup smart server for bazaar in linux using apache and mod_python or mod_wsgi.
Tried the same steps as mentioned here:- http://doc.bazaar.canonical.com/beta/en/user-guide/http_smart_server.html

Repository is in another shared drive, which is mounted to this linux m/c . (/mnt/p/HC_Data/repo/renessas)

Getting error:-
C:\>bzr log bzr+http://137.55.208.82/renessas/RC1234
bzr: ERROR: Generic bzr smart protocol error: Invalid http response for http://137.55.208.82/renessas/RC1234/.bzr/smart: Unknown response code 403

Here I attached my http.conf file and bzr.wsgi scripts.
Could any please analyze and let me know why it is not working for me.

Thanks & Regards,
Vijay

Question information

Language:
English Edit question
Status:
Solved
For:
Bazaar Edit question
Assignee:
No assignee Edit question
Solved by:
Martin Packman
Solved:
Last query:
Last reply:

This question was reopened

Revision history for this message
Vijaya Kumar (vijayakumar-cm) said :
#1

>>>>>>>>>>>Httpd.conf/wsgi >>>>>>>>>>>>>
#WSGI method
WSGIScriptAliasMatch ^/renessas/.*/\.bzr/smart$ /mnt/p/HC_Data/scripts/bzr.wsgi

#The three next lines allow regular GETs to work too
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/renessas/.*/\.bzr/smart$
RewriteRule ^/renessas/(.*/\.bzr/.*)$ /mnt/p/HC_Data/repo/renessas/$1 [L]

<Directory /mnt/p/HC_Data/repo/renessas>
    WSGIApplicationGroup %{GLOBAL}
</Directory>
>>>>>>>>>>>>>>>>>>>>>>>>

>>>>>>>>>>>Httpd.conf/mod_python >>>>>>>>>>>>>
Alias /renessas /mnt/p/HC_Data/repo/renessas
<Directory /mnt/p/HC_Data/repo/renessas>
    Options Indexes FollowSymLinks
    RewriteEngine On
    RewriteBase /renessas
    RewriteRule ^(.*/)?\.bzr/smart$ /mnt/p/HC_Data/scripts/bzr-smart.py
 #RewriteRule ^(.*/|)\.bzr/smart$ /mnt/p/HC_Data/scripts/bzr-smart.py
   #RewriteRule ^/renessas/(.*/\.bzr/.*)$ /mnt/p/HC_Data/scripts/bzr-smart.py
</Directory>

Alias /mnt/p/HC_Data/scripts/bzr-smart.py /mnt/p/HC_Data/scripts/bzr-smart.py
<Directory /mnt/p/HC_Data/scripts>
    <Files bzr-smart.py>
        PythonPath "['/usr/lib/python2.4/site-packages/bzrlib']+sys.path+['/mnt/p/HC_Data/scripts']"
        AddHandler python-program .py
        PythonHandler bzr-smart::handler
    </Files>
</Directory>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

>>>>>>>>>>>bzr.wsgi>>>>>>>>>>>>>>>>>
from bzrlib.transport.http import wsgi

def application(environ, start_response):
    app = wsgi.make_app(
        root="/mnt/p/HC_Data/repo/renessas/",
        prefix="/renessas",
        readonly=True,
        enable_logging=False)
    return app(environ, start_response)
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

>>>>>>>>>>>>bzr-smart.py>>>>>>>>>>>>
import modpywsgi
from bzrlib.transport.http import wsgi

smart_server_app = wsgi.make_app(
    root='/mnt/p/HC_Data/repo/renessas',
    prefix='/renessas/',
    path_var='REQUEST_URI',
    readonly=True,
    load_plugins=True,
    enable_logging=True)

def handler(request):
    """Handle a single request."""
    wsgi_server = modpywsgi.WSGIServer(smart_server_app)
    return wsgi_server.run(request)
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Revision history for this message
Martin Pool (mbp) said :
#2

http 403 means 'forbidden', probably something in your configuration
is blocking this request. check apache's error.log.

Revision history for this message
Vijaya Kumar (vijayakumar-cm) said :
#3

Hi,

Here is the apache error.log

[Wed Nov 09 12:39:54 2011] [error] [client 161.92.51.226] (13)Permission denied: access to /renessas/RC1234/.bzr/smart denied
[Wed Nov 09 12:39:54 2011] [error] [client 161.92.51.226] (13)Permission denied: access to /renessas/RC1234/.bzr/smart denied
[Wed Nov 09 12:40:11 2011] [error] [client 161.92.51.226] (13)Permission denied: access to /renessas/RC1234/.bzr/smart denied
[Wed Nov 09 12:40:11 2011] [error] [client 161.92.51.226] (13)Permission denied: access to /renessas/RC1234/.bzr/smart denied

FYI., i changed the repository to local and gave full permission for all users.. still the same error..

Revision history for this message
Vijaya Kumar (vijayakumar-cm) said :
#4

Access_log..

161.92.51.226 - - [09/Nov/2011:12:39:54 +0800] "POST /renessas/RC1234/.bzr/smart HTTP/1.1" 403 306 "-" "bzr/2.3.4 (urllib)"
161.92.51.226 - - [09/Nov/2011:12:39:54 +0800] "POST /renessas/RC1234/.bzr/smart HTTP/1.1" 403 306 "-" "bzr/2.3.4 (urllib)"
161.92.51.226 - - [09/Nov/2011:12:40:11 +0800] "POST /renessas/RC1234/.bzr/smart HTTP/1.1" 403 306 "-" "bzr/2.1.4 (urllib)"
161.92.51.226 - - [09/Nov/2011:12:40:11 +0800] "POST /renessas/RC1234/.bzr/smart HTTP/1.1" 403 306 "-" "bzr/2.1.4 (urllib)"

Revision history for this message
Martin Pool (mbp) said :
#5

I think you must have some other apache configuration that's blocking
these requests. Check out
http://httpd.apache.org/docs/2.2/howto/access.html

Revision history for this message
Vijaya Kumar (vijayakumar-cm) said :
#6

Hi Martin,
I still couldn't find the issue.. can i share my httpd.conf file.

Revision history for this message
Martin Pool (mbp) said :
#7

sure

Revision history for this message
Vijaya Kumar (vijayakumar-cm) said :
#8
Revision history for this message
Martin Packman (gz) said :
#9

For mod_wsgi, you need to allow access to the scripts dir, eg:

<Directory /mnt/p/HC_Data/scripts/>
 Order deny,allow
 Allow from all
</Directory>

Be aware that if you want to enable write access, you won't want "Allow from all", or will need some other mechanism of restricting access.

Revision history for this message
Vijaya Kumar (vijayakumar-cm) said :
#10

I allowed access and tried both the methods(mod_python) & (mod_wsgi), but still the same issue.

Error:-
C:\>bzr log bzr+http://137.55.208.82/bzr/renessas/RC1234
bzr: ERROR: Generic bzr smart protocol error: Invalid http response for http://137.55.208.82/bzr/renessas/RC1234/.bzr/smart: Unknown response code 403

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
##mod_python
Alias /bzr /home/tanst/repo
<Directory /home/tanst/repo>
 Order allow,deny
    Allow from all
    Options Indexes FollowSymLinks
    RewriteEngine On
    RewriteBase /bzr
    RewriteRule ^(.*/)?\.bzr/smart$ /root/bzr/scripts/bzr-smart.py
 #RewriteRule ^(.*/|)\.bzr/smart$ /root/bzr/scripts/bzr-smart.py
    #RewriteRule ^/bzr/(.*/\.bzr/.*)$ /root/bzr/scripts/bzr-smart.py
</Directory>

Alias /root/bzr/scripts/bzr-smart.py /root/bzr/scripts/bzr-smart.py
<Directory /root/bzr/scripts>
    <Files bzr-smart.py>
  Order allow,deny
  Allow from all
  PythonPath "['/usr/lib/python2.4/site-packages/bzrlib']+sys.path+['/root/bzr/scripts']"
        AddHandler python-program .py
        PythonHandler bzr-smart::handler
    </Files>
</Directory>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

##WSGI method

<Directory /root/bzr/scripts/>
 Order deny,allow
 Allow from all
</Directory>

WSGIScriptAliasMatch ^/bzr/.*/\.bzr/smart$ /root/bzr/scripts/bzr.wsgi

#The three next lines allow regular GETs to work too
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/bzr/.*/\.bzr/smart$
RewriteRule ^/bzr/(.*/\.bzr/.*)$ /home/tanst/repo/$1 [L]

<Directory /home/tanst/repo>
 Order deny,allow
 Allow from all
    WSGIApplicationGroup %{GLOBAL}
</Directory>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Revision history for this message
Martin Packman (gz) said :
#11

The www-data (or equivalent) user also has access to both the scripts directory and the repo?

I suggest picking just one mod_ and sticking with it, trying to get both working at once is confusing. You want a minimal failing case so you can work out where the problem is, rather than adding new things. I suggest working from the basics up:

# Get basic http access to the repo working. That's just an Alias or the mod_rewrite stuff.
# Add a hello world WSGI script and try accessing it through the browser.
# Finally, add the smart server script and pattern for it.

Make sure you post the apache error log extract if you get stuck, rather than assuming it's the same as before.

Revision history for this message
Vijaya Kumar (vijayakumar-cm) said :
#12

Hi, I tried with mod_python mod and failed.. complete details below... couldn't find out why cant i access the repo via apache.

Path:- /home/tanst/scripts
Path:- /home/tanst/repo
 Repository: renessas
 Branch: RC1234

>>>>>>>>bzr-smart.py>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
import modpywsgi
from bzrlib.transport.http import wsgi

smart_server_app = wsgi.make_app(
    root='/home/tanst/repo',
    prefix='/bzr/',
    path_var='REQUEST_URI',
    readonly=True,
    load_plugins=True,
    enable_logging=True)

def handler(request):
    """Handle a single request."""
    wsgi_server = modpywsgi.WSGIServer(smart_server_app)
    return wsgi_server.run(request)
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

>>>>>>>>>>>>>>>>>>httpd.conf>>>>>>>>>>>>>>>>>>>>>>>
##mod_python
Alias /bzr /home/tanst/repo
<Directory /home/tanst/repo>
 Order allow,deny
   Allow from all
   Options Indexes FollowSymLinks
   RewriteEngine On
   RewriteBase /bzr
   RewriteRule ^(.*/)?\.bzr/smart$ /home/tanst/scripts/bzr-smart.py
</Directory>

Alias /home/tanst/scripts/bzr-smart.py /home/tanst/scripts/bzr-smart.py
<Directory /home/tanst/scripts>
   <Files bzr-smart.py>
  Order allow,deny
  Allow from all
  PythonPath "['/usr/lib/python2.4/site-packages/bzrlib']+sys.path+['/home/tanst/scripts']"
       AddHandler python-program .py
       PythonHandler bzr-smart::handler
   </Files>
</Directory>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

httpd.conf:
https://docs.google.com/document/d/1ZEGtDnR8IQRK7E8s-J5EvqMsa4mBZotRYeOpktjoKKY/edit

Apache Log:-
error_log - Log Once I started apache.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
[Thu Nov 10 09:19:56 2011] [notice] caught SIGTERM, shutting down
[Thu Nov 10 09:23:04 2011] [notice] SELinux policy enabled; httpd running as context user_u:system_r:httpd_t:s0
[Thu Nov 10 09:23:04 2011] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Thu Nov 10 09:23:04 2011] [warn] module python_module is already loaded, skipping
[Thu Nov 10 09:23:04 2011] [notice] Digest: generating secret for digest authentication ...
[Thu Nov 10 09:23:04 2011] [notice] Digest: done
[Thu Nov 10 09:23:04 2011] [notice] mod_python: Creating 4 session mutexes based on 256 max processes and 0 max threads.
[Thu Nov 10 09:23:04 2011] [notice] Apache/2.2.3 (CentOS) configured -- resuming normal operations
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Executed command:-
C:\>bzr log bzr+http://137.55.208.82/bzr/renessas/RC1234
bzr: ERROR: Generic bzr smart protocol error: Invalid http response for http://137.55.208.82/bzr/renessas/RC1234/.bzr/smart: Unknown response code 403

Apache Log:-
Error log:-
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
[Thu Nov 10 09:25:16 2011] [error] [client 137.55.202.44] (13)Permission denied: access to /bzr/renessas/RC1234/.bzr/smart denied
[Thu Nov 10 09:25:16 2011] [error] [client 137.55.202.44] (13)Permission denied: access to /bzr/renessas/RC1234/.bzr/smart denied
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Access log:-
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
137.55.202.44 - - [10/Nov/2011:09:25:16 +0800] "POST /bzr/renessas/RC1234/.bzr/smart HTTP/1.1" 403 309 "-" "bzr/2.3.4 (urllib)"
137.55.202.44 - - [10/Nov/2011:09:25:16 +0800] "POST /bzr/renessas/RC1234/.bzr/smart HTTP/1.1" 403 309 "-" "bzr/2.3.4 (urllib)"
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Revision history for this message
Vijaya Kumar (vijayakumar-cm) said :
#13

Hi all,
It is working now after disable SELinux.

Revision history for this message
Vijaya Kumar (vijayakumar-cm) said :
#14

Hi,

Now i'm getting this commit error.

Commit Error:-
bzr: ERROR: Cannot lock LockDir(chroot--1213941076:///renessas/RC1234/.bzr/branch/lock): Transport operation not possible: readonly transport

i have given full permission to repository, but still the same issue.
Any idea ???

Revision history for this message
Vijaya Kumar (vijayakumar-cm) said :
#15

Repository:-
[tanst@P690-6YWJR1S src]$ ls -la /home/tanst/repo/
total 24
drwxrwxr-x 3 tanst apache 4096 Nov 8 16:30 .
drwxr-xr-x 29 tanst RemoteUsr 4096 Nov 10 13:41 ..
drwxrwxrwx 5 tanst apache 4096 Nov 8 16:30 renessas

File tried to add:-
[tanst@P690-6YWJR1S src]$ ls -l
total 4
-rwxrwxrwx 1 tanst RemoteUsr 0 Nov 10 13:42 file

Revision history for this message
Best Martin Packman (gz) said :
#16

smart_server_app = wsgi.make_app(
     root='/home/tanst/repo',
     prefix='/bzr/',
     path_var='REQUEST_URI',
     readonly=True,
     load_plugins=True,
     enable_logging=True)

Did you change this to `readonly=False` before trying to push (also see my earlier access warnings).

Revision history for this message
Vijaya Kumar (vijayakumar-cm) said :
#17

Thanks Martin Packman, that solved my question.