Ubuntu学习笔记之调试Samba

调试samba

我们工作中经常的会使用samba。
但是出现一个棘手的问题我们应该怎么办呢?网上查资料查解决方案?
还是自己下一套samba的源码分析一番呢?

本文介绍了工作中遇到的一个问题。
然后通过查看源码来分析为什么会出这个错误。
以及最后应该怎么解决这个错误。

参考https://wiki.ubuntu.com/DebuggingSamba这个。
我们先看看这个wiki上介绍的怎么调试samba的吧

Introduction(介绍)

Samba is a complex package, because it covers a wide range of use cases and provides lots of different binary packages.

Bugs relating to the samba source package typically fall into one of the following categories:(一般分为下面几种场景)

1.User cannot connect to (or properly access files on) a remote share from his Ubuntu system. This falls under the category of samba as a client.

2.Other systems cannot connect to (or properly access files on) an Ubuntu system providing samba shares. This may be an issue with samba as a server.

3.Install/upgrade failures of the samba packages.

4.libpam-smbpass specific issues. Sharing a folder from the GUI installs libpam-smbpass, which stacks a PAM module that maintains sync between system and samba passwords. Failure in libpam-smbpass may result in inability to login on the system.

5.winbind specific issues. Winbind allows to get user/group info from a Windows DC. It is sometimes installed by unsuspecting users as a recommended package from Wine.

Also, it is a very good idea to have a look at the official Samba HOWTO. You will find there not only a how-to, but also common errors.

How to file(如何定位哪个)

First figure out if the bug falls under one of the generic categories:

1.samba as a client

2.samba as a server

3.install/upgrade failure

4.libpam-smbpass related

5.winbind related

Samba as a client(samba作为客户端来使用)

IS IT A REGRESSION ?
Did this use to work properly with a previous release ?

WHAT VERSION OF SAMBA PACKAGES ARE USED ?
Please give the output of:

dpkg-query -W -f='${Package} ${Version} ${Source} ${Status}\n' | grep samba
HOW IS THE REMOTE SHARE ACCESSED FROM THE UBUNTU SYSTEM?
nautilus (or other GUI client)
smbclient (from the command line)
cifs filesystem mount (from /etc/fstab or a mount command)
IF NAUTILUS (OR ANOTHER GUI CLIENT) IS USED TO ACCESS THE REMOTE SHARE, CAN THE SHARE BE ACCESSED WITH THE SMBCLIENT COMMAND LINE UTILITY ?
To test:

install the samba-client package
try to connect to the remote system from the command line:

smbclient //remote_system/share_name
If the share requires a specific username/password, try using the "-U" parameter (for example, use "-U ntdomain\\user").

IF A CIFS MOUNT IS USED
In that case please also provide:

the content of the file /etc/fstab, or the command line used to mount the remote share if the share is manually mounted.

the content of the file /proc/fs/cifs/DebugData

WHAT IS THE REMOTE SERVER ?
In all cases, please include the output of the following smbclient command:


smbclient -L //remote_system
This should give us the remote server version. Also include on what kind of machine the share is located (Windows 2003 Server, Ubuntu 8.04, NAS box model...)

Samba as a server(samba作为服务端来使用)

IS IT A REGRESSION ?
Did this use to work properly with a previous release ?

WHAT VERSION OF SAMBA PACKAGES ARE USED ?
Please give the output of:

dpkg-query -W -f='${Package} ${Version} ${Source} ${Status}\n' | grep samba
WHICH CLIENTS ARE FAILING TO CONNECT?
Include the operating system (Windows, Ubuntu) and version (XP, Vista, 8.04) of the client systems failing to connect to the share.

WHAT IS THE ERROR MESSAGE PRODUCED ON THE CLIENT?
OTHER INFORMATION TO INCLUDE
the content of the /etc/samba/smb.conf file

log files found in /var/log/samba/

the output of the smbclient -L //server/

the output of testparm -s

Install/upgrade failure(安装、升级时候报错)

STATUS OF SAMBA PACKAGES ON THE SYSTEM
Please give the output of:

dpkg-query -W -f='${Package} ${Version} ${Source} ${Status}\n' | grep samba
OTHER INFORMATION TO INCLUDE
apt and dpkg log files: /var/log/dpkg.log and /var/log/apt/term.log.

/etc/samba/smb.conf (or absence thereof)

In the case of an upgrade was there a prompt for a modified configuration file? If so what steps were taken.

How to Triage(如何鉴别分类)

Identify if the bug falls in one of the generic categories above. If so make sure that the relevant information is available. If not ask for it using one of the stock replies.


Samba as a client


If nautilus fails to connect but smbclient can successfully connect, the bug is related to nautilus. Mark the samba task Invalid and open a new task for nautilus.

If both nautilus and smbclient can not connect, the bug is related to samba.

If cifs cannot connect the bug might be related to CIFS kernelspace (package linux) or userspace (package samba). In doubt, leave it in samba.

Stock Reply(回复)


SAMBA AS A CLIENT
Use this reply if an Ubuntu system cannot access a remote samba/windows share.


Thank you for taking the time to report this bug and helping to make Ubuntu better. Unfortunately we can't fix it without more information. 

Please include the information requested at https://wiki.ubuntu.com/DebuggingSamba#samba-client.
SAMBA AS A SERVER
Use this reply if remote clients cannot access a share provided by an Ubuntu system.


Thank you for taking the time to report this bug and helping to make Ubuntu better. Unfortunately we can't fix it without more information. 

Please include the information requested at https://wiki.ubuntu.com/DebuggingSamba#samba-server.
INSTALL/UPGRADE FAILURE
Use this reply if there is a package installation/upgrade failure on the Ubuntu system.


Thank you for taking the time to report this bug and helping to make Ubuntu better. Unfortunately we can't fix it without more information. 

Please include the information requested at https://wiki.ubuntu.com/DebuggingSamba#samba-pkg-fail.

Non-bugs(没有bug?)

Install/upgrade failure due to missing /etc/samba/smb.conf file
HOW TO RECOGNIZE IT
This is a case of install/upgrade failure that results in the following error message (potentially translated):

package samba-common <version> failed to install/upgrade: subprocess post-installation script returned error exit status 1
The DpkgTerminalLog.gz (or /var/log/apt/term.log) contains the following message:

Not replacing deleted config file /etc/samba/smb.conf
chmod: cannot access `/etc/samba/smb.conf': No such file or directory
The user should not be able to provide any /etc/samba/smb.conf file, since it is missing.

STOCK ANSWER

Thank you for taking the time to report this bug and helping to make Ubuntu better.

It looks like you manually removed /etc/samba/smb.conf before reinstalling/upgrading samba packages. Configuration files are special files that should be purged by running "apt-get purge", not manually removed.

You can recover from this situation by restoring /etc/samba/smb.conf and restart pending package configuration:
$ sudo cp /usr/share/samba/smb.conf /etc/samba/smb.conf
$ sudo dpkg --configure -a

Alternatively, you can purge samba-common completely and attempt the install/upgrade again:
$ sudo apt-get purge samba-common

This bug will be marked as Invalid: please reopen it if the above steps do not resolve the situation for you. To reopen the bug report you can click on the current status, under the Status column, and change the Status back to "New". Thanks again!
Close the bug report as Invalid.

报错日志

log.commu-pc:[2020/03/04 15:14:02.169275,  0] ../source3/auth/auth_domain.c:226(domain_client_validate)
log.commu-pc:  domain_client_validate: unable to validate password for user xxx in domain xxx to Domain controller AD-03.XXXX.COM. Error was NT_STATUS_ACCESS_DENIED.
log.commu-pc:[2020/03/04 15:14:09.504618,  0] ../source3/auth/auth_domain.c:226(domain_client_validate)
log.commu-pc:  domain_client_validate: unable to validate password for user xxx in domain xxx to Domain controller AD-03.XXXX.COM. Error was NT_STATUS_ACCESS_DENIED.
log.commu-pc:[2020/03/04 15:14:10.669048,  0] ../source3/auth/auth_domain.c:226(domain_client_validate)
log.commu-pc:  domain_client_validate: unable to validate password for user xxx in domain xxx to Domain controller AD-03.XXXX.COM. Error was NT_STATUS_ACCESS_DENIED.

通过日志分析发现 都是 说 某个 user 在 domain controller ad-03 里面 验证密码时候出错。报这个错误的时候也就是不能方法共享目录的时候。
不过这个错误 有时候出现,有时候就能访问共享。

确定samba的版本

 samba -V
Version 4.7.6-Ubuntu

取得samba的源码的版本号

buildfarm@fs-release:/var/log/samba$  dpkg-query -W -f='${Package} ${Version} ${Source} ${Status}\n' | grep samba
libsmbclient 2:4.7.6+dfsg~ubuntu-0ubuntu2.11 samba install ok installed
libwbclient0 2:4.7.6+dfsg~ubuntu-0ubuntu2.11 samba install ok installed
python-samba 2:4.7.6
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值