Managing Shared Folders

Here's some notes about making Shared Folder under Cyrus, with instructions for restricting access to everyone else.
# cyradm --user cyrus localhost
IMAP Password: <----- (Get the password from ISPMan Admins)
localhost> cm Shared
localhost> cm Shared.Lists
localhost> cm Shared.Lists.ispman-users    <--- creating a few mailboxes
localhost> sam Shared.Lists user_example_com lrswipcda
localhost> sam Shared.Lists.ispman-users user_example_com lrswipcda
localhost> sam Shared anyone none <-- prevent everyone else from seeing the group
localhost> sam Shared.Lists anyone none <-- prevent everyone else from seeing the group
Here's a little script that can make "cut-n-paste" Permissions for a group of users. I *think* you can also use group permissions, however, I've never done that.

#!/bin/bash
#Sets up shared folder permissions "worklist" suitable for cut and paste inside cyradm
#This is just a quick hack, I'm sure someone has a better one.
#Edit the users with all the users, set the perms if you want more restrictive acess  
#Make sure you have already created the mailboxes
perms="lrswipcda"
for user in user_example_com user2_example_com user3_example_com
do
  echo "sam Shared.Admin $user $perms"
  echo "sam Shared.Alerts $user $perms"
  echo "sam Shared.Alerts.Cron $user $perms"
  echo "sam Shared.Alerts.backuplogs $user $perms"
done
exit 0

Bulk Erasing Email In Cyrus

Cyrus stores emails in directories and files that look like this: (email #'s and directories)
/var/spool/cyrus/mail/u/user/user_example_com# ls
14937.  4682.  4914.  5227.  5689.  5782.  6124.  6445.  6652.  6935.  7095.         personal
19468.  4700.  4919.  5254.  5690.  5786.  6128.  6446.  6656.  6937.  7100.         drafts
20469.  4708.  4921.  5301.  5691.  5788.  6147.  6520.  6699.  6938.  7118.         work
22236.  4710.  4975.  5306.  5693.  5817.  6158.  6524.  6732.  6940.  7121.         mailing
26910.  4725.  4980.  5317.  5694.  5818.  6170.  6546.  6758.  6943.  7127.         nagios
28206.  4750.  4983.  5325.  5700.  5819.  6172.  6547.  6763.  6950.  7130.         network status
32961.  4763.  4984.  5353.  5711.  5845.  6187.  6548.  6764.  6955.  7132.         office
34414.  4765.  4986.  5358.  5712.  5857.  6188.  6549.  6792.  6976.  7134.         open-source
34416.  4772.  4987.  5371.  5715.  5864.  6215.  6553.  6793.  6984.  7135.         private
35178.  4775.  4988.  5374.  5718.  5875.  6218.  6562.  6797.  6985.  7147.         research
35179.  4781.  4999.  5462.  5719.  5880.  6226.  6568.  6799.  6995.  7148.         sales
4499.   4793.  5002.  5464.  5721.  5882.  6229.  6571.  6805.  6998.  7149.         Sent
4549.   4799.  5011.  5469.  5726.  5915.  6269.  6572.  6825.  7028.  7150.         Sent items
4617.   4800.  5014.  5470.  5728.  5916.  6307.  6573.  6846.  7030.  7152.         sent-mail
4621.   4801.  5142.  5582.  5736.  5930.  6343.  6574.  6852.  7034.  7153.         Spam
4648.   4804.  5166.  5587.  5738.  5958.  6352.  6577.  6853.  7043.  7154.         supplier
4651.   4807.  5167.  5606.  5743.  6022.  6385.  6578.  6854.  7046.  7155.         Trash
4653.   4808.  5189.  5643.  5746.  6066.  6388.  6580.  6855.  7051.  Clients       voip
4658.   4810.  5197.  5647.  5749.  6067.  6389.  6582.  6858.  7057.  cyrus.cache
4663.   4815.  5198.  5650.  5753.  6074.  6396.  6608.  6859.  7059.  cyrus.header
4664.   4823.  5215.  5651.  5756.  6094.  6423.  6618.  6862.  7062.  cyrus.index
4665.   4844.  5216.  5668.  5780.  6112.  6425.  6639.  6893.  7087.  development
After you directly touch the cyrus file system (using rm, cp, etc), you must reconstruct the mail box.

I deleted a bunch of emails like this:

  #sudo bash
  #cd /var/spool/cyrus/mail/p/user/pkoegel_azxws_com   <-- go to user's INBOX directory

  #grep -l somespammer@somewhere.com * > kill
     (delete emails containing somespammer)

  #sed 's/^/rm /' kill > step1
      (add rm to each line)

  #chmod +x step1
  #./step1

    (make it executable and run it)

Then rebuild their email box like so:
   $sudo su - cyrus
   $./reconstruct user.user_example_com
   $./reconstruct user.user_example_com.*

Sieve Notes

Sieve has crashed on me whenever I run out of disk space. Once I got the disk space under control, I had to rebuild the sieve databases.

Can't Mark Items as Seen

I've seen this a few times The logs showed this:
cyrus/imapd[21076]: DBERROR: opening /var/lib/cyrus/user/u/user_example_com.seen: cyrusdb error
cyrus/imapd[21076]: DBERROR: skiplist recovery /var/lib/cyrus/user/u/user_example_com.seen: ADD at 3F98 exists
cyrus/imapd[21076]: DBERROR: opening /var/lib/cyrus/user/u/user_example_com.seen: cyrusdb error
cyrus/imapd[21076]: Could not open seen state for user_example_com (System I/O error)
So I fixed it by moving the seen items out of the way:
# mv /var/lib/cyrus/user/u/user_example_com.s* ..

Another time this happened, I deleted the seen file, used "touch" to recreate it and set the ownership to cyrus.mail