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
    • 最新
    • 标签
主页 / unix / 问题 / 732281
Accepted
TommyPeanuts
TommyPeanuts
Asked: 2023-01-19 13:01:16 +0800 CST2023-01-19 13:01:16 +0800 CST 2023-01-19 13:01:16 +0800 CST

rsyncd service ProtectSystem=off 无效

  • 772

我正在使用ProtectSystem=full默认的 rsyncd 3.2 运行 Debian 11。

我想覆盖它,所以我习惯systemctl edit这样做。这是我要放在覆盖中的内容:

### Editing /etc/systemd/system/rsync.service.d/override.conf
### Anything between here and the comment below will become the new contents of the file

[Service]
ProtectSystem=off

### Lines below this comment will be discarded

日志报告没有解析错误,并且单元(我认为)重新加载新配置。

/etc但是,在尝试 rsync 到(例如)中的路径时,我仍然会收到“只读文件系统”错误。

我无法覆盖此限制有什么问题?或者这个限制不是问题?在我升级到 Debian 11 之前,配置在 Debian 10 上运行良好,所以我认为这ProtectSystem是导致问题的原因。

编辑:这是/etc/rsyncd.conf我正在使用的配置:

[nameOfMount]
     path = /etc/postfix
     auth users = sysadmin
     secrets file = /etc/rsyncd.secrets
     hosts allow = xxx.xxx.xxx.xxx 
     read only = false
     uid = root
     pre-xfer exec = /usr/local/bin/scriptA.sh
     post-xfer exec = /usr/local/bin/scriptB.sh

pro/post exec 脚本制作正在传输的文件的备份副本,并重新加载 postfix 守护程序。这些错误例如:

rsync error: requested action not supported (code 4) at clientserver.c(1098) [Receiver=3.2.3]
/bin/cp: cannot create regular file '/etc/postfix/fileName.yyyymmddd': Read-only file system
systemd
  • 1 1 个回答
  • 39 Views

1 个回答

  • Voted
  1. Best Answer
    roaima
    2023-01-19T14:58:57+08:002023-01-19T14:58:57+08:00

    让我们从状态检查开始

    systemctl show rsync | grep -E 'ProtectSystem|NoNewPrivileges'
    

    在我未修改的系统上这返回

    ProtectSystem=full
    NoNewPrivileges=yes
    

    我之所以选择,是NoNewPrivileges因为此设置会阻止rsyncd更改其 UID。

    现在让我们看看rsync守护进程重新启动的时间,并记下它(在我的例子中是 22:53):

    ps -ef | grep '[r]sync --daemon'
    
    root     22600     1  0 22:53 ?        00:00:00 /usr/bin/rsync --daemon --no-detach
    

    如果我将你的两行添加到覆盖中,

    systemctl edit rsync
    
    [Service]
    ProtectSystem=off
    

    然后我得到这个

    systemctl show rsync | grep -E 'ProtectSystem|NoNewPrivileges'
    
    ProtectSystem=no
    NoNewPrivileges=yes
    

    但是rsync守护进程没有重新启动:

    ps -ef | grep '[r]sync --daemon'
    
    root     22600     1  0 22:53 ?        00:00:00 /usr/bin/rsync --daemon --no-detach
    

    事实上,我发现我必须手动执行此操作

    systemctl restart rsync
    ps -ef | grep '[r]sync --daemon'
    
    root     22770     1  1 22:56 ?        00:00:00 /usr/bin/rsync --daemon --no-detach
    

    但是,文件系统仍处于只读模式。我们需要额外的一行:

    systemctl edit rsync
    
    [Service]
    ProtectSystem=off
    NoNewPrivileges=no
    

    随后重启,

    systemctl restart rsync
    

    最后的完整性检查,

    systemctl show rsync | grep -E 'ProtectSystem|NoNewPrivileges'
    

    在我的系统上,这会返回所需的结束游戏,它允许我写入下面的文件和目录/etc:

    ProtectSystem=no
    NoNewPrivileges=no
    
    • 1

相关问题

  • journalctl 中的区分级别

  • 将默认编辑器更改为 vim for _ sudo systemctl edit [unit-file] _

  • systemd:如何在服务启动时运行脚本,而不编辑服务定义

  • 使用 systemd 看门狗支持重新启动应用程序

  • 使用键盘快捷键启动/停止 systemd 服务 [关闭]

Sidebar

Stats

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

    模块 i915 可能缺少固件 /lib/firmware/i915/*

    • 3 个回答
  • Marko Smith

    无法获取 jessie backports 存储库

    • 4 个回答
  • Marko Smith

    如何将 GPG 私钥和公钥导出到文件

    • 4 个回答
  • Marko Smith

    我们如何运行存储在变量中的命令?

    • 5 个回答
  • Marko Smith

    如何配置 systemd-resolved 和 systemd-networkd 以使用本地 DNS 服务器来解析本地域和远程 DNS 服务器来解析远程域?

    • 3 个回答
  • Marko Smith

    dist-upgrade 后 Kali Linux 中的 apt-get update 错误 [重复]

    • 2 个回答
  • Marko Smith

    如何从 systemctl 服务日志中查看最新的 x 行

    • 5 个回答
  • Marko Smith

    Nano - 跳转到文件末尾

    • 8 个回答
  • Marko Smith

    grub 错误:你需要先加载内核

    • 4 个回答
  • Marko Smith

    如何下载软件包而不是使用 apt-get 命令安装它?

    • 7 个回答
  • Martin Hope
    user12345 无法获取 jessie backports 存储库 2019-03-27 04:39:28 +0800 CST
  • Martin Hope
    Carl 为什么大多数 systemd 示例都包含 WantedBy=multi-user.target? 2019-03-15 11:49:25 +0800 CST
  • Martin Hope
    rocky 如何将 GPG 私钥和公钥导出到文件 2018-11-16 05:36:15 +0800 CST
  • Martin Hope
    Evan Carroll systemctl 状态显示:“状态:降级” 2018-06-03 18:48:17 +0800 CST
  • Martin Hope
    Tim 我们如何运行存储在变量中的命令? 2018-05-21 04:46:29 +0800 CST
  • Martin Hope
    Ankur S 为什么 /dev/null 是一个文件?为什么它的功能不作为一个简单的程序来实现? 2018-04-17 07:28:04 +0800 CST
  • Martin Hope
    user3191334 如何从 systemctl 服务日志中查看最新的 x 行 2018-02-07 00:14:16 +0800 CST
  • Martin Hope
    Marko Pacak Nano - 跳转到文件末尾 2018-02-01 01:53:03 +0800 CST
  • Martin Hope
    Kidburla 为什么真假这么大? 2018-01-26 12:14:47 +0800 CST
  • Martin Hope
    Christos Baziotis 在一个巨大的(70GB)、一行、文本文件中替换字符串 2017-12-30 06:58:33 +0800 CST

热门标签

linux bash debian shell-script text-processing ubuntu centos shell awk ssh

Explore

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

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve