Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Trying to enter multi line value with zmprov

  1. #1
    mbd
    mbd is offline Senior Member
    Join Date
    Dec 2006
    Location
    Melbourne, AU
    Posts
    58
    Rep Power
    8

    Default Trying to enter multi line value with zmprov

    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 <accountname> <attribute> <value>

    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 '\n'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!

  2. #2
    schemers is offline Zimbra Employee
    Join Date
    Aug 2005
    Posts
    228
    Rep Power
    9

    Default

    This just worked for me:
    Code:
    zmprov ma user4 zimbraPrefMailSignature a\nb\nc
    and I ended up with:

    Code:
    zimbraPrefMailSignature: a
    b
    c
    This also works:

    Code:
    prov> ma user4 zimbraPrefMailSignature a\n\
    b\n\
    c
    What version are you running?

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

    Code:
    ma user4 zimbraMailSieveScript '\
    require ["fileinto", "reject", "tag", "flag"];\n\
    \n\
    # virus\n\
    if anyof (header :contains "to" "virusalert@" )\n\
    {\n\
    fileinto "/virus";\n\
    stop;\n\
    }\n\
    # phishing\n\
    if anyof (header :contains "subject" "hishing" )\n\
    {\n\
    fileinto "/phishing";\n\
    stop;\n\
    }\n'
    Note the \n\ 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:
    Code:
    ma user4 zimbraMailSieveScript <<EOF;
    blah blah
    blah blah
    EOF
    Last edited by schemers; 12-15-2006 at 04:39 PM. Reason: update answer
    Bugzilla - Wiki - Downloads - Before posting... Search!

  3. #3
    mbd
    mbd is offline Senior Member
    Join Date
    Dec 2006
    Location
    Melbourne, AU
    Posts
    58
    Rep Power
    8

    Default

    Thanks for the very fast reply!

    Quote Originally Posted by schemers View Post
    What version are you running?
    The zcs-NETWORK-4.0.4_GA_457 image for Mac OS X.

    Quote Originally Posted by schemers View Post
    Ahhhh. What I posted only works with no spaces in the value. This should work:

    Code:
    ma user4 zimbraMailSieveScript '\
    require ["fileinto", "reject", "tag", "flag"];\n\
    \n\
    # virus\n\
    if anyof (header :contains "to" "virusalert@" )\n\
    {\n\
    fileinto "/virus";\n\
    stop;\n\
    }\n\
    # phishing\n\
    if anyof (header :contains "subject" "hishing" )\n\
    {\n\
    fileinto "/phishing";\n\
    stop;\n\
    }\n'
    Note the \n\ at the end of every line, and also note the single quote (') at the beginning and end.
    I tried this, but when i run 'zmprov ga userid', the result is;

    Code:
    zimbraMailSieveScript: \
    require ["fileinto", "reject", "tag", "flag"];\n\
    \n\
    # virus\n\
    if anyof (header :contains "to" "virusalert@" )\n\
    {\n\
    fileinto "/virus";\n\
    stop;\n\
    }\n\
    # phishing\n\
    if anyof (header :contains "subject" "hishing" )\n\
    {\n\
    fileinto "/phishing";\n\
    stop;\n\
    }\n
    (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 \n's negatively affect the operations or not yet though.

    Quote Originally Posted by schemers View Post
    I really need to add support for here-doc like perl:
    Code:
    ma user4 zimbraMailSieveScript <<EOF;
    blah blah
    blah blah
    EOF
    That'd be nice

  4. #4
    mbd
    mbd is offline Senior Member
    Join Date
    Dec 2006
    Location
    Melbourne, AU
    Posts
    58
    Rep Power
    8

    Default

    Yeah, doesn't seem to be parsed well with those \n'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:

    Code:
    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

  5. #5
    mbd
    mbd is offline Senior Member
    Join Date
    Dec 2006
    Location
    Melbourne, AU
    Posts
    58
    Rep Power
    8

    Default Workaround!

    I think I've worked around the problem...

    from the command line, I typed:

    Code:
    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...

  6. #6
    schemers is offline Zimbra Employee
    Join Date
    Aug 2005
    Posts
    228
    Rep Power
    9

    Default

    Strange. I could have sworn support for \n 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:

    Code:
    zmprov ma ...
    or:

    Code:
    zmprov
    prov> ma ...
    Definitely should be doing the later.
    Bugzilla - Wiki - Downloads - Before posting... Search!

  7. #7
    Krishopper is offline Dedicated Member
    Join Date
    Dec 2006
    Location
    Minneapolis MN
    Posts
    777
    Rep Power
    9

    Default

    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 Originally Posted by schemers View Post
    Ahhhh. What I posted only works with no spaces in the value. This should work:

    Code:
    ma user4 zimbraMailSieveScript '\
    require ["fileinto", "reject", "tag", "flag"];\n\
    \n\
    # virus\n\
    if anyof (header :contains "to" "virusalert@" )\n\
    {\n\
    fileinto "/virus";\n\
    stop;\n\
    }\n\
    # phishing\n\
    if anyof (header :contains "subject" "hishing" )\n\
    {\n\
    fileinto "/phishing";\n\
    stop;\n\
    }\n'
    Note the \n\ at the end of every line, and also note the single quote (') at the beginning and end.

  8. #8
    bobby is offline Zimbra Employee
    Join Date
    Nov 2005
    Posts
    518
    Rep Power
    10

    Default

    try reloading the web client

  9. #9
    schemers is offline Zimbra Employee
    Join Date
    Aug 2005
    Posts
    228
    Rep Power
    9

    Default

    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:

    Code:
    /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.
    Bugzilla - Wiki - Downloads - Before posting... Search!

  10. #10
    Krishopper is offline Dedicated Member
    Join Date
    Dec 2006
    Location
    Minneapolis MN
    Posts
    777
    Rep Power
    9

    Default

    Quote Originally Posted by bobby View Post
    try reloading the web client
    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.

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Spam training problem...
    By TaskMaster in forum Installation
    Replies: 2
    Last Post: 05-08-2007, 09:49 AM
  2. Replies: 9
    Last Post: 04-14-2007, 08:31 AM
  3. Replies: 18
    Last Post: 03-20-2006, 02:22 PM
  4. M3 problem with shares
    By titangears in forum Users
    Replies: 4
    Last Post: 01-12-2006, 01:01 PM
  5. Replies: 13
    Last Post: 10-31-2005, 04:22 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •