vm_uuid = ENV['ARVADOS_VIRTUAL_MACHINE_UUID']
- begin
- logins = arv.virtual_machine.get_all_logins(limit: 10000, uuid: vm_uuid)[:items]
- rescue
- logins = arv.virtual_machine.logins(:uuid => vm_uuid)[:items]
- end
+ logins = arv.virtual_machine.logins(:uuid => vm_uuid)[:items]
logins = [] if logins.nil?
logins = logins.reject { |l| l[:username].nil? or l[:hostname].nil? or l[:public_key].nil? or l[:virtual_machine_uuid] != vm_uuid }
logins.each do |l|
next if seen[l[:username]]
seen[l[:username]] = true if not seen.has_key?(l[:username])
- @homedir = "/home/#{l[:username]}"
unless uids[l[:username]]
STDERR.puts "Creating account #{l[:username]}"
groups << "fuse"
groups.select! { |name| gids[name] }
# Create new user
- next unless system("/usr/sbin/useradd", "-m",
+ next unless system("useradd", "-m",
"-c", l[:username],
"-s", "/bin/bash",
"-G", groups.join(","),
out: devnull)
end
# Create .ssh directory if necessary
+ @homedir = Etc.getpwnam(l[:username]).dir
userdotssh = File.join(@homedir, ".ssh")
Dir.mkdir(userdotssh) if !File.exists?(userdotssh)
@key = "#######################################################################################
FileUtils.chown_R(l[:username], l[:username], userdotssh)
File.chmod(0700, userdotssh)
File.chmod(0750, @homedir)
+ File.chmod(0600, userauthkeys)
end
devnull.close
puts bang.backtrace.join("\n")
exit 1
end
-