Page 1 of 1

Error: mail alias foo exist

Posted: Fri Dec 13, 2013 4:48 am
by hrabbit
Hi everybody,

Just started using VestaCP and so far, loving it. However, ran across an issue when populating alias entries.

I can populate an account with entries like

Code: Select all

foo
bar
baz
Which works perfecly fine, however I can't do the following for some reason

Code: Select all

foo.bar
foo.baz
foo
The last entry causes a "Error: mail alias foo exist" error in the interface. I'm hoping this is reproduce-able by others and more importantly, if this is easy to correct or should I start hacking the domains.sh file to get around it?

Thanks in advance

Re: Error: mail alias foo exist

Posted: Fri Dec 13, 2013 10:23 am
by skid
I'll check it and get back to you soon.

Re: Error: mail alias foo exist

Posted: Sat Dec 14, 2013 3:46 am
by hrabbit
skid wrote:I'll check it and get back to you soon.
Thanks, looking forward to it.

Re: Error: mail alias foo exist

Posted: Sat Dec 14, 2013 1:57 pm
by hrabbit
Hi Skid,

Testing this further, it appears that "grep -w" seems to match words even with commas (Even though man states "Word-constituent characters are letters, digits, and the underscore.").

I have played a little and the best solution I can come up with is to perform the following. (Only tested on Debian Wheezy (7))

Code: Select all

# diff -Naur domain.sh.original domain.sh
--- domain.sh.original	2013-12-15 00:33:36.000000000 +1100
+++ domain.sh	2013-12-15 00:54:02.000000000 +1100
@@ -145,8 +145,8 @@
         log_event "$E_EXISTS" "$EVENT"
         exit $E_EXISTS
     fi
-    check_als=$(awk -F "ALIAS='" '{print $2}' $USER_DATA/mail/$domain.conf )
-    check_als=$(echo "$check_als" | cut -f 1 -d "'" | grep -w $1)
+    check_als=$(awk -F "ALIAS='" '{print $2}' $USER_DATA/mail/$domain.conf |\
+	      awk -F "'" '{print $1}' | tr "," "\n" | grep ^$1$ )
     if [ ! -z "$check_als" ]; then
         echo "Error: mail alias $1 exist"
         log_event "$E_EXISTS" "$EVENT"
Not sure on the overhead with very large lists (mine has 158 records) and I personally don't like chaining awk into awk but ya get that.

As a note, however, this does produce a correct result in my testing.

Re: Error: mail alias foo exist

Posted: Wed Dec 18, 2013 7:24 pm
by skid
Thanks for the research hrabbit. I've tried to reproduce the error on a fresh Debian 7.1 and it seem to be resolved with the new version of grep
grep (GNU grep) 2.12

Can you please check your current version and let me know if it's lower that 2.12.
Thank you

Re: Error: mail alias foo exist

Posted: Wed Dec 18, 2013 9:49 pm
by hrabbit
Hi Skid,

Just checked my system. (Reverted my changes first).

Performed the norm, update, dist-upgrade, etc. the problem is still present.

I'm running an OpenVZ (Proxmox) container for this and it's not referring to 7.1, just 7. However...

Code: Select all

# grep --version
grep (GNU grep) 2.12

Code: Select all

# cat /etc/issue.net 
Debian GNU/Linux 7
If it works properly in a standalone system but not in a container, not sure where that leaves this problem to be honest. Also, even changing to my code, there isn't anything to say it works in RH(and forks)

Re: Error: mail alias foo exist

Posted: Wed Dec 18, 2013 9:53 pm
by skid
It's weird. OpenVZ shouldn't affect the system. Can you still reproduce the error with latest grep?
Original domain function can be downloaded from githab

Re: Error: mail alias foo exist

Posted: Wed Dec 18, 2013 10:36 pm
by hrabbit
skid wrote:It's weird. OpenVZ shouldn't affect the system.
Absolutely!
skid wrote:Can you still reproduce the error with latest grep?
Original domain function can be downloaded from githab
That last test was with the original file in place. I just checked over the same function in github and it certainly matches my original copy that's currently in place.

Just as a point of interest however, even though I performed an upgrade first, the grep version was already 2.12.

Re: Error: mail alias foo exist

Posted: Thu Dec 19, 2013 7:07 am
by skid
I'm not entirely sure, does it work after upgrade?

Re: Error: mail alias foo exist

Posted: Thu Dec 19, 2013 7:33 am
by hrabbit
skid wrote:I'm not entirely sure, does it work after upgrade?
Nope, same scenario. Exact same error.

Using the default code, I have added the following aliases to an account.

foo.bar
foo.baz

Code: Select all

# dpkg -l grep
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name           Version      Architecture Description
+++-==============-============-============-=================================
ii  grep           2.12-2       amd64        GNU grep, egrep and fgrep
Then, running the following (default as extracted from domains.sh), I get the following

Code: Select all

# grep --version
grep (GNU grep) 2.12
...
# awk -F "ALIAS='" '{print $2}' /usr/local/vesta/data/users/scott/mail/comsetic.net.conf | cut -f 1 -d "'" | grep -w bar
bar.bar,bar.baz
#
As far as I know grep -w should have produced no result, however that returned both results.

This produced the correct result of course (slight variation on my original post).

Code: Select all

# awk -F "ALIAS='" '{print $2}' /usr/local/vesta/data/users/scott/mail/comsetic.net.conf | cut -f 1 -d "'" | tr "," "\n" |grep ^bar$
#
I have an urge to install a Ubuntu 12.04 instance just to see if it performs the same way to be honest. If that would be of interest, please let me know.