libs/sys: properly handle passwords with apostrophes
This commit is contained in:
parent
dc0688dbbc
commit
9c03a76fc2
1 changed files with 6 additions and 5 deletions
|
@ -604,16 +604,17 @@ end
|
||||||
-- @return Number containing 0 on success and >= 1 on error
|
-- @return Number containing 0 on success and >= 1 on error
|
||||||
function user.setpasswd(username, password)
|
function user.setpasswd(username, password)
|
||||||
if password then
|
if password then
|
||||||
password = password:gsub("'", "")
|
password = password:gsub("'", [['"'"']])
|
||||||
end
|
end
|
||||||
|
|
||||||
if username then
|
if username then
|
||||||
username = username:gsub("'", "")
|
username = username:gsub("'", [['"'"']])
|
||||||
end
|
end
|
||||||
|
|
||||||
local cmd = "(echo '"..password.."';sleep 1;echo '"..password.."')|"
|
return os.execute(
|
||||||
cmd = cmd .. "passwd '"..username.."' >/dev/null 2>&1"
|
"(echo '" .. password .. "'; sleep 1; echo '" .. password .. "') | " ..
|
||||||
return os.execute(cmd)
|
"passwd '" .. username .. "' >/dev/null 2>&1"
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue