javascript - 使用 spawnSync 和 CUPS 命令行的 EACCES 错误
问题描述
我在运行此 CUPS 命令时遇到了问题:取消所有打印机上的所有作业的选项在cancel -a
哪里。-a
这是控制台中的所有输出:
error: Error: spawnSync /home/finsoft EACCES
at Object.spawnSync (internal/child_process.js:1041:20)
at spawnSync (child_process.js:616:24)
at Object.cancelAll (/home/finsoft/ProgettoStampantiLinux/ProgettoStampanti/api/cupsApis.js:155:19)
at /home/finsoft/ProgettoStampantiLinux/ProgettoStampanti/app.js:80:24
at Layer.handle [as handle_request] (/home/finsoft/ProgettoStampantiLinux/ProgettoStampanti/node_modules/express/lib/router/layer.js:95:5)
at next (/home/finsoft/ProgettoStampantiLinux/ProgettoStampanti/node_modules/express/lib/router/route.js:137:13)
at Route.dispatch (/home/finsoft/ProgettoStampantiLinux/ProgettoStampanti/node_modules/express/lib/router/route.js:112:3)
at Layer.handle [as handle_request] (/home/finsoft/ProgettoStampantiLinux/ProgettoStampanti/node_modules/express/lib/router/layer.js:95:5)
at /home/finsoft/ProgettoStampantiLinux/ProgettoStampanti/node_modules/express/lib/router/index.js:281:22
at Function.process_params (/home/finsoft/ProgettoStampantiLinux/ProgettoStampanti/node_modules/express/lib/router/index.js:335:12) {
errno: 'EACCES',
code: 'EACCES',
syscall: 'spawnSync /home/finsoft',
path: '/home/finsoft',
spawnargs: [ '-c', 'cancel -u' ]
},
status: null,
signal: null,
output: null,
pid: 9826,
stdout: null,
stderr: null
}
这是我的 spawnSync 函数:
cancelAll = function () {
let args = ["-a"];
let cancelAll = spawnSync("cancel", args, { encoding: "utf-8", shell: '/home/finsoft'});
// console.log(cancelAll);
return cancelAll;
};
该选项shell:'/home/finsoft'
是我要使用的外壳的路径。
到目前为止我所做的:
1)我尝试将用户在 spawnSync 中使用的根组添加到根组,即 finsoft,我通过运行以下命令对其进行了仔细检查:
let args = ["-u"];
args.push('finsoft');
let uid = spawnSync('id', args, { encoding: "utf-8"});
console.log(uid);
的输出console.log(uid)
:
{
status: 0,
signal: null,
output: [ null, '1000\n', '' ],
pid: 8141,
stdout: '1000\n',
stderr: ''
}
女巫对应finsoft uid
2)我改变了/home/finsoft
这样的权限:
sudo chmod 777 /home/finsoft
结果ls-l
:
finsoft@finsoft-20351:/home$ ls -l
total 4
drwxrwxrwx 34 finsoft finsoft 4096 Feb 23 09:11 finsoft
- 我什至尝试
uid:0
在 spawnSync 中指定选项,它应该使用 root 用户,并将shell
路径更改为默认(/bin/sh
),所以我不应该遇到权限或其他要求的问题,但这会产生完全不同的错误:
Error: spawnSync /bin/sh EPERM
我还能尝试什么?
解决方案
推荐阅读
- go - 带指针的工厂方法多态性
- vb.net - Launch a PowerShell command and then pass it a password
- javascript - 将 Javascript 数组转换为 JSON 文件
- python-3.x - seaborn.catplot 的问题
- c# - How to get reference to a rectangle from List
- linux-kernel - 当 Ubuntu 基因组会话通过桌面快捷方式运行并关闭时,它被 pyinstaller 构建的 linux 应用程序破坏
- java - Custom Collector for Collectors.groupingBy doesn't work as expected
- html - Hiding an image on mobile only using CSS
- sql - 为什么会出现一个不正确的语法错误?
- java - 如何通过将变量传递给 reference.child() 从 Firebase 数据库中检索数据?