vidibus-pureftpd 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.bundle/config +2 -0
- data/.gitignore +21 -0
- data/.rspec +2 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +23 -0
- data/LICENSE +20 -0
- data/README.rdoc +48 -0
- data/Rakefile +36 -0
- data/VERSION +1 -0
- data/lib/vidibus/pureftpd.rb +70 -0
- data/lib/vidibus-pureftpd.rb +4 -0
- data/spec/spec_helper.rb +6 -0
- data/spec/vidibus/pureftpd_spec.rb +80 -0
- data/vidibus-pureftpd.gemspec +58 -0
- metadata +95 -0
data/.bundle/config
ADDED
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://gemcutter.org/
|
3
|
+
specs:
|
4
|
+
diff-lcs (1.1.2)
|
5
|
+
relevance-rcov (0.9.2.1)
|
6
|
+
rspec (2.0.0.beta.20)
|
7
|
+
rspec-core (= 2.0.0.beta.20)
|
8
|
+
rspec-expectations (= 2.0.0.beta.20)
|
9
|
+
rspec-mocks (= 2.0.0.beta.20)
|
10
|
+
rspec-core (2.0.0.beta.20)
|
11
|
+
rspec-expectations (2.0.0.beta.20)
|
12
|
+
diff-lcs (>= 1.1.2)
|
13
|
+
rspec-mocks (2.0.0.beta.20)
|
14
|
+
vidibus-core_extensions (0.3.6)
|
15
|
+
|
16
|
+
PLATFORMS
|
17
|
+
ruby
|
18
|
+
|
19
|
+
DEPENDENCIES
|
20
|
+
bundler (~> 1.0.0.beta)
|
21
|
+
relevance-rcov
|
22
|
+
rspec (~> 2.0.0.beta.20)
|
23
|
+
vidibus-core_extensions
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 Andre Pankratz
|
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.rdoc
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
= vidibus-pureftpd
|
2
|
+
|
3
|
+
This gem is part of the open source SOA framework Vidibus: http://www.vidibus.org
|
4
|
+
|
5
|
+
TODO: describe
|
6
|
+
|
7
|
+
|
8
|
+
== Installation
|
9
|
+
|
10
|
+
Add the dependency to the Gemfile of your application:
|
11
|
+
|
12
|
+
gem "vidibus-pureftpd"
|
13
|
+
|
14
|
+
Then call bundle install on your console.
|
15
|
+
|
16
|
+
|
17
|
+
== Usage
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
== Install Pure-FTPd on Debian Lenny
|
22
|
+
|
23
|
+
# Get the package:
|
24
|
+
aptitude install pure-ftpd-common pure-ftpd
|
25
|
+
|
26
|
+
# Add group pureftpd_group:
|
27
|
+
groupadd pureftpd_group
|
28
|
+
|
29
|
+
# Add user pureftpd_user without permission to a home directory or any shell:
|
30
|
+
useradd -g pureftpd_group -d /dev/null -s /etc pureftpd_user
|
31
|
+
|
32
|
+
|
33
|
+
# By default all user data will be saved in /etc/pure-ftpd/pureftpd.passwd, so make sure this file exists:
|
34
|
+
touch /etc/pure-ftpd/pureftpd.passwd
|
35
|
+
|
36
|
+
# For fast access of user data, Pure-FTPd creates a "database", which is a binary file that is ordered and has an index for quick access. Let's create this database:
|
37
|
+
pure-pw mkdb
|
38
|
+
|
39
|
+
# For more instructions, please refer to http://linux.justinhartman.com/PureFTPd_Installation_and_Setup
|
40
|
+
|
41
|
+
|
42
|
+
== TODO
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
== Copyright
|
47
|
+
|
48
|
+
Copyright (c) 2010 Andre Pankratz. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "rake"
|
3
|
+
require "rake/rdoctask"
|
4
|
+
require "rspec"
|
5
|
+
require "rspec/core/rake_task"
|
6
|
+
|
7
|
+
begin
|
8
|
+
require "jeweler"
|
9
|
+
Jeweler::Tasks.new do |gem|
|
10
|
+
gem.name = "vidibus-pureftpd"
|
11
|
+
gem.summary = %Q{Provides interface for Pure-FTPd}
|
12
|
+
gem.description = %Q{Description...}
|
13
|
+
gem.email = "andre@vidibus.com"
|
14
|
+
gem.homepage = "http://github.com/vidibus/vidibus-pureftpd"
|
15
|
+
gem.authors = ["Andre Pankratz"]
|
16
|
+
gem.add_dependency "vidibus-core_extensions"
|
17
|
+
end
|
18
|
+
Jeweler::GemcutterTasks.new
|
19
|
+
rescue LoadError
|
20
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
21
|
+
end
|
22
|
+
|
23
|
+
Rspec::Core::RakeTask.new(:rcov) do |t|
|
24
|
+
t.pattern = "spec/**/*_spec.rb"
|
25
|
+
t.rcov = true
|
26
|
+
t.rcov_opts = ["--exclude", "^spec,/gems/"]
|
27
|
+
end
|
28
|
+
|
29
|
+
Rake::RDocTask.new do |rdoc|
|
30
|
+
version = File.exist?("VERSION") ? File.read("VERSION") : ""
|
31
|
+
rdoc.rdoc_dir = "rdoc"
|
32
|
+
rdoc.title = "vidibus-pureftpd #{version}"
|
33
|
+
rdoc.rdoc_files.include("README*")
|
34
|
+
rdoc.rdoc_files.include("lib/**/*.rb")
|
35
|
+
rdoc.options << "--charset=utf-8"
|
36
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.0
|
@@ -0,0 +1,70 @@
|
|
1
|
+
module Vidibus # :nodoc
|
2
|
+
module Pureftpd
|
3
|
+
class Error < StandardError; end
|
4
|
+
|
5
|
+
class << self
|
6
|
+
|
7
|
+
# Default settings for Pure-FTPd.
|
8
|
+
def settings
|
9
|
+
@settings ||= {
|
10
|
+
:sysuser => "pureftpd_user",
|
11
|
+
:sysgroup => "pureftpd_group",
|
12
|
+
:password_file => "/etc/pure-ftpd/pureftpd.passwd",
|
13
|
+
}
|
14
|
+
end
|
15
|
+
|
16
|
+
# Adds a new user.
|
17
|
+
# Required options:
|
18
|
+
# :login, :password, :directory
|
19
|
+
def add_user(options)
|
20
|
+
unless options.keys?(:login, :password, :directory)
|
21
|
+
raise ArgumentError.new("Required options are :login, :password, :directory")
|
22
|
+
end
|
23
|
+
password = options.delete(:password)
|
24
|
+
cmd = "pure-pw useradd %{login} -f %{password_file} -u %{sysuser} -g %{sysgroup} -d %{directory} -m" % settings.merge(options)
|
25
|
+
perform(cmd) do |stdin, stdout, stderr|
|
26
|
+
stdin.puts(password)
|
27
|
+
stdin.puts(password)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# Deletes an existing user.
|
32
|
+
# Required options:
|
33
|
+
# :login
|
34
|
+
def delete_user(options)
|
35
|
+
unless options.key?(:login)
|
36
|
+
raise ArgumentError.new("Required option is :login")
|
37
|
+
end
|
38
|
+
cmd = "pure-pw userdel %{login} -f %{password_file} -m" % settings.merge(options)
|
39
|
+
perform(cmd)
|
40
|
+
end
|
41
|
+
|
42
|
+
# Changes password of existing user
|
43
|
+
def change_password(options)
|
44
|
+
unless options.keys?(:login, :password)
|
45
|
+
raise ArgumentError.new("Required options are :login, :password")
|
46
|
+
end
|
47
|
+
password = options.delete(:password)
|
48
|
+
cmd = "pure-pw passwd %{login} -f %{password_file} -m" % settings.merge(options)
|
49
|
+
perform(cmd) do |stdin, stdout, stderr|
|
50
|
+
stdin.puts(password)
|
51
|
+
stdin.puts(password)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
protected
|
56
|
+
|
57
|
+
# Performs given command. Accepts a block with |stdin, stdout, stderr|.
|
58
|
+
def perform(cmd, &block)
|
59
|
+
error = ""
|
60
|
+
Open3.popen3(cmd) do |stdin, stdout, stderr|
|
61
|
+
yield(stdin, stdout, stderr) if block_given?
|
62
|
+
error = stderr.read
|
63
|
+
end
|
64
|
+
unless error == ""
|
65
|
+
raise Error.new("Error while deleting user with this command:\n#{cmd}\n\n#{error}")
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "Vidibus::Pureftpd" do
|
4
|
+
let(:pureftpd) do
|
5
|
+
Vidibus::Pureftpd.tap do |p|
|
6
|
+
p.settings[:sysuser] = "pureftpd_user"
|
7
|
+
p.settings[:sysgroup] = "pureftpd_group"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
let(:login) { "pureftpd_tester" }
|
12
|
+
let(:password) { "secret" }
|
13
|
+
let(:directory) { "/tmp/tester" }
|
14
|
+
|
15
|
+
def setup
|
16
|
+
pureftpd.add_user(:login => login, :password => password, :directory => directory)
|
17
|
+
rescue
|
18
|
+
end
|
19
|
+
|
20
|
+
def teardown
|
21
|
+
pureftpd.delete_user(:login => login)
|
22
|
+
rescue
|
23
|
+
end
|
24
|
+
|
25
|
+
describe ".add_user" do
|
26
|
+
it "should raise an error unless all required options are given" do
|
27
|
+
expect { pureftpd.add_user(:login => login, :password => password) }.to raise_error(ArgumentError)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should add a new ftp user" do
|
31
|
+
pureftpd.add_user(:login => login, :password => password, :directory => directory)
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should raise an error if user already exists" do
|
35
|
+
pureftpd.add_user(:login => login, :password => password, :directory => directory)
|
36
|
+
expect {
|
37
|
+
pureftpd.add_user(:login => login, :password => password, :directory => directory)
|
38
|
+
}.to raise_error(Vidibus::Pureftpd::Error)
|
39
|
+
end
|
40
|
+
|
41
|
+
after { teardown }
|
42
|
+
end
|
43
|
+
|
44
|
+
describe ".delete_user" do
|
45
|
+
before { setup }
|
46
|
+
|
47
|
+
it "should raise an error unless all required options are given" do
|
48
|
+
expect { pureftpd.delete_user }.to raise_error(ArgumentError)
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should delete an existing ftp user" do
|
52
|
+
pureftpd.delete_user(:login => login)
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should raise an error if user does not exist" do
|
56
|
+
pureftpd.delete_user(:login => login)
|
57
|
+
expect {
|
58
|
+
pureftpd.delete_user(:login => login)
|
59
|
+
}.to raise_error(Vidibus::Pureftpd::Error)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe ".change_password" do
|
64
|
+
it "should raise an error unless all required options are given" do
|
65
|
+
expect { pureftpd.change_password(:login => login) }.to raise_error(ArgumentError)
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should change the password of an existing ftp user" do
|
69
|
+
setup
|
70
|
+
pureftpd.change_password(:login => login, :password => password)
|
71
|
+
teardown
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should raise an error if user does not exist" do
|
75
|
+
expect {
|
76
|
+
pureftpd.change_password(:login => login, :password => password)
|
77
|
+
}.to raise_error(Vidibus::Pureftpd::Error)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{vidibus-pureftpd}
|
8
|
+
s.version = "0.0.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Andre Pankratz"]
|
12
|
+
s.date = %q{2010-09-23}
|
13
|
+
s.description = %q{Description...}
|
14
|
+
s.email = %q{andre@vidibus.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".bundle/config",
|
21
|
+
".gitignore",
|
22
|
+
".rspec",
|
23
|
+
"Gemfile",
|
24
|
+
"Gemfile.lock",
|
25
|
+
"LICENSE",
|
26
|
+
"README.rdoc",
|
27
|
+
"Rakefile",
|
28
|
+
"VERSION",
|
29
|
+
"lib/vidibus-pureftpd.rb",
|
30
|
+
"lib/vidibus/pureftpd.rb",
|
31
|
+
"spec/spec_helper.rb",
|
32
|
+
"spec/vidibus/pureftpd_spec.rb",
|
33
|
+
"vidibus-pureftpd.gemspec"
|
34
|
+
]
|
35
|
+
s.homepage = %q{http://github.com/vidibus/vidibus-pureftpd}
|
36
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
37
|
+
s.require_paths = ["lib"]
|
38
|
+
s.rubygems_version = %q{1.3.7}
|
39
|
+
s.summary = %q{Provides interface for Pure-FTPd}
|
40
|
+
s.test_files = [
|
41
|
+
"spec/spec_helper.rb",
|
42
|
+
"spec/vidibus/pureftpd_spec.rb"
|
43
|
+
]
|
44
|
+
|
45
|
+
if s.respond_to? :specification_version then
|
46
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
47
|
+
s.specification_version = 3
|
48
|
+
|
49
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
50
|
+
s.add_runtime_dependency(%q<vidibus-core_extensions>, [">= 0"])
|
51
|
+
else
|
52
|
+
s.add_dependency(%q<vidibus-core_extensions>, [">= 0"])
|
53
|
+
end
|
54
|
+
else
|
55
|
+
s.add_dependency(%q<vidibus-core_extensions>, [">= 0"])
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
metadata
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vidibus-pureftpd
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 31
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 0
|
10
|
+
version: 0.0.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Andre Pankratz
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-09-23 00:00:00 +02:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: vidibus-core_extensions
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
35
|
+
description: Description...
|
36
|
+
email: andre@vidibus.com
|
37
|
+
executables: []
|
38
|
+
|
39
|
+
extensions: []
|
40
|
+
|
41
|
+
extra_rdoc_files:
|
42
|
+
- LICENSE
|
43
|
+
- README.rdoc
|
44
|
+
files:
|
45
|
+
- .bundle/config
|
46
|
+
- .gitignore
|
47
|
+
- .rspec
|
48
|
+
- Gemfile
|
49
|
+
- Gemfile.lock
|
50
|
+
- LICENSE
|
51
|
+
- README.rdoc
|
52
|
+
- Rakefile
|
53
|
+
- VERSION
|
54
|
+
- lib/vidibus-pureftpd.rb
|
55
|
+
- lib/vidibus/pureftpd.rb
|
56
|
+
- spec/spec_helper.rb
|
57
|
+
- spec/vidibus/pureftpd_spec.rb
|
58
|
+
- vidibus-pureftpd.gemspec
|
59
|
+
has_rdoc: true
|
60
|
+
homepage: http://github.com/vidibus/vidibus-pureftpd
|
61
|
+
licenses: []
|
62
|
+
|
63
|
+
post_install_message:
|
64
|
+
rdoc_options:
|
65
|
+
- --charset=UTF-8
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
none: false
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
hash: 3
|
74
|
+
segments:
|
75
|
+
- 0
|
76
|
+
version: "0"
|
77
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
|
+
none: false
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
hash: 3
|
83
|
+
segments:
|
84
|
+
- 0
|
85
|
+
version: "0"
|
86
|
+
requirements: []
|
87
|
+
|
88
|
+
rubyforge_project:
|
89
|
+
rubygems_version: 1.3.7
|
90
|
+
signing_key:
|
91
|
+
specification_version: 3
|
92
|
+
summary: Provides interface for Pure-FTPd
|
93
|
+
test_files:
|
94
|
+
- spec/spec_helper.rb
|
95
|
+
- spec/vidibus/pureftpd_spec.rb
|