diff --git a/src/Makefile.am b/src/Makefile.am index 3316918fd79..61fb2e998d3 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -94,7 +94,7 @@ osdmaptool_SOURCES = osdmaptool.cc osdmaptool_LDADD = libcommon.a -lpthread -lm $(CRYPTO_LIBS) $(EXTRALIBS) bin_PROGRAMS += monmaptool crushtool osdmaptool -mount_ceph_SOURCES = mount/mount.ceph.c common/armor.c common/secret.c include/addr_parsing.c +mount_ceph_SOURCES = mount/mount.ceph.c common/armor.c common/safe_io.c common/secret.c include/addr_parsing.c mount_ceph_LDADD = -lkeyutils sbin_PROGRAMS += mount.ceph diff --git a/src/common/safe_io.h b/src/common/safe_io.h index 3a975d72b90..3485392d048 100644 --- a/src/common/safe_io.h +++ b/src/common/safe_io.h @@ -23,7 +23,7 @@ extern "C" { /* * Safe functions wrapping the raw read() and write() libc functions. * These retry on EINTR, and on error return -errno instead of returning - * 1 and setting errno). + * -1 and setting errno). */ ssize_t safe_read(int fd, void *buf, size_t count) __attribute__ ((warn_unused_result)); diff --git a/src/common/secret.c b/src/common/secret.c index 70085a49371..0550293ca92 100644 --- a/src/common/secret.c +++ b/src/common/secret.c @@ -22,6 +22,7 @@ #include #include "common/armor.h" +#include "common/safe_io.h" int read_secret_from_file(const char *filename, char *secret, size_t max_len) { @@ -34,7 +35,7 @@ int read_secret_from_file(const char *filename, char *secret, size_t max_len) perror("unable to read secretfile"); return -1; } - len = read(fd, secret, max_len); + len = safe_read(fd, secret, max_len); if (len <= 0) { perror("unable to read secret from file"); return -1;