Revision f165adc0 image_creator/os_type/unix.py
b/image_creator/os_type/unix.py | ||
---|---|---|
34 | 34 |
import re |
35 | 35 |
import sys |
36 | 36 |
|
37 |
from image_creator.os_type import OSBase, exclude_task
|
|
37 |
from image_creator.os_type import OSBase, sysprep
|
|
38 | 38 |
from image_creator.util import warn, output |
39 | 39 |
|
40 | 40 |
|
... | ... | |
70 | 70 |
|
71 | 71 |
return users |
72 | 72 |
|
73 |
@exclude_task
|
|
74 |
def data_cleanup_user_accounts(self, print_header=True):
|
|
73 |
@sysprep(enabled=False)
|
|
74 |
def remove_user_accounts(self, print_header=True):
|
|
75 | 75 |
"""Remove all user account with id more than 1000""" |
76 | 76 |
|
77 | 77 |
if print_header: |
... | ... | |
113 | 113 |
if self.g.is_dir(home) and home.startswith('/home/'): |
114 | 114 |
self.g.rm_rf(home) |
115 | 115 |
|
116 |
def data_cleanup_passwords(self, print_header=True): |
|
116 |
@sysprep() |
|
117 |
def cleanup_passwords(self, print_header=True): |
|
117 | 118 |
"""Remove all passwords and lock all user accounts""" |
118 | 119 |
|
119 | 120 |
if print_header: |
... | ... | |
130 | 131 |
|
131 | 132 |
self.g.write('/etc/shadow', "\n".join(shadow) + '\n') |
132 | 133 |
|
133 |
def data_cleanup_cache(self, print_header=True): |
|
134 |
@sysprep() |
|
135 |
def cleanup_cache(self, print_header=True): |
|
134 | 136 |
"""Remove all regular files under /var/cache""" |
135 | 137 |
|
136 | 138 |
if print_header: |
... | ... | |
138 | 140 |
|
139 | 141 |
self.foreach_file('/var/cache', self.g.rm, ftype='r') |
140 | 142 |
|
141 |
def data_cleanup_tmp(self, print_header=True): |
|
143 |
@sysprep() |
|
144 |
def cleanup_tmp(self, print_header=True): |
|
142 | 145 |
"""Remove all files under /tmp and /var/tmp""" |
143 | 146 |
|
144 | 147 |
if print_header: |
... | ... | |
147 | 150 |
self.foreach_file('/tmp', self.g.rm_rf, maxdepth=1) |
148 | 151 |
self.foreach_file('/var/tmp', self.g.rm_rf, maxdepth=1) |
149 | 152 |
|
150 |
def data_cleanup_log(self, print_header=True): |
|
153 |
@sysprep() |
|
154 |
def cleanup_log(self, print_header=True): |
|
151 | 155 |
"""Empty all files under /var/log""" |
152 | 156 |
|
153 | 157 |
if print_header: |
... | ... | |
155 | 159 |
|
156 | 160 |
self.foreach_file('/var/log', self.g.truncate, ftype='r') |
157 | 161 |
|
158 |
@exclude_task
|
|
159 |
def data_cleanup_mail(self, print_header=True):
|
|
162 |
@sysprep(enabled=False)
|
|
163 |
def cleanup_mail(self, print_header=True): |
|
160 | 164 |
"""Remove all files under /var/mail and /var/spool/mail""" |
161 | 165 |
|
162 | 166 |
if print_header: |
... | ... | |
165 | 169 |
self.foreach_file('/var/spool/mail', self.g.rm_rf, maxdepth=1) |
166 | 170 |
self.foreach_file('/var/mail', self.g.rm_rf, maxdepth=1) |
167 | 171 |
|
168 |
def data_cleanup_userdata(self, print_header=True): |
|
172 |
@sysprep() |
|
173 |
def cleanup_userdata(self, print_header=True): |
|
169 | 174 |
"""Delete sensitive userdata""" |
170 | 175 |
|
171 | 176 |
homedirs = ['/root'] + self.ls('/home/') |
Also available in: Unified diff