Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
python
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
isgphys
python
Commits
32464b4c
Commit
32464b4c
authored
6 years ago
by
Sven Mäder
Browse files
Options
Downloads
Patches
Plain Diff
Add blocked permission check
parent
c2c82598
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
bin/check-home-permissions.py
+9
-9
9 additions, 9 deletions
bin/check-home-permissions.py
bin/xymon-home.py
+49
-4
49 additions, 4 deletions
bin/xymon-home.py
with
58 additions
and
13 deletions
bin/check-home-permissions.py
+
9
−
9
View file @
32464b4c
...
...
@@ -117,10 +117,10 @@ def check_homes(top):
if
users
[
home
.
name
][
'
homeDirectory
'
][
6
:]
!=
home
.
name
:
bad_home_directory
.
append
(
'
:
'
.
join
([
home
.
name
,
users
[
home
.
name
][
'
homeDirectory
'
]]))
if
users
[
home
.
name
][
'
blocked
'
]
==
'
yes
'
:
if
home
.
st
.
st_mode
!=
stat
.
S_I
FDIR
:
if
home
.
st
.
st_mode
&
stat
.
S_I
RWXU
:
not_closed
.
append
(
home
)
else
:
if
home
.
st
.
st_mode
!=
stat
.
S_I
FDIR
|
stat
.
S_IRUSR
|
stat
.
S_IWUSR
|
stat
.
S_IXUSR
:
if
home
.
st
.
st_mode
&
stat
.
S_I
RWXU
!=
stat
.
S_IRUSR
|
stat
.
S_IWUSR
|
stat
.
S_IXUSR
:
not_open
.
append
(
home
)
del
users
[
home
.
name
]
else
:
...
...
@@ -193,6 +193,13 @@ if __name__ == '__main__':
print
(
'
no nismap for home:
'
+
str
(
len
(
no_nis_map
)))
print
()
if
no_blocked
:
print
(
'
no blocked attr:
'
)
print
(
'
----------------
'
)
for
home
in
no_blocked
:
print
(
home
)
print
()
if
owner
:
print
(
'
bad owner or group:
'
)
print
(
'
-------------------
'
)
...
...
@@ -223,13 +230,6 @@ if __name__ == '__main__':
print
(
''
.
join
([
k
,
'
:
'
,
'
blocked=
'
,
v
[
'
blocked
'
],
'
'
,
'
homeDirectory=
'
,
v
[
'
homeDirectory
'
]]))
print
()
if
no_blocked
:
print
(
'
no blocked attr:
'
)
print
(
'
----------------
'
)
for
home
in
no_blocked
:
print
(
home
)
print
()
if
not_closed
:
print
(
'
home not closed:
'
)
print
(
'
----------------
'
)
...
...
This diff is collapsed.
Click to expand it.
bin/xymon-home.py
+
49
−
4
View file @
32464b4c
...
...
@@ -28,6 +28,9 @@ bad_home_directory = []
no_ldap_user
=
[]
bad_nis_map
=
[]
no_nis_map
=
[]
no_blocked
=
[]
not_closed
=
[]
not_open
=
[]
class
Home
(
object
):
...
...
@@ -75,7 +78,14 @@ def search_ldap():
ldap_users
.
search
(
'
*
'
)
for
user
in
ldap_users
:
users
[
user
[
'
uid
'
][
0
]]
=
user
[
'
homeDirectory
'
][
0
]
user_attrs
=
{}
user_attrs
[
'
homeDirectory
'
]
=
user
[
'
homeDirectory
'
][
0
]
if
user
[
'
blocked
'
]:
user_attrs
[
'
blocked
'
]
=
user
[
'
blocked
'
][
0
]
else
:
no_blocked
.
append
(
user
[
'
uid
'
][
0
])
user_attrs
[
'
blocked
'
]
=
'
no
'
users
[
user
[
'
uid
'
][
0
]]
=
user_attrs
entries
.
search
(
'
cn: *, nisMapEntry: phd-home*
'
,
[
'
nisObject
'
],
base
=
auto_home
)
for
entry
in
entries
:
...
...
@@ -109,8 +119,14 @@ def check_homes(top):
acl
.
append
(
home
)
if
home
.
name
in
users
:
if
users
[
home
.
name
][
6
:]
!=
home
.
name
:
bad_home_directory
.
append
(
'
:
'
.
join
([
home
.
name
,
users
[
home
.
name
]]))
if
users
[
home
.
name
][
'
homeDirectory
'
][
6
:]
!=
home
.
name
:
bad_home_directory
.
append
(
'
:
'
.
join
([
home
.
name
,
users
[
home
.
name
][
'
homeDirectory
'
]]))
if
users
[
home
.
name
][
'
blocked
'
]
==
'
yes
'
:
if
home
.
st
.
st_mode
&
stat
.
S_IRWXU
:
not_closed
.
append
(
home
)
else
:
if
home
.
st
.
st_mode
&
stat
.
S_IRWXU
!=
stat
.
S_IRUSR
|
stat
.
S_IWUSR
|
stat
.
S_IXUSR
:
not_open
.
append
(
home
)
del
users
[
home
.
name
]
else
:
no_ldap_user
.
append
(
home
)
...
...
@@ -167,6 +183,9 @@ def run_check(xymon):
content
+=
'
home dirs:
'
+
str
(
home_dirs
)
+
'
<br/>
'
content
+=
'
strange ldap users:
'
+
str
(
len
(
users
))
+
'
<br/>
'
content
+=
'
no blocked attr:
'
+
str
(
len
(
no_blocked
))
+
'
<br/>
'
content
+=
'
home not closed:
'
+
str
(
len
(
not_closed
))
+
'
<br/>
'
content
+=
'
home not open:
'
+
str
(
len
(
not_open
))
+
'
<br/>
'
content
+=
'
orphaned nis homes:
'
+
str
(
len
(
nis_homes
))
+
'
<br/>
'
content
+=
'
orphaned nis shares:
'
+
str
(
len
(
nis_shares
))
+
'
<br/>
'
content
+=
'
bad homeDirectory:
'
+
str
(
len
(
bad_home_directory
))
+
'
<br/>
'
...
...
@@ -176,6 +195,16 @@ def run_check(xymon):
xymon
.
section
(
title
,
content
)
if
no_blocked
:
title
=
'
ldap user has no `blocked` attribute
'
content
=
'
this is just an inconsistency and means the account is not blocked<br/><br/>
'
if
len
(
no_blocked
)
>
10
:
content
+=
'
user listing suppressed due to many entries (
'
+
str
(
len
(
no_blocked
))
+
'
)<br/>
'
else
:
content
+=
''
.
join
([
str
(
home
),
'
<br/>
'
])
xymon
.
section
(
title
,
content
)
xymon
.
color
=
pymon
.
STATUS_WARNING
if
owner
:
title
=
'
bad owner or group
'
content
=
'
home must be owned by the respective user and the group his user-private-group<br/><br/>
'
...
...
@@ -192,6 +221,22 @@ def run_check(xymon):
xymon
.
section
(
title
,
content
)
xymon
.
color
=
pymon
.
STATUS_CRITICAL
if
not_closed
:
title
=
'
home not closed (bad permissions)
'
content
=
'
blocked user homes should have <code>u=---</code><br/><br/>
'
for
home
in
not_closed
:
content
+=
''
.
join
([
str
(
home
),
'
<br/>
'
])
xymon
.
section
(
title
,
content
)
xymon
.
color
=
pymon
.
STATUS_CRITICAL
if
not_open
:
title
=
'
home not open (bad permissions)
'
content
=
'
active user homes should have <code>u=rwx</code><br/><br/>
'
for
home
in
not_open
:
content
+=
''
.
join
([
str
(
home
),
'
<br/>
'
])
xymon
.
section
(
title
,
content
)
xymon
.
color
=
pymon
.
STATUS_CRITICAL
if
acl
:
title
=
'
bad acls
'
content
=
'
home has posix.1e extended ACLs<br/>check acls using `getfacl`, which stands for `get fucking ACL`<br/><br/>
'
...
...
@@ -206,7 +251,7 @@ def run_check(xymon):
title
=
'
strange ldap users
'
content
=
'
these users seem to not have a home directory on the filesystem<br/><br/>
'
for
k
,
v
in
users
.
items
():
content
+=
'
:
'
.
join
([
k
,
v
])
+
'
<br/>
'
content
+=
''
.
join
([
k
,
'
:
'
,
'
blocked=
'
,
v
[
'
blocked
'
],
'
'
,
'
homeDirectory=
'
,
v
[
'
homeDirectory
'
],
'
<br/>
'
])
xymon
.
section
(
title
,
content
)
xymon
.
color
=
pymon
.
STATUS_CRITICAL
...
...
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