Module: OsCtld::Utils::Receive

Instance Method Summary collapse

Instance Method Details

#check_auth_pubkey(_key_pool_name, _key_name, ct, key_pubkey_hash:) ⇒ Object



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

def check_auth_pubkey(_key_pool_name, _key_name, ct, key_pubkey_hash:)
  if key_pubkey_hash.nil?
    log(:warn, 'Authentication key public-key hash not provided')
    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

  Digest::SHA256.hexdigest(used_key.pubkey) == key_pubkey_hash
end

#receive_pipeline_error(mbuffer_status, recv_status) ⇒ Object



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

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