Module: Vidibus::Pureftpd

Defined in:
lib/vidibus/pureftpd.rb,
lib/vidibus/pureftpd/user.rb,
lib/vidibus/pureftpd/version.rb

Defined Under Namespace

Classes: Error, User

Constant Summary collapse

VERSION =
'1.0.3'

Class Method Summary collapse

Class Method Details

.perform(cmd, &block) ⇒ Object

Performs given command prefixed with pure-pw. Accepts a block with |stdin, stdout, stderr|.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/vidibus/pureftpd.rb', line 20

def perform(cmd, &block)
  cmd = "pure-pw #{cmd}"
  error = ''
  output = nil

  pid, stdin, stdout, stderr = POSIX::Spawn::popen4(cmd)
  yield(stdin, stdout, stderr) if block_given?
  error = stderr.read
  output = stdout.read

  unless error == ''
    raise Error.new("Pure-FTPd returned an error:\n#{cmd}\n\n#{error}")
  end
  output
ensure
  [stdin, stdout, stderr].each { |io| io.close if !io.closed? }
  Process::waitpid(pid)
end

.settingsObject

Default settings for Pure-FTPd. You may overwrite settings like this:

Vidibus::Pureftpd.settings[:sysuser] = 'desaster_master'


10
11
12
13
14
15
16
# File 'lib/vidibus/pureftpd.rb', line 10

def settings
  @settings ||= {
    :sysuser => 'pureftpd_user',
    :sysgroup => 'pureftpd_group',
    :password_file => '/etc/pure-ftpd/pureftpd.passwd'
  }
end