subprocess of sudo, accessing /dev/sda : strange error: [Errno 2] No such file or directory
subprocess of sudo, accessing /dev/sda : strange error: [Errno 2] No such file or directory
我正在尝试使用此脚本(通过 nagios 用户)智能阅读:
https://gist.github.com/mastbaum/10663894#file-smart_watch-py
我确实启用了 nagios 来执行该文件 (/etc/sudoers):
nagios ALL= NOPASSWD: /git/check_smart/smart_watch.py
#(later on for testing)
nagios ALL= NOPASSWD: ALL
我很确定我在子进程中获得了 root 权限,似乎没有授予对设备的访问权限:
nagios@x:/dir$ sudo /git/check_smart/smart_watch.py --device /dev/sda
Traceback (most recent call last):
File "/git/check_smart/smart_watch.py", line 48, in <module>
main(args.logfile, args.device)
File "/git/check_smart/smart_watch.py", line 18, in main
code = check_smart(device)
File "/git/check_smart/smart_watch.py", line 10, in check_smart
return subprocess.call(args)
File "/usr/lib/python2.7/subprocess.py", line 493, in call
return Popen(*popenargs, **kwargs).wait()
File "/usr/lib/python2.7/subprocess.py", line 679, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1259, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
$ ls -lahtr /dev/sda
brw-rw---- 1 root disk 8, 0 cze 13 14:55 /dev/sda
命令运行完美执行为root。
知道为什么会出现 "No such file" 错误吗?
我确实期望权限被拒绝,但不是 /no file/
找到了
命令未找到 smartclt,更改为:
/usr/sbin/smartctl
我正在尝试使用此脚本(通过 nagios 用户)智能阅读: https://gist.github.com/mastbaum/10663894#file-smart_watch-py
我确实启用了 nagios 来执行该文件 (/etc/sudoers):
nagios ALL= NOPASSWD: /git/check_smart/smart_watch.py
#(later on for testing)
nagios ALL= NOPASSWD: ALL
我很确定我在子进程中获得了 root 权限,似乎没有授予对设备的访问权限:
nagios@x:/dir$ sudo /git/check_smart/smart_watch.py --device /dev/sda
Traceback (most recent call last):
File "/git/check_smart/smart_watch.py", line 48, in <module>
main(args.logfile, args.device)
File "/git/check_smart/smart_watch.py", line 18, in main
code = check_smart(device)
File "/git/check_smart/smart_watch.py", line 10, in check_smart
return subprocess.call(args)
File "/usr/lib/python2.7/subprocess.py", line 493, in call
return Popen(*popenargs, **kwargs).wait()
File "/usr/lib/python2.7/subprocess.py", line 679, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1259, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
$ ls -lahtr /dev/sda
brw-rw---- 1 root disk 8, 0 cze 13 14:55 /dev/sda
命令运行完美执行为root。
知道为什么会出现 "No such file" 错误吗? 我确实期望权限被拒绝,但不是 /no file/
找到了
命令未找到 smartclt,更改为: /usr/sbin/smartctl