Register correct handlers for nvlist_{dup,pack,unpack}

This change is related to commit 81eaf15 which ensured the correct
allocation handlers were installed for nvlist_alloc().  The nvlist
functions nvlist_dup(), nvlist_pack(), and nvlist_unpack() suffer
from the same issue and have been updated accordingly.

Signed-off-by: Ned Bass <bass6@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue #1937
Properly handle updates of variably-sized SA entries.

During the update process in sa_modify_attrs(), the sizes of existing
variably-sized SA entries are obtained from sa_lengths[]. The case where
a variably-sized SA was being replaced neglected to increment the index
into sa_lengths[], so subsequent variable-length SAs would be rewritten
with the wrong length. This patch adds the missing increment operation
so all variably-sized SA entries are stored with their correct lengths.

Previously, a size-changing update of a variably-sized SA that occurred
when there were other variably-sized SAs in the bonus buffer would cause
the subsequent SAs to be corrupted.  The most common case in which this
would occur is when a mode change caused the ZPL_DACL_ACES entry to
change size when a ZPL_DXATTR (SA xattr) entry already existed.

The following sequence would have caused a failure when xattr=sa was in
force and would corrupt the bonus buffer:

	open(filename, O_WRONLY | O_CREAT, 0600);
	...
	lsetxattr(filename, ...);	/* create xattr SA */
	chmod(filename, 0650);		/* enlarges the ACL */

Signed-off-by: Chris Dunlop <chris@onthe.net.au>
Signed-off-by: Ned Bass <bass6@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #1978
This is iSCSI sharing for ZoL (shareiscsi).
* Support retrieving active iSCSI sessions:
  + Move nfs.c:foreach_nfs_shareopt() to libshare.c:foreach_shareopt()
    so that it can be (re)used in smb.c and iscsi.c.
  + Add support for options to 'shareiscsi'.
    + name/iqn	Full iSCSI Qualified Name (IQN), including identifier
		Default: Generated by iscsi_generate_target()
			 => iqn.YYYY-MM.tld.domain:dataset
    + lun	LUN (0-16384)
		Default: 0
    + type	Share mode (fileio, blockio, nullio, disk, tape)
		Default: blockio
    + iomode	IO mode (wb, wt, ro)
		Default: wt
    + blocksize	Logical block size (512, 1024, 2048, 4096)
		Default: Volume blocksize, 4096 if not usable.
  + If not called with a name= value, then force setting it.
    This so that the IQN doesn't change every month (when
    it is regenerated again).
* Support for SCST iSCSI implementation.
* Retrive active iSCSI sessions
* Enum values for iscsi_implementation.
* Try to improve performance
  + We check for iSCSI availability in the init function only
    Limits the number of times we do this - it takes time...
  + Use stat() instead of opendir()/closedir().
  + Since iscsi_targets is global, we only retreive targets if it's NULL
    in iscsi_retrieve_targets(). It should limit the number of times we
    fork() and read targets AND sessions.
* Use ZVOL_DIR (/dev) and ZVOL_DRIVER (zvol) instead of hardcoded '/dev/zvol'.
* Run cstyle.pl to fix any code style problems.
Rewrite of the Libshare/SMBFS
* Add support for options to 'sharesmb'.
  Fixes: #1182
  + Move nfs.c:foreach_nfs_shareopt() to libshare.c:foreach_shareopt()
    so that it can be (re)used in smb.c (and later iscsi.c).
  + Call net(8) with the guest_ok option.
  + Rewrite the sharesmb part of the zfs(8) manpage.
    + Add more examples
    + Inform about the (new) options to sharesmb.
  + Add STDERR_VERBOSE to libzfs_run_process() so that we
    can catch any errors from net(8).
  + Don't call smb_retrieve_shares() after enabling a share.
    No point, it's done when really needed anyway.
  + Support 'y', 'yes' and 'true' for guest_ok.
  * If sharesmb=on, just exit cleanly directly at the top of
    get_smb_shareopts_cb().
  * Remove param 2 and 3 from smb_enable_share_one(). That is
    availible in the first param - the impl_share struct.
  * Extra debugging added in smb_enable_share_one() - print
    all our options just before we call net(8).
* Add support for optional, extra script /sbin/zfs_share_smbfs
  to run after shareing is done.
  + Add an example zfs_share_smbfs script
* The option sharesmb should not be inherited by childs.
  Samba is perfectly able to show child file systems...
* Use dataset name in comment, not the smb share name.
* Use REGISTRY SHARES instead of USER SHARES
  + These are a lot more configurable (more possibility to customize the share).
  + Remove the 'acl' option and replace it with 'writeable' instead.
  + On some machines, there is a "global" share. This isn't really a share,
    but the possibility to modify global options. So first get a line of
    _real_ shares using 'net conf listshares' and _then_ cyckle through
    them retrieving info with 'net conf showshare <share>'.
  + Add an example on how to modify a share after ZFS share and what man
    pages to use for more info.
* Speedups (less share retreivals) and make sure the 'net' command is executable.
  + Since smb_shares is global, we only retreive shares if it's NULL
    in smb_retrieve_shares(). It should limit the number of times we
    fork() and read shares (which takes time).
  + If the net command don't exist (is executable), don't even register
    the smb fstype in libshare_smb_init().
  + access() fix - check if NET_CMD_PATH is _executable_ not just 'exists'.
* Run cstyle.pl to fix any code style problems.
Make sure 'everyone' knows about changes to the sharetab.
+ Instead of opening a temporary sharetab and then renaming
  it, just open it with freopen() writeable and write the info.
  + If sharetab isn't opened, open it with fopen() instead of
    freopen() to avoid segfault if it doesn't exist.
Don't open sharetab in parse_sharetab() - it's already open!
+ Reuse the handle, fseek to beginning and read...
Change disable/enable flags to booleans.
Merge commit 'turbo/bools' into 0.6.3-turbo+updates
Merge commit 'turbo/iscsi' into 0.6.3-turbo+updates
Merge commit 'turbo/libshare_improvenments' into 0.6.3-turbo+updates
Merge commit 'turbo/smbfs_registry-shares' into 0.6.3-turbo+updates
Remove an extraneous ZFS_PROP_SHAREISCSI added in the previous force merge.
Fix some problems introduced in previous force merge.
Readd missing EZFS_KEYERR which was removed in previous force merge.
Bump release.