Module: OsCtld::Utils::Receive

Instance Method Summary collapse

Instance Method Details

#check_auth_pubkey(key_pool_name, key_name, ct) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/osctld/utils/receive.rb', line 10

def check_auth_pubkey(key_pool_name, key_name, ct)
  key_pool = DB::Pools.find(key_pool_name)
  error!('key pool not found') unless key_pool

  auth_key = key_pool.send_receive_key_chain.get_key(key_name)

  if auth_key.nil?
    log(:warn, "Authentication key #{key_name.inspect} not found in pool #{key_pool_name}")
    return false
  end

  used_key = ct.pool.send_receive_key_chain.get_key(ct.send_log.opts.key_name)

  if used_key.nil?
    log(:warn, "Used key #{ct.send_log.opts.key_name.inspect} not found in pool #{ct.pool.name}")
    return false
  end

  auth_key.pubkey == used_key.pubkey
end

#receive_pipeline_error(mbuffer_status, recv_status) ⇒ Object



3
4
5
6
7
8
# File 'lib/osctld/utils/receive.rb', line 3

def receive_pipeline_error(mbuffer_status, recv_status)
  failures = []
  failures << "mbuffer exited with #{mbuffer_status.exitstatus}" if mbuffer_status.exitstatus != 0
  failures << "zfs recv exited with #{recv_status.exitstatus}" if recv_status.exitstatus != 0
  "unable to receive stream, #{failures.join(' and ')}"
end