Fixed directory behavior on unspecified group.

This adds the necessary code to check the user's primary group, and
set the directory block's group to that.
Merge branch 'bugfix/directory-group' into dev
Merge branch 'dev' into stable