diff --git a/src/libs/elektra/plugin.c b/src/libs/elektra/plugin.c index 3be85d757d1..2cdf865b4ef 100644 --- a/src/libs/elektra/plugin.c +++ b/src/libs/elektra/plugin.c @@ -69,7 +69,7 @@ int elektraProcessPlugin (Key * cur, int * pluginNumber, char ** pluginName, cha *pluginNumber = fullname[1] - '0'; if (*pluginNumber > NR_OF_PLUGINS) { - ELEKTRA_ADD_INSTALLATION_WARNINGF (errorKey, "Tried to set more plugins than %s (NR_OF_PLUGINS). Pluginname: %s", + ELEKTRA_ADD_INSTALLATION_WARNINGF (errorKey, "Tried to set more plugins than %d (NR_OF_PLUGINS). Pluginname: %s", NR_OF_PLUGINS, fullname); return -1; } diff --git a/src/libs/pluginprocess/pluginprocess.c b/src/libs/pluginprocess/pluginprocess.c index 7a73f782271..13637de7a46 100644 --- a/src/libs/pluginprocess/pluginprocess.c +++ b/src/libs/pluginprocess/pluginprocess.c @@ -330,7 +330,8 @@ int elektraPluginProcessSend (const ElektraPluginProcess * pp, pluginprocess_t c long lresult = strtol (keyString (resultKey), &endPtr, 10); if (*endPtr != '\0' || errno == ERANGE || lresult > INT_MAX || lresult < INT_MIN) { - ELEKTRA_SET_PLUGIN_MISBEHAVIOR_ERRORF (key, "Received invalid return code or no KeySet from child process: %s", keyString (resultKey)); + ELEKTRA_SET_PLUGIN_MISBEHAVIOR_ERRORF (key, "Received invalid return code or no KeySet from child process: %s", + keyString (resultKey)); lresult = ELEKTRA_PLUGIN_STATUS_ERROR; } else // Copy everything back into the actual keysets diff --git a/src/plugins/augeas/augeas.c b/src/plugins/augeas/augeas.c index 8a34f9e0e22..2b5f5765b89 100644 --- a/src/plugins/augeas/augeas.c +++ b/src/plugins/augeas/augeas.c @@ -519,9 +519,7 @@ int elektraAugeasGet (Plugin * handle, KeySet * returned, Key * parentKey) if (!conversionData) { fclose (fh); - ELEKTRA_SET_OUT_OF_MEMORY_ERRORF ( - parentKey, "Out of memory. Errno: %s", - strerror (errno)); + ELEKTRA_SET_OUT_OF_MEMORY_ERRORF (parentKey, "Out of memory. Errno: %s", strerror (errno)); } conversionData->currentOrder = 0; diff --git a/src/plugins/base64/base64.c b/src/plugins/base64/base64.c index 2256b5264ee..2f0c7f324ab 100644 --- a/src/plugins/base64/base64.c +++ b/src/plugins/base64/base64.c @@ -107,7 +107,7 @@ static int decode (Key * key, Key * parent, bool metaMode) else if (result == -1) { // Decoding error - ELEKTRA_ADD_VALIDATION_SYNTACTIC_WARNINGF (parent, "Not Base64 encoded: %s", strVal); + ELEKTRA_ADD_VALIDATION_SYNTACTIC_WARNINGF (parent, "Key %s was not Base64 encoded: %s", keyName (key), strVal); } else if (result == -2) { diff --git a/src/plugins/blockresolver/blockresolver.c b/src/plugins/blockresolver/blockresolver.c index 8fac07220f5..351d7372499 100644 --- a/src/plugins/blockresolver/blockresolver.c +++ b/src/plugins/blockresolver/blockresolver.c @@ -255,7 +255,7 @@ int elektraBlockresolverGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned E struct stat buf; if (stat (data->realFile, &buf)) { - ELEKTRA_ADD_RESOURCE_WARNINGF (parentKey, "Failed to stat file %s\n", data->realFile); + ELEKTRA_ADD_RESOURCE_WARNINGF (parentKey, "Failed to stat file %s\n. Reason: %s", data->realFile, strerror (errno)); return -1; } if (buf.st_mtime == data->mtime) return 0; @@ -264,7 +264,7 @@ int elektraBlockresolverGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned E fin = fopen (data->realFile, "r"); if (!fin) { - ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Couldn't open %s for reading", data->realFile); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Couldn't open %s for reading. Reason: %s", data->realFile, strerror (errno)); goto GET_CLEANUP; } @@ -289,7 +289,7 @@ int elektraBlockresolverGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned E fout = fopen (data->tmpFile, "w"); if (!fout) { - ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Couldn't open %s for writing", data->tmpFile); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Couldn't open %s for writing. Reason: %s", data->tmpFile, strerror (errno)); retVal = -1; goto GET_CLEANUP; } @@ -312,7 +312,7 @@ int elektraBlockresolverSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned E struct stat buf; if (stat (data->realFile, &buf)) { - ELEKTRA_ADD_RESOURCE_WARNINGF (parentKey, "Failed to stat file %s\n", data->realFile); + ELEKTRA_ADD_RESOURCE_WARNINGF (parentKey, "Failed to stat file %s\n. Reason: %s", data->realFile, strerror (errno)); return -1; } if (buf.st_mtime > data->mtime) @@ -337,13 +337,15 @@ int elektraBlockresolverSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned E fout = fopen (mergeFile, "w"); if (!fout) { - ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Couldn't open %s for writing", data->realFile); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Couldn't open %s for writing. Reason: %s", data->realFile, + strerror (errno)); goto SET_CLEANUP; } fin = fopen (data->realFile, "r"); if (!fin) { - ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Couldn't open %s for reading", data->realFile); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Couldn't open %s for reading. Reason: %s", data->realFile, + strerror (errno)); goto SET_CLEANUP; } block = (char *) getBlock (fin, 0, data->startPos); @@ -367,7 +369,7 @@ int elektraBlockresolverSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned E fin = fopen (data->tmpFile, "r"); if (!fin) { - ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Couldn't open %s for reading", data->tmpFile); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Couldn't open %s for reading Reason: %s", data->tmpFile, strerror (errno)); goto SET_CLEANUP; } char buffer[BUFSIZE_MAX]; diff --git a/src/plugins/cachefilter/cachefilter.c b/src/plugins/cachefilter/cachefilter.c index c0839c38033..57989020b62 100644 --- a/src/plugins/cachefilter/cachefilter.c +++ b/src/plugins/cachefilter/cachefilter.c @@ -78,7 +78,8 @@ int elektraCachefilterSet (Plugin * handle, KeySet * returned, Key * parentKey) void * cache = elektraPluginGetData (handle); if (cache == NULL) { - ELEKTRA_SET_INSTALLATION_ERROR (parentKey, "Cache was not initialized."); + // TODO: Solution (Call kdbGet() to initialize Cache) + ELEKTRA_SET_INTERFACE_ERROR (parentKey, "Cache was not initialized."); return -1; // did not call kdbGet() before and therefore // also no elektraCachefilterGet() } diff --git a/src/plugins/crypto/helper.c b/src/plugins/crypto/helper.c index 17ab203b368..0180e078169 100644 --- a/src/plugins/crypto/helper.c +++ b/src/plugins/crypto/helper.c @@ -112,14 +112,15 @@ int ELEKTRA_PLUGIN_FUNCTION (getSaltFromMetakey) (Key * errorKey, Key * k, kdb_o const Key * meta = keyGetMeta (k, ELEKTRA_CRYPTO_META_SALT); if (!meta) { - ELEKTRA_SET_INTERFACE_ERRORF (errorKey, "Missing salt as metakey %s in key %s", ELEKTRA_CRYPTO_META_SALT, keyName (k)); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (errorKey, "Missing salt as metakey %s in key %s", ELEKTRA_CRYPTO_META_SALT, + keyName (k)); return -1; } int result = ELEKTRA_PLUGIN_FUNCTION (base64Decode) (errorKey, keyString (meta), salt, &saltLenInternal); if (result == -1) { - ELEKTRA_SET_VALIDATION_SEMANTIC_ERROR (errorKey, "Salt was not stored Base64 encoded."); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (errorKey, "Salt was not stored Base64 encoded in key %s", keyName (k)); return -1; } else if (result == -2) diff --git a/src/plugins/curlget/curlget.c b/src/plugins/curlget/curlget.c index 3f2bfed4e98..3ea3b61b27a 100644 --- a/src/plugins/curlget/curlget.c +++ b/src/plugins/curlget/curlget.c @@ -427,7 +427,8 @@ int elektraCurlgetOpen (Plugin * handle, Key * errorKey ELEKTRA_UNUSED) { if (!data->password) { - ELEKTRA_SET_VALIDATION_SEMANTIC_ERROR (errorKey, "No password specified for SSH password authentication"); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERROR ( + errorKey, "No password specified for SSH password authentication in plugin configuration"); if (data->uploadFileName) elektraFree (data->__uploadFileName); elektraFree (data); data = NULL; @@ -620,7 +621,7 @@ int elektraCurlgetGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTRA if (fd == -1) { - ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Failed to open %s for reading", data->path); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Failed to open %s for reading. Reason: %s", data->path, strerror (errno)); return -1; } FILE * fp = fetchFile (data, fd); @@ -637,7 +638,7 @@ int elektraCurlgetGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTRA } else { - ELEKTRA_SET_RESOURCE_ERROR (parentKey, "Failed to read configuration\n"); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Failed to read configuration. Reason: %s\n", strerror (errno)); return -1; } } @@ -762,7 +763,7 @@ int elektraCurlgetSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTRA fp = fopen (tmpFile, "rb"); if (!fp) { - ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Failed to open %s for reading", tmpFile); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Failed to open %s for reading. Reason: %s", tmpFile, strerror (errno)); return -1; } fseek (fp, 0L, SEEK_END); diff --git a/src/plugins/dump/dump.cpp b/src/plugins/dump/dump.cpp index 9d47dd841eb..4de749d9a24 100644 --- a/src/plugins/dump/dump.cpp +++ b/src/plugins/dump/dump.cpp @@ -188,6 +188,7 @@ int unserialise (std::istream & is, ckdb::Key * errorKey, ckdb::KeySet * ks) } else { + // TODO: Solution ELEKTRA_SET_VALIDATION_SYNTACTIC_ERRORF ( errorKey, "Unknown command detected in dumpfile: %s.\nMaybe you use a different file format? " diff --git a/src/plugins/fcrypt/fcrypt.c b/src/plugins/fcrypt/fcrypt.c index d305e61212c..08f4a59f167 100644 --- a/src/plugins/fcrypt/fcrypt.c +++ b/src/plugins/fcrypt/fcrypt.c @@ -127,7 +127,10 @@ static int shredTemporaryFile (int fd, Key * errorKey) if (fstat (fd, &tmpStat)) { - ELEKTRA_SET_RESOURCE_ERROR (errorKey, "Failed to retrieve the file status of the temporary file."); + ELEKTRA_SET_RESOURCE_ERRORF ( + errorKey, + "Failed to overwrite the temporary data. Cannot retrieve file status Unencrypted data may leak. Errno: %s", + strerror (errno)); return -1; } @@ -146,7 +149,8 @@ static int shredTemporaryFile (int fd, Key * errorKey) return 1; error: - ELEKTRA_SET_RESOURCE_ERROR (errorKey, "Failed to overwrite the temporary file."); + ELEKTRA_SET_RESOURCE_ERRORF (errorKey, "Failed to overwrite the temporary data. Unencrypted data may leak. Errno: %s", + strerror (errno)); return -1; } @@ -226,7 +230,8 @@ static int fcryptGpgCallAndCleanup (Key * parentKey, KeySet * pluginConfig, char // gpg call returned success, overwrite the original file with the gpg payload data if (rename (tmpFile, keyString (parentKey)) != 0) { - ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Renaming file %s to %s failed.", tmpFile, keyString (parentKey)); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Renaming file %s to %s failed. Reason: %s", tmpFile, keyString (parentKey), + strerror (errno)); result = -1; } } @@ -572,7 +577,7 @@ int ELEKTRA_PLUGIN_FUNCTION (get) (Plugin * handle, KeySet * ks ELEKTRA_UNUSED, fcryptState * s = (fcryptState *) elektraPluginGetData (handle); if (!s) { - ELEKTRA_SET_PLUGIN_MISBEHAVIOR_ERROR (parentKey, "No plugin state is available."); + ELEKTRA_SET_INSTALLATION_ERROR (parentKey, "No plugin state is available."); return -1; } diff --git a/src/plugins/file/file.c b/src/plugins/file/file.c index 9e26c01baea..115e1302da3 100644 --- a/src/plugins/file/file.c +++ b/src/plugins/file/file.c @@ -62,7 +62,7 @@ int elektraFileGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTRA_UN if (!buffer) { - ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Failed to allocate buffer of %lld bytes for %s", fileSize, fileName); + ELEKTRA_SET_OUT_OF_MEMORY_ERRORF (parentKey, "Failed to allocate buffer of %lld bytes for %s", fileSize, fileName); return -1; } @@ -70,7 +70,7 @@ int elektraFileGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTRA_UN fp = fopen (fileName, "rb"); if (!fp) { - ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Failed to open file %s", fileName); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Failed to open file %s. Reason: %s", fileName, strerror (errno)); elektraFree (buffer); return -1; } @@ -87,7 +87,7 @@ int elektraFileGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTRA_UN if (bytesRead < fileSize) { - ELEKTRA_SET_VALIDATION_SYNTACTIC_ERRORF (parentKey, "Failed to read %s completely. got %lld of %lld bytes", fileName, + ELEKTRA_SET_VALIDATION_SYNTACTIC_ERRORF (parentKey, "Failed to read %s completely. Got %lld of %lld bytes", fileName, bytesRead, fileSize); elektraFree (buffer); fclose (fp); @@ -142,7 +142,7 @@ int elektraFileSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTRA_UN fp = fopen (fileName, "wb"); if (!fp) { - ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Failed to open %s for writing", fileName); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Failed to open %s for writing. Reason: %s", fileName, strerror (errno)); return -1; } ssize_t svalueSize = keyGetValueSize (key); diff --git a/src/plugins/filecheck/filecheck.c b/src/plugins/filecheck/filecheck.c index 5bcd5b52133..4d713f6c1d5 100644 --- a/src/plugins/filecheck/filecheck.c +++ b/src/plugins/filecheck/filecheck.c @@ -206,7 +206,7 @@ static long checkFile (Key * parentKey, const char * filename, checkStruct * che FILE * fp = fopen (filename, "rb"); if (fp == NULL) { - ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Couldn't open file %s", filename); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Couldn't open file %s. Reason: %s", filename, strerror (errno)); return -1; } iconv_t conv = NULL; @@ -246,8 +246,8 @@ static long checkFile (Key * parentKey, const char * filename, checkStruct * che le_ret = validateLineEnding (line, &(checkConf->validLE), 0); if (le_ret) { - ELEKTRA_SET_VALIDATION_SYNTACTIC_ERRORF (parentKey, "Invalid lineending at position %zd", - bytesRead + le_ret); + ELEKTRA_SET_VALIDATION_SYNTACTIC_ERRORF (parentKey, "Invalid lineending at position %zd in file %s", + bytesRead + le_ret, filename); retVal = -1; break; } @@ -257,8 +257,8 @@ static long checkFile (Key * parentKey, const char * filename, checkStruct * che null_ret = checkNull (line, bytesRead); if (null_ret) { - ELEKTRA_SET_VALIDATION_SYNTACTIC_ERRORF (parentKey, "Found null-byte at position %zd", - bytesRead + null_ret); + ELEKTRA_SET_VALIDATION_SYNTACTIC_ERRORF (parentKey, "Found null-byte at position %zd in file %s", + bytesRead + null_ret, filename); retVal = -1; break; } @@ -268,8 +268,8 @@ static long checkFile (Key * parentKey, const char * filename, checkStruct * che iconv_ret = validateEncoding (line, conv, bytesRead); if (iconv_ret) { - ELEKTRA_SET_VALIDATION_SYNTACTIC_ERRORF (parentKey, "Invalid encoding at position %zd", - bytesRead + iconv_ret); + ELEKTRA_SET_VALIDATION_SYNTACTIC_ERRORF (parentKey, "Invalid encoding at position %zd in file %s", + bytesRead + iconv_ret, filename); retVal = -1; break; } @@ -279,7 +279,7 @@ static long checkFile (Key * parentKey, const char * filename, checkStruct * che bom_ret = checkBom (line); if (bom_ret) { - ELEKTRA_SET_VALIDATION_SYNTACTIC_ERROR (parentKey, "Found BOM"); + ELEKTRA_SET_VALIDATION_SYNTACTIC_ERRORF (parentKey, "Found no Byte Order Mark (BOM) in file %s", filename); retVal = -1; break; } @@ -290,8 +290,8 @@ static long checkFile (Key * parentKey, const char * filename, checkStruct * che unprintable_ret = checkUnprintable (line); if (unprintable_ret) { - ELEKTRA_SET_VALIDATION_SYNTACTIC_ERRORF (parentKey, "Unprintable character at position %zd", - bytesRead + unprintable_ret); + ELEKTRA_SET_VALIDATION_SYNTACTIC_ERRORF (parentKey, "Unprintable character at position %zd in file %s", + bytesRead + unprintable_ret, filename); retVal = -1; break; } diff --git a/src/plugins/gpgme/gpgme.c b/src/plugins/gpgme/gpgme.c index 5eb868c2960..f12352251d4 100644 --- a/src/plugins/gpgme/gpgme.c +++ b/src/plugins/gpgme/gpgme.c @@ -260,7 +260,7 @@ static int transferGpgmeDataToElektraKey (gpgme_data_t src, Key * dst, Key * err readCount = gpgme_data_read (src, buffer, ciphertextLen); if (readCount != ciphertextLen) { - ELEKTRA_SET_INTERNAL_ERROR (errorKey, "An error during occurred during the data transfer."); + ELEKTRA_SET_INTERNAL_ERRORF (errorKey, "An error during occurred during the data transfer. Reason: %s", strerror (errno)); returnValue = -1; // failure goto cleanup; } diff --git a/src/plugins/passwd/passwd.c b/src/plugins/passwd/passwd.c index b9f1c5bf2d0..6b8ada4cf0e 100644 --- a/src/plugins/passwd/passwd.c +++ b/src/plugins/passwd/passwd.c @@ -202,7 +202,8 @@ int elektraPasswdGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTRA_ FILE * pwfile = fopen (keyString (parentKey), "r"); if (!pwfile) { - ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Failed to open configuration file %s\n", keyString (parentKey)); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Failed to open configuration file %s. Reason: %s\n", keyString (parentKey), + strerror (errno)); return -1; } #if defined(USE_FGETPWENT) @@ -296,7 +297,8 @@ static int writeKS (KeySet * returned, Key * parentKey, SortBy index) FILE * pwfile = fopen (keyString (parentKey), "w"); if (!pwfile) { - ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Failed to open %s for writing\n", keyString (parentKey)); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Failed to open %s for writing\n. Reason: %s", keyString (parentKey), + strerror (errno)); return -1; } Key * cur; diff --git a/src/plugins/path/path.c b/src/plugins/path/path.c index 380b8f69417..6dceb4bc749 100644 --- a/src/plugins/path/path.c +++ b/src/plugins/path/path.c @@ -157,6 +157,7 @@ static int validatePermission (Key * key, Key * parentKey) name = p->pw_name; if (uid != 0) { + // TODO: Solution ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "To check permissions for %s I need to be the root user." " Are you running kdb as root?\"", @@ -266,6 +267,7 @@ static int switchGroup (Key * key, Key * parentKey, const char * name, const str int gidErr = setegid ((int) gr->gr_gid); if (gidErr < 0) { + // TODO: Solution ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Could not set egid of user \"%s\" for key \"%s\"." " Are you running kdb as root?\"", @@ -289,6 +291,7 @@ static int switchUser (Key * key, Key * parentKey, const struct passwd * p) int err = seteuid ((int) p->pw_uid); if (err < 0) { + // TODO: Solution ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Could not set euid of user \"%s\" for key \"%s\"." " Are you running kdb as root?\"",