Parcourir la source

Add README.md

Gildas Chabot il y a 8 ans
Parent
commit
b92753de89
1 fichiers modifiés avec 46 ajouts et 0 suppressions
  1. 46 0
      README.md

+ 46 - 0
README.md

@@ -0,0 +1,46 @@
1
+## Run
2
+
3
+Run with:
4
+
5
+```
6
+./buildAndRun.sh
7
+```
8
+
9
+To activate the plugins, move the `.so` files from the
10
+`plugins.available` directory to the `plugins` directory.
11
+
12
+## Todo
13
+
14
+- Malicious plugin -> read a folder and write to image
15
+  - Check source code?
16
+
17
+## Presentation
18
+
19
+- Add Go code at runtime
20
+- Works only on linux for now
21
+- Based on `dlfcn.h` (dynamic linking) with `cgo`
22
+  - See [`src/plugin/plugin_dlopen.go`](https://tip.golang.org/src/plugin/plugin_dlopen.go)
23
+
24
+- Only two functions: `Open(path string) (*Plugin, error)` and `(p
25
+  *Plugin) Lookup(symName string) (Symbol, error)`
26
+- Two types: `Plugin`, `Symbol`
27
+- Nothing special on the code of the plugin, only the
28
+  `-buildmode=plugin` build option
29
+
30
+Example (from [the doc](https://tip.golang.org/pkg/plugin/)):
31
+```
32
+p, err := plugin.Open("plugin_name.so")
33
+if err != nil {
34
+	panic(err)
35
+}
36
+v, err := p.Lookup("V")
37
+if err != nil {
38
+	panic(err)
39
+}
40
+f, err := p.Lookup("F")
41
+if err != nil {
42
+	panic(err)
43
+}
44
+*v.(*int) = 7
45
+f.(func())() // prints "Hello, number 7"
46
+```