Possibilité de déclarer le serveur comme read-only
This commit is contained in:
parent
81233f5b54
commit
8baac3374c
2 changed files with 8 additions and 1 deletions
|
@ -12,7 +12,7 @@ import datetime
|
||||||
from email.mime.text import MIMEText
|
from email.mime.text import MIMEText
|
||||||
from email.mime.multipart import MIMEMultipart
|
from email.mime.multipart import MIMEMultipart
|
||||||
|
|
||||||
from serverconfig import CRANSP_MAIL, DEST_MAIL, KEYS, ROLES, STORE
|
from serverconfig import READONLY, CRANSP_MAIL, DEST_MAIL, KEYS, ROLES, STORE
|
||||||
|
|
||||||
MYUID = pwd.getpwuid(os.getuid())[0]
|
MYUID = pwd.getpwuid(os.getuid())[0]
|
||||||
if MYUID == 'root':
|
if MYUID == 'root':
|
||||||
|
@ -153,11 +153,15 @@ def notification(subject,corps,fname,old):
|
||||||
conn.sendmail(frommail,tomail,msg.as_string())
|
conn.sendmail(frommail,tomail,msg.as_string())
|
||||||
conn.quit()
|
conn.quit()
|
||||||
|
|
||||||
|
WRITE_COMMANDS = ["putfile", "rmfile"]
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
argv = sys.argv[1:]
|
argv = sys.argv[1:]
|
||||||
if len(argv) not in [1, 2]:
|
if len(argv) not in [1, 2]:
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
command = argv[0]
|
command = argv[0]
|
||||||
|
if READONLY and command in WRITE_COMMANDS:
|
||||||
|
raise IOError("Ce serveur est read-only.")
|
||||||
filename = None
|
filename = None
|
||||||
try:
|
try:
|
||||||
filename = argv[1]
|
filename = argv[1]
|
||||||
|
|
|
@ -10,6 +10,9 @@ Dans le futur, sera remplacé par une connexion ldap.
|
||||||
STORE = '/root/cranspasswords/db/'
|
STORE = '/root/cranspasswords/db/'
|
||||||
""" Répertoire de stockage """
|
""" Répertoire de stockage """
|
||||||
|
|
||||||
|
READONLY = False
|
||||||
|
""" Ce serveur est-il read-only (on ne peut pas y modifier les mots de passe) """
|
||||||
|
|
||||||
CRANSP_MAIL = "cranspasswords <root@crans.org>"
|
CRANSP_MAIL = "cranspasswords <root@crans.org>"
|
||||||
""" Expéditeur du mail de notification """
|
""" Expéditeur du mail de notification """
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue