projects
/
project
/
luci.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
dc0688d
)
libs/sys: properly handle passwords with apostrophes
author
Jo-Philipp Wich
<jow@openwrt.org>
Tue, 25 Jan 2011 12:51:41 +0000
(12:51 +0000)
committer
Jo-Philipp Wich
<jow@openwrt.org>
Tue, 25 Jan 2011 12:51:41 +0000
(12:51 +0000)
libs/sys/luasrc/sys.lua
patch
|
blob
|
history
diff --git
a/libs/sys/luasrc/sys.lua
b/libs/sys/luasrc/sys.lua
index
1cf8b9f
..
1333cd8
100644
(file)
--- a/
libs/sys/luasrc/sys.lua
+++ b/
libs/sys/luasrc/sys.lua
@@
-604,16
+604,17
@@
end
-- @return Number containing 0 on success and >= 1 on error
function user.setpasswd(username, password)
if password then
-- @return Number containing 0 on success and >= 1 on error
function user.setpasswd(username, password)
if password then
- password = password:gsub("'",
""
)
+ password = password:gsub("'",
[['"'"']]
)
end
if username then
end
if username then
- username = username:gsub("'",
""
)
+ username = username:gsub("'",
[['"'"']]
)
end
end
- local cmd = "(echo '"..password.."';sleep 1;echo '"..password.."')|"
- cmd = cmd .. "passwd '"..username.."' >/dev/null 2>&1"
- return os.execute(cmd)
+ return os.execute(
+ "(echo '" .. password .. "'; sleep 1; echo '" .. password .. "') | " ..
+ "passwd '" .. username .. "' >/dev/null 2>&1"
+ )
end
end