jhbuild just won’t build! (aka Include path madness)

Posted by benjsc on November 18, 2008 under FreeDesktop, OpenSource, Programming, UniSA | Be the First to Comment

I’ve been recently trying to work out why jhbuild fails to build xorg on my FreeBSD box. Traditionally I compile to /usr/local/ however after wanting to experiment with MPX I’ve set things up so that I compile to /usr/local/MPX

Sadly this kept breaking in xorg/lib/libX11 with the error:

Read more of this article »

Clearchain Website Updated

Posted by benjsc on November 14, 2008 under ClearChain | Be the First to Comment

It’s been a while now but I’ve finally got around to updating the clearchain website. The old mediawiki based instance was nice, friendly to edit but also required syntax to edit it. After a while arguing with the syntax it gets to the point where all you really want to do is use the website rather than maintain it. Hence Clearchain lives now as a blog site. Making good use of the wordpress software.  

Word press is easy to use, has a graphical editor and just makes life easier. It’s ironic actually as all the old site really was was a blog with a few pages, it just forced mediawiki to do something it wasn’t really intended for. Now however, we’ve got things right and we’re using blogging software. There will certainly be a number of things broken after the pages have been migrated and the old blog was not shifted. Hence the blog is starting new with only previous useful pages being shifted.

stl::set

Posted by benjsc on November 13, 2008 under Programming | Be the First to Comment

Working with Mark’s dnl code, we came across an interesting issue. Mark had used the stl::set class for some of his code and whilst it compiled fine under Visual Studio, it failed to compile under gcc/g++. With the error:

dnlCommon/Logger.cpp: In member function 'void dnlCommon::Logger::setMask(std::ostream&, std::bitset<5ul>)':
dnlCommon/Logger.cpp:64: error: invalid initialization of reference of type 'dnlCommon::Logger::LoggerPair&' from expression of type 'const dnlCommon::Logger::LoggerPair'
/usr/local/lib/gcc-4.0.4/include/c++/bits/stl_algo.h: In function '_OutputIterator std::remove_copy(_InputIterator, _InputIterator, _OutputIterator, const _Tp&) [with _InputIterator = std::_Rb_tree_const_iterator<dnlCommon::Logger::LoggerPair>, _OutputIterator = std::_Rb_tree_const_iterator<dnlCommon::Logger::LoggerPair>, _Tp = dnlCommon::Logger::LoggerPair]':
/usr/local/lib/gcc-4.0.4/include/c++/bits/stl_algo.h:1112:   instantiated from '_ForwardIterator std::remove(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = std::_Rb_tree_const_iterator<dnlCommon::Logger::LoggerPair>, _Tp = dnlCommon::Logger::LoggerPair]'
dnlCommon/Logger.cpp:54:   instantiated from here
/usr/local/lib/gcc-4.0.4/include/c++/bits/stl_algo.h:1037: error: passing 'const dnlCommon::Logger::LoggerPair' as 'this' argument of 'dnlCommon::Logger::LoggerPair& dnlCommon::Logger::LoggerPair::operator=(const dnlCommon::Logger::LoggerPair&)' discards qualifiers

It turned out that the issue occurred with the assignment operator (operator = ) on the stl::set class. Tracing the problem we found that set<TYPE>::iterator is const rather than non cost. Hence calling stl functions that made use of the iterators but also the assignment operator would fail.

Looking further into the problem I found:

      // _GLIBCXX_RESOLVE_LIB_DEFECTS
      // DR 103. set::iterator is required to be modifiable,
      // but this allows modification of keys.
      typedef typename _Rep_type::const_iterator iterator;
      typedef typename _Rep_type::const_iterator const_iterator;

Hmm, that’s strange. A bit of googling revieled the problem to be an issue with the stl standard. Fixes to gcc/g++ are listed at http://gcc.gnu.org/onlinedocs/libstdc++/ext/howto.html in particular error 103 is listed at http://gcc.gnu.org/onlinedocs/libstdc++/ext/lwg-defects.html#103
So it looks like the bug was ratified by the C++ committee in 1998 and it still isn’t fixed in Visual Studio 2005 (VC++ 8.0) !

FreeBSD VPN

Posted by benjsc on under Computers, FreeBSD | Be the First to Comment

FreeBSD VPN

This document describes how to setup both the server side and client side for a PPTP connection with MPPE encryption that works for windows, MacOsX and other freebsd boxes.

The basic process:

 - Install & configure pptpserver on the freebsd server
 - Configure ppp on the freebsd server
 - Setup the clients

[edit] 1. Installing pptpserver

This part is handled really easily as it pptp server exists in the ports collections. Hence all you need to do is:

 cd /usr/port/net/poptop
 make install

To configure pptp modify /usr/local/etc/pptp.conf\\ Put the following lines in the file:

 localip 192.168.2.1
 remoteip 192.168.2.56-75

 # Listen on the outside interface only
 listen 130.220.37.202

[edit] Configure ppp on the freebsd server

Edit /etc/ppp/ppp.conf and set the following target only:

  pptp:
    set ifaddr 192.168.1.1 192.168.1.56-192.168.1.74 255.255.255.255
   set dns 192.168.0.1
    set nbns 192.168.0.1
   disable pap
   disable utmp
   disable passwdauth
   #enable chap     # MPPE Requirest chap81/MSChapV2
   enable MSChapV2
   enable mppe      # Enable Encrptions
   set log Phase Chat LCP IPCP CCP tun command  # Debugging
   set timeout 0   # Don't drop the connection
   #
   # Force 128 bit encryption with a key change every packet
   # MacOSX only works with stateless connections and the are more
   # secure anyway - just less efficient.
   set mppe 128 stateless
   # Disable compression - freebsd clients try to use it but it breaks mppe
   disable deflate pred1
   deny deflate pred1
   set server /var/run/pptp_ppp_%d "" 0700
   accept dns              # Enable clients to request dns details
   disable ipv6cp          # Disable ipv6
   enable proxy            # Enable proxying addresses on the local net for clients

Now modify/create /etc/ppp/ppp.secret and put in it:

 someuser  userpassword  192.168.1.75

Now ’someuser’ can log in with the password ‘userpassword’ and will get an IP address of 192.168.1.75. If you don’t want to specify the ip, just leave the 3rd parameter off that line of the file.

[edit] Setup Clients

This section details how to setup various clients

[edit] Windows XP

 - Create a new VPN connection
 - Specify host
 - Specify Usename  / password
 - Hit connect

[edit] FreeBSD

Freebsd works with MPPE out the box. Simply setup the following in /etc/ppp.conf

 MYVPN:
   set authname someuser
   set authkey  userpassword
   disable pred1
   enable proxy
   disable ipv6cp
   set timeout 0
   add default HISADDR

Install pptpclient

   cd /usr/ports/net/pptpclient
   make install

Now run it with: pptp serverip MYVPN\\ ie:

  pptp  130.220.37.2 MYVPN

[edit] Mac OsX

Simply configure the GUI tool.

Stl::reverse iterator

Posted by benjsc on under Programming | Be the First to Comment

I was coding a little program a while back when I found a Quirk about the stl reverse_iterator. Use of the iterator is quite easy until you have to delete from one. I tried the normal way of:

vector<sometype>::reverse_iterator myiterator...
..
..
myvector.erase(myiterator).

only to find the code didn’t compile. A little baffled I started to looking into why. It turns out you Can’t’ delete from a reverse iterator directly. So the question is How do you delete from a reverse iterator?.

Not wanting to do a full forward traversal to get to the same point I did some Googling. Eventually I found the page: http://www.ddj.com/dept/cpp/184401406

which explains why you can’t delete from the reverse iterator. More importantly it indicates a way that you can delete from the reverse_iterator. So how?

 void Manager::raiseWindow(WMWindow* wmwindow)
 {
   vector<WMWindow*>::reverse_iterator it = windows.rbegin();
   while(it != windows.rend())
   {
     if (*it == wmwindow)
     {
      // why ++it see http://www.ddj.com/dept/cpp/184401406
      windows.erase((++it).base());
      windows.push_back(wmwindow);
      break;
     }
     it++;
   }

   wmwindow->raise();
 }

</code>

Gives an example of how to do it. However, be aware, doing the above erase, invalidates the iterator so don’t go trying to use it again afterwards! }

Splitting A Patch

Posted by benjsc on under Other | Be the First to Comment

Have you ever been working on code, gone off on a side tangent and then realized you don’t have a valid patch of the code you’ve been working on? So you run diff -du, cvs diff, git diff or some other diff and suddenly realize you have a mix of old changes and new changes. Some you want to submit, others you don’t. What you really want to do is break those changes apart and apply only the ones you want.

Sadly, there is no tool to do that.. until now!

[edit] SplitPatch.rb

Peter Hutterer, whilst working at the Wearable Computer Lab at University of South Australia faced this very problem. So he wrote the program, splitpatch.

splitpatch will allow you to take a diff of a file and either:

  • Split the patch up into change to the respective patched files
  • Split the patch up into individual hunks, where each hunk can be applied separately

[edit] Usage

To use splitpatch, you’ll need ruby installed. Then simply use:

splitpatch.rb YOURPATCHFILE

To split YOURPATCHFILE into a valid patch per file contained within the patch. Or

splitpatch.rb --hunks YOURPATCHFILE

To split the patch file into individual chunks which can be applied, using patch

[edit] Download

Splitpatch can be downloaded from:

http://www.clearchain.com/~benjsc/download/splitpatch/splitpatch.rb

[edit] Patch File Format

For those who don’t think splitpatch will do what they want, here’s at least some info about the format of a patch file.

@@ -143,6 +143,13 @@
  • the first number is the starting line for this hunk in oldfile
  • the second number is the number of original source lines in this hunk (this includes lines marked with “-”)
  • the third number is the starting line for this hunk in newfile
  • the last number is the number of lines after the hunk has been applied.

Many thanks to Peter Hutterer for this valuable trip into a patch.

Setting up Sendmail with TLS & Auth support under FreeBSD

Posted by benjsc on under FreeBSD, OpenSource | Be the First to Comment

In order to setup a secure mail transport agent (MTA) that helps eliminate some spam and also allows roaming client support, some sort of authentication mechanisim must be added when setting up a MTA. In my case I’m using FreeBSD 4.9 with sendmail as my MTA. Setting Up Sendmail

Read more of this article »

LDAPAddressBook

Posted by benjsc on under OpenSource, Projects | Be the First to Comment

LDAP is a great protocol. It allows multiple clients to obtain data about virtually anything that you can think of. The LDAPAddressBook project is a project to determine a LDAP Schema that works in the following clients:

  • Mozilla Thunderbird
  • Windows Address Book
  • OS X Address Book
  • Squirrel Mail

In fact any client that supports LDAP.

Read more of this article »

Calendar RFC’s

Posted by benjsc on under Computers | Be the First to Comment

CAP Related

  • rfc2445.txt - Internet Calendaring and Scheduling Core Object Specification (ICalendar)
  • rfc2446.txt - iCalendar Transport-Independant Interoperability Protocol (iTIP)
  • rfc2447.txt - iCalendar Message-Based Interoperability Protocol (iMIP)
  • rfc2739.txt - Calendar Attributed for vCard and LDAP
  • rfc3080.txt - The Blocks Extensible Exchange Protocol Core (BEEP)
  • rfc3081.txt - Mapping the BEEP Core onto TCP
  • rfc3283.txt - Guide to Internet Calendaring
  • draf-ietf-calsch-cap13.txt - Calendar Access Protocol (CAP)

[edit] CALDav Related

Carly Close

Posted by benjsc on under Life | Be the First to Comment

Carly and Ben met in December of 2000, a surprize date by their best friends Patrick and Anita. Over time they became friends, lovers and on the 10th of April 2004 Ben asked Carly to be his wife. Carly Agreed! So on the 23rd of April 2005 they became one.

Carly is the love of Ben’s life. A lady who is straight to the point, an excellent athlete (Softball player) and very caring. A soft side hides beneath the brashness of this Taurean. She makes my life worth living — Ben