diff options
author | Barry Naujok <bnaujok@sgi.com> | 2007-09-11 04:08:29 +0000 |
---|---|---|
committer | Barry Naujok <bnaujok@sgi.com> | 2007-09-11 04:08:29 +0000 |
commit | f8e8f16aa8eaade0d6fda42079685854047980c7 (patch) | |
tree | 001254146be91d149da00c7f4a15fad741e50570 | |
parent | 1a53b1cf8de9d1eb4cc80d021460c10877453e3f (diff) | |
download | acl-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
-rw-r--r-- | getfacl/getfacl.c | 18 | ||||
-rw-r--r-- | setfacl/setfacl.c | 18 |
2 files changed, 18 insertions, 18 deletions
diff --git a/getfacl/getfacl.c b/getfacl/getfacl.c index 6ee4696..a01e211 100644 --- a/getfacl/getfacl.c +++ b/getfacl/getfacl.c @@ -598,17 +598,17 @@ int __do_print(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; } 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; } |