aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Seebach <peter.seebach@windriver.com>2013-02-13 13:32:53 -0600
committerPeter Seebach <peter.seebach@windriver.com>2013-02-13 13:35:31 -0600
commit011b401fb6be38d739215e455588af4dcd707e17 (patch)
tree6ec9ff1e7b92cb22c73b079d528c1b59455fa25a
parent363a94bb851046f62648d7c96c749e899bd0648e (diff)
downloadpseudo-PSEUDO_1_4_5.tar.gz
pseudo-PSEUDO_1_4_5.tar.bz2
pseudo-PSEUDO_1_4_5.zip
Fix linkat() again.pseudo-1.4.5PSEUDO_1_4_5
wrap_linkat() was trying to avoid "redundantly" expanding paths before calling real_linkat(). Which is fine when you're not using an absolute path in a chroot environment, but if you are, it ends up calling the real syscall with the absolute path and no chroot prefix. General observation: All the *at() implementations are expanding paths into absolute paths, then dutifully calling real_*at() functions with them anyway. This is silly. Added a note to Futures.txt to fix it some day. In the mean time, linkat() is fixed correctly; it always expands paths, does so exactly once, and then uses the underlying link() call because it doesn't need special processing of directory fds anymore. Also fixed errno stashing to reduce the risk that link() will change errno in a circumstance where it doesn't actually fail.
-rw-r--r--ChangeLog.txt5
-rw-r--r--Futures.txt5
-rw-r--r--Makefile.in4
-rw-r--r--ports/unix/guts/linkat.c14
4 files changed, 15 insertions, 13 deletions
diff --git a/ChangeLog.txt b/ChangeLog.txt
index e930b08..8f52cc9 100644
--- a/ChangeLog.txt
+++ b/ChangeLog.txt
@@ -1,3 +1,8 @@
+2013-02-13:
+ * (seebs) calling link while chrooted could in some cases result
+ in the root path not being prepended at all. One more try!
+ * (seebs) 1.4.5.
+
2013-02-12:
* (seebs) calling link while chrooted could in some cases result
in the root path being double-appended.
diff --git a/Futures.txt b/Futures.txt
index e7829ce..7a39fab 100644
--- a/Futures.txt
+++ b/Futures.txt
@@ -33,3 +33,8 @@ vague implementation thoughts:
* Test cases
- boy, do we need test cases!
+
+* Clean up *at() functions
+ - The *at() function implementations are gratuitously complicated,
+ I believe because they predate the auto-canonicalization that came
+ with the rewritten pseudo wrappers.
diff --git a/Makefile.in b/Makefile.in
index 0552d35..e0cd7a9 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1,7 +1,7 @@
#
# Makefile.in/Makefile, build rules for pseudo
#
-# Copyright (c) 2008-2012 Wind River Systems, Inc.
+# Copyright (c) 2008-2013 Wind River Systems, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the Lesser GNU General Public License version 2.1 as
@@ -27,7 +27,7 @@ BITS=@BITS@
ARCH_FLAGS=@ARCH_FLAGS@
MARK64=@MARK64@
RPATH=@RPATH@
-VERSION=1.4.4
+VERSION=1.4.5
LIB=@LIB@
BIN=bin
diff --git a/ports/unix/guts/linkat.c b/ports/unix/guts/linkat.c
index 3d0f99a..9ca7c47 100644
--- a/ports/unix/guts/linkat.c
+++ b/ports/unix/guts/linkat.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012 Wind River Systems; see
+ * Copyright (c) 2012, 2013 Wind River Systems; see
* guts/COPYRIGHT for information.
*
* int linkat(int olddirfd, const char *oldname, int newdirfd, const char *newname, int flags)
@@ -31,24 +31,17 @@
errno = ENOSYS;
return -1;
}
+#endif
oldpath = pseudo_root_path(__func__, __LINE__, olddirfd, oldname, rflags);
newpath = pseudo_root_path(__func__, __LINE__, newdirfd, newname, AT_SYMLINK_NOFOLLOW);
rc = real_link(oldpath, newpath);
+ save_errno = errno;
if (rc == -1) {
- save_errno = errno;
free(oldpath);
free(newpath);
errno = save_errno;
return rc;
}
-#else
- rc = real_linkat(olddirfd, oldname, newdirfd, newname, flags);
- if (rc == -1) {
- return rc;
- }
- oldpath = pseudo_root_path(__func__, __LINE__, olddirfd, oldname, rflags);
- newpath = pseudo_root_path(__func__, __LINE__, newdirfd, newname, AT_SYMLINK_NOFOLLOW);
-#endif
/* if we got this far, the link succeeded, and oldpath and newpath
* are the newly-allocated canonical paths. If OS, filesystem, or
@@ -74,7 +67,6 @@
*/
pseudo_client_op(OP_LINK, 0, -1, -1, newpath, &buf);
- save_errno = errno;
free(oldpath);
free(newpath);
errno = save_errno;