aboutsummaryrefslogtreecommitdiff
path: root/captain/captain.f90
diff options
context:
space:
mode:
Diffstat (limited to 'captain/captain.f90')
-rw-r--r--captain/captain.f9028
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