Skip to content

Commit

Permalink
feat: setup dynamic passphrase in level
Browse files Browse the repository at this point in the history
  • Loading branch information
moul committed Mar 7, 2019
1 parent 3f62a55 commit 6e7f2e6
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
3 changes: 2 additions & 1 deletion level/example/hello-world/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
FROM nginx
COPY static /usr/share/nginx/html
COPY static /usr/share/nginx/html
COPY on-init /pathwar-hooks/
3 changes: 3 additions & 0 deletions level/example/hello-world/on-init
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh -e

sed -i "s/THE_PASSPHRASE/$(pwctl passphrase 0)/g" /usr/share/nginx/html/index.html
2 changes: 2 additions & 0 deletions level/example/hello-world/static/index.html
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
<h1>Hello World!</h1>

<p>Here is a dynamic passphrase: <b>THE_PASSPHRASE</b></p>
14 changes: 11 additions & 3 deletions pwctl/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,18 @@ func main() {
rootCmd.AddCommand(&cobra.Command{
Use: "entrypoint",
Args: cobra.MinimumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
// FIXME: prepare the level
// FIXME: add a self-destruct mode that allow having root access only at runtime
RunE: func(_ *cobra.Command, args []string) error {
// FIXME: lock to block other commands

// prepare the level
cmd := exec.Command("/pathwar-hooks/on-init")
if err := cmd.Run(); err != nil {
return err
}

// FIXME: add a self-destruct mode that allow having root access only at runtime

// switch to original's entrypoint
binary, err := exec.LookPath(args[0])
if err != nil {
return err
Expand Down

0 comments on commit 6e7f2e6

Please sign in to comment.