starsofchance commited on
Commit
5145153
·
verified ·
1 Parent(s): b9d9d4e

Add categorized test splits for the final step of test before finetuning

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +2 -0
  2. categorized_datasets_for_R1-Distill-Llama/BigVul_Sample/BigVul_Sample_1024_to_2048.csv +0 -0
  3. categorized_datasets_for_R1-Distill-Llama/BigVul_Sample/BigVul_Sample_1024_to_2048.pkl +3 -0
  4. categorized_datasets_for_R1-Distill-Llama/BigVul_Sample/BigVul_Sample_11000_to_15000.csv +2575 -0
  5. categorized_datasets_for_R1-Distill-Llama/BigVul_Sample/BigVul_Sample_11000_to_15000.pkl +3 -0
  6. categorized_datasets_for_R1-Distill-Llama/BigVul_Sample/BigVul_Sample_2048_to_4096.csv +0 -0
  7. categorized_datasets_for_R1-Distill-Llama/BigVul_Sample/BigVul_Sample_2048_to_4096.pkl +3 -0
  8. categorized_datasets_for_R1-Distill-Llama/BigVul_Sample/BigVul_Sample_4096_to_6144.csv +0 -0
  9. categorized_datasets_for_R1-Distill-Llama/BigVul_Sample/BigVul_Sample_4096_to_6144.pkl +3 -0
  10. categorized_datasets_for_R1-Distill-Llama/BigVul_Sample/BigVul_Sample_512_to_1024.csv +3 -0
  11. categorized_datasets_for_R1-Distill-Llama/BigVul_Sample/BigVul_Sample_512_to_1024.pkl +3 -0
  12. categorized_datasets_for_R1-Distill-Llama/BigVul_Sample/BigVul_Sample_6144_to_8192.csv +0 -0
  13. categorized_datasets_for_R1-Distill-Llama/BigVul_Sample/BigVul_Sample_6144_to_8192.pkl +3 -0
  14. categorized_datasets_for_R1-Distill-Llama/BigVul_Sample/BigVul_Sample_8192_to_11000.csv +0 -0
  15. categorized_datasets_for_R1-Distill-Llama/BigVul_Sample/BigVul_Sample_8192_to_11000.pkl +3 -0
  16. categorized_datasets_for_R1-Distill-Llama/BigVul_Sample/BigVul_Sample_stats.json +47 -0
  17. categorized_datasets_for_R1-Distill-Llama/BigVul_Sample/BigVul_Sample_under_512.csv +3 -0
  18. categorized_datasets_for_R1-Distill-Llama/BigVul_Sample/BigVul_Sample_under_512.pkl +3 -0
  19. categorized_datasets_for_R1-Distill-Llama/DiverseVul_Sample/DiverseVul_Sample_1024_to_2048.jsonl +0 -0
  20. categorized_datasets_for_R1-Distill-Llama/DiverseVul_Sample/DiverseVul_Sample_1024_to_2048.pkl +3 -0
  21. categorized_datasets_for_R1-Distill-Llama/DiverseVul_Sample/DiverseVul_Sample_11000_to_15000.jsonl +0 -0
  22. categorized_datasets_for_R1-Distill-Llama/DiverseVul_Sample/DiverseVul_Sample_11000_to_15000.pkl +3 -0
  23. categorized_datasets_for_R1-Distill-Llama/DiverseVul_Sample/DiverseVul_Sample_2048_to_4096.jsonl +0 -0
  24. categorized_datasets_for_R1-Distill-Llama/DiverseVul_Sample/DiverseVul_Sample_2048_to_4096.pkl +3 -0
  25. categorized_datasets_for_R1-Distill-Llama/DiverseVul_Sample/DiverseVul_Sample_4096_to_6144.jsonl +0 -0
  26. categorized_datasets_for_R1-Distill-Llama/DiverseVul_Sample/DiverseVul_Sample_4096_to_6144.pkl +3 -0
  27. categorized_datasets_for_R1-Distill-Llama/DiverseVul_Sample/DiverseVul_Sample_512_to_1024.jsonl +0 -0
  28. categorized_datasets_for_R1-Distill-Llama/DiverseVul_Sample/DiverseVul_Sample_512_to_1024.pkl +3 -0
  29. categorized_datasets_for_R1-Distill-Llama/DiverseVul_Sample/DiverseVul_Sample_6144_to_8192.jsonl +0 -0
  30. categorized_datasets_for_R1-Distill-Llama/DiverseVul_Sample/DiverseVul_Sample_6144_to_8192.pkl +3 -0
  31. categorized_datasets_for_R1-Distill-Llama/DiverseVul_Sample/DiverseVul_Sample_8192_to_11000.jsonl +0 -0
  32. categorized_datasets_for_R1-Distill-Llama/DiverseVul_Sample/DiverseVul_Sample_8192_to_11000.pkl +3 -0
  33. categorized_datasets_for_R1-Distill-Llama/DiverseVul_Sample/DiverseVul_Sample_stats.json +47 -0
  34. categorized_datasets_for_R1-Distill-Llama/DiverseVul_Sample/DiverseVul_Sample_under_512.jsonl +0 -0
  35. categorized_datasets_for_R1-Distill-Llama/DiverseVul_Sample/DiverseVul_Sample_under_512.pkl +3 -0
  36. categorized_datasets_for_R1-Distill-Llama/PrimeVul_Sample/PrimeVul_Sample_1024_to_2048.jsonl +0 -0
  37. categorized_datasets_for_R1-Distill-Llama/PrimeVul_Sample/PrimeVul_Sample_1024_to_2048.pkl +3 -0
  38. categorized_datasets_for_R1-Distill-Llama/PrimeVul_Sample/PrimeVul_Sample_11000_to_15000.jsonl +0 -0
  39. categorized_datasets_for_R1-Distill-Llama/PrimeVul_Sample/PrimeVul_Sample_11000_to_15000.pkl +3 -0
  40. categorized_datasets_for_R1-Distill-Llama/PrimeVul_Sample/PrimeVul_Sample_2048_to_4096.jsonl +0 -0
  41. categorized_datasets_for_R1-Distill-Llama/PrimeVul_Sample/PrimeVul_Sample_2048_to_4096.pkl +3 -0
  42. categorized_datasets_for_R1-Distill-Llama/PrimeVul_Sample/PrimeVul_Sample_4096_to_6144.jsonl +0 -0
  43. categorized_datasets_for_R1-Distill-Llama/PrimeVul_Sample/PrimeVul_Sample_4096_to_6144.pkl +3 -0
  44. categorized_datasets_for_R1-Distill-Llama/PrimeVul_Sample/PrimeVul_Sample_512_to_1024.jsonl +0 -0
  45. categorized_datasets_for_R1-Distill-Llama/PrimeVul_Sample/PrimeVul_Sample_512_to_1024.pkl +3 -0
  46. categorized_datasets_for_R1-Distill-Llama/PrimeVul_Sample/PrimeVul_Sample_6144_to_8192.jsonl +0 -0
  47. categorized_datasets_for_R1-Distill-Llama/PrimeVul_Sample/PrimeVul_Sample_6144_to_8192.pkl +3 -0
  48. categorized_datasets_for_R1-Distill-Llama/PrimeVul_Sample/PrimeVul_Sample_8192_to_11000.jsonl +0 -0
  49. categorized_datasets_for_R1-Distill-Llama/PrimeVul_Sample/PrimeVul_Sample_8192_to_11000.pkl +3 -0
  50. categorized_datasets_for_R1-Distill-Llama/PrimeVul_Sample/PrimeVul_Sample_stats.json +47 -0
.gitattributes CHANGED
@@ -72,3 +72,5 @@ categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_512_to_1024.csv filt
72
  categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_under_512.csv filter=lfs diff=lfs merge=lfs -text
73
  categorized_datasets_for_QwenCoder/BigVul_Sample/BigVul_Sample_512_to_1024.csv filter=lfs diff=lfs merge=lfs -text
74
  categorized_datasets_for_QwenCoder/BigVul_Sample/BigVul_Sample_under_512.csv filter=lfs diff=lfs merge=lfs -text
 
 
 
72
  categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_under_512.csv filter=lfs diff=lfs merge=lfs -text
73
  categorized_datasets_for_QwenCoder/BigVul_Sample/BigVul_Sample_512_to_1024.csv filter=lfs diff=lfs merge=lfs -text
74
  categorized_datasets_for_QwenCoder/BigVul_Sample/BigVul_Sample_under_512.csv filter=lfs diff=lfs merge=lfs -text
75
+ categorized_datasets_for_R1-Distill-Llama/BigVul_Sample/BigVul_Sample_512_to_1024.csv filter=lfs diff=lfs merge=lfs -text
76
+ categorized_datasets_for_R1-Distill-Llama/BigVul_Sample/BigVul_Sample_under_512.csv filter=lfs diff=lfs merge=lfs -text
categorized_datasets_for_R1-Distill-Llama/BigVul_Sample/BigVul_Sample_1024_to_2048.csv ADDED
The diff for this file is too large to render. See raw diff
 
categorized_datasets_for_R1-Distill-Llama/BigVul_Sample/BigVul_Sample_1024_to_2048.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ae21c776191fc51f8ea4c8f930e6136652c1db8484e1d00a2396801b771b375c
3
+ size 4991479
categorized_datasets_for_R1-Distill-Llama/BigVul_Sample/BigVul_Sample_11000_to_15000.csv ADDED
@@ -0,0 +1,2575 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ idx,func_before,vul,func_after,patch,code_token_length,total_token_length,max_tokens_setting
2
+ 18325,"static void cmdloop(void)
3
+ {
4
+ int c;
5
+ int usinguid, havepartition, havenamespace, recursive;
6
+ static struct buf tag, cmd, arg1, arg2, arg3;
7
+ char *p, shut[MAX_MAILBOX_PATH+1], cmdname[100];
8
+ const char *err;
9
+ const char * commandmintimer;
10
+ double commandmintimerd = 0.0;
11
+ struct sync_reserve_list *reserve_list =
12
+ sync_reserve_list_create(SYNC_MESSAGE_LIST_HASH_SIZE);
13
+ struct applepushserviceargs applepushserviceargs;
14
+
15
+ prot_printf(imapd_out, ""* OK [CAPABILITY "");
16
+ capa_response(CAPA_PREAUTH);
17
+ prot_printf(imapd_out, ""]"");
18
+ if (config_serverinfo) prot_printf(imapd_out, "" %s"", config_servername);
19
+ if (config_serverinfo == IMAP_ENUM_SERVERINFO_ON) {
20
+ prot_printf(imapd_out, "" Cyrus IMAP %s"", cyrus_version());
21
+ }
22
+ prot_printf(imapd_out, "" server ready\r\n"");
23
+
24
+ /* clear cancelled flag if present before the next command */
25
+ cmd_cancelled();
26
+
27
+ motd_file();
28
+
29
+ /* Get command timer logging paramater. This string
30
+ * is a time in seconds. Any command that takes >=
31
+ * this time to execute is logged */
32
+ commandmintimer = config_getstring(IMAPOPT_COMMANDMINTIMER);
33
+ cmdtime_settimer(commandmintimer ? 1 : 0);
34
+ if (commandmintimer) {
35
+ commandmintimerd = atof(commandmintimer);
36
+ }
37
+
38
+ for (;;) {
39
+ /* Release any held index */
40
+ index_release(imapd_index);
41
+
42
+ /* Flush any buffered output */
43
+ prot_flush(imapd_out);
44
+ if (backend_current) prot_flush(backend_current->out);
45
+
46
+ /* command no longer running */
47
+ proc_register(config_ident, imapd_clienthost, imapd_userid, index_mboxname(imapd_index), NULL);
48
+
49
+ /* Check for shutdown file */
50
+ if ( !imapd_userisadmin && imapd_userid &&
51
+ (shutdown_file(shut, sizeof(shut)) ||
52
+ userdeny(imapd_userid, config_ident, shut, sizeof(shut)))) {
53
+ for (p = shut; *p == '['; p++); /* can't have [ be first char */
54
+ prot_printf(imapd_out, ""* BYE [ALERT] %s\r\n"", p);
55
+ telemetry_rusage(imapd_userid);
56
+ shut_down(0);
57
+ }
58
+
59
+ signals_poll();
60
+
61
+ if (!proxy_check_input(protin, imapd_in, imapd_out,
62
+ backend_current ? backend_current->in : NULL,
63
+ NULL, 0)) {
64
+ /* No input from client */
65
+ continue;
66
+ }
67
+
68
+ /* Parse tag */
69
+ c = getword(imapd_in, &tag);
70
+ if (c == EOF) {
71
+ if ((err = prot_error(imapd_in))!=NULL
72
+ && strcmp(err, PROT_EOF_STRING)) {
73
+ syslog(LOG_WARNING, ""%s, closing connection"", err);
74
+ prot_printf(imapd_out, ""* BYE %s\r\n"", err);
75
+ }
76
+ goto done;
77
+ }
78
+ if (c != ' ' || !imparse_isatom(tag.s) || (tag.s[0] == '*' && !tag.s[1])) {
79
+ prot_printf(imapd_out, ""* BAD Invalid tag\r\n"");
80
+ eatline(imapd_in, c);
81
+ continue;
82
+ }
83
+
84
+ /* Parse command name */
85
+ c = getword(imapd_in, &cmd);
86
+ if (!cmd.s[0]) {
87
+ prot_printf(imapd_out, ""%s BAD Null command\r\n"", tag.s);
88
+ eatline(imapd_in, c);
89
+ continue;
90
+ }
91
+ lcase(cmd.s);
92
+ xstrncpy(cmdname, cmd.s, 99);
93
+ cmd.s[0] = toupper((unsigned char) cmd.s[0]);
94
+
95
+ if (config_getswitch(IMAPOPT_CHATTY))
96
+ syslog(LOG_NOTICE, ""command: %s %s"", tag.s, cmd.s);
97
+
98
+ proc_register(config_ident, imapd_clienthost, imapd_userid, index_mboxname(imapd_index), cmd.s);
99
+
100
+ /* if we need to force a kick, do so */
101
+ if (referral_kick) {
102
+ kick_mupdate();
103
+ referral_kick = 0;
104
+ }
105
+
106
+ if (plaintextloginalert) {
107
+ prot_printf(imapd_out, ""* OK [ALERT] %s\r\n"",
108
+ plaintextloginalert);
109
+ plaintextloginalert = NULL;
110
+ }
111
+
112
+ /* Only Authenticate/Enable/Login/Logout/Noop/Capability/Id/Starttls
113
+ allowed when not logged in */
114
+ if (!imapd_userid && !strchr(""AELNCIS"", cmd.s[0])) goto nologin;
115
+
116
+ /* Start command timer */
117
+ cmdtime_starttimer();
118
+
119
+ /* note that about half the commands (the common ones that don't
120
+ hit the mailboxes file) now close the mailboxes file just in
121
+ case it was open. */
122
+ switch (cmd.s[0]) {
123
+ case 'A':
124
+ if (!strcmp(cmd.s, ""Authenticate"")) {
125
+ int haveinitresp = 0;
126
+
127
+ if (c != ' ') goto missingargs;
128
+ c = getword(imapd_in, &arg1);
129
+ if (!imparse_isatom(arg1.s)) {
130
+ prot_printf(imapd_out, ""%s BAD Invalid authenticate mechanism\r\n"", tag.s);
131
+ eatline(imapd_in, c);
132
+ continue;
133
+ }
134
+ if (c == ' ') {
135
+ haveinitresp = 1;
136
+ c = getword(imapd_in, &arg2);
137
+ if (c == EOF) goto missingargs;
138
+ }
139
+ if (c == '\r') c = prot_getc(imapd_in);
140
+ if (c != '\n') goto extraargs;
141
+
142
+ if (imapd_userid) {
143
+ prot_printf(imapd_out, ""%s BAD Already authenticated\r\n"", tag.s);
144
+ continue;
145
+ }
146
+ cmd_authenticate(tag.s, arg1.s, haveinitresp ? arg2.s : NULL);
147
+
148
+ snmp_increment(AUTHENTICATE_COUNT, 1);
149
+ }
150
+ else if (!imapd_userid) goto nologin;
151
+ else if (!strcmp(cmd.s, ""Append"")) {
152
+ if (c != ' ') goto missingargs;
153
+ c = getastring(imapd_in, imapd_out, &arg1);
154
+ if (c != ' ') goto missingargs;
155
+
156
+ cmd_append(tag.s, arg1.s, NULL);
157
+
158
+ snmp_increment(APPEND_COUNT, 1);
159
+ }
160
+ else goto badcmd;
161
+ break;
162
+
163
+ case 'C':
164
+ if (!strcmp(cmd.s, ""Capability"")) {
165
+ if (c == '\r') c = prot_getc(imapd_in);
166
+ if (c != '\n') goto extraargs;
167
+ cmd_capability(tag.s);
168
+
169
+ snmp_increment(CAPABILITY_COUNT, 1);
170
+ }
171
+ else if (!imapd_userid) goto nologin;
172
+ #ifdef HAVE_ZLIB
173
+ else if (!strcmp(cmd.s, ""Compress"")) {
174
+ if (c != ' ') goto missingargs;
175
+ c = getword(imapd_in, &arg1);
176
+ if (c == EOF) goto missingargs;
177
+ if (c == '\r') c = prot_getc(imapd_in);
178
+ if (c != '\n') goto extraargs;
179
+
180
+ cmd_compress(tag.s, arg1.s);
181
+
182
+ snmp_increment(COMPRESS_COUNT, 1);
183
+ }
184
+ #endif /* HAVE_ZLIB */
185
+ else if (!strcmp(cmd.s, ""Check"")) {
186
+ if (!imapd_index && !backend_current) goto nomailbox;
187
+ if (c == '\r') c = prot_getc(imapd_in);
188
+ if (c != '\n') goto extraargs;
189
+
190
+ cmd_noop(tag.s, cmd.s);
191
+
192
+ snmp_increment(CHECK_COUNT, 1);
193
+ }
194
+ else if (!strcmp(cmd.s, ""Copy"")) {
195
+ if (!imapd_index && !backend_current) goto nomailbox;
196
+ usinguid = 0;
197
+ if (c != ' ') goto missingargs;
198
+ copy:
199
+ c = getword(imapd_in, &arg1);
200
+ if (c == '\r') goto missingargs;
201
+ if (c != ' ' || !imparse_issequence(arg1.s)) goto badsequence;
202
+ c = getastring(imapd_in, imapd_out, &arg2);
203
+ if (c == EOF) goto missingargs;
204
+ if (c == '\r') c = prot_getc(imapd_in);
205
+ if (c != '\n') goto extraargs;
206
+
207
+ cmd_copy(tag.s, arg1.s, arg2.s, usinguid, /*ismove*/0);
208
+
209
+ snmp_increment(COPY_COUNT, 1);
210
+ }
211
+ else if (!strcmp(cmd.s, ""Create"")) {
212
+ struct dlist *extargs = NULL;
213
+
214
+ if (c != ' ') goto missingargs;
215
+ c = getastring(imapd_in, imapd_out, &arg1);
216
+ if (c == EOF) goto missingargs;
217
+ if (c == ' ') {
218
+ c = parsecreateargs(&extargs);
219
+ if (c == EOF) goto badpartition;
220
+ }
221
+ if (c == '\r') c = prot_getc(imapd_in);
222
+ if (c != '\n') goto extraargs;
223
+ cmd_create(tag.s, arg1.s, extargs, 0);
224
+ dlist_free(&extargs);
225
+
226
+ snmp_increment(CREATE_COUNT, 1);
227
+ }
228
+ else if (!strcmp(cmd.s, ""Close"")) {
229
+ if (!imapd_index && !backend_current) goto nomailbox;
230
+ if (c == '\r') c = prot_getc(imapd_in);
231
+ if (c != '\n') goto extraargs;
232
+
233
+ cmd_close(tag.s, cmd.s);
234
+
235
+ snmp_increment(CLOSE_COUNT, 1);
236
+ }
237
+ else goto badcmd;
238
+ break;
239
+
240
+ case 'D':
241
+ if (!strcmp(cmd.s, ""Delete"")) {
242
+ if (c != ' ') goto missingargs;
243
+ c = getastring(imapd_in, imapd_out, &arg1);
244
+ if (c == EOF) goto missingargs;
245
+ if (c == '\r') c = prot_getc(imapd_in);
246
+ if (c != '\n') goto extraargs;
247
+ cmd_delete(tag.s, arg1.s, 0, 0);
248
+
249
+ snmp_increment(DELETE_COUNT, 1);
250
+ }
251
+ else if (!strcmp(cmd.s, ""Deleteacl"")) {
252
+ if (c != ' ') goto missingargs;
253
+ c = getastring(imapd_in, imapd_out, &arg1);
254
+ if (c != ' ') goto missingargs;
255
+ c = getastring(imapd_in, imapd_out, &arg2);
256
+ if (c == EOF) goto missingargs;
257
+ if (c == '\r') c = prot_getc(imapd_in);
258
+ if (c != '\n') goto extraargs;
259
+ cmd_setacl(tag.s, arg1.s, arg2.s, NULL);
260
+
261
+ snmp_increment(DELETEACL_COUNT, 1);
262
+ }
263
+ else if (!strcmp(cmd.s, ""Dump"")) {
264
+ int uid_start = 0;
265
+
266
+ if(c != ' ') goto missingargs;
267
+ c = getastring(imapd_in, imapd_out, &arg1);
268
+ if(c == ' ') {
269
+ c = getastring(imapd_in, imapd_out, &arg2);
270
+ if(!imparse_isnumber(arg2.s)) goto extraargs;
271
+ uid_start = atoi(arg2.s);
272
+ }
273
+
274
+ if(c == '\r') c = prot_getc(imapd_in);
275
+ if(c != '\n') goto extraargs;
276
+
277
+ cmd_dump(tag.s, arg1.s, uid_start);
278
+ /* snmp_increment(DUMP_COUNT, 1);*/
279
+ }
280
+ else goto badcmd;
281
+ break;
282
+
283
+ case 'E':
284
+ if (!imapd_userid) goto nologin;
285
+ else if (!strcmp(cmd.s, ""Enable"")) {
286
+ if (c != ' ') goto missingargs;
287
+
288
+ cmd_enable(tag.s);
289
+ }
290
+ else if (!strcmp(cmd.s, ""Expunge"")) {
291
+ if (!imapd_index && !backend_current) goto nomailbox;
292
+ if (c == '\r') c = prot_getc(imapd_in);
293
+ if (c != '\n') goto extraargs;
294
+
295
+ cmd_expunge(tag.s, 0);
296
+
297
+ snmp_increment(EXPUNGE_COUNT, 1);
298
+ }
299
+ else if (!strcmp(cmd.s, ""Examine"")) {
300
+ if (c != ' ') goto missingargs;
301
+ c = getastring(imapd_in, imapd_out, &arg1);
302
+ if (c == EOF) goto missingargs;
303
+ prot_ungetc(c, imapd_in);
304
+
305
+ cmd_select(tag.s, cmd.s, arg1.s);
306
+
307
+ snmp_increment(EXAMINE_COUNT, 1);
308
+ }
309
+ else goto badcmd;
310
+ break;
311
+
312
+ case 'F':
313
+ if (!strcmp(cmd.s, ""Fetch"")) {
314
+ if (!imapd_index && !backend_current) goto nomailbox;
315
+ usinguid = 0;
316
+ if (c != ' ') goto missingargs;
317
+ fetch:
318
+ c = getword(imapd_in, &arg1);
319
+ if (c == '\r') goto missingargs;
320
+ if (c != ' ' || !imparse_issequence(arg1.s)) goto badsequence;
321
+
322
+ cmd_fetch(tag.s, arg1.s, usinguid);
323
+
324
+ snmp_increment(FETCH_COUNT, 1);
325
+ }
326
+ else goto badcmd;
327
+ break;
328
+
329
+ case 'G':
330
+ if (!strcmp(cmd.s, ""Getacl"")) {
331
+ if (c != ' ') goto missingargs;
332
+ c = getastring(imapd_in, imapd_out, &arg1);
333
+ if (c == EOF) goto missingargs;
334
+ if (c == '\r') c = prot_getc(imapd_in);
335
+ if (c != '\n') goto extraargs;
336
+ cmd_getacl(tag.s, arg1.s);
337
+
338
+ snmp_increment(GETACL_COUNT, 1);
339
+ }
340
+ else if (!strcmp(cmd.s, ""Getannotation"")) {
341
+ if (c != ' ') goto missingargs;
342
+ c = getastring(imapd_in, imapd_out, &arg1);
343
+ if (c != ' ') goto missingargs;
344
+
345
+ cmd_getannotation(tag.s, arg1.s);
346
+
347
+ snmp_increment(GETANNOTATION_COUNT, 1);
348
+ }
349
+ else if (!strcmp(cmd.s, ""Getmetadata"")) {
350
+ if (c != ' ') goto missingargs;
351
+
352
+ cmd_getmetadata(tag.s);
353
+
354
+ snmp_increment(GETANNOTATION_COUNT, 1);
355
+ }
356
+ else if (!strcmp(cmd.s, ""Getquota"")) {
357
+ if (c != ' ') goto missingargs;
358
+ c = getastring(imapd_in, imapd_out, &arg1);
359
+ if (c == EOF) goto missingargs;
360
+ if (c == '\r') c = prot_getc(imapd_in);
361
+ if (c != '\n') goto extraargs;
362
+ cmd_getquota(tag.s, arg1.s);
363
+
364
+ snmp_increment(GETQUOTA_COUNT, 1);
365
+ }
366
+ else if (!strcmp(cmd.s, ""Getquotaroot"")) {
367
+ if (c != ' ') goto missingargs;
368
+ c = getastring(imapd_in, imapd_out, &arg1);
369
+ if (c == EOF) goto missingargs;
370
+ if (c == '\r') c = prot_getc(imapd_in);
371
+ if (c != '\n') goto extraargs;
372
+ cmd_getquotaroot(tag.s, arg1.s);
373
+
374
+ snmp_increment(GETQUOTAROOT_COUNT, 1);
375
+ }
376
+ #ifdef HAVE_SSL
377
+ else if (!strcmp(cmd.s, ""Genurlauth"")) {
378
+ if (c != ' ') goto missingargs;
379
+
380
+ cmd_genurlauth(tag.s);
381
+ /* snmp_increment(GENURLAUTH_COUNT, 1);*/
382
+ }
383
+ #endif
384
+ else goto badcmd;
385
+ break;
386
+
387
+ case 'I':
388
+ if (!strcmp(cmd.s, ""Id"")) {
389
+ if (c != ' ') goto missingargs;
390
+ cmd_id(tag.s);
391
+
392
+ snmp_increment(ID_COUNT, 1);
393
+ }
394
+ else if (!imapd_userid) goto nologin;
395
+ else if (!strcmp(cmd.s, ""Idle"") && idle_enabled()) {
396
+ if (c == '\r') c = prot_getc(imapd_in);
397
+ if (c != '\n') goto extraargs;
398
+ cmd_idle(tag.s);
399
+
400
+ snmp_increment(IDLE_COUNT, 1);
401
+ }
402
+ else goto badcmd;
403
+ break;
404
+
405
+ case 'L':
406
+ if (!strcmp(cmd.s, ""Login"")) {
407
+ if (c != ' ') goto missingargs;
408
+ c = getastring(imapd_in, imapd_out, &arg1);
409
+ if(c != ' ') goto missingargs;
410
+
411
+ cmd_login(tag.s, arg1.s);
412
+
413
+ snmp_increment(LOGIN_COUNT, 1);
414
+ }
415
+ else if (!strcmp(cmd.s, ""Logout"")) {
416
+ if (c == '\r') c = prot_getc(imapd_in);
417
+ if (c != '\n') goto extraargs;
418
+
419
+ snmp_increment(LOGOUT_COUNT, 1);
420
+
421
+ /* force any responses from our selected backend */
422
+ if (backend_current) imapd_check(NULL, 0);
423
+
424
+ prot_printf(imapd_out, ""* BYE %s\r\n"",
425
+ error_message(IMAP_BYE_LOGOUT));
426
+ prot_printf(imapd_out, ""%s OK %s\r\n"", tag.s,
427
+ error_message(IMAP_OK_COMPLETED));
428
+
429
+ if (imapd_userid && *imapd_userid) {
430
+ telemetry_rusage(imapd_userid);
431
+ }
432
+
433
+ goto done;
434
+ }
435
+ else if (!imapd_userid) goto nologin;
436
+ else if (!strcmp(cmd.s, ""List"")) {
437
+ struct listargs listargs;
438
+
439
+ if (c != ' ') goto missingargs;
440
+
441
+ memset(&listargs, 0, sizeof(struct listargs));
442
+ listargs.ret = LIST_RET_CHILDREN;
443
+ getlistargs(tag.s, &listargs);
444
+ if (listargs.pat.count) cmd_list(tag.s, &listargs);
445
+
446
+ snmp_increment(LIST_COUNT, 1);
447
+ }
448
+ else if (!strcmp(cmd.s, ""Lsub"")) {
449
+ struct listargs listargs;
450
+
451
+ c = getastring(imapd_in, imapd_out, &arg1);
452
+ if (c != ' ') goto missingargs;
453
+ c = getastring(imapd_in, imapd_out, &arg2);
454
+ if (c == '\r') c = prot_getc(imapd_in);
455
+ if (c != '\n') goto extraargs;
456
+
457
+ memset(&listargs, 0, sizeof(struct listargs));
458
+ listargs.cmd = LIST_CMD_LSUB;
459
+ listargs.sel = LIST_SEL_SUBSCRIBED;
460
+ if (!strcasecmpsafe(imapd_magicplus, ""+dav""))
461
+ listargs.sel |= LIST_SEL_DAV;
462
+ listargs.ref = arg1.s;
463
+ strarray_append(&listargs.pat, arg2.s);
464
+
465
+ cmd_list(tag.s, &listargs);
466
+
467
+ snmp_increment(LSUB_COUNT, 1);
468
+ }
469
+ else if (!strcmp(cmd.s, ""Listrights"")) {
470
+ c = getastring(imapd_in, imapd_out, &arg1);
471
+ if (c != ' ') goto missingargs;
472
+ c = getastring(imapd_in, imapd_out, &arg2);
473
+ if (c == '\r') c = prot_getc(imapd_in);
474
+ if (c != '\n') goto extraargs;
475
+ cmd_listrights(tag.s, arg1.s, arg2.s);
476
+
477
+ snmp_increment(LISTRIGHTS_COUNT, 1);
478
+ }
479
+ else if (!strcmp(cmd.s, ""Localappend"")) {
480
+ /* create a local-only mailbox */
481
+ if (c != ' ') goto missingargs;
482
+ c = getastring(imapd_in, imapd_out, &arg1);
483
+ if (c != ' ') goto missingargs;
484
+ c = getastring(imapd_in, imapd_out, &arg2);
485
+ if (c != ' ') goto missingargs;
486
+
487
+ cmd_append(tag.s, arg1.s, *arg2.s ? arg2.s : NULL);
488
+
489
+ snmp_increment(APPEND_COUNT, 1);
490
+ }
491
+ else if (!strcmp(cmd.s, ""Localcreate"")) {
492
+ /* create a local-only mailbox */
493
+ struct dlist *extargs = NULL;
494
+
495
+ if (c != ' ') goto missingargs;
496
+ c = getastring(imapd_in, imapd_out, &arg1);
497
+ if (c == EOF) goto missingargs;
498
+ if (c == ' ') {
499
+ c = parsecreateargs(&extargs);
500
+ if (c == EOF) goto badpartition;
501
+ }
502
+ if (c == '\r') c = prot_getc(imapd_in);
503
+ if (c != '\n') goto extraargs;
504
+ cmd_create(tag.s, arg1.s, extargs, 1);
505
+ dlist_free(&extargs);
506
+
507
+ /* xxxx snmp_increment(CREATE_COUNT, 1); */
508
+ }
509
+ else if (!strcmp(cmd.s, ""Localdelete"")) {
510
+ /* delete a mailbox locally only */
511
+ if (c != ' ') goto missingargs;
512
+ c = getastring(imapd_in, imapd_out, &arg1);
513
+ if (c == EOF) goto missingargs;
514
+ if (c == '\r') c = prot_getc(imapd_in);
515
+ if (c != '\n') goto extraargs;
516
+ cmd_delete(tag.s, arg1.s, 1, 1);
517
+
518
+ /* xxxx snmp_increment(DELETE_COUNT, 1); */
519
+ }
520
+ else goto badcmd;
521
+ break;
522
+
523
+ case 'M':
524
+ if (!strcmp(cmd.s, ""Myrights"")) {
525
+ if (c != ' ') goto missingargs;
526
+ c = getastring(imapd_in, imapd_out, &arg1);
527
+ if (c == EOF) goto missingargs;
528
+ if (c == '\r') c = prot_getc(imapd_in);
529
+ if (c != '\n') goto extraargs;
530
+ cmd_myrights(tag.s, arg1.s);
531
+
532
+ /* xxxx snmp_increment(MYRIGHTS_COUNT, 1); */
533
+ }
534
+ else if (!strcmp(cmd.s, ""Mupdatepush"")) {
535
+ if (c != ' ') goto missingargs;
536
+ c = getastring(imapd_in, imapd_out, &arg1);
537
+ if(c == EOF) goto missingargs;
538
+ if(c == '\r') c = prot_getc(imapd_in);
539
+ if(c != '\n') goto extraargs;
540
+ cmd_mupdatepush(tag.s, arg1.s);
541
+
542
+ /* xxxx snmp_increment(MUPDATEPUSH_COUNT, 1); */
543
+ }
544
+ else if (!strcmp(cmd.s, ""Move"")) {
545
+ if (!imapd_index && !backend_current) goto nomailbox;
546
+ usinguid = 0;
547
+ if (c != ' ') goto missingargs;
548
+ move:
549
+ c = getword(imapd_in, &arg1);
550
+ if (c == '\r') goto missingargs;
551
+ if (c != ' ' || !imparse_issequence(arg1.s)) goto badsequence;
552
+ c = getastring(imapd_in, imapd_out, &arg2);
553
+ if (c == EOF) goto missingargs;
554
+ if (c == '\r') c = prot_getc(imapd_in);
555
+ if (c != '\n') goto extraargs;
556
+
557
+ cmd_copy(tag.s, arg1.s, arg2.s, usinguid, /*ismove*/1);
558
+
559
+ snmp_increment(COPY_COUNT, 1);
560
+ } else goto badcmd;
561
+ break;
562
+
563
+ case 'N':
564
+ if (!strcmp(cmd.s, ""Noop"")) {
565
+ if (c == '\r') c = prot_getc(imapd_in);
566
+ if (c != '\n') goto extraargs;
567
+
568
+ cmd_noop(tag.s, cmd.s);
569
+
570
+ /* xxxx snmp_increment(NOOP_COUNT, 1); */
571
+ }
572
+ else if (!imapd_userid) goto nologin;
573
+ else if (!strcmp(cmd.s, ""Namespace"")) {
574
+ if (c == '\r') c = prot_getc(imapd_in);
575
+ if (c != '\n') goto extraargs;
576
+ cmd_namespace(tag.s);
577
+
578
+ /* xxxx snmp_increment(NAMESPACE_COUNT, 1); */
579
+ }
580
+ else goto badcmd;
581
+ break;
582
+
583
+ case 'R':
584
+ if (!strcmp(cmd.s, ""Rename"")) {
585
+ havepartition = 0;
586
+ if (c != ' ') goto missingargs;
587
+ c = getastring(imapd_in, imapd_out, &arg1);
588
+ if (c != ' ') goto missingargs;
589
+ c = getastring(imapd_in, imapd_out, &arg2);
590
+ if (c == EOF) goto missingargs;
591
+ if (c == ' ') {
592
+ havepartition = 1;
593
+ c = getword(imapd_in, &arg3);
594
+ if (!imparse_isatom(arg3.s)) goto badpartition;
595
+ }
596
+ if (c == '\r') c = prot_getc(imapd_in);
597
+ if (c != '\n') goto extraargs;
598
+ cmd_rename(tag.s, arg1.s, arg2.s, havepartition ? arg3.s : 0);
599
+
600
+ /* xxxx snmp_increment(RENAME_COUNT, 1); */
601
+ } else if(!strcmp(cmd.s, ""Reconstruct"")) {
602
+ recursive = 0;
603
+ if (c != ' ') goto missingargs;
604
+ c = getastring(imapd_in, imapd_out, &arg1);
605
+ if(c == ' ') {
606
+ /* Optional RECURSEIVE argument */
607
+ c = getword(imapd_in, &arg2);
608
+ if(!imparse_isatom(arg2.s))
609
+ goto extraargs;
610
+ else if(!strcasecmp(arg2.s, ""RECURSIVE""))
611
+ recursive = 1;
612
+ else
613
+ goto extraargs;
614
+ }
615
+ if(c == '\r') c = prot_getc(imapd_in);
616
+ if(c != '\n') goto extraargs;
617
+ cmd_reconstruct(tag.s, arg1.s, recursive);
618
+
619
+ /* snmp_increment(RECONSTRUCT_COUNT, 1); */
620
+ }
621
+ else if (!strcmp(cmd.s, ""Rlist"")) {
622
+ struct listargs listargs;
623
+
624
+ c = getastring(imapd_in, imapd_out, &arg1);
625
+ if (c != ' ') goto missingargs;
626
+ c = getastring(imapd_in, imapd_out, &arg2);
627
+ if (c == '\r') c = prot_getc(imapd_in);
628
+ if (c != '\n') goto extraargs;
629
+
630
+ memset(&listargs, 0, sizeof(struct listargs));
631
+ listargs.sel = LIST_SEL_REMOTE;
632
+ listargs.ret = LIST_RET_CHILDREN;
633
+ listargs.ref = arg1.s;
634
+ strarray_append(&listargs.pat, arg2.s);
635
+
636
+ cmd_list(tag.s, &listargs);
637
+
638
+ /* snmp_increment(LIST_COUNT, 1); */
639
+ }
640
+ else if (!strcmp(cmd.s, ""Rlsub"")) {
641
+ struct listargs listargs;
642
+
643
+ c = getastring(imapd_in, imapd_out, &arg1);
644
+ if (c != ' ') goto missingargs;
645
+ c = getastring(imapd_in, imapd_out, &arg2);
646
+ if (c == '\r') c = prot_getc(imapd_in);
647
+ if (c != '\n') goto extraargs;
648
+
649
+ memset(&listargs, 0, sizeof(struct listargs));
650
+ listargs.cmd = LIST_CMD_LSUB;
651
+ listargs.sel = LIST_SEL_REMOTE | LIST_SEL_SUBSCRIBED;
652
+ listargs.ref = arg1.s;
653
+ strarray_append(&listargs.pat, arg2.s);
654
+
655
+ cmd_list(tag.s, &listargs);
656
+
657
+ /* snmp_increment(LSUB_COUNT, 1); */
658
+ }
659
+ #ifdef HAVE_SSL
660
+ else if (!strcmp(cmd.s, ""Resetkey"")) {
661
+ int have_mbox = 0, have_mech = 0;
662
+
663
+ if (c == ' ') {
664
+ have_mbox = 1;
665
+ c = getastring(imapd_in, imapd_out, &arg1);
666
+ if (c == EOF) goto missingargs;
667
+ if (c == ' ') {
668
+ have_mech = 1;
669
+ c = getword(imapd_in, &arg2);
670
+ }
671
+ }
672
+
673
+ if (c == '\r') c = prot_getc(imapd_in);
674
+ if (c != '\n') goto extraargs;
675
+ cmd_resetkey(tag.s, have_mbox ? arg1.s : 0,
676
+ have_mech ? arg2.s : 0);
677
+ /* snmp_increment(RESETKEY_COUNT, 1);*/
678
+ }
679
+ #endif
680
+ else goto badcmd;
681
+ break;
682
+
683
+ case 'S':
684
+ if (!strcmp(cmd.s, ""Starttls"")) {
685
+ if (!tls_enabled()) {
686
+ /* we don't support starttls */
687
+ goto badcmd;
688
+ }
689
+
690
+ if (c == '\r') c = prot_getc(imapd_in);
691
+ if (c != '\n') goto extraargs;
692
+
693
+ /* XXX discard any input pipelined after STARTTLS */
694
+ prot_flush(imapd_in);
695
+
696
+ /* if we've already done SASL fail */
697
+ if (imapd_userid != NULL) {
698
+ prot_printf(imapd_out,
699
+ ""%s BAD Can't Starttls after authentication\r\n"", tag.s);
700
+ continue;
701
+ }
702
+
703
+ /* if we've already done COMPRESS fail */
704
+ if (imapd_compress_done == 1) {
705
+ prot_printf(imapd_out,
706
+ ""%s BAD Can't Starttls after Compress\r\n"", tag.s);
707
+ continue;
708
+ }
709
+
710
+ /* check if already did a successful tls */
711
+ if (imapd_starttls_done == 1) {
712
+ prot_printf(imapd_out,
713
+ ""%s BAD Already did a successful Starttls\r\n"",
714
+ tag.s);
715
+ continue;
716
+ }
717
+ cmd_starttls(tag.s, 0);
718
+
719
+ snmp_increment(STARTTLS_COUNT, 1);
720
+ continue;
721
+ }
722
+ if (!imapd_userid) {
723
+ goto nologin;
724
+ } else if (!strcmp(cmd.s, ""Store"")) {
725
+ if (!imapd_index && !backend_current) goto nomailbox;
726
+ usinguid = 0;
727
+ if (c != ' ') goto missingargs;
728
+ store:
729
+ c = getword(imapd_in, &arg1);
730
+ if (c != ' ' || !imparse_issequence(arg1.s)) goto badsequence;
731
+
732
+ cmd_store(tag.s, arg1.s, usinguid);
733
+
734
+ snmp_increment(STORE_COUNT, 1);
735
+ }
736
+ else if (!strcmp(cmd.s, ""Select"")) {
737
+ if (c != ' ') goto missingargs;
738
+ c = getastring(imapd_in, imapd_out, &arg1);
739
+ if (c == EOF) goto missingargs;
740
+ prot_ungetc(c, imapd_in);
741
+
742
+ cmd_select(tag.s, cmd.s, arg1.s);
743
+
744
+ snmp_increment(SELECT_COUNT, 1);
745
+ }
746
+ else if (!strcmp(cmd.s, ""Search"")) {
747
+ if (!imapd_index && !backend_current) goto nomailbox;
748
+ usinguid = 0;
749
+ if (c != ' ') goto missingargs;
750
+ search:
751
+
752
+ cmd_search(tag.s, usinguid);
753
+
754
+ snmp_increment(SEARCH_COUNT, 1);
755
+ }
756
+ else if (!strcmp(cmd.s, ""Subscribe"")) {
757
+ if (c != ' ') goto missingargs;
758
+ havenamespace = 0;
759
+ c = getastring(imapd_in, imapd_out, &arg1);
760
+ if (c == ' ') {
761
+ havenamespace = 1;
762
+ c = getastring(imapd_in, imapd_out, &arg2);
763
+ }
764
+ if (c == EOF) goto missingargs;
765
+ if (c == '\r') c = prot_getc(imapd_in);
766
+ if (c != '\n') goto extraargs;
767
+ if (havenamespace) {
768
+ cmd_changesub(tag.s, arg1.s, arg2.s, 1);
769
+ }
770
+ else {
771
+ cmd_changesub(tag.s, (char *)0, arg1.s, 1);
772
+ }
773
+ snmp_increment(SUBSCRIBE_COUNT, 1);
774
+ }
775
+ else if (!strcmp(cmd.s, ""Setacl"")) {
776
+ if (c != ' ') goto missingargs;
777
+ c = getastring(imapd_in, imapd_out, &arg1);
778
+ if (c != ' ') goto missingargs;
779
+ c = getastring(imapd_in, imapd_out, &arg2);
780
+ if (c != ' ') goto missingargs;
781
+ c = getastring(imapd_in, imapd_out, &arg3);
782
+ if (c == EOF) goto missingargs;
783
+ if (c == '\r') c = prot_getc(imapd_in);
784
+ if (c != '\n') goto extraargs;
785
+ cmd_setacl(tag.s, arg1.s, arg2.s, arg3.s);
786
+
787
+ snmp_increment(SETACL_COUNT, 1);
788
+ }
789
+ else if (!strcmp(cmd.s, ""Setannotation"")) {
790
+ if (c != ' ') goto missingargs;
791
+ c = getastring(imapd_in, imapd_out, &arg1);
792
+ if (c != ' ') goto missingargs;
793
+
794
+ cmd_setannotation(tag.s, arg1.s);
795
+
796
+ snmp_increment(SETANNOTATION_COUNT, 1);
797
+ }
798
+ else if (!strcmp(cmd.s, ""Setmetadata"")) {
799
+ if (c != ' ') goto missingargs;
800
+ c = getastring(imapd_in, imapd_out, &arg1);
801
+ if (c != ' ') goto missingargs;
802
+
803
+ cmd_setmetadata(tag.s, arg1.s);
804
+
805
+ snmp_increment(SETANNOTATION_COUNT, 1);
806
+ }
807
+ else if (!strcmp(cmd.s, ""Setquota"")) {
808
+ if (c != ' ') goto missingargs;
809
+ c = getastring(imapd_in, imapd_out, &arg1);
810
+ if (c != ' ') goto missingargs;
811
+ cmd_setquota(tag.s, arg1.s);
812
+
813
+ snmp_increment(SETQUOTA_COUNT, 1);
814
+ }
815
+ else if (!strcmp(cmd.s, ""Sort"")) {
816
+ if (!imapd_index && !backend_current) goto nomailbox;
817
+ usinguid = 0;
818
+ if (c != ' ') goto missingargs;
819
+ sort:
820
+ cmd_sort(tag.s, usinguid);
821
+
822
+ snmp_increment(SORT_COUNT, 1);
823
+ }
824
+ else if (!strcmp(cmd.s, ""Status"")) {
825
+ if (c != ' ') goto missingargs;
826
+ c = getastring(imapd_in, imapd_out, &arg1);
827
+ if (c != ' ') goto missingargs;
828
+ cmd_status(tag.s, arg1.s);
829
+
830
+ snmp_increment(STATUS_COUNT, 1);
831
+ }
832
+ else if (!strcmp(cmd.s, ""Scan"")) {
833
+ struct listargs listargs;
834
+
835
+ c = getastring(imapd_in, imapd_out, &arg1);
836
+ if (c != ' ') goto missingargs;
837
+ c = getastring(imapd_in, imapd_out, &arg2);
838
+ if (c != ' ') goto missingargs;
839
+ c = getastring(imapd_in, imapd_out, &arg3);
840
+ if (c == '\r') c = prot_getc(imapd_in);
841
+ if (c != '\n') goto extraargs;
842
+
843
+ memset(&listargs, 0, sizeof(struct listargs));
844
+ listargs.ref = arg1.s;
845
+ strarray_append(&listargs.pat, arg2.s);
846
+ listargs.scan = arg3.s;
847
+
848
+ cmd_list(tag.s, &listargs);
849
+
850
+ snmp_increment(SCAN_COUNT, 1);
851
+ }
852
+ else if (!strcmp(cmd.s, ""Syncapply"")) {
853
+ struct dlist *kl = sync_parseline(imapd_in);
854
+
855
+ if (kl) {
856
+ cmd_syncapply(tag.s, kl, reserve_list);
857
+ dlist_free(&kl);
858
+ }
859
+ else goto extraargs;
860
+ }
861
+ else if (!strcmp(cmd.s, ""Syncget"")) {
862
+ struct dlist *kl = sync_parseline(imapd_in);
863
+
864
+ if (kl) {
865
+ cmd_syncget(tag.s, kl);
866
+ dlist_free(&kl);
867
+ }
868
+ else goto extraargs;
869
+ }
870
+ else if (!strcmp(cmd.s, ""Syncrestart"")) {
871
+ if (c == '\r') c = prot_getc(imapd_in);
872
+ if (c != '\n') goto extraargs;
873
+
874
+ /* just clear the GUID cache */
875
+ cmd_syncrestart(tag.s, &reserve_list, 1);
876
+ }
877
+ else if (!strcmp(cmd.s, ""Syncrestore"")) {
878
+ struct dlist *kl = sync_parseline(imapd_in);
879
+
880
+ if (kl) {
881
+ cmd_syncrestore(tag.s, kl, reserve_list);
882
+ dlist_free(&kl);
883
+ }
884
+ else goto extraargs;
885
+ }
886
+ else goto badcmd;
887
+ break;
888
+
889
+ case 'T':
890
+ if (!strcmp(cmd.s, ""Thread"")) {
891
+ if (!imapd_index && !backend_current) goto nomailbox;
892
+ usinguid = 0;
893
+ if (c != ' ') goto missingargs;
894
+ thread:
895
+ cmd_thread(tag.s, usinguid);
896
+
897
+ snmp_increment(THREAD_COUNT, 1);
898
+ }
899
+ else goto badcmd;
900
+ break;
901
+
902
+ case 'U':
903
+ if (!strcmp(cmd.s, ""Uid"")) {
904
+ if (!imapd_index && !backend_current) goto nomailbox;
905
+ usinguid = 1;
906
+ if (c != ' ') goto missingargs;
907
+ c = getword(imapd_in, &arg1);
908
+ if (c != ' ') goto missingargs;
909
+ lcase(arg1.s);
910
+ xstrncpy(cmdname, arg1.s, 99);
911
+ if (!strcmp(arg1.s, ""fetch"")) {
912
+ goto fetch;
913
+ }
914
+ else if (!strcmp(arg1.s, ""store"")) {
915
+ goto store;
916
+ }
917
+ else if (!strcmp(arg1.s, ""search"")) {
918
+ goto search;
919
+ }
920
+ else if (!strcmp(arg1.s, ""sort"")) {
921
+ goto sort;
922
+ }
923
+ else if (!strcmp(arg1.s, ""thread"")) {
924
+ goto thread;
925
+ }
926
+ else if (!strcmp(arg1.s, ""copy"")) {
927
+ goto copy;
928
+ }
929
+ else if (!strcmp(arg1.s, ""move"")) {
930
+ goto move;
931
+ }
932
+ else if (!strcmp(arg1.s, ""xmove"")) {
933
+ goto move;
934
+ }
935
+ else if (!strcmp(arg1.s, ""expunge"")) {
936
+ c = getword(imapd_in, &arg1);
937
+ if (!imparse_issequence(arg1.s)) goto badsequence;
938
+ if (c == '\r') c = prot_getc(imapd_in);
939
+ if (c != '\n') goto extraargs;
940
+ cmd_expunge(tag.s, arg1.s);
941
+
942
+ snmp_increment(EXPUNGE_COUNT, 1);
943
+ }
944
+ else if (!strcmp(arg1.s, ""xrunannotator"")) {
945
+ goto xrunannotator;
946
+ }
947
+ else {
948
+ prot_printf(imapd_out, ""%s BAD Unrecognized UID subcommand\r\n"", tag.s);
949
+ eatline(imapd_in, c);
950
+ }
951
+ }
952
+ else if (!strcmp(cmd.s, ""Unsubscribe"")) {
953
+ if (c != ' ') goto missingargs;
954
+ havenamespace = 0;
955
+ c = getastring(imapd_in, imapd_out, &arg1);
956
+ if (c == ' ') {
957
+ havenamespace = 1;
958
+ c = getastring(imapd_in, imapd_out, &arg2);
959
+ }
960
+ if (c == EOF) goto missingargs;
961
+ if (c == '\r') c = prot_getc(imapd_in);
962
+ if (c != '\n') goto extraargs;
963
+ if (havenamespace) {
964
+ cmd_changesub(tag.s, arg1.s, arg2.s, 0);
965
+ }
966
+ else {
967
+ cmd_changesub(tag.s, (char *)0, arg1.s, 0);
968
+ }
969
+
970
+ snmp_increment(UNSUBSCRIBE_COUNT, 1);
971
+ }
972
+ else if (!strcmp(cmd.s, ""Unselect"")) {
973
+ if (!imapd_index && !backend_current) goto nomailbox;
974
+ if (c == '\r') c = prot_getc(imapd_in);
975
+ if (c != '\n') goto extraargs;
976
+
977
+ cmd_close(tag.s, cmd.s);
978
+
979
+ snmp_increment(UNSELECT_COUNT, 1);
980
+ }
981
+ else if (!strcmp(cmd.s, ""Undump"")) {
982
+ if(c != ' ') goto missingargs;
983
+ c = getastring(imapd_in, imapd_out, &arg1);
984
+
985
+ /* we want to get a list at this point */
986
+ if(c != ' ') goto missingargs;
987
+
988
+ cmd_undump(tag.s, arg1.s);
989
+ /* snmp_increment(UNDUMP_COUNT, 1);*/
990
+ }
991
+ #ifdef HAVE_SSL
992
+ else if (!strcmp(cmd.s, ""Urlfetch"")) {
993
+ if (c != ' ') goto missingargs;
994
+
995
+ cmd_urlfetch(tag.s);
996
+ /* snmp_increment(URLFETCH_COUNT, 1);*/
997
+ }
998
+ #endif
999
+ else goto badcmd;
1000
+ break;
1001
+
1002
+ case 'X':
1003
+ if (!strcmp(cmd.s, ""Xbackup"")) {
1004
+ int havechannel = 0;
1005
+
1006
+ if (!config_getswitch(IMAPOPT_XBACKUP_ENABLED))
1007
+ goto badcmd;
1008
+
1009
+ /* user */
1010
+ if (c != ' ') goto missingargs;
1011
+ c = getastring(imapd_in, imapd_out, &arg1);
1012
+
1013
+ /* channel */
1014
+ if (c == ' ') {
1015
+ havechannel = 1;
1016
+ c = getword(imapd_in, &arg2);
1017
+ if (c == EOF) goto missingargs;
1018
+ }
1019
+
1020
+ if (c == '\r') c = prot_getc(imapd_in);
1021
+ if (c != '\n') goto extraargs;
1022
+
1023
+ cmd_xbackup(tag.s, arg1.s, havechannel ? arg2.s : NULL);
1024
+
1025
+ }
1026
+ else if (!strcmp(cmd.s, ""Xconvfetch"")) {
1027
+ cmd_xconvfetch(tag.s);
1028
+
1029
+ }
1030
+ else if (!strcmp(cmd.s, ""Xconvmultisort"")) {
1031
+ if (c != ' ') goto missingargs;
1032
+ if (!imapd_index && !backend_current) goto nomailbox;
1033
+ cmd_xconvmultisort(tag.s);
1034
+
1035
+ }
1036
+ else if (!strcmp(cmd.s, ""Xconvsort"")) {
1037
+ if (c != ' ') goto missingargs;
1038
+ if (!imapd_index && !backend_current) goto nomailbox;
1039
+ cmd_xconvsort(tag.s, 0);
1040
+
1041
+ }
1042
+ else if (!strcmp(cmd.s, ""Xconvupdates"")) {
1043
+ if (c != ' ') goto missingargs;
1044
+ if (!imapd_index && !backend_current) goto nomailbox;
1045
+ cmd_xconvsort(tag.s, 1);
1046
+
1047
+ }
1048
+ else if (!strcmp(cmd.s, ""Xfer"")) {
1049
+ int havepartition = 0;
1050
+
1051
+ /* Mailbox */
1052
+ if(c != ' ') goto missingargs;
1053
+ c = getastring(imapd_in, imapd_out, &arg1);
1054
+
1055
+ /* Dest Server */
1056
+ if(c != ' ') goto missingargs;
1057
+ c = getastring(imapd_in, imapd_out, &arg2);
1058
+
1059
+ if(c == ' ') {
1060
+ /* Dest Partition */
1061
+ c = getastring(imapd_in, imapd_out, &arg3);
1062
+ if (!imparse_isatom(arg3.s)) goto badpartition;
1063
+ havepartition = 1;
1064
+ }
1065
+
1066
+ if (c == '\r') c = prot_getc(imapd_in);
1067
+ if (c != '\n') goto extraargs;
1068
+
1069
+ cmd_xfer(tag.s, arg1.s, arg2.s,
1070
+ (havepartition ? arg3.s : NULL));
1071
+ /* snmp_increment(XFER_COUNT, 1);*/
1072
+ }
1073
+ else if (!strcmp(cmd.s, ""Xconvmeta"")) {
1074
+ cmd_xconvmeta(tag.s);
1075
+ }
1076
+ else if (!strcmp(cmd.s, ""Xlist"")) {
1077
+ struct listargs listargs;
1078
+
1079
+ if (c != ' ') goto missingargs;
1080
+
1081
+ memset(&listargs, 0, sizeof(struct listargs));
1082
+ listargs.cmd = LIST_CMD_XLIST;
1083
+ listargs.ret = LIST_RET_CHILDREN | LIST_RET_SPECIALUSE;
1084
+ getlistargs(tag.s, &listargs);
1085
+ if (listargs.pat.count) cmd_list(tag.s, &listargs);
1086
+
1087
+ snmp_increment(LIST_COUNT, 1);
1088
+ }
1089
+ else if (!strcmp(cmd.s, ""Xmove"")) {
1090
+ if (!imapd_index && !backend_current) goto nomailbox;
1091
+ usinguid = 0;
1092
+ if (c != ' ') goto missingargs;
1093
+ goto move;
1094
+ }
1095
+ else if (!strcmp(cmd.s, ""Xrunannotator"")) {
1096
+ if (!imapd_index && !backend_current) goto nomailbox;
1097
+ usinguid = 0;
1098
+ if (c != ' ') goto missingargs;
1099
+ xrunannotator:
1100
+ c = getword(imapd_in, &arg1);
1101
+ if (!arg1.len || !imparse_issequence(arg1.s)) goto badsequence;
1102
+ cmd_xrunannotator(tag.s, arg1.s, usinguid);
1103
+ }
1104
+ else if (!strcmp(cmd.s, ""Xsnippets"")) {
1105
+ if (c != ' ') goto missingargs;
1106
+ if (!imapd_index && !backend_current) goto nomailbox;
1107
+ cmd_xsnippets(tag.s);
1108
+
1109
+ }
1110
+ else if (!strcmp(cmd.s, ""Xstats"")) {
1111
+ cmd_xstats(tag.s, c);
1112
+ }
1113
+ else if (!strcmp(cmd.s, ""Xwarmup"")) {
1114
+ /* XWARMUP doesn't need a mailbox to be selected */
1115
+ if (c != ' ') goto missingargs;
1116
+ cmd_xwarmup(tag.s);
1117
+ }
1118
+ else if (!strcmp(cmd.s, ""Xkillmy"")) {
1119
+ if (c != ' ') goto missingargs;
1120
+ c = getastring(imapd_in, imapd_out, &arg1);
1121
+ if (c == EOF) goto missingargs;
1122
+ if (c == '\r') c = prot_getc(imapd_in);
1123
+ if (c != '\n') goto extraargs;
1124
+ cmd_xkillmy(tag.s, arg1.s);
1125
+ }
1126
+ else if (!strcmp(cmd.s, ""Xforever"")) {
1127
+ if (c == '\r') c = prot_getc(imapd_in);
1128
+ if (c != '\n') goto extraargs;
1129
+ cmd_xforever(tag.s);
1130
+ }
1131
+ else if (!strcmp(cmd.s, ""Xmeid"")) {
1132
+ if (c != ' ') goto missingargs;
1133
+ c = getastring(imapd_in, imapd_out, &arg1);
1134
+ if (c == EOF) goto missingargs;
1135
+ if (c == '\r') c = prot_getc(imapd_in);
1136
+ if (c != '\n') goto extraargs;
1137
+ cmd_xmeid(tag.s, arg1.s);
1138
+ }
1139
+
1140
+ else if (apns_enabled && !strcmp(cmd.s, ""Xapplepushservice"")) {
1141
+ if (c != ' ') goto missingargs;
1142
+
1143
+ memset(&applepushserviceargs, 0, sizeof(struct applepushserviceargs));
1144
+
1145
+ do {
1146
+ c = getastring(imapd_in, imapd_out, &arg1);
1147
+ if (c == EOF) goto aps_missingargs;
1148
+
1149
+ if (!strcmp(arg1.s, ""mailboxes"")) {
1150
+ c = prot_getc(imapd_in);
1151
+ if (c != '(')
1152
+ goto aps_missingargs;
1153
+
1154
+ c = prot_getc(imapd_in);
1155
+ if (c != ')') {
1156
+ prot_ungetc(c, imapd_in);
1157
+ do {
1158
+ c = getastring(imapd_in, imapd_out, &arg2);
1159
+ if (c == EOF) break;
1160
+ strarray_push(&applepushserviceargs.mailboxes, arg2.s);
1161
+ } while (c == ' ');
1162
+ }
1163
+
1164
+ if (c != ')')
1165
+ goto aps_missingargs;
1166
+ c = prot_getc(imapd_in);
1167
+ }
1168
+
1169
+ else {
1170
+ c = getastring(imapd_in, imapd_out, &arg2);
1171
+
1172
+ if (!strcmp(arg1.s, ""aps-version"")) {
1173
+ if (!imparse_isnumber(arg2.s)) goto aps_extraargs;
1174
+ applepushserviceargs.aps_version = atoi(arg2.s);
1175
+ }
1176
+ else if (!strcmp(arg1.s, ""aps-account-id""))
1177
+ buf_copy(&applepushserviceargs.aps_account_id, &arg2);
1178
+ else if (!strcmp(arg1.s, ""aps-device-token""))
1179
+ buf_copy(&applepushserviceargs.aps_device_token, &arg2);
1180
+ else if (!strcmp(arg1.s, ""aps-subtopic""))
1181
+ buf_copy(&applepushserviceargs.aps_subtopic, &arg2);
1182
+ else
1183
+ goto aps_extraargs;
1184
+ }
1185
+ } while (c == ' ');
1186
+
1187
+ if (c == '\r') c = prot_getc(imapd_in);
1188
+ if (c != '\n') goto aps_extraargs;
1189
+
1190
+ cmd_xapplepushservice(tag.s, &applepushserviceargs);
1191
+ }
1192
+
1193
+ else goto badcmd;
1194
+ break;
1195
+
1196
+ default:
1197
+ badcmd:
1198
+ prot_printf(imapd_out, ""%s BAD Unrecognized command\r\n"", tag.s);
1199
+ eatline(imapd_in, c);
1200
+ }
1201
+
1202
+ /* End command timer - don't log ""idle"" commands */
1203
+ if (commandmintimer && strcmp(""idle"", cmdname)) {
1204
+ double cmdtime, nettime;
1205
+ const char *mboxname = index_mboxname(imapd_index);
1206
+ if (!mboxname) mboxname = ""<none>"";
1207
+ cmdtime_endtimer(&cmdtime, &nettime);
1208
+ if (cmdtime >= commandmintimerd) {
1209
+ syslog(LOG_NOTICE, ""cmdtimer: '%s' '%s' '%s' '%f' '%f' '%f'"",
1210
+ imapd_userid ? imapd_userid : ""<none>"", cmdname, mboxname,
1211
+ cmdtime, nettime, cmdtime + nettime);
1212
+ }
1213
+ }
1214
+ continue;
1215
+
1216
+ nologin:
1217
+ prot_printf(imapd_out, ""%s BAD Please login first\r\n"", tag.s);
1218
+ eatline(imapd_in, c);
1219
+ continue;
1220
+
1221
+ nomailbox:
1222
+ prot_printf(imapd_out,
1223
+ ""%s BAD Please select a mailbox first\r\n"", tag.s);
1224
+ eatline(imapd_in, c);
1225
+ continue;
1226
+
1227
+ aps_missingargs:
1228
+ buf_free(&applepushserviceargs.aps_account_id);
1229
+ buf_free(&applepushserviceargs.aps_device_token);
1230
+ buf_free(&applepushserviceargs.aps_subtopic);
1231
+ strarray_fini(&applepushserviceargs.mailboxes);
1232
+
1233
+ missingargs:
1234
+ prot_printf(imapd_out,
1235
+ ""%s BAD Missing required argument to %s\r\n"", tag.s, cmd.s);
1236
+ eatline(imapd_in, c);
1237
+ continue;
1238
+
1239
+ aps_extraargs:
1240
+ buf_free(&applepushserviceargs.aps_account_id);
1241
+ buf_free(&applepushserviceargs.aps_device_token);
1242
+ buf_free(&applepushserviceargs.aps_subtopic);
1243
+ strarray_fini(&applepushserviceargs.mailboxes);
1244
+
1245
+ extraargs:
1246
+ prot_printf(imapd_out,
1247
+ ""%s BAD Unexpected extra arguments to %s\r\n"", tag.s, cmd.s);
1248
+ eatline(imapd_in, c);
1249
+ continue;
1250
+
1251
+ badsequence:
1252
+ prot_printf(imapd_out,
1253
+ ""%s BAD Invalid sequence in %s\r\n"", tag.s, cmd.s);
1254
+ eatline(imapd_in, c);
1255
+ continue;
1256
+
1257
+ badpartition:
1258
+ prot_printf(imapd_out,
1259
+ ""%s BAD Invalid partition name in %s\r\n"", tag.s, cmd.s);
1260
+ eatline(imapd_in, c);
1261
+ continue;
1262
+ }
1263
+
1264
+ done:
1265
+ cmd_syncrestart(NULL, &reserve_list, 0);
1266
+ }
1267
+ ",1,"static void cmdloop(void)
1268
+ {
1269
+ int c;
1270
+ int usinguid, havepartition, havenamespace, recursive;
1271
+ static struct buf tag, cmd, arg1, arg2, arg3;
1272
+ char *p, shut[MAX_MAILBOX_PATH+1], cmdname[100];
1273
+ const char *err;
1274
+ const char * commandmintimer;
1275
+ double commandmintimerd = 0.0;
1276
+ struct sync_reserve_list *reserve_list =
1277
+ sync_reserve_list_create(SYNC_MESSAGE_LIST_HASH_SIZE);
1278
+ struct applepushserviceargs applepushserviceargs;
1279
+
1280
+ prot_printf(imapd_out, ""* OK [CAPABILITY "");
1281
+ capa_response(CAPA_PREAUTH);
1282
+ prot_printf(imapd_out, ""]"");
1283
+ if (config_serverinfo) prot_printf(imapd_out, "" %s"", config_servername);
1284
+ if (config_serverinfo == IMAP_ENUM_SERVERINFO_ON) {
1285
+ prot_printf(imapd_out, "" Cyrus IMAP %s"", cyrus_version());
1286
+ }
1287
+ prot_printf(imapd_out, "" server ready\r\n"");
1288
+
1289
+ /* clear cancelled flag if present before the next command */
1290
+ cmd_cancelled();
1291
+
1292
+ motd_file();
1293
+
1294
+ /* Get command timer logging paramater. This string
1295
+ * is a time in seconds. Any command that takes >=
1296
+ * this time to execute is logged */
1297
+ commandmintimer = config_getstring(IMAPOPT_COMMANDMINTIMER);
1298
+ cmdtime_settimer(commandmintimer ? 1 : 0);
1299
+ if (commandmintimer) {
1300
+ commandmintimerd = atof(commandmintimer);
1301
+ }
1302
+
1303
+ for (;;) {
1304
+ /* Release any held index */
1305
+ index_release(imapd_index);
1306
+
1307
+ /* Flush any buffered output */
1308
+ prot_flush(imapd_out);
1309
+ if (backend_current) prot_flush(backend_current->out);
1310
+
1311
+ /* command no longer running */
1312
+ proc_register(config_ident, imapd_clienthost, imapd_userid, index_mboxname(imapd_index), NULL);
1313
+
1314
+ /* Check for shutdown file */
1315
+ if ( !imapd_userisadmin && imapd_userid &&
1316
+ (shutdown_file(shut, sizeof(shut)) ||
1317
+ userdeny(imapd_userid, config_ident, shut, sizeof(shut)))) {
1318
+ for (p = shut; *p == '['; p++); /* can't have [ be first char */
1319
+ prot_printf(imapd_out, ""* BYE [ALERT] %s\r\n"", p);
1320
+ telemetry_rusage(imapd_userid);
1321
+ shut_down(0);
1322
+ }
1323
+
1324
+ signals_poll();
1325
+
1326
+ if (!proxy_check_input(protin, imapd_in, imapd_out,
1327
+ backend_current ? backend_current->in : NULL,
1328
+ NULL, 0)) {
1329
+ /* No input from client */
1330
+ continue;
1331
+ }
1332
+
1333
+ /* Parse tag */
1334
+ c = getword(imapd_in, &tag);
1335
+ if (c == EOF) {
1336
+ if ((err = prot_error(imapd_in))!=NULL
1337
+ && strcmp(err, PROT_EOF_STRING)) {
1338
+ syslog(LOG_WARNING, ""%s, closing connection"", err);
1339
+ prot_printf(imapd_out, ""* BYE %s\r\n"", err);
1340
+ }
1341
+ goto done;
1342
+ }
1343
+ if (c != ' ' || !imparse_isatom(tag.s) || (tag.s[0] == '*' && !tag.s[1])) {
1344
+ prot_printf(imapd_out, ""* BAD Invalid tag\r\n"");
1345
+ eatline(imapd_in, c);
1346
+ continue;
1347
+ }
1348
+
1349
+ /* Parse command name */
1350
+ c = getword(imapd_in, &cmd);
1351
+ if (!cmd.s[0]) {
1352
+ prot_printf(imapd_out, ""%s BAD Null command\r\n"", tag.s);
1353
+ eatline(imapd_in, c);
1354
+ continue;
1355
+ }
1356
+ lcase(cmd.s);
1357
+ xstrncpy(cmdname, cmd.s, 99);
1358
+ cmd.s[0] = toupper((unsigned char) cmd.s[0]);
1359
+
1360
+ if (config_getswitch(IMAPOPT_CHATTY))
1361
+ syslog(LOG_NOTICE, ""command: %s %s"", tag.s, cmd.s);
1362
+
1363
+ proc_register(config_ident, imapd_clienthost, imapd_userid, index_mboxname(imapd_index), cmd.s);
1364
+
1365
+ /* if we need to force a kick, do so */
1366
+ if (referral_kick) {
1367
+ kick_mupdate();
1368
+ referral_kick = 0;
1369
+ }
1370
+
1371
+ if (plaintextloginalert) {
1372
+ prot_printf(imapd_out, ""* OK [ALERT] %s\r\n"",
1373
+ plaintextloginalert);
1374
+ plaintextloginalert = NULL;
1375
+ }
1376
+
1377
+ /* Only Authenticate/Enable/Login/Logout/Noop/Capability/Id/Starttls
1378
+ allowed when not logged in */
1379
+ if (!imapd_userid && !strchr(""AELNCIS"", cmd.s[0])) goto nologin;
1380
+
1381
+ /* Start command timer */
1382
+ cmdtime_starttimer();
1383
+
1384
+ /* note that about half the commands (the common ones that don't
1385
+ hit the mailboxes file) now close the mailboxes file just in
1386
+ case it was open. */
1387
+ switch (cmd.s[0]) {
1388
+ case 'A':
1389
+ if (!strcmp(cmd.s, ""Authenticate"")) {
1390
+ int haveinitresp = 0;
1391
+
1392
+ if (c != ' ') goto missingargs;
1393
+ c = getword(imapd_in, &arg1);
1394
+ if (!imparse_isatom(arg1.s)) {
1395
+ prot_printf(imapd_out, ""%s BAD Invalid authenticate mechanism\r\n"", tag.s);
1396
+ eatline(imapd_in, c);
1397
+ continue;
1398
+ }
1399
+ if (c == ' ') {
1400
+ haveinitresp = 1;
1401
+ c = getword(imapd_in, &arg2);
1402
+ if (c == EOF) goto missingargs;
1403
+ }
1404
+ if (c == '\r') c = prot_getc(imapd_in);
1405
+ if (c != '\n') goto extraargs;
1406
+
1407
+ if (imapd_userid) {
1408
+ prot_printf(imapd_out, ""%s BAD Already authenticated\r\n"", tag.s);
1409
+ continue;
1410
+ }
1411
+ cmd_authenticate(tag.s, arg1.s, haveinitresp ? arg2.s : NULL);
1412
+
1413
+ snmp_increment(AUTHENTICATE_COUNT, 1);
1414
+ }
1415
+ else if (!imapd_userid) goto nologin;
1416
+ else if (!strcmp(cmd.s, ""Append"")) {
1417
+ if (c != ' ') goto missingargs;
1418
+ c = getastring(imapd_in, imapd_out, &arg1);
1419
+ if (c != ' ') goto missingargs;
1420
+
1421
+ cmd_append(tag.s, arg1.s, NULL);
1422
+
1423
+ snmp_increment(APPEND_COUNT, 1);
1424
+ }
1425
+ else goto badcmd;
1426
+ break;
1427
+
1428
+ case 'C':
1429
+ if (!strcmp(cmd.s, ""Capability"")) {
1430
+ if (c == '\r') c = prot_getc(imapd_in);
1431
+ if (c != '\n') goto extraargs;
1432
+ cmd_capability(tag.s);
1433
+
1434
+ snmp_increment(CAPABILITY_COUNT, 1);
1435
+ }
1436
+ else if (!imapd_userid) goto nologin;
1437
+ #ifdef HAVE_ZLIB
1438
+ else if (!strcmp(cmd.s, ""Compress"")) {
1439
+ if (c != ' ') goto missingargs;
1440
+ c = getword(imapd_in, &arg1);
1441
+ if (c == EOF) goto missingargs;
1442
+ if (c == '\r') c = prot_getc(imapd_in);
1443
+ if (c != '\n') goto extraargs;
1444
+
1445
+ cmd_compress(tag.s, arg1.s);
1446
+
1447
+ snmp_increment(COMPRESS_COUNT, 1);
1448
+ }
1449
+ #endif /* HAVE_ZLIB */
1450
+ else if (!strcmp(cmd.s, ""Check"")) {
1451
+ if (!imapd_index && !backend_current) goto nomailbox;
1452
+ if (c == '\r') c = prot_getc(imapd_in);
1453
+ if (c != '\n') goto extraargs;
1454
+
1455
+ cmd_noop(tag.s, cmd.s);
1456
+
1457
+ snmp_increment(CHECK_COUNT, 1);
1458
+ }
1459
+ else if (!strcmp(cmd.s, ""Copy"")) {
1460
+ if (!imapd_index && !backend_current) goto nomailbox;
1461
+ usinguid = 0;
1462
+ if (c != ' ') goto missingargs;
1463
+ copy:
1464
+ c = getword(imapd_in, &arg1);
1465
+ if (c == '\r') goto missingargs;
1466
+ if (c != ' ' || !imparse_issequence(arg1.s)) goto badsequence;
1467
+ c = getastring(imapd_in, imapd_out, &arg2);
1468
+ if (c == EOF) goto missingargs;
1469
+ if (c == '\r') c = prot_getc(imapd_in);
1470
+ if (c != '\n') goto extraargs;
1471
+
1472
+ cmd_copy(tag.s, arg1.s, arg2.s, usinguid, /*ismove*/0);
1473
+
1474
+ snmp_increment(COPY_COUNT, 1);
1475
+ }
1476
+ else if (!strcmp(cmd.s, ""Create"")) {
1477
+ struct dlist *extargs = NULL;
1478
+
1479
+ if (c != ' ') goto missingargs;
1480
+ c = getastring(imapd_in, imapd_out, &arg1);
1481
+ if (c == EOF) goto missingargs;
1482
+ if (c == ' ') {
1483
+ c = parsecreateargs(&extargs);
1484
+ if (c == EOF) goto badpartition;
1485
+ }
1486
+ if (c == '\r') c = prot_getc(imapd_in);
1487
+ if (c != '\n') goto extraargs;
1488
+ cmd_create(tag.s, arg1.s, extargs, 0);
1489
+ dlist_free(&extargs);
1490
+
1491
+ snmp_increment(CREATE_COUNT, 1);
1492
+ }
1493
+ else if (!strcmp(cmd.s, ""Close"")) {
1494
+ if (!imapd_index && !backend_current) goto nomailbox;
1495
+ if (c == '\r') c = prot_getc(imapd_in);
1496
+ if (c != '\n') goto extraargs;
1497
+
1498
+ cmd_close(tag.s, cmd.s);
1499
+
1500
+ snmp_increment(CLOSE_COUNT, 1);
1501
+ }
1502
+ else goto badcmd;
1503
+ break;
1504
+
1505
+ case 'D':
1506
+ if (!strcmp(cmd.s, ""Delete"")) {
1507
+ if (c != ' ') goto missingargs;
1508
+ c = getastring(imapd_in, imapd_out, &arg1);
1509
+ if (c == EOF) goto missingargs;
1510
+ if (c == '\r') c = prot_getc(imapd_in);
1511
+ if (c != '\n') goto extraargs;
1512
+ cmd_delete(tag.s, arg1.s, 0, 0);
1513
+
1514
+ snmp_increment(DELETE_COUNT, 1);
1515
+ }
1516
+ else if (!strcmp(cmd.s, ""Deleteacl"")) {
1517
+ if (c != ' ') goto missingargs;
1518
+ c = getastring(imapd_in, imapd_out, &arg1);
1519
+ if (c != ' ') goto missingargs;
1520
+ c = getastring(imapd_in, imapd_out, &arg2);
1521
+ if (c == EOF) goto missingargs;
1522
+ if (c == '\r') c = prot_getc(imapd_in);
1523
+ if (c != '\n') goto extraargs;
1524
+ cmd_setacl(tag.s, arg1.s, arg2.s, NULL);
1525
+
1526
+ snmp_increment(DELETEACL_COUNT, 1);
1527
+ }
1528
+ else if (!strcmp(cmd.s, ""Dump"")) {
1529
+ int uid_start = 0;
1530
+
1531
+ if(c != ' ') goto missingargs;
1532
+ c = getastring(imapd_in, imapd_out, &arg1);
1533
+ if(c == ' ') {
1534
+ c = getastring(imapd_in, imapd_out, &arg2);
1535
+ if(!imparse_isnumber(arg2.s)) goto extraargs;
1536
+ uid_start = atoi(arg2.s);
1537
+ }
1538
+
1539
+ if(c == '\r') c = prot_getc(imapd_in);
1540
+ if(c != '\n') goto extraargs;
1541
+
1542
+ cmd_dump(tag.s, arg1.s, uid_start);
1543
+ /* snmp_increment(DUMP_COUNT, 1);*/
1544
+ }
1545
+ else goto badcmd;
1546
+ break;
1547
+
1548
+ case 'E':
1549
+ if (!imapd_userid) goto nologin;
1550
+ else if (!strcmp(cmd.s, ""Enable"")) {
1551
+ if (c != ' ') goto missingargs;
1552
+
1553
+ cmd_enable(tag.s);
1554
+ }
1555
+ else if (!strcmp(cmd.s, ""Expunge"")) {
1556
+ if (!imapd_index && !backend_current) goto nomailbox;
1557
+ if (c == '\r') c = prot_getc(imapd_in);
1558
+ if (c != '\n') goto extraargs;
1559
+
1560
+ cmd_expunge(tag.s, 0);
1561
+
1562
+ snmp_increment(EXPUNGE_COUNT, 1);
1563
+ }
1564
+ else if (!strcmp(cmd.s, ""Examine"")) {
1565
+ if (c != ' ') goto missingargs;
1566
+ c = getastring(imapd_in, imapd_out, &arg1);
1567
+ if (c == EOF) goto missingargs;
1568
+ prot_ungetc(c, imapd_in);
1569
+
1570
+ cmd_select(tag.s, cmd.s, arg1.s);
1571
+
1572
+ snmp_increment(EXAMINE_COUNT, 1);
1573
+ }
1574
+ else goto badcmd;
1575
+ break;
1576
+
1577
+ case 'F':
1578
+ if (!strcmp(cmd.s, ""Fetch"")) {
1579
+ if (!imapd_index && !backend_current) goto nomailbox;
1580
+ usinguid = 0;
1581
+ if (c != ' ') goto missingargs;
1582
+ fetch:
1583
+ c = getword(imapd_in, &arg1);
1584
+ if (c == '\r') goto missingargs;
1585
+ if (c != ' ' || !imparse_issequence(arg1.s)) goto badsequence;
1586
+
1587
+ cmd_fetch(tag.s, arg1.s, usinguid);
1588
+
1589
+ snmp_increment(FETCH_COUNT, 1);
1590
+ }
1591
+ else goto badcmd;
1592
+ break;
1593
+
1594
+ case 'G':
1595
+ if (!strcmp(cmd.s, ""Getacl"")) {
1596
+ if (c != ' ') goto missingargs;
1597
+ c = getastring(imapd_in, imapd_out, &arg1);
1598
+ if (c == EOF) goto missingargs;
1599
+ if (c == '\r') c = prot_getc(imapd_in);
1600
+ if (c != '\n') goto extraargs;
1601
+ cmd_getacl(tag.s, arg1.s);
1602
+
1603
+ snmp_increment(GETACL_COUNT, 1);
1604
+ }
1605
+ else if (!strcmp(cmd.s, ""Getannotation"")) {
1606
+ if (c != ' ') goto missingargs;
1607
+ c = getastring(imapd_in, imapd_out, &arg1);
1608
+ if (c != ' ') goto missingargs;
1609
+
1610
+ cmd_getannotation(tag.s, arg1.s);
1611
+
1612
+ snmp_increment(GETANNOTATION_COUNT, 1);
1613
+ }
1614
+ else if (!strcmp(cmd.s, ""Getmetadata"")) {
1615
+ if (c != ' ') goto missingargs;
1616
+
1617
+ cmd_getmetadata(tag.s);
1618
+
1619
+ snmp_increment(GETANNOTATION_COUNT, 1);
1620
+ }
1621
+ else if (!strcmp(cmd.s, ""Getquota"")) {
1622
+ if (c != ' ') goto missingargs;
1623
+ c = getastring(imapd_in, imapd_out, &arg1);
1624
+ if (c == EOF) goto missingargs;
1625
+ if (c == '\r') c = prot_getc(imapd_in);
1626
+ if (c != '\n') goto extraargs;
1627
+ cmd_getquota(tag.s, arg1.s);
1628
+
1629
+ snmp_increment(GETQUOTA_COUNT, 1);
1630
+ }
1631
+ else if (!strcmp(cmd.s, ""Getquotaroot"")) {
1632
+ if (c != ' ') goto missingargs;
1633
+ c = getastring(imapd_in, imapd_out, &arg1);
1634
+ if (c == EOF) goto missingargs;
1635
+ if (c == '\r') c = prot_getc(imapd_in);
1636
+ if (c != '\n') goto extraargs;
1637
+ cmd_getquotaroot(tag.s, arg1.s);
1638
+
1639
+ snmp_increment(GETQUOTAROOT_COUNT, 1);
1640
+ }
1641
+ #ifdef HAVE_SSL
1642
+ else if (!strcmp(cmd.s, ""Genurlauth"")) {
1643
+ if (c != ' ') goto missingargs;
1644
+
1645
+ cmd_genurlauth(tag.s);
1646
+ /* snmp_increment(GENURLAUTH_COUNT, 1);*/
1647
+ }
1648
+ #endif
1649
+ else goto badcmd;
1650
+ break;
1651
+
1652
+ case 'I':
1653
+ if (!strcmp(cmd.s, ""Id"")) {
1654
+ if (c != ' ') goto missingargs;
1655
+ cmd_id(tag.s);
1656
+
1657
+ snmp_increment(ID_COUNT, 1);
1658
+ }
1659
+ else if (!imapd_userid) goto nologin;
1660
+ else if (!strcmp(cmd.s, ""Idle"") && idle_enabled()) {
1661
+ if (c == '\r') c = prot_getc(imapd_in);
1662
+ if (c != '\n') goto extraargs;
1663
+ cmd_idle(tag.s);
1664
+
1665
+ snmp_increment(IDLE_COUNT, 1);
1666
+ }
1667
+ else goto badcmd;
1668
+ break;
1669
+
1670
+ case 'L':
1671
+ if (!strcmp(cmd.s, ""Login"")) {
1672
+ if (c != ' ') goto missingargs;
1673
+ c = getastring(imapd_in, imapd_out, &arg1);
1674
+ if(c != ' ') goto missingargs;
1675
+
1676
+ cmd_login(tag.s, arg1.s);
1677
+
1678
+ snmp_increment(LOGIN_COUNT, 1);
1679
+ }
1680
+ else if (!strcmp(cmd.s, ""Logout"")) {
1681
+ if (c == '\r') c = prot_getc(imapd_in);
1682
+ if (c != '\n') goto extraargs;
1683
+
1684
+ snmp_increment(LOGOUT_COUNT, 1);
1685
+
1686
+ /* force any responses from our selected backend */
1687
+ if (backend_current) imapd_check(NULL, 0);
1688
+
1689
+ prot_printf(imapd_out, ""* BYE %s\r\n"",
1690
+ error_message(IMAP_BYE_LOGOUT));
1691
+ prot_printf(imapd_out, ""%s OK %s\r\n"", tag.s,
1692
+ error_message(IMAP_OK_COMPLETED));
1693
+
1694
+ if (imapd_userid && *imapd_userid) {
1695
+ telemetry_rusage(imapd_userid);
1696
+ }
1697
+
1698
+ goto done;
1699
+ }
1700
+ else if (!imapd_userid) goto nologin;
1701
+ else if (!strcmp(cmd.s, ""List"")) {
1702
+ struct listargs listargs;
1703
+
1704
+ if (c != ' ') goto missingargs;
1705
+
1706
+ memset(&listargs, 0, sizeof(struct listargs));
1707
+ listargs.ret = LIST_RET_CHILDREN;
1708
+ getlistargs(tag.s, &listargs);
1709
+ if (listargs.pat.count) cmd_list(tag.s, &listargs);
1710
+
1711
+ snmp_increment(LIST_COUNT, 1);
1712
+ }
1713
+ else if (!strcmp(cmd.s, ""Lsub"")) {
1714
+ struct listargs listargs;
1715
+
1716
+ c = getastring(imapd_in, imapd_out, &arg1);
1717
+ if (c != ' ') goto missingargs;
1718
+ c = getastring(imapd_in, imapd_out, &arg2);
1719
+ if (c == '\r') c = prot_getc(imapd_in);
1720
+ if (c != '\n') goto extraargs;
1721
+
1722
+ memset(&listargs, 0, sizeof(struct listargs));
1723
+ listargs.cmd = LIST_CMD_LSUB;
1724
+ listargs.sel = LIST_SEL_SUBSCRIBED;
1725
+ if (!strcasecmpsafe(imapd_magicplus, ""+dav""))
1726
+ listargs.sel |= LIST_SEL_DAV;
1727
+ listargs.ref = arg1.s;
1728
+ strarray_append(&listargs.pat, arg2.s);
1729
+
1730
+ cmd_list(tag.s, &listargs);
1731
+
1732
+ snmp_increment(LSUB_COUNT, 1);
1733
+ }
1734
+ else if (!strcmp(cmd.s, ""Listrights"")) {
1735
+ c = getastring(imapd_in, imapd_out, &arg1);
1736
+ if (c != ' ') goto missingargs;
1737
+ c = getastring(imapd_in, imapd_out, &arg2);
1738
+ if (c == '\r') c = prot_getc(imapd_in);
1739
+ if (c != '\n') goto extraargs;
1740
+ cmd_listrights(tag.s, arg1.s, arg2.s);
1741
+
1742
+ snmp_increment(LISTRIGHTS_COUNT, 1);
1743
+ }
1744
+ else if (!strcmp(cmd.s, ""Localappend"")) {
1745
+ /* create a local-only mailbox */
1746
+ if (c != ' ') goto missingargs;
1747
+ c = getastring(imapd_in, imapd_out, &arg1);
1748
+ if (c != ' ') goto missingargs;
1749
+ c = getastring(imapd_in, imapd_out, &arg2);
1750
+ if (c != ' ') goto missingargs;
1751
+
1752
+ cmd_append(tag.s, arg1.s, *arg2.s ? arg2.s : NULL);
1753
+
1754
+ snmp_increment(APPEND_COUNT, 1);
1755
+ }
1756
+ else if (!strcmp(cmd.s, ""Localcreate"")) {
1757
+ /* create a local-only mailbox */
1758
+ struct dlist *extargs = NULL;
1759
+
1760
+ if (c != ' ') goto missingargs;
1761
+ c = getastring(imapd_in, imapd_out, &arg1);
1762
+ if (c == EOF) goto missingargs;
1763
+ if (c == ' ') {
1764
+ c = parsecreateargs(&extargs);
1765
+ if (c == EOF) goto badpartition;
1766
+ }
1767
+ if (c == '\r') c = prot_getc(imapd_in);
1768
+ if (c != '\n') goto extraargs;
1769
+ cmd_create(tag.s, arg1.s, extargs, 1);
1770
+ dlist_free(&extargs);
1771
+
1772
+ /* xxxx snmp_increment(CREATE_COUNT, 1); */
1773
+ }
1774
+ else if (!strcmp(cmd.s, ""Localdelete"")) {
1775
+ /* delete a mailbox locally only */
1776
+ if (c != ' ') goto missingargs;
1777
+ c = getastring(imapd_in, imapd_out, &arg1);
1778
+ if (c == EOF) goto missingargs;
1779
+ if (c == '\r') c = prot_getc(imapd_in);
1780
+ if (c != '\n') goto extraargs;
1781
+ cmd_delete(tag.s, arg1.s, 1, 1);
1782
+
1783
+ /* xxxx snmp_increment(DELETE_COUNT, 1); */
1784
+ }
1785
+ else goto badcmd;
1786
+ break;
1787
+
1788
+ case 'M':
1789
+ if (!strcmp(cmd.s, ""Myrights"")) {
1790
+ if (c != ' ') goto missingargs;
1791
+ c = getastring(imapd_in, imapd_out, &arg1);
1792
+ if (c == EOF) goto missingargs;
1793
+ if (c == '\r') c = prot_getc(imapd_in);
1794
+ if (c != '\n') goto extraargs;
1795
+ cmd_myrights(tag.s, arg1.s);
1796
+
1797
+ /* xxxx snmp_increment(MYRIGHTS_COUNT, 1); */
1798
+ }
1799
+ else if (!strcmp(cmd.s, ""Mupdatepush"")) {
1800
+ if (c != ' ') goto missingargs;
1801
+ c = getastring(imapd_in, imapd_out, &arg1);
1802
+ if(c == EOF) goto missingargs;
1803
+ if(c == '\r') c = prot_getc(imapd_in);
1804
+ if(c != '\n') goto extraargs;
1805
+ cmd_mupdatepush(tag.s, arg1.s);
1806
+
1807
+ /* xxxx snmp_increment(MUPDATEPUSH_COUNT, 1); */
1808
+ }
1809
+ else if (!strcmp(cmd.s, ""Move"")) {
1810
+ if (!imapd_index && !backend_current) goto nomailbox;
1811
+ usinguid = 0;
1812
+ if (c != ' ') goto missingargs;
1813
+ move:
1814
+ c = getword(imapd_in, &arg1);
1815
+ if (c == '\r') goto missingargs;
1816
+ if (c != ' ' || !imparse_issequence(arg1.s)) goto badsequence;
1817
+ c = getastring(imapd_in, imapd_out, &arg2);
1818
+ if (c == EOF) goto missingargs;
1819
+ if (c == '\r') c = prot_getc(imapd_in);
1820
+ if (c != '\n') goto extraargs;
1821
+
1822
+ cmd_copy(tag.s, arg1.s, arg2.s, usinguid, /*ismove*/1);
1823
+
1824
+ snmp_increment(COPY_COUNT, 1);
1825
+ } else goto badcmd;
1826
+ break;
1827
+
1828
+ case 'N':
1829
+ if (!strcmp(cmd.s, ""Noop"")) {
1830
+ if (c == '\r') c = prot_getc(imapd_in);
1831
+ if (c != '\n') goto extraargs;
1832
+
1833
+ cmd_noop(tag.s, cmd.s);
1834
+
1835
+ /* xxxx snmp_increment(NOOP_COUNT, 1); */
1836
+ }
1837
+ else if (!imapd_userid) goto nologin;
1838
+ else if (!strcmp(cmd.s, ""Namespace"")) {
1839
+ if (c == '\r') c = prot_getc(imapd_in);
1840
+ if (c != '\n') goto extraargs;
1841
+ cmd_namespace(tag.s);
1842
+
1843
+ /* xxxx snmp_increment(NAMESPACE_COUNT, 1); */
1844
+ }
1845
+ else goto badcmd;
1846
+ break;
1847
+
1848
+ case 'R':
1849
+ if (!strcmp(cmd.s, ""Rename"")) {
1850
+ havepartition = 0;
1851
+ if (c != ' ') goto missingargs;
1852
+ c = getastring(imapd_in, imapd_out, &arg1);
1853
+ if (c != ' ') goto missingargs;
1854
+ c = getastring(imapd_in, imapd_out, &arg2);
1855
+ if (c == EOF) goto missingargs;
1856
+ if (c == ' ') {
1857
+ havepartition = 1;
1858
+ c = getword(imapd_in, &arg3);
1859
+ if (!imparse_isatom(arg3.s)) goto badpartition;
1860
+ }
1861
+ if (c == '\r') c = prot_getc(imapd_in);
1862
+ if (c != '\n') goto extraargs;
1863
+ cmd_rename(tag.s, arg1.s, arg2.s, havepartition ? arg3.s : 0);
1864
+
1865
+ /* xxxx snmp_increment(RENAME_COUNT, 1); */
1866
+ } else if(!strcmp(cmd.s, ""Reconstruct"")) {
1867
+ recursive = 0;
1868
+ if (c != ' ') goto missingargs;
1869
+ c = getastring(imapd_in, imapd_out, &arg1);
1870
+ if(c == ' ') {
1871
+ /* Optional RECURSEIVE argument */
1872
+ c = getword(imapd_in, &arg2);
1873
+ if(!imparse_isatom(arg2.s))
1874
+ goto extraargs;
1875
+ else if(!strcasecmp(arg2.s, ""RECURSIVE""))
1876
+ recursive = 1;
1877
+ else
1878
+ goto extraargs;
1879
+ }
1880
+ if(c == '\r') c = prot_getc(imapd_in);
1881
+ if(c != '\n') goto extraargs;
1882
+ cmd_reconstruct(tag.s, arg1.s, recursive);
1883
+
1884
+ /* snmp_increment(RECONSTRUCT_COUNT, 1); */
1885
+ }
1886
+ else if (!strcmp(cmd.s, ""Rlist"")) {
1887
+ struct listargs listargs;
1888
+
1889
+ c = getastring(imapd_in, imapd_out, &arg1);
1890
+ if (c != ' ') goto missingargs;
1891
+ c = getastring(imapd_in, imapd_out, &arg2);
1892
+ if (c == '\r') c = prot_getc(imapd_in);
1893
+ if (c != '\n') goto extraargs;
1894
+
1895
+ memset(&listargs, 0, sizeof(struct listargs));
1896
+ listargs.sel = LIST_SEL_REMOTE;
1897
+ listargs.ret = LIST_RET_CHILDREN;
1898
+ listargs.ref = arg1.s;
1899
+ strarray_append(&listargs.pat, arg2.s);
1900
+
1901
+ cmd_list(tag.s, &listargs);
1902
+
1903
+ /* snmp_increment(LIST_COUNT, 1); */
1904
+ }
1905
+ else if (!strcmp(cmd.s, ""Rlsub"")) {
1906
+ struct listargs listargs;
1907
+
1908
+ c = getastring(imapd_in, imapd_out, &arg1);
1909
+ if (c != ' ') goto missingargs;
1910
+ c = getastring(imapd_in, imapd_out, &arg2);
1911
+ if (c == '\r') c = prot_getc(imapd_in);
1912
+ if (c != '\n') goto extraargs;
1913
+
1914
+ memset(&listargs, 0, sizeof(struct listargs));
1915
+ listargs.cmd = LIST_CMD_LSUB;
1916
+ listargs.sel = LIST_SEL_REMOTE | LIST_SEL_SUBSCRIBED;
1917
+ listargs.ref = arg1.s;
1918
+ strarray_append(&listargs.pat, arg2.s);
1919
+
1920
+ cmd_list(tag.s, &listargs);
1921
+
1922
+ /* snmp_increment(LSUB_COUNT, 1); */
1923
+ }
1924
+ #ifdef HAVE_SSL
1925
+ else if (!strcmp(cmd.s, ""Resetkey"")) {
1926
+ int have_mbox = 0, have_mech = 0;
1927
+
1928
+ if (c == ' ') {
1929
+ have_mbox = 1;
1930
+ c = getastring(imapd_in, imapd_out, &arg1);
1931
+ if (c == EOF) goto missingargs;
1932
+ if (c == ' ') {
1933
+ have_mech = 1;
1934
+ c = getword(imapd_in, &arg2);
1935
+ }
1936
+ }
1937
+
1938
+ if (c == '\r') c = prot_getc(imapd_in);
1939
+ if (c != '\n') goto extraargs;
1940
+ cmd_resetkey(tag.s, have_mbox ? arg1.s : 0,
1941
+ have_mech ? arg2.s : 0);
1942
+ /* snmp_increment(RESETKEY_COUNT, 1);*/
1943
+ }
1944
+ #endif
1945
+ else goto badcmd;
1946
+ break;
1947
+
1948
+ case 'S':
1949
+ if (!strcmp(cmd.s, ""Starttls"")) {
1950
+ if (!tls_enabled()) {
1951
+ /* we don't support starttls */
1952
+ goto badcmd;
1953
+ }
1954
+
1955
+ if (c == '\r') c = prot_getc(imapd_in);
1956
+ if (c != '\n') goto extraargs;
1957
+
1958
+ /* XXX discard any input pipelined after STARTTLS */
1959
+ prot_flush(imapd_in);
1960
+
1961
+ /* if we've already done SASL fail */
1962
+ if (imapd_userid != NULL) {
1963
+ prot_printf(imapd_out,
1964
+ ""%s BAD Can't Starttls after authentication\r\n"", tag.s);
1965
+ continue;
1966
+ }
1967
+
1968
+ /* if we've already done COMPRESS fail */
1969
+ if (imapd_compress_done == 1) {
1970
+ prot_printf(imapd_out,
1971
+ ""%s BAD Can't Starttls after Compress\r\n"", tag.s);
1972
+ continue;
1973
+ }
1974
+
1975
+ /* check if already did a successful tls */
1976
+ if (imapd_starttls_done == 1) {
1977
+ prot_printf(imapd_out,
1978
+ ""%s BAD Already did a successful Starttls\r\n"",
1979
+ tag.s);
1980
+ continue;
1981
+ }
1982
+ cmd_starttls(tag.s, 0);
1983
+
1984
+ snmp_increment(STARTTLS_COUNT, 1);
1985
+ continue;
1986
+ }
1987
+ if (!imapd_userid) {
1988
+ goto nologin;
1989
+ } else if (!strcmp(cmd.s, ""Store"")) {
1990
+ if (!imapd_index && !backend_current) goto nomailbox;
1991
+ usinguid = 0;
1992
+ if (c != ' ') goto missingargs;
1993
+ store:
1994
+ c = getword(imapd_in, &arg1);
1995
+ if (c != ' ' || !imparse_issequence(arg1.s)) goto badsequence;
1996
+
1997
+ cmd_store(tag.s, arg1.s, usinguid);
1998
+
1999
+ snmp_increment(STORE_COUNT, 1);
2000
+ }
2001
+ else if (!strcmp(cmd.s, ""Select"")) {
2002
+ if (c != ' ') goto missingargs;
2003
+ c = getastring(imapd_in, imapd_out, &arg1);
2004
+ if (c == EOF) goto missingargs;
2005
+ prot_ungetc(c, imapd_in);
2006
+
2007
+ cmd_select(tag.s, cmd.s, arg1.s);
2008
+
2009
+ snmp_increment(SELECT_COUNT, 1);
2010
+ }
2011
+ else if (!strcmp(cmd.s, ""Search"")) {
2012
+ if (!imapd_index && !backend_current) goto nomailbox;
2013
+ usinguid = 0;
2014
+ if (c != ' ') goto missingargs;
2015
+ search:
2016
+
2017
+ cmd_search(tag.s, usinguid);
2018
+
2019
+ snmp_increment(SEARCH_COUNT, 1);
2020
+ }
2021
+ else if (!strcmp(cmd.s, ""Subscribe"")) {
2022
+ if (c != ' ') goto missingargs;
2023
+ havenamespace = 0;
2024
+ c = getastring(imapd_in, imapd_out, &arg1);
2025
+ if (c == ' ') {
2026
+ havenamespace = 1;
2027
+ c = getastring(imapd_in, imapd_out, &arg2);
2028
+ }
2029
+ if (c == EOF) goto missingargs;
2030
+ if (c == '\r') c = prot_getc(imapd_in);
2031
+ if (c != '\n') goto extraargs;
2032
+ if (havenamespace) {
2033
+ cmd_changesub(tag.s, arg1.s, arg2.s, 1);
2034
+ }
2035
+ else {
2036
+ cmd_changesub(tag.s, (char *)0, arg1.s, 1);
2037
+ }
2038
+ snmp_increment(SUBSCRIBE_COUNT, 1);
2039
+ }
2040
+ else if (!strcmp(cmd.s, ""Setacl"")) {
2041
+ if (c != ' ') goto missingargs;
2042
+ c = getastring(imapd_in, imapd_out, &arg1);
2043
+ if (c != ' ') goto missingargs;
2044
+ c = getastring(imapd_in, imapd_out, &arg2);
2045
+ if (c != ' ') goto missingargs;
2046
+ c = getastring(imapd_in, imapd_out, &arg3);
2047
+ if (c == EOF) goto missingargs;
2048
+ if (c == '\r') c = prot_getc(imapd_in);
2049
+ if (c != '\n') goto extraargs;
2050
+ cmd_setacl(tag.s, arg1.s, arg2.s, arg3.s);
2051
+
2052
+ snmp_increment(SETACL_COUNT, 1);
2053
+ }
2054
+ else if (!strcmp(cmd.s, ""Setannotation"")) {
2055
+ if (c != ' ') goto missingargs;
2056
+ c = getastring(imapd_in, imapd_out, &arg1);
2057
+ if (c != ' ') goto missingargs;
2058
+
2059
+ cmd_setannotation(tag.s, arg1.s);
2060
+
2061
+ snmp_increment(SETANNOTATION_COUNT, 1);
2062
+ }
2063
+ else if (!strcmp(cmd.s, ""Setmetadata"")) {
2064
+ if (c != ' ') goto missingargs;
2065
+ c = getastring(imapd_in, imapd_out, &arg1);
2066
+ if (c != ' ') goto missingargs;
2067
+
2068
+ cmd_setmetadata(tag.s, arg1.s);
2069
+
2070
+ snmp_increment(SETANNOTATION_COUNT, 1);
2071
+ }
2072
+ else if (!strcmp(cmd.s, ""Setquota"")) {
2073
+ if (c != ' ') goto missingargs;
2074
+ c = getastring(imapd_in, imapd_out, &arg1);
2075
+ if (c != ' ') goto missingargs;
2076
+ cmd_setquota(tag.s, arg1.s);
2077
+
2078
+ snmp_increment(SETQUOTA_COUNT, 1);
2079
+ }
2080
+ else if (!strcmp(cmd.s, ""Sort"")) {
2081
+ if (!imapd_index && !backend_current) goto nomailbox;
2082
+ usinguid = 0;
2083
+ if (c != ' ') goto missingargs;
2084
+ sort:
2085
+ cmd_sort(tag.s, usinguid);
2086
+
2087
+ snmp_increment(SORT_COUNT, 1);
2088
+ }
2089
+ else if (!strcmp(cmd.s, ""Status"")) {
2090
+ if (c != ' ') goto missingargs;
2091
+ c = getastring(imapd_in, imapd_out, &arg1);
2092
+ if (c != ' ') goto missingargs;
2093
+ cmd_status(tag.s, arg1.s);
2094
+
2095
+ snmp_increment(STATUS_COUNT, 1);
2096
+ }
2097
+ else if (!strcmp(cmd.s, ""Scan"")) {
2098
+ struct listargs listargs;
2099
+
2100
+ c = getastring(imapd_in, imapd_out, &arg1);
2101
+ if (c != ' ') goto missingargs;
2102
+ c = getastring(imapd_in, imapd_out, &arg2);
2103
+ if (c != ' ') goto missingargs;
2104
+ c = getastring(imapd_in, imapd_out, &arg3);
2105
+ if (c == '\r') c = prot_getc(imapd_in);
2106
+ if (c != '\n') goto extraargs;
2107
+
2108
+ memset(&listargs, 0, sizeof(struct listargs));
2109
+ listargs.ref = arg1.s;
2110
+ strarray_append(&listargs.pat, arg2.s);
2111
+ listargs.scan = arg3.s;
2112
+
2113
+ cmd_list(tag.s, &listargs);
2114
+
2115
+ snmp_increment(SCAN_COUNT, 1);
2116
+ }
2117
+ else if (!strcmp(cmd.s, ""Syncapply"")) {
2118
+ if (!imapd_userisadmin) goto badcmd;
2119
+
2120
+ struct dlist *kl = sync_parseline(imapd_in);
2121
+
2122
+ if (kl) {
2123
+ cmd_syncapply(tag.s, kl, reserve_list);
2124
+ dlist_free(&kl);
2125
+ }
2126
+ else goto extraargs;
2127
+ }
2128
+ else if (!strcmp(cmd.s, ""Syncget"")) {
2129
+ if (!imapd_userisadmin) goto badcmd;
2130
+
2131
+ struct dlist *kl = sync_parseline(imapd_in);
2132
+
2133
+ if (kl) {
2134
+ cmd_syncget(tag.s, kl);
2135
+ dlist_free(&kl);
2136
+ }
2137
+ else goto extraargs;
2138
+ }
2139
+ else if (!strcmp(cmd.s, ""Syncrestart"")) {
2140
+ if (!imapd_userisadmin) goto badcmd;
2141
+
2142
+ if (c == '\r') c = prot_getc(imapd_in);
2143
+ if (c != '\n') goto extraargs;
2144
+
2145
+ /* just clear the GUID cache */
2146
+ cmd_syncrestart(tag.s, &reserve_list, 1);
2147
+ }
2148
+ else if (!strcmp(cmd.s, ""Syncrestore"")) {
2149
+ if (!imapd_userisadmin) goto badcmd;
2150
+
2151
+ struct dlist *kl = sync_parseline(imapd_in);
2152
+
2153
+ if (kl) {
2154
+ cmd_syncrestore(tag.s, kl, reserve_list);
2155
+ dlist_free(&kl);
2156
+ }
2157
+ else goto extraargs;
2158
+ }
2159
+ else goto badcmd;
2160
+ break;
2161
+
2162
+ case 'T':
2163
+ if (!strcmp(cmd.s, ""Thread"")) {
2164
+ if (!imapd_index && !backend_current) goto nomailbox;
2165
+ usinguid = 0;
2166
+ if (c != ' ') goto missingargs;
2167
+ thread:
2168
+ cmd_thread(tag.s, usinguid);
2169
+
2170
+ snmp_increment(THREAD_COUNT, 1);
2171
+ }
2172
+ else goto badcmd;
2173
+ break;
2174
+
2175
+ case 'U':
2176
+ if (!strcmp(cmd.s, ""Uid"")) {
2177
+ if (!imapd_index && !backend_current) goto nomailbox;
2178
+ usinguid = 1;
2179
+ if (c != ' ') goto missingargs;
2180
+ c = getword(imapd_in, &arg1);
2181
+ if (c != ' ') goto missingargs;
2182
+ lcase(arg1.s);
2183
+ xstrncpy(cmdname, arg1.s, 99);
2184
+ if (!strcmp(arg1.s, ""fetch"")) {
2185
+ goto fetch;
2186
+ }
2187
+ else if (!strcmp(arg1.s, ""store"")) {
2188
+ goto store;
2189
+ }
2190
+ else if (!strcmp(arg1.s, ""search"")) {
2191
+ goto search;
2192
+ }
2193
+ else if (!strcmp(arg1.s, ""sort"")) {
2194
+ goto sort;
2195
+ }
2196
+ else if (!strcmp(arg1.s, ""thread"")) {
2197
+ goto thread;
2198
+ }
2199
+ else if (!strcmp(arg1.s, ""copy"")) {
2200
+ goto copy;
2201
+ }
2202
+ else if (!strcmp(arg1.s, ""move"")) {
2203
+ goto move;
2204
+ }
2205
+ else if (!strcmp(arg1.s, ""xmove"")) {
2206
+ goto move;
2207
+ }
2208
+ else if (!strcmp(arg1.s, ""expunge"")) {
2209
+ c = getword(imapd_in, &arg1);
2210
+ if (!imparse_issequence(arg1.s)) goto badsequence;
2211
+ if (c == '\r') c = prot_getc(imapd_in);
2212
+ if (c != '\n') goto extraargs;
2213
+ cmd_expunge(tag.s, arg1.s);
2214
+
2215
+ snmp_increment(EXPUNGE_COUNT, 1);
2216
+ }
2217
+ else if (!strcmp(arg1.s, ""xrunannotator"")) {
2218
+ goto xrunannotator;
2219
+ }
2220
+ else {
2221
+ prot_printf(imapd_out, ""%s BAD Unrecognized UID subcommand\r\n"", tag.s);
2222
+ eatline(imapd_in, c);
2223
+ }
2224
+ }
2225
+ else if (!strcmp(cmd.s, ""Unsubscribe"")) {
2226
+ if (c != ' ') goto missingargs;
2227
+ havenamespace = 0;
2228
+ c = getastring(imapd_in, imapd_out, &arg1);
2229
+ if (c == ' ') {
2230
+ havenamespace = 1;
2231
+ c = getastring(imapd_in, imapd_out, &arg2);
2232
+ }
2233
+ if (c == EOF) goto missingargs;
2234
+ if (c == '\r') c = prot_getc(imapd_in);
2235
+ if (c != '\n') goto extraargs;
2236
+ if (havenamespace) {
2237
+ cmd_changesub(tag.s, arg1.s, arg2.s, 0);
2238
+ }
2239
+ else {
2240
+ cmd_changesub(tag.s, (char *)0, arg1.s, 0);
2241
+ }
2242
+
2243
+ snmp_increment(UNSUBSCRIBE_COUNT, 1);
2244
+ }
2245
+ else if (!strcmp(cmd.s, ""Unselect"")) {
2246
+ if (!imapd_index && !backend_current) goto nomailbox;
2247
+ if (c == '\r') c = prot_getc(imapd_in);
2248
+ if (c != '\n') goto extraargs;
2249
+
2250
+ cmd_close(tag.s, cmd.s);
2251
+
2252
+ snmp_increment(UNSELECT_COUNT, 1);
2253
+ }
2254
+ else if (!strcmp(cmd.s, ""Undump"")) {
2255
+ if(c != ' ') goto missingargs;
2256
+ c = getastring(imapd_in, imapd_out, &arg1);
2257
+
2258
+ /* we want to get a list at this point */
2259
+ if(c != ' ') goto missingargs;
2260
+
2261
+ cmd_undump(tag.s, arg1.s);
2262
+ /* snmp_increment(UNDUMP_COUNT, 1);*/
2263
+ }
2264
+ #ifdef HAVE_SSL
2265
+ else if (!strcmp(cmd.s, ""Urlfetch"")) {
2266
+ if (c != ' ') goto missingargs;
2267
+
2268
+ cmd_urlfetch(tag.s);
2269
+ /* snmp_increment(URLFETCH_COUNT, 1);*/
2270
+ }
2271
+ #endif
2272
+ else goto badcmd;
2273
+ break;
2274
+
2275
+ case 'X':
2276
+ if (!strcmp(cmd.s, ""Xbackup"")) {
2277
+ int havechannel = 0;
2278
+
2279
+ if (!config_getswitch(IMAPOPT_XBACKUP_ENABLED))
2280
+ goto badcmd;
2281
+
2282
+ /* user */
2283
+ if (c != ' ') goto missingargs;
2284
+ c = getastring(imapd_in, imapd_out, &arg1);
2285
+
2286
+ /* channel */
2287
+ if (c == ' ') {
2288
+ havechannel = 1;
2289
+ c = getword(imapd_in, &arg2);
2290
+ if (c == EOF) goto missingargs;
2291
+ }
2292
+
2293
+ if (c == '\r') c = prot_getc(imapd_in);
2294
+ if (c != '\n') goto extraargs;
2295
+
2296
+ cmd_xbackup(tag.s, arg1.s, havechannel ? arg2.s : NULL);
2297
+
2298
+ }
2299
+ else if (!strcmp(cmd.s, ""Xconvfetch"")) {
2300
+ cmd_xconvfetch(tag.s);
2301
+
2302
+ }
2303
+ else if (!strcmp(cmd.s, ""Xconvmultisort"")) {
2304
+ if (c != ' ') goto missingargs;
2305
+ if (!imapd_index && !backend_current) goto nomailbox;
2306
+ cmd_xconvmultisort(tag.s);
2307
+
2308
+ }
2309
+ else if (!strcmp(cmd.s, ""Xconvsort"")) {
2310
+ if (c != ' ') goto missingargs;
2311
+ if (!imapd_index && !backend_current) goto nomailbox;
2312
+ cmd_xconvsort(tag.s, 0);
2313
+
2314
+ }
2315
+ else if (!strcmp(cmd.s, ""Xconvupdates"")) {
2316
+ if (c != ' ') goto missingargs;
2317
+ if (!imapd_index && !backend_current) goto nomailbox;
2318
+ cmd_xconvsort(tag.s, 1);
2319
+
2320
+ }
2321
+ else if (!strcmp(cmd.s, ""Xfer"")) {
2322
+ int havepartition = 0;
2323
+
2324
+ /* Mailbox */
2325
+ if(c != ' ') goto missingargs;
2326
+ c = getastring(imapd_in, imapd_out, &arg1);
2327
+
2328
+ /* Dest Server */
2329
+ if(c != ' ') goto missingargs;
2330
+ c = getastring(imapd_in, imapd_out, &arg2);
2331
+
2332
+ if(c == ' ') {
2333
+ /* Dest Partition */
2334
+ c = getastring(imapd_in, imapd_out, &arg3);
2335
+ if (!imparse_isatom(arg3.s)) goto badpartition;
2336
+ havepartition = 1;
2337
+ }
2338
+
2339
+ if (c == '\r') c = prot_getc(imapd_in);
2340
+ if (c != '\n') goto extraargs;
2341
+
2342
+ cmd_xfer(tag.s, arg1.s, arg2.s,
2343
+ (havepartition ? arg3.s : NULL));
2344
+ /* snmp_increment(XFER_COUNT, 1);*/
2345
+ }
2346
+ else if (!strcmp(cmd.s, ""Xconvmeta"")) {
2347
+ cmd_xconvmeta(tag.s);
2348
+ }
2349
+ else if (!strcmp(cmd.s, ""Xlist"")) {
2350
+ struct listargs listargs;
2351
+
2352
+ if (c != ' ') goto missingargs;
2353
+
2354
+ memset(&listargs, 0, sizeof(struct listargs));
2355
+ listargs.cmd = LIST_CMD_XLIST;
2356
+ listargs.ret = LIST_RET_CHILDREN | LIST_RET_SPECIALUSE;
2357
+ getlistargs(tag.s, &listargs);
2358
+ if (listargs.pat.count) cmd_list(tag.s, &listargs);
2359
+
2360
+ snmp_increment(LIST_COUNT, 1);
2361
+ }
2362
+ else if (!strcmp(cmd.s, ""Xmove"")) {
2363
+ if (!imapd_index && !backend_current) goto nomailbox;
2364
+ usinguid = 0;
2365
+ if (c != ' ') goto missingargs;
2366
+ goto move;
2367
+ }
2368
+ else if (!strcmp(cmd.s, ""Xrunannotator"")) {
2369
+ if (!imapd_index && !backend_current) goto nomailbox;
2370
+ usinguid = 0;
2371
+ if (c != ' ') goto missingargs;
2372
+ xrunannotator:
2373
+ c = getword(imapd_in, &arg1);
2374
+ if (!arg1.len || !imparse_issequence(arg1.s)) goto badsequence;
2375
+ cmd_xrunannotator(tag.s, arg1.s, usinguid);
2376
+ }
2377
+ else if (!strcmp(cmd.s, ""Xsnippets"")) {
2378
+ if (c != ' ') goto missingargs;
2379
+ if (!imapd_index && !backend_current) goto nomailbox;
2380
+ cmd_xsnippets(tag.s);
2381
+
2382
+ }
2383
+ else if (!strcmp(cmd.s, ""Xstats"")) {
2384
+ cmd_xstats(tag.s, c);
2385
+ }
2386
+ else if (!strcmp(cmd.s, ""Xwarmup"")) {
2387
+ /* XWARMUP doesn't need a mailbox to be selected */
2388
+ if (c != ' ') goto missingargs;
2389
+ cmd_xwarmup(tag.s);
2390
+ }
2391
+ else if (!strcmp(cmd.s, ""Xkillmy"")) {
2392
+ if (c != ' ') goto missingargs;
2393
+ c = getastring(imapd_in, imapd_out, &arg1);
2394
+ if (c == EOF) goto missingargs;
2395
+ if (c == '\r') c = prot_getc(imapd_in);
2396
+ if (c != '\n') goto extraargs;
2397
+ cmd_xkillmy(tag.s, arg1.s);
2398
+ }
2399
+ else if (!strcmp(cmd.s, ""Xforever"")) {
2400
+ if (c == '\r') c = prot_getc(imapd_in);
2401
+ if (c != '\n') goto extraargs;
2402
+ cmd_xforever(tag.s);
2403
+ }
2404
+ else if (!strcmp(cmd.s, ""Xmeid"")) {
2405
+ if (c != ' ') goto missingargs;
2406
+ c = getastring(imapd_in, imapd_out, &arg1);
2407
+ if (c == EOF) goto missingargs;
2408
+ if (c == '\r') c = prot_getc(imapd_in);
2409
+ if (c != '\n') goto extraargs;
2410
+ cmd_xmeid(tag.s, arg1.s);
2411
+ }
2412
+
2413
+ else if (apns_enabled && !strcmp(cmd.s, ""Xapplepushservice"")) {
2414
+ if (c != ' ') goto missingargs;
2415
+
2416
+ memset(&applepushserviceargs, 0, sizeof(struct applepushserviceargs));
2417
+
2418
+ do {
2419
+ c = getastring(imapd_in, imapd_out, &arg1);
2420
+ if (c == EOF) goto aps_missingargs;
2421
+
2422
+ if (!strcmp(arg1.s, ""mailboxes"")) {
2423
+ c = prot_getc(imapd_in);
2424
+ if (c != '(')
2425
+ goto aps_missingargs;
2426
+
2427
+ c = prot_getc(imapd_in);
2428
+ if (c != ')') {
2429
+ prot_ungetc(c, imapd_in);
2430
+ do {
2431
+ c = getastring(imapd_in, imapd_out, &arg2);
2432
+ if (c == EOF) break;
2433
+ strarray_push(&applepushserviceargs.mailboxes, arg2.s);
2434
+ } while (c == ' ');
2435
+ }
2436
+
2437
+ if (c != ')')
2438
+ goto aps_missingargs;
2439
+ c = prot_getc(imapd_in);
2440
+ }
2441
+
2442
+ else {
2443
+ c = getastring(imapd_in, imapd_out, &arg2);
2444
+
2445
+ if (!strcmp(arg1.s, ""aps-version"")) {
2446
+ if (!imparse_isnumber(arg2.s)) goto aps_extraargs;
2447
+ applepushserviceargs.aps_version = atoi(arg2.s);
2448
+ }
2449
+ else if (!strcmp(arg1.s, ""aps-account-id""))
2450
+ buf_copy(&applepushserviceargs.aps_account_id, &arg2);
2451
+ else if (!strcmp(arg1.s, ""aps-device-token""))
2452
+ buf_copy(&applepushserviceargs.aps_device_token, &arg2);
2453
+ else if (!strcmp(arg1.s, ""aps-subtopic""))
2454
+ buf_copy(&applepushserviceargs.aps_subtopic, &arg2);
2455
+ else
2456
+ goto aps_extraargs;
2457
+ }
2458
+ } while (c == ' ');
2459
+
2460
+ if (c == '\r') c = prot_getc(imapd_in);
2461
+ if (c != '\n') goto aps_extraargs;
2462
+
2463
+ cmd_xapplepushservice(tag.s, &applepushserviceargs);
2464
+ }
2465
+
2466
+ else goto badcmd;
2467
+ break;
2468
+
2469
+ default:
2470
+ badcmd:
2471
+ prot_printf(imapd_out, ""%s BAD Unrecognized command\r\n"", tag.s);
2472
+ eatline(imapd_in, c);
2473
+ }
2474
+
2475
+ /* End command timer - don't log ""idle"" commands */
2476
+ if (commandmintimer && strcmp(""idle"", cmdname)) {
2477
+ double cmdtime, nettime;
2478
+ const char *mboxname = index_mboxname(imapd_index);
2479
+ if (!mboxname) mboxname = ""<none>"";
2480
+ cmdtime_endtimer(&cmdtime, &nettime);
2481
+ if (cmdtime >= commandmintimerd) {
2482
+ syslog(LOG_NOTICE, ""cmdtimer: '%s' '%s' '%s' '%f' '%f' '%f'"",
2483
+ imapd_userid ? imapd_userid : ""<none>"", cmdname, mboxname,
2484
+ cmdtime, nettime, cmdtime + nettime);
2485
+ }
2486
+ }
2487
+ continue;
2488
+
2489
+ nologin:
2490
+ prot_printf(imapd_out, ""%s BAD Please login first\r\n"", tag.s);
2491
+ eatline(imapd_in, c);
2492
+ continue;
2493
+
2494
+ nomailbox:
2495
+ prot_printf(imapd_out,
2496
+ ""%s BAD Please select a mailbox first\r\n"", tag.s);
2497
+ eatline(imapd_in, c);
2498
+ continue;
2499
+
2500
+ aps_missingargs:
2501
+ buf_free(&applepushserviceargs.aps_account_id);
2502
+ buf_free(&applepushserviceargs.aps_device_token);
2503
+ buf_free(&applepushserviceargs.aps_subtopic);
2504
+ strarray_fini(&applepushserviceargs.mailboxes);
2505
+
2506
+ missingargs:
2507
+ prot_printf(imapd_out,
2508
+ ""%s BAD Missing required argument to %s\r\n"", tag.s, cmd.s);
2509
+ eatline(imapd_in, c);
2510
+ continue;
2511
+
2512
+ aps_extraargs:
2513
+ buf_free(&applepushserviceargs.aps_account_id);
2514
+ buf_free(&applepushserviceargs.aps_device_token);
2515
+ buf_free(&applepushserviceargs.aps_subtopic);
2516
+ strarray_fini(&applepushserviceargs.mailboxes);
2517
+
2518
+ extraargs:
2519
+ prot_printf(imapd_out,
2520
+ ""%s BAD Unexpected extra arguments to %s\r\n"", tag.s, cmd.s);
2521
+ eatline(imapd_in, c);
2522
+ continue;
2523
+
2524
+ badsequence:
2525
+ prot_printf(imapd_out,
2526
+ ""%s BAD Invalid sequence in %s\r\n"", tag.s, cmd.s);
2527
+ eatline(imapd_in, c);
2528
+ continue;
2529
+
2530
+ badpartition:
2531
+ prot_printf(imapd_out,
2532
+ ""%s BAD Invalid partition name in %s\r\n"", tag.s, cmd.s);
2533
+ eatline(imapd_in, c);
2534
+ continue;
2535
+ }
2536
+
2537
+ done:
2538
+ cmd_syncrestart(NULL, &reserve_list, 0);
2539
+ }
2540
+ ","@@ -2062,6 +2062,8 @@ static void cmdloop(void)
2541
+ snmp_increment(SCAN_COUNT, 1);
2542
+ }
2543
+ else if (!strcmp(cmd.s, ""Syncapply"")) {
2544
+ + if (!imapd_userisadmin) goto badcmd;
2545
+ +
2546
+ struct dlist *kl = sync_parseline(imapd_in);
2547
+
2548
+ if (kl) {
2549
+ @@ -2071,6 +2073,8 @@ static void cmdloop(void)
2550
+ else goto extraargs;
2551
+ }
2552
+ else if (!strcmp(cmd.s, ""Syncget"")) {
2553
+ + if (!imapd_userisadmin) goto badcmd;
2554
+ +
2555
+ struct dlist *kl = sync_parseline(imapd_in);
2556
+
2557
+ if (kl) {
2558
+ @@ -2080,13 +2084,17 @@ static void cmdloop(void)
2559
+ else goto extraargs;
2560
+ }
2561
+ else if (!strcmp(cmd.s, ""Syncrestart"")) {
2562
+ + if (!imapd_userisadmin) goto badcmd;
2563
+ +
2564
+ if (c == '\r') c = prot_getc(imapd_in);
2565
+ if (c != '\n') goto extraargs;
2566
+
2567
+ /* just clear the GUID cache */
2568
+ cmd_syncrestart(tag.s, &reserve_list, 1);
2569
+ }
2570
+ else if (!strcmp(cmd.s, ""Syncrestore"")) {
2571
+ + if (!imapd_userisadmin) goto badcmd;
2572
+ +
2573
+ struct dlist *kl = sync_parseline(imapd_in);
2574
+
2575
+ if (kl) {",11258,11493,15000
categorized_datasets_for_R1-Distill-Llama/BigVul_Sample/BigVul_Sample_11000_to_15000.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a499107ff2c6cdd2a17ad0b2ffe6d3c1f9ec490cd60317187f77a071293d076b
3
+ size 96375
categorized_datasets_for_R1-Distill-Llama/BigVul_Sample/BigVul_Sample_2048_to_4096.csv ADDED
The diff for this file is too large to render. See raw diff
 
categorized_datasets_for_R1-Distill-Llama/BigVul_Sample/BigVul_Sample_2048_to_4096.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9624d29dd4d8b6127c9a3d5beea84723a3f24d981b2218388bf07414ed10781a
3
+ size 2774203
categorized_datasets_for_R1-Distill-Llama/BigVul_Sample/BigVul_Sample_4096_to_6144.csv ADDED
The diff for this file is too large to render. See raw diff
 
categorized_datasets_for_R1-Distill-Llama/BigVul_Sample/BigVul_Sample_4096_to_6144.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:564d75a55c32af5bd8d99fa15e1f6fc4651d595f40597160d69b89e0d882b7cb
3
+ size 1492747
categorized_datasets_for_R1-Distill-Llama/BigVul_Sample/BigVul_Sample_512_to_1024.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:89ffa42365ba1c0488a1de5ea667f705ab7b78c4559c222ce3dc93047c1a7dec
3
+ size 12312875
categorized_datasets_for_R1-Distill-Llama/BigVul_Sample/BigVul_Sample_512_to_1024.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ef4cb75ffaddc34b74b7594b42a4078514126c6ffbf657425ea26415cec6bbd7
3
+ size 8507150
categorized_datasets_for_R1-Distill-Llama/BigVul_Sample/BigVul_Sample_6144_to_8192.csv ADDED
The diff for this file is too large to render. See raw diff
 
categorized_datasets_for_R1-Distill-Llama/BigVul_Sample/BigVul_Sample_6144_to_8192.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f8e526a29d5c4b9745727ef8fe2a09531a4f4cf2c7886a98f358847b55bd2a28
3
+ size 561370
categorized_datasets_for_R1-Distill-Llama/BigVul_Sample/BigVul_Sample_8192_to_11000.csv ADDED
The diff for this file is too large to render. See raw diff
 
categorized_datasets_for_R1-Distill-Llama/BigVul_Sample/BigVul_Sample_8192_to_11000.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9a2f883b26024bd37475f6bc170b0a69a8e383129d1c7a88b10a61967fef58a3
3
+ size 533095
categorized_datasets_for_R1-Distill-Llama/BigVul_Sample/BigVul_Sample_stats.json ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "total": 10000,
3
+ "processed": 9998,
4
+ "skipped": 2,
5
+ "categories": {
6
+ "under_512": {
7
+ "count": 7607,
8
+ "percentage": 76.07,
9
+ "max_tokens_setting": 512
10
+ },
11
+ "512_to_1024": {
12
+ "count": 1717,
13
+ "percentage": 17.17,
14
+ "max_tokens_setting": 1024
15
+ },
16
+ "1024_to_2048": {
17
+ "count": 483,
18
+ "percentage": 4.83,
19
+ "max_tokens_setting": 2048
20
+ },
21
+ "2048_to_4096": {
22
+ "count": 133,
23
+ "percentage": 1.33,
24
+ "max_tokens_setting": 4096
25
+ },
26
+ "4096_to_6144": {
27
+ "count": 39,
28
+ "percentage": 0.39,
29
+ "max_tokens_setting": 6144
30
+ },
31
+ "6144_to_8192": {
32
+ "count": 11,
33
+ "percentage": 0.11,
34
+ "max_tokens_setting": 8192
35
+ },
36
+ "8192_to_11000": {
37
+ "count": 7,
38
+ "percentage": 0.07,
39
+ "max_tokens_setting": 11000
40
+ },
41
+ "11000_to_15000": {
42
+ "count": 1,
43
+ "percentage": 0.01,
44
+ "max_tokens_setting": 15000
45
+ }
46
+ }
47
+ }
categorized_datasets_for_R1-Distill-Llama/BigVul_Sample/BigVul_Sample_under_512.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:59c31734f90fe028ab87a0620e7309b28571d3344cbdda3baa78a7a4ab29e485
3
+ size 29917281
categorized_datasets_for_R1-Distill-Llama/BigVul_Sample/BigVul_Sample_under_512.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3213c74eeb5da9688708a67a82684952a46af136cf8f06cea6a7f7ecf03ed1a9
3
+ size 12519806
categorized_datasets_for_R1-Distill-Llama/DiverseVul_Sample/DiverseVul_Sample_1024_to_2048.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
categorized_datasets_for_R1-Distill-Llama/DiverseVul_Sample/DiverseVul_Sample_1024_to_2048.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:748b8994285fe6b65eb5717f59076fdb5874b5a0b982db92923a16d208751d4d
3
+ size 2510632
categorized_datasets_for_R1-Distill-Llama/DiverseVul_Sample/DiverseVul_Sample_11000_to_15000.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
categorized_datasets_for_R1-Distill-Llama/DiverseVul_Sample/DiverseVul_Sample_11000_to_15000.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:eff9a5daa9bae69bf19618a3463b9633fe0e2a5865937197142675312126b4d9
3
+ size 161976
categorized_datasets_for_R1-Distill-Llama/DiverseVul_Sample/DiverseVul_Sample_2048_to_4096.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
categorized_datasets_for_R1-Distill-Llama/DiverseVul_Sample/DiverseVul_Sample_2048_to_4096.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9234691891059ac5928fa83a72c9bd4629c1cfc449391f4a9a14a42f530b4d91
3
+ size 1594661
categorized_datasets_for_R1-Distill-Llama/DiverseVul_Sample/DiverseVul_Sample_4096_to_6144.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
categorized_datasets_for_R1-Distill-Llama/DiverseVul_Sample/DiverseVul_Sample_4096_to_6144.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9b35fa9f8cf736f49ca4d6b79ad8eed459e2b76344e82b69da3817b5384a7f75
3
+ size 775072
categorized_datasets_for_R1-Distill-Llama/DiverseVul_Sample/DiverseVul_Sample_512_to_1024.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
categorized_datasets_for_R1-Distill-Llama/DiverseVul_Sample/DiverseVul_Sample_512_to_1024.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d9e775341e44151d261f55f14bce96e4b1e720b2188dccb181dbc2aa9e4260eb
3
+ size 3466049
categorized_datasets_for_R1-Distill-Llama/DiverseVul_Sample/DiverseVul_Sample_6144_to_8192.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
categorized_datasets_for_R1-Distill-Llama/DiverseVul_Sample/DiverseVul_Sample_6144_to_8192.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:81a88bd06b559912ad0d7109bed0eda9a0f020f940607158d4ca1d2ad8c49d3e
3
+ size 624732
categorized_datasets_for_R1-Distill-Llama/DiverseVul_Sample/DiverseVul_Sample_8192_to_11000.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
categorized_datasets_for_R1-Distill-Llama/DiverseVul_Sample/DiverseVul_Sample_8192_to_11000.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9711874e990cd35bc624616437b49e812b565cf4261d769c394b19f49dd16637
3
+ size 172796
categorized_datasets_for_R1-Distill-Llama/DiverseVul_Sample/DiverseVul_Sample_stats.json ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "total": 10000,
3
+ "processed": 9993,
4
+ "skipped": 7,
5
+ "categories": {
6
+ "under_512": {
7
+ "count": 7025,
8
+ "percentage": 70.25,
9
+ "max_tokens_setting": 512
10
+ },
11
+ "512_to_1024": {
12
+ "count": 2089,
13
+ "percentage": 20.89,
14
+ "max_tokens_setting": 1024
15
+ },
16
+ "1024_to_2048": {
17
+ "count": 619,
18
+ "percentage": 6.19,
19
+ "max_tokens_setting": 2048
20
+ },
21
+ "2048_to_4096": {
22
+ "count": 179,
23
+ "percentage": 1.79,
24
+ "max_tokens_setting": 4096
25
+ },
26
+ "4096_to_6144": {
27
+ "count": 45,
28
+ "percentage": 0.45,
29
+ "max_tokens_setting": 6144
30
+ },
31
+ "6144_to_8192": {
32
+ "count": 26,
33
+ "percentage": 0.26,
34
+ "max_tokens_setting": 8192
35
+ },
36
+ "8192_to_11000": {
37
+ "count": 6,
38
+ "percentage": 0.06,
39
+ "max_tokens_setting": 11000
40
+ },
41
+ "11000_to_15000": {
42
+ "count": 4,
43
+ "percentage": 0.04,
44
+ "max_tokens_setting": 15000
45
+ }
46
+ }
47
+ }
categorized_datasets_for_R1-Distill-Llama/DiverseVul_Sample/DiverseVul_Sample_under_512.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
categorized_datasets_for_R1-Distill-Llama/DiverseVul_Sample/DiverseVul_Sample_under_512.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:77691e46a83fff6ddd474d16984a9ec021edd8e0683fe8be582ae2c6a35bd238
3
+ size 2978468
categorized_datasets_for_R1-Distill-Llama/PrimeVul_Sample/PrimeVul_Sample_1024_to_2048.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
categorized_datasets_for_R1-Distill-Llama/PrimeVul_Sample/PrimeVul_Sample_1024_to_2048.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b5e8ed7fae9811e1220810e5b5c053b32b20ca44b6b9a7ba62279f01b0e7d43f
3
+ size 3079029
categorized_datasets_for_R1-Distill-Llama/PrimeVul_Sample/PrimeVul_Sample_11000_to_15000.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
categorized_datasets_for_R1-Distill-Llama/PrimeVul_Sample/PrimeVul_Sample_11000_to_15000.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:104ba03ca422aad541f930a23c003d1ac167941d074b7f22e8a35c3c37484c74
3
+ size 813621
categorized_datasets_for_R1-Distill-Llama/PrimeVul_Sample/PrimeVul_Sample_2048_to_4096.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
categorized_datasets_for_R1-Distill-Llama/PrimeVul_Sample/PrimeVul_Sample_2048_to_4096.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c4b183cf10226ae7eb5563584bba7d1c6f6727d7ce2b4d89b2e72c231a668869
3
+ size 2132230
categorized_datasets_for_R1-Distill-Llama/PrimeVul_Sample/PrimeVul_Sample_4096_to_6144.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
categorized_datasets_for_R1-Distill-Llama/PrimeVul_Sample/PrimeVul_Sample_4096_to_6144.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:67659416378af034edd71267e13723a106c3305e4ca1b5b6bf65a1c03bc636d4
3
+ size 857520
categorized_datasets_for_R1-Distill-Llama/PrimeVul_Sample/PrimeVul_Sample_512_to_1024.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
categorized_datasets_for_R1-Distill-Llama/PrimeVul_Sample/PrimeVul_Sample_512_to_1024.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7cb1fcaf960fe50b62bbde5dbd476dc30368bc83e0d2d0f8afb7cec1be932ce5
3
+ size 3471251
categorized_datasets_for_R1-Distill-Llama/PrimeVul_Sample/PrimeVul_Sample_6144_to_8192.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
categorized_datasets_for_R1-Distill-Llama/PrimeVul_Sample/PrimeVul_Sample_6144_to_8192.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3c18f3729d2d83c2fd4bb886df1a7a2053cd73e372fd8fdfff1f6f27e4e7ee39
3
+ size 612624
categorized_datasets_for_R1-Distill-Llama/PrimeVul_Sample/PrimeVul_Sample_8192_to_11000.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
categorized_datasets_for_R1-Distill-Llama/PrimeVul_Sample/PrimeVul_Sample_8192_to_11000.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:60b2c2377c95366a64ef64d6c3a4431869c0d1adbf9ef003eb02391c80bf7690
3
+ size 626231
categorized_datasets_for_R1-Distill-Llama/PrimeVul_Sample/PrimeVul_Sample_stats.json ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "total": 10000,
3
+ "processed": 9999,
4
+ "skipped": 1,
5
+ "categories": {
6
+ "under_512": {
7
+ "count": 6769,
8
+ "percentage": 67.69,
9
+ "max_tokens_setting": 512
10
+ },
11
+ "512_to_1024": {
12
+ "count": 2115,
13
+ "percentage": 21.15,
14
+ "max_tokens_setting": 1024
15
+ },
16
+ "1024_to_2048": {
17
+ "count": 763,
18
+ "percentage": 7.63,
19
+ "max_tokens_setting": 2048
20
+ },
21
+ "2048_to_4096": {
22
+ "count": 239,
23
+ "percentage": 2.39,
24
+ "max_tokens_setting": 4096
25
+ },
26
+ "4096_to_6144": {
27
+ "count": 49,
28
+ "percentage": 0.49,
29
+ "max_tokens_setting": 6144
30
+ },
31
+ "6144_to_8192": {
32
+ "count": 26,
33
+ "percentage": 0.26,
34
+ "max_tokens_setting": 8192
35
+ },
36
+ "8192_to_11000": {
37
+ "count": 19,
38
+ "percentage": 0.19,
39
+ "max_tokens_setting": 11000
40
+ },
41
+ "11000_to_15000": {
42
+ "count": 19,
43
+ "percentage": 0.19,
44
+ "max_tokens_setting": 15000
45
+ }
46
+ }
47
+ }