Skip to content

Commit

Permalink
Don't let the user run as root
Browse files Browse the repository at this point in the history
Closes #1815
  • Loading branch information
kylef committed Apr 9, 2014
1 parent f054f3b commit 0465aee
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ To install or update CocoaPods see this [guide](http://docs.cocoapods.org/guides
[Kyle Fuller](https://github.com/kylef)
[#2010](https://github.com/CocoaPods/CocoaPods/issues/2010)

* Prevent the user from using `pod` commands as root
[Kyle Fuller](https://github.com/kylef)
[#1815](https://github.com/CocoaPods/CocoaPods/issues/1815)

## 0.31.1
[CocoaPods](https://github.com/CocoaPods/CocoaPods/compare/0.31.1...0.31.0)
[CocoaPods-Core](https://github.com/CocoaPods/Core/compare/0.31.1...0.31.0)
Expand Down
3 changes: 3 additions & 0 deletions lib/cocoapods/command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,14 @@ def self.parse(argv)
end

def self.run(argv)
help! "You cannot run CocoaPods as root." if Process.uid == 0

argv = CLAide::ARGV.new(argv)
if argv.flag?('version')
UI.puts VERSION
exit 0
end

super(argv)
UI.print_warnings
end
Expand Down
4 changes: 4 additions & 0 deletions spec/functional/command_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,9 @@ module Pod
UI.output.should.include 'spec/fixtures/spec-repos/master/AFNetworking'
end

it "doesn't let you run as root" do
Process.stubs(:uid).returns(0)
lambda { Pod::Command.run(['--version']) }.should.raise CLAide::Help
end
end
end

0 comments on commit 0465aee

Please sign in to comment.