Merge lp:~harlowja/cloud-init/fix-redact into lp:~cloud-init-dev/cloud-init/trunk

Proposed by Joshua Harlow
Status: Merged
Merged at revision: 755
Proposed branch: lp:~harlowja/cloud-init/fix-redact
Merge into: lp:~cloud-init-dev/cloud-init/trunk
Diff against target: 37 lines (+11/-7)
1 file modified
cloudinit/distros/__init__.py (+11/-7)
To merge this branch: bzr merge lp:~harlowja/cloud-init/fix-redact
Reviewer Review Type Date Requested Status
cloud-init Commiters Pending
Review via email: mp+142017@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'cloudinit/distros/__init__.py'
2--- cloudinit/distros/__init__.py 2012-11-20 06:04:31 +0000
3+++ cloudinit/distros/__init__.py 2013-01-05 18:06:21 +0000
4@@ -297,22 +297,26 @@
5 "no_create_home": "-M",
6 }
7
8+ redact_fields = ['passwd']
9+
10 # Now check the value and create the command
11 for option in kwargs:
12 value = kwargs[option]
13 if option in adduser_opts and value \
14 and isinstance(value, str):
15 adduser_cmd.extend([adduser_opts[option], value])
16-
17- # Redact the password field from the logs
18- if option != "password":
19+ # Redact certain fields from the logs
20+ if option in redact_fields:
21+ x_adduser_cmd.extend([adduser_opts[option], 'REDACTED'])
22+ else:
23 x_adduser_cmd.extend([adduser_opts[option], value])
24- else:
25- x_adduser_cmd.extend([adduser_opts[option], 'REDACTED'])
26-
27 elif option in adduser_opts_flags and value:
28 adduser_cmd.append(adduser_opts_flags[option])
29- x_adduser_cmd.append(adduser_opts_flags[option])
30+ # Redact certain fields from the logs
31+ if option in redact_fields:
32+ x_adduser_cmd.append('REDACTED')
33+ else:
34+ x_adduser_cmd.append(adduser_opts_flags[option])
35
36 # Default to creating home directory unless otherwise directed
37 # Also, we do not create home directories for system users.