9f24f9e262
- add for-next changes, update changelog date * add 0001-smbinfo-Improve-help-usage-and-add-h-option.patch * add 0002-smbinfo-Add-bash-completion-support-for-smbinfo.patch * add 0003-getcifsacl-Add-support-to-accept-more-paths.patch * add 0004-getcifsacl-Fix-usage-message-to-include-multiple-fil.patch * add 0005-smbinfo-add-GETCOMPRESSION-support.patch * add 0006-getcifsacl-Add-support-for-R-recursive-option.patch * add 0007-smbinfo-add-bash-completion-support-for-getcompressi.patch * add 0008-mount.cifs.c-fix-memory-leaks-in-main-func.patch * add 0009-Zero-fill-the-allocated-memory-for-new-struct-cifs_n.patch * add 0010-Zero-fill-the-allocated-memory-for-a-new-ACE.patch OBS-URL: https://build.opensuse.org/request/show/723800 OBS-URL: https://build.opensuse.org/package/show/network:samba:STABLE/cifs-utils?expand=0&rev=172
127 lines
3.0 KiB
Diff
127 lines
3.0 KiB
Diff
From 9beaa8c3c895ca8460d81fb54a6a0de2bb21a277 Mon Sep 17 00:00:00 2001
|
|
From: Kenneth D'souza <kdsouza@redhat.com>
|
|
Date: Wed, 17 Apr 2019 22:49:09 +0530
|
|
Subject: [PATCH] getcifsacl: Add support to accept more paths
|
|
|
|
Accept more than one path on the getcifsacl command line.
|
|
|
|
Signed-off-by: Kenneth D'souza <kdsouza@redhat.com>
|
|
---
|
|
getcifsacl.c | 80 +++++++++++++++++++++++++++++++++---------------------------
|
|
1 file changed, 44 insertions(+), 36 deletions(-)
|
|
|
|
diff --git a/getcifsacl.c b/getcifsacl.c
|
|
index fc78881..556178a 100644
|
|
--- a/getcifsacl.c
|
|
+++ b/getcifsacl.c
|
|
@@ -340,14 +340,52 @@ getcifsacl_usage(const char *prog)
|
|
fprintf(stderr, "\nRefer to getcifsacl(1) manpage for details\n");
|
|
}
|
|
|
|
+static void
|
|
+getcifsacl(const char *filename, bool raw)
|
|
+{
|
|
+ ssize_t attrlen;
|
|
+ size_t bufsize = BUFSIZE;
|
|
+ char *attrval;
|
|
+ int failed = 0;
|
|
+cifsacl:
|
|
+ if (bufsize >= XATTR_SIZE_MAX) {
|
|
+ fprintf(stderr, "buffer to allocate exceeds max size of %d\n",
|
|
+ XATTR_SIZE_MAX);
|
|
+ exit(1);
|
|
+ }
|
|
+
|
|
+ attrval = malloc(bufsize * sizeof(char));
|
|
+ if (!attrval) {
|
|
+ fprintf(stderr, "error allocating memory for attribute value buffer\n");
|
|
+ exit(1);
|
|
+ }
|
|
+
|
|
+ attrlen = getxattr(filename, ATTRNAME, attrval, bufsize);
|
|
+ if (attrlen == -1) {
|
|
+ if (errno == ERANGE) {
|
|
+ free(attrval);
|
|
+ bufsize += BUFSIZE;
|
|
+ goto cifsacl;
|
|
+ } else {
|
|
+ fprintf(stderr, "Failed to getxattr %s: %s\n", filename,
|
|
+ strerror(errno));
|
|
+ failed = -1;
|
|
+ }
|
|
+ }
|
|
+
|
|
+ if (failed == 0) {
|
|
+ printf("# filename: %s\n", filename);
|
|
+ parse_sec_desc((struct cifs_ntsd *)attrval, attrlen, raw);
|
|
+ printf("\n");
|
|
+ }
|
|
+ free(attrval);
|
|
+}
|
|
+
|
|
int
|
|
main(const int argc, char *const argv[])
|
|
{
|
|
int c, ret = 0;
|
|
bool raw = false;
|
|
- ssize_t attrlen;
|
|
- size_t bufsize = BUFSIZE;
|
|
- char *filename, *attrval;
|
|
execname = basename(argv[0]);
|
|
|
|
if (argc < 2) {
|
|
@@ -374,8 +412,7 @@ main(const int argc, char *const argv[])
|
|
printf("you must specify a filename after options.\n");
|
|
printf("Usage: getcifsacl [option] <file_name>\n");
|
|
goto out;
|
|
- } else
|
|
- filename = argv[optind];
|
|
+ }
|
|
|
|
if (!raw && !plugin_loaded) {
|
|
ret = init_plugin(&plugin_handle);
|
|
@@ -386,38 +423,9 @@ main(const int argc, char *const argv[])
|
|
plugin_loaded = true;
|
|
}
|
|
|
|
-cifsacl:
|
|
- if (bufsize >= XATTR_SIZE_MAX) {
|
|
- printf("buffer to allocate exceeds max size of %d\n",
|
|
- XATTR_SIZE_MAX);
|
|
- ret = -1;
|
|
- goto out;
|
|
- }
|
|
-
|
|
- attrval = malloc(bufsize * sizeof(char));
|
|
- if (!attrval) {
|
|
- printf("error allocating memory for attribute value buffer\n");
|
|
- ret = -1;
|
|
- goto out;
|
|
- }
|
|
-
|
|
- attrlen = getxattr(filename, ATTRNAME, attrval, bufsize);
|
|
- if (attrlen == -1) {
|
|
- if (errno == ERANGE) {
|
|
- free(attrval);
|
|
- bufsize += BUFSIZE;
|
|
- goto cifsacl;
|
|
- } else {
|
|
- fprintf(stderr, "getxattr failed on %s: %s\n", filename, strerror(errno) );
|
|
- free(attrval);
|
|
- ret = -1;
|
|
- goto out;
|
|
- }
|
|
- }
|
|
-
|
|
- parse_sec_desc((struct cifs_ntsd *)attrval, attrlen, raw);
|
|
+ for(; optind < argc; optind++)
|
|
+ getcifsacl(argv[optind], raw);
|
|
|
|
- free(attrval);
|
|
out:
|
|
if (plugin_loaded)
|
|
exit_plugin(plugin_handle);
|
|
--
|
|
2.16.4
|
|
|