ThomasTJdev / nim_websitecreator

Nim fullstack website framework - deploy a website within minutes
https://nimwc.org
MIT License
176 stars 7 forks source link

Enable/Disable plugin with firejail enabled fails #59

Closed ThomasTJdev closed 5 years ago

ThomasTJdev commented 5 years ago

Bug Short Description:

Enabling a plugin while firejail is active crashes the program.

Operating System:

Choose 1 or more. Mark the checkbox it with an X.

Bug Severity:

Choose only 1. Mark the checkbox it with an X.

Version

Semantic Version of this software the Bug Reproduces into. Type in the Version Number

    5.0.0

Workarounds:

Any Workarounds you have tried. Choose none or one or more. Mark the checkbox it with an X.

  1. /home/user/.nimble/pkgs/firejail-0.5.0/firejail.nim
  2. Comment out fea = and let firejailFeatures =
    
    #fea = "{" & v.normalize.split("compile time support:")[1].multiReplace(
    #  ("disabled", "false,"), ("enabled", "true,"),
    #  (" support is ", "\": " ), ("- ", " \"" ), ("-", "_" )) & "}"
    enUsUtf8 = "--env=LC_" & [
    "CTYPE='$1'", "NUMERIC='$1'", "TIME='$1'", "COLLATE='$1'", "MONETARY='$1'",
    "MESSAGES='$1'", "PAPER='$1'", "NAME='$1'", "ADDRESS='$1'", "TELEPHONE='$1'",
    "MEASUREMENT='$1'", "IDENTIFICATION='$1'", "ALL='$1'",
    ].join(" --env=LC_").format("en_US.UTF-8") & " --env=LANG='en_US.UTF-8'"

let firejailFeatures* = ""#parseJson(fea) ## Features available on the Firejails.

3. Comment out firejail feature info in serverinfo.tmpl and firejail.tmpl

### Steps to reproduce:
- 1. Download a plugin
- 2. Go to plugin page and enable
- 3. *program recompiles*
- 4. Crash

### Actual Output:

Hint: firejail [Processing] stack trace: (most recent call last) ../../../../.nimble/pkgs/firejail-0.5.0/firejail.nim(14) /home/user/.nimble/pkgs/firejail-0.5.0/firejail.nim(14, 57) Error: index out of bounds E, [2019-03-02T15:40:49] -- nimwc_main: nimwc_main.nim(582) nimwc_main jester.nim(476) serve httpbeast.nim(414) run httpbeast.nim(287) eventLoop httpbeast.nim(219) processEvents jester.nim(475) :anonymous jester.nim(380) handleRequest asyncmacro.nim(313) dispatch asyncmacro.nim(36) dispatch_continue jester.nim(281) dispatchIter asyncmacro.nim(313) match asyncmacro.nim(36) match_continue macros.nim(570) matchIter nimwc_main.nim(264) recompile os.nim(692) moveFile os.nim(685) tryMoveFSObject oserr.nim(66) raiseOSError [[reraised from: nimwc_main.nim(582) nimwc_main jester.nim(476) serve httpbeast.nim(414) run httpbeast.nim(287) eventLoop httpbeast.nim(219) processEvents jester.nim(475) :anonymous jester.nim(380) handleRequest asyncmacro.nim(313) dispatch asyncmacro.nim(39) dispatch_continue jester.nim(281) dispatchIter asyncfutures.nim(302) read ]] [[reraised from: nimwc_main.nim(582) nimwc_main jester.nim(476) serve httpbeast.nim(414) run httpbeast.nim(287) eventLoop httpbeast.nim(219) processEvents jester.nim(475) :anonymous jester.nim(380) handleRequest asyncmacro.nim(313) handleRequestSlow asyncmacro.nim(39) handleRequestSlow_continue jester.nim(330) handleRequestSlowIter asyncfutures.nim(302) read ]] No such file or directory; Additional info: "No such file or directory" Async traceback: nimwc_main.nim(582) nimwc_main jester.nim(476) serve httpbeast.nim(414) run httpbeast.nim(287) eventLoop httpbeast.nim(219) processEvents jester.nim(475) :anonymous jester.nim(380) handleRequest asyncmacro.nim(313) dispatch asyncmacro.nim(36) dispatch_continue

Resumes an async procedure

jester.nim(281) dispatchIter asyncmacro.nim(313) match asyncmacro.nim(36) match_continue

Resumes an async procedure

macros.nim(570) matchIter nimwc_main.nim(264) recompile os.nim(692) moveFile os.nim(685) tryMoveFSObject oserr.nim(66) raiseOSError

[

nimwc_main.nim(582)   nimwc_main
jester.nim(476)       serve
httpbeast.nim(414)    run
httpbeast.nim(287)    eventLoop
httpbeast.nim(219)    processEvents
jester.nim(475)       :anonymous
jester.nim(380)       handleRequest
asyncmacro.nim(313)   dispatch
asyncmacro.nim(39)    dispatch_continue
  ## Resumes an async procedure
jester.nim(281)       dispatchIter
asyncfutures.nim(302) read

]# Exception message: No such file or directory; Additional info: "No such file or directory" Exception type: D, [2019-03-02T15:40:49] -- nimwc_main: 502 Bad Gateway {"content-type": @["text/html;charset=utf-8"]}


### Expected Output:

NimWC starts again

juancarlospaco commented 5 years ago

"No such file or directory" are the folder tree of the plugins getting created properly?. When you add a plugin would it need to force -d:rc ?. Thats weird, but can be fixed with an inline try except on the variable.

ThomasTJdev commented 5 years ago

The plugin is downloaded correct. It is during the recompiling with recompile*(). I can easily compile it myself with using -d:rc on the nimwc.nim instead.

https://github.com/ThomasTJdev/nim_websitecreator/blob/master/nimwcpkg/nimwc_main.nim#L261-L265

The try except would need to be located inside firejail-nim where fea = is defined.

juancarlospaco commented 5 years ago

This should be Fixed now. :slightly_smiling_face:

ThomasTJdev commented 5 years ago

https://github.com/juancarlospaco/nim-firejail/pull/4