Open ValeriaXYN opened 1 week ago
现在暂时的解决方案是卸载后回退到1.5.1版本(1.6.0更新前的最后一个版本),目前服务模式运行正常。
./nyanpasu-service install --user %USERNAME% --nyanpasu-data-dir "C:\Users\%USERNAME%\AppData\Local\Clash Nyanpasu\data" --nyanpasu-config-dir "C:\Users\%USERNAME%\AppData\Roaming\Clash Nyanpasu\config" --nyanpasu-app-dir "D:\NetWork\ClashNyan"
An example of use. Please change the directory of your own @ValeriaXYN
Not being able to auto-install is indeed a flaw, probably related to limitations of rust and windows group policy. a similar project clash_verge is able to auto-install, might be worth a reference
Thank you very much! Now the service mode is running.
Not being able to auto-install is indeed a flaw, probably related to limitations of rust and windows group policy. a similar project clash_verge is able to auto-install, might be worth a reference
I have no idea about the failures of service automatic installation on Windows.
The backend logic is same with the manual prompt, although the installation prompt in 1.6.1 is wrong.
By the way, do you instal the winsw globally?
nop, windows doesn't include winsw by default. Does nyanpasu need winsw as pre-dependency?
Not being able to auto-install is indeed a flaw, probably related to limitations of rust and windows group policy. a similar project clash_verge is able to auto-install, might be worth a reference
I have no idea about the failures of service automatic installation on Windows.
The backend logic is same with the manual prompt, although the installation prompt in 1.6.1 is wrong.
I don't know, it just looked like this
🎉Congratulations: the problem has been pinpointed to the user variable in the get_service_install_args function in backend\tauri\src\core\service\control.rs
When user
is changed to a fixed string everything works without any errors: one-click auto-installation
nop, windows doesn't include winsw by default. Does nyanpasu need winsw as pre-dependency?
No. The upstream service manager deps prefers winsw, and sc.exe as fallback
Congratulations: the problem has been pinpointed to the user variable in the get_service_install_args function in backend\tauri\src\core\service\control.rs
When
user
is changed to a fixed string everything works without any errors: one-click auto-installation
So, the syscall fails with errors?
Now, the user in windows do nothing. The DACL in windows is too complex to generate from our default preferences. We are planned to authorize the named pipe with RW permission only for the specified user.
at the upstream source code
pub async fn get_current_user_sid() -> IoResult<String> {
let output = Command::new("cmd")
.args(["/C", "wmic useraccount where name='%username%' get sid"])
.creation_flags(0x0800_0000) // CREATE_NO_WINDOW
.output()
.await
.map_err(|e| {
IoError::new(
IoErrorKind::Other,
format!("Failed to execute command: {}", e),
)
})?;
if !output.status.success() {
return Err(IoError::new(IoErrorKind::Other, "Command failed"));
}
let output_str = String::from_utf8_lossy(&output.stdout);
let lines: Vec<&str> = output_str.lines().collect();
if lines.len() < 2 {
return Err(IoError::new(IoErrorKind::Other, "Unexpected output format"));
}
let sid = lines[1].trim().to_string();
Ok(sid)
}
it is equivalent to the cmd command
wmic useraccount where name='%username%' get sid
But the wmic utility may be deprecated or not installed in newer versions of Windows, which is where the problem occurs.
I tested %USERNAME%
and it's perfectly fine to install service mode, so there's no need to use the sid form %username%(At least on newer versions of windows)
at the upstream source code
pub async fn get_current_user_sid() -> IoResult<String> { let output = Command::new("cmd") .args(["/C", "wmic useraccount where name='%username%' get sid"]) .creation_flags(0x0800_0000) // CREATE_NO_WINDOW .output() .await .map_err(|e| { IoError::new( IoErrorKind::Other, format!("Failed to execute command: {}", e), ) })?; if !output.status.success() { return Err(IoError::new(IoErrorKind::Other, "Command failed")); } let output_str = String::from_utf8_lossy(&output.stdout); let lines: Vec<&str> = output_str.lines().collect(); if lines.len() < 2 { return Err(IoError::new(IoErrorKind::Other, "Unexpected output format")); } let sid = lines[1].trim().to_string(); Ok(sid) }
it is equivalent to the cmd command
wmic useraccount where name='%username%' get sid
But the wmic utility may be deprecated or not installed in newer versions of Windows, which is where the problem occurs.
I tested
%USERNAME%
and it's perfectly fine to install service mode, so there's no need to use the sid form %username%(At least on newer versions of windows)
The user do nothing now.
You can check the original code here: https://github.com/libnyanpasu/nyanpasu-service/blob/main/nyanpasu_ipc/src/server/mod.rs
I don't have a good idea to generate the sdsf correctly, so I grant public access for all users now.
Because of the unimplementation of the permissions, so Sids or usernames(Domain/User is better) are both acceptable.
我不太懂这方面,但我的nyanpasu存在相同的问题,我具体应该怎么做?
我不太懂这方面,但我的nyanpasu存在相同的问题,我具体应该怎么做?
@lanterner3054 Try using the latest development version, which should already have the fix. You can see if this resolves the issue.
复现步骤 / Step to reproduce
以管理员身份打开PowerShell,输入 cd "\?\C:\Program Files (x86)\Clash Nyanpasu" ./nyanpasu-service install
预期行为 / Expected behavior
nyanpasu-service安装成功
实际行为 / Actual behavior
错误如下: PS C:\WINDOWS\system32> cd "\?\C:\Program Files (x86)\Clash Nyanpasu" PS Microsoft.PowerShell.Core\FileSystem::\?\C:\Program Files (x86)\Clash Nyanpasu> ./nyanpasu-service install error: the following required arguments were not provided: --user
--nyanpasu-data-dir
--nyanpasu-config-dir
--nyanpasu-app-dir
Usage: nyanpasu-service.exe install --user --nyanpasu-data-dir --nyanpasu-config-dir --nyanpasu-app-dir
For more information, try '--help'.
应用日志 / App logs
No response
备注 / Addition details
在1.6.0版本更新之前可以成功安装服务模式,自从1.6.0版本更新之后就无法安装服务模式了
环境信息 / Environment information
自查步骤 / Verify steps