]> www.vanbest.org Git - motioneye-debian/commitdiff
add support for password hook external program
authorCalin Crisan <ccrisan@gmail.com>
Sat, 5 Aug 2017 12:40:40 +0000 (15:40 +0300)
committerCalin Crisan <ccrisan@gmail.com>
Sat, 5 Aug 2017 12:40:40 +0000 (15:40 +0300)
motioneye/config.py
motioneye/settings.py

index c6066732d324c0074f711767f2d68ded7f9838a1..2a8be05861db677d520baada7d3aaa6057d97693 100644 (file)
@@ -645,6 +645,20 @@ def main_ui_to_dict(ui):
         '@normal_username': ui['normal_username']
     }
 
+    def call_hook(u, p):
+        if settings.PASSWORD_HOOK:
+            env = {
+                'MEYE_USERNAME': u,
+                'MEYE_PASSWORD': p
+            }
+
+            try:
+                subprocess.check_output(settings.PASSWORD_HOOK, env=env, stderr=subprocess.STDOUT)
+                logging.debug('password hook exec succeeded')
+
+            except Exception as e:
+                logging.error('password hook exec failed: %s' % e)
+
     if ui.get('admin_password') is not None:
         if ui['admin_password']:
             data['@admin_password'] = hashlib.sha1(ui['admin_password']).hexdigest()
@@ -652,6 +666,8 @@ def main_ui_to_dict(ui):
         else:
             data['@admin_password'] = ''
 
+        call_hook(ui['admin_username'], ui['admin_password'])
+
     if ui.get('normal_password') is not None:
         if ui['normal_password']:
             data['@normal_password'] = hashlib.sha1(ui['normal_password']).hexdigest()
@@ -659,6 +675,8 @@ def main_ui_to_dict(ui):
         else:
             data['@normal_password'] = ''
 
+        call_hook(ui['normal_username'], ui['normal_password'])
+
     # additional configs
     for name, value in ui.iteritems():
         if not name.startswith('_'):
index 44786611dded48bae54eb46d8f8a9418db9df024..10d32f45c9f23c8f679c2deab6f38b297d94d97c 100644 (file)
@@ -124,3 +124,7 @@ ADD_REMOVE_CAMERAS = True
 
 # enable HTTPS certificate validation
 VALIDATE_CERTS = True
+
+# an external program to be executed whenever a password changes;
+# the program will be invoked with environment variables MEYE_USERNAME and MEYE_PASSWORD
+PASSWORD_HOOK = None