I'm trying to make apache load basic auth credentials from a sqlite3 database.

The configuration I've tried (and many other variations) is:

<VirtualHost *>
    ServerAdmin admin@example.com
    ServerName git.example.com
    ErrorLog "/var/log/httpd/git-error_log"
    CustomLog "/var/log/httpd/git-access_log" common
    DocumentRoot "/usr/share/cgit/"
    DBDriver sqlite3
    DBDParams "/home/git/db.sqlite"
    DBDMin 1
    DBDKeep 2
    DBDMax 10
    DBDExptime 60

    <Directory "/usr/share/cgit/">
        AuthType Basic 
        AuthName Test 
        AuthBasicProvider dbd 
        Require valid-user 
        AuthDBDUserPWQuery "SELECT pw AS password FROM cgit_passwords WHERE uid=%s" 
        AllowOverride None
        Options ExecCGI FollowSymlinks
        Order deny,allow
        Allow from all

    Alias /cgit.css "/usr/share/cgit/cgit.css"
    Alias /cgit.png "/usr/share/cgit/cgit.png"
    Alias /favicon.ico "/usr/share/cgit/favicon.ico"
    #ScriptAlias / "/var/www/cgi-bin/cgit/"
    #Alias /cgit-data "/usr/share/cgit"

However, apache complains that:

[dbd:error] [pid 16673] (20014)Internal error: AH00629: Can't connect to sqlite3: unable to open database file

Which doesn't make sense. I've enabled a shell for the apache user, logged in with su - apache, and I can open and execute operations on the database "/home/git/db.sqlite"

  • Is this on a Linux system? On one with SELinux enabled?
    – Jeff Schaller
    Feb 14 '18 at 14:08
  • Yes, selinux is enabled.
    – Flavius
    Feb 14 '18 at 14:09
  • as another possibility: fredericiana.com/2014/11/29/sqlite-error-open-database-file -- indicates that the apache user would need to be able to write a file in /home/git
    – Jeff Schaller
    Feb 14 '18 at 14:10
  • Apache user is able to create new files in /home/git and write to them.
    – Flavius
    Feb 14 '18 at 14:14
  • Are there any related log entries in audit log (/var/log/audit/audit.log)?
    – sebasth
    Feb 14 '18 at 15:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.