[apt-keys] On évite de spammer.
This commit is contained in:
parent
46836d8999
commit
60bae0afe6
1 changed files with 6 additions and 10 deletions
|
@ -2,27 +2,24 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
from subprocess import Popen, PIPE, STDOUT
|
from subprocess import Popen, PIPE, STDOUT
|
||||||
import lc_ldap.shortcuts
|
import lc_ldap.shortcuts
|
||||||
from socket import gethostname
|
from socket import gethostname
|
||||||
|
|
||||||
|
|
||||||
keyserver='komaz.adm.crans.org'
|
keyserver='komaz.adm.crans.org'
|
||||||
basedir='/bcfg2/Cfg/etc/crans/apt-keys/'
|
basedir='/bcfg2/Cfg/etc/crans/apt-keys/'
|
||||||
|
|
||||||
|
|
||||||
conn=lc_ldap.shortcuts.lc_ldap_readonly()
|
conn=lc_ldap.shortcuts.lc_ldap_readonly()
|
||||||
nounou=conn.search(u"(&(gpgFingerprint=*)(droits=nounou))")
|
nounou=conn.search(u"(&(gpgFingerprint=*)(droits=nounou))")
|
||||||
fpr=[u['gpgFingerprint'][0].value for u in nounou]
|
fpr=[u['gpgFingerprint'][0].value for u in nounou]
|
||||||
|
|
||||||
def refresh_keys():
|
def refresh_keys():
|
||||||
p = Popen(['gpg', '--keyserver', 'komaz.adm.crans.org', '--recv-keys'] + fpr, stdout=PIPE, stdin=PIPE, stderr=STDOUT)
|
p = Popen(['gpg', '--keyserver', 'komaz.adm.crans.org', '--recv-keys'] + fpr, stdout=PIPE, stdin=PIPE, stderr=STDOUT)
|
||||||
ret=p.communicate()
|
# ret = (stdoutdata, stderrdata) if stdout/stderr sent to PIPE
|
||||||
|
ret = p.communicate()
|
||||||
if ret[1]:
|
if ret[1]:
|
||||||
print ret[1]
|
print >> sys.stderr, ret[1]
|
||||||
if ret[0]:
|
|
||||||
print ret[0]
|
|
||||||
|
|
||||||
|
|
||||||
def write_keys():
|
def write_keys():
|
||||||
for user in nounou:
|
for user in nounou:
|
||||||
|
@ -35,16 +32,15 @@ def write_keys():
|
||||||
p = Popen(['gpg', '--armor', '--export-options', 'export-minimal', '--export', user['gpgFingerprint'][0].value], stdout=PIPE, stdin=PIPE, stderr=STDOUT)
|
p = Popen(['gpg', '--armor', '--export-options', 'export-minimal', '--export', user['gpgFingerprint'][0].value], stdout=PIPE, stdin=PIPE, stderr=STDOUT)
|
||||||
ret=p.communicate()
|
ret=p.communicate()
|
||||||
if ret[1]:
|
if ret[1]:
|
||||||
print ret[1]
|
print >> sys.stderr, ret[1]
|
||||||
if ret[0]:
|
if ret[0]:
|
||||||
with open(path, 'w') as f:
|
with open(path, 'w') as f:
|
||||||
f.write(ret[0])
|
f.write(ret[0])
|
||||||
f.close()
|
f.close()
|
||||||
print "Witten down %s" % path
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
if gethostname() != 'bcfg2':
|
if gethostname() != 'bcfg2':
|
||||||
print "Doit être lancé sur bcfg2"
|
print >> sys.stderr, "Doit être lancé sur bcfg2"
|
||||||
exit(1)
|
exit(1)
|
||||||
else:
|
else:
|
||||||
refresh_keys()
|
refresh_keys()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue