View Issue Details

IDProjectCategoryView StatusLast Update
0000893bareos-corewebuipublic2019-12-18 15:25
Reportertonyalbers Assigned Tofrank  
PriorityhighSeveritymajorReproducibilityalways
Status closedResolutionfixed 
PlatformLinuxOSCentOSOS Version7
Product Version17.2.4 
Summary0000893: webui cannot list dirs with only files in them
DescriptionWe have a user's homedir which contains only files. When trying to browse the backup in the webui, it says: "Oops, something went wrong, probably too many files."
The user has 76 files in his homedir.
Another user's homedir which has files AND folders is browsable.
Steps To ReproduceNot entirely sure, but we use the following fileset resource:

FileSet {
  Name = "p004home"
  Description = "Backup Project 004 user homedirs."
  Include {

     Options {
        exclude = yes
        wilddir = /data/home/*p004/data
        wild = /data/home/*lock_file*
     }
     Options {
        signature = MD5
        wilddir = /data/home/*p004
        wild = /data/home/*p004/*
     }
     Options {
        exclude = yes
        wilddir = /data/home/*
     }

     File = /data/home/
  }
}
Additional InformationMay be related to: 0000891

Also, it seems that in the output it misses a comma sometimes. If I open the webui in Chrome, choose CTRL+SHIFT+I for developer tools and use network monitoring, I can see that in the last communication before the popup there's something wrong with the json output. First statement is not separated from the second by a comma:
[{"id":"-12408","text":".ssh/","icon":"glyphicon glyphicon-folder-close","state":"","data":{"type":"D","fullpath":"\/data\/home\/tegp004\/.ssh\/","pathid":12408,"fileid":1990019,"stat":{"atime":1516607463,"dev":64770,"ino":9840045,"group":"20503","rdev":0,"mtime":1511276383,"mode":16832,"nlink":2,"user":"20503","size":4096,"ctime":1511276394},"name":".ssh\/","jobid":21643,"lstat":"P0C liWt EHA C FAX FAX A BAA BAA I BaZZfn BaFD9f BaFD9q A A C","linkfileindex":0},"children":true}{"id"...

(Last few words, no comma between } and { )
Tagswebui

Relationships

related to 0000891 closedfrank Webui will not open some windows clients directories 
child of 0000910 closed Release bareos-17.2.5 

Activities

asger_blekinge

asger_blekinge

2018-01-23 15:07

reporter  

893.patch (1,166 bytes)   
Index: module/Restore/src/Restore/Controller/RestoreController.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- module/Restore/src/Restore/Controller/RestoreController.php	(revision 7d9c6270c5c01c7944a09d2777d8d08b0cc305f1)
+++ module/Restore/src/Restore/Controller/RestoreController.php	(date 1516708101000)
@@ -326,6 +326,7 @@
 
       $dnum = count($this->directories);
       $fnum = count($this->files);
+      //$tmp is the number of directories minus . and ..
       $tmp = $dnum;
 
       // Build Json for JStree
@@ -336,10 +337,12 @@
          foreach($this->directories as $dir) {
             if($dir['name'] == ".") {
                --$dnum;
+               --$tmp;
                next($this->directories);
             }
             elseif($dir['name'] == "..") {
                --$dnum;
+               --$tmp;
                next($this->directories);
             }
             else {
@@ -360,7 +363,7 @@
 
       }
 
-      if( $tmp > 2 && $fnum > 0 ) {
+      if( $tmp > 0 && $fnum > 0 ) {
          $items .= ",";
       }
 
893.patch (1,166 bytes)   
asger_blekinge

asger_blekinge

2018-01-23 15:10

reporter   ~0002879

Uploaded patch that solves the problem.

The problem is that is that if the directory list does not include . and .., the RemoteController will fail when generating JSON output.

It expects the list to contain . and .., which it filters out. But it only puts a , after the directory list if the list contains more than 2 directories. However, if the list does NOT contain . and .., this means the produced JSON will be invalid if the list contains less than 3 normal directories.
asger_blekinge

asger_blekinge

2018-01-23 15:12

reporter   ~0002880

So the bug title is actually wrong. It should be something like "webui cannot list directories with at least 1 file and between 1 and 3 direct subdirectories"

And the error message should probably not be "Oops, something went wrong, probably too many files.", but rather "Oops, something went wrong, probably too few directories." ;)
frank

frank

2018-02-13 18:52

developer   ~0002909

Fix committed to bareos-webui bareos-17.2 branch with changesetid 7738.

Related Changesets

bareos-webui: bareos-17.2 ee232a6f

2018-02-13 19:43

frank

Ported: N/A

Details Diff
Fix to bugreport 0000905 and 0000893

Regarding 0000905:

When returning an Ajax result, inside a json string value don't use addslashes.
You don't want both " and ' escaped at the same time. Instead just use
str_replace('"','\"',$Str).

Regarding 0000893:

A misplaced dir and file separator ',' lead to malformed json which could result in
a non loadable subtree.

Fixes 0000893: webui cannot list dirs with only files in them
Fixes 0000905: Restore WebUI - Enable to browse directory when a file name contain a single quote
Affected Issues
0000893, 0000905
mod - module/Restore/src/Restore/Controller/RestoreController.php Diff File

Issue History

Date Modified Username Field Change
2018-01-23 08:46 tonyalbers New Issue
2018-01-23 15:07 asger_blekinge File Added: 893.patch
2018-01-23 15:10 asger_blekinge Note Added: 0002879
2018-01-23 15:12 asger_blekinge Note Added: 0002880
2018-01-23 15:13 asger_blekinge Tag Attached: webui
2018-01-26 16:29 frank Assigned To => frank
2018-01-26 16:29 frank Status new => assigned
2018-02-13 18:42 frank Status assigned => confirmed
2018-02-13 18:52 frank Changeset attached => bareos-webui bareos-17.2 ee232a6f
2018-02-13 18:52 frank Note Added: 0002909
2018-02-13 18:52 frank Status confirmed => resolved
2018-02-13 18:52 frank Resolution open => fixed
2018-02-13 18:55 frank Relationship added child of 0000910
2018-03-12 11:33 frank Relationship added related to 0000891
2019-12-18 15:25 arogge Status resolved => closed