Skip to content

Commit

Permalink
fcrypt: improve error messages
Browse files Browse the repository at this point in the history
See ElektraInitiative#3022 for full discussion.
  • Loading branch information
petermax2 committed Oct 12, 2019
1 parent 4dc4ae8 commit a1042a8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions doc/news/_preparation_next_release.md
Expand Up @@ -67,6 +67,7 @@ The following section lists news about the [modules](https://www.libelektra.org/
- Fixed some typos and links in the documentation and add new iterate example. _(Philipp Gackstatter)_
- We removed `keyRel` and `keyRel2` since it can be easily replaced by other existing functions. _(Philipp Gackstatter)_
- We improved the error messages in `gpgme`. _(Peter Nirschl)_
- We improved the error messages in `fcrypt`. _(Peter Nirschl)_

### Camel

Expand Down
14 changes: 7 additions & 7 deletions src/plugins/fcrypt/fcrypt.c
Expand Up @@ -129,7 +129,7 @@ static int shredTemporaryFile (int fd, Key * errorKey)
{
ELEKTRA_SET_RESOURCE_ERRORF (
errorKey,
"Failed to overwrite the temporary data. Cannot retrieve file status. Unencrypted data may leak. Errno: %s",
"Failed to overwrite the temporary data. Cannot retrieve file status. WARNING: Unencrypted data may leak. Errno: %s",
strerror (errno));
return -1;
}
Expand All @@ -149,7 +149,7 @@ static int shredTemporaryFile (int fd, Key * errorKey)
return 1;

error:
ELEKTRA_SET_RESOURCE_ERRORF (errorKey, "Failed to overwrite the temporary data. Unencrypted data may leak. Reason: %s",
ELEKTRA_SET_RESOURCE_ERRORF (errorKey, "Failed to overwrite the temporary data. WARNING: Unencrypted data may leak! Reason: %s",
strerror (errno));
return -1;
}
Expand Down Expand Up @@ -251,7 +251,7 @@ static int fcryptGpgCallAndCleanup (Key * parentKey, KeySet * pluginConfig, char
{
ELEKTRA_ADD_RESOURCE_WARNINGF (
parentKey,
"Failed to unlink a temporary file. WARNING: unencrypted data may leak! Please try to delete "
"Failed to unlink a temporary file. WARNING: Unencrypted data may leak! Please try to delete "
"the file manually. Affected file: %s. Reason: %s",
tmpFile, strerror (errno));
}
Expand Down Expand Up @@ -284,7 +284,7 @@ static int fcryptEncrypt (KeySet * pluginConfig, Key * parentKey)

if (recipientCount == 0 && signatureCount == 0)
{
ELEKTRA_SET_INSTALLATION_ERRORF (
ELEKTRA_SET_VALIDATION_SEMANTIC_ERROR (
parentKey,
"Missing GPG recipient key (specified as %s) or GPG signature key (specified as %s) in plugin configuration",
ELEKTRA_RECIPIENT_KEY, ELEKTRA_SIGNATURE_KEY);
Expand Down Expand Up @@ -490,7 +490,7 @@ static int fcryptDecrypt (KeySet * pluginConfig, Key * parentKey, fcryptState *
{
ELEKTRA_ADD_RESOURCE_WARNINGF (
parentKey,
"Failed to unlink a temporary file. WARNING: unencrypted data may leak! Please try to delete "
"Failed to unlink a temporary file. WARNING: Unencrypted data may leak! Please try to delete "
"the file manually. Affected file: %s, error description: %s",
tmpFile, strerror (errno));
}
Expand Down Expand Up @@ -607,7 +607,7 @@ int ELEKTRA_PLUGIN_FUNCTION (get) (Plugin * handle, KeySet * ks ELEKTRA_UNUSED,
{
ELEKTRA_ADD_RESOURCE_WARNINGF (
parentKey,
"Failed to unlink a temporary file. WARNING: unencrypted data may leak! Please try "
"Failed to unlink a temporary file. WARNING: Unencrypted data may leak! Please try "
"to delete the file manually. Affected file: %s, error description: %s",
s->tmpFilePath, strerror (errno));
}
Expand Down Expand Up @@ -674,7 +674,7 @@ int ELEKTRA_PLUGIN_FUNCTION (checkconf) (Key * errorKey, KeySet * conf)
if (recipientCount == 0 && signatureCount == 0)
{
char * errorDescription = ELEKTRA_PLUGIN_FUNCTION (getMissingGpgKeyErrorText) (conf);
ELEKTRA_SET_INSTALLATION_ERROR (errorKey, errorDescription);
ELEKTRA_SET_VALIDATION_SEMANTIC_ERROR (errorKey, errorDescription);
elektraFree (errorDescription);
return -1;
}
Expand Down

0 comments on commit a1042a8

Please sign in to comment.