Improved Passwd#add_user.

This commit is contained in:
Luka Vandervelden 2019-11-17 19:37:06 +01:00
parent 142f80f663
commit 4a65a41f16

View File

@ -145,7 +145,17 @@ class Passwd
digest.hexdigest
end
def add_user(login, password = nil, uid = nil, gid = nil, home = "/", shell = "/bin/nologin")
def add_user(login,
password = nil,
uid = nil,
gid = nil,
home = "/",
shell = "/bin/nologin",
full_name = nil,
location = nil,
office_phone_number = nil,
home_phone_number = nil,
other_contact = nil)
# FIXME: If user already exists, exception? Replacement?
uid = get_free_uid if uid.nil?
@ -158,7 +168,12 @@ class Passwd
"x"
end
user = Passwd::User.new login, password_hash, uid, gid, home, shell
user = Passwd::User.new(login, password_hash, uid, gid, home, shell,
full_name: full_name,
location: location,
office_phone_number: office_phone_number,
home_phone_number: home_phone_number,
other_contact: other_contact)
File.write(@passwd, user.to_csv + "\n", mode: "a")