2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-10-17 14:26:10 +00:00

Add fns to handle profile removal to the kernel interface

Signed-off-by: John Johansen <john.johansen@canonical.com>
[tyhicks: Forward ported patch to trunk]
[tyhicks: remove commented out code]
[tyhicks: fix use after free]
Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
This commit is contained in:
John Johansen
2015-03-25 17:09:26 -05:00
committed by Tyler Hicks
parent 4e712f6c8d
commit 4970d40e0d
6 changed files with 58 additions and 60 deletions

View File

@@ -204,3 +204,26 @@ int aa_load_buffer(int option, char *buffer, int size)
return write_policy_buffer(fd, kernel_supports_setload, buffer, size);
}
/**
* aa_remove_profile - remove a profile from the kernel
* @fqname: the fully qualified name of the profile to remove
*
* Returns: 0 on success, -1 on error with errno set
*/
int aa_remove_profile(const char *fqname)
{
autoclose int dirfd = -1;
autoclose int fd = -1;
dirfd = open_iface_dir();
if (dirfd == -1)
return -1;
fd = open_option_iface(dirfd, OPTION_REMOVE);
if (fd == -1)
return -1;
/* include trailing \0 in buffer write */
return write_buffer(fd, fqname, strlen(fqname) + 1, 0);
}