Unset LD_LIBRARY_PATH before executing commands (exec api) 53/17253/2
authorSebastien Douheret <sebastien.douheret@iot.bzh>
Wed, 17 Oct 2018 13:32:16 +0000 (15:32 +0200)
committerJan-Simon Moeller <jsmoeller@linuxfoundation.org>
Thu, 18 Oct 2018 08:26:19 +0000 (08:26 +0000)
New environment-setup-*-agl-linux file, used to set environment
variables to use an SDK, now checks if LD_LIBRARY_PATH is set or not.
And not empty LD_LIBRARY_PATH is considered as misconfigured and
prevent to use SDK.
So unset by default LD_LIBRARY_PATH env variable and allow to disable
this unset by setting ldLibPathNoReset field of ExecArgs command.

For info, reported error message when call environement-setup-* script:

Your environment is misconfigured, you probably need to
'unset LD_LIBRARY_PATH' but please check why this was set in the
first place and that it's safe to unset.
The SDK will not operate correctly in most cases when LD_LIBRARY_PATH
is set.
For more references see:
 http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html#AEN80
 http://xahlee.info/UnixResource_dir/_/ldpath.html

Change-Id: I386b92b04ebd33db39ac617acffa4e15b21213ad
Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
lib/xdsserver/apiv1-exec.go
lib/xsapiv1/exec.go

index aea34e4..46c8148 100644 (file)
@@ -83,6 +83,15 @@ func (s *APIService) execCmd(c *gin.Context) {
 
        // Build command line
        cmd := []string{}
+
+       // Reset by default LD_LIBRARY_PATH
+       // With new AGL SDK, New environment-setup-*-agl-linux file checks if
+       // LD_LIBRARY_PATH is set or not and not empty LD_LIBRARY_PATH is considered
+       // as misconfigured and prevent to use SDK
+       if !args.LdLibPathNoReset {
+               cmd = append(cmd, "unset LD_LIBRARY_PATH; ")
+       }
+
        // Setup env var regarding Sdk ID (used for example to setup cross toolchain)
        if envCmd := s.sdks.GetEnvCmd(args.SdkID, prj.DefaultSdk); len(envCmd) > 0 {
                cmd = append(cmd, envCmd...)
index 78f05e2..0364999 100644 (file)
@@ -20,17 +20,18 @@ package xsapiv1
 type (
        // ExecArgs JSON parameters of /exec command
        ExecArgs struct {
-               ID              string   `json:"id" binding:"required"`
-               SdkID           string   `json:"sdkID"` // sdk ID to use for setting env
-               CmdID           string   `json:"cmdID"` // command unique ID
-               Cmd             string   `json:"cmd" binding:"required"`
-               Args            []string `json:"args"`
-               Env             []string `json:"env"`
-               RPath           string   `json:"rpath"`           // relative path into project
-               TTY             bool     `json:"tty"`             // Use a tty, specific to gdb --tty option
-               TTYGdbserverFix bool     `json:"ttyGdbserverFix"` // Set to true to activate gdbserver workaround about inferior output
-               ExitImmediate   bool     `json:"exitImmediate"`   // when true, exit event sent immediately when command exited (IOW, don't wait file synchronization)
-               CmdTimeout      int      `json:"timeout"`         // command completion timeout in Second
+               ID               string   `json:"id" binding:"required"`
+               SdkID            string   `json:"sdkID"` // sdk ID to use for setting env
+               CmdID            string   `json:"cmdID"` // command unique ID
+               Cmd              string   `json:"cmd" binding:"required"`
+               Args             []string `json:"args"`
+               Env              []string `json:"env"`
+               RPath            string   `json:"rpath"`            // relative path into project
+               TTY              bool     `json:"tty"`              // Use a tty, specific to gdb --tty option
+               TTYGdbserverFix  bool     `json:"ttyGdbserverFix"`  // Set to true to activate gdbserver workaround about inferior output
+               LdLibPathNoReset bool     `json:"ldLibPathNoReset"` // Set to true to not reset LD_LIBRARY_PATH when sourcing environment file
+               ExitImmediate    bool     `json:"exitImmediate"`    // when true, exit event sent immediately when command exited (IOW, don't wait file synchronization)
+               CmdTimeout       int      `json:"timeout"`          // command completion timeout in Second
        }
 
        // ExecResult JSON result of /exec command