【问题标题】:rsync daemon behaving eraticallyrsync 守护进程行为异常
【发布时间】:2016-12-08 14:36:38
【问题描述】:

我正在运行 rsync 守护进程(为 SaneSecurity 签名提供镜像)。

rsync 是这样启动的(来自 runit):

    /usr/bin/rsync -v --daemon --no-detach

并且配置包含:

    use chroot = no
    munge symlinks = no
    max connections = 200
    timeout = 30
    syslog facility = local5
    transfer logging = no
    log file = /var/log/rsync.log
    reverse lookup = no
    [sanesecurity]
      comment = SaneSecurity ClamAV Mirror
      path = /srv/mirror/sanesecurity
      read only = yes
      list = no
      uid = nobody
      gid = nogroup

但我看到的是很多“挥之不去”的 rsync 进程:

   # ps auxwww|grep rsync
   root       423  0.0  0.0   4244  1140 ?        Ss   Oct30   0:00 runsv rsync
   root      2529  0.0  0.0  11156  2196 ?        S    15:00   0:00 /usr/bin/rsync -v --daemon --no-detach
   nobody    4788  0.0  0.0  20536  2860 ?        S    15:10   0:00 /usr/bin/rsync -v --daemon --no-detach
   nobody    5094  0.0  0.0  19604  2448 ?        S    15:13   0:00 /usr/bin/rsync -v --daemon --no-detach
   root      5304  0.0  0.0  11156   180 ?        S    15:15   0:00 /usr/bin/rsync -v --daemon --no-detach
   root      5435  0.0  0.0  11156   180 ?        S    15:16   0:00 /usr/bin/rsync -v --daemon --no-detach
   root      5797  0.0  0.0  11156   180 ?        S    15:19   0:00 /usr/bin/rsync -v --daemon --no-detach 
   nobody    5913  0.0  0.0  20536  2860 ?        S    15:20   0:00 /usr/bin/rsync -v --daemon --no-detach
   nobody    6032  0.0  0.0  20536  2860 ?        S    15:21   0:00 /usr/bin/rsync -v --daemon --no-detach
   root      6207  0.0  0.0  11156   180 ?        S    15:22   0:00 /usr/bin/rsync -v --daemon --no-detach
   nobody    6292  0.0  0.0  20544  2744 ?        S    15:23   0:00 /usr/bin/rsync -v --daemon --no-detach
   root      6467  0.0  0.0  11156   180 ?        S    15:25   0:00 /usr/bin/rsync -v --daemon --no-detach
   root      6905  0.0  0.0  11156   180 ?        S    15:29   0:00 /usr/bin/rsync -v --daemon --no-detach

(现在是 15:30)

所以从 15:10、15:13 等开始就有进程(甚至没有放弃特权!)。

他们在做什么?

让我们检查一下:

    # strace -p 5304
    strace: Process 5304 attached
    select(4, [3], NULL, [3], {25, 19185}^C
    strace: Process 5304 detached
    <detached ...>

    # strace -p 5797
    strace: Process 5797 attached
    select(4, [3], NULL, [3], {48, 634487}^C
    strace: Process 5797 detached
    <detached ...>

Ubuntu Xenial 的 rsync 和 PPA 安装的都发生了这种情况(当前使用 rsync 3.1.2-1~ubuntu16.04.1york0)

【问题讨论】:

    标签: linux ubuntu daemon rsync


    【解决方案1】:

    为每个连接创建一个进程。在客户端选择模块之前,进程不知道它是否应该放弃权限。

    您可以轻松创建这样的流程。

    nc $host 873
    

    您会注意到连接不会在 30 秒后关闭,因为超时只是磁盘 i/o 超时。 rsync 客户端有一个--contimeout 选项,但似乎缺少服务器端选项。

    【讨论】:

      【解决方案2】:

      最后,我求助于从 (x)inetd 调用 rsync,而不是单独运行它。

          service rsync
          {
            disable = no
            socket_type = stream
            wait = no
            user = root
            server = /usr/bin/timeout
            server_args =  -k 60s 60s /usr/bin/rsync --daemon
            log_on_failure += USERID
            flags = IPv6
          }
      

      作为一个额外的转折,我用 timeout 包装了 rsync 调用,为长时间运行的进程添加了另一项保护措施。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2023-03-02
        • 2013-10-07
        • 1970-01-01
        • 2011-04-06
        • 1970-01-01
        • 1970-01-01
        • 2012-12-03
        相关资源
        最近更新 更多