This commit is contained in:
2025-10-22 21:02:48 +08:00
parent d69b9e126b
commit 1b6591384b

View File

@@ -58,11 +58,16 @@ def ensure_user_and_groups(authenticator, handler, authentication):
c.Authenticator.post_auth_hook = ensure_user_and_groups
# ========== spawn 钩子:清 shared + 只读挂载 ==========
def prepare_user(spawner):
username = spawner.user.name
user_dir = Path(str(USER_HOME).format(username=username))
# 仅清 shared保留用户其它文件
# ① 确保家目录 700 + 属主正确(首次/后续都适用)
user_dir.mkdir(mode=0o700, parents=True, exist_ok=True)
shutil.chown(user_dir, user=username, group=username)
# ② 只清 shared保留用户其它文件
shared = user_dir / "shared"
if shared.exists():
shutil.rmtree(shared)