mirror of
				https://github.com/lxsang/antd-web-apps
				synced 2025-10-31 10:25:38 +01:00 
			
		
		
		
	set correct envar when user running Lua code
This commit is contained in:
		| @@ -115,6 +115,27 @@ function SystemController:apigateway(...) | |||||||
|         end |         end | ||||||
|         local r, e |         local r, e | ||||||
|         e = "{'error': 'Unknow function'}" |         e = "{'error': 'Unknow function'}" | ||||||
|  |         -- set env var | ||||||
|  |         local home = ulib.home_dir(uid.id) | ||||||
|  |         ulib.setenv("USER", SESSION.user, 1) | ||||||
|  |         ulib.setenv("LOGNAME", SESSION.user, 1) | ||||||
|  |         if home then | ||||||
|  |             ulib.setenv("HOME", home, 1) | ||||||
|  |             ulib.setenv("PWD", home,1) | ||||||
|  |             local paths = "" | ||||||
|  |             if ulib.exists(home.."/bin") then | ||||||
|  |                 paths = home.."/bin:" | ||||||
|  |             end | ||||||
|  |             if ulib.exists(home.."/.local/bin") then | ||||||
|  |                 paths = paths..home.."/.local/bin:" | ||||||
|  |             end | ||||||
|  |             local envar = ulib.getenv("PATH") | ||||||
|  |             if envar then | ||||||
|  |                 paths = paths..envar | ||||||
|  |             end | ||||||
|  |             ulib.setenv("PATH", paths,1) | ||||||
|  |         end | ||||||
|  |         -- run the code as user | ||||||
|         if data.code then |         if data.code then | ||||||
|             r, e = load(data.code) |             r, e = load(data.code) | ||||||
|             if r then |             if r then | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user