Blob Blame History Raw
--- acl-2.2.39/getfacl/getfacl.c.old	2007-11-08 14:38:56.000000000 +0100
+++ acl-2.2.39/getfacl/getfacl.c	2007-11-08 14:39:19.000000000 +0100
@@ -598,17 +598,17 @@ int __do_print(const char *file, const s
 char *resolve_symlinks(const char *file)
 {
 	static char buffer[4096];
+	struct stat stat;
 	char *path = NULL;
-	ssize_t len;
 
-	len = readlink(file, buffer, sizeof(buffer)-1);
-	if (len < 0) {
-		if (errno == EINVAL)	/* not a symlink, use given path */
-			path = (char *)file;
-	} else {
-		buffer[len+1] = '\0';
-		path = buffer;
-	}
+	if (lstat(file, &stat) == -1)
+		return path;
+
+	if (S_ISLNK(stat.st_mode) && !opt_walk_physical)
+		path = realpath(file, buffer);
+	else
+		path = (char *)file; 	/* not a symlink, use given path */
+
 	return path;
 }
 
--- acl-2.2.39/setfacl/setfacl.c.old	2006-06-20 08:51:25.000000000 +0200
+++ acl-2.2.39/setfacl/setfacl.c	2007-11-08 14:39:19.000000000 +0100
@@ -314,17 +316,17 @@ int __do_set(const char *file, const str
 char *resolve_symlinks(const char *file)
 {
 	static char buffer[4096];
+	struct stat stat;
 	char *path = NULL;
-	ssize_t len;
 
-	len = readlink(file, buffer, sizeof(buffer)-1);
-	if (len < 0) {
-		if (errno == EINVAL)	/* not a symlink, use given path */
-			path = (char *)file;
-	} else {
-		buffer[len+1] = '\0';
-		path = buffer;
-	}
+	if (lstat(file, &stat) == -1)
+		return path;
+
+	if (S_ISLNK(stat.st_mode) && !opt_walk_physical)
+		path = realpath(file, buffer);
+	else
+		path = (char *)file;    /* not a symlink, use given path */
+
 	return path;
 }