AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / ubuntu / 问题 / 1072008
Accepted
Soheil Pourbafrani
Soheil Pourbafrani
Asked: 2018-09-05 04:59:44 +0800 CST2018-09-05 04:59:44 +0800 CST 2018-09-05 04:59:44 +0800 CST

启动时在服务中打开设备文件的权限被拒绝

  • 772

我将ntp.conf文件更改为从设备读取时间:

server 127.127.8.0 mode 2 # standard time from device
server 127.127.1.0 # local clock
fudge 127.127.1.0 stratum 12 

设备文件是文件/dev/refclock-0的链接/dev/mbgclock。问题是当我运行 ntp 守护进程时,我观察到它的状态:

PARSE receiver #0: parse_start: open of /dev/refclock-0 failed: Permission denied

我将权限更改refclock-0为 777 (我知道它很脏,只是为了测试)并将该行添加User=root到 ntp 启动脚本,但错误仍然存​​在!我该如何解决?这是文件/usr/lib/systemd/system/ntpd.service

[Unit]
Description=Network Time Service
After=syslog.target ntpdate.service sntp.service

[Service]
User=root
Type=forking
EnvironmentFile=-/etc/sysconfig/ntpd
ExecStart=/usr/sbin/ntpd -u ntp:ntp $OPTIONS
PrivateTmp=true

[Install]
WantedBy=multi-user.target

这是 ntpd 服务的状态:

● ntpd.service - Network Time Service
   Loaded: loaded (/usr/lib/systemd/system/ntpd.service; enabled; vendor preset: disabled)
   Active: active (running) since Tue 2018-09-04 17:09:08 +0430; 16h ago
  Process: 5741 ExecStart=/usr/sbin/ntpd -u ntp:ntp $OPTIONS (code=exited, status=0/SUCCESS)
 Main PID: 5742 (ntpd)
   CGroup: /system.slice/ntpd.service
           └─5742 /usr/sbin/ntpd -u ntp:ntp -g

Sep 04 17:09:08 hardware ntpd[5742]: Listen normally on 2 lo 127.0.0.1 UDP 123
Sep 04 17:09:08 hardware ntpd[5742]: Listen normally on 3 enp3s0 192.168.1.60 UDP 123
Sep 04 17:09:08 hardware ntpd[5742]: Listen normally on 4 lo ::1 UDP 123
Sep 04 17:09:08 hardware ntpd[5742]: Listen normally on 5 enp3s0 fe80::7895:667b:cec:9b2 UDP 123
Sep 04 17:09:08 hardware ntpd[5742]: Listening on routing socket on fd #22 for interface updates
Sep 04 17:09:08 hardware ntpd[5742]: PARSE receiver #0: parse_start: open of /dev/refclock-0 failed: Permission denied
Sep 04 17:09:08 hardware ntpd[5742]: 127.127.8.0 interface 127.0.0.1 -> (none)
Sep 04 17:09:08 hardware ntpd[5742]: 0.0.0.0 c016 06 restart
Sep 04 17:09:08 hardware ntpd[5742]: 0.0.0.0 c012 02 freq_set kernel -9.533 PPM
Sep 04 17:09:10 hardware ntpd[5742]: 0.0.0.0 c515 05 clock_sync
services systemd ntp
  • 1 1 个回答
  • 1563 Views

1 个回答

  • Voted
  1. Best Answer
    Christian Ehrhardt
    2018-09-05T21:39:25+08:002018-09-05T21:39:25+08:00

    ntp默认情况下在 apparmor 隔离下运行。因此,对于 99% 的情况,您将被 apparmor Deny 阻止 - 检查 dmesg 输出。

    由于 refclocks 有很多潜在的名称,因此配置文件不能仅仅允许/dev/*,特别是因为大多数用户不使用 refclocks。

    因此配置文件已经有一个可调文件/etc/apparmor.d/tunables/ntpd:

    #Add your ntpd devices here eg. if you have a DCF clock
    # @{NTPD_DEVICE}="/dev/ttyS1"
    @{NTPD_DEVICE}="/dev/null"
    

    对于您的情况,以下内容应使其通过此阶段:

    @{NTPD_DEVICE}="refclock-0"
    
    • 1

相关问题

  • “服务”和“/etc/init.d/”有什么区别?

  • 延长笔记本电脑和笔记本电脑电池寿命的技巧

  • 如何设置 Ubuntu 以将我的时钟与时间服务器同步?

  • 命令列出启动时启动的服务?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何运行 .sh 脚本?

    • 16 个回答
  • Marko Smith

    如何安装 .tar.gz(或 .tar.bz2)文件?

    • 14 个回答
  • Marko Smith

    如何列出所有已安装的软件包

    • 24 个回答
  • Marko Smith

    无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗?

    • 25 个回答
  • Martin Hope
    Flimm 如何在没有 sudo 的情况下使用 docker? 2014-06-07 00:17:43 +0800 CST
  • Martin Hope
    Ivan 如何列出所有已安装的软件包 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    La Ode Adam Saputra 无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗? 2010-11-30 18:12:48 +0800 CST
  • Martin Hope
    David Barry 如何从命令行确定目录(文件夹)的总大小? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher “以下软件包已被保留:”为什么以及如何解决? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford 如何删除 PPA? 2010-07-30 01:09:42 +0800 CST

热门标签

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve