apalmblad/ruby-shadow — pull request #14 by caleb (2013-11-13 20:01:02+00:00)
Title: unify the OSX, BSD and Linux versions into one lib

There are two implementations of the shadow functionality in OSX, FreeBSD, and
Linux, pwd.h and shadow.h.

This version will build the correct version of the library depending on the host
operating system.

I've implemented separate libraries for each of the varients (shadow and pwd).
The build system will select which .c file to compile based on rbconf's host_os.

I've updated the README file to reflect that the library works on FreeBSD and
indicate which functions are available.

Some fixes were made to the osx branch:

* the pw_change field of the passwd structure indicates the date (in seconds since
Jan 1, 1970) when the password MUST be changed, not the date when the password
was last changed, as was implemented in the original osx branch.

I've created a new field, pw_change, that will hold this field

* the original osx implementation did not correctly calculate the seconds since
Jan 1, 1970 of the two date fields. Parenthesis needed to be added for order
of operations reasons, and the result needed to be run through INT2FIX to properly
store the value in a Ruby fixnum.

* FreeBSD does not have uuid/uuid.h but instead uuid.h, so I perform a test in
exconf.rb to determine which one to use.

Some other fixes/adjustments were made to the master branch:

* When calling putspent or fgetspent on Linux we'd get a core dump. Using the
function rb_io_stdio_file to grab the stdio file handle instead of directly
using the stdio_file member fixed the problem.

* I added the pw_change field used by the pwd.h implementation, but set the value
to nil whenever an Entry is created

I've tested this library on Ruby 1.8.7-p374, 1.9.3-p448, and 2.0.0-p247 on:

Ubuntu 12.04
OS X 10.9
FreeBSD 9.1