Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 149829 Details for
Bug 223840
[LSPP] getfacl fails to correctly display all information about links explicited as arguments
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
Improved walk patch
acl-2.2.39-walk.patch (text/x-patch), 5.14 KB, created by
Thomas Woerner
on 2007-03-12 15:42:22 UTC
(
hide
)
Description:
Improved walk patch
Filename:
MIME Type:
Creator:
Thomas Woerner
Created:
2007-03-12 15:42:22 UTC
Size:
5.14 KB
patch
obsolete
>--- acl-2.2.39/getfacl/getfacl.c.walk 2006-06-20 08:51:25.000000000 +0200 >+++ acl-2.2.39/getfacl/getfacl.c 2007-03-12 16:38:36.000000000 +0100 >@@ -34,7 +34,6 @@ > #include <dirent.h> > #include <libgen.h> > #include <getopt.h> >-#include <ftw.h> > #include <locale.h> > #include "config.h" > #include "user_group.h" >@@ -70,9 +69,9 @@ > const char *progname; > const char *cmd_line_options; > >-int opt_recursive; /* recurse into sub-directories? */ >-int opt_walk_logical; /* always follow symbolic links */ >-int opt_walk_physical; /* never follow symbolic links */ >+int opt_recursive = 0; /* recurse into sub-directories? */ >+int opt_walk_logical = 0; /* always follow symbolic links */ >+int opt_walk_physical = 0; /* never follow symbolic links */ > int opt_print_acl = 0; > int opt_print_default_acl = 0; > int opt_strip_leading_slash = 1; >@@ -562,71 +561,132 @@ > > > static int __errors; >-int __do_print(const char *file, const struct stat *stat, >- int flag, struct FTW *ftw) >+ >+int walk_tree(const char *file) > { >- int saved_errno = errno; >+ static int level = 0; >+ static int link_count = 0; >+ DIR *dir; >+ struct dirent *entry; >+ struct stat buf; >+ char path[FILENAME_MAX]; >+ char path2[FILENAME_MAX]; >+ char path3[FILENAME_MAX]; >+ char *dir_name; >+ size_t len; >+ ssize_t slen; > > /* Process the target of a symbolic link, and traverse the link, > only if doing a logical walk, or if the symbolic link was > specified on the command line. Always skip symbolic links if > doing a physical walk. */ > >- if (S_ISLNK(stat->st_mode) && >- (opt_walk_physical || (ftw->level > 0 && !opt_walk_logical))) >+ len = strlen(file); >+ /* check for FILENAME_MAX */ >+ if (len > FILENAME_MAX) { >+ fprintf(stderr, "%s: %s: %s\n", progname, xquote(file), >+ strerror(ENAMETOOLONG)); >+ __errors++; >+ return 0; >+ } >+ /* string ends with '/', remove it and restart */ >+ if (len > 1 && file[len-1] == '/') { >+ strncpy(path, file, FILENAME_MAX-1); >+ path[FILENAME_MAX] = '\n'; >+ path[len-1] = '\0'; >+ return walk_tree(path); >+ } >+ >+ if (level > 0 && !opt_recursive) > return 0; > >- if (do_print(file, stat)) >+ if (lstat(file, &buf) != 0) { >+ fprintf(stderr, "%s: %s: %s\n", progname, xquote(file), >+ strerror(errno)); > __errors++; >- >- if (flag == FTW_DNR && opt_recursive) { >- /* Item is a directory which can't be read. */ >- fprintf(stderr, "%s: %s: %s\n", >- progname, file, strerror(saved_errno)); > return 0; > } > >- /* We also get here in non-recursive mode. In that case, >- return something != 0 to abort nftw. */ >+ if (S_ISLNK(buf.st_mode)) { >+ /* physical means: no links at all */ >+ if (opt_walk_physical) >+ return 1; >+ >+ /* logical: show information or walk if points to directory >+ * also for symbolic link arguments on level 0 */ >+ if (opt_walk_logical || (level == 0 && link_count == 0)) { >+ /* get directory name */ >+ strncpy(path2, file, FILENAME_MAX-1); >+ path2[FILENAME_MAX] = '\n'; >+ dir_name = dirname(path2); >+ >+ /* get link target */ >+ slen = readlink(file, path, FILENAME_MAX-1); >+ if (slen < 0) { >+ fprintf(stderr, "%s: %s: %s\n", progname, >+ xquote(file), strerror(errno)); >+ __errors++; >+ return 0; >+ } >+ path[slen+1] = '\n'; > >- if (!opt_recursive) >- return 1; >+ if (slen == 0 || path[0] == '/' || >+ ! strcmp(dir_name, ".")) >+ strncpy(path3, path, FILENAME_MAX); >+ else >+ snprintf(path3, FILENAME_MAX, "%s/%s", >+ dir_name, path); >+ >+ if (stat(path3, &buf) != 0) { >+ fprintf(stderr, "%s: %s: %s\n", progname, >+ xquote(path), strerror(errno)); >+ __errors++; >+ return 0; >+ } >+ if (S_ISDIR(buf.st_mode) && opt_recursive && >+ link_count < 1) { >+ link_count++; >+ if (walk_tree(path3) != 1) >+ return 0; >+ link_count--; >+ } else { >+ if (do_print(path3, &buf)) >+ __errors++; >+ } >+ return 1; >+ } >+ } > >- return 0; >-} >+ if (do_print(file, &buf)) >+ __errors++; > >-char *resolve_symlinks(const char *file) >-{ >- static char buffer[4096]; >- 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; >- } >- return path; >-} >+ /* it is a directory, walk */ >+ if (S_ISDIR(buf.st_mode)) { >+ level++; >+ dir = opendir(file); >+ if (!dir) { >+ fprintf(stderr, "%s: %s: %s\n", progname, >+ xquote(file), strerror(errno)); >+ __errors++; >+ return 0; >+ } > >-int walk_tree(const char *file) >-{ >- const char *p; >+ while ((entry = readdir(dir)) != NULL) { >+ if (! strcmp(entry->d_name, ".") || >+ ! strcmp(entry->d_name, "..")) >+ continue; > >- __errors = 0; >- if ((p = resolve_symlinks(file)) == NULL) { >- fprintf(stderr, "%s: %s: %s\n", progname, >- xquote(file), strerror(errno)); >- __errors++; >- } else if (nftw(p, __do_print, 0, opt_walk_logical? 0 : FTW_PHYS) < 0) { >- fprintf(stderr, "%s: %s: %s\n", progname, xquote(file), >- strerror(errno)); >- __errors++; >+ snprintf(path, FILENAME_MAX, "%s/%s", file, >+ entry->d_name); >+ >+ if (walk_tree(path) != 1) >+ return 0; >+ } >+ closedir(dir); >+ level--; > } >- return __errors; >+ >+ return 1; > } > > int main(int argc, char *argv[])
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 223840
:
149571
|
149713
|
149829
|
150058