Class: PostfixAdmin::Doveadm

Inherits:
Object
  • Object
show all
Defined in:
lib/postfix_admin/doveadm.rb

Class Method Summary collapse

Class Method Details

.command_nameObject



29
30
31
# File 'lib/postfix_admin/doveadm.rb', line 29

def self.command_name
  "doveadm pw"
end

.password(in_password, in_scheme, prefix) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/postfix_admin/doveadm.rb', line 12

def self.password(in_password, in_scheme, prefix)
  password = Shellwords.escape(in_password)
  scheme = Shellwords.escape(in_scheme)
  _stdin, stdout, stderr = Open3.popen3("#{self.command_name} -s #{scheme} -p #{password}")

  if stderr.readlines.to_s =~ /Fatal:/
    raise Error, stderr.readlines
  else
    res = stdout.readlines.first.chomp
    if prefix
      res
    else
      res.gsub("{#{scheme}}", "")
    end
  end
end

.schemesObject



7
8
9
10
# File 'lib/postfix_admin/doveadm.rb', line 7

def self.schemes
  result = `#{self.command_name} -l`
  result.split
end