Skip to content

Commit

Permalink
Merge pull request #320 from timopollmeier/smb-alert-update-7.0
Browse files Browse the repository at this point in the history
Improve handling of SMB alert file path (7.0)
  • Loading branch information
mattmundell committed Jan 9, 2019
2 parents e8edfa8 + 21885f8 commit 0356381
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions src/alert_methods/SMB/alert
Original file line number Diff line number Diff line change
Expand Up @@ -136,16 +136,27 @@ def main():

# get list of subdirectory paths
dest_parts = dest_path.split('\\')
dest_subpaths = [dest_parts[0]]
dest_subpaths = []
make_dest = ''
for i in range(0, len(dest_parts)):
if dest_parts[i].endswith('.'):
print("File or subdirectory names must not be '.', '..' or"
" end with a dot",
file=sys.stderr)
sys.exit(1)

if len(dest_parts) >= 2:
make_dest = dest_parts[0]
for i in range(1, len(dest_parts)):
dest_subpaths.append(make_dest)
make_dest += '\\' + dest_parts[i]
for i in range(0, len(dest_parts) - 1):
if dest_parts[i]:
if make_dest:
make_dest += '\\' + dest_parts[i]
else:
make_dest = dest_parts[i]
dest_subpaths.append(make_dest)

# Find first existing path
first_existing_path_index = -1
for i in range(len(dest_subpaths)-1, 0, -1):
for i in range(len(dest_subpaths)-1, -1, -1):
if smb_dir_exists(auth_path, share, dest_subpaths[i]):
first_existing_path_index = i
break
Expand Down

0 comments on commit 0356381

Please sign in to comment.