summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Reichl <preichl@redhat.com>2014-11-28 13:17:44 +0000
committerJakub Hrozek <jhrozek@redhat.com>2014-11-28 16:16:37 +0100
commitaff8b0e3b41644c70704b78e15501779d52b6ff4 (patch)
treef0ae0696f623a5bfc36f18f7fea68af904a67f1d
parent5b4c6f22cb576a11037c7fa940fe0ba09e643e77 (diff)
downloadsssd-aff8b0e3b41644c70704b78e15501779d52b6ff4.tar.gz
sssd-aff8b0e3b41644c70704b78e15501779d52b6ff4.tar.xz
sssd-aff8b0e3b41644c70704b78e15501779d52b6ff4.zip
Fix: always check return value of unlink()
Resolves: https://fedorahosted.org/sssd/ticket/2506 Reviewed-by: Lukáš Slebodník <lslebodn@redhat.com>
-rw-r--r--src/monitor/monitor.c9
-rw-r--r--src/responder/ssh/sshsrv_cmd.c14
-rw-r--r--src/sbus/sssd_dbus_server.c12
-rw-r--r--src/util/server.c10
4 files changed, 38 insertions, 7 deletions
diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index b55757d95..c6834a115 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -1685,7 +1685,14 @@ static errno_t load_configuration(TALLOC_CTX *mem_ctx,
* misconfiguration gets in the way
*/
talloc_zfree(ctx->cdb);
- unlink(cdb_file);
+ ret = unlink(cdb_file);
+ if (ret != EOK && errno != ENOENT) {
+ ret = errno;
+ DEBUG(SSSDBG_MINOR_FAILURE,
+ "Purging existing confdb failed: %d [%s].\n",
+ ret, sss_strerror(ret));
+ goto done;
+ }
ret = confdb_init(ctx, &ctx->cdb, cdb_file);
if (ret != EOK) {
diff --git a/src/responder/ssh/sshsrv_cmd.c b/src/responder/ssh/sshsrv_cmd.c
index 5bed2e0ad..e7bed3ab2 100644
--- a/src/responder/ssh/sshsrv_cmd.c
+++ b/src/responder/ssh/sshsrv_cmd.c
@@ -536,7 +536,7 @@ static errno_t
ssh_host_pubkeys_update_known_hosts(struct ssh_cmd_ctx *cmd_ctx)
{
TALLOC_CTX *tmp_ctx;
- errno_t ret;
+ errno_t ret, tmp_ret;
const char *attrs[] = {
SYSDB_NAME,
SYSDB_NAME_ALIAS,
@@ -654,7 +654,17 @@ ssh_host_pubkeys_update_known_hosts(struct ssh_cmd_ctx *cmd_ctx)
done:
if (fd != -1) close(fd);
- if (ret != EOK && filename) unlink(filename);
+ if (ret != EOK && filename) {
+ tmp_ret = unlink(filename);
+ /* non-fatal failure */
+ if (tmp_ret != EOK) {
+ tmp_ret = errno;
+ DEBUG(SSSDBG_MINOR_FAILURE,
+ "Failed to remove file: %s - %d : [%s]!\n",
+ filename, tmp_ret, sss_strerror(tmp_ret));
+ }
+ }
+
talloc_free(tmp_ctx);
return ret;
diff --git a/src/sbus/sssd_dbus_server.c b/src/sbus/sssd_dbus_server.c
index 18fb98df6..137524892 100644
--- a/src/sbus/sssd_dbus_server.c
+++ b/src/sbus/sssd_dbus_server.c
@@ -192,7 +192,7 @@ int sbus_new_server(TALLOC_CTX *mem_ctx,
DBusError dbus_error;
dbus_bool_t dbret;
char *tmp;
- int ret;
+ int ret, tmp_ret;
char *filename;
char *symlink_filename = NULL;
const char *socket_address;
@@ -343,9 +343,17 @@ int sbus_new_server(TALLOC_CTX *mem_ctx,
*_server = talloc_steal(mem_ctx, server);
ret = EOK;
+
done:
if (ret != EOK && symlink_filename) {
- unlink(symlink_filename);
+ tmp_ret = unlink(symlink_filename);
+ /* non-fatal failure */
+ if (tmp_ret != EOK) {
+ tmp_ret = errno;
+ DEBUG(SSSDBG_MINOR_FAILURE,
+ "Failed to remove symbolic link: %d [%s]!\n",
+ tmp_ret, sss_strerror(tmp_ret));
+ }
}
talloc_free(tmp_ctx);
return ret;
diff --git a/src/util/server.c b/src/util/server.c
index 03f4b9588..abd29310f 100644
--- a/src/util/server.c
+++ b/src/util/server.c
@@ -194,8 +194,14 @@ int pidfile(const char *path, const char *name)
/* nothing in the file or no process */
close(fd);
- unlink(file);
-
+ ret = unlink(file);
+ /* non-fatal failure */
+ if (ret != EOK) {
+ ret = errno;
+ DEBUG(SSSDBG_MINOR_FAILURE,
+ "Failed to remove file: %s - %d [%s]!\n",
+ file, ret, sss_strerror(ret));
+ }
} else {
if (err != ENOENT) {
talloc_free(file);