summaryrefslogtreecommitdiff
path: root/lib/gitano/usercommand.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitano/usercommand.lua')
-rw-r--r--lib/gitano/usercommand.lua92
1 files changed, 46 insertions, 46 deletions
diff --git a/lib/gitano/usercommand.lua b/lib/gitano/usercommand.lua
index f9ddf1d..e85e839 100644
--- a/lib/gitano/usercommand.lua
+++ b/lib/gitano/usercommand.lua
@@ -54,7 +54,7 @@ local function builtin_whoami_run(config, repo, cmdline, env)
local longesttag = 0
for tagname in pairs(userdata.keys) do
if #tagname > longesttag then
- longesttag = #tagname
+ longesttag = #tagname
end
end
for tagname, keydata in pairs(userdata.keys) do
@@ -69,26 +69,26 @@ local function builtin_whoami_run(config, repo, cmdline, env)
for grname, gtab in pairs(config.groups) do
log.ddebug(grname, "?")
if gtab.filtered_members[username] then
- if #grname > maxname then
- maxname = #grname
- end
- groups[#groups+1] = grname
- log.ddebug(grname,"=", tostring(#groups))
- if not gtab.members[username] then
- indirect[grname] = gtab.filtered_members[username]
- end
+ if #grname > maxname then
+ maxname = #grname
+ end
+ groups[#groups+1] = grname
+ log.ddebug(grname,"=", tostring(#groups))
+ if not gtab.members[username] then
+ indirect[grname] = gtab.filtered_members[username]
+ end
end
end
if #groups > 0 then
pfx = " In groups:"
table.sort(groups)
for _, group in ipairs(groups) do
- local spaces = (" "):rep(maxname - #group)
- log.ddebug(group, indirect[group] or "DIRECT")
- local via = indirect[group] and (" (via %s)"):format((indirect[group]:match("^[^!]+!([^!]+)")) or "???") or ""
- log.stdout(pfx, spaces .. group .. ":",
- config.groups[group].settings.description .. via)
- pfx = " "
+ local spaces = (" "):rep(maxname - #group)
+ log.ddebug(group, indirect[group] or "DIRECT")
+ local via = indirect[group] and (" (via %s)"):format((indirect[group]:match("^[^!]+!([^!]+)")) or "???") or ""
+ log.stdout(pfx, spaces .. group .. ":",
+ config.groups[group].settings.description .. via)
+ pfx = " "
end
end
return "exit", 0
@@ -121,20 +121,20 @@ local function builtin_sshkey_validate(config, _, cmdline)
end
if cmdline[2] == "list" then
if #cmdline > 2 then
- log.error("sshkey list: No arguments expected")
- return false
+ log.error("sshkey list: No arguments expected")
+ return false
end
elseif cmdline[2] == "add" or cmdline[2] == "del" then
if #cmdline ~= 3 then
- log.error("sshkey", cmdline[2] .. ": Expected tag and no more")
- return false
+ log.error("sshkey", cmdline[2] .. ": Expected tag and no more")
+ return false
end
if not cmdline[3]:match("^[a-z][a-z0-9_-]+$") then
- log.error("sshkey:", cmdline[3], "is not a valid tag name.")
- log.state("Tag names start with a letter and may contain only letters")
- log.state("and numbers, underscores and dashes. Tag names must be at")
- log.state("least two characters long.")
- return false
+ log.error("sshkey:", cmdline[3], "is not a valid tag name.")
+ log.state("Tag names start with a letter and may contain only letters")
+ log.state("and numbers, underscores and dashes. Tag names must be at")
+ log.state("least two characters long.")
+ return false
end
else
log.error("sshkey: Unknown subcommand", cmdline[2])
@@ -154,16 +154,16 @@ local function builtin_sshkey_prep(config, _, cmdline, context)
if cmdline[2] == "add" then
-- Ensure that the given tag doesn't already exist
if utab.keys[cmdline[3]] then
- return "deny", "Key tag " .. cmdline[3] .. " already exists"
+ return "deny", "Key tag " .. cmdline[3] .. " already exists"
end
elseif cmdline[2] == "del" then
-- Ensure that the given tag does exist
if not utab.keys[cmdline[3]] then
- return "deny", "Key tag " .. cmdline[3] .. " does not exist"
+ return "deny", "Key tag " .. cmdline[3] .. " does not exist"
end
-- And that it's not the one we're currently using
if cmdline[3] == context.keytag then
- return "deny", "Key tag " .. cmdline[3] .. " is in use"
+ return "deny", "Key tag " .. cmdline[3] .. " is in use"
end
end
return action, reason
@@ -174,7 +174,7 @@ local function builtin_sshkey_run(conf, _, cmdline, env)
if cmdline[2] == "list" then
if not next(utab.keys) then
log.warn("There are no SSH keys registered for", env.GITANO_USER
- .. ", sorry")
+ .. ", sorry")
else
local pfx = " SSH key:"
for tagname, keydata in pairs(utab.keys) do
@@ -188,14 +188,14 @@ local function builtin_sshkey_run(conf, _, cmdline, env)
local keytype, keydata, keytag = sshkey:match("^([^ ]+) ([^ ]+) ([^ ].*)$")
if not (keytype and keydata and keytag) then
log.error("Unable to parse key,", filename,
- "did not smell like an OpenSSH v2 key")
+ "did not smell like an OpenSSH v2 key")
return "exit", 1
end
if (keytype ~= "ssh-rsa") and (keytype ~= "ssh-dss") and
(keytype ~= "ecdsa-sha2-nistp256") and
(keytype ~= "ecdsa-sha2-nistp384") and
- (keytype ~= "ecdsa-sha2-nistp521") then
+ (keytype ~= "ecdsa-sha2-nistp521") then
log.error("Unknown key type", keytype)
return "exit", 1
end
@@ -260,18 +260,18 @@ local function update_htpasswd(user, passwd)
if passwd ~= '' then
local proc = subprocess.spawn_simple({
- "htpasswd", flags, htpasswd_path, user,
- stdin = passwd,
- stdout = subprocess.PIPE,
- stderr = subprocess.PIPE
+ "htpasswd", flags, htpasswd_path, user,
+ stdin = passwd,
+ stdout = subprocess.PIPE,
+ stderr = subprocess.PIPE
})
_, exit_code = proc:wait()
else
local proc = subprocess.spawn_simple({
- "htpasswd", "-D", htpasswd_path, user,
- stdout = subprocess.PIPE,
- stderr = subprocess.PIPE
+ "htpasswd", "-D", htpasswd_path, user,
+ stdout = subprocess.PIPE,
+ stderr = subprocess.PIPE
})
_, exit_code = proc:wait()
@@ -288,7 +288,7 @@ local function builtin_passwd_run(conf, _, cmdline, env)
if conf.users[user]["passwd.hash"] == nil and password == "" then
log.chat(string.format("Password for %s is not set and no password was"
- .. " provided, no action taken.", user))
+ .. " provided, no action taken.", user))
return "exit", 0
end
@@ -313,7 +313,7 @@ local function builtin_passwd_run(conf, _, cmdline, env)
end
local action = string.format("%s password for %s",
- password ~= '' and "Update" or "Remove", user)
+ password ~= '' and "Update" or "Remove", user)
ok, msg = config.commit(conf, action, user)
@@ -323,21 +323,21 @@ local function builtin_passwd_run(conf, _, cmdline, env)
end
log.chat(string.format("%s password for %s",
- password ~= '' and "Updated" or "Removed", user))
+ password ~= '' and "Updated" or "Removed", user))
return "exit", 0
end
local function register_commands(reg)
assert(reg("whoami", builtin_whoami_short, builtin_whoami_helptext,
- builtin_whoami_validate,
- builtin_whoami_prep, builtin_whoami_run, false, false))
+ builtin_whoami_validate,
+ builtin_whoami_prep, builtin_whoami_run, false, false))
assert(reg("sshkey", builtin_sshkey_short, builtin_sshkey_helptext,
- builtin_sshkey_validate, builtin_sshkey_prep,
- builtin_sshkey_run, false, false))
+ builtin_sshkey_validate, builtin_sshkey_prep,
+ builtin_sshkey_run, false, false))
assert(reg("passwd", builtin_passwd_short, builtin_passwd_helptext,
- builtin_passwd_validate, builtin_passwd_prep,
- builtin_passwd_run, false, false))
+ builtin_passwd_validate, builtin_passwd_prep,
+ builtin_passwd_run, false, false))
end
return {