gluon-core: remove unused user/group management functions, call lock command directly

This commit is contained in:
Matthias Schiffer 2018-02-25 07:05:32 +01:00
parent 6ae1af9694
commit 987eef011a
No known key found for this signature in database
GPG Key ID: 16EF3F64CB201D9C

View File

@ -6,28 +6,15 @@ local string = string
module 'gluon.users'
function add_user(username, uid, gid)
util.lock('/var/lock/passwd')
util.replace_prefix('/etc/passwd', username .. ':', string.format('%s:*:%u:%u::/var:/bin/false\n', username, uid, gid))
util.replace_prefix('/etc/shadow', username .. ':', string.format('%s:*:0:0:99999:7:::\n', username))
util.unlock('/var/lock/passwd')
end
function remove_user(username)
util.lock('/var/lock/passwd')
os.execute('exec lock /var/lock/passwd')
util.replace_prefix('/etc/passwd', username .. ':')
util.replace_prefix('/etc/shadow', username .. ':')
util.unlock('/var/lock/passwd')
end
function add_group(groupname, gid)
util.lock('/var/lock/group')
util.replace_prefix('/etc/group', groupname .. ':', string.format('%s:x:%u:\n', groupname, gid))
util.unlock('/var/lock/group')
os.execute('exec lock -u /var/lock/passwd')
end
function remove_group(groupname)
util.lock('/var/lock/group')
os.execute('exec lock /var/lock/group')
util.replace_prefix('/etc/group', groupname .. ':')
util.unlock('/var/lock/group')
os.execute('exec lock -u /var/lock/group')
end