Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

re-use keyToTemporaryFile function #696

Closed
glimchb opened this issue Oct 5, 2023 · 0 comments · Fixed by #697
Closed

re-use keyToTemporaryFile function #696

glimchb opened this issue Oct 5, 2023 · 0 comments · Fixed by #697

Comments

@glimchb
Copy link
Member

glimchb commented Oct 5, 2023

today we save PSK in

func (s *Server) keyToTemporaryFile(pskKey []byte) (string, error) {
keyFile, err := s.psk.createTempFile("/var/tmp", "opikey")
if err != nil {
log.Printf("error: failed to create file for key: %v", err)
return "", status.Error(codes.Internal, "failed to handle key")
}
const keyPermissions = 0600
if err := s.psk.writeKey(keyFile.Name(), pskKey, keyPermissions); err != nil {
log.Printf("error: failed to write to key file: %v", err)
removeErr := os.Remove(keyFile.Name())
log.Printf("Delete key file after key write: %v", removeErr)
return "", status.Error(codes.Internal, "failed to handle key")
}
return keyFile.Name(), nil
}

in #398 I need to save PSK also here

params := spdk.NvmfSubsystemAddHostParams{
Nqn: in.NvmeSubsystem.Spec.Nqn,
Host: in.NvmeSubsystem.Spec.Hostnqn,
}

Let's move keyToTemporaryFile function to utils so we can re-use it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant