Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Initial import of hg.uk.xensource.com/carbon/trunk/api.hg c/s 9691:9a…

…256016640e

 dated 'Sat Jun 06 09:11:37 2009 +0100'. Also add LICENSE and CREDITS file.

For reference here is the output of 'hg export 9691':
...
# Date 1244275897 -3600
# Node ID 9a256016640e987705abe1e85c960b0f16fb0404
# Parent  24ade2b2a4d089d1fa35980f80b9330bcc1de726
...

Signed-off-by: David Scott <dave.scott@eu.citrix.com>
  • Loading branch information...
commit f77e7288839255690826d89c1ce750f23554e45e 0 parents
Xen hg user authored
Showing with 34,891 additions and 0 deletions.
  1. +2 −0  .hg_archival.txt
  2. +170 −0 .hgignore
  3. +24 −0 CREDITS
  4. +199 −0 LICENSE
  5. +65 −0 Makefile
  6. +174 −0 OMakefile
  7. +97 −0 OMakeroot
  8. +8 −0 export.sh
  9. +102 −0 mk/Makefile
  10. +44 −0 mk/xe.spec.in
  11. +60 −0 ocaml/OMakefile
  12. +20 −0 ocaml/auth/OMakefile
  13. +5 −0 ocaml/auth/auth.ml
  14. +111 −0 ocaml/auth/auth_signature.ml
  15. +353 −0 ocaml/auth/authx.ml
  16. +165 −0 ocaml/auth/extauth.ml
  17. +794 −0 ocaml/auth/extauth_plugin_ADlikewise.ml
  18. +5 −0 ocaml/auth/pam.ml
  19. +61 −0 ocaml/auth/parse_likewise.ml
  20. +17 −0 ocaml/auth/testauth.ml
  21. +106 −0 ocaml/auth/testauthx.ml
  22. +125 −0 ocaml/auth/xa_auth.c
  23. +13 −0 ocaml/auth/xa_auth.h
  24. +74 −0 ocaml/auth/xa_auth_stubs.c
  25. +18 −0 ocaml/autogen/OMakefile
  26. +12 −0 ocaml/cdrommon/OMakefile
  27. +58 −0 ocaml/cdrommon/cdrommon.ml
  28. +2 −0  ocaml/client_records/OMakefile
  29. +359 −0 ocaml/client_records/record_util.ml
  30. +1,113 −0 ocaml/client_records/records.ml
  31. +6 −0 ocaml/console/OMakefile
  32. +66 −0 ocaml/console/client.ml
  33. +9 −0 ocaml/cvm/OMakefile
  34. +268 −0 ocaml/cvm/cvm.ml
  35. +25 −0 ocaml/cvm/hvm.config
  36. +32 −0 ocaml/cvm/vm.config
  37. +41 −0 ocaml/database/OMakefile
  38. +224 −0 ocaml/database/backend_sqlite.ml
  39. +6 −0 ocaml/database/backend_sqlite.mli
  40. +171 −0 ocaml/database/backend_xml.ml
  41. +7 −0 ocaml/database/backend_xml.mli
  42. +801 −0 ocaml/database/block_device_io.ml
  43. +4 −0 ocaml/database/block_device_io_errors.ml
  44. +138 −0 ocaml/database/db_access.ml
  45. +54 −0 ocaml/database/db_action_helper.ml
  46. +286 −0 ocaml/database/db_backend.ml
  47. +891 −0 ocaml/database/db_cache.ml
  48. +44 −0 ocaml/database/db_cache_types.ml
  49. +37 −0 ocaml/database/db_conn_store.ml
  50. +3 −0  ocaml/database/db_conn_store.mli
  51. +157 −0 ocaml/database/db_connections.ml
  52. +71 −0 ocaml/database/db_dirty.ml
  53. +4 −0 ocaml/database/db_exn.ml
  54. +90 −0 ocaml/database/db_filter.ml
  55. +18 −0 ocaml/database/db_filter_lex.mll
  56. +43 −0 ocaml/database/db_filter_parse.mly
  57. +14 −0 ocaml/database/db_filter_types.ml
  58. +66 −0 ocaml/database/db_lock.ml
  59. +114 −0 ocaml/database/db_remote_cache_access.ml
  60. +274 −0 ocaml/database/db_remote_marshall.ml
  61. +255 −0 ocaml/database/db_upgrade.ml
  62. +140 −0 ocaml/database/db_xml.ml
  63. +85 −0 ocaml/database/dbupdate.ml
  64. +51 −0 ocaml/database/eventgen.ml
  65. +69 −0 ocaml/database/generation.ml
  66. +177 −0 ocaml/database/master_connection.ml
  67. +619 −0 ocaml/database/redo_log.ml
  68. +67 −0 ocaml/database/redo_log.mli
  69. +61 −0 ocaml/database/ref_index.ml
  70. +7 −0 ocaml/database/ref_index.mli
  71. +72 −0 ocaml/database/sql_msg_example.txt
  72. +80 −0 ocaml/database/sqllex.mll
  73. +39 −0 ocaml/database/sqlparse.mly
  74. +32 −0 ocaml/database/sqlsyntax.ml
  75. +25 −0 ocaml/database/string_marshall_helper.ml
  76. +19 −0 ocaml/database/string_unmarshall_helper.ml
  77. +245 −0 ocaml/database/unit_test_marshall.ml
  78. +12 −0 ocaml/database/unit_test_sql.ml
  79. +79 −0 ocaml/database/xml_spaces.ml
  80. +22 −0 ocaml/db_process/OMakefile
  81. +182 −0 ocaml/db_process/xapi-db-process.ml
  82. +41 −0 ocaml/db_process/xapi-db-upgrade-4.2.ml
  83. +16 −0 ocaml/events/OMakefile
  84. +34 −0 ocaml/events/event_listen.ml
  85. +20 −0 ocaml/events/event_listen.py
  86. +21 −0 ocaml/fdhelper/OMakefile
  87. +46 −0 ocaml/fdhelper/closeandexec.ml
  88. +6 −0 ocaml/gpg/OMakefile
  89. +126 −0 ocaml/gpg/gpg.ml
  90. +8 −0 ocaml/gpg/gpg.mli
  91. +16 −0 ocaml/graph/OMakefile
  92. +13 −0 ocaml/graph/go
  93. +166 −0 ocaml/graph/graph.ml
  94. +9 −0 ocaml/guest/OMakefile
  95. +263 −0 ocaml/guest/agent.ml
  96. +16 −0 ocaml/guest_installer/OMakefile
  97. +63 −0 ocaml/guest_installer/distros.ml
  98. +79 −0 ocaml/guest_installer/operations.ml
  99. +5 −0 ocaml/guest_installer/util.ml
  100. +26 −0 ocaml/guest_installer/xinstall.ml
  101. +9 −0 ocaml/http/OMakefile
  102. +81 −0 ocaml/http/base64.ml
  103. +7 −0 ocaml/http/base64.mli
  104. +15 −0 ocaml/http/base64_main.ml
  105. +152 −0 ocaml/http/buf_io.ml
  106. +228 −0 ocaml/http/http.ml
  107. +77 −0 ocaml/http/http.mli
  108. +436 −0 ocaml/http/http_svr.ml
  109. +43 −0 ocaml/http/mime.ml
  110. +6 −0 ocaml/http/mime.mli
  111. +107 −0 ocaml/http/mime.types
  112. +975 −0 ocaml/idl/FriendlyErrorNames.resx
  113. +3,567 −0 ocaml/idl/FriendlyNames.resx
  114. +138 −0 ocaml/idl/OMakefile
  115. +314 −0 ocaml/idl/api_errors.ml
  116. +71 −0 ocaml/idl/api_lowlevel.ml
  117. +31 −0 ocaml/idl/api_lowlevel.mli
  118. +67 −0 ocaml/idl/api_messages.ml
  119. +63 −0 ocaml/idl/binding_sanity_checks/Makefile
  120. +46 −0 ocaml/idl/binding_sanity_checks/checkpool.py
  121. +100 −0 ocaml/idl/binding_sanity_checks/create_vm.py
  122. +20 −0 ocaml/idl/binding_sanity_checks/getpifdetails.py
  123. +184 −0 ocaml/idl/binding_sanity_checks/graphxapi.py
  124. +114 −0 ocaml/idl/binding_sanity_checks/hannesscript.py
  125. +127 −0 ocaml/idl/binding_sanity_checks/metrics.py
  126. +39 −0 ocaml/idl/binding_sanity_checks/metrics_monitor.py
  127. +55 −0 ocaml/idl/binding_sanity_checks/migratetoprimary.py
  128. +99 −0 ocaml/idl/binding_sanity_checks/nagios_plugins/check_pool.py
  129. +165 −0 ocaml/idl/binding_sanity_checks/newmetricsgraph.py
  130. +27 −0 ocaml/idl/binding_sanity_checks/poolify.py
  131. +59 −0 ocaml/idl/binding_sanity_checks/powercycle.py
  132. +60 −0 ocaml/idl/binding_sanity_checks/sanitycheck.bash
  133. +30 −0 ocaml/idl/binding_sanity_checks/sanitychecklib.py
  134. +54 −0 ocaml/idl/binding_sanity_checks/sharedstorage.py
  135. +31 −0 ocaml/idl/binding_sanity_checks/skeleton.py
  136. +62 −0 ocaml/idl/binding_sanity_checks/storagerepositories.py
  137. +241 −0 ocaml/idl/binding_sanity_checks/tutorial_examples/XenAPI.py
  138. +37 −0 ocaml/idl/binding_sanity_checks/tutorial_examples/cpu_use.py
  139. +170 −0 ocaml/idl/binding_sanity_checks/tutorial_examples/dbgraph.py
  140. +25 −0 ocaml/idl/binding_sanity_checks/tutorial_examples/helloxapi.py
  141. +97 −0 ocaml/idl/binding_sanity_checks/tutorial_examples/nagios_plugin.py
  142. +20 −0 ocaml/idl/binding_sanity_checks/tutorial_examples/nagios_snippet.py
  143. +15 −0 ocaml/idl/binding_sanity_checks/tutorial_examples/nagios_snippet2.py
  144. +25 −0 ocaml/idl/binding_sanity_checks/unpoolify.py
  145. +50 −0 ocaml/idl/binding_sanity_checks/xapigraph
  146. BIN  ocaml/idl/check.png
  147. BIN  ocaml/idl/citrix_logo_black.eps
  148. +94 −0 ocaml/idl/constants.ml
  149. +45 −0 ocaml/idl/coversheet.tex
  150. +4,876 −0 ocaml/idl/datamodel.ml
  151. +44 −0 ocaml/idl/datamodel.mli
  152. +79 −0 ocaml/idl/datamodel_main.ml
  153. +201 −0 ocaml/idl/datamodel_types.ml
  154. +468 −0 ocaml/idl/datamodel_utils.ml
  155. +51 −0 ocaml/idl/datamodel_values.ml
  156. +225 −0 ocaml/idl/dm_api.ml
  157. +35 −0 ocaml/idl/dm_api.mli
  158. +298 −0 ocaml/idl/dot_backend.ml
  159. +171 −0 ocaml/idl/dtd_backend.ml
  160. +9 −0 ocaml/idl/errors.sh
  161. +19 −0 ocaml/idl/examples/vdi.xml
  162. +23 −0 ocaml/idl/examples/vif.xml
  163. +79 −0 ocaml/idl/examples/vm.xml
  164. +488 −0 ocaml/idl/fdl.tex
  165. +60 −0 ocaml/idl/friendly_error_names.ml
  166. +102 −0 ocaml/idl/friendly_names.ml
  167. +99 −0 ocaml/idl/html/api.css
  168. +39 −0 ocaml/idl/html/apitreeview.css
  169. +11 −0 ocaml/idl/html/apitreeview.js
  170. +12 −0 ocaml/idl/html/browser.html
  171. +17 −0 ocaml/idl/html/header.html
  172. BIN  ocaml/idl/html/images/background_image.jpg
  173. +19 −0 ocaml/idl/html/overlay/API/Classes/VM/Fields/VCPUs_params.html
  174. +26 −0 ocaml/idl/html/overlay/API/conventions
  175. +169 −0 ocaml/idl/html_autogen.ml
  176. +224 −0 ocaml/idl/html_backend.ml
  177. +157 −0 ocaml/idl/html_build.ml
  178. +182 −0 ocaml/idl/html_common.ml
  179. +22 −0 ocaml/idl/html_imagemap.ml
  180. +27 −0 ocaml/idl/html_main.ml
  181. +21 −0 ocaml/idl/html_types.ml
  182. +28 −0 ocaml/idl/js_backend/OMakefile
  183. +48 −0 ocaml/idl/js_backend/main.ml
  184. +560 −0 ocaml/idl/latex_backend.ml
  185. +28 −0 ocaml/idl/lua/OMakefile
  186. +20 −0 ocaml/idl/lua/main.ml
  187. +38 −0 ocaml/idl/make-gnu-fdl-release.sh
  188. +138 −0 ocaml/idl/ocaml_backend/OMakefile
  189. +38 −0 ocaml/idl/ocaml_backend/README
  190. +162 −0 ocaml/idl/ocaml_backend/context.ml
  191. +89 −0 ocaml/idl/ocaml_backend/context.mli
  192. +58 −0 ocaml/idl/ocaml_backend/event_helper.ml
  193. +56 −0 ocaml/idl/ocaml_backend/event_types.ml
  194. +57 −0 ocaml/idl/ocaml_backend/exnHelper.ml
  195. +181 −0 ocaml/idl/ocaml_backend/genOCaml.ml
  196. +104 −0 ocaml/idl/ocaml_backend/gen_api.ml
  197. +79 −0 ocaml/idl/ocaml_backend/gen_api_main.ml
  198. +196 −0 ocaml/idl/ocaml_backend/gen_client.ml
  199. +13 −0 ocaml/idl/ocaml_backend/gen_common.ml
  200. +481 −0 ocaml/idl/ocaml_backend/gen_db_actions.ml
  201. +122 −0 ocaml/idl/ocaml_backend/gen_db_check.ml
  202. +98 −0 ocaml/idl/ocaml_backend/gen_empty_custom.ml
  203. +299 −0 ocaml/idl/ocaml_backend/gen_server.ml
  204. +32 −0 ocaml/idl/ocaml_backend/htmldoc.ml
  205. +44 −0 ocaml/idl/ocaml_backend/json.ml
  206. +88 −0 ocaml/idl/ocaml_backend/locking_helpers.ml
  207. +15 −0 ocaml/idl/ocaml_backend/locking_helpers.mli
  208. +67 −0 ocaml/idl/ocaml_backend/logdodgyexceptionspatch
  209. +127 −0 ocaml/idl/ocaml_backend/ocaml_syntax.ml
  210. +82 −0 ocaml/idl/ocaml_backend/ocaml_utils.ml
  211. +10 −0 ocaml/idl/ocaml_backend/python/list_vms.py
  212. +6 −0 ocaml/idl/ocaml_backend/python/pause_vm.py
  213. +44 −0 ocaml/idl/ocaml_backend/python/test_client.py
  214. +6 −0 ocaml/idl/ocaml_backend/python/unpause_vm.py
  215. +58 −0 ocaml/idl/ocaml_backend/ref.ml
  216. +14 −0 ocaml/idl/ocaml_backend/ref.mli
  217. +161 −0 ocaml/idl/ocaml_backend/server_helpers.ml
  218. +49 −0 ocaml/idl/ocaml_backend/session_check.ml
  219. +176 −0 ocaml/idl/ocaml_backend/taskHelper.ml
  220. +20 −0 ocaml/idl/ocaml_backend/taskHelper.mli
  221. +301 −0 ocaml/idl/ocaml_backend/xMLRPC.ml
  222. +131 −0 ocaml/idl/ocaml_backend/xMLRPC.mli
  223. +410 −0 ocaml/idl/ocaml_backend/xmlrpcclient.ml
  224. +52 −0 ocaml/idl/ocaml_backend/xmlrpcclient.mli
  225. +219 −0 ocaml/idl/perl_backend.ml
  226. +141 −0 ocaml/idl/presentation.tex
  227. +65 −0 ocaml/idl/python_backend/xapi.py
  228. +110 −0 ocaml/idl/sdk-README.html
  229. +29 −0 ocaml/idl/sdk-classes.dot
  230. +137 −0 ocaml/idl/sdk-faq.html
  231. +38 −0 ocaml/idl/sdk-index.html
  232. +45 −0 ocaml/idl/sdkwww-index.html
  233. +11 −0 ocaml/idl/sql_backend/OMakefile
  234. +50 −0 ocaml/idl/sql_backend/gen_schema.ml
  235. +3 −0  ocaml/idl/sql_backend/gen_schema_main.ml
  236. +77 −0 ocaml/idl/sql_backend/locking.ml
  237. +668 −0 ocaml/idl/testinclude.tex
  238. +99 −0 ocaml/idl/userguide.css
  239. +35 −0 ocaml/idl/vm-lifecycle.tex
  240. +15 −0 ocaml/idl/vm_lifecycle.dot
Sorry, we could not display the entire diff because too many files (882) changed.
2  .hg_archival.txt
@@ -0,0 +1,2 @@
+repo: 9537d35d664a63ea7cc0dd1909d3064dd506b0d3
+node: 9a256016640e987705abe1e85c960b0f16fb0404
170 .hgignore
@@ -0,0 +1,170 @@
+syntax: glob
+.pc
+*~
+*\#*
+*.orig
+*.rej
+*.a
+*.annot
+*.aux
+*.cma
+*.cmi
+*.cmo
+*.cmx
+*.cmxa
+*.d
+*.dvi
+*.flc
+*.log
+*.o
+*.omc
+*.opic
+*.opt
+*.run
+*.pyc
+*.omakedb
+*.omakedb.lock
+*.db
+*.exe
+*.exe.mdb
+.*.swp
+*.dat
+*.gp
+TAGS
+dist
+mk/.*
+ocaml/idl/vm_lifecycle.eps
+ocaml/idl/xen*-datamodel-graph.gif
+ocaml/idl/xen*-datamodel-graph.map
+ocaml/idl/xen*-datamodel.tex
+ocaml/idl/xen*api.ps
+ocaml/idl/xen*api.pdf
+ocaml/stdlib2/t*.ml
+ocaml/auth/testauthx
+ocaml/xapi/at_least_once_more
+js/devweb/api.js
+ocaml/util/pciutil
+ocaml/autogen/*.*
+ocaml/autogen/doc
+ocaml/idl/c_backend/autogen/*
+ocaml/idl/c_backend/autogen-ent/*
+ocaml/idl/c_backend/libxen/*
+ocaml/idl/c_backend/libxenenterprise/*
+ocaml/idl/c_backend/test_bindings_enterprise
+ocaml/idl/c_backend/libxenenterprise.so*
+ocaml/idl/c_backend/gen_c_binding
+ocaml/idl/csharp_backend/gen_csharp_binding
+ocaml/idl/java_binding/main
+ocaml/lvhdrt/lvhdrt
+ocaml/multipathrt/multipathrt
+ocaml/perftest/histogram
+ocaml/perftest/cumulative_time
+ocaml/xenops/memory_summary
+ocaml/xenops/squeeze_test
+ocaml/idl/java_binding/obj/*
+ocaml/idl/binding_sanity_checks/*.class
+ocaml/idl/binding_sanity_checks/doc
+ocaml/idl/binding_sanity_checks/binding
+ocaml/idl/binding_sanity_checks/*.svg
+ocaml/idl/binding_sanity_checks/*.png
+ocaml/idl/binding_sanity_checks/sanitycheckmetrics
+ocaml/idl/xenenterpriseapi.toc
+ocaml/toplevel/xencaml
+ocaml/cli/cli_lex.ml
+ocaml/database/sqllex.ml
+ocaml/database/sqlparse.mli
+ocaml/database/sqlparse.ml
+ocaml/sexpr/sExprLexer.ml
+ocaml/sexpr/sExprParser.ml
+ocaml/sexpr/sExprParser.mli
+ocaml/idl/csharp_backend/autogen
+ocaml/idl/csharp_backend/autogen-gui
+ocaml/idl/csharp_backend/autogen-enterprise
+ocaml/idl/csharp_backend/*.dll
+ocaml/idl/csharp_backend/test.exe
+ocaml/templates/templateLexer.ml
+ocaml/templates/templateParser.ml
+ocaml/templates/templateParser.mli
+ocaml/util/version.ml
+
+stunnel-4.15/Makefile
+stunnel-4.15/config.status
+stunnel-4.15/doc/Makefile
+stunnel-4.15/libtool
+stunnel-4.15/src/.deps/*.Po
+stunnel-4.15/src/.deps/*.Plo
+stunnel-4.15/src/.libs/*
+stunnel-4.15/src/Makefile
+stunnel-4.15/src/env.lo
+stunnel-4.15/src/libstunnel.la
+stunnel-4.15/src/stunnel
+stunnel-4.15/src/stunnel3
+stunnel-4.15/tools/Makefile
+stunnel-4.15/tools/stunnel.conf-sample
+stunnel-4.15/tools/stunnel.init
+zurich/java/com/xensource/autogen/*.java
+js/api.js
+ocaml/cdrommon/cdrommon
+ocaml/console/console
+ocaml/database/db_filter_lex.ml
+ocaml/database/db_filter_parse.ml
+ocaml/database/db_filter_parse.mli
+ocaml/database/dbupdate
+ocaml/database/unit_test_marshall
+ocaml/database/block_device_io
+ocaml/db_process/xapi-db-process
+ocaml/db_process/xapi-db-upgrade-4.2
+ocaml/events/event_listen
+ocaml/fdhelper/closeandexec
+ocaml/fdhelper/closeandexec_static
+ocaml/graph/graph
+ocaml/guest/agent
+ocaml/idl/datamodel
+ocaml/idl/html_build
+ocaml/idl/js_backend/api.js
+ocaml/idl/js_backend/main
+ocaml/idl/ocaml_backend/gen_api_main
+ocaml/mpathalert/mpathalert
+ocaml/muxdemux/tar
+ocaml/netdev/brctl
+ocaml/p2v/p2v
+ocaml/perftest/perftest
+ocaml/rfb/rfb_randomtest
+ocaml/util/file_access_test
+ocaml/util/unix-domain-wrapper
+ocaml/util/xmlpp
+ocaml/vncproxy/vncproxy
+ocaml/xapi/binpack
+ocaml/xapi/database_store
+ocaml/xapi/fakeguestagent
+ocaml/xapi/quicktest_encodings_module.ml
+ocaml/xapi/quicktestbin
+ocaml/xapi/stresstest
+ocaml/xapi/xapi
+ocaml/xe-cli/rt/geneva/cli_test
+ocaml/xe-cli/rt/geneva/sm_stress
+ocaml/xe-cli/rt/gtclient
+ocaml/xe-cli/rt/gtserver_linux
+ocaml/xe-cli/rt/test_host
+ocaml/xe-cli/rt/xgetip
+ocaml/xe-cli/xe
+ocaml/xenguest/dumpcore
+ocaml/xenguest/xenguest
+ocaml/xenops-ts/runtest
+ocaml/xenops/dbgring
+ocaml/xenops/fence
+ocaml/xenops/list_domains
+ocaml/xenops/watch_test
+ocaml/xenops/xal
+ocaml/xenops/xenops
+ocaml/xenops/xenvm
+ocaml/xenops/xenvm-cmd
+ocaml/xenops/xs
+ocaml/xenstored/xenstored
+ocaml/xiu/xiu
+ocaml/xsh/xsh
+ocaml/xsrpc/xsrpc
+ocaml/xsrpc/xsrpcd-util
+ocaml/xstest/xsbench
+ocaml/xstest/xstest
+ocaml/xstest/xscheckperms
24 CREDITS
@@ -0,0 +1,24 @@
+This is a partial list of people who have contributed code to this repository,
+sorted alphabetically.
+
+Andrew Peace
+Anil Madhavapeddy
+David Scott
+Ewan Mellor
+Henry Hughes
+Hugh Warrington
+Ian Campbell
+Jon Harrop
+Jonathan Davies
+Jonathan Knowles
+Jonathan Ludlam
+Magnus Therning
+Marcus Granado
+Richard Sharp
+Rob Hoes
+Stephen Rice
+Stephen Turner
+Thomas Gazagnaire
+Tim Deegan
+Tom Wilkie
+Vincent Hanquez
199 LICENSE
@@ -0,0 +1,199 @@
+This repository is distributed under the terms of the GNU Lesser General
+Public License version 2.1 (included below).
+
+As a special exception to the GNU Lesser General Public License, you
+may link, statically or dynamically, a "work that uses the Library"
+with a publicly distributed version of the Library to produce an
+executable file containing portions of the Library, and distribute
+that executable file under terms of your choice, without any of the
+additional requirements listed in clause 6 of the GNU Lesser General
+Public License. By "a publicly distributed version of the Library",
+we mean either the unmodified Library as distributed, or a
+modified version of the Library that is distributed under the
+conditions defined in clause 3 of the GNU Library General Public
+License. This exception does not however invalidate any other reasons
+why the executable file might be covered by the GNU Lesser General
+Public License.
+
+------------
+
+GNU LESSER GENERAL PUBLIC LICENSE
+Version 2.1, February 1999
+
+
+Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+Everyone is permitted to copy and distribute verbatim copies
+of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL. It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+Preamble
+The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users.
+
+This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below.
+
+When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things.
+
+To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it.
+
+For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights.
+
+We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library.
+
+To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others.
+
+Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license.
+
+Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs.
+
+When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library.
+
+We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances.
+
+For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License.
+
+In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system.
+
+Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library.
+
+The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run.
+
+
+TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you".
+
+A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables.
+
+The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".)
+
+"Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library.
+
+Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does.
+
+1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library.
+
+You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee.
+
+2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions:
+
+
+a) The modified work must itself be a software library.
+b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change.
+c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License.
+d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful.
+(For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License.
+
+3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices.
+
+Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy.
+
+This option is useful when you wish to copy part of the code of the Library into a program that is not a library.
+
+4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange.
+
+If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code.
+
+5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License.
+
+However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables.
+
+When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law.
+
+If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.)
+
+Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself.
+
+6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications.
+
+You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things:
+
+
+a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.)
+b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with.
+c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution.
+d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place.
+e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy.
+For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable.
+
+It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute.
+
+7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things:
+
+
+a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above.
+b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work.
+8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.
+
+9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it.
+
+10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License.
+
+11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice.
+
+This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.
+
+12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License.
+
+13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation.
+
+14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally.
+
+NO WARRANTY
+
+15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+
+END OF TERMS AND CONDITIONS
+How to Apply These Terms to Your New Libraries
+If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License).
+
+To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found.
+
+
+one line to give the library's name and an idea of what it does.
+Copyright (C) year name of author
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names:
+
+
+Yoyodyne, Inc., hereby disclaims all copyright interest in
+the library `Frob' (a library for tweaking knobs) written
+by James Random Hacker.
+
+signature of Ty Coon, 1 April 1990
+Ty Coon, President of Vice
+
+That's all there is to it!
65 Makefile
@@ -0,0 +1,65 @@
+# Set this to some other value on systems with no Xen libs to
+# build only the client stuff and the fakeserver.
+COMPILE_XENSTUFF ?= yes
+export COMPILE_XENSTUFF
+
+PRODUCT_VERSION?=unknown
+PRODUCT_BRAND?=Miamidev
+BUILD_NUMBER?=6666
+COMPILE_NATIVE?=yes
+export PRODUCT_VERSION PRODUCT_BRAND BUILD_NUMBER
+
+.PHONY: all
+all:
+ omake ocaml/util/version.ml
+ omake phase1 phase2
+ omake phase3
+
+.PHONY: phase3
+phase3:
+ omake phase3
+
+.PHONY: api
+api: all
+ @ :
+
+.PHONY: xapimon
+xapimon:
+ omake ocaml/xapimon/xapimon
+
+.PHONY: stresstest
+stresstest:
+ omake ocaml/xapi/stresstest
+
+.PHONY: cvm
+cvm:
+ omake ocaml/cvm/cvm
+
+.PHONY: install
+install:
+ omake install
+
+.PHONY: sdk-install
+sdk-install:
+ omake sdk-install
+
+.PHONY:patch
+patch:
+ omake patch
+
+.PHONY: clean
+clean:
+ omake clean
+ rm -rf dist/staging
+ rm -f .omakedb .omakedb.lock
+
+.PHONY: otags
+otags:
+ otags -vi -r . -o tags
+
+.PHONY: doc
+# For the doc target, we need to have phase2 done in case autogenerated .ml files are required
+doc:
+ omake ocaml/util/version.ml
+ omake phase1 phase2
+ omake doc
174 OMakefile
@@ -0,0 +1,174 @@
+IPROG=install -m 755 -o root -g root
+IDATA=install -m 644 -o root -g root
+
+XEN_COMPILE_ARCH = $(shell uname -m | sed -e"s/i.86/x86_32/g")
+
+if $(equal $(XEN_COMPILE_ARCH), x86_32)
+ LIBDIR = lib
+ export
+else
+ LIBDIR = lib64
+ export
+
+# Default to bytecode unless COMPILE_NATIVE is defined
+if $(not $(defined-env COMPILE_NATIVE))
+ COMPILE_NATIVE = yes
+ export
+BYTE_ENABLED = false
+NATIVE_ENABLED = $(if $(equal $(COMPILE_NATIVE), yes), true, false)
+
+if $(not $(defined-env CARBON_DISTFILES))
+ CARBON_DISTFILES = /usr/groups/linux/distfiles
+ export
+
+USE_OCAMLFIND = true
+
+OCAMLFLAGS = -g -dtypes -thread -warn-error F
+OCAMLPACKS = threads bigarray
+
+# c compiling stuff
+OCAMLCFLAGS += -g
+OCAMLOPTFLAGS = -ccopt -fPIC
+CFLAGS+=-g -O2
+if $(defined-env COMPILE_NATIVE)
+ CFLAGS+=-DCOMPILE_NATIVE
+ export
+
+LDFLAGS+=-static
+
+if $(not $(defined-env XEN_ROOT))
+ XEN_ROOT =
+ export
+
+XEN_CFLAGS=-I$(XEN_ROOT)/usr/include
+XEN_OCAML_LINK_FLAGS=-cclib -L$(XEN_ROOT)/usr/$(LIBDIR)
+XEN_OCAML_CLIBS=
+
+# For the Zurich chroot environment
+CFLAGS+=-I$(shell ocamlc -where)
+
+DIST=$(ROOT)/dist
+SDK=$(ROOT)/dist/staging/SDK
+SDKWWW=$(ROOT)/dist/staging/SDKwww
+DEBUGDIST=$(DIST)/staging/opt/xensource/debug
+LIBEXEC=$(DIST)/staging/opt/xensource/libexec
+
+CLEAN_OBJS = *.cmi *.cmo *.cmx *.cma *.cmxa *.annot *.run *.opt *.o *.a
+export CLEAN_OBJS
+
+.PHONY: clean
+clean:
+ rm -rf doc/
+
+.SUBDIRS: ocaml scripts
+
+
+if $(not $(defined-env COMPILE_OCAML))
+ COMPILE_OCAML = yes
+ export
+if $(not $(defined-env COMPILE_JS))
+ COMPILE_JS = yes
+ export
+
+# inherits COMPILE_XENSTUFF from the Makefile (NB don't set it here or else
+# you can't build the fakeserver etc on a machine without Xen, e.g. an Apple)
+if $(not $(defined-env COMPILE_XENSTUFF))
+ COMPILE_XENSTUFF = no
+ export
+
+.PHONY: none
+
+# Ocaml #############################################################################
+OCAML_PHASE1= copy_quicktest_modules
+OCAML_PHASE2= autogen_idl
+
+# JS ################################################################################
+JS_PHASE1=
+JS_PHASE2=js_binding
+JS_PHASE3=
+
+JS_PHASE1_TARGETS = $(if $(equal $(COMPILE_JS), yes), $(JS_PHASE1), none)
+JS_PHASE2_TARGETS = $(if $(equal $(COMPILE_JS), yes), $(JS_PHASE2), none)
+JS_PHASE3_TARGETS = $(if $(equal $(COMPILE_JS), yes), $(JS_PHASE3), none)
+
+# Phase 3 targets divided into two depending on whether we're building the Xen stuff or not:
+OCAML_PHASE3_XEN = \
+ ocaml/xapi/xapi \
+ ocaml/xenstored/xenstored \
+ ocaml/xstest/xstest \
+ ocaml/xstest/xsbench \
+ ocaml/xstest/xscheckperms \
+ allxenops \
+ ocaml/xenops-ts/runtest \
+ ocaml/xenguest/xenguest \
+ ocaml/xenguest/dumpcore \
+ ocaml/xapi/fakeguestagent \
+ ocaml/xsrpc/xsrpc \
+ ocaml/xsrpc/xsrpcd-util \
+ ocaml/guest/agent \
+ ocaml/netdev/brctl \
+ ocaml/p2v/p2v
+
+OCAML_PHASE3_NOXEN = \
+ ocaml/auth/testauthx \
+ ocaml/xe-cli/xe \
+ ocaml/xsh/xsh \
+ ocaml/xe-cli/rt/test_host \
+ ocaml/xe-cli/rt/gtclient \
+ ocaml/xe-cli/rt/gtserver_linux \
+ ocaml/xe-cli/rt/xgetip \
+ ocaml/xe-cli/rt/geneva/cli_test \
+ ocaml/xe-cli/rt/geneva/sm_stress \
+ ocaml/util/unix-domain-wrapper \
+ ocaml/util/xmlpp \
+ ocaml/util/file_access_test \
+ ocaml/events/event_listen \
+ ocaml/muxdemux/tar \
+ ocaml/console/console \
+ ocaml/graph/graph \
+ ocaml/rfb/rfb_randomtest \
+ ocaml/database/unit_test_marshall \
+ ocaml/database/dbupdate \
+ ocaml/database/block_device_io \
+ ocaml/fdhelper/closeandexec \
+ ocaml/fdhelper/closeandexec_static \
+ ocaml/toplevel \
+ ocaml/xiu/xiu \
+ ocaml/cdrommon/cdrommon \
+ ocaml/xapi/stresstest \
+ ocaml/xapi/fakeguestagent \
+ ocaml/xapi/quicktestbin \
+ ocaml/xapi/binpack \
+ ocaml/idl/datamodel \
+ ocaml/idl/html_build \
+ ocaml/db_process/xapi-db-process \
+ ocaml/vncproxy/vncproxy \
+ ocaml/perftest/perftest \
+ ocaml/perftest/histogram \
+ ocaml/perftest/cumulative_time \
+ ocaml/lvhdrt/lvhdrt \
+ ocaml/mpathalert/mpathalert \
+ ocaml/multipathrt/multipathrt
+
+
+OCAML_PHASE3 = $(if $(equal $(COMPILE_XENSTUFF), yes), $(OCAML_PHASE3_XEN) $(OCAML_PHASE3_NOXEN), $(OCAML_PHASE3_NOXEN))
+
+OCAML_PHASE1_TARGETS = $(if $(equal $(COMPILE_OCAML), yes), $(OCAML_PHASE1), none)
+OCAML_PHASE2_TARGETS = $(if $(equal $(COMPILE_OCAML), yes), $(OCAML_PHASE2), none)
+OCAML_PHASE3_TARGETS = $(if $(equal $(COMPILE_OCAML), yes), $(OCAML_PHASE3), none)
+
+#####################################################################################
+
+# phase1: build stdlib2
+.PHONY: phase1
+phase1: $(OCAML_PHASE1_TARGETS) $(JS_PHASE1_TARGETS)
+ mkdir -p $(DIST) $(DIST)/bin
+
+# phase2: build compilers and make autogenerated files
+.PHONY: phase2
+phase2: $(OCAML_PHASE2_TARGETS) $(JS_PHASE2_TARGETS)
+
+# phase3: use autogenerated files to make apps
+.PHONY: phase3
+phase3: $(OCAML_PHASE3_TARGETS) $(JS_PHASE3_TARGETS)
+
97 OMakeroot
@@ -0,0 +1,97 @@
+########################################################################
+# Permission is hereby granted, free of charge, to any person
+# obtaining a copy of this file, to deal in the File without
+# restriction, including without limitation the rights to use,
+# copy, modify, merge, publish, distribute, sublicense, and/or
+# sell copies of the File, and to permit persons to whom the
+# File is furnished to do so, subject to the following condition:
+#
+# THE FILE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE FILE OR
+# THE USE OR OTHER DEALINGS IN THE FILE.
+
+########################################################################
+# The standard OMakeroot file.
+# You will not normally need to modify this file.
+# By default, your changes should be placed in the
+# OMakefile in this directory.
+#
+# If you decide to modify this file, note that it uses exactly
+# the same syntax as the OMakefile.
+#
+
+#
+# Include the standard installed configuration files.
+# Any of these can be deleted if you are not using them,
+# but you probably want to keep the Common file.
+#
+open build/C
+open build/OCaml
+open build/LaTeX
+
+# Other C libraries - used when making .cma or .cmxa libraries.
+# Should be of the form '-cclib -lpam' or such like
+OTHER_CLIBS=
+
+#
+# The command-line variables are defined *after* the
+# standard configuration has been loaded.
+#
+DefineCommandVars()
+
+OCamlLibraryClib(name, files, clibs) =
+ name = $(file $(name))
+
+ OFILES = $(addsuffix $(EXT_OBJ), $(files))
+ CMOFILES = $(addsuffix .cmo, $(files))
+ CMXFILES = $(addsuffix .cmx, $(files))
+
+ CLIB = $(file $(name)$(EXT_LIB))
+ BYTELIB = $(file $(name).cma)
+ NATIVELIB = $(file $(name).cmxa)
+
+ __BYTE_CLIBS = $(addsuffix $(EXT_LIB), $(clibs))
+ __NATIVE_CLIBS = $(addsuffix $(EXT_LIB), $(clibs))
+ _BYTE_CLIBS = $(addprefix $(absname $(CWD))/, $(__BYTE_CLIBS))
+ _NATIVE_CLIBS = $(addprefix $(absname $(CWD))/, $(__NATIVE_CLIBS))
+ BYTE_CLIBS = $(mapprefix -cclib, $(_BYTE_CLIBS))
+ NATIVE_CLIBS = $(mapprefix -cclib, $(_NATIVE_CLIBS))
+
+ #
+ # Link commands
+ #
+ $(BYTELIB): $(CMOFILES) $(_BYTE_CLIBS)
+ $(OCAMLFIND) $(OCAMLLINK) $(LAZY_OCAMLFINDFLAGS) $(OCAMLFLAGS) $(OCAMLCFLAGS) \
+ $(OCAML_LIB_FLAGS) -a -o $@ $(OCamlLinkSort $(CMOFILES)) -custom $(BYTE_CLIBS) $(OCAML_LINK_FLAGS) $(OTHER_CLIBS)
+
+ $(NATIVELIB) $(CLIB): $(CMXFILES) $(OFILES) $(_NATIVE_CLIBS)
+ $(OCAMLFIND) $(OCAMLOPTLINK) $(LAZY_OCAMLFINDFLAGS) $(OCAMLFLAGS) $(OCAMLOPTFLAGS) \
+ $(OCAML_LIB_FLAGS) -a -o $(NATIVELIB) $(OCamlLinkSort $(CMXFILES)) $(NATIVE_CLIBS) $(OTHER_CLIBS)
+
+ return $(array $(if $(NATIVE_ENABLED), $(NATIVELIB)), $(if $(NATIVE_ENABLED), $(CLIB)), $(if $(BYTE_ENABLED), $(BYTELIB)))
+
+#
+# The documentation generator
+#
+OCAMLDOC = ocamldoc
+
+#
+# Generation of documentation from .ml or .mli files
+#
+OCamlDoc(dir, filenames) =
+ private.MODULES = $(removesuffix $(filenames))
+ private.CMIFILES = $(addsuffix .cmi, $(MODULES))
+
+ .PHONY: doc
+ doc: $(CMIFILES)
+ mkdir -p $(dir)
+ $(OCAMLFIND) $(OCAMLDOC) $(LAZY_OCAMLFINDFLAGS) $(PREFIXED_OCAMLPACKS) $(PREFIXED_OCAMLINCLUDES) -I +threads -html -d $(dir) -sort $(filenames)
+
+#
+# Include the OMakefile in this directory.
+#
+.SUBDIRS: .
8 export.sh
@@ -0,0 +1,8 @@
+# run . ./export.sh to export variables to environment in chroot to be able
+# to use omake directly
+export COMPILE_XENSTUFF=yes
+export PRODUCT_VERSION=unknown
+export PRODUCT_BRAND=Rio
+export BUILD_NUMBER=6666
+export COMPILE_NATIVE=yes
+
102 mk/Makefile
@@ -0,0 +1,102 @@
+# makefile for api component in build system
+USE_BRANDING := yes
+USE_BUILD_NUMBER := yes
+IMPORT_BRANDING := yes
+include $(B_BASE)/common.mk
+include $(B_BASE)/rpmbuild.mk
+
+OUTPUT_PKG := $(MY_MAIN_PACKAGES)/xapi.tar.bz2
+OUTPUT_XAPI := $(MY_OUTPUT_DIR)/xapi
+OUTPUT_CLI := $(MY_OUTPUT_DIR)/xe
+OUTPUT_CLI_RT := $(MY_OUTPUT_DIR)/cli-regress.tar.gz
+OUTPUT_CLI_RT_GENEVA := $(MY_OUTPUT_DIR)/cli-regress-geneva.tar.gz
+OUTPUT_XENOPS_RT := $(MY_OUTPUT_DIR)/xenops-regress.tar.gz
+OUTPUT_FAKESERVER := $(MY_OUTPUT_DIR)/fakeserver.tar.bz2
+OUTPUT_DOCS := $(MY_OUTPUT_DIR)/sdkiso
+OUTPUT_WEBZIP := $(MY_OUTPUT_DIR)/sdk-html.zip
+OUTPUT_XENGUEST_SRC := $(MY_OUTPUT_DIR)/xenguest-src.tar.bz2
+OUTPUT_PATCH := $(MY_OUTPUT_DIR)/testpatch.asc
+OUTPUT_DATAMODEL_DIR := $(MY_OUTPUT_DIR)/datamodel
+
+CLI_RPM_SOURCES :=
+CLI_RPM_SOURCES += $(RPM_SOURCESDIR)/xe
+CLI_RPM_SOURCES += $(RPM_SOURCESDIR)/bash-completion
+
+JQUERY_PACK_DIST=$(CARBON_DISTFILES)/javascript/jquery/jquery-1.1.3.1.pack.js
+JQUERY_TV_DIST=$(CARBON_DISTFILES)/javascript/jquery/treeview/jquery.treeview.zip
+
+export BUILD_NUMBER
+export PRODUCT_BRAND
+export PRODUCT_VERSION
+
+REPO=$(call hg_loc,api)
+
+.PHONY: build
+build: $(OUTPUT_PKG) $(MY_OBJ_DIR)/.rpmbuild.cli.stamp $(MY_SOURCES)/MANIFEST
+ $(call mkdir_clean,$(MY_LINUX_CDFILES)/client_install)
+ install -m 755 -o root -g root $(RPM_RPMSDIR)/i386/xe-cli-*.rpm $(MY_LINUX_CDFILES)/client_install/
+
+$(MY_SOURCES)/MANIFEST: $(MY_SOURCES_DIRSTAMP) $(OUTPUT_XENGUEST_SRC)
+ echo api gpl file $(OUTPUT_XENGUEST_SRC) > $@
+ echo api gpl file $(JQUERY_PACK_DIST) >> $@
+ echo api gpl file $(JQUERY_TV_DIST) >> $@
+
+$(OUTPUT_PKG) $(OUTPUT_FAKESERVER) $(OUTPUT_XAPI) $(OUTPUT_CLI) \
+ $(OUTPUT_XENOPS_RT) $(OUTPUT_XENGUEST_SRC): $(call hg_req,api) $(MY_MAIN_PACKAGES)/.dirstamp
+ rm -rf $(REPO)/dist
+ $(MAKE) clean
+ $(MAKE) -C $(REPO)
+ $(call mkdir_clean,$(MY_OBJ_DIR)/xenops-rt)
+ install -m 755 -o root -g root $(REPO)/ocaml/xenops/xenvm $(MY_OBJ_DIR)/xenops-rt/xenvm
+ install -m 755 -o root -g root $(REPO)/ocaml/xenops-ts/runtest $(MY_OBJ_DIR)/xenops-rt/runtest
+ install -m 755 -o root -g root $(REPO)/ocaml/p2v/p2v $(MY_OUTPUT_DIR)/p2v-server
+ install -m 755 -o root -g root $(REPO)/ocaml/fdhelper/closeandexec_static $(MY_OUTPUT_DIR)/closeandexec_static
+ tar -C $(MY_OBJ_DIR)/xenops-rt -zcf $(OUTPUT_XENOPS_RT) .
+ $(MAKE) -C $(REPO) install
+ mkdir -p $(REPO)/dist/staging/var/xapi
+ mkdir -p $(REPO)/dist/staging/var/log/xen
+ mkdir -p $(REPO)/dist/staging/var/opt/xen/iso_import
+ cp $(REPO)/dist/staging/opt/xensource/bin/xapi $(OUTPUT_XAPI)
+ tar -C $(REPO)/dist/staging -jcf $(OUTPUT_PKG) .
+ tar -C $(REPO)/dist -jcf $(OUTPUT_XENGUEST_SRC) xenguest-src
+ tar -C $(REPO)/dist/cli-rt -zcf $(OUTPUT_CLI_RT) .
+ tar -C $(REPO)/dist/cli-regress-geneva -zcf $(OUTPUT_CLI_RT_GENEVA) .
+ install -m 755 -o root -g root $(REPO)/dist/staging/opt/xensource/bin/xe $(MY_OUTPUT_DIR)/xe
+ rm -rf $(REPO)/dist
+ $(MAKE) -C $(REPO) sdk-install
+ $(call mkdir_clean,$(OUTPUT_DOCS))
+ cp $(REPO)/dist/staging/SDK/README.html $(OUTPUT_DOCS)/
+ cp -a $(REPO)/dist/staging/SDK/docs $(OUTPUT_DOCS)/
+ cd $(REPO)/dist/staging/SDKwww && zip -9rv $(OUTPUT_WEBZIP) .
+ tar -C $(REPO)/dist/staging --exclude=etc/xensource/license -jcf $(OUTPUT_FAKESERVER) .
+ install -m 644 -o root -g root $(REPO)/ocaml/xe-cli/rt/geneva/testpatch.asc $(OUTPUT_PATCH)
+ rm -rf $(OUTPUT_DATAMODEL_DIR)
+ mkdir -p $(OUTPUT_DATAMODEL_DIR)
+ install -m 644 -o root -g root $(REPO)/ocaml/idl/datamodel.a $(OUTPUT_DATAMODEL_DIR)
+ install -m 644 -o root -g root $(REPO)/ocaml/idl/datamodel.cmxa $(OUTPUT_DATAMODEL_DIR)
+ install -m 644 -o root -g root $(REPO)/ocaml/idl/datamodel.cmi $(OUTPUT_DATAMODEL_DIR)
+ install -m 644 -o root -g root $(REPO)/ocaml/idl/datamodel_types.cmi $(OUTPUT_DATAMODEL_DIR)
+ install -m 644 -o root -g root $(REPO)/ocaml/idl/datamodel_utils.cmi $(OUTPUT_DATAMODEL_DIR)
+ install -m 644 -o root -g root $(REPO)/ocaml/idl/dm_api.cmi $(OUTPUT_DATAMODEL_DIR)
+ install -m 644 -o root -g root $(REPO)/ocaml/idl/api_messages.cmi $(OUTPUT_DATAMODEL_DIR)
+
+$(RPM_SOURCESDIR)/xe: $(OUTPUT_CLI)
+ mkdir -p $(RPM_SOURCESDIR)
+ cp $< $@
+
+$(RPM_SOURCESDIR)/bash-completion: $(REPO)/ocaml/xe-cli/bash-completion
+ mkdir -p $(RPM_SOURCESDIR)
+ cp $< $@
+
+$(RPM_SPECSDIR)/xe.spec: xe.spec.in
+ mkdir -p $(RPM_SPECSDIR)
+ $(call brand,xe.spec.in) > $@
+
+$(MY_OBJ_DIR)/.rpmbuild.cli.stamp: $(RPM_DIRECTORIES) $(RPM_SPECSDIR)/xe.spec $(CLI_RPM_SOURCES)
+ $(RPMBUILD) --target i386 -ba $(RPM_SPECSDIR)/xe.spec
+ touch $@
+
+.PHONY: clean
+clean:
+ rm -f $(OUTPUT_PKG) $(OUTPUT_FAKESERVER) $(OUTPUT_CLI) $(OUTPUT_XENOPS_RT) $(OUTPUT_WEBZIP)
+ $(MAKE) -C $(REPO) clean
44 mk/xe.spec.in
@@ -0,0 +1,44 @@
+Summary: @PRODUCT_BRAND@ CLI by @COMPANY_NAME_SHORT@.
+Name: xe-cli
+Version: @PRODUCT_VERSION@
+Release: @BUILD_NUMBER@
+License: Copyright @COPYRIGHT_YEARS@ @COMPANY_NAME_LEGAL@ All Rights Reserved
+Group: System/Management
+URL: http://www.citrix.com
+Source0: xe
+Source1: bash-completion
+BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot
+Requires: stunnel >= 4.0
+Obsoletes: xenenterprise-cli
+
+# Disable build root strip policy, executables generated by ocamlc -custom
+# MUST NOT BE STRIPPED
+%define __spec_install_post /usr/lib/rpm/brp-compress
+
+%description
+@PRODUCT_BRAND@ command line interface for managing @BRAND_GUESTS@.
+
+%prep
+
+%build
+%install
+rm -rf $RPM_BUILD_ROOT
+
+mkdir -p $RPM_BUILD_ROOT/opt/xensource/bin
+cp %{SOURCE0} $RPM_BUILD_ROOT/opt/xensource/bin/xe
+
+mkdir -p $RPM_BUILD_ROOT/usr/bin
+ln -s /opt/xensource/bin/xe $RPM_BUILD_ROOT/usr/bin/xe
+
+mkdir -p $RPM_BUILD_ROOT/etc/bash_completion.d
+cp %{SOURCE1} $RPM_BUILD_ROOT/etc/bash_completion.d/%{name}
+
+%files
+%defattr(-,root,root,-)
+/opt/xensource/bin/xe
+/usr/bin/xe
+/etc/bash_completion.d/%{name}
+%doc
+
+
+%changelog
60 ocaml/OMakefile
@@ -0,0 +1,60 @@
+# You must set your XEN_ROOT env var before building
+XEN_CFLAGS += -I$(XEN_ROOT)/usr/include
+OCAMLINCLUDES += +ocamldoc $(ROOT)/ocaml/util
+
+OCAMLPACKS += stdext log
+
+OCAML_LIBS += \
+ $(ROOT)/ocaml/util/version \
+ $(ROOT)/ocaml/util/backtrace \
+ $(ROOT)/ocaml/util/debug \
+ $(ROOT)/ocaml/util/forkhelpers \
+ $(ROOT)/ocaml/util/stunnel \
+ $(ROOT)/ocaml/util/sha1sum \
+ $(ROOT)/ocaml/util/gzip \
+ $(ROOT)/ocaml/util/stats
+
+.SUBDIRS: \
+ autogen \
+ xe-cli \
+ xapimon \
+ cvm \
+ guest_installer \
+ client_records \
+ idl \
+ util \
+ xapi \
+ templates \
+ http \
+ sexpr \
+ xenguest \
+ xenops \
+ xenops-ts \
+ xsrpc \
+ muxdemux \
+ xva \
+ guest \
+ console \
+ netdev \
+ auth \
+ events \
+ in_guest_install \
+ p2v \
+ graph \
+ license \
+ rfb \
+ fdhelper \
+ database \
+ toplevel \
+ xenstored \
+ xstest \
+ xiu \
+ cdrommon \
+ gpg \
+ db_process \
+ vncproxy \
+ xsh \
+ perftest \
+ lvhdrt \
+ mpathalert \
+ multipathrt
20 ocaml/auth/OMakefile
@@ -0,0 +1,20 @@
+OTHER_CLIBS = -cclib -lpam
+OCAMLINCLUDES += ../autogen ../idl/ocaml_backend ../xapi
+
+StaticCLibrary(auth_stubs, xa_auth xa_auth_stubs)
+OCamlLibraryClib(pam, pam, auth_stubs)
+
+section
+ OCAML_LIBS += pam
+ OCAML_CLIBS += auth_stubs
+
+ OCamlProgram(testauth, testauth)
+ OCamlProgram(testauthx, testauthx authx auth_signature)
+
+.PHONY: clean
+clean:
+ rm -rf $(CLEAN_OBJS) *.aux *.log *.fig
+
+.PHONY: install
+install:
+ mkdir -p $(DIST)/staging/opt/xensource/bin
5 ocaml/auth/auth.ml
@@ -0,0 +1,5 @@
+
+external authenticate : string -> string -> unit = "stub_XA_mh_authorize"
+
+external change_password : string -> string -> unit = "stub_XA_mh_chpasswd"
+
111 ocaml/auth/auth_signature.ml
@@ -0,0 +1,111 @@
+
+(*
+ * Interface for External Authentication Plugin component
+ * v1 22Oct08
+ *
+*)
+
+exception Auth_failure of string
+exception Auth_service_error of string
+exception Subject_cannot_be_resolved
+
+type t =
+ {
+
+ (* subject_id Authenticate_username_password(string username, string password)
+
+ Takes a username and password, and tries to authenticate against an already configured
+ auth service (see XenAPI requirements Wiki page for details of how auth service configuration
+ takes place and the appropriate vlaues are stored within the XenServer Metadata).
+ If authentication is successful then a subject_id is returned representing the account
+ corresponding to the supplied credentials (where the subject_id is in a namespace managed by
+ the auth module/service itself -- e.g. maybe a SID or something in the AD case).
+ Raises auth_failure if authentication is not successful
+ *)
+ authenticate_username_password : string -> string -> string;
+
+ (* subject_id Authenticate_ticket(string ticket)
+
+ As above but uses a ticket as credentials (i.e. for single sign-on)
+ *)
+ authenticate_ticket : string -> string;
+
+ (* subject_id get_subject_identifier(string subject_name)
+
+ Takes a subject_name (as may be entered into the XenCenter UI when defining subjects --
+ see Access Control wiki page); and resolves it to a subject_id against the external
+ auth/directory service.
+ Raises Not_found if authentication is not succesful.
+ *)
+ get_subject_identifier : string -> string;
+
+ (* ((string*string) list) query_subject_information(string subject_identifier)
+
+ Takes a subject_identifier and returns the user record from the directory service as
+ key/value pairs. In the returned string*string map, there _must_ be a key called
+ subject_name that refers to the name of the account (e.g. the user or group name as may
+ be displayed in XenCenter). There is no other requirements to include fields from the user
+ record -- initially I'd imagine that we wouldn't bother adding anything else here, but
+ it's a string*string list anyway for possible future expansion.
+ Raises Not_found if subject_id cannot be resolved by external auth service
+ *)
+ query_subject_information : string -> ((string*string) list);
+
+ (* (string list) query_group_membership(string subject_identifier)
+
+ Takes a subject_identifier and returns its group membership (i.e. a list of subject
+ identifiers of the groups that the subject passed in belongs to). The set of groups returned
+ _must_ be transitively closed wrt the is_member_of relation if the external directory service
+ supports nested groups (as AD does for example)
+ *)
+ query_group_membership : string -> (string list);
+
+ (*
+ In addition, there are some event hooks that auth modules implement as follows:
+ *)
+
+ (* unit on_enable(((string*string) list) config_params)
+
+ Called internally by xapi _on each host_ when a client enables an external auth service for the
+ pool via the XenAPI [see AD integration wiki page]. The config_params here are the ones passed
+ by the client as part of the corresponding XenAPI call.
+ On receiving this hook, the auth module should:
+ (i) do whatever it needs to do (if anything) to register with the external auth/directory
+ service [using the config params supplied to get access]
+ (ii) Write the config_params that it needs to store persistently in the XenServer metadata
+ into the Pool.external_auth_configuration field. [Note - the rationale for making the plugin
+ write the config params it needs long-term into the XenServer metadata itself is so it can
+ explicitly filter any one-time credentials [like AD username/password for example] that it
+ does not need long-term.]
+ *)
+ on_enable : ((string*string) list) -> unit;
+
+ (* unit on_disable()
+
+ Called internally by xapi _on each host_ when a client disables an auth service via the XenAPI.
+ The hook will be called _before_ the Pool configuration fields relating to the external-auth
+ service are cleared (i.e. so you can access the config params you need from the pool metadata
+ within the body of the on_disable method)
+ *)
+ on_disable : ((string*string) list) -> unit;
+
+ (* unit on_xapi_initialize(bool system_boot)
+
+ Called internally by xapi whenever it starts up. The system_boot flag is true iff xapi is
+ starting for the first time after a host boot
+ *)
+ on_xapi_initialize : bool -> unit;
+
+ (* unit on_xapi_exit()
+
+ Called internally when xapi is doing a clean exit.
+ *)
+ on_xapi_exit : unit -> unit;
+
+ }
+
+(* Auth modules must implement this signature:*)
+module type AUTH_MODULE =
+sig
+ val methods : t
+end
353 ocaml/auth/authx.ml
@@ -0,0 +1,353 @@
+
+module AuthX : Auth_signature.AUTH_MODULE =
+struct
+
+(*
+ * External Authentication Plugin component
+ * using Unix PAM/NSS as a backend
+ * v1 22Oct08 marcusg@eu.citrix.com
+ *
+*)
+
+(* This implementation is supposed to only use local names in the NSS and PAM databases *)
+(* => PAM: is used for authentication *)
+(* => NSS: is used as a database for groups, list of users etc *)
+(* Both, by default, use only local information from /etc/passwd and /etc/group *)
+(* PAM can be extended to use Kerberos by using xs-documents.hg/technical/howto/howto-dom0-ad-krb5.txt *)
+(* NSS can be extended to use LDAP by using xs-documents.hg/technical/howto/howto-dom0-ad-nss-ldap.txt *)
+
+(* Verifies if a subject_name is in one of the NSS databases *)
+(* Useful databases are: *)
+(* 'passwd', for the list of users *)
+(* 'group', for the list of groups *)
+(* Returns the id corresponding to the subject_name *)
+(* Raises Not_found if subject_name not in NSS database *)
+
+(* this function should use glibc's nss/nsswitch.h/__nss_database_lookup() *)
+(* linking against /usr/lib/libnss.a (package libnss-devel-static) *)
+(* since we want a quick prototype, for now we'll call the command-line versions... *)
+let getent_idbyname nss_database subject_name =
+
+ let ic = Unix.open_process_in ("getent "^nss_database) in
+ try
+ (* getent passwd returns several lines *)
+ let rec getnextuid ic =
+ let line = input_line ic in
+ let recs = Stringext.String.split ':' line in
+ let username = List.nth recs 0 in
+ let uid = List.nth recs 2 in
+ if username = subject_name then
+ begin
+ ignore (Unix.close_process_in ic);
+ uid
+ end
+ else getnextuid ic
+ in
+ getnextuid ic
+ with e ->
+ ignore (Unix.close_process_in ic);
+ raise Not_found
+
+let getent_namebyid nss_database subject_id =
+
+ let ic = Unix.open_process_in ("getent "^nss_database) in
+ try
+ (* getent passwd returns several lines *)
+ let rec getnextuid ic =
+ let line = input_line ic in
+ let recs = Stringext.String.split ':' line in
+ let username = List.nth recs 0 in
+ let uid = List.nth recs 2 in
+ if uid = subject_id then
+ begin
+ ignore (Unix.close_process_in ic);
+ username
+ end
+ else getnextuid ic
+ in
+ getnextuid ic
+ with e ->
+ ignore (Unix.close_process_in ic);
+ raise Not_found
+
+let getent_idbyid nss_database subject_id =
+
+ let ic = Unix.open_process_in ("getent "^nss_database) in
+ try
+ (* getent passwd returns several lines *)
+ let rec getnextuid ic =
+ let line = input_line ic in
+ let recs = Stringext.String.split ':' line in
+ let uid = List.nth recs 2 in
+ if uid = subject_id then
+ begin
+ ignore (Unix.close_process_in ic);
+ uid
+ end
+ else getnextuid ic
+ in
+ getnextuid ic
+ with e ->
+ ignore (Unix.close_process_in ic);
+ raise Not_found
+
+let getent_allbyid nss_database subject_id =
+
+ let ic = Unix.open_process_in ("getent "^nss_database) in
+ try
+ (* getent passwd returns several lines *)
+ let rec getnextuid ic =
+ let line = input_line ic in
+ let recs = Stringext.String.split ':' line in
+ let uid = List.nth recs 2 in
+ if uid = subject_id then
+ begin
+ ignore (Unix.close_process_in ic);
+ recs
+ end
+ else getnextuid ic
+ in
+ getnextuid ic
+ with e ->
+ ignore (Unix.close_process_in ic);
+ raise Not_found
+
+
+(* subject_id get_subject_identifier(string subject_name)
+
+ Takes a subject_name (as may be entered into the XenCenter UI when defining subjects --
+ see Access Control wiki page); and resolves it to a subject_id against the external
+ auth/directory service.
+ Raises Not_found if authentication is not succesful.
+*)
+let get_subject_identifier subject_name =
+
+ try
+ (* looks up list of users*)
+ "u"^(getent_idbyname "passwd" subject_name)
+ with Not_found ->
+ (* looks up list of groups*)
+ "g"^(getent_idbyname "group" subject_name)
+
+
+(* subject_id Authenticate_username_password(string username, string password)
+
+ Takes a username and password, and tries to authenticate against an already configured
+ auth service (see XenAPI requirements Wiki page for details of how auth service configuration
+ takes place and the appropriate vlaues are stored within the XenServer Metadata).
+ If authentication is successful then a subject_id is returned representing the account
+ corresponding to the supplied credentials (where the subject_id is in a namespace managed by
+ the auth module/service itself -- e.g. maybe a SID or something in the AD case).
+ Raises auth_failure if authentication is not successful
+*)
+
+(* call already existing pam.ml *)
+let authenticate_username_password username password =
+
+ (* first, we try to authenticated against our user database using PAM *)
+ try
+ Pam.authenticate username password;
+
+ (* no exception raised, then authentication succeeded, *)
+ (* now we return the authenticated user's id *)
+ get_subject_identifier username
+
+ with (Failure msg) ->
+ (*debug "Failed to authenticate user %s: %s" uname msg;*)
+ raise (Auth_signature.Auth_failure msg)
+
+(* subject_id Authenticate_ticket(string ticket)
+
+ As above but uses a ticket as credentials (i.e. for single sign-on)
+*)
+ (* not implemented now, not needed for our tests, only for a *)
+ (* future single sign-on feature *)
+let authenticate_ticket tgt =
+ failwith "authx authenticate_ticket not implemented"
+
+(* ((string*string) list) query_subject_information(string subject_identifier)
+
+ Takes a subject_identifier and returns the user record from the directory service as
+ key/value pairs. In the returned string*string map, there _must_ be a key called
+ subject_name that refers to the name of the account (e.g. the user or group name as may
+ be displayed in XenCenter). There is no other requirements to include fields from the user
+ record -- initially qI'd imagine that we wouldn't bother adding anything else here, but
+ it's a string*string list anyway for possible future expansion.
+ Raises Not_found if subject_id cannot be resolved by external auth service
+*)
+let query_subject_information subject_identifier =
+
+ (* we are expecting an id such as u0, g0, u123 etc *)
+ if String.length subject_identifier < 2 then raise Not_found;
+
+ match (String.get subject_identifier 0) with
+ | 'u' -> begin
+ (* 1. first look up the list of users *)
+
+ (* here we remove the prefix u or g *)
+ let subject_identifier = String.sub subject_identifier 1 (String.length subject_identifier-1) in
+
+ let infolist = getent_allbyid "passwd" subject_identifier in
+ [ ("subject-name", List.nth infolist 0);
+ ("subject-pwd", List.nth infolist 1);
+ ("subject-id", "u"^(List.nth infolist 2));
+ ("subject-gid", "g"^(List.nth infolist 3));
+ ("subject-realname", List.nth infolist 4);
+ ("subject-homedir", List.nth infolist 5);
+ ("subject-shell", List.nth infolist 6);
+ (* comma-separated list of subjects that are contained in this subject *)
+ ("contains-byname", "") (*in this case, no element *)
+ ]
+ end
+ | 'g' -> begin
+ (* 2. only then we look up the list of groups *)
+
+ (* here we remove the prefix u or g *)
+ let subject_identifier = String.sub subject_identifier 1 (String.length subject_identifier-1) in
+
+ let infolist = getent_allbyid "group" subject_identifier in
+ [ ("subject-name", List.nth infolist 0);
+ ("subject-pwd", List.nth infolist 1);
+ ("subject-id", "g"^(List.nth infolist 2));
+ ("subject-gid", "g"^(List.nth infolist 2));
+ ("subject-realname", List.nth infolist 0);
+ ("subject-homedir", "");
+ ("subject-shell", "");
+ (* comma-separated list of subjects that are contained in this subject *)
+ ("contains-byname", List.nth infolist 3)
+ ]
+ end
+ | _ -> raise Not_found
+
+(* (string list) query_group_membership(string subject_identifier)
+
+ Takes a subject_identifier and returns its group membership (i.e. a list of subject
+ identifiers of the groups that the subject passed in belongs to). The set of groups returned
+ _must_ be transitively closed wrt the is_member_of relation if the external directory service
+ supports nested groups (as AD does for example)
+*)
+ (* this function should use glibc's nss/nsswitch.h/__nss_database_lookup() *)
+ (* linking against /usr/lib/libnss.a (package libnss-devel-static) *)
+ (* since we want a quick prototype, for now we'll call the command-line versions... *)
+
+ (* in unix, groups cannot contain groups, so we just verify the groups a user *)
+ (* belongs to and, if that fails, if some group has the required identifier *)
+let query_group_membership subject_identifier =
+
+ (* 1. first we try to see if our subject identifier is a user id...*)
+
+ (* SECURITY: subject_name/id must have double quotes stripped off or escaped, *)
+ (* we do not want any user sending arbitrary 'su' injection commands to Dom0 as root..... *)
+ let sanitized_subject_id = String.escaped subject_identifier in
+
+ (* we are expecting an id such as u0, g0, u123 etc *)
+ if String.length sanitized_subject_id < 2 then raise Not_found;
+
+ (* here we remove the prefix u or g *)
+ let sanitized_subject_id = String.sub sanitized_subject_id 1 (String.length sanitized_subject_id-1) in
+
+ match (String.get subject_identifier 0) with
+ | 'u' -> begin
+ (* looks up list of users*)
+ let subject_name = getent_namebyid "passwd" sanitized_subject_id in
+ let sanitized_subject_name = String.escaped subject_name in
+
+ (* we use a handy unix command line tool for quick prototyping *)
+ (* maybe in the future this action could be linked directly against libnss.a *)
+ let ic = Unix.open_process_in ("su \"" ^ sanitized_subject_name ^ "\" -c \"id -G\"") in
+ try
+ (* id -G always returns one line only *)
+ let gidline = input_line ic in
+ ignore (Unix.close_process_in ic);
+ let gids = Stringext.String.split ' ' gidline in
+ List.map (fun gid -> "g"^gid) gids
+ with
+ | e ->
+ ignore (Unix.close_process_in ic);
+ raise e
+ end
+
+ | 'g' -> begin
+ (* 2. if (1) fails, we try to see if our subject identifier is a group id...*)
+ (* in Unix, a group cannot contain other groups, so no need to go recursively *)
+ ("g"^(getent_idbyid "group" sanitized_subject_id))::[]
+ end
+
+ | _ -> raise Not_found
+
+(*
+ In addition, there are some event hooks that auth modules implement as follows:
+*)
+
+(* unit on_enable(((string*string) list) config_params)
+
+ Called internally by xapi _on each host_ when a client enables an external auth service for the
+ pool via the XenAPI [see AD integration wiki page]. The config_params here are the ones passed
+ by the client as part of the corresponding XenAPI call.
+ On receiving this hook, the auth module should:
+ (i) do whatever it needs to do (if anything) to register with the external auth/directory
+ service [using the config params supplied to get access]
+ (ii) Write the config_params that it needs to store persistently in the XenServer metadata
+ into the Pool.external_auth_configuration field. [Note - the rationale for making the plugin
+ write the config params it needs long-term into the XenServer metadata itself is so it can
+ explicitly filter any one-time credentials [like AD username/password for example] that it
+ does not need long-term.]
+*)
+let on_enable config_params =
+ (* nothing to do in this unix plugin, we always have /etc/passwd and /etc/group *)
+
+ (* but in the ldap plugin, we should 'join the AD/kerberos domain', i.e. we should*)
+ (* basically: (1) create a machine account in the kerberos realm,*)
+ (* (2) store the machine account password somewhere locally (in a keytab) *)
+ ()
+
+(* unit on_disable()
+
+ Called internally by xapi _on each host_ when a client disables an auth service via the XenAPI.
+ The hook will be called _before_ the Pool configuration fields relating to the external-auth
+ service are cleared (i.e. so you can access the config params you need from the pool metadata
+ within the body of the on_disable method)
+*)
+let on_disable config_params =
+ (* nothing to disable in this unix plugin, we should not disable /etc/passwd and /etc/group:) *)
+
+ (* but in the ldap plugin, we should 'leave the AD/kerberos domain', i.e. we should *)
+ (* (1) remove the machine account from the kerberos realm, (2) remove the keytab locally *)
+ ()
+
+(* unit on_xapi_initialize(bool system_boot)
+
+ Called internally by xapi whenever it starts up. The system_boot flag is true iff xapi is
+ starting for the first time after a host boot
+*)
+let on_xapi_initialize system_boot =
+ (* again, nothing to be initialized here in this unix plugin *)
+
+ (* in the ldap plugin, we should try to obtain the kerberos tgt, storing*)
+ (* it e.g. in /tmp/krb5cc_0, so that ldap, and nss_over_ldap functions can use it to *)
+ (* automatically authenticate the ldap principal *)
+ ()
+
+(* unit on_xapi_exit()
+
+ Called internally when xapi is doing a clean exit.
+*)
+let on_xapi_exit () =
+ (* nothing to do here in this unix plugin *)
+
+ (* in the ldap plugin, we should remove the tgt ticket in /tmp/krb5cc_0 *)
+ ()
+
+(* Implement the single value required for the module signature *)
+let methods = {Auth_signature.authenticate_username_password = authenticate_username_password;
+ Auth_signature.authenticate_ticket = authenticate_ticket;
+ Auth_signature.get_subject_identifier = get_subject_identifier;
+ Auth_signature.query_subject_information = query_subject_information;
+ Auth_signature.query_group_membership = query_group_membership;
+ Auth_signature.on_enable = on_enable;
+ Auth_signature.on_disable = on_disable;
+ Auth_signature.on_xapi_initialize = on_xapi_initialize;
+ Auth_signature.on_xapi_exit = on_xapi_exit}
+end
+
+
165 ocaml/auth/extauth.ml
@@ -0,0 +1,165 @@
+open Db_actions
+open Auth_signature
+
+module D = Debug.Debugger(struct let name="extauth" end)
+open D
+
+exception Unknown_extauth_type of string
+exception Extauth_is_disabled
+
+module Ext_auth =
+struct
+
+(* CP-781: Implement Ext_auth as a multiplexer for all the authentication plugins *)
+(* Will call the dispatch to the appropriate xapi-auth-module's functions,
+ depending on the 'auth_type' field of this host *)
+
+ (* this 'named dispatcher' should not be used in general by other xapi modules, only during *)
+ (* xapi_host.enable_extauth, when we do not yet have access here to the global variable host.external_auth_type *)
+ let nd auth_type =
+ debug "using external auth plugin %s" auth_type;
+ match auth_type with
+ | "" -> (* ext auth is disabled, no plugin available*)
+ begin
+ debug "External authentication is disabled.";
+ raise Extauth_is_disabled
+ end
+ (* our "local" authentication plugin *)
+ | "PAM" -> (*pam/nss unix services*)
+ Authx.AuthX.methods
+ (* the Likewise authentication plugin *)
+ | "AD" -> (*windows active directory*)
+ Extauth_plugin_ADlikewise.AuthADlw.methods
+ (* if no other auth_type fits, then we don't know what to do *)
+ | _ as uat -> (*error*)
+ begin
+ debug "Unknown external authentication type: %s" uat;
+ raise (Unknown_extauth_type uat)
+ end
+
+ (* this is the generic dispatcher that should be used by any function in other xapi modules *)
+ let d() =
+ (* this function reads auth_type field for this host and returns appropriate
+ methods record for each implemented xapi-auth-module plugin *)
+ let auth_type =
+ Server_helpers.exec_with_new_task "obtaining auth_type"
+ (fun __context ->
+ let host = Helpers.get_localhost ~__context in
+ Db.Host.get_external_auth_type ~__context ~self:host
+ )
+ in
+ nd auth_type
+
+end
+
+(* some constants *)
+let extauth_hook_script_name = "extauth-hook" (* script name in /etc/xapi.d/plugins/ *)
+let event_name_after_subject_add = "after-subject-add"
+let event_name_after_subject_remove = "after-subject-remove"
+let event_name_after_xapi_initialize = "after-xapi-initialize"
+let event_name_before_extauth_disable = "before-extauth-disable"
+let event_name_after_extauth_enable = "after-extauth-enable"
+let get_event_params ~__context host =
+ let auth_type = Db.Host.get_external_auth_type ~__context ~self:host in
+ let service_name = Db.Host.get_external_auth_service_name ~__context ~self:host in
+ [("auth_type",auth_type);("service_name",service_name)]
+
+(* allows extauth hook script to be called only under specific conditions *)
+let can_execute_extauth_hook_script ~__context host event_name =
+ let auth_type = Db.Host.get_external_auth_type ~__context ~self:host in
+ (* if extauth is enabled, we call the hook-script for any event *)
+ ((auth_type<>"") or
+ (* otherwise, if extauth is disabled, we call the hook-script only when enabling extauth or initializing xapi *)
+ List.mem event_name [
+ event_name_after_extauth_enable;
+ event_name_after_xapi_initialize;
+ ]
+ )
+
+(* this function should only be used directly by host.{enable,disable}_extauth *)
+(* use the generic call below to avoid concurrency problems between the script and host.{enable,disable}_extauth *)
+let call_extauth_hook_script_in_host_wrapper ~__context host event_name ~call_plugin_fn =
+ (* CP-709: call extauth-hook-script *)
+ (* Forkhelpers.execute_command_get_output hook-script "/opt/xensource/bin/external-auth-hook-script" *)
+ (* fork a new thread and call new xapi.host.call-subject-add-hook-script method *)
+ (* see xapi_sync.ml *)
+ (* host.call-plugins scriptname (calls /etc/xapi.d/plugins/scriptname*)
+
+ if can_execute_extauth_hook_script ~__context host event_name
+ then begin
+ try
+ let result = call_plugin_fn () in
+ debug "Result of Extauth-hook: '%s'" result;
+
+ (* extauth-hook can return three values:
+ "True" -> OK
+ "ERROR_0: rewrite_etc_pamd_ssh failed"
+ "ERROR_1: revert_etc_pamd_ssh failed"
+ *)
+ begin match result with
+ | "True" -> begin
+ (host,result) (* OK *)
+ end
+ | "ERROR_0: rewrite_etc_pamd_ssh failed" as errmsg -> begin
+ failwith errmsg
+ end
+ | "ERROR_1: revert_etc_pamd_ssh failed" as errmsg -> begin
+ failwith errmsg
+ end
+ | _ as errmsg -> begin (* unexpected result *)
+ failwith errmsg
+ end
+ end
+ with e ->
+ let msg = (ExnHelper.string_of_exn e) in
+ warn "Extauth-hook failed: exception: %s" msg;
+ raise e (* FAILED *)
+ end
+ else begin
+ debug "Extauth-hook event %s not called in this host because external authentication is disabled." event_name;
+ (host,"") (* hook script was not called, no result to return *)
+ end
+
+(* this is the generic call to be used by anyone who wants to call the extauth-hook script *)
+let call_extauth_hook_script_in_host ~__context host event_name =
+ let event_params = get_event_params ~__context host in
+ let call_plugin_fn () =
+ Helpers.call_api_functions ~__context (fun rpc session_id ->
+ Client.Client.Host.call_plugin rpc session_id host (* will call extauth plugin with mutex *)
+ extauth_hook_script_name (* script name in /etc/xapi.d/plugins/ *)
+ event_name (* event name sent to script *)
+ event_params (* parameters sent to event name *)
+ )
+ in
+ call_extauth_hook_script_in_host_wrapper ~__context host event_name ~call_plugin_fn
+
+type hook_script_result =
+ | Hook_Script_Success of string
+ | Hook_Script_Failure of string
+
+(* calls extauth_hook_script in all hosts of the pool *)
+let call_extauth_hook_script_in_pool ~__context event_name =
+ (* CP-709: call extauth-hook-script *)
+ (* we call the script for each host in the pool, using a best-effort attempt to call *)
+ (* all hosts even if one fails *)
+
+ let host = Helpers.get_localhost ~__context in
+ if can_execute_extauth_hook_script ~__context host event_name
+ then begin
+ let hosts = Db.Host.get_all ~__context in
+ let host_msgs = List.map (fun host ->
+ try
+ let (host,result) = call_extauth_hook_script_in_host ~__context host event_name in
+ (host,Hook_Script_Success result)
+ with e ->
+ (* we should not re-raise the exception here, since we want to go through as many hosts as possible *)
+ let msg = (ExnHelper.string_of_exn e) in
+ (host,Hook_Script_Failure msg)
+ ) hosts in
+ host_msgs
+ end
+ else begin
+ debug "Extauth-hook event %s not called in the pool because external authentication is disabled." event_name;
+ []
+ end
+
794 ocaml/auth/extauth_plugin_ADlikewise.ml
@@ -0,0 +1,794 @@
+module D = Debug.Debugger(struct let name="extauth_plugin_ADlikewise" end)
+open D
+
+module AuthADlw : Auth_signature.AUTH_MODULE =
+struct
+
+(*
+ * External Authentication Plugin component
+ * using AD/Likewise as a backend
+ * v1 01Dec08 marcusg@eu.citrix.com
+ *
+*)
+
+(* removes white spaces in the beginning and the end of a string *)
+let trim = Xmlrpc_sexpr.trim
+
+(** has_substr str sub returns true if sub is a substring of str. Simple, naive, slow. *)
+let has_substr str sub =
+ if String.length sub > String.length str then false else
+ begin
+ let result=ref false in
+ for start = 0 to (String.length str) - (String.length sub) do
+ if String.sub str start (String.length sub) = sub then result := true
+ done;
+ !result
+ end
+
+let user_friendly_error_msg = "The Active Directory Plug-in could not complete the command. Additional information in the XenServer log."
+
+open Pervasiveext
+
+
+let likewise_common ?stdin_string:(stdin_string="") params_list likewise_cmd =
+
+ (* SECURITY: params_list is untrusted external data. Therefore, we must be careful against *)
+ (* the user sending arbitrary injection commands by escaping the likewise cmd parameters. *)
+ (* In order to avoid any escaping or injection exploiting the shell, we call Unix.execvp directly (via create_process, see unix.ml), *)
+ (* instead of using the shell to interpret the parameters and execute the likewise cmd. *)
+
+ let debug_cmd = (likewise_cmd^" "^(List.fold_right (fun p pp->"\""^p^"\" "^pp) params_list "")) in
+
+ (* stuff to clean up on the way out of the function: *)
+ let fds_to_close = ref [] in
+ let files_to_unlink = ref [] in
+ (* take care to close an fd only once *)
+ let close_fd fd =
+ if List.mem fd !fds_to_close then begin
+ Unix.close fd;
+ fds_to_close := List.filter (fun x -> x <> fd) !fds_to_close
+ end in
+ (* take care to unlink a file only once *)
+ let unlink_file filename =
+ if List.mem filename !files_to_unlink then begin
+ Unix.unlink filename;
+ files_to_unlink := List.filter (fun x -> x <> filename) !files_to_unlink
+ end in
+ (* guarantee to release all resources (files, fds) *)
+ let finalize () =
+ List.iter close_fd !fds_to_close;
+ List.iter unlink_file !files_to_unlink in
+ let finally_finalize f = finally f finalize in
+ finally_finalize
+ (fun () ->
+ (* creates pipes between xapi and likewise process *)
+ let (in_readme, in_writeme) = Unix.pipe () in
+ fds_to_close := in_readme :: in_writeme :: !fds_to_close;
+ let out_tmpfile = Filename.temp_file "lw" ".out" in
+ files_to_unlink := out_tmpfile :: !files_to_unlink;
+ let err_tmpfile = Filename.temp_file "lw" ".err" in
+ files_to_unlink := err_tmpfile :: !files_to_unlink;
+ let out_writeme = Unix.openfile out_tmpfile [ Unix.O_WRONLY] 0o0 in
+ fds_to_close := out_writeme :: !fds_to_close;
+ let err_writeme = Unix.openfile err_tmpfile [ Unix.O_WRONLY] 0o0 in
+ fds_to_close := err_writeme :: !fds_to_close;
+
+ (*enforces that likewise cmd only inherits the fds explicitly cited below*)
+ let args = Forkhelpers.close_and_exec_cmdline
+ (* we use stdin,stdout and stderr instead of in_readme,out_writeme,err_writeme because *)
+ (* this function maps them internally: in_readme->unix.stdin, out_writeme->unix.stdout, err_writeme->unix.stderr *)
+ [Unix.stdin;Unix.stdout;Unix.stderr]
+ likewise_cmd
+ params_list
+ in
+ (* we bypass the shell here, calling create_process that forks and calls unix.execvp directly, *)
+ (* in order to avoid potential cmd injections that use shell vulnerabilities\escape sequences *)
+ let pid =
+ (try
+ Unix.create_process
+ (List.hd args) (*this is the likewise_cmd*)
+ (Array.append [|(List.hd args)|] (Array.of_list (List.tl args))) (* these are the parameters *)
+ in_readme (* pass along to likewise_cmd the read-only end point of our new stdin pipe *)
+ out_writeme (* pass along to likewise_cmd the write-only end point of our new stdout file *)
+ err_writeme (* pass along to likewise_cmd the write-only end point of our new stderr file *)
+ with
+ | e-> begin
+ let msg = (Printf.sprintf "Error creating process for cmd %s: %s" debug_cmd (ExnHelper.string_of_exn e)) in
+ debug "%s" msg;
+ raise (Auth_signature.Auth_service_error msg) (* general error *)
+ end)
+ in
+ finally
+ (fun () ->
+ debug "Created process pid %i for cmd %s" pid debug_cmd;
+ (* Insert this delay to reproduce the cannot write to stdin bug:
+ Thread.delay 5.; *)
+ (* WARNING: we don't close the in_readme because otherwise in the case where the likewise
+ binary doesn't expect any input there is a race between it finishing (and closing the last
+ reference to the in_readme) and us attempting to write to in_writeme. If likewise wins the
+ race then our write will fail with EPIPE (Unix.error 31 in ocamlese). If we keep a reference
+ to in_readme then our write of "\n" will succeed.
+
+ An alternative fix would be to not write anything when stdin_string = "" *)
+
+ (* push stdin_string to recently created process' STDIN *)
+ begin
+ (* usually, STDIN contains some sensitive data such as passwords that we do not want showing up in ps *)
+ (* or in the debug log via debug_cmd *)
+ try
+ let stdin_string = stdin_string ^ "\n" in (*HACK:without \n, the likewise scripts don't return!*)
+ Unix.write in_writeme stdin_string 0 (String.length stdin_string);
+ close_fd in_writeme; (* we need to close stdin, otherwise the unix cmd waits forever *)
+ with e -> begin
+ (* in_string is usually the password or other sensitive param, so never write it to debug or exn *)
+ debug "Error writing to stdin for cmd %s: %s" debug_cmd (ExnHelper.string_of_exn e);
+ raise (Auth_signature.Auth_service_error (ExnHelper.string_of_exn e))
+ end
+ end;
+ )
+ (fun () -> Unix.waitpid [] pid);
+ (* <-- at this point the process has quit and left us its output in temporary files *)
+
+ (* we parse the likewise cmd's STDOUT *)
+ let result =
+ try
+ (* we read STDERR, just for completeness, but do not expect anything here *)
+ (try
+ let err_readme = Unix.openfile err_tmpfile [ Unix.O_RDONLY ] 0o0 in
+ fds_to_close := err_readme :: !fds_to_close;
+
+ let err_readme_c = (Unix.in_channel_of_descr err_readme) in
+ let err_result = Parse_likewise.of_channel err_readme_c in
+ (* parse_likewise will raise a parse_failure exception here if something unusual is returned in STDERR *)
+ (* parse_likewise will raise an End_of_file exception here if nothing is returned in STDERR *)
+
+ (* we should never reach this point. *)
+ let msg =
+ (Printf.sprintf "Likewise returned success/failure in STDERR for cmd %s: %s" debug_cmd
+ (match err_result with
+ | Parse_likewise.Success ls-> "SUCCESS"^(List.fold_left (fun a b -> " "^a^" "^b) "" (List.map (fun (k,v)->k^"="^v) ls))
+ | Parse_likewise.Failure (code,err)-> Printf.sprintf "FAILURE %i: %s" code err
+ )
+ )
+ in
+ debug "%s" msg;
+ raise (Parse_likewise.Parse_failure (msg,"IN STDERR"))
+ with
+ | End_of_file -> () (* OK, we expect no STDERR output, therefore an EOF is expected *)
+ | e -> (* unexpected error returned by likewise when reading STDERR *)
+ begin
+ debug "Likewise returned an error in STDERR: %s" (ExnHelper.string_of_exn e);
+ raise e (* this should be caught by the parse_failure/unknown_error handlers below *)
+ end
+ );
+ (* we read STDOUT *)
+ let out_readme = Unix.openfile out_tmpfile [ Unix.O_RDONLY ] 0o0 in
+ fds_to_close := out_readme :: !fds_to_close;
+
+ let out_readme_c = (Unix.in_channel_of_descr out_readme) in
+ let out_list = Parse_likewise.of_channel out_readme_c in
+ out_list
+ with
+ | Parse_likewise.Parse_failure (param,err) ->
+ let msg = (Printf.sprintf "Parse_likewise failure for returned value %s: %s" param err) in
+ debug "Error likewise for cmd %s: %s" debug_cmd msg;
+ (* CA-27772: return user-friendly error messages when Likewise crashes *)
+ let msg = user_friendly_error_msg in
+ raise (Auth_signature.Auth_service_error msg)
+ | e -> (* unknown error *)
+ begin
+ debug "Parse_likewise error for cmd %s: %s" debug_cmd (ExnHelper.string_of_exn e);
+ (* CA-27772: return user-friendly error messages when Likewise crashes *)
+ let msg = user_friendly_error_msg in
+ raise (Auth_signature.Auth_service_error msg (*(ExnHelper.string_of_exn e)*))
+ end
+ in
+
+
+ (* finally, we analyze the results *)
+ begin
+ match result with
+ | Parse_likewise.Success attrs ->
+ attrs (* OK, return the whole output list *)
+ | Parse_likewise.Failure (code,errmsg) -> begin
+ debug "Likewise raised an error for cmd %s: (%i) %s" debug_cmd code errmsg;
+ match code with
+ | 32775 -> (* no such user *)
+ raise Not_found (*Subject_cannot_be_resolved*)
+ | 32779 -> (* no such group *)
+ raise Not_found (*Subject_cannot_be_resolved*)
+ | 32784 -> (* The authentication request could not be handled *)
+ raise (Auth_signature.Auth_failure errmsg)
+ | 32814 -> (* authentication failed *)
+ raise (Auth_signature.Auth_failure errmsg)
+ | 32823 -> (* authentication failed: The user account is disabled *)
+ raise (Auth_signature.Auth_failure errmsg)
+ | 32838 -> (* no such user or group *)
+ raise Not_found (*Subject_cannot_be_resolved*)
+ | 524359 -> (* error joining AD domain *)
+ raise (Auth_signature.Auth_service_error errmsg)
+ | 32885 (* lsass server not responding *)
+ | 32888 (* domain is offline (probably /etc/resolv.conf doesn't point to AD's DNS server) *)
+ | _ ->
+ raise (Auth_signature.Auth_service_error (Printf.sprintf "(%i) %s" code errmsg)) (* general Likewise error *)
+ end
+ end
+)
+
+let get_joined_domain_name () =
+ Server_helpers.exec_with_new_task "obtaining joined-domain name"
+ (fun __context ->
+ let host = Helpers.get_localhost ~__context in
+ (* the service_name always contains the domain name provided during domain-join *)
+ Db.Host.get_external_auth_service_name ~__context ~self:host;
+ )
+
+(* CP-842: when resolving AD usernames, make joined-domain prefix optional *)
+let get_full_subject_name ?(use_nt_format=true) subject_name = (* CA-27744: always use NT-style names by default *)
+ try
+ (* tests if the UPN account name separator @ is present in subject name *)
+ ignore(String.index subject_name '@');
+ (* we only reach this point if the separator @ is present in subject_name *)
+ (* nothing to do, we assume that subject_name already contains the domain name after @ *)
+ subject_name
+ with Not_found -> begin (* if no UPN username separator @ was found *)
+ try
+ (* tests if the NT account name separator \ is present in subject name *)
+ ignore(String.index subject_name '\\');
+ (* we only reach this point if the separator \ is present in subject_name *)
+ (* nothing to do, we assume that subject_name already contains the domain name before \ *)
+ subject_name
+ with Not_found -> begin (* if neither the UPN separator @ nor the NT username separator \ was found *)
+ if use_nt_format then begin (* the default: NT names is unique, whereas UPN ones are not (CA-27744) *)
+ (* we prepend the joined-domain name to the subjectname as an NT name: <domain.com>\<subjectname> *)
+ (get_joined_domain_name ()) ^ "\\" ^ subject_name
+ (* obs: (1) likewise accepts a fully qualified domain name <domain.com> with both formats and *)
+ (* (2) some likewise commands accept only the NT-format, such as lw-find-group-by-name *)
+ end
+ else begin (* UPN format not the default format (CA-27744) *)
+ (* we append the joined-domain name to the subjectname as a UPN name: <subjectname>@<domain.com> *)
+ subject_name ^"@"^(get_joined_domain_name ())
+ end
+ end
+ end
+
+(* Converts from UPN format (user@domain.com) to legacy NT format (domain.com\user) *)
+(* This function is a workaround to use lw-find-group-by-name, which requires nt-format names) *)
+(* For anything else, use the original UPN name *)
+let convert_upn_to_nt_username subject_name =
+ try
+ (* test if the UPN account name separator @ is present in subject name *)
+ let i = String.index subject_name '@' in
+ (* we only reach this point if the separator @ is present in subject_name *)
+ (* when @ is present, we need to convert the UPN name to NT format *)
+ let user = String.sub subject_name 0 i in
+ let domain = String.sub subject_name (i+1) ((String.length subject_name) - i - 1) in
+ domain ^ "\\" ^ user
+ with Not_found -> begin (* if no UPN username separator @ was found *)
+ (* nothing to do in this case *)
+ subject_name
+ end
+
+let likewise_get_all_byid subject_id =
+
+ let subject_attrs = likewise_common ["--minimal";subject_id] "/opt/likewise/bin/lw-find-by-sid" in
+ subject_attrs (* OK, return the whole output list *)
+
+let likewise_get_gids_byname _subject_name =
+ let subject_name = get_full_subject_name _subject_name in (* append domain if necessary *)
+
+ let subject_attrs = likewise_common ["--minimal";subject_name] "/opt/likewise/bin/lw-list-groups" in
+ (* returns all gids in the result *)
+ List.map (fun (n,v)->v) (List.filter (fun (n,v)->n="Gid") subject_attrs)
+
+let likewise_get_sid_bygid gid =
+
+ let subject_attrs = likewise_common ["--minimal";gid] "/opt/likewise/bin/lw-find-group-by-id" in
+ (* lw-find-group-by-id returns several lines. We only need the SID *)
+ if List.mem_assoc "SID" subject_attrs then List.assoc "SID" subject_attrs (* OK, return SID *)
+ else begin (*no SID value returned*)
+ (* this should not have happend, likewise didn't return an SID field!! *)
+ let msg = (Printf.sprintf "Likewise didn't return an SID field for gid %s" gid) in
+ debug "Error likewise_get_sid_bygid for gid %s: %s" gid msg;
+ raise (Auth_signature.Auth_service_error msg) (* general Likewise error *)
+ end
+
+let likewise_get_sid_byname _subject_name cmd =
+ let subject_name = get_full_subject_name _subject_name in (* append domain if necessary *)
+
+ let subject_attrs = likewise_common ["--minimal";subject_name] cmd in
+ (* lw-find-user-by-name returns several lines. We ony need the SID *)
+ if List.mem_assoc "SID" subject_attrs then List.assoc "SID" subject_attrs (* OK, return SID *)
+ else begin (*no SID value returned*)
+ (* this should not have happend, likewise didn't return an SID field!! *)
+ let msg = (Printf.sprintf "Likewise didn't return an SID field for user %s" subject_name) in
+ debug "Error likewise_get_sid_byname for subject name %s: %s" subject_name msg;
+ raise (Auth_signature.Auth_service_error msg) (* general Likewise error *)
+ end
+
+(* subject_id get_subject_identifier(string subject_name)
+
+ Takes a subject_name (as may be entered into the XenCenter UI when defining subjects --
+ see Access Control wiki page); and resolves it to a subject_id against the external
+ auth/directory service.
+ Raises Not_found (*Subject_cannot_be_resolved*) if authentication is not succesful.
+*)
+let get_subject_identifier _subject_name =
+ try
+ (* looks up list of users*)
+ let subject_name = get_full_subject_name _subject_name in (* append domain if necessary *)
+ likewise_get_sid_byname subject_name "/opt/likewise/bin/lw-find-user-by-name"
+ with Not_found ->
+ (* append domain if necessary, lw-find-group-by-name only accepts nt-format names *)
+ let subject_name = get_full_subject_name ~use_nt_format:true (convert_upn_to_nt_username _subject_name) in
+ (* looks up list of groups*)
+ likewise_get_sid_byname subject_name "/opt/likewise/bin/lw-find-group-by-name"
+
+(* subject_id Authenticate_username_password(string username, string password)
+
+ Takes a username and password, and tries to authenticate against an already configured
+ auth service (see XenAPI requirements Wiki page for details of how auth service configuration
+ takes place and the appropriate vlaues are stored within the XenServer Metadata).
+ If authentication is successful then a subject_id is returned representing the account
+ corresponding to the supplied credentials (where the subject_id is in a namespace managed by
+ the auth module/service itself -- e.g. maybe a SID or something in the AD case).
+ Raises auth_failure if authentication is not successful
+*)
+
+let authenticate_username_password _username password =
+ let username = get_full_subject_name _username in (* append domain if necessary *)
+
+ (* first, we try to authenticated user against our external user database *)
+ (* likewise_common will raise an Auth_failure if external authentication fails *)
+ likewise_common ~stdin_string:password [username] "/opt/likewise/bin/lw-auth-user"; (* no --minimal *)
+ (* no exception raised, then authentication succeeded, *)
+ (* now we return the authenticated user's id *)
+ get_subject_identifier username
+
+
+(* subject_id Authenticate_ticket(string ticket)
+
+ As above but uses a ticket as credentials (i.e. for single sign-on)
+*)
+ (* not implemented now, not needed for our tests, only for a *)
+ (* future single sign-on feature *)
+let authenticate_ticket tgt =
+ failwith "extauth_plugin authenticate_ticket not implemented"
+
+(* ((string*string) list) query_subject_information(string subject_identifier)
+
+ Takes a subject_identifier and returns the user record from the directory service as
+ key/value pairs. In the returned string*string map, there _must_ be a key called
+ subject_name that refers to the name of the account (e.g. the user or group name as may
+ be displayed in XenCenter). There is no other requirements to include fields from the user
+ record -- initially qI'd imagine that we wouldn't bother adding anything else here, but
+ it's a string*string list anyway for possible future expansion.
+ Raises Not_found (*Subject_cannot_be_resolved*) if subject_id cannot be resolved by external auth service
+*)
+let query_subject_information subject_identifier =
+
+ let unmap_lw_space_chars lwname =
+ let defensive_copy = String.copy lwname in
+ (* CA-29006: map chars in lw-names back to original space chars in windows-names *)
+ (* we use + as the likewise space-replacement because it's an invalid NT-username char in windows *)
+ (* the space-replacement char used by likewise is defined at /etc/likewise/lsassd.conf *)
+ let current_lw_space_replacement = '+' in