Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Benjamin Graillot
scripts
Commits
0922e3c6
Commit
0922e3c6
authored
May 16, 2013
by
Vincent Le gallic
Browse files
lc_ldap.shortcuts
parent
dc01a371
Changes
8
Hide whitespace changes
Inline
Side-by-side
gestion/gen_confs/firewall4.py
View file @
0922e3c6
...
...
@@ -5,13 +5,15 @@
import
os
import
sys
sys
.
path
.
append
(
'/usr/scripts/gestion'
)
sys
.
path
.
append
(
'/usr/scripts/
lc_ldap
'
)
sys
.
path
.
append
(
'/usr/scripts/'
)
from
config
import
NETs
,
blacklist_sanctions
,
blacklist_sanctions_soft
,
blacklist_bridage_upload
,
mac_komaz
,
mac_titanic
,
adm_users
,
accueil_route
import
pwd
import
config.firewall
import
lc_ldap
import
lc_ldap.shortcuts
import
lc_ldap.objets
import
lc_ldap.attributs
import
socket
from
ipset
import
IpsetError
,
Ipset
from
iptools
import
AddrInNet
,
NetSubnets
,
IpSubnet
,
NetInNets
...
...
@@ -87,9 +89,9 @@ class firewall_base(object) :
blacklisted
=
[
machine
for
machine
in
conn
.
search
(
"blacklist=*"
,
sizelimit
=
4096
)
if
machine
.
blacklist_actif
()
]
self
.
_blacklisted_machines
=
set
()
for
item
in
blacklisted
:
if
isinstance
(
item
,
lc_ldap
.
proprio
):
if
isinstance
(
item
,
lc_ldap
.
objets
.
proprio
):
self
.
_blacklisted_machines
=
self
.
_blacklisted_machines
.
union
(
item
.
machines
())
elif
isinstance
(
item
,
lc_ldap
.
machine
):
elif
isinstance
(
item
,
lc_ldap
.
objets
.
machine
):
self
.
_blacklisted_machines
.
add
(
item
)
else
:
print
>>
sys
.
stderr
,
'Objet %s inconnu blacklisté'
%
a
.
__class__
.
__name__
...
...
@@ -206,7 +208,7 @@ class firewall_base(object) :
sys
.
exit
(
1
)
# Connection à la base ldap
conn
=
lc_ldap
.
lc_ldap_admin
()
conn
=
lc_ldap
.
shortcuts
.
lc_ldap_admin
()
self
.
reloadable
=
{
'blacklist_hard'
:
self
.
blacklist_hard
,
...
...
gestion/gen_confs/firewall_new.py
View file @
0922e3c6
...
...
@@ -27,7 +27,7 @@
import
sys
sys
.
path
.
append
(
'/usr/scripts/'
)
sys
.
path
.
append
(
'/usr/scripts/gestion'
)
sys
.
path
.
append
(
'/usr/scripts/
lc_ldap
'
)
sys
.
path
.
append
(
'/usr/scripts/'
)
import
cranslib.deprecated
cranslib
.
deprecated
.
module
()
...
...
@@ -44,13 +44,11 @@ from iptools import AddrInNet, NetSubnets, IpSubnet
from
config
import
NETs
,
mac_komaz
,
mac_wifi
,
mac_titanic
,
p2p
,
vlans
,
debit_max_radin
,
adm_users
,
accueil_route
,
blacklist_sanctions
,
blacklist_sanctions_soft
,
periode_transitoire
import
config.firewall
from
ipset
import
IpsetError
,
Ipset
from
lc_ldap
import
lc_ldap
from
ipt
import
gethostbyname
syslog
.
openlog
(
'firewall'
)
debug
=
1
db
=
crans_ldap
()
QUERY
=
lc_ldap
(
uri
=
'ldap://ldap.adm.crans.org/'
)
class
IptablesError
(
Exception
):
""" Gestion des erreurs d'iptables """
...
...
gestion/gen_confs/populate_sshFingerprint.py
View file @
0922e3c6
...
...
@@ -9,14 +9,14 @@ import hashlib
from
socket
import
gethostname
from
netifaces
import
interfaces
,
ifaddresses
,
AF_INET
sys
.
path
.
append
(
'/usr/scripts/
lc_ldap
'
)
sys
.
path
.
append
(
'/usr/scripts/'
)
sys
.
path
.
append
(
'/usr/scripts/gestion'
)
sys
.
path
.
append
(
'/etc/crans/secrets/'
)
import
lc_ldap
import
lc_ldap
.shortcuts
import
config
conn
=
lc_ldap
.
lc_ldap_admin
()
conn
=
lc_ldap
.
shortcuts
.
lc_ldap_admin
()
ssh_algo
=
config
.
sshfp_algo
.
keys
()
...
...
sip/code_impression.py
View file @
0922e3c6
...
...
@@ -3,12 +3,12 @@
import
sys
from
sh
import
grep
,
ErrorReturnCode_1
sys
.
path
.
append
(
'/usr/scripts/gestion'
)
sys
.
path
.
append
(
'/usr/scripts/
lc_ldap
'
)
sys
.
path
.
append
(
'/usr/scripts/'
)
sys
.
path
.
append
(
'/etc/crans/secrets/'
)
import
lc_ldap
import
lc_ldap
.shortcuts
conn
=
lc_ldap
.
lc_ldap_admin
()
conn
=
lc_ldap
.
shortcuts
.
lc_ldap_admin
()
try
:
aid
=
int
(
sys
.
argv
[
1
][
1
:])
...
...
sip/num_to_callerid.py
View file @
0922e3c6
...
...
@@ -5,10 +5,10 @@
import
sys
import
psycopg2
sys
.
path
.
append
(
'/usr/scripts/gestion'
)
sys
.
path
.
append
(
'/usr/scripts/
lc_ldap
'
)
sys
.
path
.
append
(
'/usr/scripts/'
)
sys
.
path
.
append
(
'/etc/crans/secrets/'
)
import
lc_ldap
import
lc_ldap
.shortcuts
try
:
conn
=
psycopg2
.
connect
(
"dbname='django' user='crans' host='pgsql.adm.crans.org'"
)
...
...
@@ -17,7 +17,7 @@ try:
caller_id
=
cur
.
fetchall
()[
0
][
0
]
if
caller_id
==
'full_name'
or
caller_id
==
'both'
:
conn
=
lc_ldap
.
lc_ldap_admin
()
conn
=
lc_ldap
.
shortcuts
.
lc_ldap_admin
()
aid
=
int
(
sys
.
argv
[
1
][
1
:])
adh
=
conn
.
search
(
'aid=%s'
%
aid
)[
0
]
sys
.
stdout
.
write
(
'%s %s'
%
(
adh
[
'prenom'
][
0
],
adh
[
'nom'
][
0
]))
...
...
sip/sip_multidial.py
View file @
0922e3c6
...
...
@@ -3,13 +3,14 @@
import
sys
,
os
,
hashlib
sys
.
path
.
append
(
'/usr/scripts/gestion'
)
sys
.
path
.
append
(
'/usr/scripts/
lc_ldap
'
)
sys
.
path
.
append
(
'/usr/scripts/'
)
sys
.
path
.
append
(
'/etc/crans/secrets/'
)
import
secrets
,
lc_ldap
import
secrets
import
lc_ldap.shortcuts
from
sh
import
asterisk
conn
=
lc_ldap
.
lc_ldap_admin
()
conn
=
lc_ldap
.
shortcuts
.
lc_ldap_admin
()
def
gen_multidial
(
droit
):
dial
=
"exten => %(droit)s,1,Ringing
\n
exten => %(droit)s,n,Wait(4)
\n
exten => %(droit)s,n,Answer
\n
exten => %(droit)s,n,Dial("
%
{
'droit'
:
droit
}
...
...
sip/user_exist.py
View file @
0922e3c6
...
...
@@ -2,13 +2,14 @@
# -*- coding: utf-8 -*-
import
sys
sys
.
path
.
append
(
'/usr/scripts/gestion'
)
sys
.
path
.
append
(
'/usr/scripts/
lc_ldap
'
)
sys
.
path
.
append
(
'/usr/scripts/'
)
sys
.
path
.
append
(
'/etc/crans/secrets/'
)
import
secrets
,
lc_ldap
import
secrets
import
lc_ldap.shortcuts
conn
=
lc_ldap
.
lc_ldap_admin
()
conn
=
lc_ldap
.
shortcuts
.
lc_ldap_admin
()
try
:
if
len
(
sys
.
argv
[
1
])
==
5
:
aid
=
int
(
sys
.
argv
[
1
][
1
:])
...
...
surveillance/mac_prises/mac_prise_analyzer.py
View file @
0922e3c6
...
...
@@ -15,11 +15,12 @@ import time
sys
.
path
.
append
(
'/usr/scripts/gestion'
)
from
config
import
mac_prise
from
affich_tools
import
tableau
sys
.
path
.
append
(
'/usr/scripts/lc_ldap'
)
import
lc_ldap
sys
.
path
.
append
(
'/usr/scripts/'
)
import
lc_ldap.shortcuts
import
lc_ldap.objets
import
collections
ldap
=
lc_ldap
.
lc_ldap_local
()
ldap
=
lc_ldap
.
shortcuts
.
lc_ldap_local
()
conn
=
psycopg2
.
connect
(
user
=
'crans'
,
database
=
'mac_prises'
)
conn
.
set_session
(
autocommit
=
True
)
...
...
@@ -74,7 +75,7 @@ def genere_comptage(duree):
for
entry
in
fetched
:
machines
=
ldap
.
search
(
'(macAddress=%s)'
%
entry
[
'mac'
])
if
len
(
machines
)
>
0
:
if
isinstance
(
machines
[
0
],
lc_ldap
.
machineWifi
):
if
isinstance
(
machines
[
0
],
lc_ldap
.
objets
.
machineWifi
):
continue
else
:
continue
...
...
Write
Preview
Supports
Markdown
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