Skip to content

Commit

Permalink
filed: ldap - detect missing data during restore
Browse files Browse the repository at this point in the history
When the LDAP plugin fails to back up an object, it will be recorded in
the catlog, but the data will be missing.
Previously these objects were silently ignored during restore, leading
to an incomplete set of restored objects.
This patch now adds a rudimentary detection of this case by checking if
plugin_io() is called with IO_READ, IO_WRITE or IO_SEEK between the
calls to IO_OPEN and IO_CLOSE. When there is no call we now emit a
warning that there was no data to restore the object.
  • Loading branch information
arogge committed Sep 11, 2020
1 parent 41bb9f6 commit e9b60b1
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion core/src/plugins/filed/python/ldap/BareosFdPluginLDAP.py
Expand Up @@ -111,7 +111,7 @@ def create_file(self, restorepkt):
to get the actual DN of the LDAP record
"""
bareosfd.DebugMessage(
100, "BareosFdPluginVMware:create_file() called with %s\n" % (restorepkt)
100, "BareosFdPluginLDAP:create_file() called with %s\n" % (restorepkt)
)
if restorepkt.type == bareosfd.bFileType["FT_DIREND"]:
restorepkt.create_status = bareosfd.bCFs["CF_SKIP"]
Expand All @@ -133,12 +133,19 @@ def plugin_io(self, IOP):
)

if IOP.func == bareosfd.bIOPS["IO_OPEN"]:
self.last_op = IOP.func
return bareosfd.bRC_OK

elif IOP.func == bareosfd.bIOPS["IO_CLOSE"]:
if self.last_op == bareosfd.bIOPS["IO_OPEN"]:
bareosfd.JobMessage(
bareosfd.bJobMessageType["M_WARNING"],
"Missing data for DN %s\n" % self.ldap.dn)
self.last_op = IOP.func
return bareosfd.bRC_OK

elif IOP.func == bareosfd.bIOPS["IO_SEEK"]:
self.last_op = IOP.func
return bareosfd.bRC_OK

elif IOP.func == bareosfd.bIOPS["IO_READ"]:
Expand All @@ -150,6 +157,7 @@ def plugin_io(self, IOP):
IOP.status = 0
IOP.io_errno = 0

self.last_op = IOP.func
return bareosfd.bRC_OK

elif IOP.func == bareosfd.bIOPS["IO_WRITE"]:
Expand All @@ -158,6 +166,7 @@ def plugin_io(self, IOP):
IOP.status = IOP.count
IOP.io_errno = 0

self.last_op = IOP.func
return bareosfd.bRC_OK

def end_backup_file(self):
Expand Down

0 comments on commit e9b60b1

Please sign in to comment.