关闭

Samba源码编译及安装

标签: samba指定的网络名不再可用源码Badtalloc magic valu
5472人阅读 评论(5) 收藏 举报

Samba源码编译及安装

一 引子

系统是Ubuntu14.04,参考《Ubuntu 14.04 samba安装》http://blog.chinaunix.net/uid-26527046-id-4338338.html,进行samba安装,在Windows 7下访问,却总提示“指定的网络名不再可用”,在另外的Ubuntu机器可以访问,但创建文件虽然成功,但会提示权限问题。

 

“指定的网络名不再可用”的问题,在/var/samba/log/ 下的log文件的显示这样的错误:

 

 

[2016/06/01 11:21:18.465733,  0]../source3/lib/popt_common.c:68(popt_s3_talloc_log_fn)

 talloc: access after free error - first free may be at../source3/smbd/open.c:3715

[2016/06/01 11:21:18.465781,  0]../source3/lib/popt_common.c:68(popt_s3_talloc_log_fn)

  Badtalloc magic value - access after free

[2016/06/01 11:21:18.465792,  0] ../source3/lib/util.c:789(smb_panic_s3)

 PANIC (pid 3000): Bad talloc magic value - access after free

[2016/06/01 11:21:18.466529,  0] ../source3/lib/util.c:900(log_stack_trace)

 BACKTRACE: 34 stack frames:

   #0/usr/lib/x86_64-linux-gnu/samba/libsmbregistry.so.0(log_stack_trace+0x1a)[0x7f34da58214a]

   #1/usr/lib/x86_64-linux-gnu/samba/libsmbregistry.so.0(smb_panic_s3+0x20)[0x7f34da582220]

   #2/usr/lib/x86_64-linux-gnu/libsamba-util.so.0(smb_panic+0x2f) [0x7f34db2f98df]

   #3/usr/lib/x86_64-linux-gnu/libtalloc.so.2(+0x1b5f) [0x7f34d8080b5f]

   #4/usr/lib/x86_64-linux-gnu/libtalloc.so.2(_talloc_steal_loc+0xab)[0x7f34d808777b]

   #5/usr/lib/x86_64-linux-gnu/libtalloc.so.2(_talloc_move+0x13) [0x7f34d80877b3]

   #6/usr/lib/x86_64-linux-gnu/samba/libsmbd-base.so.0(+0x18a9d8) [0x7f34daf3a9d8]

   #7/usr/lib/x86_64-linux-gnu/samba/libsmbd-base.so.0(+0x18ade1) [0x7f34daf3ade1]

   #8/usr/lib/x86_64-linux-gnu/samba/libdbwrap.so.0(+0x51ed) [0x7f34d55471ed]

   #9/usr/lib/x86_64-linux-gnu/libtdb.so.1(+0x8745) [0x7f34d22f2745]

  #10 /usr/lib/x86_64-linux-gnu/libtdb.so.1(tdb_parse_record+0x6c)[0x7f34d22ededc]

  #11 /usr/lib/x86_64-linux-gnu/samba/libdbwrap.so.0(+0x5559)[0x7f34d5547559]

  #12/usr/lib/x86_64-linux-gnu/samba/libdbwrap.so.0(dbwrap_parse_record+0x1b)[0x7f34d5544dbb]

  #13/usr/lib/x86_64-linux-gnu/samba/libsmbd-base.so.0(fetch_share_mode_unlocked+0x54)[0x7f34daf3ba34]

  #14/usr/lib/x86_64-linux-gnu/samba/libsmbd-base.so.0(get_file_infos+0x60)[0x7f34daf34a20]

  #15/usr/lib/x86_64-linux-gnu/samba/libsmbd-base.so.0(smbd_dirptr_get_entry+0x738)[0x7f34dae5e0d8]

  #16 /usr/lib/x86_64-linux-gnu/samba/libsmbd-base.so.0(smbd_dirptr_lanman2_entry+0x1c5)[0x7f34dae91f55]

  #17 /usr/lib/x86_64-linux-gnu/samba/libsmbd-base.so.0(+0x14050f)[0x7f34daef050f]

  #18/usr/lib/x86_64-linux-gnu/samba/libsmbd-base.so.0(smbd_smb2_request_process_query_directory+0x2e4)[0x7f34daef0c24]

  #19/usr/lib/x86_64-linux-gnu/samba/libsmbd-base.so.0(smbd_smb2_request_dispatch+0xcad)[0x7f34daede49d]

  #20 /usr/lib/x86_64-linux-gnu/samba/libsmbd-base.so.0(+0x12f0c2)[0x7f34daedf0c2]

  #21 /usr/lib/x86_64-linux-gnu/libsmbconf.so.0(run_events_poll+0x16c)[0x7f34d921aa2c]

  #22 /usr/lib/x86_64-linux-gnu/libsmbconf.so.0(+0x25c80) [0x7f34d921ac80]

  #23 /usr/lib/x86_64-linux-gnu/libtevent.so.0(_tevent_loop_once+0x8d)[0x7f34d7e73d5d]

  #24 /usr/lib/x86_64-linux-gnu/libtevent.so.0(tevent_common_loop_wait+0x1b)[0x7f34d7e73efb]

  #25/usr/lib/x86_64-linux-gnu/samba/libsmbd-base.so.0(smbd_process+0x6c9)[0x7f34daecd5b9]

  #26 smbd(+0x96b6) [0x7f34db9936b6]

  #27 /usr/lib/x86_64-linux-gnu/libsmbconf.so.0(run_events_poll+0x16c) [0x7f34d921aa2c]

  #28 /usr/lib/x86_64-linux-gnu/libsmbconf.so.0(+0x25c80) [0x7f34d921ac80]

  #29 /usr/lib/x86_64-linux-gnu/libtevent.so.0(_tevent_loop_once+0x8d)[0x7f34d7e73d5d]

  #30/usr/lib/x86_64-linux-gnu/libtevent.so.0(tevent_common_loop_wait+0x1b)[0x7f34d7e73efb]

  #31 smbd(main+0x15b4) [0x7f34db9916c4]

  #32 /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf5)[0x7f34d7accec5]

  #33 smbd(+0x7a96) [0x7f34db991a96]

[2016/06/01 11:21:18.466649,  0] ../source3/lib/util.c:801(smb_panic_s3)

  smb_panic():calling panic action [/usr/share/samba/panic-action 3000]

[2016/06/01 11:21:18.469073,  0] ../source3/lib/util.c:809(smb_panic_s3)

 smb_panic(): action returned status 0

[2016/06/01 11:21:18.469125,  0] ../source3/lib/dumpcore.c:318(dump_core)

 dumping core in /var/log/samba/cores/smbd

[2016/06/01 11:23:04.329167,  0]../source3/lib/popt_common.c:68(popt_s3_talloc_log_fn)

 talloc: access after free error - first free may be at../source3/smbd/open.c:3715

[2016/06/01 11:23:04.329238,  0] ../source3/lib/popt_common.c:68(popt_s3_talloc_log_fn)

  Badtalloc magic value - access after free

[2016/06/01 11:23:04.329281,  0] ../source3/lib/util.c:789(smb_panic_s3)

 PANIC (pid 3004): Bad talloc magic value - access after free

[2016/06/01 11:23:04.330660,  0] ../source3/lib/util.c:900(log_stack_trace)

 BACKTRACE: 35 stack frames:

   #0/usr/lib/x86_64-linux-gnu/samba/libsmbregistry.so.0(log_stack_trace+0x1a)[0x7f34da58214a]

   #1/usr/lib/x86_64-linux-gnu/samba/libsmbregistry.so.0(smb_panic_s3+0x20) [0x7f34da582220]

   #2/usr/lib/x86_64-linux-gnu/libsamba-util.so.0(smb_panic+0x2f) [0x7f34db2f98df]

   #3/usr/lib/x86_64-linux-gnu/libtalloc.so.2(+0x1b5f) [0x7f34d8080b5f]

   #4/usr/lib/x86_64-linux-gnu/libtalloc.so.2(_talloc_steal_loc+0xab) [0x7f34d808777b]

   #5/usr/lib/x86_64-linux-gnu/libtalloc.so.2(_talloc_move+0x13) [0x7f34d80877b3]

   #6/usr/lib/x86_64-linux-gnu/samba/libsmbd-base.so.0(+0x18a9d8) [0x7f34daf3a9d8]

   #7/usr/lib/x86_64-linux-gnu/samba/libsmbd-base.so.0(get_share_mode_lock+0x17e) [0x7f34daf3b60e]

   #8/usr/lib/x86_64-linux-gnu/samba/libsmbd-base.so.0(close_file+0x10d)[0x7f34daeb216d]

   #9/usr/lib/x86_64-linux-gnu/samba/libsmbd-base.so.0(file_close_user+0x35)[0x7f34dae58d45]

  #10 /usr/lib/x86_64-linux-gnu/samba/libsmbd-base.so.0(smbXsrv_session_logoff+0xcd)[0x7f34daef787d]

  #11 /usr/lib/x86_64-linux-gnu/samba/libsmbd-base.so.0(+0x147c06)[0x7f34daef7c06]

  #12 /usr/lib/x86_64-linux-gnu/samba/libsmbd-base.so.0(+0x147ce2)[0x7f34daef7ce2]

  #13 /usr/lib/x86_64-linux-gnu/samba/libdbwrap.so.0(+0x471d)[0x7f34d554671d]

  #14 /usr/lib/x86_64-linux-gnu/samba/libdbwrap.so.0(+0x485a)[0x7f34d554685a]

  #15 /usr/lib/x86_64-linux-gnu/samba/libdbwrap.so.0(dbwrap_traverse+0xa)[0x7f34d5544d4a]

  #16 /usr/lib/x86_64-linux-gnu/samba/libsmbd-base.so.0(smbXsrv_session_logoff_all+0x3c)[0x7f34daef7e5c]

  #17 /usr/lib/x86_64-linux-gnu/samba/libsmbd-base.so.0(+0x14c85d)[0x7f34daefc85d]

  #18 /usr/lib/x86_64-linux-gnu/samba/libsmbd-base.so.0(+0x14cd5e)[0x7f34daefcd5e]

  #19 /usr/lib/x86_64-linux-gnu/samba/libsmbd-shim.so.0(exit_server_cleanly+0x12)[0x7f34d8ddaca2]

  #20 /usr/lib/x86_64-linux-gnu/samba/libsmbd-base.so.0(+0x116850)[0x7f34daec6850]

  #21/usr/lib/x86_64-linux-gnu/libtevent.so.0(tevent_common_check_signal+0x257)[0x7f34d7e77967]

  #22 /usr/lib/x86_64-linux-gnu/libsmbconf.so.0(run_events_poll+0x24)[0x7f34d921a8e4]

  #23 /usr/lib/x86_64-linux-gnu/libsmbconf.so.0(+0x25c80) [0x7f34d921ac80]

  #24 /usr/lib/x86_64-linux-gnu/libtevent.so.0(_tevent_loop_once+0x8d)[0x7f34d7e73d5d]

  #25/usr/lib/x86_64-linux-gnu/libtevent.so.0(tevent_common_loop_wait+0x1b)[0x7f34d7e73efb]

  #26/usr/lib/x86_64-linux-gnu/samba/libsmbd-base.so.0(smbd_process+0x6c9)[0x7f34daecd5b9]

  #27 smbd(+0x96b6) [0x7f34db9936b6]

  #28 /usr/lib/x86_64-linux-gnu/libsmbconf.so.0(run_events_poll+0x16c)[0x7f34d921aa2c]

  #29 /usr/lib/x86_64-linux-gnu/libsmbconf.so.0(+0x25c80) [0x7f34d921ac80]

  #30 /usr/lib/x86_64-linux-gnu/libtevent.so.0(_tevent_loop_once+0x8d)[0x7f34d7e73d5d]

  #31 /usr/lib/x86_64-linux-gnu/libtevent.so.0(tevent_common_loop_wait+0x1b)[0x7f34d7e73efb]

  #32 smbd(main+0x15b4) [0x7f34db9916c4]

  #33 /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf5)[0x7f34d7accec5]

  #34 smbd(+0x7a96) [0x7f34db991a96]

 

在网上查找各种解决方法,都没有用,比如: 检查 ComputerBrowser、Server、Workstation 三个服务

 

最后在samba官网看到,这是samba的一个BUG,有patch可以解决,这样我想,使用SAMBA的最新版本,应该就可以解决了吧。

于是有下面编译安装的过程。

二 编译及安装

1 到https://download.samba.org/pub/samba/stable/下载最新版本源码,我下载的是samba-4.4.3.tar.gz

2 解压,tar -xvf samba-4.4.3.tar.gz

3 安装编译环境及必要的工具:

sudo apt-get install git-core gnupg flexbison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multiliblibc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev ccachelibgl1-mesa-dev libxml2-utils xsltproc unzip

 

sudo apt-get install python-dev libgnutls-devlibacl1-dev libldap2-dev

4 进入samba-4.4.3目录,开始进行编译:

./configure

make

sudo make install

configure或make过程,如果提示缺什么工具,就需要安装什么工具。

安装目录是在/user/local/samba下,这个目录并没有export出来,继续往下看。

5 卸载apt-get install安装的samba

$sudo apt-get remove samba-common

$sudo apt-get remove samba

6 export samba环境变量

sudo vi /etc/ld.so.conf.d/samba.conf

添加:

/usr/local/samba/lib

 

sudo vi /etc/profile.d/samba.sh

添加:

export PATH=$PATH:/usr/local/samba/bin:/usr/local/samba/sbin

 

sudo vi /etc/sudoers

修改:

Defaults       secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

Defaults       secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/samba/bin:/usr/local/samba/sbin"

 

因为这个文件是只读的,要用wq!保存。

7 重启系统,然后用命令smbd –V 查看版本,以确认环境变量是否起作用。

三 Samba配置

新装的samba,跑的配置文件是在/usr/local/samba/etc/目录下,所以需要将smb.conf拷过去。

sudo cp samba-4.4.3/packaging/LSB/smb.conf /usr/local/etc/

sudo vi /usr/local/etc/smb.conf

将workgroup改为:

workgroup = WORKGROUP

 

在文件末尾添加:

[share]

       path= /home/xxx/share

       writeable= yes

       validusers = xxx

 

xxx 是系统的一个用户名,在其HOME目录下需要创建一个share文件夹。

 

添加xxx Samba用户:

sudo smbpasswd –a xxx

按要求输入密码

xxx首先必须是系统用户名称,密码可以不必与系统用户的密码相同。

 

smb.conf修改完毕后保存,然后调用下面命令启动samba服务:

sudo nmbd

sudo smbd

 

然后在Windows进行映射或者网上邻居访问。

四 参考

《Ubuntu 14.04samba安装》http://blog.chinaunix.net/uid-26527046-id-4338338.html

《编译安装SAMBA-3.5.6》http://www.cnblogs.com/steven_oyj/archive/2011/05/17/2048980.html

《samba服务器的安装》http://blog.csdn.net/a921800467b/article/details/8274611

 

1
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:301572次
    • 积分:3802
    • 等级:
    • 排名:第8699名
    • 原创:70篇
    • 转载:1篇
    • 译文:6篇
    • 评论:87条
    文章分类
    最新评论