platform/upstream/smack.git
10 years agolibsmack: clean up redundant stuff
Jarkko Sakkinen [Thu, 5 Dec 2013 18:18:02 +0000 (20:18 +0200)]
libsmack: clean up redundant stuff

Cleaned up redundant constants and code. Grouped related constants
nearby each other.

Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
(cherry picked from commit d6f8c52011013f536b7171c2d1f3e9c5ecfaf2f9)

10 years agoMerge branch 'v1.0.x'
Jarkko Sakkinen [Thu, 5 Dec 2013 18:12:18 +0000 (20:12 +0200)]
Merge branch 'v1.0.x'

10 years agolibsmack: add support for new access mode for setting locks ("l")
Rafal Krypa [Mon, 22 Jul 2013 17:05:09 +0000 (19:05 +0200)]
libsmack: add support for new access mode for setting locks ("l")

This change should be backward compatible for kernels without l-mode support
as long as requested permissions don't contain this mode.

Signed-off-by: Rafal Krypa <r.krypa@samsung.com>
10 years agoMerge branch 'v1.0.x'
Jarkko Sakkinen [Thu, 5 Dec 2013 17:27:49 +0000 (19:27 +0200)]
Merge branch 'v1.0.x'

10 years agoutils: common.c: invalid fprintf()
Jarkko Sakkinen [Thu, 5 Dec 2013 17:26:01 +0000 (19:26 +0200)]
utils: common.c: invalid fprintf()

fprintf() has path parameter that was not utilized.

Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
10 years agoutils: apply access rules to load/load2 in one shot
Jarkko Sakkinen [Thu, 28 Nov 2013 23:09:22 +0000 (01:09 +0200)]
utils: apply access rules to load/load2 in one shot

Open load/load2 only once. Inside the callback only collect rules
using smack_accessed_add_from_file(). Finally, apply access rules
in a single slot.

This was inspired by feedback from Rafal Krypa <r.krypa@samsung.com>.

Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
10 years agoMerge branch 'v1.0.x'
Jarkko Sakkinen [Tue, 3 Dec 2013 16:29:34 +0000 (18:29 +0200)]
Merge branch 'v1.0.x'

10 years agoDo not silently ignore files when applying them in smackload/ctl v1.0.2
Jarkko Sakkinen [Tue, 3 Dec 2013 16:22:55 +0000 (18:22 +0200)]
Do not silently ignore files when applying them in smackload/ctl

Detect unknown file types and non-regular files and fail if they
are found with proper error reporting.

Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
10 years agoMerge branch 'v1.0.x'
Jarkko Sakkinen [Mon, 2 Dec 2013 17:36:06 +0000 (19:36 +0200)]
Merge branch 'v1.0.x'

10 years agoMerge remote-tracking branch 'jsakkine/issue60' into v1.0.x
Jarkko Sakkinen [Mon, 2 Dec 2013 17:34:51 +0000 (19:34 +0200)]
Merge remote-tracking branch 'jsakkine/issue60' into v1.0.x

10 years agoMerge branch 'v1.0.x'
Jarkko Sakkinen [Mon, 2 Dec 2013 17:12:29 +0000 (19:12 +0200)]
Merge branch 'v1.0.x'

10 years agoMerge remote-tracking branch 'rafal-krypa/issue70' into v1.0.x
Jarkko Sakkinen [Mon, 2 Dec 2013 16:22:49 +0000 (18:22 +0200)]
Merge remote-tracking branch 'rafal-krypa/issue70' into v1.0.x

10 years agosmackctl: fix reporting "unknown action" (regression in ce452ab)
Rafal Krypa [Mon, 2 Dec 2013 14:04:37 +0000 (15:04 +0100)]
smackctl: fix reporting "unknown action" (regression in ce452ab)

Running "smackctl apply" and "smackctl clear" ended with error and
message about unknown action, although the action was known and
performed successfully.

Signed-off-by: Rafal Krypa <r.krypa@samsung.com>
10 years agolibsmack: fix smack_cipso_apply() failing with more than one rule
Rafal Krypa [Mon, 2 Dec 2013 15:03:28 +0000 (16:03 +0100)]
libsmack: fix smack_cipso_apply() failing with more than one rule

Fixing regression in f47b9c90 that causes smack_cipso_apply() to fail due
to a typo.

Signed-off-by: Rafal Krypa <r.krypa@samsung.com>
10 years agolibsmack: remove redundant check for clear flag form accesses_apply()
Jarkko Sakkinen [Sun, 1 Dec 2013 15:03:55 +0000 (17:03 +0200)]
libsmack: remove redundant check for clear flag form accesses_apply()

Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
10 years agolibsmack: remove redundant strlen() call from accesses_apply()
Jarkko Sakkinen [Sun, 1 Dec 2013 15:01:42 +0000 (17:01 +0200)]
libsmack: remove redundant strlen() call from accesses_apply()

Return value of snprintf() should give the same length as strlen()
would given that string fits into buffer.

Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
10 years agolibsmack: check in accesses_apply() that rule has short labels
Jarkko Sakkinen [Sun, 1 Dec 2013 14:51:04 +0000 (16:51 +0200)]
libsmack: check in accesses_apply() that rule has short labels

Check rule has short labels when only 'load' is available.

Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
10 years agoMerge branch 'v1.0.x'
Jarkko Sakkinen [Mon, 2 Dec 2013 06:39:34 +0000 (08:39 +0200)]
Merge branch 'v1.0.x'

10 years agoMerge remote-tracking branch 'rafal-krypa/issue68' into v1.0.x
Jarkko Sakkinen [Mon, 2 Dec 2013 06:33:00 +0000 (08:33 +0200)]
Merge remote-tracking branch 'rafal-krypa/issue68' into v1.0.x

10 years agolibsmack: early fail in accesses_apply() if modify rules are not supported
Jarkko Sakkinen [Sun, 1 Dec 2013 14:43:14 +0000 (16:43 +0200)]
libsmack: early fail in accesses_apply() if modify rules are not supported

In accesses_apply(), in the beginning of each iteration, check
that change_fd is a valid file descriptor if the current rule
is a modify rule. Return with -1 immediately if that is not the
case.

Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
10 years agolibsmack: parse whole access type string, not only first 5 bytes.
Rafal Krypa [Thu, 3 Jan 2013 09:34:34 +0000 (10:34 +0100)]
libsmack: parse whole access type string, not only first 5 bytes.

Previous version of this function parsed only first ACC_LEN (5)
characters of access_type. Now the whole string will be read.

This will prevent silent ignoring of access type characters in cases
like "-rwxat" or "rrwxat".

Re-applying because it was reverted by d2283792.

10 years agolibsmack: fixed segfault in get_label() (regression in 66483b)
Rafal Krypa [Fri, 29 Nov 2013 19:42:25 +0000 (20:42 +0100)]
libsmack: fixed segfault in get_label() (regression in 66483b)

Commit 66483b introduced segfault in API functions smack_revoke_subject()
and smack_set_label_for_self().
Fix the accidental NULL pointer dereference.

10 years agoMerge branch 'v1.0.x'
Jarkko Sakkinen [Thu, 28 Nov 2013 16:05:17 +0000 (18:05 +0200)]
Merge branch 'v1.0.x'

10 years agoMerge remote-tracking branch 'jsakkine/issue64' into v1.0.x
Jarkko Sakkinen [Thu, 28 Nov 2013 16:04:12 +0000 (18:04 +0200)]
Merge remote-tracking branch 'jsakkine/issue64' into v1.0.x

10 years agolibsmack: fixed apply_accesses() (regression in d2283792)
Jarkko Sakkinen [Thu, 28 Nov 2013 15:49:47 +0000 (17:49 +0200)]
libsmack: fixed apply_accesses() (regression in d2283792)

Took accesses_apply() from 8fd0167 and converted it mechanically
as possible to use the changed struct smack_rule. Now smackload
works succesfully for a single file too. Mistake I did in
d2283792 was that I unncessarily cleaned up accesses_apply()
at the same time as changing things. My bad.

Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
10 years agoisgx: fix: clear flag for directory parameter in smackload/smackctl
Jarkko Sakkinen [Wed, 27 Nov 2013 22:03:06 +0000 (00:03 +0200)]
isgx: fix: clear flag for directory parameter in smackload/smackctl

Clear flag was not properly applied when directory is given
for smackload. This patch fixes the issue. I decided to move
into opendir/readdir approach because nftw() does not support
supplying any kind of state to the callback. The end result
looks also more manageable that we had before.

Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
10 years agoMerge branch 'v1.0.x'
Jarkko Sakkinen [Wed, 27 Nov 2013 12:17:45 +0000 (14:17 +0200)]
Merge branch 'v1.0.x'

10 years agodebian: enable parallel build.
Rafal Krypa [Thu, 21 Nov 2013 12:42:24 +0000 (13:42 +0100)]
debian: enable parallel build.

Support `dpkg-buildpackage -j' by adding --parallel to dh invocations.

10 years agodebian: convert for multi-arch packages.
Rafal Krypa [Fri, 3 May 2013 12:04:51 +0000 (14:04 +0200)]
debian: convert for multi-arch packages.

10 years agodebian: add build dependency on doxygen.
Rafal Krypa [Fri, 22 Nov 2013 09:45:45 +0000 (10:45 +0100)]
debian: add build dependency on doxygen.

Make sure that devel manuals will be generated for libsmack-dev package.

10 years agoMerge branch 'v1.0.x'
Jarkko Sakkinen [Wed, 27 Nov 2013 12:07:06 +0000 (14:07 +0200)]
Merge branch 'v1.0.x'

10 years agolibsmack: revert access codes
Jarkko Sakkinen [Tue, 26 Nov 2013 19:02:05 +0000 (21:02 +0200)]
libsmack: revert access codes

Revert access codes as internal representation for access types
because they work much better when we have to merge rules.

Other aim of this patch is to clean up internal presentation.
After this change the whole access state can be represented
with only two integers.

Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
10 years agoMerge remote-tracking branch 'smack-1.0.x/master'
Jarkko Sakkinen [Mon, 25 Nov 2013 14:07:17 +0000 (16:07 +0200)]
Merge remote-tracking branch 'smack-1.0.x/master'

10 years agoutils: more verbose error reporting when applying rules
Jarkko Sakkinen [Mon, 25 Nov 2013 13:08:20 +0000 (15:08 +0200)]
utils: more verbose error reporting when applying rules

Add more verbose error reporting when applying either access
rules or CIPSO. The key point is to be able to separate whether
error occured during reading or applying phase.

Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
10 years agoMerge remote-tracking branch 'smack-1.0.x/master'
Jarkko Sakkinen [Mon, 25 Nov 2013 14:00:45 +0000 (16:00 +0200)]
Merge remote-tracking branch 'smack-1.0.x/master'

10 years agoFix memory leak on smack_cipso
Zofia Abramowska [Fri, 22 Nov 2013 09:38:06 +0000 (10:38 +0100)]
Fix memory leak on smack_cipso

smack_cipso_free() didn't release main pointer, which was
inconsistent with header description and further usage in
apply_cipso_file().
(cherry picked from commit 6304f9a3f73312a7feb3b25fa593919744acb947)

10 years agoutils: fix CIPSO error messages in common.c
Jarkko Sakkinen [Thu, 21 Nov 2013 18:50:37 +0000 (20:50 +0200)]
utils: fix CIPSO error messages in common.c

When applying CIPSO fails use different error message than when
applying access rules. Additionally, fixed indentation for lines
printing error message that are over 80 characters long.
(cherry picked from commit 43b5e8da94acba1f790eb65b4256ba6013397dde)

10 years agoFix memory leak on smack_cipso
Zofia Abramowska [Fri, 22 Nov 2013 09:38:06 +0000 (10:38 +0100)]
Fix memory leak on smack_cipso

smack_cipso_free() didn't release main pointer, which was
inconsistent with header description and further usage in
apply_cipso_file().

10 years agoutils: fix CIPSO error messages in common.c
Jarkko Sakkinen [Thu, 21 Nov 2013 18:50:37 +0000 (20:50 +0200)]
utils: fix CIPSO error messages in common.c

When applying CIPSO fails use different error message than when
applying access rules. Additionally, fixed indentation for lines
printing error message that are over 80 characters long.

10 years agodoc: show version
Jarkko Sakkinen [Thu, 21 Nov 2013 15:36:35 +0000 (17:36 +0200)]
doc: show version

Fix documentation to show correct package version.
(cherry picked from commit 399e3a662c0ddb81cae94804a96416ae856e7507)

10 years agodoc: fix parallel build, broken by c5e2007.
Rafal Krypa [Thu, 21 Nov 2013 12:40:08 +0000 (13:40 +0100)]
doc: fix parallel build, broken by c5e2007.

Parallel make failed, because dependencies were not properly specified
for all auto generated man pages.
(cherry picked from commit d9e0abc8657dc1ee5aab391af4543a7cd1c9d757)

10 years agodebian: fix package build, broken by c5e2007.
Rafal Krypa [Thu, 21 Nov 2013 11:47:26 +0000 (12:47 +0100)]
debian: fix package build, broken by c5e2007.

Auto generated manpages are in different locations than static ones, so
libsmack-dev.manpages needs to be modified.
It now includes all generated section 3 manuals.
(cherry picked from commit b3b70c21b75cc5e92d7334406557a8f49d0b4714)

10 years agodoc: show version
Jarkko Sakkinen [Thu, 21 Nov 2013 15:36:35 +0000 (17:36 +0200)]
doc: show version

Fix documentation to show correct package version.

10 years agodoc: fix parallel build, broken by c5e2007.
Rafal Krypa [Thu, 21 Nov 2013 12:40:08 +0000 (13:40 +0100)]
doc: fix parallel build, broken by c5e2007.

Parallel make failed, because dependencies were not properly specified
for all auto generated man pages.

10 years agodebian: fix package build, broken by c5e2007.
Rafal Krypa [Thu, 21 Nov 2013 11:47:26 +0000 (12:47 +0100)]
debian: fix package build, broken by c5e2007.

Auto generated manpages are in different locations than static ones, so
libsmack-dev.manpages needs to be modified.
It now includes all generated section 3 manuals.

10 years agoGenerate API documentation by using Doxygen.
Jarkko Sakkinen [Tue, 19 Nov 2013 20:34:02 +0000 (22:34 +0200)]
Generate API documentation by using Doxygen.

Generate API documentation from smack.h by using Doxygen so that
documentation needs to be maintained only in one place.
(cherry picked from commit c5e200768a99451c559570b0a44673a8ecd5ee7f)

Conflicts:

doc/Makefile.am
doc/smack_have_access.3

10 years agoMerge remote-tracking branch 'jsakkine/issue45'
Jarkko Sakkinen [Thu, 21 Nov 2013 09:10:56 +0000 (11:10 +0200)]
Merge remote-tracking branch 'jsakkine/issue45'

10 years agoSolve problem with "make distcheck" breaking on systemd config files.
Rafal Krypa [Wed, 20 Nov 2013 11:47:26 +0000 (12:47 +0100)]
Solve problem with "make distcheck" breaking on systemd config files.

Dist packages created by "make dist" were built without smack.mount and
smack.service files. This caused the packages to fail to build.
Adding the files to EXTRA_DIST solves the problem.
(cherry picked from commit 73ec7d5be2c87bf13dbd45f2cb8433122b1bd08d)

10 years agoSolve problem with "make distcheck" breaking on systemd config files.
Rafal Krypa [Wed, 20 Nov 2013 11:47:26 +0000 (12:47 +0100)]
Solve problem with "make distcheck" breaking on systemd config files.

Dist packages created by "make dist" were built without smack.mount and
smack.service files. This caused the packages to fail to build.
Adding the files to EXTRA_DIST solves the problem.

10 years agoCopy labels using get_label()
Jarkko Sakkinen [Tue, 19 Nov 2013 13:07:17 +0000 (15:07 +0200)]
Copy labels using get_label()

Copy and validate labels in a single transaction:

- No trust for having '\0' in the src buffer when copying
  labels.
- Improves performance by combining length calculation, validation
  and copying.
(cherry picked from commit 16f84d57e2766f1ccfd59ae77fad407b6cc5ff81)

10 years agoHelper function get_label()
Jarkko Sakkinen [Tue, 19 Nov 2013 11:49:37 +0000 (13:49 +0200)]
Helper function get_label()

The helper function ssize_t get_label(char *dest, const char *src)
validates the given label and copies it to the dest buffer if
available.
(cherry picked from commit 09fdff9a456dec54a4c8548c9b9acbcbce48d59a)

10 years agoGenerate API documentation by using Doxygen.
Jarkko Sakkinen [Tue, 19 Nov 2013 20:34:02 +0000 (22:34 +0200)]
Generate API documentation by using Doxygen.

Generate API documentation from smack.h by using Doxygen so that
documentation needs to be maintained only in one place.

10 years agoUse strncpy() always copying labels.
Jarkko Sakkinen [Mon, 18 Nov 2013 16:04:03 +0000 (18:04 +0200)]
Use strncpy() always copying labels.

Defence in depth and a good practice. Places an absolute limit
to the length copied.
(cherry picked from commit 0eee8f8b3efd153c5ef09c08244e189f0cda51a4)

10 years agoFixed copyright clauses.
Jarkko Sakkinen [Thu, 14 Nov 2013 15:29:05 +0000 (17:29 +0200)]
Fixed copyright clauses.

Checked that copyright notices are properly set up as according to:

http://www.gnu.org/licenses/gpl-howto.html

Corrected where they are not. Note that one or two-line fixes do not
count as copyrightable assets.

Additionally, fixed a minor indentation issue in chsmack.c.
(cherry picked from commit 7b41f3cff96755146539f74a8c780ac9bbe71b36)

10 years agoCopy labels using get_label()
Jarkko Sakkinen [Tue, 19 Nov 2013 13:07:17 +0000 (15:07 +0200)]
Copy labels using get_label()

Copy and validate labels in a single transaction:

- No trust for having '\0' in the src buffer when copying
  labels.
- Improves performance by combining length calculation, validation
  and copying.

10 years agoHelper function get_label()
Jarkko Sakkinen [Tue, 19 Nov 2013 11:49:37 +0000 (13:49 +0200)]
Helper function get_label()

The helper function ssize_t get_label(char *dest, const char *src)
validates the given label and copies it to the dest buffer if
available.

10 years agoMerge remote-tracking branch 'jarkkos/strcpy-fix'
Jarkko Sakkinen [Tue, 19 Nov 2013 08:36:52 +0000 (10:36 +0200)]
Merge remote-tracking branch 'jarkkos/strcpy-fix'

10 years agoMerge remote-tracking branch 'jarkkos/copyright-fix'
Jarkko Sakkinen [Tue, 19 Nov 2013 08:34:50 +0000 (10:34 +0200)]
Merge remote-tracking branch 'jarkkos/copyright-fix'

10 years agoRegression fix: don't modify smack_accesses while applying the rules.
Rafał Krypa [Thu, 14 Nov 2013 23:58:22 +0000 (00:58 +0100)]
Regression fix: don't modify smack_accesses while applying the rules.

Regression introduced in eaf908fd caused access_type field to be modified,
when smack_accesses_apply() is called with clear set to true.

This patch reverts that, restoring invariant that smack_accessess_apply()
doesn't modify given rule set.
(cherry picked from commit 74f5b5c21a2ed9c0576c3c3ab3802d11d66098a9)

10 years agoUse strncpy() always copying labels.
Jarkko Sakkinen [Mon, 18 Nov 2013 16:04:03 +0000 (18:04 +0200)]
Use strncpy() always copying labels.

Defence in depth and a good practice. Places an absolute limit
to the length copied.

10 years agoFixed copyright clauses.
Jarkko Sakkinen [Thu, 14 Nov 2013 15:29:05 +0000 (17:29 +0200)]
Fixed copyright clauses.

Checked that copyright notices are properly set up as according to:

http://www.gnu.org/licenses/gpl-howto.html

Corrected where they are not. Note that one or two-line fixes do not
count as copyrightable assets.

Additionally, fixed a minor indentation issue in chsmack.c.

10 years agoRegression fix: don't modify smack_accesses while applying the rules.
Rafał Krypa [Thu, 14 Nov 2013 23:58:22 +0000 (00:58 +0100)]
Regression fix: don't modify smack_accesses while applying the rules.

Regression introduced in eaf908fd caused access_type field to be modified,
when smack_accesses_apply() is called with clear set to true.

This patch reverts that, restoring invariant that smack_accessess_apply()
doesn't modify given rule set.

10 years agoFix man pages
Jarkko Sakkinen [Wed, 30 Oct 2013 13:52:19 +0000 (15:52 +0200)]
Fix man pages

Regression from 1edba54.
(cherry picked from commit e6f32e4403ad549102cfbdbd02b4dcd254da84d2)

10 years agoUse smack_label_length() internally instead strnlen()
Janusz Kozerski [Mon, 28 Oct 2013 13:28:59 +0000 (14:28 +0100)]
Use smack_label_length() internally instead strnlen()

Use smack_label_length() to check correctness labels instead strnlen().
(cherry picked from commit 6d3fd3049e08377f75b554cedcd200286fbf359c)

10 years agoFix value returned by smack_label_length()
Janusz Kozerski [Mon, 28 Oct 2013 13:44:05 +0000 (14:44 +0100)]
Fix value returned by smack_label_length()

In some cases smack_label_length have returned 0 on incorrect label.
Now smack_label_length() always returns -1 in case of incorrect label.
(cherry picked from commit f7e4232a319b269f6214af660173eebaa605ad9e)

10 years agoFix man pages
Jarkko Sakkinen [Wed, 30 Oct 2013 13:52:19 +0000 (15:52 +0200)]
Fix man pages

Regression from 1edba54.

10 years agoUse smack_label_length() internally instead strnlen()
Janusz Kozerski [Mon, 28 Oct 2013 13:28:59 +0000 (14:28 +0100)]
Use smack_label_length() internally instead strnlen()

Use smack_label_length() to check correctness labels instead strnlen().

10 years agoFix value returned by smack_label_length()
Janusz Kozerski [Mon, 28 Oct 2013 13:44:05 +0000 (14:44 +0100)]
Fix value returned by smack_label_length()

In some cases smack_label_length have returned 0 on incorrect label.
Now smack_label_length() always returns -1 in case of incorrect label.

10 years agoRemove errno assignments
Jarkko Sakkinen [Fri, 25 Oct 2013 13:06:28 +0000 (16:06 +0300)]
Remove errno assignments

If we want to report something libsmack specific, then we should
have our own error codes. By using errno values to report libsmack
specific error condition we almost zero their value. By removing
these assignment you can resolved from a changed errno value that
a system call failed.

This patch does not break API contract as use of errno values is
undefined in the API documentation.
(cherry picked from commit 1edba541de63b088a60d89e4a0433bf9149c4b13)

10 years agoMerge remote-tracking branch 'jarkkos/errno-cleanup'
Jarkko Sakkinen [Mon, 28 Oct 2013 12:59:06 +0000 (14:59 +0200)]
Merge remote-tracking branch 'jarkkos/errno-cleanup'

10 years agoRemove errno assignments
Jarkko Sakkinen [Fri, 25 Oct 2013 13:06:28 +0000 (16:06 +0300)]
Remove errno assignments

If we want to report something libsmack specific, then we should
have our own error codes. By using errno values to report libsmack
specific error condition we almost zero their value. By removing
these assignment you can resolved from a changed errno value that
a system call failed.

This patch does not break API contract as use of errno values is
undefined in the API documentation.

10 years agoFix: smack_label_length(): int -> ssize_t
Jarkko Sakkinen [Fri, 25 Oct 2013 12:58:48 +0000 (15:58 +0300)]
Fix: smack_label_length(): int -> ssize_t

10 years agoRemoved smack_label_length() API
Jarkko Sakkinen [Fri, 25 Oct 2013 12:46:56 +0000 (15:46 +0300)]
Removed smack_label_length() API

In order to use this smack_label_length() in 1.0 branch, this patch
takes it away from the API. Adds temporarily unused attribute to the
function siganture.

10 years agoAdd smack_label_length() function
Janusz Kozerski [Wed, 2 Oct 2013 07:52:23 +0000 (09:52 +0200)]
Add smack_label_length() function

Kernel does not validate the Smack label - instead the label will be
cut on the first incorrect character (after parsing at least one
correct character).

This function gives the user possibility to verify the correctness
of the Smack label before use and calculate labels length.

Additionally, all string length calculations are replaces with this
function to make implementation safer.

[jarkko.sakkinen@linux.intel.com:
 did some modifications:
 - smack_is_label_valid() -> smack_label_length()
 - libsmack.c:
   * return length
   * loop invariant had off-by-one error
   * cosmetic: "++i" not "i++"
 - libsmack.h:
   * updated documentation
   * cosmetic: formatting errors in  @param and @return]
(cherry picked from commit 8b083a8c67219c5d1dbfbf2ad1082c1954f9c9fa)

10 years agoAdd smack_label_length() function
Janusz Kozerski [Wed, 2 Oct 2013 07:52:23 +0000 (09:52 +0200)]
Add smack_label_length() function

Kernel does not validate the Smack label - instead the label will be
cut on the first incorrect character (after parsing at least one
correct character).

This function gives the user possibility to verify the correctness
of the Smack label before use and calculate labels length.

Additionally, all string length calculations are replaces with this
function to make implementation safer.

[jarkko.sakkinen@linux.intel.com:
 did some modifications:
 - smack_is_label_valid() -> smack_label_length()
 - libsmack.c:
   * return length
   * loop invariant had off-by-one error
   * cosmetic: "++i" not "i++"
 - libsmack.h:
   * updated documentation
   * cosmetic: formatting errors in  @param and @return]

10 years agoCleaning error logs for rules applying utilities
Zofia Abramowska [Tue, 6 Aug 2013 13:42:33 +0000 (15:42 +0200)]
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.
(cherry picked from commit bcaf9018f41809cb93aaccf9e9fb49b59750dc7e)

10 years agoCleaning error logs for rules applying utilities
Zofia Abramowska [Tue, 6 Aug 2013 13:42:33 +0000 (15:42 +0200)]
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.

10 years agoAdd parameter name back to the chsmack error message
Jarkko Sakkinen [Tue, 22 Oct 2013 19:26:26 +0000 (22:26 +0300)]
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.
(cherry picked from commit d98a04ff7ccbcfcf36d9d4d43de68448b70da9fa)

10 years agoutils/chsmack: fix hazardous option parsing
José Bollo [Mon, 21 Oct 2013 10:18:50 +0000 (12:18 +0200)]
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]
(cherry picked from commit 18ebc2fe71da94599e45029d7b26144c6bbe7cb4)

10 years agoAdd parameter name back to the chsmack error message
Jarkko Sakkinen [Tue, 22 Oct 2013 19:26:26 +0000 (22:26 +0300)]
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.

10 years agoutils/chsmack: fix hazardous option parsing
José Bollo [Mon, 21 Oct 2013 10:18:50 +0000 (12:18 +0200)]
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]

10 years agoFix: accept 255 character labels
Jarkko Sakkinen [Mon, 21 Oct 2013 16:21:42 +0000 (19:21 +0300)]
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.
(cherry picked from commit 1794fed08418b0e254e1e3a7325a8a67f8186bbc)

10 years agoFix: accept 255 character labels
Jarkko Sakkinen [Mon, 21 Oct 2013 16:21:42 +0000 (19:21 +0300)]
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.

10 years agoChange apply_cipso_cb() to use proper apply_cipso_file()
Zofia Abramowska [Tue, 8 Oct 2013 14:24:24 +0000 (16:24 +0200)]
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.
(cherry picked from commit d45ffe9082243377cdba9a2d224bab0e110501e0)

10 years agoFix: allow CIPSO labels with zero categories
Jarkko Sakkinen [Tue, 8 Oct 2013 13:17:23 +0000 (16:17 +0300)]
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
(cherry picked from commit 4e4ea9142727ca7f14bf1d64cd81949b28bb1d0b)

10 years agoDocumented order in which access rules are applied to kernel.
Jarkko Sakkinen [Wed, 2 Oct 2013 08:07:59 +0000 (11:07 +0300)]
Documented order in which access rules are applied to kernel.
(cherry picked from commit f82cadf3b7a9d84ae0bf2aa06fb8ecff9b4332dc)

10 years agoFixes for doxygen errors coming from 3810596.
Jarkko Sakkinen [Wed, 2 Oct 2013 05:49:02 +0000 (08:49 +0300)]
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.
(cherry picked from commit 8ef1846c05d32a92b23538ee491fd31350c2a045)

10 years agolibsmack: clean up smack_accesses_add_modify()
Jarkko Sakkinen [Wed, 2 Oct 2013 05:38:59 +0000 (08:38 +0300)]
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.
(cherry picked from commit 22c98dd03e352057b23f8d8d2d9ad252175c685b)

10 years agoCleaned up init code.
Jarkko Sakkinen [Tue, 1 Oct 2013 23:56:06 +0000 (02:56 +0300)]
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.
(cherry picked from commit c59864f9d4a67dcf76ba01d9c4db2b12fada6339)

10 years agoMerge branch 'cipso_bug' of git://github.com/zos/smack into zos-cipso_bug
Jarkko Sakkinen [Tue, 8 Oct 2013 14:36:32 +0000 (17:36 +0300)]
Merge branch 'cipso_bug' of git://github.com/zos/smack into zos-cipso_bug

10 years agoChange apply_cipso_cb() to use proper apply_cipso_file()
Zofia Abramowska [Tue, 8 Oct 2013 14:24:24 +0000 (16:24 +0200)]
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.

10 years agoFix: allow CIPSO labels with zero categories
Jarkko Sakkinen [Tue, 8 Oct 2013 13:17:23 +0000 (16:17 +0300)]
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

10 years agoDocumented order in which access rules are applied to kernel.
Jarkko Sakkinen [Wed, 2 Oct 2013 08:07:59 +0000 (11:07 +0300)]
Documented order in which access rules are applied to kernel.

10 years agoFixes for doxygen errors coming from 3810596.
Jarkko Sakkinen [Wed, 2 Oct 2013 05:49:02 +0000 (08:49 +0300)]
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.

10 years agolibsmack: clean up smack_accesses_add_modify()
Jarkko Sakkinen [Wed, 2 Oct 2013 05:38:59 +0000 (08:38 +0300)]
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.

10 years agoCleaned up init code.
Jarkko Sakkinen [Tue, 1 Oct 2013 23:56:06 +0000 (02:56 +0300)]
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.

10 years agoUpdate configure.ac version and mainter information
Jarkko Sakkinen [Wed, 2 Oct 2013 17:41:16 +0000 (20:41 +0300)]
Update configure.ac version and mainter information

Update version to 1.0.2 and maintaer email from @intel.com
to @linux.intel.com.

10 years agoUpdate version and maintainer information
Jarkko Sakkinen [Wed, 2 Oct 2013 17:38:17 +0000 (20:38 +0300)]
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.

10 years agoSet revision for v1.0.2 release
Jarkko Sakkinen [Wed, 2 Oct 2013 17:33:06 +0000 (20:33 +0300)]
Set revision for v1.0.2 release

This was forgotten to set for v1.0.1. My apologies.
Setting this early on so will not be forgotten when
v1.0.2 is tagged.

10 years agoMajor documentation cleanup.
Jarkko Sakkinen [Mon, 30 Sep 2013 13:18:32 +0000 (16:18 +0300)]
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.