callback.json.example 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. {
  2. "conf_id":
  3. {
  4. "bdriver": "Backend pool driver to proxy. This can be a class name or a full module path to a class implementing `qubes.storage.Pool`.",
  5. "bdriver_args": {
  6. "arg name 1": "arg value 1",
  7. "arg name 2": "arg value 2"
  8. },
  9. "cmd": "Default command to call when the [pre|post]_[op] operations are not specified (default: None). The command is called as such: `[cmd] [name] [bdriver] [operation] [ctor params]`. [name]: name of the pool, [operation]: any of the `[pre|post]_` operations from below including its arguments, [bdriver]: backend driver of the pool, [ctor params]: Parameters passed to the `bdriver` constructor in JSON format. Each parameter is on a single line for easy parsing.",
  10. "signal_back": "Boolean (true|false) to allow the executed commands to send signals back to the callback driver (default: false). Signals must be on a dedicated line on stdout. Currently only `SIGNAL_setup` is supported. When found, it causes the callback driver to re-setup the backend pool.",
  11. "pre_sinit": "Command to call before one-time storage initialization/first usage (default: None). Called exactly once for every `qubesd` start. Can be used to override `cmd`. Pass `-` to ignore this callback entirely even if `cmd` is specified.",
  12. "pre_setup": "Called before creating a new pool. Can be used to override `cmd`. Pass `-` to ignore this callback entirely even if `cmd` is specified.",
  13. "post_destroy": "Called after removing an existing pool. Same as above otherwise.",
  14. "pre_volume_create": "Called before creating a volume for the pool. Same as above otherwise.",
  15. "post_volume_create": "Called after creating a volume for the pool. Same as above otherwise.",
  16. "post_volume_remove": "Called after removing a volume of the pool. Same as above otherwise.",
  17. "pre_volume_resize": "Called before resizing a volume of the pool. Same as above otherwise.",
  18. "pre_volume_start": "Called before starting a volume of the pool. Same as above otherwise.",
  19. "post_volume_start": "Called after starting a volume of the pool. Same as above otherwise.",
  20. "post_volume_stop": "Called after stopping a volume of the pool. Same as above otherwise.",
  21. "pre_volume_import": "Called before importing a volume from another. Same as above otherwise.",
  22. "post_volume_import": "Called after importing a volume from another. Same as above otherwise.",
  23. "pre_volume_import_data": "Called before overwriting this volume with new data. Same as above otherwise.",
  24. "post_volume_import_data_end": "Called after finishing an `import_data` action. Same as above otherwise.",
  25. "pre_volume_export": "Called before exporting a volume. Same as above otherwise.",
  26. "post_volume_export_end": "Called after a volume export completed. Same as above otherwise.",
  27. "description": "Optional description for your personal reference."
  28. },
  29. "testing-fail-missing-all":
  30. {
  31. "description": "For testing purposes only."
  32. },
  33. "testing-fail-missing-bdriver-args":
  34. {
  35. "bdriver": "file",
  36. "description": "For testing purposes only."
  37. },
  38. "testing-succ-file-01":
  39. {
  40. "bdriver": "file",
  41. "bdriver_args": {
  42. "dir_path": "/mnt/test01",
  43. "revisions_to_keep": 0
  44. },
  45. "description": "For testing purposes only."
  46. },
  47. "testing-succ-file-02":
  48. {
  49. "bdriver": "file",
  50. "bdriver_args": {
  51. "dir_path": "/mnt/test02"
  52. },
  53. "cmd": "testCbLogArgs",
  54. "description": "For testing purposes only."
  55. },
  56. "testing-succ-file-03":
  57. {
  58. "bdriver": "file",
  59. "bdriver_args": {
  60. "dir_path": "/mnt/test03"
  61. },
  62. "cmd": "exit 1",
  63. "pre_sinit": "testCbLogArgs pre_sinit",
  64. "pre_setup": "testCbLogArgs pre_setup",
  65. "post_destroy": "-",
  66. "description": "For testing purposes only."
  67. },
  68. "testing-succ-file-luks":
  69. {
  70. "bdriver": "file",
  71. "bdriver_args": {
  72. "dir_path": "/mnt/test_luks"
  73. },
  74. "pre_setup": "set -e -o pipefail ; [ ! -e /mnt/test.key ] ; [ ! -e /mnt/test.luks ] ; dd if=/dev/random bs=100 of=/mnt/test.key iflag=fullblock count=1 ; dd if=/dev/urandom bs=1M of=/mnt/test.luks iflag=fullblock count=2048 ; cryptsetup luksFormat -q --key-file /mnt/test.key /mnt/test.luks ; cryptsetup open -q --key-file /mnt/test.key /mnt/test.luks test-luks ; mkfs -t ext4 /dev/mapper/test-luks ; mkdir -p /mnt/test_luks ; mount /dev/mapper/test-luks /mnt/test_luks",
  75. "pre_sinit": "set -e -o pipefail ; if [[ \"$(findmnt -S /dev/mapper/test-luks -n -o TARGET)\" != \"/mnt/test_luks\" ]] ; then cryptsetup status test-luks > /dev/null || cryptsetup open -q --key-file /mnt/test.key /mnt/test.luks test-luks ; mount /dev/mapper/test-luks /mnt/test_luks ; else exit 0 ; fi",
  76. "post_destroy": "umount /mnt/test_luks && cryptsetup close test-luks ; set -e -o pipefail ; dd if=/dev/urandom bs=100 of=/mnt/test.key iflag=fullblock count=1 ; rm -f /mnt/test.key ; rm -f /mnt/test.luks ; rmdir /mnt/test_luks",
  77. "pre_volume_create": "[[ \"$(findmnt -S /dev/mapper/test-luks -n -o TARGET)\" == \"/mnt/test_luks\" ]]",
  78. "pre_volume_import": "[[ \"$(findmnt -S /dev/mapper/test-luks -n -o TARGET)\" == \"/mnt/test_luks\" ]]",
  79. "pre_volume_import_data": "[[ \"$(findmnt -S /dev/mapper/test-luks -n -o TARGET)\" == \"/mnt/test_luks\" ]]",
  80. "post_volume_import_data_end": "[[ \"$(findmnt -S /dev/mapper/test-luks -n -o TARGET)\" == \"/mnt/test_luks\" ]]",
  81. "description": "For testing purposes only: Showcasing seemless use of encrypted VM pools. For personal use, a dedicated script is recommended."
  82. },
  83. "testing-succ-file-luks-eph":
  84. {
  85. "bdriver": "file",
  86. "bdriver_args": {
  87. "dir_path": "/mnt/test_eph"
  88. },
  89. "signal_back": true,
  90. "pre_setup": "set -e -o pipefail ; if [[ \"$(findmnt -T /mnt/ram -o SOURCE -n)\" != \"ramfs\" ]] ; then mkdir -p /mnt/ram ; mount -t ramfs ramfs /mnt/ram ; fi ; if [[ \"$(findmnt -S /dev/mapper/test-eph -n -o TARGET)\" != \"/mnt/test_eph\" ]] ; then if [ -f /mnt/ram/teph.key ] ; then cryptsetup status test-eph > /dev/null || cryptsetup open -q --key-file /mnt/ram/teph.key /mnt/teph.luks test-eph ; else dd if=/dev/random bs=100 of=/mnt/ram/teph.key iflag=fullblock count=1 ; if [ ! -f /mnt/teph.luks ] ; then dd if=/dev/urandom bs=1M of=/mnt/teph.luks iflag=fullblock count=2048 ; fi ; cryptsetup luksFormat -q --key-file /mnt/ram/teph.key /mnt/teph.luks ;cryptsetup open -q --key-file /mnt/ram/teph.key /mnt/teph.luks test-eph ; mkfs -t ext4 /dev/mapper/test-eph ; echo SIGNAL_setup ; fi ; mkdir -p /mnt/test_eph ; mount /dev/mapper/test-eph /mnt/test_eph ; fi ; exit 0",
  91. "pre_sinit": "set -e -o pipefail ; if [[ \"$(findmnt -T /mnt/ram -o SOURCE -n)\" != \"ramfs\" ]] ; then mkdir -p /mnt/ram ; mount -t ramfs ramfs /mnt/ram ; fi ; if [[ \"$(findmnt -S /dev/mapper/test-eph -n -o TARGET)\" != \"/mnt/test_eph\" ]] ; then if [ -f /mnt/ram/teph.key ] ; then cryptsetup status test-eph > /dev/null || cryptsetup open -q --key-file /mnt/ram/teph.key /mnt/teph.luks test-eph ; else dd if=/dev/random bs=100 of=/mnt/ram/teph.key iflag=fullblock count=1 ; if [ ! -f /mnt/teph.luks ] ; then dd if=/dev/urandom bs=1M of=/mnt/teph.luks iflag=fullblock count=2048 ; fi ; cryptsetup luksFormat -q --key-file /mnt/ram/teph.key /mnt/teph.luks ;cryptsetup open -q --key-file /mnt/ram/teph.key /mnt/teph.luks test-eph ; mkfs -t ext4 /dev/mapper/test-eph ; echo SIGNAL_setup ; fi ; mkdir -p /mnt/test_eph ; mount /dev/mapper/test-eph /mnt/test_eph ; fi ; exit 0",
  92. "post_destroy": "umount /mnt/test_eph && cryptsetup close test-eph ; set -e -o pipefail ; if [ -f /mnt/ram/teph.key ] ; then dd if=/dev/urandom bs=100 of=/mnt/ram/teph.key iflag=fullblock count=1 ; rm -f /mnt/ram/teph.key ; fi ; rm -f /mnt/teph.luks ; rmdir /mnt/test_eph",
  93. "pre_volume_create": "[[ \"$(findmnt -S /dev/mapper/test-eph -n -o TARGET)\" == \"/mnt/test_eph\" ]]",
  94. "pre_volume_import": "[[ \"$(findmnt -S /dev/mapper/test-eph -n -o TARGET)\" == \"/mnt/test_eph\" ]]",
  95. "pre_volume_import_data": "[[ \"$(findmnt -S /dev/mapper/test-eph -n -o TARGET)\" == \"/mnt/test_eph\" ]]",
  96. "post_volume_import_data_end": "[[ \"$(findmnt -S /dev/mapper/test-eph -n -o TARGET)\" == \"/mnt/test_eph\" ]]",
  97. "description": "For testing purposes only: Showcasing seemless use of encrypted disposable (upon boot) VM pools with keys held in RAM only. For personal use, a dedicated script is recommended."
  98. }
  99. }