Samba 服务将无法在 16.04 LTS(非升级版)上启动

Samba 服务将无法在 16.04 LTS(非升级版)上启动

你好,长期听众,第一次来电。

我有一个运行 16.04 LTS Desktop 的系统,其中的 Samba 共享大约在两个月前停止启动。我尝试重启、清除、重新安装,但都失败了。在此先感谢您提供的任何帮助。

请注意,我搜索到的最常见链接是针对 Ubuntu 升级到 16.04 后出现的类似问题,而我从未升级过。此外,涉及注释掉 smb.conf 的解决方案security = share不适username map = smbusers用于我的情况,因为这些从未出现在我的smb.conf文件中。

以下是一个例子:

    user@ubuntu:~$ sudo apt upgrade
    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    Calculating upgrade... Done
    0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
    1 not fully installed or removed.
    After this operation, 0 B of additional disk space will be used.
    Do you want to continue? [Y/n] y
    Setting up samba (2:4.3.11+dfsg-0ubuntu0.16.04.12) ...
    Job for smbd.service failed because the control process exited with error code. 
    See "systemctl status smbd.service" and "journalctl -xe" for details.
    invoke-rc.d: initscript smbd, action "start" failed.
    ● smbd.service - LSB: start Samba SMB/CIFS daemon (smbd)
    Loaded: loaded (/etc/init.d/smbd; bad; vendor preset: enabled)
    Active: failed (Result: exit-code) since Sun 2018-01-28 12:49:10 EST; 7ms ago
    Docs: man:systemd-sysv-generator(8)
    Process: 6851 ExecStart=/etc/init.d/smbd start (code=exited, status=1/FAILURE)

    Jan 28 12:48:39 ubuntu systemd[1]: Starting LSB: start Samba SMB/CIFS daemon (.....
    Jan 28 12:49:10 ubuntu smbd[6851]:  * Starting SMB/CIFS daemon smbd
    Jan 28 12:49:10 ubuntu smbd[6851]:    ...fail!
    Jan 28 12:49:10 ubuntu systemd[1]: smbd.service: Control process exited, code=...=1
    Jan 28 12:49:10 ubuntu systemd[1]: Failed to start LSB: start Samba SMB/CIFS d...).
    Jan 28 12:49:10 ubuntu systemd[1]: smbd.service: Unit entered failed state.
    Jan 28 12:49:10 ubuntu systemd[1]: smbd.service: Failed with result 'exit-code'.
    Hint: Some lines were ellipsized, use -l to show in full.
    dpkg: error processing package samba (--configure):
     subprocess installed post-installation script returned error exit status 1
    Processing triggers for libc-bin (2.23-0ubuntu10) ...
    Errors were encountered while processing:
     samba
    E: Sub-process /usr/bin/dpkg returned an error code (1)

如果我尝试手动启动 samba,系统会告诉我该服务已被屏蔽:

    user@ubuntu:~$ sudo systemctl restart samba 
    Failed to restart samba.service: Unit samba.service is masked.

单纯地揭露真相是没有用的。显然smbd.service这还没开始。

我怀疑当时我搞乱了文件权限,没有把东西恢复到原来的状态。无论如何,这是我最好的猜测。

非常感谢所有建议。

编辑并添加:

sudo systemctl restart samba-ad-dc没有输出,因此我认为重新启动后没有问题。

systemctl status samba-ad-dc输出:

    user@ubuntu://$ systemctl status samba-ad-dc
    ● samba-ad-dc.service - LSB: start Samba daemons for the AD DC
       Loaded: loaded (/etc/init.d/samba-ad-dc; bad; vendor preset: enabled)
       Active: active (exited) since Sun 2018-01-28 14:25:40 EST; 16s ago
         Docs: man:systemd-sysv-generator(8)
      Process: 4949 ExecStop=/etc/init.d/samba-ad-dc stop (code=exited, status=0/SUCCE
      Process: 4962 ExecStart=/etc/init.d/samba-ad-dc start (code=exited, status=0/SUC

    Jan 28 14:25:40 SVR systemd[1]: Starting LSB: start Samba daemons for the AD DC...
    Jan 28 14:25:40 SVR systemd[1]: Started LSB: start Samba daemons for the AD DC.

编辑#2:

有用户提醒我 Samba 无法正常工作。请求的输出:

    user@ubuntu://$ smbclient -L localhost
    WARNING: The "syslog" option is deprecated
    Enter user’s password: 
    Connection to localhost failed (Error NT_STATUS_CONNECTION_REFUSED)

编辑#3-4:

testparm 输出(我更正了 smb.conf 中的创建掩码错误以创建掩码,但没有任何改进):

    user@ubuntu://$ testparm
    Load smb config files from /etc/samba/smb.conf
    rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
    WARNING: The "syslog" option is deprecated
    Processing section "[printers]"
    Processing section "[print$]"
    Processing section "[share]"
    Loaded services file OK.
    Server role: ROLE_STANDALONE

    Press enter to see a dump of your service definitions

    # Global parameters
    [global]
        server string = %h server (Samba, Ubuntu)
        server role = standalone server
        obey pam restrictions = Yes
        pam password change = Yes
        passwd program = /usr/bin/passwd %u
        passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
        unix password sync = Yes
        syslog = 0
        log file = /var/log/samba/log.%m
        max log size = 10000
        dns proxy = No
        panic action = /usr/share/samba/panic-action %d
        idmap config * : backend = tdb
        read only = No
    [printers]
        comment = All Printers
        path = /var/spool/samba
        read only = Yes
        create mask = 0700
        printable = Yes
        browseable = No
    [print$]
        comment = Printer Drivers
        path = /var/lib/samba/printers
        read only = Yes
    [share]
        comment = Ubuntu File Server Share
        path = /media/4TB-A
        create mask = 0755
        guest ok = Yes

编辑#5a:

    user@ubuntu://$ sudo apt-get install -f
    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
    1 not fully installed or removed.
    After this operation, 0 B of additional disk space will be used.
    Setting up samba (2:4.3.11+dfsg-0ubuntu0.16.04.12) ...
    Job for smbd.service failed because the control process exited with error code. See "systemctl status smbd.service" and "journalctl -xe" for details.
    invoke-rc.d: initscript smbd, action "start" failed.
    ● smbd.service - LSB: start Samba SMB/CIFS daemon (smbd)
       Loaded: loaded (/etc/init.d/smbd; bad; vendor preset: enabled)
       Active: failed (Result: exit-code) since Sun 2018-01-28 15:21:41 EST; 7ms ago
         Docs: man:systemd-sysv-generator(8)
      Process: 5967 ExecStart=/etc/init.d/smbd start (code=exited, status=1/FAILURE)

    Jan 28 15:21:41 SVR systemd[1]: Starting LSB: start Samba SMB/CIFS daemon (smbd)...
    Jan 28 15:21:41 SVR smbd[5967]:  * Starting SMB/CIFS daemon smbd
    Jan 28 15:21:41 SVR smbd[5967]:    ...fail!
    Jan 28 15:21:41 SVR systemd[1]: smbd.service: Control process exited, code=exited...s=1
    Jan 28 15:21:41 SVR systemd[1]: Failed to start LSB: start Samba SMB/CIFS daemon ...d).
    Jan 28 15:21:41 SVR systemd[1]: smbd.service: Unit entered failed state.
    Jan 28 15:21:41 SVR systemd[1]: smbd.service: Failed with result 'exit-code'.
    Hint: Some lines were ellipsized, use -l to show in full.
    dpkg: error processing package samba (--configure):
     subprocess installed post-installation script returned error exit status 1
    Processing triggers for libc-bin (2.23-0ubuntu10) ...
    Errors were encountered while processing:
     samba
    E: Sub-process /usr/bin/dpkg returned an error code (1)

编辑#5b:

    user@ubuntu://$ sudo dpkg --configure -a
    Setting up samba (2:4.3.11+dfsg-0ubuntu0.16.04.12) ...
    Job for smbd.service failed because the control process exited with error code. See "systemctl status smbd.service" and "journalctl -xe" for details.
    invoke-rc.d: initscript smbd, action "start" failed.
    ● smbd.service - LSB: start Samba SMB/CIFS daemon (smbd)
       Loaded: loaded (/etc/init.d/smbd; bad; vendor preset: enabled)
       Active: failed (Result: exit-code) since Sun 2018-01-28 15:22:32 EST; 7ms ago
         Docs: man:systemd-sysv-generator(8)
      Process: 6091 ExecStart=/etc/init.d/smbd start (code=exited, status=1/FAILURE)

    Jan 28 15:22:31 SVR systemd[1]: Starting LSB: start Samba SMB/CIFS daemon (smbd)...
    Jan 28 15:22:31 SVR smbd[6091]:  * Starting SMB/CIFS daemon smbd
    Jan 28 15:22:32 SVR smbd[6091]:    ...fail!
    Jan 28 15:22:32 SVR systemd[1]: smbd.service: Control process exited, code=exited...s=1
    Jan 28 15:22:32 SVR systemd[1]: Failed to start LSB: start Samba SMB/CIFS daemon ...d).
    Jan 28 15:22:32 SVR systemd[1]: smbd.service: Unit entered failed state.
    Jan 28 15:22:32 SVR systemd[1]: smbd.service: Failed with result 'exit-code'.
    Hint: Some lines were ellipsized, use -l to show in full.
    dpkg: error processing package samba (--configure):
     subprocess installed post-installation script returned error exit status 1
    Processing triggers for libc-bin (2.23-0ubuntu10) ...
    Errors were encountered while processing:
     samba

编辑#6:

我真的很感谢您今天抽出时间帮助我,N0rbert。我很难通过 ssh 处理您的最后一个请求,但远程管理员进入了该框并让它正常工作。

    user@ubuntu:/var/cache/apt/archives$ sudo dpkg -i --force-all /var/cache/apt/archives/samba_2%3a4.3.11+dfsg-0ubuntu0.16.04.12_amd64.deb
    (Reading database ... 309686 files and directories currently installed.)
    Preparing to unpack .../samba_2%3a4.3.11+dfsg-0ubuntu0.16.04.12_amd64.deb ...
    Unpacking samba (2:4.3.11+dfsg-0ubuntu0.16.04.12) over (2:4.3.11+dfsg-0ubuntu0.16.04.12) ...
    Setting up samba (2:4.3.11+dfsg-0ubuntu0.16.04.12) ...
    Job for smbd.service failed because the control process exited with error code. See "systemctl status smbd.service" and "journalctl -xe" for details.
    invoke-rc.d: initscript smbd, action "start" failed.
    ● smbd.service - LSB: start Samba SMB/CIFS daemon (smbd)
       Loaded: loaded (/etc/init.d/smbd; bad; vendor preset: enabled)
       Active: failed (Result: exit-code) since Sun 2018-01-28 16:48:22 EST; 6ms ago
         Docs: man:systemd-sysv-generator(8)
      Process: 7175 ExecStart=/etc/init.d/smbd start (code=exited, status=1/FAILURE)

    Jan 28 16:48:22 SVR systemd[1]: Starting LSB: start Samba SMB/CIFS daemon (.....
    Jan 28 16:48:22 SVR smbd[7175]:  * Starting SMB/CIFS daemon smbd
    Jan 28 16:48:22 SVR smbd[7175]:    ...fail!
    Jan 28 16:48:22 SVR systemd[1]: smbd.service: Control process exited, code=...=1
    Jan 28 16:48:22 SVR systemd[1]: Failed to start LSB: start Samba SMB/CIFS d...).
    Jan 28 16:48:22 SVR systemd[1]: smbd.service: Unit entered failed state.
    Jan 28 16:48:22 SVR systemd[1]: smbd.service: Failed with result 'exit-code'.
    Hint: Some lines were ellipsized, use -l to show in full.
    dpkg: error processing package samba (--install):
     subprocess installed post-installation script returned error exit status 1
    Processing triggers for libc-bin (2.23-0ubuntu10) ...
    Processing triggers for ufw (0.35-0ubuntu2) ...
    Rules updated for profile 'OpenSSH'
    Rules updated for profile 'Samba'
    Firewall reloaded
    Processing triggers for ureadahead (0.100.0-19) ...
    ureadahead will be reprofiled on next reboot
    Processing triggers for systemd (229-4ubuntu21) ...
    Processing triggers for man-db (2.7.5-1) ...
    Errors were encountered while processing:
     samba

下一个:

    user@ubuntu:/var/cache/apt/archives$ sudo apt-get install -f
    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
    1 not fully installed or removed.
    After this operation, 0 B of additional disk space will be used.
    Setting up samba (2:4.3.11+dfsg-0ubuntu0.16.04.12) ...
    Job for smbd.service failed because the control process exited with error code. See "systemctl status smbd.service" and "journalctl -xe" for details.
    invoke-rc.d: initscript smbd, action "start" failed.
    ● smbd.service - LSB: start Samba SMB/CIFS daemon (smbd)
       Loaded: loaded (/etc/init.d/smbd; bad; vendor preset: enabled)
       Active: failed (Result: exit-code) since Sun 2018-01-28 16:51:44 EST; 5ms ago
         Docs: man:systemd-sysv-generator(8)
      Process: 8065 ExecStart=/etc/init.d/smbd start (code=exited, status=1/FAILURE)

    Jan 28 16:51:44 SVR systemd[1]: Starting LSB: start Samba SMB/CIFS daemon (smbd)...
    Jan 28 16:51:44 SVR smbd[8065]:  * Starting SMB/CIFS daemon smbd
    Jan 28 16:51:44 SVR smbd[8065]:    ...fail!
    Jan 28 16:51:44 SVR systemd[1]: smbd.service: Control process exited, code=exited...s=1
    Jan 28 16:51:44 SVR systemd[1]: Failed to start LSB: start Samba SMB/CIFS daemon ...d).
    Jan 28 16:51:44 SVR systemd[1]: smbd.service: Unit entered failed state.
    Jan 28 16:51:44 SVR systemd[1]: smbd.service: Failed with result 'exit-code'.
    Hint: Some lines were ellipsized, use -l to show in full.
    dpkg: error processing package samba (--configure):
     subprocess installed post-installation script returned error exit status 1
    Processing triggers for libc-bin (2.23-0ubuntu10) ...
    Errors were encountered while processing:
     samba
    E: Sub-process /usr/bin/dpkg returned an error code (1)

下一个:

    user@ubuntu:/var/cache/apt/archives$ sudo dpkg --configure -a
    Setting up samba (2:4.3.11+dfsg-0ubuntu0.16.04.12) ...
    Job for smbd.service failed because the control process exited with error code. See "systemctl status smbd.service" and "journalctl -xe" for details.
    invoke-rc.d: initscript smbd, action "start" failed.
    ● smbd.service - LSB: start Samba SMB/CIFS daemon (smbd)
       Loaded: loaded (/etc/init.d/smbd; bad; vendor preset: enabled)
       Active: failed (Result: exit-code) since Sun 2018-01-28 16:52:41 EST; 6ms ago
         Docs: man:systemd-sysv-generator(8)
      Process: 8194 ExecStart=/etc/init.d/smbd start (code=exited, status=1/FAILURE)

    Jan 28 16:52:41 SVR systemd[1]: Starting LSB: start Samba SMB/CIFS daemon (smbd)...
    Jan 28 16:52:41 SVR smbd[8194]:  * Starting SMB/CIFS daemon smbd
    Jan 28 16:52:41 SVR smbd[8194]:    ...fail!
    Jan 28 16:52:41 SVR systemd[1]: smbd.service: Control process exited, code=exited...s=1
    Jan 28 16:52:41 SVR systemd[1]: Failed to start LSB: start Samba SMB/CIFS daemon ...d).
    Jan 28 16:52:41 SVR systemd[1]: smbd.service: Unit entered failed state.
    Jan 28 16:52:41 SVR systemd[1]: smbd.service: Failed with result 'exit-code'.
    Hint: Some lines were ellipsized, use -l to show in full.
    dpkg: error processing package samba (--configure):
     subprocess installed post-installation script returned error exit status 1
    Processing triggers for libc-bin (2.23-0ubuntu10) ...
    Errors were encountered while processing:
     samba

我重新启动后发现没有任何改善或变化。我按照建议更改了 /etc/samba/smb.conf 文件,但没有任何变化。而且我确实有权限访问共享文件夹。

    user@ubuntu:~$ ls -ld /media/4TB-A
    drwxrwxr-x 1 user user 262144 Dec 31  1969 /media/4TB-A

我真的很茫然。

编辑#7:已解决!!!

用户 jelmer 让我检查 samba 日志/var/log/samba。奇怪的是,log.此文件夹中的一个文件最后一次修改是在本月初,其他文件也更早修改。该文件显示:

    [2018/01/05 23:33:51.639673,  0] ../lib/util/util.c:285(directory_create_or_exist_strict)
     invalid permissions on directory '/var/lib/samba/private/msg.sock': has 0704 should be 0700

msg.sock因此我按照消息指示将的权限更改为0700,然后在运行时服务启动sudo apt upgrade。成功。

感谢 jelner 让我更深入地了解了 sticks,特别感谢 N0rbert 今天花时间耐心索取更多信息,这让我学到了很多关于 samba 和系统服务的知识。向你们两人致敬。

答案1

在这里我将总结解决该问题的所有步骤:

  1. 在现代 Ubuntu 上,主要的 Samba 服务是samba-ad-dc,用户可以重新启动它们并使用以下方式检查其状态

    sudo systemctl restart samba-ad-dc
    systemctl status samba-ad-dc
    
  2. 可以使用以下命令显示所有 Samba 共享

    smbclient -L localhost 
    
  3. 如果没有显示股票,可以/etc/samba/smb.conf检查

    testparm
    
  4. 要恢复 APT 和 dpkg 操作,可以运行

    sudo apt-get install -f
    sudo dpkg --configure -a
    
  5. 我们知道这些命令失败了,所以我们可以安装 Samba 包强制所有警告,然后再次恢复:

    sudo dpkg -i --force-all /var/cache/apt/archives/samba_2%3a4.3.11+dfsg-0ubuntu0.16.04‌​.12_amd64.deb
    sudo apt-get install -f
    sudo dpkg --configure -a
    
  6. 如果没有其他帮助,请尝试使用这个/etc/samba/smb.conf

    # Global parameters
    [global]
        server string = %h server (Samba, Ubuntu)
        server role = standalone server
        map to guest = Bad User
        obey pam restrictions = Yes
        pam password change = Yes
        passwd program = /usr/bin/passwd %u
        passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
        unix password sync = Yes
        syslog = 0
        log file = /var/log/samba/log.%m
        max log size = 1000
        dns proxy = No
        usershare allow guests = Yes
        panic action = /usr/share/samba/panic-action %d
        idmap config * : backend = tdb
    
    
    [printers]
        comment = All Printers
        path = /var/spool/samba
        create mask = 0700
        printable = Yes
        browseable = No
    
    
    [print$]
        comment = Printer Drivers
        path = /var/lib/samba/printers
    
    
    [share]
        comment = Ubuntu File Server Share
        path = /media/4TB-A
        create mask = 0755
        guest ok = Yes
    

    并确保您可以访问/media/4TB-A(使用 检查ls -ld /media/4TB-A)。

  7. 耶尔默关于日志的评论/var/log/samba显示如下:

     [2018/01/05 23:33:51.639673,  0] ../lib/util/util.c:285(directory_create_or_exist_strict)
     invalid permissions on directory '/var/lib/samba/private/msg.sock': has 0704 should be 0700
    

    所以问题已经完全解决了

     sudo chmod 0700 /var/lib/samba/private/msg.sock
     sudo apt-get upgrade
    

相关内容