pgagroal icon indicating copy to clipboard operation
pgagroal copied to clipboard

Adding filename to master key generation Issue #419

Open palak-chaturvedi opened this issue 10 months ago • 11 comments

Updated with respect to the new configuration.c changes.

  • Can add -c conf-file to the master-key generation pgagroal-admin -c conf-file -g master-key
  • The pgagroal_get_master_key() is also updated to access the master_key_file_location from the conf file.

@jesperpedersen @fluca1978

palak-chaturvedi avatar Apr 01 '24 14:04 palak-chaturvedi

Please, use the same pull request, and force push changes instead of opening new ones...

jesperpedersen avatar Apr 01 '24 15:04 jesperpedersen

Okk I will continue in this There were some merge conflicts in it. I was not able to pull all the new commits from the master branch. So I thought I would make it much cleaner in this one.

palak-chaturvedi avatar Apr 01 '24 18:04 palak-chaturvedi

@palak-chaturvedi please be patient, let's go back one step: add the -m flag to both pagroal- and pgagroal-admin, so that if specified, the executables can find out the correct location of the master key file and other related stuff. Then we will decide if and how to handle it within the main configuration file.

fluca1978 avatar Apr 04 '24 13:04 fluca1978

If we add the -m flag then we will have to change lots of functions including reloading the configuration files and all the functions in configuration.c . Is this better option than conf file changing?

palak-chaturvedi avatar Apr 06 '24 20:04 palak-chaturvedi

It is ok for the pgagroal.conf file, but pgagroal-admin shouldn't depend on that file

jesperpedersen avatar Apr 06 '24 23:04 jesperpedersen

Ok so If the conf file is not given then all the functions other than those that require master-key should not throw error.

I am working on the -m flag it would change all the configuration.c functions because master key is required in those codes.

palak-chaturvedi avatar Apr 07 '24 12:04 palak-chaturvedi

I'm wondering if this is rally worth, since it seems to be fairly complex (as of design).

However, mu opinion is that pgagroal.conf should have a setting for the master key file location, and pgagroal-admin should have a -m flag that reflects the same setting. In this way, the configuration of main should be straightforward, while the pgagroal-admin can use the same location specified on the command line. However, this could cause some confusion, since pgagroal-admin does not ask for a master key location, and will write on the default path, so the user can end up with pgagroal-admin writing in a location and pgagroal looking into another without any error or warning. Is it worth?

fluca1978 avatar Apr 08 '24 07:04 fluca1978

The master_key_path is in pgagroal.conf, so it will be used for pgagroal. pgagroal-cli also uses pgagroal.conf.

The only binary that you have to change are pgagroal-admin with the -m switch, and pgagroal-vault for the pgagroal-vault.conf configuration

jesperpedersen avatar Apr 08 '24 12:04 jesperpedersen

heyy @fluca1978 I made the changes can you please check once again?

palak-chaturvedi avatar Apr 21 '24 13:04 palak-chaturvedi

Looks fine. A few comments:

  1. if I try to use a command that do not require a master key file with a wrong master key file, everything works fine. Maybe we should check for the -m usage early in pgagroal-admin:
% pgagroal-admin user ls --master-key-file /this/does/not/exists
luca
  1. if pgagroal does not find the master key file, it warns with the wrong error message:
% pgagroal
pgagroal: Invalid master key file (file </etc/pgagroal/pgagroal_users.conf>)
  1. I would remove master_key_file_location from the configuration and add the -m flag to the pgagroal tool itself.

fluca1978 avatar Apr 22 '24 07:04 fluca1978

@palak-chaturvedi in commit 411a0fa you fixed the first problem, good! Still issue two is there.

% pgagroal                                   
pgagroal: Invalid master key file (file </etc/pgagroal/pgagroal_users.conf>)

and this is related to issue three: I would remove the master key file from the configuration and add the -m option to main.c. Otherwise, if you believe it is better to keep such file in the configuration file, can you please argument your idea?

fluca1978 avatar Apr 29 '24 11:04 fluca1978