File tree 1 file changed +5
-6
lines changed
1 file changed +5
-6
lines changed Original file line number Diff line number Diff line change @@ -42,16 +42,15 @@ local function save_auth_file()
42
42
assert (type (stuff .privileges ) == " table" )
43
43
assert (stuff .last_login == nil or type (stuff .last_login ) == " number" )
44
44
end
45
- local file , errmsg = io.open (core .auth_file_path , ' w+b' )
46
- if not file then
47
- error (core .auth_file_path .. " could not be opened for writing: " .. errmsg )
48
- end
45
+ local content = " "
49
46
for name , stuff in pairs (core .auth_table ) do
50
47
local priv_string = core .privs_to_string (stuff .privileges )
51
48
local parts = {name , stuff .password , priv_string , stuff .last_login or " " }
52
- file :write (table.concat (parts , " :" ).. " \n " )
49
+ content = content .. table.concat (parts , " :" ) .. " \n "
50
+ end
51
+ if not core .safe_file_write (core .auth_file_path , content ) then
52
+ error (core .auth_file_path .. " could not be written to" )
53
53
end
54
- io.close (file )
55
54
end
56
55
57
56
read_auth_file ()
You can’t perform that action at this time.
0 commit comments