From 33dfbdc5abe933cde7a3758f78bb4d6467149d03 Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Mon, 8 Feb 2010 14:27:02 -0800 Subject: [PATCH] Fix list of shares, don't show duplicate files --- samba/CHANGELOG | 1 + samba/samba-lib.pl | 9 +++++++-- samba/view_users.cgi | 7 +++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/samba/CHANGELOG b/samba/CHANGELOG index 81a64f2c6..0f8f768fd 100644 --- a/samba/CHANGELOG +++ b/samba/CHANGELOG @@ -23,3 +23,4 @@ The 'Password never expires' flag can be set for user accounts, thanks to a patc Allow the server description to be set to explicitly nothing. ---- Changes since 1.500 ---- Show the real Samba version number on the main page. +Fix list of users for a share to show open files correctly, and not show the same file multiple times on different shares. diff --git a/samba/samba-lib.pl b/samba/samba-lib.pl index 99f2262c3..d25094d10 100755 --- a/samba/samba-lib.pl +++ b/samba/samba-lib.pl @@ -222,10 +222,15 @@ sub list_locks { local($l, $started, @rv); local $out; -&execute_command("$config{samba_status_program} -L", undef, \$out, undef); +&execute_command("LANG=C $config{samba_status_program} -L", undef, \$out, undef); foreach $l (split(/\n/, $out)) { if ($l =~ /^----/) { $started = 1; } - if ($started && $l =~ /^(\d+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(.*)\s+(\S+\s+\S+\s+\d+\s+\d+:\d+:\d+\s+\d+)/) { + if ($started && $l =~ /^(\d+)\s+(\d+)\s+(\S+)\s+(0x\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S.*)\s\s((Mon|Tue|Wed|Thu|Fri|Sat|Sun)\s.*)/i) { + # New-style line + push(@rv, [ $1, $3, $5, $6, $7.'/'.$8, $9 ]); + } + elsif ($started && $l =~ /^(\d+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(.*)\s+(\S+\s+\S+\s+\d+\s+\d+:\d+:\d+\s+\d+)/) { + # Old-style line push(@rv, [ $1, $2, $3, $4, $5, $6 ]); } } diff --git a/samba/view_users.cgi b/samba/view_users.cgi index edd1c7f59..c01c5fef7 100755 --- a/samba/view_users.cgi +++ b/samba/view_users.cgi @@ -61,12 +61,19 @@ if (@cons) { if (!$in{'share'}) { push(@cols, &html_escape($c->[0])); } + $p = undef; + &get_share($c->[0]); + $p = &getval("path"); push(@cols, &html_escape($c->[1])); push(@cols, &html_escape($c->[2])); push(@cols, &html_escape($c->[4])); push(@cols, &html_escape($c->[5])); local $ulocks; @ulocks = grep { $_->[0] == $c->[3] } @locks; + if ($p) { + # Limit to files under share + @ulocks = grep { $_->[4] =~ /^\Q$p\E\// } @ulocks; + } foreach $l (@ulocks) { $ulocks .= &html_escape($l->[4])." (". &html_escape($l->[1]).")
\n";