Notes about open source software, computers, other stuff.

Month: March 2014

Fixing problems after giving your Samba server a new IP address

While moving my DHCP server to a Raspberry Pi I also changed some of the IPs handed out to my (virtual) servers. This lead to problems when I logged into Windows (which is tied to my Samba domain), Windows complained that my roaming profile wasn’t completely synced and browsing network shares didn’t work, copying from (mounted) network shares didn’t work, etc.

In the Samba log files I noticed some references to the old IP address (192.168.10.23), e.g.:

[2014/03/13 16:22:23,  0] nmbd/nmbd_become_dmb.c:237(become_domain_master_query_success)
  become_domain_master_query_success:
  There is already a domain master browser at IP 192.168.10.23 for workgroup SENW registered on subnet UNICAST_SUBNET.

and

  [2014/03/13 16:20:07,  0] nmbd/nmbd_browsesync.c:248(domain_master_node_status_fail)
  domain_master_node_status_fail:
  Doing a node status request to the domain master browser
  for workgroup SENW at IP 192.168.10.23 failed.
  Cannot sync browser lists.

Even after restarting smbd and nmbd, and checking my smb.conf thoroughly, these kept showing up.

It turns out (thanks a lot Matt Godbolt) that nmbd keeps caches in two files (paths as they are on my Ubuntu 12.04 server):

  • /var/cache/samba/browse.dat
  • /var/lib/samba/wins.dat

Simply stop nmbd, delete them, restart nmbd and you’re happy.

Related Images:

Slackware on the Raspberry Pi

I took some time this week to migrate my DNs and DCHP server from an Ubuntu virtual machine to my Raspberry Pi. I wanted to do this because these two servers are so essential to regular network functioning. Before this change whenever my server was down (for whatever reason) any machine connected to the LAN would stop having a working internet connection. Moreover, since I never got the VM to boot correctly on autostart I had to manually start it every time the server came back up again.
Conclusion: not ideal and pissed of family members ;-).

Since I had my Raspberry Pi lying around and, apart from a few toy projects, hadn’t used it for anything, I decided to use it for this task: low power requirements and hardware that was more than up to the task.

The question was which distribution to use. I could have gone for Raspbian (Debian for the Raspberry Pi), which would have blended well with my otherwise Ubuntu-minded network. However, partly for nostalgic reasons, partly make sure I don’t get too tied to one distribution, I decided to try and install Slackware, the distribution I used for my first steps in Linux Land.

I followed most of the steps from the fatdog.eu tutorial (see link below) to get everything running. It’s a very well written, extensive tutorial. Things where I followed my own judgement/experience were the fact that I didn’t use a USB stick to download the Slackware packages on (I used an NFS share on my server) and the package selection. With a relatively simple selection I now have about 2GB of disk usage.

Only one thing left to migrate to the Pi now: my LDAP server. Unfortunately it’s been several years since I configured OpenLDAP (on Ubuntu) and Slackware doesn’t include the OpenLDAP server by default. So this will be something for a rainy day…

Links:

Related Images:

Implicit make rules and linking to libraries

Note to self: If relying on implicit make rules, then the libraries you want to link to need to go into the LDLIBS variable, not in the LDFLAGS variable.

The case at hand: I wanted to do a quick test on how to write gzipped files using the Boost libraries. Because this was a simple example, I also wanted a simple Makefile to accompany it, meaning I wanted to use implicit rules.

Here’s the example C++ code I used, slightly modified from the Boost example:

#include <fstream>
#include <iostream>
#include <boost/iostreams/filtering_streambuf.hpp>
#include <boost/iostreams/copy.hpp>
#include <boost/iostreams/filter/gzip.hpp>
 
namespace io = boost::iostreams;
int main()
{
    using namespace std;
 
    ifstream infile("hello.txt", ios_base::in | ios_base::binary);
    ofstream outfile("hello.txt.gz", ios_base::out | ios_base::binary);
    io::filtering_streambuf<io::output> out;
    out.push(io::gzip_compressor());
    out.push(outfile);
    io::copy(infile, out);
 
    return 0;
}

The accompanying Makefile looks like this:

CXXFLAGS=-I/usr/include/boost
LDLIBS=-lboost_iostreams -lboost_system -lstdc++
 
# Needed because otherwise cc is used, in which case -lstdc++
# must be added to -LDLIBS
#CC=g++
 
PROGRAM=boost_write_gzip
 
$(PROGRAM): $(PROGRAM).o
 
clean:
	$(RM) $(PROGRAM).o $(PROGRAM)

Notes

  • Note the addition of -lstdc++ to the LDLIBS, this is because the implicit rule uses cc to do the linking. This is no problem for C++ code, as longs as you add the C++ standard library. Alternatively, you can set CC=g++ as shown in the comment, instead of adding -lstdc++.
  • Note that somewhere since Boost v1.50 the addition of -lboost_system is required.
  • This was done on a machine with Ubuntu Linux 13.10 installed, Boost version 1.53 (the libboost-all-dev package).

Links:

Related Images:

© 2024 Lennart's weblog

Theme by Anders NorĂ©nUp ↑