summaryrefslogtreecommitdiff
path: root/src/sss_client
diff options
context:
space:
mode:
Diffstat (limited to 'src/sss_client')
-rw-r--r--src/sss_client/pam_sss.c50
-rw-r--r--src/sss_client/ssh/sss_ssh_knownhostsproxy.c4
2 files changed, 27 insertions, 27 deletions
diff --git a/src/sss_client/pam_sss.c b/src/sss_client/pam_sss.c
index 8778fe19..3de810c5 100644
--- a/src/sss_client/pam_sss.c
+++ b/src/sss_client/pam_sss.c
@@ -47,6 +47,7 @@
#include "sss_pam_macros.h"
#include "sss_cli.h"
+#include "util/atomic_io.h"
#include <libintl.h>
#define _(STRING) dgettext (PACKAGE, STRING)
@@ -499,17 +500,12 @@ static errno_t display_pw_reset_message(pam_handle_t *pamh,
goto done;
}
-
- total_len = 0;
- while (total_len < stat_buf.st_size) {
- ret = read(fd, msg_buf + total_len, stat_buf.st_size - total_len);
- if (ret == -1) {
- if (errno == EINTR || errno == EAGAIN) continue;
- ret = errno;
- D(("read failed [%d][%s].", ret, strerror(ret)));
- goto done;
- }
- total_len += ret;
+ errno = 0;
+ total_len = sss_atomic_read_s(fd, msg_buf, stat_buf.st_size);
+ if (ret == -1) {
+ ret = errno;
+ D(("read failed [%d][%s].", ret, strerror(ret)));
+ goto done;
}
ret = close(fd);
@@ -1088,7 +1084,8 @@ static int send_and_receive(pam_handle_t *pamh, struct pam_items *pi,
#ifdef HAVE_SELINUX
char *path = NULL;
char *tmp_path = NULL;
- int pos, len;
+ ssize_t written;
+ int len;
int fd;
mode_t oldmask;
#endif /* HAVE_SELINUX */
@@ -1206,21 +1203,24 @@ static int send_and_receive(pam_handle_t *pamh, struct pam_items *pi,
goto done;
}
- pos = 0;
len = strlen(pi->selinux_user);
- while (pos < len) {
- ret = write(fd, pi->selinux_user + pos, len-pos);
- if (ret < 0) {
- if (errno != EINTR) {
- logger(pamh, LOG_ERR, "writing to SELinux data file "
- "failed. %s", tmp_path);
- pam_status = PAM_SYSTEM_ERR;
- goto done;
- }
- continue;
- }
- pos += ret;
+
+ errno = 0;
+ written = sss_atomic_write_s(fd, pi->selinux_user, len);
+ if (written == -1) {
+ ret = errno;
+ logger(pamh, LOG_ERR, "writing to SELinux data file "
+ "failed. %s", tmp_path);
+ pam_status = PAM_SYSTEM_ERR;
+ goto done;
}
+
+ if (written != len) {
+ logger(pamh, LOG_ERR, "Expected to write %d bytes, wrote %d",
+ written, len);
+ goto done;
+ }
+
close(fd);
rename(tmp_path, path);
diff --git a/src/sss_client/ssh/sss_ssh_knownhostsproxy.c b/src/sss_client/ssh/sss_ssh_knownhostsproxy.c
index 6424d7b7..e45ef45f 100644
--- a/src/sss_client/ssh/sss_ssh_knownhostsproxy.c
+++ b/src/sss_client/ssh/sss_ssh_knownhostsproxy.c
@@ -140,11 +140,11 @@ connect_socket(int family, struct sockaddr *addr, size_t addr_len)
}
errno = 0;
- res = sss_atomic_write(i == 0 ? sock : 1, buffer, res);
+ res = sss_atomic_write_s(i == 0 ? sock : 1, buffer, res);
ret = errno;
if (res == -1) {
DEBUG(SSSDBG_OP_FAILURE,
- ("sss_atomic_write() failed (%d): %s\n",
+ ("sss_atomic_write_s() failed (%d): %s\n",
ret, strerror(ret)));
goto done;
} else if (ret == EPIPE) {