[fix] prevent shell injections

This commit is contained in:
Laurent Peuch 2017-08-18 02:34:46 +02:00
parent d16f3f81d0
commit c8c7fe7fc7

View file

@ -842,7 +842,7 @@ end
function hash_password(password)
-- TODO is the password checked by regex? we don't want to
-- allow shell injection
local mkpasswd = io.popen("mkpasswd --method=sha-512 '" ..password.."'")
local mkpasswd = io.popen("mkpasswd --method=sha-512 '" ..password:gsub("'", "'\\''").."'")
local hashed_password = "{CRYPT}"..mkpasswd:read()
mkpasswd:close()
return hashed_password