Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mffzoom
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
wizards
mffzoom
Commits
1adb5df1
Commit
1adb5df1
authored
3 years ago
by
Martin Mareš
Browse files
Options
Downloads
Patches
Plain Diff
Added a Sieve filter for automatic processing of login codes
parent
5991fa72
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
code/README
+4
-0
4 additions, 0 deletions
code/README
code/zoom-code
+52
-0
52 additions, 0 deletions
code/zoom-code
with
56 additions
and
0 deletions
code/README
0 → 100644
+
4
−
0
View file @
1adb5df1
Copy zoom-code to /usr/local/lib/dovecot/sieve-pipe/, so that it can be
executed by Sieve.
Set up Sieve to pipe e-mail with the right subject to this filter.
This diff is collapsed.
Click to expand it.
code/zoom-code
0 → 100755
+
52
−
0
View file @
1adb5df1
#!/usr/bin/python3
# Sieve pipe handler for processing Zoom login codes
import
email
import
email.policy
import
os
import
re
import
subprocess
import
sys
import
syslog
from
tempfile
import
NamedTemporaryFile
def
fail
(
msg
):
syslog
.
syslog
(
syslog
.
LOG_ERR
,
msg
)
sys
.
exit
(
0
)
def
mumble
(
msg
):
syslog
.
syslog
(
syslog
.
LOG_INFO
,
msg
)
def
main
():
msg
=
email
.
message_from_file
(
sys
.
stdin
,
policy
=
email
.
policy
.
default
)
to
=
msg
.
get
(
'
To
'
,
""
)
m
=
re
.
match
(
'
(zoom(-m)?-[0-9]{1,2})@
'
,
to
)
if
not
m
:
fail
(
'
Cannot determine recipient account
'
)
user
=
m
[
1
]
body
=
msg
.
get_body
()
body_ct
=
body
.
get_content_type
()
if
body_ct
==
'
text/html
'
:
tmpf
=
NamedTemporaryFile
(
mode
=
'
w
'
)
tmpf
.
write
(
body
.
get_content
())
tmpf
.
flush
()
res
=
subprocess
.
run
([
'
/usr/bin/lynx
'
,
'
-force_html
'
,
'
-nolist
'
,
'
-display_charset=utf-8
'
,
'
-dump
'
,
tmpf
.
name
],
stdout
=
subprocess
.
PIPE
,
text
=
True
)
if
res
.
returncode
!=
0
:
fail
(
f
'
Subprocess failed with return code
{
res
.
returncode
}
'
)
out
=
res
.
stdout
else
:
out
=
body
.
get_content
()
os
.
umask
(
0o022
)
with
open
(
f
"
/srv/mffzoom/code/www/
{
user
}
.txt
"
,
"
w
"
)
as
f
:
f
.
write
(
out
)
try
:
syslog
.
openlog
(
'
zoom-code
'
)
main
()
mumble
(
'
Login code stored
'
)
except
Exception
as
e
:
fail
(
str
(
e
))
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment