Search code examples
ubuntufirebirdrightsfirebird-3.0

How to configure firebird 3.0 or set rights so any user can create a DB


I followed this guide for firebird3.0 on ubuntu. It is outdated, since there is no more employe.fdb in the examples and you have to create it itself through the included sql script. My problem is, that I can only create this database if I use isql-fb as sudo. I followed the suggestions here and here and I can connect without sudo now if I add localhost: to the path, but I still can't create a database. Like I don't even have a firebird goup to add myself to. If I try to create a database not as sudo I get this error:

Statement failed, SQLSTATE = HY000
operating system directive access failed
-Not a directory

Solution

  • I followed the steps on https://help.ubuntu.com/community/Firebird3.0 on Ubuntu 21.04 until sudo apt-get install firebird3.0-examples firebird-dev, and I skipped the step sudo add-apt-repository ppa:mapopa/firebird3.0 as firebird3.0 is already in the default repository. Installation created a firebird group for me.

    The essential step that is missing from that page is adding yourself to the group firebird. If you don't do this, you don't have access to some of the files and/or directories used by the Firebird Embedded engine (which is used when you don't specify a host name), which causes the error shown in your question.

    Use usermod -aG firebird <yourusername> to add yourself, followed by newgrp firebird to refresh the group list in your current session*. You can then use isql-fb without specifying a host name like localhost. For example, using the instructions in README.Debian in /usr/share/doc/firebird3.0-examples/examples/ to create the employee example database.

    Keep in mind, when specifying only filenames in Firebird, you're using its Embedded mode, and files are accessed with the filesystem access rights of your current user. If you prefix it with localhost:, it will connect through the Firebird Server process on your machine using the filesystem access rights of the firebird user. This difference is important, because the firebird user has - for example - no access to your home directory.

    To be able to create a database through Firebird Server, the user must have sufficient privileges to create databases. By default only the SYSDBA user has this privilege.

    To be able to create users, you need to be attached to a database, with a user with sufficient privileges to creates users.

    If you don't have a database yet, you can create one:

    create database 'localhost:<path-to-db>' user sysdba password '<your password>';
    

    If you already have a database, you can use:

    connect 'localhost:<path-to-db>' user sysdba password '<your password>';
    

    You can then create - as SYSDBA - additional users with CREATE USER:

    CREATE USER NAMAL PASSWORD '12345';
    

    To give this user the privilege to create a database, use - as SYSDBA - GRANT:

    GRANT CREATE DATABASE TO USER NAMAL;
    

    * Minor caveat: I didn't actually try newgrp myself, instead I rebooted my VM before I found this option