Fix list of shares, don't show duplicate files
authorJamie Cameron <jcameron@webmin.com>
Mon, 8 Feb 2010 22:27:02 +0000 (14:27 -0800)
committerJamie Cameron <jcameron@webmin.com>
Mon, 8 Feb 2010 22:27:02 +0000 (14:27 -0800)
samba/CHANGELOG
samba/samba-lib.pl
samba/view_users.cgi

index 81a64f2..0f8f768 100644 (file)
@@ -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.
index 99f2262..d25094d 100755 (executable)
@@ -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 ]);
                }
        }
index edd1c7f..c01c5fe 100755 (executable)
@@ -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]).")<br>\n";