libs/sys: fix luci.sys.checkpasswd() semantics
[project/luci.git] / libs / sys / luasrc / sys.lua
index 7906d2b..18c7911 100644 (file)
@@ -612,11 +612,10 @@ end
 -- @return                     Boolean indicating wheather the passwords are equal
 function user.checkpasswd(username, pass)
        local pwh = user.getpasswd(username)
-       if pwh and nixio.crypt(pass, pwh) ~= pwh then
-               return false
-       else
-               return true
+       if pwh then
+               return (nixio.crypt(pass, pwh) == pwh)
        end
+       return false
 end
 
 --- Change the password of given user.
@@ -795,7 +794,7 @@ end
 -- @return             Numeric index value
 function init.index(name)
        if fs.access(init.dir..name) then
-               return call("env -i sh -c 'source %s%s; exit $START' >/dev/null"
+               return call("env -i sh -c 'source %s%s enabled; exit ${START:-255}' >/dev/null"
                        %{ init.dir, name })
        end
 end