mirror of
https://gitcode.com/JianFeeeee/webui4frpc.git
synced 2026-10-31 14:27:23 +00:00
feat(packaging): 单元与安装包改为配置文件启动,口令不再写入 ExecStart
所有交付形态统一成「只传 -config」,凭据留在配置文件 / secrets 文件里。
- systemd 单元:ExecStart 改为 `-config /etc/webui4frpc/config.json`,
EnvironmentFile 加 `-` 前缀变成可选;新增 ReadOnlyPaths=-/etc/webui4frpc/secret。
- 新增 packaging/common/config.json 示例:口令默认用
file:/etc/webui4frpc/secret/password 引用,内嵌以 "_" 开头的说明键。
- webui4frpc.env 瘦身为可选环境变量(${VAR} 取值来源),不再承载明文口令。
- deb/rpm:安装 config.json 与 0750 的 secret 目录,config.json 进 conffiles,
安装后提示改成「设置 password 文件」。
- release.sh 的分发单元模板同步改 -config;tar.gz 附 config.json.example。
- macOS pkg:写 config.json + secret/password,launch 包装脚本只传 -config。
- Windows NSIS:安装时把口令写进 secret-password.txt(icacls 限制为
SYSTEM/Administrators),生成 data/config.json 用 file: 引用,启动脚本只传
-config;顺带按 JSON 规则转义 addr/user。makensis 实测可编译通过。
This commit is contained in:
@ -5,6 +5,10 @@
|
||||
|
||||
!include "MUI2.nsh"
|
||||
!include "LogicLib.nsh"
|
||||
!include "StrFunc.nsh"
|
||||
|
||||
; Used to JSON-escape the free-text fields written into config.json below.
|
||||
${Using:StrFunc} StrRep
|
||||
|
||||
!ifndef VERSION
|
||||
!define VERSION "0.0.0"
|
||||
@ -48,6 +52,9 @@ Var TxtPass
|
||||
Var CfgAddr
|
||||
Var CfgUser
|
||||
Var CfgPass
|
||||
Var EscAddr
|
||||
Var EscUser
|
||||
Var EscDir
|
||||
|
||||
Function .onInit
|
||||
StrCpy $CfgAddr "0.0.0.0:7500"
|
||||
@ -95,12 +102,37 @@ Section "webui4frpc" SecMain
|
||||
|
||||
CreateDirectory "$INSTDIR\data"
|
||||
|
||||
; 启动脚本,承载安装时选择的配置
|
||||
; ---- 启动配置 ----
|
||||
; 口令写进独立文件、由 config.json 用 "file:" 引用:既不出现在启动脚本的
|
||||
; 命令行上(任务管理器 / wmic 可见),也不需要做 JSON 转义。
|
||||
${StrRep} $EscDir $INSTDIR "\" "\\"
|
||||
${StrRep} $EscAddr $CfgAddr "\" "\\"
|
||||
${StrRep} $EscAddr $EscAddr '$\"' '\"'
|
||||
${StrRep} $EscUser $CfgUser "\" "\\"
|
||||
${StrRep} $EscUser $EscUser '$\"' '\"'
|
||||
|
||||
FileOpen $1 "$INSTDIR\secret-password.txt" w
|
||||
FileWrite $1 "$CfgPass$\r$\n"
|
||||
FileClose $1
|
||||
; 口令文件仅 SYSTEM / Administrators 可读(Program Files 默认 Users 可读)
|
||||
nsExec::ExecToLog 'icacls "$INSTDIR\secret-password.txt" /inheritance:r /grant:r *S-1-5-18:F *S-1-5-32-544:F'
|
||||
|
||||
FileOpen $2 "$INSTDIR\data\config.json" w
|
||||
FileWrite $2 "{$\r$\n"
|
||||
FileWrite $2 ' "addr": "$EscAddr",$\r$\n'
|
||||
FileWrite $2 ' "user": "$EscUser",$\r$\n'
|
||||
FileWrite $2 ' "password": "file:$EscDir\\secret-password.txt",$\r$\n'
|
||||
FileWrite $2 ' "workdir": "data"$\r$\n'
|
||||
FileWrite $2 "}$\r$\n"
|
||||
FileClose $2
|
||||
|
||||
; 启动脚本:只传 -config,不传任何凭据
|
||||
FileOpen $0 "$INSTDIR\start-webui4frpc.cmd" w
|
||||
FileWrite $0 "@echo off$\r$\n"
|
||||
FileWrite $0 "rem webui4frpc 启动脚本(由安装程序生成)$\r$\n"
|
||||
FileWrite $0 "rem 凭据在 data\config.json(口令来自 secret-password.txt),不经过命令行。$\r$\n"
|
||||
FileWrite $0 "cd /d %~dp0$\r$\n"
|
||||
FileWrite $0 'webui4frpc.exe -addr $CfgAddr -user $CfgUser -password $CfgPass -workdir "%~dp0data"$\r$\n'
|
||||
FileWrite $0 'webui4frpc.exe -config "%~dp0data\config.json"$\r$\n'
|
||||
FileClose $0
|
||||
|
||||
WriteRegStr HKLM "Software\webui4frpc" "InstallDir" "$INSTDIR"
|
||||
@ -142,6 +174,8 @@ Section "Uninstall"
|
||||
|
||||
Delete "$INSTDIR\webui4frpc.exe"
|
||||
Delete "$INSTDIR\start-webui4frpc.cmd"
|
||||
Delete "$INSTDIR\secret-password.txt"
|
||||
Delete "$INSTDIR\data\config.json"
|
||||
Delete "$INSTDIR\README.md"
|
||||
Delete "$INSTDIR\LICENSE.txt"
|
||||
Delete "$INSTDIR\uninstall.exe"
|
||||
|
||||
Reference in New Issue
Block a user