if (smackfs_mnt_dirfd < 0)
return -1;
- fd = openat(smackfs_mnt_dirfd, "access2", O_RDWR);
- if (fd < 0) {
- if (errno != ENOENT)
- return -1;
-
- fd = openat(smackfs_mnt_dirfd, "access", O_RDWR);
- if (fd < 0)
- return -1;
-
- use_long = 0;
- }
+ slen = get_label(NULL, subject);
+ olen = get_label(NULL, object);
+
+ if (slen < 0 || olen < 0)
+ return -1;
+
+ fd = open_smackfs_file("access2", "access", &use_long);
+ if (fd < 0)
+ return -1;
+ if (!use_long && (slen > SHORT_LABEL_LEN || olen > SHORT_LABEL_LEN)) {
+ close(fd);
+ return -1;
+ }
+
if ((code = str_to_access_code(access_type)) < 0)
return -1;
access_code_to_str(code, str);