Permalink
Browse files

Merge remote branch 'origin/teal_13_03_acu78361_thunker_fix'

Conflicts:
	Gemfile.lock
	spec/scripts/thunker_spec.rb
  • Loading branch information...
2 parents 09847f7 + 7213280 commit b593719c3ca8028d7e40dd99fc03d60df8a3fea1 @ryanwilliamson ryanwilliamson committed Mar 6, 2013
Showing with 6 additions and 14 deletions.
  1. +5 −8 scripts/thunker.rb
  2. +1 −6 spec/scripts/thunker_spec.rb
View
13 scripts/thunker.rb
@@ -309,18 +309,15 @@ def display_motd
# Ensure the user's PTY/TTY will be owned by him once we thunk through to his account.
# This helps apps like screen/tmux work better.
def chown_tty(username)
- tty = `tty`.chomp
+ tty = `tty 2> /dev/null`.chomp
+ @log.error("'tty' command failed") unless $?.success?
+
if File.exists?(tty)
%x(sudo chown #{Shellwords.escape(username)} #{Shellwords.escape(tty)})
raise RuntimeError, "Failed to change ownership of #{tty}" unless $?.success?
- else
- raise Errno::ENOENT, "'tty' command did not give a reasonable answer: #{tty}"
+ else
+ @log.error("'tty' command did not give a reasonable answer: #{tty}")
end
- rescue Exception => e
- STDERR.puts "Cannot chown your TTY - #{e.class.name}: #{e.message}"
- STDERR.puts "Your session will continue, but screen and other terminal-magic apps"
- STDERR.puts "may not work."
- STDERR.puts
end
# Version information
View
7 spec/scripts/thunker_spec.rb
@@ -117,6 +117,7 @@ def create_user(superuser=false, profile_data=nil, force=false)
subject.should_receive(:create_audit_entry).with("EMAIL@EMAIL.COM", "USER", FlexMock.any, FlexMock.any, FlexMock.any)
subject.should_receive(:create_profile).with(FlexMock.any, "USER", "URL", force) if profile_data
subject.should_receive(:display_motd)
+ flexmock(subject).should_receive(:chown_tty).and_return(true)
flexmock(Kernel).should_receive(:exec).with('sudo', '-i', '-u', "USER")
args = '--username USER --uuid 123 --email EMAIL@EMAIL.COM'.split
args.push('-s') if superuser
@@ -131,12 +132,6 @@ def create_user(superuser=false, profile_data=nil, force=false)
end
end
- context 'rs_thunk --username USER --uuid 123 --email EMAIL@EMAIL.COM -s' do
- it 'should create account with superuser privilege' do
- create_user(true)
- end
- end
-
context 'rs_thunk --username USER --uuid 123 --email EMAIL@EMAIL.COM -p URL' do
it 'should create account and use extra profile data' do
create_user(false, "URL")

1 comment on commit b593719

@rightscale-ci
RightScale-Engineering member

RS-COMPLIANCE: COMPLIANCE-COMMITMESSAGE-PASS Build: #15135(2013-04-01_06-20-45), repo: right_link, branch/tag: aqua_acu78536_productize, sha: b593719, status: PASS, reason: Was a merge commit

Please sign in to comment.