Prevent potentially unterminated buffers while adding rule to the list

Functions smack_accesses_add() and smack_accesses_add_modify() don't check
length of arguments subject and object. These arguments are used as source
for strncpy(), which can cause labels to be truncated.

But the length argument for strncpy() is too large. This might cause
rule->subject or rule->object to be not terminated by null character.
It can happen when these functions are called from outside libsmack.
It can also happen while parsing files in smack_accesses_add_from_file(),
because that function doesn't validate subject and object too.

This commit fixes the problem by checking arguments in smack_accesses_add()
and smack_accesses_add_modify(). After checking strcpy() is safe for
copying them.
Avoid memory allocation while opening smackfs files.

Using openat() on pre-opened smackfs directory eliminates need to construct
absolute path to a smackfs file before opening it.
Merge pull request #13 from rafal-krypa/samsung

Samsung
Cleaned up command line arguments handling in chsmack.

Argument handling code looks terrible at the moment in chsmack.
Migrated to getopt_long().
Added AUTHORS file.
Revert "Avoid memory allocation while opening smackfs files."

This reverts commit 6c1d15b1fe420b848d7afdd0a7ef0c20dfdcc08e.
Removed redundant is_smackfs_mounted().

This functionality is fully handled in the library initialization.
Major documentation cleanup.

smack.h was starting to rotten so I did a major cleanup for it.
Also fixed couple of minor doxygen issues by removing deprecated
variables.
Update version and maintainer information

Set version information to 1.1 for the next libsmack release.
Change maintainer email from @intel.com to @linux.intel.com.
Cleaned up init code.

There was lot of clutter and misleading comments in the code
and some minor coding convention issues. This patch cleans up
init.c for the most part.
libsmack: clean up smack_accesses_add_modify()

This patch makes smack_accesses_add_modify() easier to follow by
changing variable names bit more self-documentative and less easier
to mix up with adding and deleting rules. This patch also fixes some
very minor coding style errors.

Also documentation of this function is cleaned up.
Fixes for doxygen errors coming from 3810596.

Doxygen errors that are regression from 3810596. Went in because
I forgot to install doxygen into my test environment.
Documented order in which access rules are applied to kernel.
Fix: allow CIPSO labels with zero categories

There was false restriction in smack_cipso_add_from_file() that
disallowed CIPSO labels without categories.

For example, this example given in the SMACK kernel documentation
should be perfectly legal:

TopSecret 7
Change apply_cipso_cb() to use proper apply_cipso_file()

apply_cipso_cb() used improper apply_rules_file(). Changed this to
call apply_cipso_file() instead.
Merge branch 'cipso_bug' of git://github.com/zos/smack into zos-cipso_bug
Fix: accept 255 character labels

Example:

 # /home/jsakkine/devel/smack/utils/chsmack \
   -a$(printf '12345%.0s' {1..51}) foo
 foo: Invalid argument
 # /home/jsakkine/devel/smack/utils/chsmack \
   -a$(printf '12345%.0s' {1..51} | head -c -1) foo
 #

This patch fixes this issue.
utils/chsmack: fix hazardous option parsing

The variable option_index was only set to a proper value if the
given option is a long option. There was also exit() missing on
error condition if SMACK label was invalid.

This patch removes option_index, parameter name from corresponding
error message and adds exit() call when the error condition
realizes.

[jarkko.sakkinen@linux.intel.com: rewrote patch description]
Add parameter name back to the chsmack error message

This patch add parameter name back to the error message. Instead
of relaying on hazardous longindex parameter of getopt_long(), a
look-up table is constructed to map short option to the corresponding
struct option entry.

Additionally, the basename of the application is added to the error
message. Also usage message is converted to use basename instead of
the full path name.
Cleaning error logs for rules applying utilities

Removed perror logs from main utilities files. Moved error logs
inside /utils/common.c. Errors are logged from I/O operations and
applying rules/cipso from files.