Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f9014b84 authored by Felix Ableitner's avatar Felix Ableitner
Browse files

Check for forbidden usernames

parent 3ac449f8
Loading
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -8,7 +8,6 @@ COPY app/requirements.txt .

RUN apk add --no-cache openssl \
 && apk add --no-cache --virtual build-deps build-base libffi-dev openssl-dev \
 && pip install --upgrade pip \
 && pip install --no-cache-dir -r requirements.txt \
 && apk del build-deps

+23 −0
Original line number Diff line number Diff line
abuse
hostmaster
postmaster
webmaster
postmaster
root
sendmail
postfix
contact
info
sales
marketing
news
newsletter
eelo
job
jobs
career
admin
legal
apache
postfix
mysql
 No newline at end of file
+6 −1
Original line number Diff line number Diff line
@@ -39,12 +39,17 @@ class MyHandler(BaseHTTPRequestHandler):
                       fallback_email: str, # new parameter
                       nextcloud_quota: str # new parameter
                       ):
        target_username = target_email.split('@')[0]
        with open('forbidden_usernames') as f:
            if target_username in f.read().splitlines():
                self.respond(403, 'this username is not allowed')
                return
        # create account via postfixadmin ssh
        ssh = paramiko.SSHClient()
        ssh.set_missing_host_key_policy(paramiko.MissingHostKeyPolicy)
        ssh.connect(hostname='postfixadmin', username='pfexec', password=os.environ['POSTFIXADMIN_SSH_PASSWORD'])
        ftp = ssh.open_sftp()
        temp_file_name = '/tmp/' + target_email.split('@')[0] + '-details'
        temp_file_name = '/tmp/' + target_username + target_email.split('@')[0] + '-details'
        temp_file = ftp.file(temp_file_name, 'w')
        temp_file.writeln(target_email)
        temp_file.writeln(password)