diff options
author | Jeffrey Armstrong <jeff@approximatrix.com> | 2022-04-27 09:52:34 -0400 |
---|---|---|
committer | Jeffrey Armstrong <jeff@approximatrix.com> | 2022-04-27 09:52:34 -0400 |
commit | e5a2850b6bb9887b241316be24b3f7047cef6ea3 (patch) | |
tree | b4b2f8b73200d24d1247a44fe522f832e6be103e /captain/captain.f90 | |
parent | 6cf8d2b298b0770b46753a902b4c5622b5b1ddd2 (diff) | |
download | levitating-e5a2850b6bb9887b241316be24b3f7047cef6ea3.tar.gz levitating-e5a2850b6bb9887b241316be24b3f7047cef6ea3.zip |
Added command line args to create an admin user. Fixed a few db bugs.
Diffstat (limited to 'captain/captain.f90')
-rw-r--r-- | captain/captain.f90 | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/captain/captain.f90 b/captain/captain.f90 index 94b2f96..6713a9e 100644 --- a/captain/captain.f90 +++ b/captain/captain.f90 @@ -70,6 +70,8 @@ contains Print *, " -c <configfile> Use the specified config file" Print *, " -g Operate in Gemini mode" Print *, " -w Operate in CGI mode (default)" + Print *, " --new-admin <username> <password>" + Print *, " Add a new administrator to the system" Print *, " " Print *, "Config file can also be specified via the environment variables:" Print *, " LEVITATING_CONFIG_CGI Path to config for CGI mode" @@ -80,9 +82,11 @@ contains subroutine parse_options use config use m_crypt + use captain_db, only: new_admin_db implicit none - character(len=1024)::option, tmp + character(len=1024)::option, username, password + character(len=:), pointer::tmp logical::config_loaded integer::i @@ -112,12 +116,32 @@ contains else if(trim(option) == "--hash") then i = i + 1 call get_command_argument(i, option) - tmp = hash(option) + tmp => hash(option) Print *, "Hash: "//trim(tmp) Print *, "Verify: "//trim(option), verify_hash(trim(option), tmp) Print *, "Unverify: "//trim(option)//"X", verify_hash(trim(option)//"X", tmp) stop + else if(trim(option) == "--new-admin") then + + ! Config better be loaded by now... + if(config_loaded) then + call initialize_db(database_filename) + + i = i + 1 + call get_command_argument(i, username) + i = i + 1 + call get_command_argument(i, password) + if(new_admin_db(trim(username), trim(password))) then + Print *, "Admin '"//trim(username)//"' added successfully!" + else + Print *, "Operation failed." + end if + else + Print *, "Please specify the configuration file first" + end if + stop + end if i = i + 1 |