result = bind(sock, (struct sockaddr*) &sockaddr, sizeof(struct sockaddr_un));
RUNNER_ASSERT_ERRNO_MSG(result == 0, "bind failed");
//Set socket label to something different than expecedLabel
- result = fsetxattr(sock, XATTR_NAME_SMACKIPIN, socketLabel,
- strlen(socketLabel), 0);
+ result = smack_set_label_for_file(sock, XATTR_NAME_SMACKIPIN, socketLabel);
RUNNER_ASSERT_ERRNO_MSG(result == 0,
"Can't set socket label. Result: " << result);
- result = fsetxattr(sock, XATTR_NAME_SMACKIPOUT, socketLabel,
- strlen(socketLabel), 0);
+ result = smack_set_label_for_file(sock, XATTR_NAME_SMACKIPOUT, socketLabel);
RUNNER_ASSERT_ERRNO_MSG(result == 0,
"Can't set socket label. Result: " << result);
Api::setProcessLabel(app_id);
- char value[SMACK_LABEL_LEN + 1];
- ssize_t size;
- size = fgetxattr(sock, XATTR_NAME_SMACKIPIN, value, sizeof(value));
- RUNNER_ASSERT_ERRNO_MSG(size != -1, "fgetxattr failed: " << value);
- result = expected_label.compare(value);
+ result = smack_new_label_from_file(sock, XATTR_NAME_SMACKIPIN, &label);
+ RUNNER_ASSERT_ERRNO_MSG(result != -1, "smack_new_label_from_file failed: " << label);
+ labelPtr.reset(label);
+ result = expected_label.compare(label);
RUNNER_ASSERT_MSG(result == 0, "Socket label is incorrect. Expected: " <<
- expected_label << " Actual: " << value);
+ expected_label << " Actual: " << label);
- size = fgetxattr(sock, XATTR_NAME_SMACKIPOUT, value, sizeof(value));
- RUNNER_ASSERT_ERRNO_MSG(size != -1, "fgetxattr failed: " << value);
- result = expected_label.compare(value);
+ result = smack_new_label_from_file(sock, XATTR_NAME_SMACKIPOUT, &label);
+ RUNNER_ASSERT_ERRNO_MSG(result != -1, "smack_new_label_from_file failed: " << label);
+ labelPtr.reset(label);
+ result = expected_label.compare(label);
RUNNER_ASSERT_MSG(result == 0, "Socket label is incorrect. Expected: " <<
- expected_label << " Actual: " << value);
+ expected_label << " Actual: " << label);
result = smack_new_label_from_self(&label);
RUNNER_ASSERT_MSG(result >= 0,