V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
yazinnnn
V2EX  ›  Linux

Linux 守护进程的问题,如何能让 ubuntu 的 systemd 执行的子进程能 reboot 或者关机?

  •  1
     
  •   yazinnnn · Mar 6, 2020 · 3737 views
    This topic created in 2252 days ago, the information mentioned may be changed or developed.

    ubuntu 下提示

    Failed to set wall message, ignoring: Interactive authentication required. Failed to reboot system via logind: Interactive authentication required. Failed to open /dev/initctl: 权限不够 Failed to talk to init daemon.

    而我另一台 manjaro 的 linux 主机上却可以正常关机

    远程 ssh 普通用户上来也是同样的情况,ubuntu 不可以直接重启,manjaro 可以

    请问要修改哪里呢?

    /etc/sudoers 里已经添加了

    xxxx ALL = NOPASSWD: /usr/bin/reboot xxxx ALL = NOPASSWD: /usr/bin/halt

    没有起效.....

    1 replies    2020-03-07 01:27:20 +08:00
    jhsea3do
        1
    jhsea3do  
       Mar 7, 2020
    ls -la /dev/initctl
    lrwxrwxrwx. 1 root root 25 Dec 17 09:05 /dev/initctl -> /run/systemd/initctl/fifo

    ls -la /run/systemd/initctl/fifo
    prw-------. 1 root root 0 Dec 17 09:05 /run/systemd/initctl/fifo


    你的 systemd 应该是以非 root 的用户在跑的,如果你考虑用 sudo 哪就要把 require tty 的限制去掉。

    总得来说,这是一种安全风险,如果你的这个 systemd 服务有漏洞,黑客就拿到 roo shell。

    建议你可以写一个文本文件,然后 crontab 去扫描这个文件发现内容为 1 就重启。

    想再安全就可以考虑用 rsa 来防止张三李四之类的用户随意修改文本文件造成关机。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   4710 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 61ms · UTC 04:08 · PVG 12:08 · LAX 21:08 · JFK 00:08
    ♥ Do have faith in what you're doing.