tmp
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user