← Back to team overview

cloud-init-dev team mailing list archive

[Merge] lp:~harlowja/cloud-init/fix-redact into lp:cloud-init

 

Joshua Harlow has proposed merging lp:~harlowja/cloud-init/fix-redact into lp:cloud-init.

Requested reviews:
  cloud init development team (cloud-init-dev)
Related bugs:
  Bug #1096417 in cloud-init: "Redact the password field from the logs not correct?"
  https://bugs.launchpad.net/cloud-init/+bug/1096417

For more details, see:
https://code.launchpad.net/~harlowja/cloud-init/fix-redact/+merge/142017
-- 
https://code.launchpad.net/~harlowja/cloud-init/fix-redact/+merge/142017
Your team cloud init development team is requested to review the proposed merge of lp:~harlowja/cloud-init/fix-redact into lp:cloud-init.
=== modified file 'cloudinit/distros/__init__.py'
--- cloudinit/distros/__init__.py	2012-11-20 06:04:31 +0000
+++ cloudinit/distros/__init__.py	2013-01-05 18:06:21 +0000
@@ -297,22 +297,26 @@
             "no_create_home": "-M",
         }
 
+        redact_fields = ['passwd']
+
         # Now check the value and create the command
         for option in kwargs:
             value = kwargs[option]
             if option in adduser_opts and value \
                 and isinstance(value, str):
                 adduser_cmd.extend([adduser_opts[option], value])
-
-                # Redact the password field from the logs
-                if option != "password":
+                # Redact certain fields from the logs
+                if option in redact_fields:
+                    x_adduser_cmd.extend([adduser_opts[option], 'REDACTED'])
+                else:
                     x_adduser_cmd.extend([adduser_opts[option], value])
-                else:
-                    x_adduser_cmd.extend([adduser_opts[option], 'REDACTED'])
-
             elif option in adduser_opts_flags and value:
                 adduser_cmd.append(adduser_opts_flags[option])
-                x_adduser_cmd.append(adduser_opts_flags[option])
+                # Redact certain fields from the logs
+                if option in redact_fields:
+                    x_adduser_cmd.append('REDACTED')
+                else:
+                    x_adduser_cmd.append(adduser_opts_flags[option])
 
         # Default to creating home directory unless otherwise directed
         #  Also, we do not create home directories for system users.


Follow ups