Remove #ifdefs around code using pread(3) and pwrite(3).
This commit is contained in:
@@ -591,11 +591,10 @@ iolog_open(struct iolog_file *iol, int dfd, int iofd, const char *mode)
|
|||||||
iol->compressed = iolog_compress;
|
iol->compressed = iolog_compress;
|
||||||
} else {
|
} else {
|
||||||
/* check for gzip magic number */
|
/* check for gzip magic number */
|
||||||
if (read(fd, magic, sizeof(magic)) == ssizeof(magic)) {
|
if (pread(fd, magic, sizeof(magic), 0) == ssizeof(magic)) {
|
||||||
if (magic[0] == gzip_magic[0] && magic[1] == gzip_magic[1])
|
if (magic[0] == gzip_magic[0] && magic[1] == gzip_magic[1])
|
||||||
iol->compressed = true;
|
iol->compressed = true;
|
||||||
}
|
}
|
||||||
(void)lseek(fd, 0, SEEK_SET);
|
|
||||||
}
|
}
|
||||||
(void)fcntl(fd, F_SETFD, FD_CLOEXEC);
|
(void)fcntl(fd, F_SETFD, FD_CLOEXEC);
|
||||||
#ifdef HAVE_ZLIB_H
|
#ifdef HAVE_ZLIB_H
|
||||||
|
@@ -115,14 +115,10 @@ is_script(int fd)
|
|||||||
char magic[2];
|
char magic[2];
|
||||||
debug_decl(is_script, SUDOERS_DEBUG_MATCH);
|
debug_decl(is_script, SUDOERS_DEBUG_MATCH);
|
||||||
|
|
||||||
if (read(fd, magic, 2) == 2) {
|
if (pread(fd, magic, 2, 0) == 2) {
|
||||||
if (magic[0] == '#' && magic[1] == '!')
|
if (magic[0] == '#' && magic[1] == '!')
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
if (lseek(fd, (off_t)0, SEEK_SET) == -1) {
|
|
||||||
sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_ERRNO|SUDO_DEBUG_LINENO,
|
|
||||||
"unable to rewind script fd");
|
|
||||||
}
|
|
||||||
debug_return_int(ret);
|
debug_return_int(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -307,17 +307,7 @@ ts_write(int fd, const char *fname, struct timestamp_entry *entry, off_t offset)
|
|||||||
nwritten = write(fd, entry, entry->size);
|
nwritten = write(fd, entry, entry->size);
|
||||||
} else {
|
} else {
|
||||||
old_eof = offset;
|
old_eof = offset;
|
||||||
#ifdef HAVE_PWRITE
|
|
||||||
nwritten = pwrite(fd, entry, entry->size, offset);
|
nwritten = pwrite(fd, entry, entry->size, offset);
|
||||||
#else
|
|
||||||
if (lseek(fd, offset, SEEK_SET) == -1) {
|
|
||||||
sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_ERRNO|SUDO_DEBUG_LINENO,
|
|
||||||
"unable to seek to %lld", (long long)offset);
|
|
||||||
nwritten = -1;
|
|
||||||
} else {
|
|
||||||
nwritten = write(fd, entry, entry->size);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
if ((size_t)nwritten != entry->size) {
|
if ((size_t)nwritten != entry->size) {
|
||||||
if (nwritten == -1) {
|
if (nwritten == -1) {
|
||||||
@@ -577,16 +567,7 @@ ts_read(struct ts_cookie *cookie, struct timestamp_entry *entry)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Seek to the record position and read it. */
|
/* Seek to the record position and read it. */
|
||||||
#ifdef HAVE_PREAD
|
|
||||||
nread = pread(cookie->fd, entry, sizeof(*entry), cookie->pos);
|
nread = pread(cookie->fd, entry, sizeof(*entry), cookie->pos);
|
||||||
#else
|
|
||||||
if (lseek(cookie->fd, cookie->pos, SEEK_SET) == -1) {
|
|
||||||
sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_ERRNO|SUDO_DEBUG_LINENO,
|
|
||||||
"unable to seek to %lld", (long long)cookie->pos);
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
nread = read(cookie->fd, entry, sizeof(*entry));
|
|
||||||
#endif
|
|
||||||
if (nread != sizeof(*entry)) {
|
if (nread != sizeof(*entry)) {
|
||||||
/* short read, should not happen */
|
/* short read, should not happen */
|
||||||
sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
|
sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
|
||||||
|
Reference in New Issue
Block a user