Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
snf-image-creator
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
itminedu
snf-image-creator
Commits
9fe161f8
Commit
9fe161f8
authored
12 years ago
by
Nikos Skalkotos
Browse files
Options
Downloads
Patches
Plain Diff
Monitor passworded users in FreeBSD
parent
6df939f7
Loading
Loading
Loading
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
image_creator/os_type/freebsd.py
+31
-1
31 additions, 1 deletion
image_creator/os_type/freebsd.py
with
31 additions
and
1 deletion
image_creator/os_type/freebsd.py
+
31
−
1
View file @
9fe161f8
...
...
@@ -33,9 +33,39 @@
from
image_creator.os_type.unix
import
Unix
import
re
class
Freebsd
(
Unix
):
"""
OS class for FreeBSD Unix-like os
"""
pass
def
__init__
(
self
,
rootdev
,
ghandler
,
output
):
super
(
Freebsd
,
self
).
__init__
(
rootdev
,
ghandler
,
output
)
self
.
meta
[
"
USERS
"
]
=
"
"
.
join
(
self
.
_get_passworded_users
())
# Delete the USERS metadata if empty
if
not
len
(
self
.
meta
[
'
USERS
'
]):
self
.
out
.
warn
(
"
No passworded users found!
"
)
del
self
.
meta
[
'
USERS
'
]
def
_get_passworded_users
(
self
):
users
=
[]
regexp
=
re
.
compile
(
'
^([^:]+):((?:![^:]+)|(?:[^!*][^:]+)|):(?:[^:]*:){7}(?:[^:]*)
'
)
for
line
in
self
.
g
.
cat
(
'
/etc/master.passwd
'
).
splitlines
():
line
=
line
.
split
(
'
#
'
)[
0
]
match
=
regexp
.
match
(
line
)
if
not
match
:
continue
user
,
passwd
=
match
.
groups
()
if
len
(
passwd
)
>
0
and
passwd
[
0
]
==
'
!
'
:
self
.
out
.
warn
(
"
Ignoring locked %s account.
"
%
user
)
else
:
users
.
append
(
user
)
return
users
# vim: set sta sts=4 shiftwidth=4 sw=4 et ai :
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment