diff options
author | Daniel Silverstone <dsilvers@digital-scurf.org> | 2017-07-31 16:17:27 -0400 |
---|---|---|
committer | Daniel Silverstone <dsilvers@digital-scurf.org> | 2017-07-31 16:58:58 -0400 |
commit | 078694c78772d8a219273c5b48a15ad991ce0ec6 (patch) | |
tree | 7063d16da9db3a31710c260e806ba166fb935162 | |
parent | f107f28ea45b15611b5699cb21662daf5ca0535a (diff) | |
download | gitano-078694c78772d8a219273c5b48a15ad991ce0ec6.tar.gz |
Use new lock/unlock functions to guard htpasswd updatesdsilvers/sysbranch-fixes
-rw-r--r-- | lib/gitano/admincommand.lua | 2 | ||||
-rw-r--r-- | lib/gitano/usercommand.lua | 3 |
2 files changed, 4 insertions, 1 deletions
diff --git a/lib/gitano/admincommand.lua b/lib/gitano/admincommand.lua index be6bf0a..5f1bcf9 100644 --- a/lib/gitano/admincommand.lua +++ b/lib/gitano/admincommand.lua @@ -129,6 +129,7 @@ local function update_user_in_htpasswd(conf, userfrom, userto) return end local htpasswd_path = os.getenv("HOME") .. "/htpasswd" + local lock = util.lockfile(htpasswd_path .. ".lock") local fh = io.open(htpasswd_path, "r") if not fh then return end local to_write = {} @@ -151,6 +152,7 @@ local function update_user_in_htpasswd(conf, userfrom, userto) log.warn(i18n.expand("ERROR_UNABLE_TO_RENAME_INTO_PLACE", {what="htpasswd", reason=luxio.strerror(errno)})) end + util.unlockfile(lock) end local builtin_user_short = "Manage users in Gitano" diff --git a/lib/gitano/usercommand.lua b/lib/gitano/usercommand.lua index 5d3d7ac..af7141c 100644 --- a/lib/gitano/usercommand.lua +++ b/lib/gitano/usercommand.lua @@ -282,6 +282,7 @@ end local function update_htpasswd(user, passwd) local htpasswd_path = os.getenv("HOME") .. "/htpasswd" + local lock = util.lockfile(htpasswd_path .. ".lock") local flags = io.open(htpasswd_path, "r") and "-i" or "-ic" local exit_code @@ -303,7 +304,7 @@ local function update_htpasswd(user, passwd) _, exit_code = proc:wait() end - + util.unlockfile(lock) return exit_code == 0 end |