Firebird does not forget default password after changing it for sysdba user - firebird

I am unable to make Firebird forget the old password for default user. I have installed Firebird version 3.0.4 on my local computer. I have tried to change the default password masterkey to another one via gsec tool. First I have logged in into this tool with command:
gsec -user sysdba -password masterkey -database "C:\Program Files\Firebird\Firebird_3_0\security3.fdb"
And then with command modify I have set next password:
modify sysdba -pw qwerty12
The issue is that now I can login into sysdba account with both passwords, the old masterkey password and the new one qwerty12 password. How can I make the Firebird to forget the old default password?

The problem is not that Firebird remembers the default password, the problem is that Firebird stores a password per authentication plugin, and SYSDBA happens to exist for two (or possibly more) authentication plugins.
To fix this, you must either drop the SYSDBA account for one of the authentication plugins, or change its password. Dropping the SYSDBA account is, unfortunately, rather hard to do for the Legacy_Auth plugin (you need to manually delete it from the security database, see at the end of this answer).
Assuming the standard Firebird install (which has authentication plugins Srp and Legacy_Auth), you need to do the following to change the password (note: I'm assuming that the problematic account is the one for Legacy_Auth, not Srp):
In firebird.conf, setting UserManager ensure both user managers are listed:
UserManager = Srp, Legacy_UserManager
Restart Firebird
Change the password for both plugins
alter user SYSDBA password '<new password>' using plugin Srp;
alter user SYSDBA password '<new password>' using plugin Legacy_UserManager;
Keep in mind: the legacy authentication plugin truncates passwords at 8 characters.
If you want to prevent authentication using the Legacy_Auth plugin entirely, then edit the firebird.conf and remove Legacy_Auth from the AuthServer setting (also check databases.conf if the database has a custom configuration).
I have asked a question on the firebird-devel mailing list about the inability to drop the Legacy_Auth SYSDBA account. The answer I got was that historically it was impossible to delete the SYSDBA account in older Firebird versions, so the Legacy_UserManager plugin explicitly disallows deleting SYSDBA (while Srp allows it). The workaround is to connect directly to the security database, and delete the user manually from the PLG$USERS table (which contains the Legacy_Auth users, Srp users are in PLG$SRP):
delete from plg$users where plg$user_name = 'SYSDBA';
You can connect to the security database using isql -user sysdba -password <yourpassword> security.db (assuming the security.db alias is defined in databases.conf, otherwise use the full path to your security3.fdb).
A slightly more obscure alternative would be to define a mapping that maps an authentication as SYSDBA using Legacy_Auth to a different (unprivileged) user (eg GUEST):
create global mapping NO_LEGACY_SYSDBA
using plugin Legacy_Auth
from user sysdba to user guest;
To drop the SYSDBA account for the Srp plugin, you only need to execute (as admin):
drop user SYSDBA using plugin Srp;

Related

Firebird DDL for user and privileges

I have Firebird 2.5 and I need to extract all user and privileges as DDL to export to another Firebird database.
For example, I need get the script for user max
"Create user max FIRSTNAME 'Max' LASTNAME 'Power' Grant admin option";
I use IB Expert, but did not find this option to extract the DDL.
Tools -> Grants/Rights Manager -> Toolbar -> Save -> To Script Executive
Alternatively, go to the Tools -> Extract Metadata -> Settings and down there check the "extract grants" checkbox.
You also have to remember that users themselves do not exist in the database (only grants do), users they exist in the server, not the database.
See how to display and set user rights in firebird database
Also see GSEC documentation:
http://www.destructor.de/firebird/gsec.htm
https://www.firebirdsql.org/file/documentation/html/en/firebirddocs/gsec/firebird-gsec.html#gsec-batch
gsec -user sysdba -password <password> -database <databasename> -display - a command like that should display all the users registered with the server used to connect to the database. It would be trivial to take the user list and add the create user command to every one.
There is one more niche case that Firebird might have no any users, borrowing them from the host operating system. It is called "Trusted Authentication" mode. If GSEC would show no users or too few ones - check authentication settings in the relevant firebird.conf, maybe you would have to dump users list from Windows, not from Firebird.
https://www.firebirdsql.org/rlsnotesh/rnfb210-wintrusted.html
https://github.com/FirebirdSQL/firebird/blob/master/doc/README.trusted_authentication

PostgreSQL user account has unknown password by default

I just installed PostgreSQL 13 on Windows 11. When I run the command psql by default it uses the user aaron, the name of my Windows user account. However, it asks me for a password. I have tried all passwords associated with my Windows account as well as the default password I set for the user postgres, none of which worked. I was able to log in with psql -U postgres, and I ran the command \du, and there was only one role in the list, postgres. Later I created the role aaron without specifying a password, but it still asks for a password.
So, did the user aaron exist initially or not? If not, then how was it the default user when I ran the psql command? What is the password for this user?
So, did the user aaron exist initially or not
No, it did not. The only user that is created when installing Postgres (or more precisely: when running initdb) is postgres.
If not, then how was it the default user when I ran the psql command
Quote from the manual
The default user name is your operating-system user name, as is the default database name
psql simply uses the operating system user as the default username to connect to the server. It knows nothing about the database user(s) until it tries to connect with a specific username and potentially password.
You can set a different default through the (Windows) environment variable PGUSER
Later I created the role aaron without specifying a password, but it still asks for a password.
Whether or not a password is required is controlled through pg_hba.conf
When you run psql command and don't provide a username it considers (that the current system user which in your case is aaron) is the user you want to use to login and hence you see a user which really don't exists.
Now regarding the password you might want to check a file generally named as pg_hba.conf which hold the essentials of who can connect (IPs) what username can he have and should that user be asked for password.
Now generally you will find answers saying that find this file and write down trust everywhere (which basically means if some specific user from a specific IP access this database of replication then don't ask for a password and let him enter), which you should not do until and unless you are utterly sure the postgresql server is just just local and has no real-time purpose.
So concluding you want to create a user with some encrypted password and then provide necessary privilege.
P.S: I have tried all these on a linux machine, but the server configurations are more or less same.
It's worth pointing out that PostgreSQL has it's own users and permissions independent of the OS. Some installers will automatically create a postgres OS user. I'm not sure what Windows does.
It seems that PostgreSQL can do Windows authentication. See this question for details on how to configure that.
As #a_horse_with_no_name has said, connection configuration is controlled by pg_hba.conf
PostgreSQL tries not to leak information about its users, so the failed-authentication attempt is not given much information about why it failed.
If you look in the server's log file, rather than the clients, you should first see messages about 'aaron' failing to authenticate because the user does not existing, and then (after you create it) about it failing to authenticate because it has no password assigned.
When you created the user, you should have assigned it a password if you wanted to use a password. Or as a superuser in psql, create it without a password and then assign one with \password aaron That way the password won't be visible on the screen, or in the log files.
To give a concise, direct answer:
right click on Windows icon and click “System”.
scroll down to “Advanced System Settings”.
click Environment Variables.
in “System variables”, click “New”.
Set Variable Name to PGUSER and Variable Value to postgres.
Or, in cmd: set PGUSER=postgres, which also sets it globally.
go to "Services" (in Task Manager), and restart the "postgresql-X64" service.

Changing SYSDBA user password in InterBase

I am working with InterBase 2020 version. Since InterBase installs with default user SYSDBA and default password for SYSDBA as masterkey , I want to change the password for SYSDBA user.
Using gsec tool I am able to change the password however when I backup the database and restore it on different machine having SYSDBA password as masterkey , I am able to do this successfully.
So even if I have changed the password on my machine , InterBase db backup (with changed SYSDBA password) could be restored on a machine having SYSDBA password as masterkey.
Where is the security in this case and How could I prevent this ?
Is Embedded User Authentication a solution to prevent unauthorized users restoring the database ?
You have to activate Embedded User Authentication in your Database. So you can define different SYSDBA per Database with different password.

Firebird default user not set

When I try anything in isql, I get the message:
Your user name and password are not defined. Ask your database
administrator to set up a Firebird login.
unable to open database
When I try to create the user I still get the message:
C:\Program Files\Firebird\Firebird_3_0>gsec -user sysdba -password masterkey
use gsec -? to get help
Your user name and password are not defined. Ask your database administrator to set up a Firebird login.
unable to open database
But I am the administrator, and I installed it.
How do I create the user SYSDBA in Firebird?
The combination of the "Your user name and password are not defined. Ask your database administrator to set up a Firebird login." with "unable to open database" does not mean the SYSDBA account does not exist, it means that the Firebird process was unable to open the security database to perform authentication.
This can happen if you installed Firebird in C:\Program Files, and you are running the Firebird server as an application (instead of as a service) and UAC is enabled, or you are running as a service, but the user account running the service has insufficient rights to read and write to the security3.fdb file.
You either need to run Firebird as a service (e.g. as configured by the installer), or - if you really want to run Firebird as an application - install Firebird outside of C:\Program Files.
How do I create the user SYSDBA in Firebird?
Connect to any database (security.db or employee) in embedded mode using user name SYSDBA (password is not needed in this mode) and issue SQL command "CREATE USER" as described in Firebird Language Reference.
You can learn more about embedded mode from Firebird 3.0 Release Notes.

Setting password for PostgreSQL user doesn't work

I'm stuck.
The task: I need to have a certain Postgres user to own certain database with predefined password. Basically, I just don't want to maintain separate development settings for Django project apart from those present in our project's repo.
Prerequisites: PostgreSQL 9.1 on Ubuntu, database 'project' which has the owner 'project'. The 'project' user is seems to be also superuser, and should have the password 'project'. Of course there are fake names, just because of NDA. Note: I'm able to log in as 'postgres' user, that's how I use the database right now.
The problem: I tried a set of ways, mostly obvious which can be found here on Stackoverflow or in Google, to set a password to this user, but still having 'password authentication failed' message (see below).
What I've tried:
setting up password via PgAdmin
setting up password through ALTER ROLE project WITH PASSWORD 'project'
changing settings in pg_hba.conf, tried local all project peer, local all project md5
Maybe I'm missing something straightforward, please let me know.
Thanks!
UPDATE:
Here is a screenshot for this user from login roles pane -
See that part at the bottom of your screenshot:
.. VALID UNTIL '1970-01-01 00:00:00:
or the "Account Expires" field above
That expiration date is wrong and explains why this account can't login.
Presumably you've been bitten by the pgAdmin bug mentioned here:
Postgres password authentication fails
TL;DR solution: ALTER USER username VALID UNTIL 'infinity';
(and of course update pgAdmin).
Is the LOGIN attribute set in your role? CREATE ROLE does not set this attribute by default. See: http://www.postgresql.org/docs/9.1/static/role-attributes.html