diff --git a/howdy/src/config.ini b/howdy/src/config.ini index db9980f..8e4ca79 100644 --- a/howdy/src/config.ini +++ b/howdy/src/config.ini @@ -94,7 +94,7 @@ rotate = 0 [snapshots] # Capture snapshots of failed login attempts and save them to disk with metadata -# Snapshots are saved to the "snapshots" folder +# Snapshots are saved to /var/log/howdy/snapshots save_failed = false # Do the same as the option above but for successful attempts diff --git a/howdy/src/snapshot.py b/howdy/src/snapshot.py index c853ffa..324b578 100644 --- a/howdy/src/snapshot.py +++ b/howdy/src/snapshot.py @@ -8,14 +8,14 @@ import numpy as np def generate(frames, text_lines): - """Generate a shapshot from given frames""" + """Generate a snapshot from given frames""" # Don't execute if no frames were given if len(frames) == 0: return # Get the path to the containing folder - abpath = os.path.dirname(os.path.abspath(__file__)) + core_path = os.path.dirname(os.path.abspath(__file__)) # Get frame dimensions frame_height, frame_width, cc = frames[0].shape # Spread the given frames out horizontally @@ -31,7 +31,7 @@ def generate(frames, text_lines): # Add the Howdy logo if there's space to do so if len(frames) > 1: # Load the logo from file - logo = cv2.imread(abpath + "/logo.png") + logo = cv2.imread(core_path + "/logo.png") # Calculate the position of the logo logo_y = frame_height + 20 logo_x = frame_width * len(frames) - 210 @@ -49,14 +49,19 @@ def generate(frames, text_lines): line_number += 1 + # Define path to any howdy logs + log_path = "/var/log/howdy" + # Made sure a snapshot folder exist - if not os.path.exists(abpath + "/snapshots"): - os.makedirs(abpath + "/snapshots") + if not os.path.exists(log_path): + os.makedirs(log_path) + if not os.path.exists(log_path + "/snapshots"): + os.makedirs(log_path + "/snapshots") # Generate a filename based on the current time filename = datetime.datetime.utcnow().strftime("%Y%m%dT%H%M%S.jpg") # Write the image to that file - cv2.imwrite(abpath + "/snapshots/" + filename, snap) + cv2.imwrite(log_path + "/snapshots/" + filename, snap) # Return the saved file location - return abpath + "/snapshots/" + filename + return log_path + "/snapshots/" + filename