Commit 8baac337 authored by Vincent Le gallic's avatar Vincent Le gallic

Possibilité de déclarer le serveur comme read-only

parent 81233f5b
......@@ -12,7 +12,7 @@ import datetime
from email.mime.text import MIMEText
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]
if MYUID == 'root':
......@@ -153,11 +153,15 @@ def notification(subject,corps,fname,old):
conn.sendmail(frommail,tomail,msg.as_string())
conn.quit()
WRITE_COMMANDS = ["putfile", "rmfile"]
if __name__ == "__main__":
argv = sys.argv[1:]
if len(argv) not in [1, 2]:
sys.exit(1)
command = argv[0]
if READONLY and command in WRITE_COMMANDS:
raise IOError("Ce serveur est read-only.")
filename = None
try:
filename = argv[1]
......
......@@ -10,6 +10,9 @@ Dans le futur, sera remplacé par une connexion ldap.
STORE = '/root/cranspasswords/db/'
""" 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>"
""" Expéditeur du mail de notification """
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment