Delete Public SSH Key tmp file after calculating fingerprint#1855
Conversation
Signed-off-by: Magnus Lindvall <magnus@dnmgns.com>
|
LGTM |
lafriks
left a comment
There was a problem hiding this comment.
It should be after check for error as on error writeTmpKeyFile will return empty string.
|
@lafriks - Yeah, nice catch. And if |
Signed-off-by: Magnus Lindvall <magnus@dnmgns.com>
| } else if len(stdout) < 2 { | ||
| return "", errors.New("not enough output for calculating fingerprint: " + stdout) | ||
| } | ||
| os.Remove(tmpPath) |
There was a problem hiding this comment.
You should still use defer before executing ssh-keygen (after checking empty string) since if the check failed the file is not removed otherwise.
There was a problem hiding this comment.
See SSHKeyGenParsePublicKey on where to place defer remove
| } else if len(stdout) < 2 { | ||
| return "", errors.New("not enough output for calculating fingerprint: " + stdout) | ||
| } | ||
| os.Remove(tmpPath) |
There was a problem hiding this comment.
See SSHKeyGenParsePublicKey on where to place defer remove
Signed-off-by: Magnus Lindvall <magnus@dnmgns.com>
Signed-off-by: Magnus Lindvall <magnus@dnmgns.com>
|
LGTM |
When using LDAP User Synchronization (#1478) with LDAP Public SSH Keys synchronization (#1844), the public key fingerprint calculation might be running with a quite high frequency.
As the tmp-files for calculating public key fingerprint is not deleted, the system could end up with lots of public tmp files causing inode issue and running out of disk space.
This PR addresses this issue by cleaning up the tmp file after the fingerprint has been calculated.