Trying to enter multi line value with zmprov

Discuss your pilot or production implementation with other Zimbra admins or our engineers.
mbd
Advanced member
Advanced member
Posts: 54
Joined: Fri Sep 12, 2014 10:21 pm

Trying to enter multi line value with zmprov

Post by mbd »

Hi,
This is my first post, so before I ask my qn, just wanted to say how impressed I am with Zimbra so far. It's really an incredible piece of software!
My qn is as follows....
I'm trying to figure out a way to import a multiple line value into a user's zimbraMailSieveScript attribute so that they we don't have to use the GUI to enter multiple mail rules.
I understand that the command should be something along the lines of
zmprov ma
But the zimbraMailSieveScript usually looks something like this:
=-=-=-=-=-=-=

zimbraMailSieveScript: require ["fileinto", "reject", "tag", "flag"];
# virus

if anyof (header :contains "to" "virusalert@" )

{

fileinto "/virus";

stop;

}

# phishing

if anyof (header :contains "subject" "hishing" )

{

fileinto "/phishing";

stop;

}

=-=-=-=-=-=-=
Is there a way to refer zmprov to a file to grab the whole value needed? I tried using '
's in case that worked (as suggested in another thread) but that didn't work.
If there's another easy way to set multiple rules, please feel free to let me know. (For example, would doing an ldapmodify directly to the ldap server work?).
Thanks for any assistance that can be offered!
schemers
Outstanding Member
Outstanding Member
Posts: 225
Joined: Fri Sep 12, 2014 9:53 pm

Trying to enter multi line value with zmprov

Post by schemers »

This just worked for me:



zmprov ma user4 zimbraPrefMailSignature a
b
c


and I ended up with:


zimbraPrefMailSignature: a

b

c


This also works:


prov> ma user4 zimbraPrefMailSignature a


b


c


What version are you running?
Ahhhh. What I posted only works with no spaces in the value. This should work:


ma user4 zimbraMailSieveScript '

require ["fileinto", "reject", "tag", "flag"];





# virus


if anyof (header :contains "to" "virusalert@" )


{


fileinto "/virus";


stop;


}


# phishing


if anyof (header :contains "subject" "hishing" )


{


fileinto "/phishing";


stop;


}
'


Note the
at the end of every line, and also note the single quote (') at the beginning and end.
I really need to add support for here-doc like perl:



ma user4 zimbraMailSieveScript <
blah blah

blah blah

EOF

mbd
Advanced member
Advanced member
Posts: 54
Joined: Fri Sep 12, 2014 10:21 pm

Trying to enter multi line value with zmprov

Post by mbd »

Thanks for the very fast reply!
[quote user="schemers"]

What version are you running?

[/QUOTE]
The zcs-NETWORK-4.0.4_GA_457 image for Mac OS X.
[quote user="schemers"]

Ahhhh. What I posted only works with no spaces in the value. This should work:


ma user4 zimbraMailSieveScript '

require ["fileinto", "reject", "tag", "flag"];





# virus


if anyof (header :contains "to" "virusalert@" )


{


fileinto "/virus";


stop;


}


# phishing


if anyof (header :contains "subject" "hishing" )


{


fileinto "/phishing";


stop;


}
'


Note the
at the end of every line, and also note the single quote (') at the beginning and end.

[/QUOTE]
I tried this, but when i run 'zmprov ga userid', the result is;


zimbraMailSieveScript:

require ["fileinto", "reject", "tag", "flag"];





# virus


if anyof (header :contains "to" "virusalert@" )


{


fileinto "/virus";


stop;


}


# phishing


if anyof (header :contains "subject" "hishing" )


{


fileinto "/phishing";


stop;


}



(I.e., I'm getting all the backslashes and the 'n's in there as well).
I've not tested to see whether or not the existance of the
's negatively affect the operations or not yet though.
[quote user="schemers"]

I really need to add support for here-doc like perl:



ma user4 zimbraMailSieveScript <
blah blah

blah blah

EOF

[/QUOTE]
That'd be nice :)
mbd
Advanced member
Advanced member
Posts: 54
Joined: Fri Sep 12, 2014 10:21 pm

Trying to enter multi line value with zmprov

Post by mbd »

Yeah, doesn't seem to be parsed well with those
's - when I login as the user and look at the mail filters, I get an 'A network service error has occurred' popup box with the following error report:


msg - system failure: org.apache.jsieve.parser.generated.TokenMgrError: Lexical error at line 1, column 1. Encountered: "\" (92), after : ""

com.zimbra.cs.service.ServiceException: system failure: org.apache.jsieve.parser.generated.TokenMgrError: Lexical error at line 1, column 1. Encountered: "\" (92), after : ""

at com.zimbra.cs.service.ServiceException.FAILURE(ServiceException.java:174)

at com.zimbra.soap.SoapEngine.dispatchRequest(SoapEngine.java:272)

at com.zimbra.soap.SoapEngine.dispatch(SoapEngine.java:162)

at com.zimbra.soap.SoapEngine.dispatch(SoapEngine.java:84)

at com.zimbra.soap.SoapServlet.doPost(SoapServlet.java:223)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)

at com.zimbra.cs.servlet.ZimbraServlet.service(ZimbraServlet.java:173)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)

at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)

at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:541)

at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)

at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)

at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:667)

at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)

at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)

at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)

at java.lang.Thread.run(Thread.java:613)

Caused by: org.apache.jsieve.parser.generated.TokenMgrError: Lexical error at line 1, column 1. Encountered: "\" (92), after : ""

at org.apache.jsieve.parser.generated.SieveParserTokenManager.getNextToken(SieveParserTokenManager.java:616)

at org.apache.jsieve.parser.generated.SieveParser.jj_ntk(SieveParser.java:562)

at org.apache.jsieve.parser.generated.SieveParser.commands(SieveParser.java:64)

at org.apache.jsieve.parser.generated.SieveParser.start(SieveParser.java:20)

at org.apache.jsieve.SieveFactory.parse(SieveFactory.java:89)

at com.zimbra.cs.filter.RuleManager.parse(RuleManager.java:218)

at com.zimbra.cs.filter.RuleManager.getRulesAsXML(RuleManager.java:124)

at com.zimbra.cs.service.mail.GetRules.handle(GetRules.java:51)

at com.zimbra.soap.SoapEngine.dispatchRequest(SoapEngine.java:261)

... 21 more
code - service.FAILURE

method - ZmCsfeCommand.prototype.invoke

detail - soap:Receiver

mbd
Advanced member
Advanced member
Posts: 54
Joined: Fri Sep 12, 2014 10:21 pm

Trying to enter multi line value with zmprov

Post by mbd »

I think I've worked around the problem...
from the command line, I typed:


zmprov ma userid zimbraMailSieveScript 'require ["fileinto", "reject", "tag", "flag"];CTRL-J
# virus

if anyof (header :contains "to" "virusalert@" )

{

fileinto "/virus";

stop;

}

# phishing

if anyof (header :contains "subject" "hishing" )

{

fileinto "/phishing";

stop;

}

'


(Note the CTRL-J at the end of the first line. After that, cutting and pasting multiple lines seems to be fine and the final "'" at the end submits the command.
Now I see the filters if I login as the user and look at the mail filters. I'll have to do some testing to ensure that the rules are actually working etc, but this is close if not the actual solution...
schemers
Outstanding Member
Outstanding Member
Posts: 225
Joined: Fri Sep 12, 2014 9:53 pm

Trying to enter multi line value with zmprov

Post by schemers »

Strange. I could have sworn support for
has been in for quite a long time. I think I only recently added support for a trailing (along with an option to read input from a file).
On my system (basically 4.5rc1 which is being released shortly), I cut-and-paste that example and it worked fine.
Are you running:


zmprov ma ...


or:


zmprov

prov> ma ...


Definitely should be doing the later.
Krishopper
Outstanding Member
Outstanding Member
Posts: 769
Joined: Fri Sep 12, 2014 10:23 pm

Trying to enter multi line value with zmprov

Post by Krishopper »

What else needs to be done to "sync" this to the UI?

I attempted to add a massive list of filtering rules for mailing lists using this, and verified it went in place with "zmprov ga" and all was there and to my best knowledge with proper syntax as well. i went into Preferences/Filters in the UI and none of the new stuff was there. I added a test rule in the UI, and it overwrote everything I imported with "zmprov ma" back to its original rule set plus the temporary rule I put in place.
[quote user="schemers"]

Ahhhh. What I posted only works with no spaces in the value. This should work:


ma user4 zimbraMailSieveScript '

require ["fileinto", "reject", "tag", "flag"];





# virus


if anyof (header :contains "to" "virusalert@" )


{


fileinto "/virus";


stop;


}


# phishing


if anyof (header :contains "subject" "hishing" )


{


fileinto "/phishing";


stop;


}
'


Note the
at the end of every line, and also note the single quote (') at the beginning and end.

[/quote]
bobby
Outstanding Member
Outstanding Member
Posts: 515
Joined: Fri Sep 12, 2014 10:01 pm

Trying to enter multi line value with zmprov

Post by bobby »

try reloading the web client
schemers
Outstanding Member
Outstanding Member
Posts: 225
Joined: Fri Sep 12, 2014 9:53 pm

Trying to enter multi line value with zmprov

Post by schemers »

It was also recently brought to our attention that the server is caching parsed rules and might not detect a change made directly to zimbraMailSieveScript until a server restart.
The web client goes through the rules SOAP interface, which will update the client.
Note that I'm in the process of adding filter rule support to zmmailbox, so that instead of trying to edit the filter rules as a script, you'll be able to do something like:


/opt/zimbra/bin/zmprov

prov> sm user1

mailbox: user1@slapshot.liquidsys.com, size: 8.16 MB, messages: 251, unread: 3

mbox user1@slapshot.liquidsys.com> afrl phishing header subject contains hishing fileinto "/phishing" stop

mbox user1@slapshot.liquidsys.com>


this goes through the SOAP interface, as well as only generates rules that the web UI can display correctly.
Hoping to get this into 4.5.1.
Krishopper
Outstanding Member
Outstanding Member
Posts: 769
Joined: Fri Sep 12, 2014 10:23 pm

Trying to enter multi line value with zmprov

Post by Krishopper »

[quote user="17224bobby"]try reloading the web client[/QUOTE]
I did that. I logged out and logged back in, including trying a different browser. Up until I tried to add a new filter through the web client, the rules were still set in zimbraMailSieveScript.
What you're saying is that *just* changing zimbraMailSieveScript will be all that needs to be done, including making the new rules show up on the web client? If so, I will do some more dinking around and see if I can figure out what's going on.
Post Reply