qubes_callback.json.example 8.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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 on_[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 `on_` 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. "on_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. "on_ctor": "Command to call after object construction (default: None). Can be used to override `cmd`. Pass `-` to ignore this callback entirely even if `cmd` is specified.",
  13. "on_setup": "Called before creation of a new pool. Same as above otherwise.",
  14. "on_destroy": "Called after removal of an existing pool. Same as above otherwise.",
  15. "on_volume_create": "Called before creation of a volume for the pool. Same as above otherwise.",
  16. "on_volume_remove": "Called after removal of a volume of the pool. Same as above otherwise.",
  17. "on_volume_resize": "Called before resizing a volume of the pool. Same as above otherwise.",
  18. "on_volume_start": "Called before starting a volume of the pool. Same as above otherwise.",
  19. "on_volume_stop": "Called after stopping a volume of the pool. Same as above otherwise.",
  20. "on_volume_import": "Called before importing a volume from elsewhere. Same as above otherwise.",
  21. "on_volume_import_data": "Called before importing a volume from elsewhere. Same as above otherwise.",
  22. "on_volume_import_data_end": "Called after finishing an `import_data` action. Same as above otherwise.",
  23. "description": "Optional description for your personal reference."
  24. },
  25. "testing-fail-missing-all":
  26. {
  27. "description": "For testing purposes only."
  28. },
  29. "testing-fail-missing-bdriver-args":
  30. {
  31. "bdriver": "file",
  32. "description": "For testing purposes only."
  33. },
  34. "testing-succ-file-01":
  35. {
  36. "bdriver": "file",
  37. "bdriver_args": {
  38. "dir_path": "/mnt/test01",
  39. "revisions_to_keep": 0
  40. },
  41. "description": "For testing purposes only."
  42. },
  43. "testing-succ-file-02":
  44. {
  45. "bdriver": "file",
  46. "bdriver_args": {
  47. "dir_path": "/mnt/test02"
  48. },
  49. "cmd": "testCbLogArgs",
  50. "description": "For testing purposes only."
  51. },
  52. "testing-succ-file-03":
  53. {
  54. "bdriver": "file",
  55. "bdriver_args": {
  56. "dir_path": "/mnt/test03"
  57. },
  58. "cmd": "exit 1",
  59. "on_ctor": "testCbLogArgs on_ctor",
  60. "on_sinit": "testCbLogArgs on_sinit",
  61. "on_setup": "testCbLogArgs on_setup",
  62. "on_destroy": "-",
  63. "description": "For testing purposes only."
  64. },
  65. "testing-succ-file-luks":
  66. {
  67. "bdriver": "file",
  68. "bdriver_args": {
  69. "dir_path": "/mnt/test_luks"
  70. },
  71. "on_ctor": "logger 'testing-succ-file-luks: ctor'",
  72. "on_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",
  73. "on_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",
  74. "on_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",
  75. "on_volume_create": "[[ \"$(findmnt -S /dev/mapper/test-luks -n -o TARGET)\" == \"/mnt/test_luks\" ]]",
  76. "on_volume_import": "[[ \"$(findmnt -S /dev/mapper/test-luks -n -o TARGET)\" == \"/mnt/test_luks\" ]]",
  77. "on_volume_import_data": "[[ \"$(findmnt -S /dev/mapper/test-luks -n -o TARGET)\" == \"/mnt/test_luks\" ]]",
  78. "on_volume_import_data_end": "[[ \"$(findmnt -S /dev/mapper/test-luks -n -o TARGET)\" == \"/mnt/test_luks\" ]]",
  79. "description": "For testing purposes only: Showcasing seemless use of encrypted VM pools. For personal use, a dedicated script is recommended."
  80. },
  81. "testing-succ-file-luks-eph":
  82. {
  83. "bdriver": "file",
  84. "bdriver_args": {
  85. "dir_path": "/mnt/test_eph"
  86. },
  87. "signal_back": true,
  88. "on_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",
  89. "on_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",
  90. "on_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",
  91. "on_volume_create": "[[ \"$(findmnt -S /dev/mapper/test-eph -n -o TARGET)\" == \"/mnt/test_eph\" ]]",
  92. "on_volume_import": "[[ \"$(findmnt -S /dev/mapper/test-eph -n -o TARGET)\" == \"/mnt/test_eph\" ]]",
  93. "on_volume_import_data": "[[ \"$(findmnt -S /dev/mapper/test-eph -n -o TARGET)\" == \"/mnt/test_eph\" ]]",
  94. "on_volume_import_data_end": "[[ \"$(findmnt -S /dev/mapper/test-eph -n -o TARGET)\" == \"/mnt/test_eph\" ]]",
  95. "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."
  96. }
  97. }