mirror of
https://github.com/hashcat/hashcat.git
synced 2024-11-22 16:18:09 +00:00
Make sure to unlink the pidfile only if our instance created it, but even in case of error
This commit is contained in:
parent
ef004e85f0
commit
79e8b6a6b9
@ -20,8 +20,6 @@
|
||||
#include <psapi.h>
|
||||
#endif // _WIN
|
||||
|
||||
void unlink_pidfile (hashcat_ctx_t *hashcat_ctx);
|
||||
|
||||
int pidfile_ctx_init (hashcat_ctx_t *hashcat_ctx);
|
||||
|
||||
void pidfile_ctx_destroy (hashcat_ctx_t *hashcat_ctx);
|
||||
|
@ -1319,6 +1319,8 @@ typedef struct pidfile_ctx
|
||||
|
||||
pidfile_data_t *pd;
|
||||
|
||||
bool pidfile_written;
|
||||
|
||||
} pidfile_ctx_t;
|
||||
|
||||
typedef struct kernel_rule
|
||||
|
@ -1125,10 +1125,6 @@ int hashcat_session_execute (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
unlink_restore (hashcat_ctx);
|
||||
|
||||
// unlink the pidfile
|
||||
|
||||
unlink_pidfile (hashcat_ctx);
|
||||
|
||||
// final update dictionary cache
|
||||
|
||||
dictstat_write (hashcat_ctx);
|
||||
|
@ -143,13 +143,6 @@ static int write_pidfile (hashcat_ctx_t *hashcat_ctx)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void unlink_pidfile (hashcat_ctx_t *hashcat_ctx)
|
||||
{
|
||||
pidfile_ctx_t *pidfile_ctx = hashcat_ctx->pidfile_ctx;
|
||||
|
||||
unlink (pidfile_ctx->filename);
|
||||
}
|
||||
|
||||
int pidfile_ctx_init (hashcat_ctx_t *hashcat_ctx)
|
||||
{
|
||||
folder_config_t *folder_config = hashcat_ctx->folder_config;
|
||||
@ -158,11 +151,15 @@ int pidfile_ctx_init (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
hc_asprintf (&pidfile_ctx->filename, "%s/%s.pid", folder_config->session_dir, user_options->session);
|
||||
|
||||
pidfile_ctx->pidfile_written = false;
|
||||
|
||||
const int rc_init_pidfile = init_pidfile (hashcat_ctx);
|
||||
|
||||
if (rc_init_pidfile == -1) return -1;
|
||||
|
||||
write_pidfile (hashcat_ctx);
|
||||
const int rc = write_pidfile (hashcat_ctx);
|
||||
|
||||
if (rc == 0) pidfile_ctx->pidfile_written = true;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -171,6 +168,11 @@ void pidfile_ctx_destroy (hashcat_ctx_t *hashcat_ctx)
|
||||
{
|
||||
pidfile_ctx_t *pidfile_ctx = hashcat_ctx->pidfile_ctx;
|
||||
|
||||
if (pidfile_ctx->pidfile_written == true)
|
||||
{
|
||||
unlink (pidfile_ctx->filename);
|
||||
}
|
||||
|
||||
hcfree (pidfile_ctx->filename);
|
||||
|
||||
hcfree (pidfile_ctx->pd);
|
||||
|
Loading…
Reference in New Issue
Block a user