summaryrefslogtreecommitdiff
path: root/setfacl
diff options
context:
space:
mode:
authorBarry Naujok <bnaujok@sgi.com>2007-09-11 04:08:29 +0000
committerBarry Naujok <bnaujok@sgi.com>2007-09-11 04:08:29 +0000
commitf8e8f16aa8eaade0d6fda42079685854047980c7 (patch)
tree001254146be91d149da00c7f4a15fad741e50570 /setfacl
parent1a53b1cf8de9d1eb4cc80d021460c10877453e3f (diff)
downloadacl-f8e8f16aa8eaade0d6fda42079685854047980c7.tar.gz
Fix symlink handling in getfattr, getfacl and setfacl
Merge of master-melb:xfs-cmds:29637a by kenmcd. Fix symlink handling in getfacl
Diffstat (limited to 'setfacl')
-rw-r--r--setfacl/setfacl.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/setfacl/setfacl.c b/setfacl/setfacl.c
index bb1c586..1304d04 100644
--- a/setfacl/setfacl.c
+++ b/setfacl/setfacl.c
@@ -314,17 +314,17 @@ int __do_set(const char *file, const struct stat *stat,
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;
}