Using regular expressions in NSsbackup does not work properly.

Bug #299967 reported by Jean-Peer Lorenz
2
Affects Status Importance Assigned to Milestone
nssbackup
Fix Released
High
Jean-Peer Lorenz

Bug Description

Using regular expressions in NSsbackup does not work properly:

This bug report collects some issues concerning the use of regular expressions for definition of exclusions within NSsbackup. These issues are:

1. it is possible to add an empty expression using the graphical configuration tool

2. if an invalid regular expression was created with a prior version of NSsbackup (or by editing the configuration file manually), the demon 'nssbackupd' fails with following exception:

   2008-11-07 19:16:53,802 - DEBUG - BackupManager.py:__fillSnapshot(320) - getting exclude list for actual snapshot
   2008-11-07 19:16:53,803 - ERROR - nssbackupd.py:__onError(216) - unexpected end of regular expression
   2008-11-07 19:16:53,822 - ERROR - nssbackupd.py:__onError(217) - Traceback (most recent call last):
     File "/usr/local/lib/python2.5/site-packages/nssbackup/nssbackupd.py", line 136, in run
       self.__bm.makeBackup()
     File "/usr/local/lib/python2.5/site-packages/nssbackup/managers/BackupManager.py", line 173, in makeBackup
       self.__fillSnapshot(prev)
     File "/usr/local/lib/python2.5/site-packages/nssbackup/managers/BackupManager.py", line 322, in __fillSnapshot
       rexclude = [ re.compile(p) for p in self.__actualSnapshot.getExcludes() if len(p)>0]
     File "/usr/lib/python2.5/re.py", line 188, in compile
       return _compile(pattern, flags)
     File "/usr/lib/python2.5/re.py", line 241, in _compile
       raise error, v # invalid expression
   error: unexpected end of regular expression

This should be avoided. This bug is critical since the backup fails.

3. It is _not_ possible to remove ALL defined regular expressions in configuration GUI, i.e. defined regexps and defined filetypes. The very last expression is removed from the displayed list but not from the conf-file.

4. if an invalid regular expression was created with a prior version of NSsbackup (or by editing the configuration file manually) the expression is displayed in GUI and is saved again. This should be avoided.

Revision history for this message
Jean-Peer Lorenz (peer.loz) wrote :

Here is a patch to fix the reported issues above.
Explanations on the modifications:

=== modified file 'src/nssbackup/util/__init__.py':

* adding new functions to unify checking of expressions (maybe it is useful for further versions to create somekind of ConfigurationHandler class to encapsulate reading configuration files, checking of configuration values and setting of new ones - so this is a bugfix only for the current release candidate version)

=== modified file 'src/nssbackup/ui/SBConfigGTK.py':

* adding a method for showing a dialogbox containing an errormessage

* the regular expressions from the configuration file were checked before they are added to any lists; if they are invalid they were removed and the users gets informed. This fixes issue 4).

* if a regular expression is added to the configuration, the resulting line gets stripped off leading and trailing ',' to avoid to unwanted adding of an empty expression

* in method 'on_ex_delregex_clicked': the removal of an expression is done by the function mentioned above. The last expression didn't had a leading comma, so it was not removed. This fixes issue 3).

* in method 'cell_regex_edited_callback': it was possible to clear the expression and therefore an empty expression was stored. The fix now checks not only for a valid expression but additionally for a not empty expression. This fixes issue 1).

* while checking regular expression only 're.error' were catched now.

=== modified file 'src/nssbackup/managers/BackupManager.py':

* while reading the configuration it is checked whether the expression is not empty and valid. If so it is added otherwise output a log message. This fixes issue 2).

=== modified file 'src/nssbackup/managers/SnapshotManager.py'

* string formatting was errornous. Fixed without changing the content of translated string. This fixes bug Bug #299964: Exception 'TypeError' is raised if an error occurs while pulling a snapshot.

Changed in nssbackup:
assignee: nobody → peer.loz
importance: Undecided → High
milestone: none → release0.2
status: New → Confirmed
Changed in nssbackup:
status: Confirmed → Fix Committed
Changed in nssbackup:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.