Accepting request 725640 from network:samba:STABLE
Automatic submission by obs-autosubmit OBS-URL: https://build.opensuse.org/request/show/725640 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/cifs-utils?expand=0&rev=60
This commit is contained in:
commit
b89be90307
106
0001-smbinfo-Improve-help-usage-and-add-h-option.patch
Normal file
106
0001-smbinfo-Improve-help-usage-and-add-h-option.patch
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
From 12c2f088fa3d666fc5aa48a700e740523d8d2023 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Kenneth D'souza <kdsouza@redhat.com>
|
||||||
|
Date: Wed, 17 Apr 2019 15:36:46 +0530
|
||||||
|
Subject: [PATCH] smbinfo: Improve help usage and add -h option.
|
||||||
|
|
||||||
|
Call usage only for -h case. This avoids cluttering the screen with long
|
||||||
|
help output.
|
||||||
|
As we are adding more options to the utility, the end error is just hidden.
|
||||||
|
Call short_usage wherever necessary.
|
||||||
|
|
||||||
|
Signed-off-by: Kenneth D'souza <kdsouza@redhat.com>
|
||||||
|
---
|
||||||
|
smbinfo.c | 27 ++++++++++++++++++++++-----
|
||||||
|
smbinfo.rst | 5 ++++-
|
||||||
|
2 files changed, 26 insertions(+), 6 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/smbinfo.c b/smbinfo.c
|
||||||
|
index 4bc503a..6e258c2 100644
|
||||||
|
--- a/smbinfo.c
|
||||||
|
+++ b/smbinfo.c
|
||||||
|
@@ -64,6 +64,8 @@ usage(char *name)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Usage: %s [-V] <command> <file>\n"
|
||||||
|
"-V for verbose output\n"
|
||||||
|
+ "-h display this help text\n"
|
||||||
|
+ "-v print smbinfo version\n"
|
||||||
|
"Commands are\n"
|
||||||
|
" fileaccessinfo:\n"
|
||||||
|
" Prints FileAccessInfo for a cifs file.\n"
|
||||||
|
@@ -97,6 +99,14 @@ usage(char *name)
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
+static void
|
||||||
|
+short_usage(char *name)
|
||||||
|
+{
|
||||||
|
+ fprintf(stderr, "Usage: %s [-v] [-V] <command> <file>\n"
|
||||||
|
+ "Try 'smbinfo -h' for more information.\n", name);
|
||||||
|
+ exit(1);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
static void
|
||||||
|
win_to_timeval(uint64_t smb2_time, struct timeval *tv)
|
||||||
|
{
|
||||||
|
@@ -1075,7 +1085,11 @@ int main(int argc, char *argv[])
|
||||||
|
int c;
|
||||||
|
int f;
|
||||||
|
|
||||||
|
- while ((c = getopt_long(argc, argv, "vV", NULL, NULL)) != -1) {
|
||||||
|
+ if (argc < 2) {
|
||||||
|
+ short_usage(argv[0]);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ while ((c = getopt_long(argc, argv, "vVh", NULL, NULL)) != -1) {
|
||||||
|
switch (c) {
|
||||||
|
case 'v':
|
||||||
|
printf("smbinfo version %s\n", VERSION);
|
||||||
|
@@ -1083,15 +1097,18 @@ int main(int argc, char *argv[])
|
||||||
|
case 'V':
|
||||||
|
verbose = 1;
|
||||||
|
break;
|
||||||
|
- default:
|
||||||
|
+ case 'h':
|
||||||
|
usage(argv[0]);
|
||||||
|
+ break;
|
||||||
|
+ default:
|
||||||
|
+ short_usage(argv[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- if (optind >= argc - 1)
|
||||||
|
- usage(argv[0]);
|
||||||
|
+ if (optind >= argc -1)
|
||||||
|
+ short_usage(argv[0]);
|
||||||
|
|
||||||
|
- if ((f = open(argv[optind + 1], O_RDONLY)) < 0) {
|
||||||
|
+ if ((f = open(argv[optind + 1 ], O_RDONLY)) < 0) {
|
||||||
|
fprintf(stderr, "Failed to open %s\n", argv[optind + 1]);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
diff --git a/smbinfo.rst b/smbinfo.rst
|
||||||
|
index 0c96050..be4c829 100644
|
||||||
|
--- a/smbinfo.rst
|
||||||
|
+++ b/smbinfo.rst
|
||||||
|
@@ -11,7 +11,7 @@ Userspace helper to display SMB-specific file information for the Linux SMB clie
|
||||||
|
SYNOPSIS
|
||||||
|
********
|
||||||
|
|
||||||
|
- smbinfo [-v] [-V] {command} {file system object}
|
||||||
|
+ smbinfo [-v] [-h] [-V] {command} {file system object}
|
||||||
|
|
||||||
|
***********
|
||||||
|
DESCRIPTION
|
||||||
|
@@ -38,6 +38,9 @@ OPTIONS
|
||||||
|
-V
|
||||||
|
Verbose output.
|
||||||
|
|
||||||
|
+-h
|
||||||
|
+ Print help explaining the command line options.
|
||||||
|
+
|
||||||
|
*******
|
||||||
|
COMMAND
|
||||||
|
*******
|
||||||
|
--
|
||||||
|
2.16.4
|
||||||
|
|
65
0002-smbinfo-Add-bash-completion-support-for-smbinfo.patch
Normal file
65
0002-smbinfo-Add-bash-completion-support-for-smbinfo.patch
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
From dfe497f9f51983147a7caa69f62bb6648ea507ec Mon Sep 17 00:00:00 2001
|
||||||
|
From: Kenneth D'souza <kdsouza@redhat.com>
|
||||||
|
Date: Wed, 17 Apr 2019 16:57:05 +0530
|
||||||
|
Subject: [PATCH] smbinfo: Add bash completion support for smbinfo.
|
||||||
|
|
||||||
|
This help us better populate options using <tab> <tab>.
|
||||||
|
|
||||||
|
Signed-off-by: Kenneth D'souza <kdsouza@redhat.com>
|
||||||
|
Signed-off-by: Pavel Shilovsky <pshilov@microsoft.com>
|
||||||
|
---
|
||||||
|
bash-completion/smbinfo | 42 ++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
1 file changed, 42 insertions(+)
|
||||||
|
create mode 100644 bash-completion/smbinfo
|
||||||
|
|
||||||
|
diff --git a/bash-completion/smbinfo b/bash-completion/smbinfo
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000..ad5d34d
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/bash-completion/smbinfo
|
||||||
|
@@ -0,0 +1,42 @@
|
||||||
|
+# bash completion for smbinfo -*- shell-script -*-
|
||||||
|
+smb_info()
|
||||||
|
+{
|
||||||
|
+ local cur prev OPTS
|
||||||
|
+ COMPREPLY=()
|
||||||
|
+ cur="${COMP_WORDS[COMP_CWORD]}"
|
||||||
|
+ prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||||
|
+ OPTS="fileaccessinfo
|
||||||
|
+ filealigninfo
|
||||||
|
+ fileallinfo
|
||||||
|
+ filebasicinfo
|
||||||
|
+ fileeainfo
|
||||||
|
+ filefsfullsizeinfo
|
||||||
|
+ fileinternalinfo
|
||||||
|
+ filemodeinfo
|
||||||
|
+ filepositioninfo
|
||||||
|
+ filestandardinfo
|
||||||
|
+ fsctl-getobjid
|
||||||
|
+ list-snapshots
|
||||||
|
+ quota
|
||||||
|
+ secdesc"
|
||||||
|
+ case $prev in
|
||||||
|
+ '-v'|'-h')
|
||||||
|
+ return 0
|
||||||
|
+ ;;
|
||||||
|
+ 'fileaccessinfo'|'filealigninfo'|'fileallinfo'|'filebasicinfo'|'fileeainfo'|'filefsfullsizeinfo'|\
|
||||||
|
+ 'fileinternalinfo'|'filemodeinfo'|'filepositioninfo'|'filestandardinfo'|'fsctl-getobjid'|\
|
||||||
|
+ 'list-snapshots'|'quota'|'secdesc')
|
||||||
|
+ local IFS=$'\n'
|
||||||
|
+ compopt -o filenames
|
||||||
|
+ COMPREPLY=( $(compgen -f -o dirnames -- ${cur:-""}) )
|
||||||
|
+ return 0
|
||||||
|
+ ;;
|
||||||
|
+ '-V'|*'smbinfo')
|
||||||
|
+ COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
|
||||||
|
+ return 0
|
||||||
|
+ ;;
|
||||||
|
+ esac
|
||||||
|
+
|
||||||
|
+ return 0
|
||||||
|
+}
|
||||||
|
+complete -F smb_info smbinfo
|
||||||
|
--
|
||||||
|
2.16.4
|
||||||
|
|
126
0003-getcifsacl-Add-support-to-accept-more-paths.patch
Normal file
126
0003-getcifsacl-Add-support-to-accept-more-paths.patch
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
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
|
||||||
|
|
@ -0,0 +1,35 @@
|
|||||||
|
From f2955af017f604003e3c8c3efe0fb0fb85584cea Mon Sep 17 00:00:00 2001
|
||||||
|
From: Pavel Shilovsky <pshilov@microsoft.com>
|
||||||
|
Date: Thu, 18 Apr 2019 12:32:02 -0700
|
||||||
|
Subject: [PATCH] getcifsacl: Fix usage message to include multiple files
|
||||||
|
|
||||||
|
Signed-off-by: Pavel Shilovsky <pshilov@microsoft.com>
|
||||||
|
---
|
||||||
|
getcifsacl.c | 4 ++--
|
||||||
|
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/getcifsacl.c b/getcifsacl.c
|
||||||
|
index 556178a..bea81ee 100644
|
||||||
|
--- a/getcifsacl.c
|
||||||
|
+++ b/getcifsacl.c
|
||||||
|
@@ -330,7 +330,7 @@ getcifsacl_usage(const char *prog)
|
||||||
|
fprintf(stderr,
|
||||||
|
"%s: Display CIFS/NTFS ACL in a security descriptor of a file object\n",
|
||||||
|
prog);
|
||||||
|
- fprintf(stderr, "Usage: %s [option] <file_name>\n", prog);
|
||||||
|
+ fprintf(stderr, "Usage: %s [option] <file_name1> [<file_name2>,<file_name3>,...]\n", prog);
|
||||||
|
fprintf(stderr, "Valid options:\n");
|
||||||
|
fprintf(stderr, "\t-h Display this help text\n");
|
||||||
|
fprintf(stderr, "\n");
|
||||||
|
@@ -410,7 +410,7 @@ main(const int argc, char *const argv[])
|
||||||
|
|
||||||
|
if (optind >= argc) {
|
||||||
|
printf("you must specify a filename after options.\n");
|
||||||
|
- printf("Usage: getcifsacl [option] <file_name>\n");
|
||||||
|
+ printf("Usage: getcifsacl [option] <file_name1> [<file_name2>,<file_name3>,...]\n");
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
--
|
||||||
|
2.16.4
|
||||||
|
|
100
0005-smbinfo-add-GETCOMPRESSION-support.patch
Normal file
100
0005-smbinfo-add-GETCOMPRESSION-support.patch
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
From 1e4fca25948d52fc29410963663f3af72275bcb6 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Ronnie Sahlberg <lsahlber@redhat.com>
|
||||||
|
Date: Thu, 11 Apr 2019 12:23:06 +1000
|
||||||
|
Subject: [PATCH] smbinfo: add GETCOMPRESSION support
|
||||||
|
|
||||||
|
Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
|
||||||
|
---
|
||||||
|
smbinfo.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
smbinfo.rst | 2 ++
|
||||||
|
2 files changed, 50 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/smbinfo.c b/smbinfo.c
|
||||||
|
index 6e258c2..b4d497b 100644
|
||||||
|
--- a/smbinfo.c
|
||||||
|
+++ b/smbinfo.c
|
||||||
|
@@ -89,6 +89,8 @@ usage(char *name)
|
||||||
|
" Prints FileStandardInfo for a cifs file.\n"
|
||||||
|
" fsctl-getobjid:\n"
|
||||||
|
" Prints the objectid of the file and GUID of the underlying volume.\n"
|
||||||
|
+ " getcompression:\n"
|
||||||
|
+ " Prints the compression setting for the file.\n"
|
||||||
|
" list-snapshots:\n"
|
||||||
|
" List the previous versions of the volume that backs this file.\n"
|
||||||
|
" quota:\n"
|
||||||
|
@@ -252,6 +254,50 @@ fsctlgetobjid(int f)
|
||||||
|
free(qi);
|
||||||
|
}
|
||||||
|
|
||||||
|
+static void
|
||||||
|
+print_getcompression(uint8_t *sd)
|
||||||
|
+{
|
||||||
|
+ uint16_t u16;
|
||||||
|
+
|
||||||
|
+ memcpy(&u16, &sd[0], 2);
|
||||||
|
+ u16 = le16toh(u16);
|
||||||
|
+
|
||||||
|
+ printf("Compression: ");
|
||||||
|
+ switch (u16) {
|
||||||
|
+ case 0:
|
||||||
|
+ printf("(0) NONE\n");
|
||||||
|
+ break;
|
||||||
|
+ case 2:
|
||||||
|
+ printf("(2) LZNT1\n");
|
||||||
|
+ break;
|
||||||
|
+ default:
|
||||||
|
+ printf("(%d) UNKNOWN\n", u16);
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static void
|
||||||
|
+getcompression(int f)
|
||||||
|
+{
|
||||||
|
+ struct smb_query_info *qi;
|
||||||
|
+
|
||||||
|
+ qi = malloc(sizeof(struct smb_query_info) + 2);
|
||||||
|
+ memset(qi, 0, sizeof(qi) + 2);
|
||||||
|
+ qi->info_type = 0x9003c;
|
||||||
|
+ qi->file_info_class = 0;
|
||||||
|
+ qi->additional_information = 0;
|
||||||
|
+ qi->input_buffer_length = 2;
|
||||||
|
+ qi->flags = PASSTHRU_FSCTL;
|
||||||
|
+
|
||||||
|
+ if (ioctl(f, CIFS_QUERY_INFO, qi) < 0) {
|
||||||
|
+ fprintf(stderr, "ioctl failed with %s\n", strerror(errno));
|
||||||
|
+ exit(1);
|
||||||
|
+ }
|
||||||
|
+ print_getcompression((uint8_t *)(&qi[1]));
|
||||||
|
+
|
||||||
|
+ free(qi);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
static void
|
||||||
|
print_fileaccessinfo(uint8_t *sd, int type)
|
||||||
|
{
|
||||||
|
@@ -1135,6 +1181,8 @@ int main(int argc, char *argv[])
|
||||||
|
filestandardinfo(f);
|
||||||
|
else if (!strcmp(argv[optind], "fsctl-getobjid"))
|
||||||
|
fsctlgetobjid(f);
|
||||||
|
+ else if (!strcmp(argv[optind], "getcompression"))
|
||||||
|
+ getcompression(f);
|
||||||
|
else if (!strcmp(argv[optind], "list-snapshots"))
|
||||||
|
list_snapshots(f);
|
||||||
|
else if (!strcmp(argv[optind], "quota"))
|
||||||
|
diff --git a/smbinfo.rst b/smbinfo.rst
|
||||||
|
index be4c829..500ce0e 100644
|
||||||
|
--- a/smbinfo.rst
|
||||||
|
+++ b/smbinfo.rst
|
||||||
|
@@ -67,6 +67,8 @@ COMMAND
|
||||||
|
|
||||||
|
`fsctl-getobjid`: Prints the ObjectID
|
||||||
|
|
||||||
|
+`getcompression`: Prints the compression setting for the file.
|
||||||
|
+
|
||||||
|
`list-snapshots`: Lists the previous versions of the volume that backs this file
|
||||||
|
|
||||||
|
`quota`: Print the quota for the volume in the form
|
||||||
|
--
|
||||||
|
2.16.4
|
||||||
|
|
123
0006-getcifsacl-Add-support-for-R-recursive-option.patch
Normal file
123
0006-getcifsacl-Add-support-for-R-recursive-option.patch
Normal file
@ -0,0 +1,123 @@
|
|||||||
|
From 43f389bb3759ea49efb705acd2d314fd91a7bc57 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Kenneth D'souza <kdsouza@redhat.com>
|
||||||
|
Date: Mon, 22 Apr 2019 11:23:41 +0530
|
||||||
|
Subject: [PATCH] getcifsacl: Add support for -R(recursive) option.
|
||||||
|
|
||||||
|
Add support for -R option so we can list the ACLs of all files and
|
||||||
|
directories recursively.
|
||||||
|
|
||||||
|
Signed-off-by: Kenneth D'souza <kdsouza@redhat.com>
|
||||||
|
---
|
||||||
|
getcifsacl.c | 32 +++++++++++++++++++++++++++-----
|
||||||
|
getcifsacl.rst.in | 3 +++
|
||||||
|
2 files changed, 30 insertions(+), 5 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/getcifsacl.c b/getcifsacl.c
|
||||||
|
index bea81ee..d58b769 100644
|
||||||
|
--- a/getcifsacl.c
|
||||||
|
+++ b/getcifsacl.c
|
||||||
|
@@ -37,10 +37,12 @@
|
||||||
|
#include <sys/xattr.h>
|
||||||
|
#include "cifsacl.h"
|
||||||
|
#include "idmap_plugin.h"
|
||||||
|
+#include <ftw.h>
|
||||||
|
|
||||||
|
static void *plugin_handle;
|
||||||
|
static bool plugin_loaded;
|
||||||
|
static char *execname;
|
||||||
|
+static bool raw = false;
|
||||||
|
|
||||||
|
static void
|
||||||
|
print_each_ace_mask(uint32_t mask)
|
||||||
|
@@ -336,12 +338,14 @@ getcifsacl_usage(const char *prog)
|
||||||
|
fprintf(stderr, "\n");
|
||||||
|
fprintf(stderr, "\t-v Version of the program\n");
|
||||||
|
fprintf(stderr, "\n");
|
||||||
|
+ fprintf(stderr, "\t-R recurse into subdirectories\n");
|
||||||
|
+ fprintf(stderr, "\n");
|
||||||
|
fprintf(stderr, "\t-r Display raw values of the ACE fields\n");
|
||||||
|
fprintf(stderr, "\nRefer to getcifsacl(1) manpage for details\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
-getcifsacl(const char *filename, bool raw)
|
||||||
|
+getcifsacl(const char *filename)
|
||||||
|
{
|
||||||
|
ssize_t attrlen;
|
||||||
|
size_t bufsize = BUFSIZE;
|
||||||
|
@@ -381,12 +385,21 @@ cifsacl:
|
||||||
|
free(attrval);
|
||||||
|
}
|
||||||
|
|
||||||
|
+static int recursive(const char *filename, const struct stat *sb, int tflag, struct FTW *ftwbuf)
|
||||||
|
+{
|
||||||
|
+ (void)sb;
|
||||||
|
+ (void)tflag;
|
||||||
|
+ (void)ftwbuf;
|
||||||
|
+ getcifsacl(filename);
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
int
|
||||||
|
main(const int argc, char *const argv[])
|
||||||
|
{
|
||||||
|
int c, ret = 0;
|
||||||
|
- bool raw = false;
|
||||||
|
execname = basename(argv[0]);
|
||||||
|
+ int do_recursive = 0;
|
||||||
|
|
||||||
|
if (argc < 2) {
|
||||||
|
fprintf(stderr, "%s: you must specify a filename.\n", execname);
|
||||||
|
@@ -394,7 +407,7 @@ main(const int argc, char *const argv[])
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
- while ((c = getopt_long(argc, argv, "rhv", NULL, NULL)) != -1) {
|
||||||
|
+ while ((c = getopt_long(argc, argv, "Rrhv", NULL, NULL)) != -1) {
|
||||||
|
switch (c) {
|
||||||
|
case 'v':
|
||||||
|
printf("Version: %s\n", VERSION);
|
||||||
|
@@ -402,6 +415,9 @@ main(const int argc, char *const argv[])
|
||||||
|
case 'r':
|
||||||
|
raw = true;
|
||||||
|
break;
|
||||||
|
+ case 'R':
|
||||||
|
+ do_recursive = 1;
|
||||||
|
+ break;
|
||||||
|
default:
|
||||||
|
getcifsacl_usage(execname);
|
||||||
|
goto out;
|
||||||
|
@@ -423,8 +439,14 @@ main(const int argc, char *const argv[])
|
||||||
|
plugin_loaded = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
- for(; optind < argc; optind++)
|
||||||
|
- getcifsacl(argv[optind], raw);
|
||||||
|
+ for(; optind < argc; optind++) {
|
||||||
|
+ if(do_recursive) {
|
||||||
|
+ if (nftw(argv[optind], recursive, 20, 0) == -1)
|
||||||
|
+ fprintf(stderr, "Invalid filename %s: %s\n", argv[optind], strerror(errno));
|
||||||
|
+ }
|
||||||
|
+ else
|
||||||
|
+ getcifsacl(argv[optind]);
|
||||||
|
+ }
|
||||||
|
|
||||||
|
out:
|
||||||
|
if (plugin_loaded)
|
||||||
|
diff --git a/getcifsacl.rst.in b/getcifsacl.rst.in
|
||||||
|
index 21a10cd..ffde968 100644
|
||||||
|
--- a/getcifsacl.rst.in
|
||||||
|
+++ b/getcifsacl.rst.in
|
||||||
|
@@ -43,6 +43,9 @@ OPTIONS
|
||||||
|
flags are displayed in hexadecimal format, a SID is not mapped to a
|
||||||
|
name.
|
||||||
|
|
||||||
|
+-R
|
||||||
|
+ List the ACLs of all files and directories recursively.
|
||||||
|
+
|
||||||
|
*****
|
||||||
|
NOTES
|
||||||
|
*****
|
||||||
|
--
|
||||||
|
2.16.4
|
||||||
|
|
@ -0,0 +1,34 @@
|
|||||||
|
From 13c370424575d864544bfb4535832dfcffa91e82 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Pavel Shilovsky <pshilov@microsoft.com>
|
||||||
|
Date: Tue, 7 May 2019 15:52:30 -0700
|
||||||
|
Subject: [PATCH] smbinfo: add bash completion support for getcompression
|
||||||
|
|
||||||
|
Signed-off-by: Pavel Shilovsky <pshilov@microsoft.com>
|
||||||
|
---
|
||||||
|
bash-completion/smbinfo | 3 ++-
|
||||||
|
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/bash-completion/smbinfo b/bash-completion/smbinfo
|
||||||
|
index ad5d34d..282db55 100644
|
||||||
|
--- a/bash-completion/smbinfo
|
||||||
|
+++ b/bash-completion/smbinfo
|
||||||
|
@@ -16,6 +16,7 @@ smb_info()
|
||||||
|
filepositioninfo
|
||||||
|
filestandardinfo
|
||||||
|
fsctl-getobjid
|
||||||
|
+ getcompression
|
||||||
|
list-snapshots
|
||||||
|
quota
|
||||||
|
secdesc"
|
||||||
|
@@ -25,7 +26,7 @@ smb_info()
|
||||||
|
;;
|
||||||
|
'fileaccessinfo'|'filealigninfo'|'fileallinfo'|'filebasicinfo'|'fileeainfo'|'filefsfullsizeinfo'|\
|
||||||
|
'fileinternalinfo'|'filemodeinfo'|'filepositioninfo'|'filestandardinfo'|'fsctl-getobjid'|\
|
||||||
|
- 'list-snapshots'|'quota'|'secdesc')
|
||||||
|
+ 'getcompression'|'list-snapshots'|'quota'|'secdesc')
|
||||||
|
local IFS=$'\n'
|
||||||
|
compopt -o filenames
|
||||||
|
COMPREPLY=( $(compgen -f -o dirnames -- ${cur:-""}) )
|
||||||
|
--
|
||||||
|
2.16.4
|
||||||
|
|
73
0008-mount.cifs.c-fix-memory-leaks-in-main-func.patch
Normal file
73
0008-mount.cifs.c-fix-memory-leaks-in-main-func.patch
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
From bf7f48f4c7dcee623bd92b2e7a6ffd97a64a1138 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Jiawen Liu <liujiawen10@huawei.com>
|
||||||
|
Date: Tue, 6 Aug 2019 10:35:29 +0800
|
||||||
|
Subject: [PATCH] mount.cifs.c: fix memory leaks in main func
|
||||||
|
MIME-Version: 1.0
|
||||||
|
Content-Type: text/plain; charset=UTF-8
|
||||||
|
Content-Transfer-Encoding: 8bit
|
||||||
|
|
||||||
|
In mount.cifs module, orgoptions and mountpoint in the main func
|
||||||
|
point to the memory allocated by func realpath and strndup respectively.
|
||||||
|
However, they are not freed before the main func returns so that the
|
||||||
|
memory leaks occurred.
|
||||||
|
|
||||||
|
The memory leak problem is reported by LeakSanitizer tool.
|
||||||
|
LeakSanitizer url: "https://github.com/google/sanitizers"
|
||||||
|
|
||||||
|
Here I free the pointers orgoptions and mountpoint before main
|
||||||
|
func returns.
|
||||||
|
|
||||||
|
Fixes:7549ad5e7126 ("memory leaks: caused by func realpath and strndup")
|
||||||
|
Signed-off-by: Jiawen Liu <liujiawen10@huawei.com>
|
||||||
|
Reported-by: Jin Du <dujin1@huawei.com>
|
||||||
|
Reviewed-by: Saisai Zhang <zhangsaisai@huawei.com>
|
||||||
|
Reviewed-by: Aurélien Aptel <aaptel@suse.com>
|
||||||
|
---
|
||||||
|
mount.cifs.c | 10 +++++++++-
|
||||||
|
1 file changed, 9 insertions(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/mount.cifs.c b/mount.cifs.c
|
||||||
|
index b3235e4..7748d54 100644
|
||||||
|
--- a/mount.cifs.c
|
||||||
|
+++ b/mount.cifs.c
|
||||||
|
@@ -1942,6 +1942,9 @@ restore_privs:
|
||||||
|
gid_t __attribute__((unused)) gignore = setfsgid(oldfsgid);
|
||||||
|
}
|
||||||
|
|
||||||
|
+ if (rc) {
|
||||||
|
+ free(*mountpointp);
|
||||||
|
+ }
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -2044,8 +2047,10 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
|
/* chdir into mountpoint as soon as possible */
|
||||||
|
rc = acquire_mountpoint(&mountpoint);
|
||||||
|
- if (rc)
|
||||||
|
+ if (rc) {
|
||||||
|
+ free(orgoptions);
|
||||||
|
return rc;
|
||||||
|
+ }
|
||||||
|
|
||||||
|
/*
|
||||||
|
* mount.cifs does privilege separation. Most of the code to handle
|
||||||
|
@@ -2064,6 +2069,8 @@ int main(int argc, char **argv)
|
||||||
|
/* child */
|
||||||
|
rc = assemble_mountinfo(parsed_info, thisprogram, mountpoint,
|
||||||
|
orig_dev, orgoptions);
|
||||||
|
+ free(orgoptions);
|
||||||
|
+ free(mountpoint);
|
||||||
|
return rc;
|
||||||
|
} else {
|
||||||
|
/* parent */
|
||||||
|
@@ -2209,5 +2216,6 @@ mount_exit:
|
||||||
|
}
|
||||||
|
free(options);
|
||||||
|
free(orgoptions);
|
||||||
|
+ free(mountpoint);
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.16.4
|
||||||
|
|
@ -0,0 +1,27 @@
|
|||||||
|
From 5a468f3dcbea4bfbc380a3f86466b8e33bc40570 Mon Sep 17 00:00:00 2001
|
||||||
|
From: misku <miskuu@gmail.com>
|
||||||
|
Date: Wed, 31 Jul 2019 13:12:24 +0200
|
||||||
|
Subject: [PATCH] Zero fill the allocated memory for new `struct cifs_ntsd`
|
||||||
|
|
||||||
|
Fixes a bug where `sacloffset` may not be set at all later on and therefore it
|
||||||
|
can contain the original memory contents == trash.
|
||||||
|
---
|
||||||
|
setcifsacl.c | 2 +-
|
||||||
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/setcifsacl.c b/setcifsacl.c
|
||||||
|
index da1d742..f3d0189 100644
|
||||||
|
--- a/setcifsacl.c
|
||||||
|
+++ b/setcifsacl.c
|
||||||
|
@@ -206,7 +206,7 @@ alloc_sec_desc(struct cifs_ntsd *pntsd, struct cifs_ntsd **npntsd,
|
||||||
|
acessize = aces * sizeof(struct cifs_ace);
|
||||||
|
bufsize = size + acessize;
|
||||||
|
|
||||||
|
- *npntsd = malloc(bufsize);
|
||||||
|
+ *npntsd = calloc(1, bufsize);
|
||||||
|
if (!*npntsd) {
|
||||||
|
printf("%s: Memory allocation failure", __func__);
|
||||||
|
return errno;
|
||||||
|
--
|
||||||
|
2.16.4
|
||||||
|
|
29
0010-Zero-fill-the-allocated-memory-for-a-new-ACE.patch
Normal file
29
0010-Zero-fill-the-allocated-memory-for-a-new-ACE.patch
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
From cb3dc2fe88f6179011acbafaaed025c5bdc96131 Mon Sep 17 00:00:00 2001
|
||||||
|
From: misku <miskuu@gmail.com>
|
||||||
|
Date: Wed, 31 Jul 2019 13:11:18 +0200
|
||||||
|
Subject: [PATCH] Zero fill the allocated memory for a new ACE
|
||||||
|
|
||||||
|
Fixes a bug inside a call to `verify_ace_flag`. When a flag string (char*)
|
||||||
|
passed as a first parameter is "0x0", the final flag value (the second
|
||||||
|
parameter - the value of a pointer to uint8_t) is not modified at all
|
||||||
|
and contains the original memory contents == trash.
|
||||||
|
---
|
||||||
|
setcifsacl.c | 2 +-
|
||||||
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/setcifsacl.c b/setcifsacl.c
|
||||||
|
index 1b98c37..da1d742 100644
|
||||||
|
--- a/setcifsacl.c
|
||||||
|
+++ b/setcifsacl.c
|
||||||
|
@@ -672,7 +672,7 @@ build_cmdline_aces(char **arrptr, int numcaces)
|
||||||
|
goto build_cmdline_aces_ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
- cacesptr[i] = malloc(sizeof(struct cifs_ace));
|
||||||
|
+ cacesptr[i] = calloc(1, sizeof(struct cifs_ace));
|
||||||
|
if (!cacesptr[i]) {
|
||||||
|
printf("%s: ACE alloc error %d\n", __func__, errno);
|
||||||
|
goto build_cmdline_aces_ret;
|
||||||
|
--
|
||||||
|
2.16.4
|
||||||
|
|
@ -1,13 +1,23 @@
|
|||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Wed Apr 10 11:07:07 UTC 2019 - Aurelien Aptel <aaptel@suse.com>
|
Thu Aug 15 16:50:29 UTC 2019 - Aurelien Aptel <aaptel@suse.com>
|
||||||
|
|
||||||
- Update to cifs-utils 6.9; (bsc#1132087).
|
- Update to cifs-utils 6.9; (bsc#1132087); (bsc#1136031).
|
||||||
* adds fixes for Azure
|
* adds fixes for Azure
|
||||||
* new smbinfo utility
|
* new smbinfo utility
|
||||||
* remove cifs-utils-6.8.tar.bz2
|
* remove cifs-utils-6.8.tar.bz2
|
||||||
* remove cifs-utils-6.8.tar.bz2.asc
|
* remove cifs-utils-6.8.tar.bz2.asc
|
||||||
* add cifs-utils-6.9.tar.bz2
|
* add cifs-utils-6.9.tar.bz2
|
||||||
* add cifs-utils-6.9.tar.bz2.asc
|
* add cifs-utils-6.9.tar.bz2.asc
|
||||||
|
* 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
|
||||||
- Remove backports that are already in 6.9; (fate#325270); (bsc#1130528);
|
- Remove backports that are already in 6.9; (fate#325270); (bsc#1130528);
|
||||||
* remove 0001-docs-cleanup-rst-formating.patch
|
* remove 0001-docs-cleanup-rst-formating.patch
|
||||||
* remove 0002-mount.cifs.rst-document-new-no-handlecache-mount-opt.patch
|
* remove 0002-mount.cifs.rst-document-new-no-handlecache-mount-opt.patch
|
||||||
@ -21,6 +31,7 @@ Wed Apr 10 11:07:07 UTC 2019 - Aurelien Aptel <aaptel@suse.com>
|
|||||||
* remove 0010-mount.cifs.rst-document-vers-3.02-mount-option.patch
|
* remove 0010-mount.cifs.rst-document-vers-3.02-mount-option.patch
|
||||||
* remove allow-dns-resolver-key-to-expire.patch
|
* remove allow-dns-resolver-key-to-expire.patch
|
||||||
* remove suse-document-new-vers-default-SMB2.1.patch
|
* remove suse-document-new-vers-default-SMB2.1.patch
|
||||||
|
- Remove dependency workaround regarding python2/python3
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Tue Mar 12 13:39:46 UTC 2019 - palcantara@suse.de
|
Tue Mar 12 13:39:46 UTC 2019 - palcantara@suse.de
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
# license that conforms to the Open Source Definition (Version 1.9)
|
# license that conforms to the Open Source Definition (Version 1.9)
|
||||||
# published by the Open Source Initiative.
|
# published by the Open Source Initiative.
|
||||||
|
|
||||||
# Please submit bugfixes or comments via http://bugs.opensuse.org/
|
# Please submit bugfixes or comments via https://bugs.opensuse.org/
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
||||||
@ -32,6 +32,17 @@ Source6: cifs-utils.keyring
|
|||||||
Source100: README.cifstab.migration
|
Source100: README.cifstab.migration
|
||||||
Source1: cifs.init
|
Source1: cifs.init
|
||||||
|
|
||||||
|
Patch0: 0001-smbinfo-Improve-help-usage-and-add-h-option.patch
|
||||||
|
Patch1: 0002-smbinfo-Add-bash-completion-support-for-smbinfo.patch
|
||||||
|
Patch2: 0003-getcifsacl-Add-support-to-accept-more-paths.patch
|
||||||
|
Patch3: 0004-getcifsacl-Fix-usage-message-to-include-multiple-fil.patch
|
||||||
|
Patch4: 0005-smbinfo-add-GETCOMPRESSION-support.patch
|
||||||
|
Patch5: 0006-getcifsacl-Add-support-for-R-recursive-option.patch
|
||||||
|
Patch6: 0007-smbinfo-add-bash-completion-support-for-getcompressi.patch
|
||||||
|
Patch7: 0008-mount.cifs.c-fix-memory-leaks-in-main-func.patch
|
||||||
|
Patch8: 0009-Zero-fill-the-allocated-memory-for-new-struct-cifs_n.patch
|
||||||
|
Patch9: 0010-Zero-fill-the-allocated-memory-for-a-new-ACE.patch
|
||||||
|
|
||||||
# cifs-utils 6.8 switched to python for man page generation
|
# cifs-utils 6.8 switched to python for man page generation
|
||||||
# we need to require either py2 or py3 package
|
# we need to require either py2 or py3 package
|
||||||
# some products do not have a py2/py3 versions
|
# some products do not have a py2/py3 versions
|
||||||
@ -72,11 +83,6 @@ BuildRequires: fdupes
|
|||||||
BuildRequires: libwbclient-devel
|
BuildRequires: libwbclient-devel
|
||||||
BuildRequires: pam-devel
|
BuildRequires: pam-devel
|
||||||
BuildRequires: pkg-config
|
BuildRequires: pkg-config
|
||||||
%if 0%{?suse_version} >= 1500 || 0%{?sle_version} >= 150000
|
|
||||||
BuildRequires: (samba-libs-python3 if samba-libs >= 4.9.3)
|
|
||||||
%else
|
|
||||||
BuildRequires: samba-libs-python3
|
|
||||||
%endif
|
|
||||||
Requires: keyutils
|
Requires: keyutils
|
||||||
%if ! %{defined _rundir}
|
%if ! %{defined _rundir}
|
||||||
%define _rundir %{_localstatedir}/run
|
%define _rundir %{_localstatedir}/run
|
||||||
@ -112,6 +118,16 @@ provide these credentials to the kernel automatically at login.
|
|||||||
%prep
|
%prep
|
||||||
%setup -q
|
%setup -q
|
||||||
cp -a ${RPM_SOURCE_DIR}/README.cifstab.migration .
|
cp -a ${RPM_SOURCE_DIR}/README.cifstab.migration .
|
||||||
|
%patch0 -p1
|
||||||
|
%patch1 -p1
|
||||||
|
%patch2 -p1
|
||||||
|
%patch3 -p1
|
||||||
|
%patch4 -p1
|
||||||
|
%patch5 -p1
|
||||||
|
%patch6 -p1
|
||||||
|
%patch7 -p1
|
||||||
|
%patch8 -p1
|
||||||
|
%patch9 -p1
|
||||||
|
|
||||||
%build
|
%build
|
||||||
export CFLAGS="%{optflags} -D_GNU_SOURCE -fpie"
|
export CFLAGS="%{optflags} -D_GNU_SOURCE -fpie"
|
||||||
|
Loading…
Reference in New Issue
Block a user