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 311829 Details for
Bug 454987
getcap should not follow symlinks to directories in recursive mode
[?]
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.
[patch]
patch (fix candidate)
libcap-symlinks.patch (text/plain), 2.87 KB, created by
Lukas Kuklinek
on 2008-07-15 14:06:42 UTC
(
hide
)
Description:
patch (fix candidate)
Filename:
MIME Type:
Creator:
Lukas Kuklinek
Created:
2008-07-15 14:06:42 UTC
Size:
2.87 KB
patch
obsolete
>diff -up libcap-2.10/progs/getcap.c.orig libcap-2.10/progs/getcap.c >--- libcap-2.10/progs/getcap.c.orig 2008-01-22 01:16:58.000000000 +0100 >+++ libcap-2.10/progs/getcap.c 2008-07-15 15:44:34.000000000 +0200 >@@ -4,6 +4,9 @@ > * This displays the capabilities of a given file. > */ > >+ >+#define _XOPEN_SOURCE 500 >+ > #include <errno.h> > #include <stdio.h> > #include <string.h> >@@ -13,6 +16,7 @@ > #include <sys/stat.h> > #include <sys/types.h> > #include <sys/capability.h> >+#include <ftw.h> > > static int verbose = 0; > static int recursive = 0; >@@ -27,22 +31,24 @@ static void usage(void) > exit(1); > } > >-static void do_recursive(const char *fname); >- >-static void do_getcap(const char *fname) >+static int do_getcap(const char *fname, const struct stat *stbuf, >+ int tflag, struct FTW* ftwbuf) > { > cap_t cap_d; > char *result; > >+ if (tflag != FTW_F) >+ return 0; >+ > cap_d = cap_get_file(fname); > if (cap_d == NULL) { > if (errno != ENODATA) { >- fprintf(stderr, "Failed to get capabilities of file `%s' (%s)\n", >- fname, strerror(errno)); >+ fprintf(stderr, "Failed to get capabilities of file `%s' (%s)\n", >+ fname, strerror(errno)); > } else if (verbose) { >- printf("%s\n", fname); >+ printf("%s\n", fname); > } >- goto out; >+ return 0; > } > > result = cap_to_text(cap_d, NULL); >@@ -51,45 +57,14 @@ static void do_getcap(const char *fname) > "Failed to get capabilities of human readable format at `%s' (%s)\n", > fname, strerror(errno)); > cap_free(cap_d); >- return; >+ return 0; > } >+ > printf("%s %s\n", fname, result); > cap_free(cap_d); > cap_free(result); > >- out: >- if (recursive) { >- struct stat stbuf; >- >- if (stat(fname, &stbuf)) { >- fprintf(stderr, "Failed to get attribute of file `%s' (%s)\n", >- fname, strerror(errno)); >- } else if (S_ISDIR(stbuf.st_mode)) { >- do_recursive(fname); >- } >- } >-} >- >-static void do_recursive(const char *fname) >-{ >- DIR *dirp; >- struct dirent *dent; >- char buffer[PATH_MAX]; >- >- dirp = opendir(fname); >- if (dirp == NULL) { >- fprintf(stderr, "Failed to open directory `%s' (%s)\n", >- fname, strerror(errno)); >- return; >- } >- >- while ((dent = readdir(dirp)) != NULL) { >- if (!strcmp(dent->d_name, ".") || !strcmp(dent->d_name, "..")) >- continue; >- snprintf(buffer, PATH_MAX, "%s/%s", fname, dent->d_name); >- do_getcap(buffer); >- } >- closedir(dirp); >+ return 0; > } > > int main(int argc, char **argv) >@@ -112,8 +87,19 @@ int main(int argc, char **argv) > if (!argv[optind]) > usage(); > >- for (i=optind; argv[i] != NULL; i++) >- do_getcap(argv[i]); >+ for (i=optind; argv[i] != NULL; i++) { >+ if (recursive) { >+ nftw(argv[i], do_getcap, 20, FTW_PHYS); >+ } >+ else { >+ struct stat stbuf; >+ lstat(argv[i], &stbuf); >+ int tflag = S_ISREG(stbuf.st_mode) ? FTW_F : >+ (S_ISLNK(stbuf.st_mode) ? FTW_SL : FTW_NS); >+ do_getcap(argv[i], &stbuf, tflag, 0); >+ } >+ } > > return 0; > } >+
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 Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 454987
: 311829