Commit graph

3 commits

Author SHA1 Message Date
Steve Beattie
ffc6529bef
binutils/aa-features-abi: fix failure to close fd due to shadowed var decl
The variable used to store the file descriptor for the --file ended up
being declared twice, resulting in the autoclose attribute attached to
the first declaration being removed by the shadowed second declaration.
Fix this by converting the second declaration to just be an assignment,
as was intended.

strace output before:

  [...]
  ) = 1925
  close(1)                                = 0
  exit_group(0)                           = ?
  +++ exited with 0 +++

strace output after removing shadow declaration:

  ) = 1925
  close(1)                                = 0
  close(3)                                = 0
  exit_group(0)                           = ?
  +++ exited with 0 +++

(File descriptor 3 is what is returned by the open() call on the
 --file argument.)

Signed-off-by: Steve Beattie <steve.beattie@canonical.com>
Acked-by: John Johansen <john.johansen@canonical.com>
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/804
2021-09-27 13:07:11 -07:00
Steve Beattie
8137beb265
binutils/aa-features-abi: make -f short arg actually be accepted
The aa-features-abi -f short argument was not added to the
getopt_long() set of short arguments, resulting in the command
incorrectly failing like so:

  $ ./aa-features-abi -f /etc/apparmor.d/abi/3.0
  ./aa-features-abi: invalid option -- 'f'
  USAGE: ./aa-features-abi [OPTIONS] <SOURCE> [OUTPUT OPTIONS]
  [...]

The long --file option works as expected.

Fix this by adding f to the set of short arguments passed to
getopt_long().

Signed-off-by: Steve Beattie <steve.beattie@canonical.com>
Acked-by: John Johansen <john.johansen@canonical.com>
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/804
2021-09-27 13:05:59 -07:00
John Johansen
11ef957274 binutils: Add tool to enable extraction of the kernel features abi
Add a basic tool for manipulating the apparmor features abi via
libapparmor. This serves as a basic tool and as an example of using
the library api.

Currently its function is limited to extracting the kernel feature
abi and loading a feature abi from a file and then outputing it.

In the future it will pickup the ability to verify the feature
abi, and merge feature abis.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/613
Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Steve Beattie <steve.beattie@canonical.com>
2020-09-27 16:28:27 -07:00