From 363a94bb851046f62648d7c96c749e899bd0648e Mon Sep 17 00:00:00 2001 From: Peter Seebach Date: Tue, 12 Feb 2013 15:42:49 -0600 Subject: Fix link() to work when chrooted The automatic path fixups invoked for names which end in the string "path" was still applying to link(), which then called linkat(), which would do the same path fixups; if you were chrooted, this would produce bogus paths. On systems which actually have linkat(), this would produce the even more mysterious behavior that the link would succeed, but the following stat would fail. Solution: Change the wrapfuncs prototypes for link() so it doesn't invoke automatic path name fixups. --- ChangeLog.txt | 5 +++++ Makefile.in | 2 +- ports/unix/guts/link.c | 6 +++--- ports/unix/wrapfuncs.in | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 680aecf..e930b08 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,3 +1,8 @@ +2013-02-12: + * (seebs) calling link while chrooted could in some cases result + in the root path being double-appended. + * (seebs) and tag 1.4.4 so that can get out as a clean update. + 2013-01-31: * (seebs) tag 1.4.3 (to avoid any problems with the changes since 1.4.2 and old tarballs) diff --git a/Makefile.in b/Makefile.in index 69bbe6e..0552d35 100644 --- a/Makefile.in +++ b/Makefile.in @@ -27,7 +27,7 @@ BITS=@BITS@ ARCH_FLAGS=@ARCH_FLAGS@ MARK64=@MARK64@ RPATH=@RPATH@ -VERSION=1.4.3 +VERSION=1.4.4 LIB=@LIB@ BIN=bin diff --git a/ports/unix/guts/link.c b/ports/unix/guts/link.c index cabcdf4..3b340ee 100644 --- a/ports/unix/guts/link.c +++ b/ports/unix/guts/link.c @@ -1,9 +1,9 @@ /* - * Copyright (c) 2008-2010, 2012 Wind River Systems; see + * Copyright (c) 2008-2010, 2012, 2013 Wind River Systems; see * guts/COPYRIGHT for information. * * static int - * wrap_link(const char *oldpath, const char *newpath) { + * wrap_link(const char *oldname, const char *newname) { * int rc = -1; */ /* since 2.6.18 or so, linkat supports AT_SYMLINK_FOLLOW, which @@ -12,7 +12,7 @@ * does NOT support AT_SYMLINK_NOFOLLOW! So define this in * your port's portdefs.h or hope the default works for you. */ - rc = wrap_linkat(AT_FDCWD, oldpath, AT_FDCWD, newpath, + rc = wrap_linkat(AT_FDCWD, oldname, AT_FDCWD, newname, PSEUDO_LINK_SYMLINK_BEHAVIOR); /* return rc; diff --git a/ports/unix/wrapfuncs.in b/ports/unix/wrapfuncs.in index f6a2cd1..7e205f0 100644 --- a/ports/unix/wrapfuncs.in +++ b/ports/unix/wrapfuncs.in @@ -37,7 +37,7 @@ int chmod(const char *path, mode_t mode); int chown(const char *path, uid_t owner, gid_t group); int fchmodat(int dirfd, const char *path, mode_t mode, int flags); int fchownat(int dirfd, const char *path, uid_t owner, gid_t group, int flags); -int link(const char *oldpath, const char *newpath); /* flags=AT_SYMLINK_NOFOLLOW */ +int link(const char *oldname, const char *newname); /* flags=AT_SYMLINK_NOFOLLOW */ int linkat(int olddirfd, const char *oldname, int newdirfd, const char *newname, int flags); int mkdir(const char *path, mode_t mode); /* flags=AT_SYMLINK_NOFOLLOW */ int mkdirat(int dirfd, const char *path, mode_t mode); /* flags=AT_SYMLINK_NOFOLLOW */ -- cgit v1.2.2-1-g5e49