summaryrefslogtreecommitdiffstats
path: root/src/krb5_plugin
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2012-04-02 17:26:05 -0400
committerStephen Gallagher <sgallagh@redhat.com>2012-04-20 10:55:14 -0400
commit9d7d4458d94d0aac0a7edf999368eb18f89cb76a (patch)
treeb443c2ed560bc5f61cae78e94ceeb795fa1f83b4 /src/krb5_plugin
parent9959c512ac3ba36f7a0db7614f0357ce0bae748f (diff)
downloadsssd_unused-9d7d4458d94d0aac0a7edf999368eb18f89cb76a.tar.gz
sssd_unused-9d7d4458d94d0aac0a7edf999368eb18f89cb76a.tar.xz
sssd_unused-9d7d4458d94d0aac0a7edf999368eb18f89cb76a.zip
Convert read and write operations to sss_atomic_read
https://fedorahosted.org/sssd/ticket/1209
Diffstat (limited to 'src/krb5_plugin')
-rw-r--r--src/krb5_plugin/sssd_krb5_locator_plugin.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/src/krb5_plugin/sssd_krb5_locator_plugin.c b/src/krb5_plugin/sssd_krb5_locator_plugin.c
index 3eced04d..b8d4e31b 100644
--- a/src/krb5_plugin/sssd_krb5_locator_plugin.c
+++ b/src/krb5_plugin/sssd_krb5_locator_plugin.c
@@ -86,7 +86,6 @@ static int get_krb5info(const char *realm, struct sssd_ctx *ctx,
char *krb5info_name = NULL;
size_t len;
uint8_t buf[BUFSIZE + 1];
- uint8_t *p;
int fd = -1;
const char *name_tmpl = NULL;
char *port_str;
@@ -129,23 +128,19 @@ static int get_krb5info(const char *realm, struct sssd_ctx *ctx,
goto done;
}
- len = BUFSIZE;
- p = buf;
memset(buf, 0, BUFSIZE+1);
- while (len != 0 && (ret = read(fd, p, len)) != 0) {
- if (ret == -1) {
- if (errno == EINTR || errno == EAGAIN) continue;
- PLUGIN_DEBUG(("read failed [%d][%s].\n", errno, strerror(errno)));
- close(fd);
- goto done;
- }
- len -= ret;
- p += ret;
+ errno = 0;
+ len = sss_atomic_read_s(fd, buf, BUFSIZE);
+ if (len == -1) {
+ ret = errno;
+ PLUGIN_DEBUG(("read failed [%d][%s].\n", ret, strerror(ret)));
+ close(fd);
+ goto done;
}
close(fd);
- if (len == 0) {
+ if (len == BUFSIZE) {
PLUGIN_DEBUG(("Content of krb5info file [%s] is [%d] or larger.\n",
krb5info_name, BUFSIZE));
}
@@ -212,6 +207,7 @@ static int get_krb5info(const char *realm, struct sssd_ctx *ctx,
goto done;
}
+ ret = 0;
done:
free(krb5info_name);
return ret;