[apparmor] [PATCH 5/6] libapparmor: Migrate aa_kernel_interface API to openat() style

Seth Arnold seth.arnold at canonical.com
Thu Apr 2 01:06:51 UTC 2015


On Thu, Mar 26, 2015 at 04:48:01PM -0500, Tyler Hicks wrote:
> Signed-off-by: Tyler Hicks <tyhicks at canonical.com>

Can you explain the -1 here? I can't tell what the -1 does to openat(2):

> @@ -119,7 +119,7 @@ static int replace_all_cb(int dirfd unused, const char *name, struct stat *st,
>  			return -1;
>  		}
>  		retval = aa_kernel_interface_replace_policy_from_file(data->kernel_interface,
> +								      -1, path);
>  	}

>  int aa_kernel_interface_replace_policy_from_file(aa_kernel_interface *kernel_interface,
> +						 int dirfd, const char *path)
>  {
>  	return write_policy_file_to_iface(kernel_interface,
> +					  AA_IFACE_FILE_REPLACE, dirfd, path);
>  }

>  static int write_policy_file_to_iface(aa_kernel_interface *kernel_interface,
> +				      const char *iface_file,
> +				      int dirfd, const char *path)
>  {
>  	autoclose int fd;
>  
> +	fd = openat(dirfd, path, O_RDONLY);
>  	if (fd == -1)
>  		return -1;

Thanks
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <https://lists.ubuntu.com/archives/apparmor/attachments/20150401/46bdbb41/attachment.pgp>


More information about the AppArmor mailing list