run-as-root 0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE.txt +20 -0
- data/README.md +13 -0
- data/Rakefile +32 -0
- data/VERSION +1 -0
- data/lib/run-as-root.rb +12 -0
- metadata +69 -0
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Sergio Rubio <rubiojr@frameos.org>
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
require 'jeweler'
|
5
|
+
Jeweler::Tasks.new do |gem|
|
6
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
7
|
+
gem.version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
8
|
+
gem.name = "run-as-root"
|
9
|
+
gem.homepage = "http://github.com/rubiojr/run-as-root"
|
10
|
+
gem.license = "MIT"
|
11
|
+
gem.summary = %Q{Require root to run the command}
|
12
|
+
gem.description = %Q{Require this gem to force the user of a command/script to execute it as root}
|
13
|
+
gem.email = "rubiojr@frameos.org"
|
14
|
+
gem.authors = ["Sergio Rubio"]
|
15
|
+
# Include your dependencies below. Runtime dependencies are required when using your gem,
|
16
|
+
# and development dependencies are only needed for development (ie running rake tasks, tests, etc)
|
17
|
+
# gem.add_runtime_dependency 'jabber4r', '> 0.1'
|
18
|
+
# gem.add_development_dependency 'rspec', '> 1.2.3'
|
19
|
+
end
|
20
|
+
Jeweler::RubygemsDotOrgTasks.new
|
21
|
+
|
22
|
+
task :default => :build
|
23
|
+
|
24
|
+
require 'rdoc/task'
|
25
|
+
Rake::RDocTask.new do |rdoc|
|
26
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
27
|
+
|
28
|
+
rdoc.rdoc_dir = 'rdoc'
|
29
|
+
rdoc.title = "abiquo-chef-agent #{version}"
|
30
|
+
rdoc.rdoc_files.include('README*')
|
31
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
32
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1
|
data/lib/run-as-root.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
def whoami_root(cmd)
|
2
|
+
`#{cmd}`.strip.chomp == 'root'
|
3
|
+
$stderr.puts $run_as_root_msg || 'You need to be root to run this command.'
|
4
|
+
exit $run_as_root_exit_code || 1
|
5
|
+
end
|
6
|
+
|
7
|
+
['/usr/bin/whoami', '/bin/whoami'].each do |w|
|
8
|
+
if File.exist? w
|
9
|
+
whoami_root w
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
metadata
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: run-as-root
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 9
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: "0.1"
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Sergio Rubio
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2011-08-09 00:00:00 Z
|
18
|
+
dependencies: []
|
19
|
+
|
20
|
+
description: Require this gem to force the user of a command/script to execute it as root
|
21
|
+
email: rubiojr@frameos.org
|
22
|
+
executables: []
|
23
|
+
|
24
|
+
extensions: []
|
25
|
+
|
26
|
+
extra_rdoc_files:
|
27
|
+
- LICENSE.txt
|
28
|
+
- README.md
|
29
|
+
files:
|
30
|
+
- LICENSE.txt
|
31
|
+
- README.md
|
32
|
+
- Rakefile
|
33
|
+
- VERSION
|
34
|
+
- lib/run-as-root.rb
|
35
|
+
homepage: http://github.com/rubiojr/run-as-root
|
36
|
+
licenses:
|
37
|
+
- MIT
|
38
|
+
post_install_message:
|
39
|
+
rdoc_options: []
|
40
|
+
|
41
|
+
require_paths:
|
42
|
+
- lib
|
43
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
44
|
+
none: false
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
hash: 3
|
49
|
+
segments:
|
50
|
+
- 0
|
51
|
+
version: "0"
|
52
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
hash: 3
|
58
|
+
segments:
|
59
|
+
- 0
|
60
|
+
version: "0"
|
61
|
+
requirements: []
|
62
|
+
|
63
|
+
rubyforge_project:
|
64
|
+
rubygems_version: 1.8.5
|
65
|
+
signing_key:
|
66
|
+
specification_version: 3
|
67
|
+
summary: Require root to run the command
|
68
|
+
test_files: []
|
69
|
+
|