diff options
author | Matthew Dempsky <matthew@cvs.openbsd.org> | 2012-03-21 04:28:46 +0000 |
---|---|---|
committer | Matthew Dempsky <matthew@cvs.openbsd.org> | 2012-03-21 04:28:46 +0000 |
commit | fb44f6e2a6eef242e86c5b9ef8587ebbf7bcd71c (patch) | |
tree | f3f232a366316025b8abee5f5028cbc543bb9266 /libexec/ld.so | |
parent | c09f28795f27fd0d377dd9a77a45691c6860df93 (diff) |
Switch ld.so's _dl_opendir functions to use a locally defined
_dl_dirdesc struct (containing just the fields ld.so's implementation
actually needs) instead of reusing libc's _dirdesc struct.
Also, switch ldconfig to use futimens() instead of futimes().
ok deraadt@
Diffstat (limited to 'libexec/ld.so')
-rw-r--r-- | libexec/ld.so/dir.c | 22 | ||||
-rw-r--r-- | libexec/ld.so/dir.h | 10 | ||||
-rw-r--r-- | libexec/ld.so/ldconfig/prebind.c | 10 | ||||
-rw-r--r-- | libexec/ld.so/ldconfig/prebind_delete.c | 10 | ||||
-rw-r--r-- | libexec/ld.so/library_subr.c | 4 |
5 files changed, 32 insertions, 24 deletions
diff --git a/libexec/ld.so/dir.c b/libexec/ld.so/dir.c index eb357e3beb4..34fac9cf6b4 100644 --- a/libexec/ld.so/dir.c +++ b/libexec/ld.so/dir.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dir.c,v 1.15 2011/07/14 02:16:00 deraadt Exp $ */ +/* $OpenBSD: dir.c,v 1.16 2012/03/21 04:28:45 matthew Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -43,16 +43,22 @@ #include "util.h" #include "dir.h" -long _dl_telldir(const DIR *dirp); -void _dl_seekdir(DIR *dirp, long loc); +struct _dl_dirdesc { + int dd_fd; /* file descriptor associated with directory */ + long dd_loc; /* offset in current buffer */ + long dd_size; /* amount of data returned by getdirentries */ + char *dd_buf; /* data buffer */ + int dd_len; /* size of data buffer */ + off_t dd_seek; /* magic cookie returned by getdirentries */ +}; /* * Open a directory. */ -DIR * +_dl_DIR * _dl_opendir(const char *name) { - DIR *dirp; + _dl_DIR *dirp; int fd; struct stat sb; @@ -63,7 +69,7 @@ _dl_opendir(const char *name) return (NULL); } if (_dl_fcntl(fd, F_SETFD, FD_CLOEXEC) < 0 || - (dirp = (DIR *)_dl_malloc(sizeof(DIR))) == NULL) { + (dirp = _dl_malloc(sizeof(*dirp))) == NULL) { _dl_close(fd); return (NULL); } @@ -87,7 +93,7 @@ _dl_opendir(const char *name) * close a directory. */ int -_dl_closedir(DIR *dirp) +_dl_closedir(_dl_DIR *dirp) { int fd; int ret; @@ -106,7 +112,7 @@ _dl_closedir(DIR *dirp) * get next entry in a directory. */ struct dirent * -_dl_readdir(DIR *dirp) +_dl_readdir(_dl_DIR *dirp) { struct dirent *dp; diff --git a/libexec/ld.so/dir.h b/libexec/ld.so/dir.h index ab476fda7fb..fa3f8dc2a31 100644 --- a/libexec/ld.so/dir.h +++ b/libexec/ld.so/dir.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dir.h,v 1.2 2003/06/02 19:38:24 millert Exp $ */ +/* $OpenBSD: dir.h,v 1.3 2012/03/21 04:28:45 matthew Exp $ */ /* * Copyright (c) 1983, 1993 @@ -29,6 +29,8 @@ * SUCH DAMAGE. */ -DIR *_dl_opendir(const char *name); -int _dl_closedir(DIR *dirp); -struct dirent *_dl_readdir(DIR *dirp); +typedef struct _dl_dirdesc _dl_DIR; + +_dl_DIR *_dl_opendir(const char *name); +int _dl_closedir(_dl_DIR *dirp); +struct dirent *_dl_readdir(_dl_DIR *dirp); diff --git a/libexec/ld.so/ldconfig/prebind.c b/libexec/ld.so/ldconfig/prebind.c index 6badf720d5c..a90cc4d49b1 100644 --- a/libexec/ld.so/ldconfig/prebind.c +++ b/libexec/ld.so/ldconfig/prebind.c @@ -1,4 +1,4 @@ -/* $OpenBSD: prebind.c,v 1.14 2011/11/28 20:59:03 guenther Exp $ */ +/* $OpenBSD: prebind.c,v 1.15 2012/03/21 04:28:45 matthew Exp $ */ /* * Copyright (c) 2006 Dale Rahn <drahn@dalerahn.com> * @@ -1925,7 +1925,7 @@ int prebind_writenewfile(int infd, char *name, struct stat *st, off_t orig_size, struct prebind_info *info) { - struct timeval tv[2]; + struct timespec ts[2]; char *newname, *buf; ssize_t len, wlen; int outfd; @@ -1979,9 +1979,9 @@ prebind_writenewfile(int infd, char *name, struct stat *st, off_t orig_size, prebind_writefile(outfd, info); /* move new file into place */ - TIMESPEC_TO_TIMEVAL(&tv[0], &st->st_atimespec); - TIMESPEC_TO_TIMEVAL(&tv[1], &st->st_mtimespec); - if (futimes(outfd, tv) == -1) + ts[0] = st->st_atimespec; + ts[1] = st->st_mtimespec; + if (futimens(outfd, ts) == -1) goto fail; if (fchown(outfd, st->st_uid, st->st_gid) == -1) goto fail; diff --git a/libexec/ld.so/ldconfig/prebind_delete.c b/libexec/ld.so/ldconfig/prebind_delete.c index c0296f44b0b..400f32e37a7 100644 --- a/libexec/ld.so/ldconfig/prebind_delete.c +++ b/libexec/ld.so/ldconfig/prebind_delete.c @@ -1,4 +1,4 @@ -/* $OpenBSD: prebind_delete.c,v 1.10 2010/03/30 17:42:50 zinovik Exp $ */ +/* $OpenBSD: prebind_delete.c,v 1.11 2012/03/21 04:28:45 matthew Exp $ */ /* * Copyright (c) 2006 Dale Rahn <drahn@dalerahn.com> @@ -216,7 +216,7 @@ done: int prebind_newfile(int infd, char *name, struct stat *st, off_t orig_size) { - struct timeval tv[2]; + struct timespec ts[2]; char *newname, *buf; ssize_t len, wlen; int outfd; @@ -269,9 +269,9 @@ prebind_newfile(int infd, char *name, struct stat *st, off_t orig_size) goto fail; /* move new file into place */ - TIMESPEC_TO_TIMEVAL(&tv[0], &st->st_atimespec); - TIMESPEC_TO_TIMEVAL(&tv[1], &st->st_mtimespec); - if (futimes(outfd, tv) == -1) + ts[0] = st->st_atimespec; + ts[1] = st->st_mtimespec; + if (futimens(outfd, ts) == -1) goto fail; if (fchown(outfd, st->st_uid, st->st_gid) == -1) goto fail; diff --git a/libexec/ld.so/library_subr.c b/libexec/ld.so/library_subr.c index 23243868803..62beabcedd0 100644 --- a/libexec/ld.so/library_subr.c +++ b/libexec/ld.so/library_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: library_subr.c,v 1.35 2011/11/28 20:59:03 guenther Exp $ */ +/* $OpenBSD: library_subr.c,v 1.36 2012/03/21 04:28:45 matthew Exp $ */ /* * Copyright (c) 2002 Dale Rahn @@ -131,7 +131,7 @@ _dl_find_shlib(struct sod *sodp, const char *searchpath, int nohints) struct dirent *dp; const char *pp; int match, len; - DIR *dd; + _dl_DIR *dd; struct sod tsod, bsod; /* transient and best sod */ /* if we are to search default directories, and hints |