Temporary GPG homedir management implementation.
More...
Go to the source code of this file.
Temporary GPG homedir management implementation.
Definition in file homedir.c.
◆ gpg_homedir_create()
| gpg_homedir_t * gpg_homedir_create |
( |
void |
| ) |
|
Definition at line 23 of file homedir.c.
23 {
24 gpg_homedir_t *homedir = SAFE_MALLOC(sizeof(gpg_homedir_t), gpg_homedir_t *);
25 if (!homedir) {
26 log_error("Failed to allocate memory for GPG homedir handle");
27 return NULL;
28 }
29
30
31 if (platform_mkdtemp(homedir->path, sizeof(homedir->path), "ascii-chat-gpg") != 0) {
32 log_error("Failed to create temporary GPG homedir");
33 SAFE_FREE(homedir);
34 return NULL;
35 }
36
37
38 if (platform_chmod(homedir->path, 0700) != 0) {
39 log_warn("Failed to set permissions on GPG homedir, attempting cleanup");
40 platform_rmdir_recursive(homedir->path);
41 SAFE_FREE(homedir);
42 return NULL;
43 }
44
45 log_debug("Created temporary GPG homedir: %s", homedir->path);
46 return homedir;
47}
◆ gpg_homedir_destroy()
| void gpg_homedir_destroy |
( |
gpg_homedir_t * |
homedir | ) |
|
Definition at line 56 of file homedir.c.
56 {
57 if (!homedir) {
58 return;
59 }
60
61
62 if (platform_rmdir_recursive(homedir->path) != 0) {
63 log_warn("Failed to completely clean up GPG homedir: %s", homedir->path);
64 } else {
65 log_debug("Cleaned up temporary GPG homedir: %s", homedir->path);
66 }
67
68 SAFE_FREE(homedir);
69}
◆ gpg_homedir_path()
| const char * gpg_homedir_path |
( |
const gpg_homedir_t * |
homedir | ) |
|
Definition at line 49 of file homedir.c.
49 {
50 if (!homedir) {
51 return NULL;
52 }
53 return homedir->path;
54}