[PATCH 3/3] cyradm: add support to set private annotations

Norbert Warmuth now at arcor.de
Sun Mar 29 13:34:34 EDT 2015


Extend the mboxconfig command with an optional attributename
parameter. It can be use to overwrite the default attribute name
and prefix "value.shared" with "value.priv".

As "/<explicit annotation" this provides access to a very low level
SETANNOTATION protocol functionality. It can be used to workaround
missing RFC 5464 (The IMAP METADATA Extension) support in Cyrus:IMAP
and cyradm.

Examples:
   mboxconfig "INBOX.Trash" /specialuse \\Trash value.priv
---
 perl/imap/IMAP/Admin.pm | 11 ++++++-----
 perl/imap/IMAP/Shell.pm |  4 ++--
 perl/imap/cyradm.sh     |  8 ++++++--
 3 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/perl/imap/IMAP/Admin.pm b/perl/imap/IMAP/Admin.pm
index 42cd660..958a1de 100644
--- a/perl/imap/IMAP/Admin.pm
+++ b/perl/imap/IMAP/Admin.pm
@@ -817,7 +817,7 @@ sub getinfo {
 *info = *getinfo;
 
 sub mboxconfig {
-  my ($self, $mailbox, $entry, $value) = @_;
+  my ($self, $mailbox, $entry, $value, $attribname) = @_;
 
   my %values = ( "comment" => "/comment",
 		 "expire" => "/vendor/cmu/cyrus-imapd/expire",
@@ -841,15 +841,16 @@ sub mboxconfig {
   my ($rc, $msg);
 
   $value = undef if($value eq "none");
+  $attribname = "value.shared" unless defined ($attribname);
 
   if(defined($value)) {
     ($rc, $msg) = $self->send('', '',
-			      "SETANNOTATION %q %q (\"value.shared\" %q)",
-		              $mailbox, $entry, $value);
+			      'SETANNOTATION %q %q (%q %q)',
+		              $mailbox, $entry, $attribname, $value);
   } else {
     ($rc, $msg) = $self->send('', '',
-                              "SETANNOTATION %q %q (\"value.shared\" NIL)",
-		              $mailbox, $entry);
+                              'SETANNOTATION %q %q (%q NIL)',
+		              $mailbox, $entry, $attribname);
   }
 
   if ($rc eq 'OK') {
diff --git a/perl/imap/IMAP/Shell.pm b/perl/imap/IMAP/Shell.pm
index 05a12d4..5c0d982 100644
--- a/perl/imap/IMAP/Shell.pm
+++ b/perl/imap/IMAP/Shell.pm
@@ -1475,7 +1475,7 @@ sub _sc_mboxcfg {
   while (defined ($opt = shift(@argv))) {
     last if $opt eq '--';
     if ($opt =~ /^-/) {
-      die "usage: mboxconfig mailbox [comment|expire|news2mail|pop3showafter|sharedseen|sieve|squat|/<explicit annotation>] value\n";
+      die "usage: mboxconfig mailbox [comment|expire|news2mail|pop3showafter|sharedseen|sieve|squat|/<explicit annotation>] value [attributename]\n";
     }
     else {
       push(@nargv, $opt);
@@ -1484,7 +1484,7 @@ sub _sc_mboxcfg {
   }
   push(@nargv, @argv);
   if (@nargv < 2) {
-    die "usage: mboxconfig mailbox [comment|expire|news2mail|pop3showafter|sharedseen|sieve|squat|/<explicit annotation>] value\n";
+    die "usage: mboxconfig mailbox [comment|expire|news2mail|pop3showafter|sharedseen|sieve|squat|/<explicit annotation>] value [attributename]\n";
   }
   if (!$cyrref || !$$cyrref) {
     die "mboxconfig: no connection to server\n";
diff --git a/perl/imap/cyradm.sh b/perl/imap/cyradm.sh
index a532a7b..b8b03f4 100644
--- a/perl/imap/cyradm.sh
+++ b/perl/imap/cyradm.sh
@@ -197,11 +197,15 @@ find the quota root for a mailbox.
 
 show quota roots and quotas for mailbox
 
-=item C<mboxconfig> I<mailbox> I<attribute> I<value>
+=item C<mboxconfig> I<mailbox> I<attribute> I<value> [I<attributname>]
 
-=item C<mboxcfg> I<mailbox> I<attribute> I<value>
+=item C<mboxcfg> I<mailbox> I<attribute> I<value> [I<attributname>]
 
 Set mailbox metadata.  A value of "none" will remove the attribute.
+The optional attributname allows to switch from the default attribute
+name and prefix "value.shared" to "value.priv" which is required to
+set for example the /specialuse annotation on a mailbox.
+
 The currently supported attributes are:
 
 =over 4
-- 
2.1.4




More information about the Cyrus-devel mailing list