idnits 2.17.00 (12 Aug 2021) /tmp/idnits13055/draft-ietf-qresync-rfc4551bis-02.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- ** There are 10 instances of too long lines in the document, the longest one being 7 characters in excess of 72. -- The draft header indicates that this document obsoletes RFC4551, but the abstract doesn't seem to mention this, which it should. -- The draft header indicates that this document updates RFC2683, but the abstract doesn't seem to mention this, which it should. -- The draft header indicates that this document updates RFC3501, but the abstract doesn't seem to directly say this. It does mention RFC3501 though, so this could be OK. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year (Using the creation date from RFC2683, updated by this document, for RFC5378 checks: 1997-09-09) -- The document seems to lack a disclaimer for pre-RFC5378 work, but may have content which was first submitted before 10 November 2008. If you have contacted all the original authors and they are all willing to grant the BCP78 rights to the IETF Trust, then this is fine, and you can ignore this comment. If not, you may need to add the pre-RFC5378 disclaimer. (See the Legal Provisions document at https://trustee.ietf.org/license-info for more information.) -- The document date (July 01, 2013) is 3245 days in the past. Is this intentional? Checking references for intended status: Proposed Standard ---------------------------------------------------------------------------- (See RFCs 3967 and 4897 for information about using normative references to lower-maturity documents in RFCs) == Missing Reference: 'UNSEEN 12' is mentioned on line 822, but not defined == Missing Reference: 'UIDVALIDITY 3857529045' is mentioned on line 823, but not defined == Missing Reference: 'UIDNEXT 4392' is mentioned on line 824, but not defined == Missing Reference: 'HIGHESTMODSEQ 715194045007' is mentioned on line 827, but not defined == Missing Reference: 'HIGHESTMODSEQ 12111230047' is mentioned on line 380, but not defined == Missing Reference: 'MODIFIED 7' is mentioned on line 408, but not defined -- Looks like a reference, but probably isn't: '9' on line 408 == Missing Reference: 'MODIFIED 12' is mentioned on line 418, but not defined == Missing Reference: 'MODIFIED 101' is mentioned on line 511, but not defined == Missing Reference: 'MODIFIED 2' is mentioned on line 544, but not defined ** Obsolete normative reference: RFC 3501 (Obsoleted by RFC 9051) -- Obsolete informational reference (is this intentional?): RFC 1305 (Obsoleted by RFC 5905) Summary: 2 errors (**), 0 flaws (~~), 10 warnings (==), 7 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 Network Working Group A. Melnikov 3 Internet-Draft Isode Ltd. 4 Obsoletes: 4551 (if approved) July 01, 2013 5 Updates: 3501, 2683 (if approved) 6 Intended status: Standards Track 7 Expires: January 02, 2014 9 IMAP Extension for Conditional STORE Operation or Quick Flag Changes 10 Resynchronization 11 draft-ietf-qresync-rfc4551bis-02.txt 13 Abstract 15 Often, multiple IMAP (RFC 3501) clients need to coordinate changes to 16 a common IMAP mailbox. Examples include different clients working on 17 behalf of the same user, and multiple users accessing shared 18 mailboxes. These clients need a mechanism to synchronize state 19 changes for messages within the mailbox. They must be able to 20 guarantee that only one client can change message state (e.g., 21 message flags) at any time. An example of such an application is use 22 of an IMAP mailbox as a message queue with multiple dequeueing 23 clients. 25 The Conditional Store facility provides a protected update mechanism 26 for message state information that can detect and resolve conflicts 27 between multiple writing mail clients. 29 The Conditional Store facility also allows a client to quickly 30 resynchronize mailbox flag changes. 32 This document defines an extension to IMAP (RFC 3501). 34 Status of This Memo 36 This Internet-Draft is submitted in full conformance with the 37 provisions of BCP 78 and BCP 79. 39 Internet-Drafts are working documents of the Internet Engineering 40 Task Force (IETF). Note that other groups may also distribute 41 working documents as Internet-Drafts. The list of current Internet- 42 Drafts is at http://datatracker.ietf.org/drafts/current/. 44 Internet-Drafts are draft documents valid for a maximum of six months 45 and may be updated, replaced, or obsoleted by other documents at any 46 time. It is inappropriate to use Internet-Drafts as reference 47 material or to cite them other than as "work in progress." 48 This Internet-Draft will expire on January 02, 2014. 50 Copyright Notice 52 Copyright (c) 2013 IETF Trust and the persons identified as the 53 document authors. All rights reserved. 55 This document is subject to BCP 78 and the IETF Trust's Legal 56 Provisions Relating to IETF Documents 57 (http://trustee.ietf.org/license-info) in effect on the date of 58 publication of this document. Please review these documents 59 carefully, as they describe your rights and restrictions with respect 60 to this document. Code Components extracted from this document must 61 include Simplified BSD License text as described in Section 4.e of 62 the Trust Legal Provisions and are provided without warranty as 63 described in the Simplified BSD License. 65 Table of Contents 67 1. Introduction and Overview . . . . . . . . . . . . . . . . . . 2 68 2. Conventions Used in This Document . . . . . . . . . . . . . . 5 69 3. IMAP Protocol Changes . . . . . . . . . . . . . . . . . . . . 6 70 3.1. New OK Untagged Responses for SELECT and EXAMINE . . . . 6 71 3.1.1. HIGHESTMODSEQ Response Code . . . . . . . . . . . . . 6 72 3.1.2. NOMODSEQ Response Code . . . . . . . . . . . . . . . 7 73 3.2. STORE and UID STORE Commands . . . . . . . . . . . . . . 8 74 3.3. FETCH and UID FETCH Commands . . . . . . . . . . . . . . 14 75 3.3.1. CHANGEDSINCE FETCH Modifier . . . . . . . . . . . . . 14 76 3.3.2. MODSEQ Message Data Item in FETCH Command . . . . . . 14 77 3.4. MODSEQ Search Criterion in SEARCH . . . . . . . . . . . . 16 78 3.5. Modified SEARCH Untagged Response . . . . . . . . . . . . 17 79 3.6. HIGHESTMODSEQ Status Data Items . . . . . . . . . . . . . 18 80 3.7. CONDSTORE Parameter to SELECT and EXAMINE . . . . . . . . 18 81 3.8. Additional Quality-of-Implementation Issues . . . . . . . 19 82 4. Formal Syntax . . . . . . . . . . . . . . . . . . . . . . . . 19 83 5. Server Implementation Considerations . . . . . . . . . . . . 22 84 6. Long Command Lines . . . . . . . . . . . . . . . . . . . . . 23 85 7. Security Considerations . . . . . . . . . . . . . . . . . . . 23 86 8. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 23 87 9. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 24 88 10. References . . . . . . . . . . . . . . . . . . . . . . . . . 24 89 10.1. Normative References . . . . . . . . . . . . . . . . . . 24 90 10.2. Informative References . . . . . . . . . . . . . . . . . 24 91 Appendix A. Changes since RFC 4551 . . . . . . . . . . . . . . . 25 92 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 25 94 1. Introduction and Overview 95 The Conditional STORE extension is present in any IMAP4 96 implementation that returns "CONDSTORE" as one of the supported 97 capabilities in the CAPABILITY command response. 99 An IMAP server that supports this extension MUST associate a positive 100 unsigned 64-bit value called a modification sequence (mod-sequence) 101 with every IMAP message. This is an opaque value updated by the 102 server whenever a metadata item is modified. The server MUST 103 guarantee that each STORE command performed on the same mailbox 104 (including simultaneous stores to different metadata items from 105 different connections) will get a different mod-sequence value. 106 Also, for any two successful STORE operations performed in the same 107 session on the same mailbox, the mod-sequence of the second completed 108 operation MUST be greater than the mod-sequence of the first 109 completed. Note that the latter rule disallows the use of the system 110 clock as a mod-sequence, because if system time changes (e.g., an NTP 111 [RFC1305] client adjusting the time), the next generated value might 112 be less than the previous one. 114 Mod-sequences allow a client that supports the CONDSTORE extension to 115 determine if a message metadata has changed since some known moment. 116 Whenever the state of a flag changes (i.e., the flag is added where 117 previously it wasn't set, or the flag is removed and before it was 118 set) the value of the modification sequence for the message MUST be 119 updated. Adding the flag when it is already present or removing when 120 it is not present SHOULD NOT change the mod-sequence. 122 When a message is appended to a mailbox (via the IMAP APPEND command, 123 COPY to the mailbox, or using an external mechanism) the server 124 generates a new modification sequence that is higher than the highest 125 modification sequence of all messages in the mailbox and assigns it 126 to the appended message. 128 The server MAY store separate (per-message) modification sequence 129 values for different metadata items. If the server does so, per- 130 message mod-sequence is the highest mod-sequence of all metadata 131 items for the specified message. 133 The server that supports this extension is not required to be able to 134 store mod-sequences for every available mailbox. Section 3.1.2 135 describes how the server may act if a particular mailbox doesn't 136 support the persistent storage of mod-sequences. 138 This extension makes the following changes to the IMAP4 protocol: 140 a. adds UNCHANGEDSINCE STORE modifier. 142 b. adds the MODIFIED response code which should be used with an OK 143 response to the STORE command. (It can also be used in a NO 144 response.) 146 c. adds a new MODSEQ message data item for use with the FETCH 147 command. 149 d. adds CHANGEDSINCE FETCH modifier. 151 e. adds a new MODSEQ search criterion. 153 f. extends the syntax of untagged SEARCH responses to include mod- 154 sequence. 156 g. adds new OK untagged responses for the SELECT and EXAMINE 157 commands. 159 h. defines an additional parameter to SELECT/EXAMINE commands. 161 i. adds the HIGHESTMODSEQ status data item to the STATUS command. 163 A client supporting CONDSTORE extension indicates its willingness to 164 receive mod-sequence updates in all untagged FETCH responses by 165 issuing: 167 o a SELECT or EXAMINE command with the CONDSTORE parameter, 169 o a STATUS (HIGHESTMODSEQ) command, 171 o a FETCH or SEARCH command that includes the MODSEQ message data 172 item, 174 o a FETCH command with the CHANGEDSINCE modifier, or 176 o a STORE command with the UNCHANGEDSINCE modifier. 178 o a ENABLE command containing "CONDSTORE" as one of the parameters. 179 (This requirement only applies to servers that also implement the 180 ENABLE extension [RFC5161].) 182 The server MUST include mod-sequence data in all subsequent untagged 183 FETCH responses (until the connection is closed), whether they were 184 caused by a regular STORE, a STORE with UNCHANGEDSINCE modifier, or 185 an external agent. 187 This document uses the term "CONDSTORE-aware client" to refer to a 188 client that announces its willingness to receive mod-sequence updates 189 as described above. The term "CONDSTORE enabling command" will refer 190 any of the commands listed above. A future extension to this 191 document may extend the list of CONDSTORE enabling commands. A first 192 CONDSTORE enabling command executed in the session with a mailbox 193 selected MUST cause the server to return HIGHESTMODSEQ 194 (Section 3.1.1) for the mailbox, unless the server has sent NOMODSEQ 195 (Section 3.1.2) response code when the currently selected mailbox was 196 selected. 198 The rest of this document describes the protocol changes more 199 rigorously. 201 2. Conventions Used in This Document 203 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 204 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this 205 document are to be interpreted as described in RFC 2119 [RFC2119]. 207 In examples, lines beginning with "S:" are sent by the IMAP server, 208 and lines beginning with "C:" are sent by the client. Line breaks 209 may appear in example commands solely for editorial clarity; when 210 present in the actual message, they are represented by "CRLF". 212 Formal syntax is defined using ABNF [RFC5234]. 214 The term "metadata" or "metadata item" is used throughout this 215 document. It refers to any system or user-defined keyword. Future 216 documents may extend "metadata" to include other dynamic message 217 data. 219 Some IMAP mailboxes are private, accessible only to the owning user. 220 Other mailboxes are not, either because the owner has set an Access 221 Control List [RFC4314] that permits access by other users, or because 222 it is a shared mailbox. Let's call a metadata item "shared" for the 223 mailbox if any changes to the metadata items are persistent and 224 visible to all other users accessing the mailbox. Otherwise, the 225 metadata item is called "private". Note that private metadata items 226 are still visible to all sessions accessing the mailbox as the same 227 user. Also note that different mailboxes may have different metadata 228 items as shared. 230 See Section 1 for the definition of a "CONDSTORE-aware client" and a 231 "CONDSTORE enabling command". 233 3. IMAP Protocol Changes 235 3.1. New OK Untagged Responses for SELECT and EXAMINE 237 This document adds two new response codes, HIGHESTMODSEQ and 238 NOMODSEQ. One of those response codes MUST be returned in the OK 239 untagged response for a successful SELECT/EXAMINE command. 241 When opening a mailbox, the server must check if the mailbox supports 242 the persistent storage of mod-sequences. If the mailbox supports the 243 persistent storage of mod-sequences and the mailbox open operation 244 succeeds, the server MUST send the OK untagged response including 245 HIGHESTMODSEQ response code. If the persistent storage for the 246 mailbox is not supported, the server MUST send the OK untagged 247 response including NOMODSEQ response code instead. 249 3.1.1. HIGHESTMODSEQ Response Code 251 This document adds a new response code that is returned in the OK 252 untagged response for the SELECT and EXAMINE commands. A server 253 supporting the persistent storage of mod-sequences for the mailbox 254 MUST send the OK untagged response including HIGHESTMODSEQ response 255 code with every successful SELECT or EXAMINE command: 257 OK [HIGHESTMODSEQ ] 259 where is the highest mod-sequence value of 260 all messages in the mailbox. When the server changes UIDVALIDITY 261 for a mailbox, it doesn't have to keep the same HIGHESTMODSEQ for 262 the mailbox. 264 Note that this requirement applies whether or not a CONDSTORE 265 enabling command was issued in the session. 267 A disconnected client can use the value of HIGHESTMODSEQ to check if 268 it has to refetch metadata from the server. If the UIDVALIDITY value 269 has changed for the selected mailbox, the client MUST delete the 270 cached value of HIGHESTMODSEQ. If UIDVALIDITY for the mailbox is the 271 same, and if the HIGHESTMODSEQ value stored in the client's cache is 272 less than the value returned by the server, then some metadata items 273 on the server have changed since the last synchronization, and the 274 client needs to update its cache. The client MAY use SEARCH MODSEQ 275 (Section 3.4) to find out exactly which metadata items have changed. 276 Alternatively, the client MAY issue FETCH with the CHANGEDSINCE 277 modifier (Section 3.3.1) in order to fetch data for all messages that 278 have metadata items changed since some known modification sequence. 280 C: A142 SELECT INBOX 281 S: * 172 EXISTS 282 S: * 1 RECENT 283 S: * OK [UNSEEN 12] Message 12 is first unseen 284 S: * OK [UIDVALIDITY 3857529045] UIDs valid 285 S: * OK [UIDNEXT 4392] Predicted next UID 286 S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) 287 S: * OK [PERMANENTFLAGS (\Deleted \Seen \*)] Limited 288 S: * OK [HIGHESTMODSEQ 715194045007] 289 S: A142 OK [READ-WRITE] SELECT completed 291 Example 1 293 3.1.2. NOMODSEQ Response Code 295 A server that doesn't support the persistent storage of mod-sequences 296 for the mailbox MUST send the OK untagged response including NOMODSEQ 297 response code with every successful SELECT or EXAMINE command. Note 298 that this requirement applies whether or not a CONDSTORE enabling 299 command was issued in the session. 301 A server that returned NOMODSEQ response code for a mailbox, which 302 subsequently receives one of the following commands while the mailbox 303 is selected: 305 o a FETCH command with the CHANGEDSINCE modifier, 307 o a FETCH or SEARCH command that includes the MODSEQ message data 308 item, or 310 o a STORE command with the UNCHANGEDSINCE modifier 312 MUST reject any such command with the tagged BAD response. 314 C: A142 SELECT INBOX 315 S: * 172 EXISTS 316 S: * 1 RECENT 317 S: * OK [UNSEEN 12] Message 12 is first unseen 318 S: * OK [UIDVALIDITY 3857529045] UIDs valid 319 S: * OK [UIDNEXT 4392] Predicted next UID 320 S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) 321 S: * OK [PERMANENTFLAGS (\Deleted \Seen \*)] Limited 322 S: * OK [NOMODSEQ] Sorry, this mailbox format doesn't support 323 modsequences 324 S: A142 OK [READ-WRITE] SELECT completed 326 Example 2 328 3.2. STORE and UID STORE Commands 330 This document defines the following STORE modifier (see Section 2.5 331 of [RFC4466]): 333 UNCHANGEDSINCE For each message specified in the 334 message set, the server performs the following. If the mod- 335 sequence of any metadata item of the message is equal or less than 336 the specified UNCHANGEDSINCE value, then the requested operation 337 (as described by the message data item) is performed. If the 338 operation is successful, the server MUST update the mod-sequence 339 attribute of the message. An untagged FETCH response MUST be 340 sent, even if the .SILENT suffix is specified, and the response 341 MUST include the MODSEQ message data item. This is required to 342 update the client's cache with the correct mod-sequence values. 343 See Section 3.3.2 for more details. 345 However, if the mod-sequence of any metadata item of the message is 346 greater than the specified UNCHANGEDSINCE value, then the requested 347 operation MUST NOT be performed. In this case, the mod-sequence 348 attribute of the message is not updated, and the message number (or 349 unique identifier in the case of the UID STORE command) is added to 350 the list of messages that failed the UNCHANGEDSINCE test. 352 When the server finished performing the operation on all the messages 353 in the message set, it checks for a non-empty list of messages that 354 failed the UNCHANGEDSINCE test. If this list is non-empty, the 355 server MUST return in the tagged response a MODIFIED response code. 356 The MODIFIED response code includes the message set (for STORE) or 357 set of UIDs (for UID STORE) of all messages that failed the 358 UNCHANGEDSINCE test. 360 All messages pass the UNCHANGEDSINCE test. 362 C: a103 UID STORE 6,4,8 (UNCHANGEDSINCE 12121230045) 363 +FLAGS.SILENT (\Deleted) 364 S: * 1 FETCH (UID 4 MODSEQ (12121231000)) 365 S: * 2 FETCH (UID 6 MODSEQ (12121230852)) 366 S: * 4 FETCH (UID 8 MODSEQ (12121130956)) 367 S: a103 OK Conditional Store completed 369 Example 3 371 C: a104 STORE * (UNCHANGEDSINCE 12121230045) +FLAGS.SILENT 372 (\Deleted $Processed) 373 S: * 50 FETCH (MODSEQ (12111230047)) 374 S: a104 OK Store (conditional) completed 376 Example 4 378 C: c101 STORE 50 (UNCHANGEDSINCE 12121230045) -FLAGS.SILENT 379 (\Deleted) 380 S: * OK [HIGHESTMODSEQ 12111230047] 381 S: * 50 FETCH (MODSEQ (12111230048)) 382 S: c101 OK Store (conditional) completed 384 HIGHESTMODSEQ response code was sent by the server presumably because 385 this was the first CONDSTORE enabling command. 387 Example 5 389 In spite of the failure of the conditional STORE operation for 390 message 7, the server continues to process the conditional STORE in 391 order to find all messages that fail the test. 393 C: d105 STORE 7,5,9 (UNCHANGEDSINCE 320162338) 394 +FLAGS.SILENT (\Deleted) 395 S: * 5 FETCH (MODSEQ (320162350)) 396 S: d105 OK [MODIFIED 7,9] Conditional STORE failed 398 Example 6 400 Same as above, but the server follows the SHOULD recommendation in 401 Section 6.4.6 of [RFC3501]. 403 C: d105 STORE 7,5,9 (UNCHANGEDSINCE 320162338) 404 +FLAGS.SILENT (\Deleted) 405 S: * 7 FETCH (MODSEQ (320162342) FLAGS (\Seen \Deleted)) 406 S: * 5 FETCH (MODSEQ (320162350)) 407 S: * 9 FETCH (MODSEQ (320162349) FLAGS (\Answered)) 408 S: d105 OK [MODIFIED 7,9] Conditional STORE failed 410 Use of UNCHANGEDSINCE with a modification sequence of 0 always fails 411 if the metadata item exists. A system flag MUST always be considered 412 existent, whether it was set or not. 414 Example 7 416 C: a102 STORE 12 (UNCHANGEDSINCE 0) 417 +FLAGS.SILENT ($MDNSent) 418 S: a102 OK [MODIFIED 12] Conditional STORE failed 419 The client has tested the presence of the $MDNSent user-defined 420 keyword. 422 Example 8 424 Note: A client trying to make an atomic change to the state of a 425 particular metadata item (or a set of metadata items) should be 426 prepared to deal with the case when the server returns the MODIFIED 427 response code if the state of the metadata item being watched hasn't 428 changed (but the state of some other metadata item has). This is 429 necessary, because some servers don't store separate mod-sequences 430 for different metadata items. However, a server implementation 431 SHOULD avoid generating spurious MODIFIED responses for +FLAGS/-FLAGS 432 STORE operations, even when the server stores a single mod-sequence 433 per message. Section 5 describes how this can be achieved. 435 Unless the server has included an unsolicited FETCH to update 436 client's knowledge about messages that have failed the UNCHANGEDSINCE 437 test, upon receipt of the MODIFIED response code, the client SHOULD 438 try to figure out if the required metadata items have indeed changed 439 by issuing FETCH or NOOP command. It is RECOMMENDED that the server 440 avoids the need for the client to do that by sending an unsolicited 441 FETCH response (Examples 9 and 10). 443 If the required metadata items haven't changed, the client SHOULD 444 retry the command with the new mod-sequence. The client SHOULD allow 445 for a configurable but reasonable number of retries (at least 2). 447 In the example below, the server returns the MODIFIED response code 448 without sending information describing why the STORE UNCHANGEDSINCE 449 operation has failed. 451 C: a106 STORE 100:150 (UNCHANGEDSINCE 212030000000) 452 +FLAGS.SILENT ($Processed) 453 S: * 100 FETCH (MODSEQ (303181230852)) 454 S: * 102 FETCH (MODSEQ (303181230852)) 455 ... 456 S: * 150 FETCH (MODSEQ (303181230852)) 457 S: a106 OK [MODIFIED 101] Conditional STORE failed 459 The flag $Processed was set on the message 101... 461 C: a107 NOOP 462 S: * 101 FETCH (MODSEQ (303011130956) FLAGS ($Processed)) 463 S: a107 OK 465 Example 9 467 Or the flag hasn't changed, but another has (note that this server 468 behaviour is discouraged. Server implementers should also see 469 Section 5)... 471 C: b107 NOOP 472 S: * 101 FETCH (MODSEQ (303011130956) FLAGS (\Deleted \Answered)) 473 S: b107 OK 475 ...and the client retries the operation for the message 101 with 476 the updated UNCHANGEDSINCE value 478 C: b108 STORE 101 (UNCHANGEDSINCE 303011130956) 479 +FLAGS.SILENT ($Processed) 480 S: * 101 FETCH (MODSEQ (303181230852)) 481 S: b108 OK Conditional Store completed 483 Same as above, but the server avoids the need for the client to poll 484 for changes. 486 The flag $Processed was set on the message 101 by another 487 client... 489 C: a106 STORE 100:150 (UNCHANGEDSINCE 212030000000) 490 +FLAGS.SILENT ($Processed) 491 S: * 100 FETCH (MODSEQ (303181230852)) 492 S: * 101 FETCH (MODSEQ (303011130956) FLAGS ($Processed)) 493 S: * 102 FETCH (MODSEQ (303181230852)) 494 ... 495 S: * 150 FETCH (MODSEQ (303181230852)) 496 S: a106 OK [MODIFIED 101] Conditional STORE failed 498 Example 10 500 Or the flag hasn't changed, but another has (note that this server 501 behaviour is discouraged. Server implementers should also see 502 Section 5)... 504 C: a106 STORE 100:150 (UNCHANGEDSINCE 212030000000) 505 +FLAGS.SILENT ($Processed) 506 S: * 100 FETCH (MODSEQ (303181230852)) 507 S: * 101 FETCH (MODSEQ (303011130956) FLAGS (\Deleted \Answered)) 508 S: * 102 FETCH (MODSEQ (303181230852)) 509 ... 510 S: * 150 FETCH (MODSEQ (303181230852)) 511 S: a106 OK [MODIFIED 101] Conditional STORE failed 512 ...and the client retries the operation for the message 101 with 513 the updated UNCHANGEDSINCE value 515 C: b108 STORE 101 (UNCHANGEDSINCE 303011130956) 516 +FLAGS.SILENT ($Processed) 517 S: * 101 FETCH (MODSEQ (303181230852)) 518 S: b108 OK Conditional Store completed 520 Or the flag hasn't changed, but another has (nice server behaviour. 521 Server implementers should also see Section 5)... 523 C: a106 STORE 100:150 (UNCHANGEDSINCE 212030000000) 524 +FLAGS.SILENT ($Processed) 525 S: * 100 FETCH (MODSEQ (303181230852)) 526 S: * 101 FETCH (MODSEQ (303011130956) FLAGS ($Processed \Deleted 527 \Answered)) 528 S: * 102 FETCH (MODSEQ (303181230852)) 529 ... 530 S: * 150 FETCH (MODSEQ (303181230852)) 531 S: a106 OK Conditional STORE completed 533 The following example is based on the example from the Section 4.2.3 534 of [RFC2180] and demonstrates that the MODIFIED response code may be 535 also returned in the tagged NO response. 537 Client tries to conditionally STORE flags on a mixture of expunged 538 and non-expunged messages; one message fails the UNCHANGEDSINCE 539 test. 541 C: B001 STORE 1:7 (UNCHANGEDSINCE 320172338) +FLAGS (\SEEN) 542 S: * 1 FETCH (MODSEQ (320172342) FLAGS (\SEEN)) 543 S: * 3 FETCH (MODSEQ (320172342) FLAGS (\SEEN)) 544 S: B001 NO [MODIFIED 2] Some of the messages no longer exist. 546 C: B002 NOOP 547 S: * 4 EXPUNGE 548 S: * 4 EXPUNGE 549 S: * 4 EXPUNGE 550 S: * 4 EXPUNGE 551 S: * 2 FETCH (MODSEQ (320172340) FLAGS (\Deleted \Answered)) 552 S: B002 OK NOOP Completed. 554 By receiving FETCH responses for messages 1 and 3, and EXPUNGE 555 responses that indicate that messages 4 through 7 have been 556 expunged, the client retries the operation only for the message 2. 557 The updated UNCHANGEDSINCE value is used. 559 C: b003 STORE 2 (UNCHANGEDSINCE 320172340) +FLAGS (\Seen) 560 S: * 2 FETCH (MODSEQ (320180050)) 561 S: b003 OK Conditional Store completed 563 Example 11 565 Note: If a message is specified multiple times in the message set, 566 and the server doesn't internally eliminate duplicates from the 567 message set, it MUST NOT fail the conditional STORE operation for the 568 second (or subsequent) occurrence of the message if the operation 569 completed successfully for the first occurrence. For example, if the 570 client specifies: 572 e105 STORE 7,3:9 (UNCHANGEDSINCE 12121230045) +FLAGS.SILENT 573 (\Deleted) 575 the server must not fail the operation for message 7 as part of 576 processing "3:9" if it succeeded when message 7 was processed the 577 first time. 579 Once the client specified the UNCHANGEDSINCE modifier in a STORE 580 command, the server MUST include the MODSEQ fetch response data items 581 in all subsequent unsolicited FETCH responses. 583 This document also changes the behaviour of the server when it has 584 performed a STORE or UID STORE command and the UNCHANGEDSINCE 585 modifier is not specified. If the operation is successful for a 586 message, the server MUST update the mod-sequence attribute of the 587 message. The server is REQUIRED to include the mod-sequence value 588 whenever it decides to send the unsolicited FETCH response to all 589 CONDSTORE-aware clients that have opened the mailbox containing the 590 message. 592 Server implementers should also see Section 3.8 for additional 593 quality of implementation issues related to the STORE command. 595 3.3. FETCH and UID FETCH Commands 597 3.3.1. CHANGEDSINCE FETCH Modifier 599 This document defines the following FETCH modifier (see Section 2.4 600 of [RFC4466]): 602 CHANGEDSINCE CHANGEDSINCE FETCH modifier allows to 603 create a further subset of the list of messages described by 604 sequence set. The information described by message data items is 605 only returned for messages that have mod-sequence bigger than 606 . 608 When CHANGEDSINCE FETCH modifier is specified, it implicitly adds 609 MODSEQ FETCH message data item (Section 3.3.2). 611 C: s100 UID FETCH 1:* (FLAGS) (CHANGEDSINCE 12345) 612 S: * 1 FETCH (UID 4 MODSEQ (65402) FLAGS (\Seen)) 613 S: * 2 FETCH (UID 6 MODSEQ (75403) FLAGS (\Deleted)) 614 S: * 4 FETCH (UID 8 MODSEQ (29738) FLAGS ($NoJunk $AutoJunk 615 $MDNSent)) 616 S: s100 OK FETCH completed 618 Example 12 620 3.3.2. MODSEQ Message Data Item in FETCH Command 622 This extension adds a MODSEQ message data item to the FETCH command. 623 The MODSEQ message data item allows clients to retrieve mod-sequence 624 values for a range of messages in the currently selected mailbox. 626 Once the client specified the MODSEQ message data item in a FETCH 627 request, the server MUST include the MODSEQ fetch response data items 628 in all subsequent unsolicited FETCH responses. 630 Syntax: MODSEQ The MODSEQ message data item causes the server to 631 return MODSEQ fetch response data items. 633 Syntax: MODSEQ ( ) MODSEQ response data items 634 contain per-message mod-sequences. 636 The MODSEQ response data item is returned if the client issued 637 FETCH with MODSEQ message data item. It also allows the server to 638 notify the client about mod-sequence changes caused by conditional 639 STOREs (Section 3.2) and/or changes caused by external sources. 641 C: a FETCH 1:3 (MODSEQ) 642 S: * 1 FETCH (MODSEQ (624140003)) 643 S: * 2 FETCH (MODSEQ (624140007)) 644 S: * 3 FETCH (MODSEQ (624140005)) 645 S: a OK Fetch complete 647 In this example, the client requests per-message mod-sequences for a 648 set of messages. 650 Example 13 652 When a flag for a message is modified in a different session, the 653 server sends an unsolicited FETCH response containing the mod- 654 sequence for the message. 656 (Session 1, authenticated as a user "alex"). The user adds a 657 shared flag \Deleted: 659 C: A142 SELECT INBOX 660 ... 661 S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) 662 S: * OK [PERMANENTFLAGS (\Answered \Deleted \Seen \*)] Limited 663 ... 664 C: A160 STORE 7 +FLAGS.SILENT (\Deleted) 665 S: * 7 FETCH (MODSEQ (2121231000)) 666 S: A160 OK Store completed 668 (Session 2, also authenticated as the user "alex"). Any changes 669 to flags are always reported to all sessions authenticated as the 670 same user as in the session 1. 672 C: C180 NOOP 673 S: * 7 FETCH (FLAGS (\Deleted \Answered) MODSEQ (12121231000)) 674 S: C180 OK Noop completed 676 (Session 3, authenticated as a user "andrew"). As \Deleted is a 677 shared flag, changes in session 1 are also reported in session 3: 679 C: D210 NOOP 680 S: * 7 FETCH (FLAGS (\Deleted \Answered) MODSEQ (12121231000)) 681 S: D210 OK Noop completed 683 The user modifies a private flag \Seen in session 1... 685 C: A240 STORE 7 +FLAGS.SILENT (\Seen) 686 S: * 7 FETCH (MODSEQ (12121231777)) 687 S: A240 OK Store completed 689 ...which is only reported in session 2... 691 C: C270 NOOP 692 S: * 7 FETCH (FLAGS (\Deleted \Answered \Seen) MODSEQ 693 (12121231777)) 694 S: C270 OK Noop completed 696 ...but not in session 3. 698 C: D300 NOOP 699 S: D300 OK Noop completed 701 And finally, the user removes flags \Answered (shared) and \Seen 702 (private) in session 1. 704 C: A330 STORE 7 -FLAGS.SILENT (\Answered \Seen) 705 S: * 7 FETCH (MODSEQ (12121245160)) 706 S: A330 OK Store completed 708 Both changes are reported in the session 2... 710 C: C360 NOOP 711 S: * 7 FETCH (FLAGS (\Deleted) MODSEQ (12121245160)) 712 S: C360 OK Noop completed 714 ...and only changes to shared flags are reported in session 3. 716 C: D390 NOOP 717 S: * 7 FETCH (FLAGS (\Deleted) MODSEQ (12121245160)) 718 S: D390 OK Noop completed 720 Example 14 722 Server implementers should also see Section 3.8 for additional 723 quality of implementation issues related to the FETCH command. 725 3.4. MODSEQ Search Criterion in SEARCH 727 The MODSEQ criterion for the SEARCH command allows a client to search 728 for the metadata items that were modified since a specified moment. 730 Syntax: MODSEQ [ ] 732 Messages that have modification values that are equal to or 733 greater than . This allows a client, for 734 example, to find out which messages contain metadata items that 735 have changed since the last time it updated its disconnected 736 cache. The client may also specify (name of metadata 737 item) and (type of metadata item) before . can be one of "shared", "priv" 739 (private), or "all". The latter means that the server should use 740 the biggest value among "priv" and "shared" mod- sequences for the 741 metadata item. If the server doesn't store internally separate 742 mod-sequences for different metadata items, it MUST ignore and . Otherwise, the server should use them 744 to narrow down the search. 746 For a flag , the corresponding has a form " 747 /flags/" as defined in [RFC4466]. Note that the leading 748 "\" character that denotes a system flag has to be escaped as per 749 Section 4.3 of [RFC3501], as the uses syntax for 750 quoted strings. 752 If client specifies a MODSEQ criterion in a SEARCH command and the 753 server returns a non-empty SEARCH result, the server MUST also append 754 (to the end of the untagged SEARCH response) the highest mod-sequence 755 for all messages being returned. See also Section 3.5. 757 C: a SEARCH MODSEQ "/flags/\\draft" all 620162338 758 S: * SEARCH 2 5 6 7 11 12 18 19 20 23 (MODSEQ 917162500) 759 S: a OK Search complete 761 In the above example, the message numbers of any messages containing 762 the string "IMAP4" in the "value" attribute of the "/comment" entry 763 and having a mod-sequence equal to or greater than 620162338 for the 764 "\Draft" flag are returned in the search results. 766 Example 15 768 C: t SEARCH OR NOT MODSEQ 720162338 LARGER 50000 769 S: * SEARCH 770 S: t OK Search complete, nothing found 772 Example 16 774 3.5. Modified SEARCH Untagged Response 775 Data: zero or more numbers 776 mod-sequence value (omitted if no match) 778 This document extends syntax of the untagged SEARCH response to 779 include the highest mod-sequence for all messages being returned. 781 If a client specifies a MODSEQ criterion in a SEARCH (or UID SEARCH) 782 command and the server returns a non-empty SEARCH result, the server 783 MUST also append (to the end of the untagged SEARCH response) the 784 highest mod-sequence for all messages being returned. See 785 Section 3.4 for examples. 787 3.6. HIGHESTMODSEQ Status Data Items 789 This document defines a new status data item: 791 HIGHESTMODSEQ The highest mod-sequence value of all messages in the 792 mailbox. This is the same value that is returned by the server in 793 the HIGHESTMODSEQ response code in an OK untagged response (see 794 Section 3.1.1). If the server doesn't support the persistent 795 storage of mod-sequences for the mailbox (see Section 3.1.2), the 796 server MUST return 0 as the value of HIGHESTMODSEQ status data 797 item. 799 C: A042 STATUS blurdybloop (UIDNEXT MESSAGES HIGHESTMODSEQ) 800 S: * STATUS blurdybloop (MESSAGES 231 UIDNEXT 44292 801 HIGHESTMODSEQ 7011231777) 802 S: A042 OK STATUS completed 804 Example 17 806 3.7. CONDSTORE Parameter to SELECT and EXAMINE 808 The CONDSTORE extension defines a single optional select parameter, 809 "CONDSTORE", which tells the server that it MUST include the MODSEQ 810 fetch response data items in all subsequent unsolicited FETCH 811 responses. 813 The CONDSTORE parameter to SELECT/EXAMINE helps avoid a race 814 condition that might arise when one or more metadata items are 815 modified in another session after the server has sent the 816 HIGHESTMODSEQ response code and before the client was able to issue a 817 CONDSTORE enabling command. 819 C: A142 SELECT INBOX (CONDSTORE) 820 S: * 172 EXISTS 821 S: * 1 RECENT 822 S: * OK [UNSEEN 12] Message 12 is first unseen 823 S: * OK [UIDVALIDITY 3857529045] UIDs valid 824 S: * OK [UIDNEXT 4392] Predicted next UID 825 S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) 826 S: * OK [PERMANENTFLAGS (\Deleted \Seen \*)] Limited 827 S: * OK [HIGHESTMODSEQ 715194045007] 828 S: A142 OK [READ-WRITE] SELECT completed, CONDSTORE is now enabled 830 Example 18 832 3.8. Additional Quality-of-Implementation Issues 834 Server implementations should follow the following rule, which 835 applies to any successfully completed STORE/UID STORE (with and 836 without UNCHANGEDSINCE modifier), as well as to a FETCH command that 837 implicitly sets \Seen flag: 839 Adding the flag when it is already present or removing when it is 840 not present SHOULD NOT change the mod-sequence. 842 This will prevent spurious client synchronization requests. 844 However, note that client implementers MUST NOT rely on this server 845 behavior. A client can't distinguish between the case when a server 846 has violated the SHOULD mentioned above, and that when one or more 847 clients set and unset (or unset and set) the flag in another session. 849 4. Formal Syntax 851 The following syntax specification uses the Augmented Backus-Naur 852 Form (ABNF) [RFC5234] notation. Elements not defined here can be 853 found in the formal syntax of the ABNF [RFC5234], IMAP [RFC3501], and 854 IMAP ABNF extensions [RFC4466] specifications. 856 Except as noted otherwise, all alphabetic characters are case- 857 insensitive. The use of upper- or lowercase characters to define 858 token strings is for editorial clarity only. Implementations MUST 859 accept these strings in a case-insensitive fashion. 861 capability =/ "CONDSTORE" 863 status-att =/ "HIGHESTMODSEQ" 864 ;; extends non-terminal defined in RFC 3501. 866 status-att-val =/ "HIGHESTMODSEQ" SP mod-sequence-valzer 867 ;; extends non-terminal defined in [RFC4466]. 868 ;; Value 0 denotes that the mailbox doesn't 869 ;; support persistent mod-sequences 870 ;; as described in Section 3.1.2 [[Check the ref]] 872 store-modifier =/ "UNCHANGEDSINCE" SP mod-sequence-valzer 873 ;; Only a single "UNCHANGEDSINCE" may be 874 ;; specified in a STORE operation 876 fetch-modifier =/ chgsince-fetch-mod 877 ;; conforms to the generic "fetch-modifier" 878 ;; syntax defined in [RFC4466]. 880 chgsince-fetch-mod = "CHANGEDSINCE" SP mod-sequence-value 881 ;; CHANGEDSINCE FETCH modifier conforms to 882 ;; the fetch-modifier syntax 884 fetch-att =/ fetch-mod-sequence 885 ;; modifies original IMAP4 fetch-att 887 fetch-mod-sequence = "MODSEQ" 889 fetch-mod-resp = "MODSEQ" SP "(" permsg-modsequence ")" 891 msg-att-dynamic =/ fetch-mod-resp 893 search-key =/ search-modsequence 894 ;; modifies original IMAP4 search-key 895 ;; 896 ;; This change applies to all commands 897 ;; referencing this non-terminal, in 898 ;; particular SEARCH. 900 search-modsequence = "MODSEQ" [search-modseq-ext] SP 901 mod-sequence-valzer 903 search-modseq-ext = SP entry-name SP entry-type-req 905 resp-text-code =/ "HIGHESTMODSEQ" SP mod-sequence-value / 906 "NOMODSEQ" / 907 "MODIFIED" SP sequence-set 909 entry-name = entry-flag-name 911 entry-flag-name = DQUOTE "/flags/" attr-flag DQUOTE 912 ;; each system or user defined flag 913 ;; is mapped to "/flags/". 914 ;; 915 ;; follows the escape rules 916 ;; used by "quoted" string as described in 917 ;; Section 4.3 of [RFC3501], e.g., for the flag 918 ;; \Seen the corresponding is 919 ;; "/flags/\\seen", and for the flag 920 ;; $MDNSent, the corresponding 921 ;; is "/flags/$mdnsent". 923 entry-type-resp = "priv" / "shared" 924 ;; metadata item type 926 entry-type-req = entry-type-resp / "all" 927 ;; perform SEARCH operation on private 928 ;; metadata item, shared metadata item or both 930 permsg-modsequence = mod-sequence-value 931 ;; per message mod-sequence 933 mod-sequence-value = 1*DIGIT 934 ;; Positive unsigned 64-bit integer 935 ;; (mod-sequence) 936 ;; (1 <= n < 18,446,744,073,709,551,615) 938 mod-sequence-valzer = "0" / mod-sequence-value 940 search-sort-mod-seq = "(" "MODSEQ" SP mod-sequence-value ")" 942 select-param =/ condstore-param 943 ;; conforms to the generic "select-param" 944 ;; non-terminal syntax defined in [RFC4466]. 946 condstore-param = "CONDSTORE" 948 mailbox-data =/ "SEARCH" [1*(SP nz-number) SP 949 search-sort-mod-seq] 951 attr-flag = "\\Answered" / "\\Flagged" / "\\Deleted" / 952 "\\Seen" / "\\Draft" / attr-flag-keyword / 953 attr-flag-extension 954 ;; Does not include "\\Recent" 956 attr-flag-extension = "\\" atom 957 ;; Future expansion. Client implementations 958 ;; MUST accept flag-extension flags. Server 959 ;; implementations MUST NOT generate 960 ;; flag-extension flags except as defined by 961 ;; future standard or standards-track 962 ;; revisions of [RFC3501]. 964 attr-flag-keyword = atom 966 5. Server Implementation Considerations 968 This section describes how a server implementation that doesn't store 969 separate per-metadata mod-sequences for different metadata items can 970 avoid sending the MODIFIED response to any of the following 971 conditional STORE operations: 973 +FLAGS 975 -FLAGS 977 +FLAGS.SILENT 979 -FLAGS.SILENT 981 Note that the optimization described in this section can't be 982 performed in case of a conditional STORE FLAGS operation. 984 Let's use the following example. The client has issued 986 C: a106 STORE 100:150 (UNCHANGEDSINCE 212030000000) 987 +FLAGS.SILENT ($Processed) 989 When the server receives the command and parses it successfully, it 990 iterates through the message set and tries to execute the conditional 991 STORE command for each message. 993 Each server internally works as a client, i.e., it has to cache the 994 current state of all IMAP flags as it is known to the client. In 995 order to report flag changes to the client, the server compares the 996 cached values with the values in its database for IMAP flags. 998 Imagine that another client has changed the state of a flag \Deleted 999 on the message 101 and that the change updated the mod-sequence for 1000 the message. The server knows that the mod-sequence for the mailbox 1001 has changed; however, it also knows that: 1003 a. the client is not interested in \Deleted flag, as it hasn't 1004 included it in +FLAGS.SILENT operation; and 1006 b. the state of the flag $Processed hasn't changed (the server can 1007 determine this by comparing cached flag state with the state of 1008 the flag in the database). 1010 Therefore, the server doesn't have to report MODIFIED to the client. 1011 Instead, the server may set $Processed flag, update the mod-sequence 1012 for the message 101 once again and send an untagged FETCH response 1013 with new mod-sequence and flags: 1015 S: * 101 FETCH (MODSEQ (303011130956) 1016 FLAGS ($Processed \Deleted \Answered)) 1018 See also Section 3.8 for additional quality-of-implementation issues. 1020 6. Long Command Lines 1022 This document updates recommended line length limits specified in 1023 Section 3.2.1.5 of [RFC2683]. While the advice in the first 1024 paragraph of that section still applies ("use compact message/UID set 1025 representations"), the 1000 octet limit suggested in the second 1026 paragraph turned out to be quite problematic when the CONDSTORE 1027 extension is used. The updated recommendation is as follows: a 1028 client should limit the length of the command lines it generates to 1029 approximately 8192 octets (including all quoted strings but not 1030 including literals). 1032 7. Security Considerations 1034 It is believed that the Conditional STORE extension doesn't raise any 1035 new security concerns that are not already discussed in [RFC3501]. 1036 However, the availability of this extension may make it possible for 1037 IMAP4 to be used in critical applications it could not be used for 1038 previously, making correct IMAP server implementation and operation 1039 even more important. 1041 8. IANA Considerations 1043 IMAP4 capabilities are registered by publishing a standards track or 1044 IESG approved experimental RFC. The registry is currently located 1045 at: 1047 http://www.iana.org/assignments/imap4-capabilities 1049 This document defines the CONDSTORE IMAP capability. IANA has added 1050 it to the registry accordingly. 1052 9. Acknowledgements 1054 Thank you to Steve Hole for co-editing RFC 4551. 1056 Thank you to Dave Cridland for helping to convert the original text 1057 RFC to xml2rfc format. 1059 Some text was borrowed from "IMAP ANNOTATE Extension" [RFC5257] by 1060 Randall Gellens and Cyrus Daboo and from "ACAP -- Application 1061 Configuration Access Protocol" [RFC2244] by Chris Newman and John 1062 Myers. 1064 Many thanks to Randall Gellens for his thorough review of the 1065 document. 1067 The authors also acknowledge the feedback provided by Cyrus Daboo, 1068 Larry Greenfield, Chris Newman, Harrie Hazewinkel, Arnt Gulbrandsen, 1069 Timo Sirainen, Mark Crispin, Ned Freed, Ken Murchison, and Dave 1070 Cridland. 1072 10. References 1074 10.1. Normative References 1076 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 1077 Requirement Levels", BCP 14, RFC 2119, March 1997. 1079 [RFC3501] Crispin, M., "INTERNET MESSAGE ACCESS PROTOCOL - VERSION 1080 4rev1", RFC 3501, March 2003. 1082 [RFC4466] Melnikov, A. and C. Daboo, "Collected Extensions to IMAP4 1083 ABNF", RFC 4466, April 2006. 1085 [RFC5161] Gulbrandsen, A. and A. Melnikov, "The IMAP ENABLE 1086 Extension", RFC 5161, March 2008. 1088 [RFC5234] Crocker, D. and P. Overell, "Augmented BNF for Syntax 1089 Specifications: ABNF", STD 68, RFC 5234, January 2008. 1091 10.2. Informative References 1093 [RFC1305] Mills, D., "Network Time Protocol (Version 3) 1094 Specification, Implementation", RFC 1305, March 1992. 1096 [RFC2180] Gahrns, M., "IMAP4 Multi-Accessed Mailbox Practice", RFC 1097 2180, July 1997. 1099 [RFC2244] Newman, C. and J. Myers, "ACAP -- Application 1100 Configuration Access Protocol", RFC 2244, November 1997. 1102 [RFC2683] Leiba, B., "IMAP4 Implementation Recommendations", RFC 1103 2683, September 1999. 1105 [RFC4314] Melnikov, A., "IMAP4 Access Control List (ACL) Extension", 1106 RFC 4314, December 2005. 1108 [RFC5257] Daboo, C. and R. Gellens, "Internet Message Access 1109 Protocol - ANNOTATE Extension", RFC 5257, June 2008. 1111 Appendix A. Changes since RFC 4551 1113 Fixed errata 3401, 3506 and 3509. 1115 Updated references. 1117 Incorporated some text from RFC 5161 (no semantic change.) 1119 Editorial corrections. 1121 Author's Address 1123 Alexey Melnikov 1124 Isode Ltd. 1125 5 Castle Business Village 1126 36 Station Road 1127 Hampton, Middlesex TW12 2BX 1128 UK 1130 Email: Alexey.Melnikov@isode.com