问题描述
我在运行此 CUPS 命令时遇到权限问题:cancel -a
其中 -a
是取消所有打印机上所有作业的选项。
这是控制台中的所有输出:
@H_404_8@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'
是我要使用的 shell 的路径。
到现在为止我做了什么:
1) 我尝试将用户在 spawnSync 中使用的根组添加到根组中,即 finsoft,我通过运行以下命令对其进行了双重检查:
let args = ["-u"];
args.push('finsoft');
let uid = spawnSync('id',{ encoding: "utf-8"});
console.log(uid);
console.log(uid)
的输出:
{
status: 0,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
- 我什至尝试在 spawnSync 中指定选项
uid:0
,它应该使用 root 用户,并将shell
路径更改为其默认路径(/bin/sh
),所以我不应该没有权限或其他要求方面的问题,但这会产生完全不同的错误:
Error: spawnSync /bin/sh EPERM
我还能尝试什么?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)