Skip to content

Commit

Permalink
fix(krb5): fix delete keytab err when file not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
wanghuagang committed Jan 9, 2025
1 parent 5075531 commit 280d56c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pkg/kerberos/kadmin.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,15 @@ func (k *Kadmin) Ktadd(principals ...string) ([]byte, error) {
// Create a temporary file for the keytab
tmpFile, err := os.CreateTemp("", "*.keytab")
if err != nil {
kadminLogger.Error(err, "Failed to create temporary keytab file")
logger.Error(err, "Failed to create temporary keytab file")
return nil, err
}
keytab := tmpFile.Name()
defer func() {
if closeErr := tmpFile.Close(); closeErr != nil {
kadminLogger.Error(closeErr, "Failed to close temporary keytab file")
logger.Error(closeErr, "Failed to close temporary keytab file")
}
if err := os.Remove(keytab); err != nil {
if err := os.RemoveAll(keytab); err != nil {
logger.Error(err, "Failed to remove keytab")
}
}()
Expand Down

0 comments on commit 280d56c

Please sign in to comment.