From 37f68f0e04aadf3e829eab7e6a6fe569e2e3032a Mon Sep 17 00:00:00 2001 From: DanyLE Date: Sun, 10 Mar 2024 22:55:39 +0100 Subject: [PATCH] fix: query home dir from user id, if fail, fallback to default value --- libs/vfs.lua | 11 +++++++++-- router.lua | 8 +++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/libs/vfs.lua b/libs/vfs.lua index 18132e1..621f637 100644 --- a/libs/vfs.lua +++ b/libs/vfs.lua @@ -2,14 +2,21 @@ local vfs = {} vfs.ospath = function(path) local user = SESSION.user + local uid = ulib.uid(SESSION.user) local prefix = string.match(path, "%a+:/") + local home = ulib.home_dir(uid.id) + if not home then + home = string.format("%s/%s",VFS_HOME, user) + else + LOG_DEBUG("User home is %s", home) + end local os_path = nil if (prefix ~= nil) then local suffix = string.gsub(path, prefix, "") if prefix == "home:/" then - os_path = string.format(VFS_HOME, user) .. '/' .. suffix + os_path = home.. '/' .. suffix elseif prefix == "desktop:/" then - os_path = string.format(VFS_HOME, user) .. "/.antos/desktop/" .. suffix + os_path = home .. "/.antos/desktop/" .. suffix elseif prefix == "shared:/" then os_path = require("shared").ospath(ulib.trim(suffix, "/")) elseif prefix == "os:/" then diff --git a/router.lua b/router.lua index 5870db5..2c99027 100644 --- a/router.lua +++ b/router.lua @@ -15,7 +15,13 @@ package.path = package.path..";"..WWW_ROOT .. '/libs/?.lua' require("common") DIR_SEP = "/" -VFS_HOME = "/home/%s" +VFS_HOME = os.getenv("HOME_ROOT") +if not VFS_HOME then + VFS_HOME="/home" +end + +LOG_DEBUG("VFS_HOME=%s", VFS_HOME) + -- class path: path.to.class CONTROLLER_ROOT = "os.controllers" MODEL_ROOT = "os.models"