Skip to content

3.4.0 portability regression because of openat(AT_FDCWD #701

@solardiz

Description

@solardiz

The 3.4.0 release blindly assumes that openat and AT_FDCWD are available when certain other things are, but this is not the case e.g. on ancient glibc. This fixes build on glibc 2.3.6:

+++ rsync-3.4.0/syscall.c	2025-01-15 03:21:50 +0000
@@ -734,7 +734,7 @@ int secure_relative_open(const char *bas
 		return -1;
 	}
 
-#if !defined(O_NOFOLLOW) || !defined(O_DIRECTORY)
+#if !defined(O_NOFOLLOW) || !defined(O_DIRECTORY) || !defined(AT_FDCWD)
 	// really old system, all we can do is live with the risks
 	if (!basedir) {
 		return open(relpath, flags, mode);

Just like the O_* checks here, this added check relies on AT_FDCWD being a macro (rather than e.g. part of an enum) on systems where it's present - I don't know whether that is guaranteed or perhaps not.

It's unfortunate that this fallback code keeps some of the security issues exposed - perhaps this is worth warning about somewhere beyond the source code comment? For example, maybe configure should fail on such systems by default, and require an "accept risks" option to override that.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions