| |
@@ -6624,7 +6624,7 @@
|
| |
krb_principal = options.host_principal_format % socket.getfqdn()
|
| |
try:
|
| |
# Check ccache is not empty or authentication will fail
|
| |
- if os.stat(options.ccache).st_size == 0:
|
| |
+ if os.path.exists(options.ccache) and os.stat(options.ccache).st_size == 0:
|
| |
os.remove(options.ccache)
|
| |
|
| |
session.gssapi_login(principal=krb_principal,
|
| |
This is a "look before you leap" pattern with
os.path.exists()
. It's better to call your file operations directly, and ignore the exception if the file does not exist.Python 3.6+ (ie, CentOS 8) has a
FileNotFoundError
exception that is handy for this: