New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updated Quota Support to Latest Version of MiaB and resolving code review comments #2387
base: main
Are you sure you want to change the base?
Conversation
Looks like 15-mailbox.conf is just relocated and the script is already updated so it's fine as-is. |
Does not appear to be any reason why https://raw.githubusercontent.com/jrsupplee/mailinabox/master/setup/bootstrap.sh was being used instead of https://mailinabox.email/setup.sh?ping=1 -- my best guess is for reasons of pinning the version |
.gitignore
Outdated
@@ -5,5 +5,6 @@ tools/__pycache__/ | |||
externals/ | |||
.env | |||
.vagrant | |||
.idea/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small change happy to remove if you want
Woops looks like basing off main was a bad idea. Gonna redo this and base instead off of v68 |
f82be1b
to
1795f8a
Compare
So the conflict is trivial to resolve (just bring in the first line of the |
strangely, I get a 500 error the first time I run |
When it 500s after setting the password, it seems it fails to create the admin user. Creating the admin user by hand seems to work?
|
Fixed the 500, it was related to missing the subprocess module. Fixed some conflicts with the spamassassin.sh script also |
I've resolved the conflict -- the remote chadfurman/mailinabox has a somewhat stable and tested version of this tagged as |
@@ -117,6 +123,14 @@ def setup_key_auth(mgmt_uri): | |||
if "admin" in user['privileges']: | |||
print(user['email']) | |||
|
|||
elif sys.argv[1] == "user" and sys.argv[2] == "quota" and len(sys.argv) == 4: | |||
# Set a user's quota |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this comment correct? I don't understand how this sets a user's quota.
Not sure if it helps or not but I've installed this with the v68a 'tag' on my production MiaB server and can confirm it works. Steps I've taken to install it: ssh into your box -
|
echo "CREATE TABLE aliases (id INTEGER PRIMARY KEY AUTOINCREMENT, source TEXT NOT NULL UNIQUE, destination TEXT NOT NULL, permitted_senders TEXT);" | sqlite3 "$db_path"; | ||
echo "CREATE TABLE mfa (id INTEGER PRIMARY KEY AUTOINCREMENT, user_id INTEGER NOT NULL, type TEXT NOT NULL, secret TEXT NOT NULL, mru_token TEXT, label TEXT, FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE);" | sqlite3 "$db_path"; | ||
echo "CREATE TABLE auto_aliases (id INTEGER PRIMARY KEY AUTOINCREMENT, source TEXT NOT NULL UNIQUE, destination TEXT NOT NULL, permitted_senders TEXT);" | sqlite3 "$db_path"; | ||
elif sqlite3 $db_path ".schema users" | grep --invert-match quota; then | ||
echo "ALTER TABLE users ADD COLUMN quota TEXT NOT NULL DEFAULT '0';" | sqlite3 $db_path; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You've opted to make the quota column type TEXT versus making it a numeric column. Just curious if there was a reason for this choice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pretty sure what is stored in sqlite is basically for the webui to 'display' with what is actually set with maildirsize file for dovecot.
Also don't forget this is based on proven code from @jrsupplee, so some of this code is obviously not written by Chad.
@@ -20,10 +20,12 @@ db_path=$STORAGE_ROOT/mail/users.sqlite | |||
# Create an empty database if it doesn't yet exist. | |||
if [ ! -f "$db_path" ]; then | |||
echo "Creating new user database: $db_path"; | |||
echo "CREATE TABLE users (id INTEGER PRIMARY KEY AUTOINCREMENT, email TEXT NOT NULL UNIQUE, password TEXT NOT NULL, extra, privileges TEXT NOT NULL DEFAULT '');" | sqlite3 "$db_path"; | |||
echo "CREATE TABLE users (id INTEGER PRIMARY KEY AUTOINCREMENT, email TEXT NOT NULL UNIQUE, password TEXT NOT NULL, extra, privileges TEXT NOT NULL DEFAULT '', quota TEXT NOT NULL DEFAULT '0');" | sqlite3 $db_path; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand correctly, '0' means unlimited and non-zero represents the quota. But there's no symbolic representation for "system default' from what I can see. So for example, if I made the system default 1GB, then the users would all get their DB value set to 1GB. If I later were to increase the system default to 10GB, the existing users would stay at 1GB and not inherit the new default.
Correct me if I've overlooked something and that's not how it works, but assuming that description is correct, then I'm wondering if the users that are getting the "system default quota" should have a symbolic representation of this in the DB, so if the default were to be changed, these users inherit the new value automatically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quota is not applied, by default so it is basically set to 0. 0 represents "no quota or 'unlimited' quota" (obviously the limit is the size of the hard-drive for miab server.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think my confusion stems from the fact that 0 means unlimited, but I also see a system default-quota
value that can be set, and I'm not sure what role that default value plays in this. How would I set a user to the "default-quota" value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dms00 - Will not having some of these answers prevent this from being merged? Again, code is based on original code from PR - #1568 created by @jrsupplee. Of which we don't have all the answers as to why things were done the original way. Perhaps this was meant for something that wasn't implemented. I do appreciate you reviewing this though. If its required for the PR to be completed we can try to figure out what John was doing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tried to use it but when I set quota and try to send a mail that has attachments to exceed the quota it errors but mail still sent but it didn't saved as sent folder.. How can I prevent that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So you installed the fork, you set a quota. Then you tried to send mail out of that mailbox in order to exceed the quota. It sends the mail, but doesnt save the mail in the sent box.
Am I understanding the above correctly?
You wouldn't prevent that, that is the expected result. Once a user hits a quota that is set, they need to either remove mail from their mailbox, sent folder, trash, etc or things become a bit unstable (by design) you wont be allowed to future things to disk as you exceed the quota.
How can you prevent it, give yourself more quota or delete mail.
Maybe I dont understand correctly though....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You understand correctly but I want to prevent that email sent. If quota is full user shouldn't be able to use it. And what can be do about 1 quota per domain? like example.com has 10GB total quota and every user in it like hi@example.com go@example.com has same quota based on domain but it will not affect to example.net?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay I understand what you would like to see, but I believe this is a limitation of Dovecot / Postfix.
^ @jrsupplee
This PR is an update of #1568 ported to the latest version of MiaB.
TODO: