Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
itminedu
snf-image-creator
Commits
e56edd29
Commit
e56edd29
authored
May 22, 2013
by
Nikos Skalkotos
Browse files
Add cleanup_password sysprep for freebsd
parent
d8a12a7e
Changes
1
Hide whitespace changes
Inline
Side-by-side
image_creator/os_type/freebsd.py
View file @
e56edd29
...
...
@@ -31,7 +31,7 @@
# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.
from
image_creator.os_type.unix
import
Unix
from
image_creator.os_type.unix
import
Unix
,
sysprep
import
re
...
...
@@ -72,4 +72,32 @@ class Freebsd(Unix):
return
users
@
sysprep
()
def
cleanup_password
(
self
,
print_header
=
True
):
"""Remove all passwords and lock all user accounts"""
if
print_header
:
self
.
out
.
output
(
"Cleaning up passwords & locking all user "
"accounts"
)
master_passwd
=
[]
for
line
in
self
.
g
.
cat
(
'/etc/master.passwd'
).
splitlines
():
# Check for empty or comment lines
if
len
(
line
.
split
(
'#'
)[
0
])
==
0
:
master_passwd
.
append
(
line
)
continue
fields
=
line
.
split
(
':'
)
if
fields
[
1
]
not
in
(
'*'
,
'!'
):
fields
[
1
]
=
'!'
master_passwd
.
append
(
":"
.
join
(
fields
))
self
.
g
.
write
(
'/etc/master.passwd'
,
"
\n
"
.
join
(
master_passwd
)
+
'
\n
'
)
# Make sure no one can login on the system
self
.
g
.
rm_rf
(
'/etc/spwd.db'
)
# vim: set sta sts=4 shiftwidth=4 sw=4 et ai :
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment