Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
scripts
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Thomas Blanc
scripts
Commits
7560f05a
Commit
7560f05a
authored
Oct 28, 2013
by
Vincent Le gallic
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[arpwatch] On n'envoie pas de mail pour les évènement inintéressants.
parent
cb58f8f6
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
51 additions
and
14 deletions
+51
-14
firewall/aiccu_postup
firewall/aiccu_postup
+1
-1
gestion/ressuscite.py
gestion/ressuscite.py
+1
-1
secours/secours.py
secours/secours.py
+1
-2
surveillance/arpwatch/report.py
surveillance/arpwatch/report.py
+44
-6
wiki/auth/cas.py
wiki/auth/cas.py
+4
-4
No files found.
firewall/aiccu_postup
View file @
7560f05a
...
...
@@ -5,4 +5,4 @@
/etc/init.d/netacct-crans-sixxs2 restart
/etc/init.d/firewall6 restart
/usr/sbin/monit monitor netacct-crans-sixxs2
#
/usr/sbin/monit monitor netacct-crans-sixxs2
gestion/ressuscite.py
View file @
7560f05a
...
...
@@ -361,7 +361,7 @@ def ressuscite(adh, oldmachine):
except
EnvironmentError
,
c
:
err
+=
c
.
args
[
0
]
+
'
\n
'
elif
len
(
c
.
args
)
>
1
and
c
.
args
[
1
]
==
3
and
isadm
:
# Mac douteuse
no
,
res
=
dlg
.
yesno
(
text
=
u
"L
\'
adresse MAC ne correspond à aucun constructeur, continuer ?"
,
no
=
dlg
.
yesno
(
text
=
u
"L
\'
adresse MAC ne correspond à aucun constructeur, continuer ?"
,
title
=
u
"Adresse MAC"
)
if
not
no
:
try
:
machine
.
mac
(
str
(
oldmachine
.
mac
()),
1
)
...
...
secours/secours.py
View file @
7560f05a
...
...
@@ -76,8 +76,7 @@ COMMANDES = {
'/etc/init.d/postfix restart'
,
],
'komaz'
:
[
'/etc/init.d/aiccu restart'
,
'/usr/bin/monit monitor netacct-crans-sixxs2'
,
'/usr/bin/monit start netacct-crans-sixxs2'
,
],
}.
get
(
HOSTNAME
,
[])
...
...
surveillance/arpwatch/report.py
View file @
7560f05a
...
...
@@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-
# Ajout d'un whos et d'un tracage aux mails d'arpwatch
# Auteurs : Stéphane Glondu, Cyril Cohen, Daniel STAN, Valentin Samir
# Auteurs : Stéphane Glondu, Cyril Cohen, Daniel STAN, Valentin Samir
, Vincent Le Gallic
# Licence : GPLv2
from
__future__
import
print_function
...
...
@@ -14,7 +14,7 @@ import common
sys
.
path
.
append
(
'/usr/scripts'
)
from
gestion.tools.locate_mac
import
trace_machine
,
format_mac
,
info_machine
from
gestion.config
import
NETs
import
gestion.config
from
gestion.iptools
import
AddrInNets
from
utils.sendmail
import
sendmail
...
...
@@ -26,7 +26,14 @@ if not recipients:
find_mac
=
re
.
compile
(
r
'[0-9A-Fa-f]{1,2}(?::[0-9A-Fa-f]{1,2}){5}'
)
find_ip
=
re
.
compile
(
r
'[0-9]{1,3}(?:\.[0-9]{1,3}){3}'
)
arpwatched_net
=
NETs
[
'all'
]
+
NETs
[
'adm'
]
+
NETs
[
'accueil'
]
+
NETs
[
'isolement'
]
+
NETs
[
'personnel-ens'
]
+
NETs
[
'evenementiel'
]
#: Regexp pour matcher l'interface.
#: Ne matche pas toutes les interface (si un jour eth1 poppe),
#: Mais de toutes façons on ne drope que des interfaces qu'on a réussi à identifier
find_iface
=
re
.
compile
(
r
'eth0(?:\.[0-9]+)?'
)
arpwatched_nets
=
sum
([
gestion
.
config
.
NETs
[
nom
]
for
nom
in
[
'all'
,
'adm'
,
'accueil'
,
'isolement'
,
'personnel-ens'
,
'evenementiel'
]],
[])
#: VLANS dont on ignore les "new station"/"new activity" *si elles ont une ip correspondant au vlan*
ignored_vlans
=
[
'accueil'
,
'wifi'
]
def
get_machine
(
unformated_mac
):
"""Renvoie les informations sur la machine à partir de sa mac"""
...
...
@@ -39,6 +46,37 @@ def get_subject(headers_list):
return
line
[
9
:].
strip
()
return
None
def
drop_report
(
subject
,
ip
):
"""Détermine à partir du ``subject`` du mail
si il n'est pas nécessaire d'envoyer une notification pour cet évènement.
Renvoie ``True`` si il faut le dropper.
"""
# On récupère l'interface et l'ip dans le sujet
ifaces
=
find_iface
.
findall
(
subject
)
iface
=
ifaces
[
0
]
if
ifaces
else
None
if
not
iface
is
None
:
# On détermine le vlan
vlans
=
re
.
findall
(
r
"\.([^\.]*)$"
,
iface
)
try
:
vlan
=
int
(
vlans
[
0
])
if
vlans
else
None
except
ValueError
:
vlan
=
None
ips
=
find_ip
.
findall
(
subject
)
ip
=
ips
[
0
]
if
ips
else
None
#print("%r, %r" % (ip, iface))
#print(arpwatched_nets)
if
u
"new station"
in
subject
or
"new activity"
in
subject
:
if
not
vlan
is
None
:
vlannames
=
[
k
for
(
k
,
v
)
in
gestion
.
config
.
vlans
.
iteritems
()
if
v
==
vlan
]
#print("vlannames : %r" % vlannames)
if
vlannames
and
vlannames
[
0
]
in
ignored_vlans
:
#print("%r in %r ?" % (ip, gestion.config.NETs[vlannames[0]]))
if
AddrInNets
(
ip
,
gestion
.
config
.
NETs
[
vlannames
[
0
]]):
# On ignore les new station dont l'IP est sur le bon vlan
return
True
return
False
def
report
(
texte
,
fallback
=
False
):
"""Envoi d'un rapport"""
textes
=
texte
.
splitlines
(
True
)
...
...
@@ -59,8 +97,8 @@ def report(texte, fallback=False):
ip
=
set
(
find_ip
.
findall
(
texte
)).
pop
()
except
KeyError
:
ip
=
None
# On complète le message
if
u
'flip flop'
in
subject
and
ip
is
not
None
and
AddrInNets
(
ip
,
arpwatched_net
):
# On complète le message
seulement en cas de flip flop
if
u
'flip flop'
in
subject
and
ip
is
not
None
and
AddrInNets
(
ip
,
arpwatched_net
s
):
try
:
macs
=
find_mac
.
findall
(
texte
)
for
mac
in
macs
:
...
...
@@ -75,7 +113,7 @@ def report(texte, fallback=False):
textes
.
append
(
u
'
\n
--
\n
arpwatch_sendmail.py
\n
'
)
out
=
''
.
join
(
textes
)
if
recipients
:
if
recipients
and
not
drop_report
()
:
sendmail
(
u
"arpwatch@crans.org"
,
recipients
,
subject
,
out
,
more_headers
=
{
'X-Mailer'
:
__file__
,
...
...
wiki/auth/cas.py
View file @
7560f05a
...
...
@@ -128,10 +128,10 @@ class CASAuth(BaseAuth):
session_service
.
destroy_session
(
request
,
session
)
# authenticated user
if
not
force
and
user_obj
and
user_obj
.
valid
:
if
self
.
action
==
action
:
request
.
http_redirect
(
url
)
return
user_obj
,
True
#
if not force and user_obj and user_obj.valid:
#
if self.action == action:
#
request.http_redirect(url)
#
return user_obj, True
if
self
.
ticket_path
and
request
.
method
==
'POST'
:
logoutRequest
=
request
.
form
.
get
(
'logoutRequest'
,
None
)
...
...
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