Mimic pkg_delete default: if one of the pkg delete args contains * then switch to MATCH_GLOB
Add new pkgdb_access() function to test if process has the right
access levels to continue.  Now takes notice of $INSTALL_AS_USER in
the environment.
Use EPKG_ENOACCESS for consistency with EPKG_ENODB
Add error code for insecure permissions on databases
Rewrite pkgdb_access to actually test what we're interested in:

  * Are the permissions on the DB too lax?

  * Do we have the level of (read,write,create) access we need.

'create' access translates into 'read,write' access on the enclosing
directory.
Instead of testing geteuid() == 0, instead, test what we really mean:
the package database (local.sqlite) has secure permissions, and the
euid of the process as appropriate read / write access (including to
create the DB)
Fix brain-o.  Copy the directory, not what we just tested to be a NULL
pointer.

Tweak error message slightly.
Fixes #414 -- pkgng should be usable as an ordinary user when
INSTALL_AS_USER is set in the environment.

It's insecure if the package DB is owned by another user when root is
doing stuff.

When INSTALL_AS_USER is set, allowed owners of the pkg DB are root or
the euid of the process.  The egid of the process can have write
access.
Fix the build: don't use 'access' as a variable name because that
clashes with access() which ticks off gcc.  Add err.h to rquery.c
because without it use of warnx() ticks off clang...
Say 'yes' or '!yes' not 'yes == true' or 'yes == false'
Consistentify boolean usage
Add periodic scripts converted from pkg_install
Merge pull request #416 from aklv/periodic

Add periodic scripts converted from pkg_install
Sync usage_audit() with manual page.
Merge pull request #418 from glenbarber/master

Sync usage_audit() with manual page.
Issue 414:

Response to PR ports/175249:

Perhaps the variables could be better named: euid, egid here are the
expected user and group ownership of the various files and
directories.  I've changed them to fileowner and filegroup.

In normal use both /var/db/pkg and all the .sqlite files pkg uses
within it should be owned by root:wheel and only writeable by root.
Allowing non-root to modify the pkg DB would be a security debacle
just waiting to happen.

The change as you have it would mean that an ordinary user could not
run pkg info on a standard system.

The install_as_user flag specifically changes the requirement on
ownership so that a (non-root) user can have a personally owned copy
of a pkgng database.  Implicit in that is the assumption that they're
going to set PKG_DBDIR to put their private DB in other than the
default location.

I found and fixed a different bug to do with creating repo.sqlite the
first time ever 'pkg update' was run for a new $PKG_DBDIR, and I have
shamelessly stolen your additions to the error message in
file_mode_insecure().
Add new case insensitive match capability.

Add boolean flag to pkg_is_installed() to allow case insensitve
matching there.

Use pkg_is_installed() instead of duplicating the code in several
places.
Fix typo: the option for 'exact match' is -e
Revise pkg-set.8 to use better English.  Sort option descriptions
alphabetically, add description of '-e' for exact match.
Add '-e' option to pkg-set.  Sort options. Delete unused 'k' from
getopts() string.  Make handling of 'yes' more like other programs.