V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
yazinnnn
V2EX  ›  Linux

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

  •  1
     
  •   yazinnnn · 2020-03-06 18:51:47 +08:00 · 3125 次点击
    这是一个创建于 1510 天前的主题,其中的信息可能已经有所发展或是发生改变。

    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 条回复    2020-03-07 01:27:20 +08:00
    jhsea3do
        1
    jhsea3do  
       2020-03-07 01:27:20 +08:00
    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 来防止张三李四之类的用户随意修改文本文件造成关机。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   992 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 19:52 · PVG 03:52 · LAX 12:52 · JFK 15:52
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.