You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have seen situations where the permissions of the AccessoryInfo.xxx.json and IdentityCache.xxx.json files have changed or mismatch with the hap-nodejs running process. Personally noticed this after converting docker project to run as non-root. The effect of this is upon publishing the accessory, fails due to this
Proposed Change
Incorporate a test for access permissions to the persist storage location and/or files associated with the accessory upon publish and warn if cannot be written to or access. I incorporate such a test in my project
Example code I have used
// Check permissions for HAP-nodejs to access required storage for this device
var storagePath = path.normalize(process.cwd() + "/" + HAP.HAPStorage.storage().options.dir);
var fileAccessIssues = [];
fs.readdirSync(storagePath).filter((file) => file.includes(this.HomeKitAccessory.username.replace(/:/g, "").toUpperCase())).forEach((file) => {
try {
fs.accessSync(storagePath + "/" + file, fs.constants.R_OK | fs.constants.W_OK);
} catch (error) {
// Access permission error to file
fileAccessIssues.push(storagePath + "/" + file);
}
});
if (fileAccessIssues.length == 0) {
// Publish accessory on local network and push onto export array for HAP-NodeJS "accessory factory"
this.HomeKitAccessory.publish({username: this.HomeKitAccessory.username, pincode: this.HomeKitAccessory.pincode, category: this.HomeKitAccessory.category, advertiser: this.mDNSAdvertiser});
this.#outputLogging("Advertising '%s' as '%s' to local network. HomeKit pairing code is '%s'", this.deviceData.description, this.HomeKitAccessory.displayName, this.HomeKitAccessory.pincode);
}
if (fileAccessIssues.length != 0) {
// Detected file permission/access issues with HAP-NodeJS file storage, so we'll be unable to publish this accessory on the local network for HomeKit
this.#outputLogging("Permission/access issues to required storage used by HAP-NodeJS. This will prevent accessory from operating correctly in HomeKit until corrected");
fileAccessIssues.forEach((file) => {
this.#outputLogging(" += '%s'", file);
});
}
Additional Context
No response
The text was updated successfully, but these errors were encountered:
Current Situation
I have seen situations where the permissions of the AccessoryInfo.xxx.json and IdentityCache.xxx.json files have changed or mismatch with the hap-nodejs running process. Personally noticed this after converting docker project to run as non-root. The effect of this is upon publishing the accessory, fails due to this
Proposed Change
Incorporate a test for access permissions to the persist storage location and/or files associated with the accessory upon publish and warn if cannot be written to or access. I incorporate such a test in my project
Example code I have used
Additional Context
No response
The text was updated successfully, but these errors were encountered: