Netatalk / netatalk

Netatalk is a Free and Open Source AFP fileserver. A *NIX or BSD system running Netatalk is capable of serving many Macintosh clients simultaneously as an AppleShare file server.
https://netatalk.io
GNU General Public License v2.0
353 stars 87 forks source link

SQLite CNID backend #1570

Open rdmark opened 1 month ago

rdmark commented 1 month ago

Port the sqlite CNID backend from netatalk-classic (netatalk 2.x based) to netatalk 4.x.

rdmark commented 3 days ago

@NJRoadfan This is close to working now, FYI.

Two outstanding issues:

The directory that houses the sqlite cnid databases (e.g. /var/lib/netatalk/CNID needs to have 777 permissions since the database client is embedded in afpd which runs as a normal user (obviously) when a user authenticates and attempts to initialize the volume. We may need a helper daemon akin to cnid_dbd to run the database client as root.

But more importantly, there's a crash in dircache_add() when it tries to enumerate the volume, so something isn't lining up quite yet.

Nonetheless, the backend builds and starts up now, and can generate a little cnid sqlite database file that you can query, which is neat.

NJRoadfan commented 3 days ago

Here is what comes up when trying to rebuild an existing volume with dbd -f: Nov 14 18:53:18.614566 dbd[5231] {cnid_sqlite.c:100} (error:Default): sqlite3_bind_text(db->cnid_add_stmt, 1, stmt_param_name, strlen(stmt_param_name), SQLITE_STATIC) failed: No such file or directory

Here is a dump of the database, it doesn't get very far:

PRAGMA foreign_keys=OFF;
BEGIN TRANSACTION;
CREATE TABLE volumes ( VolUUID CHAR(32) PRIMARY KEY,VolPath TEXT(4096),Stamp BINARY(8),Depleted INT);
INSERT INTO volumes VALUES('830A28BBB084683384019DD280C51FA8','/srv/A2SERVER/A2FILES','n�6g',0);
CREATE TABLE `830A28BBB084683384019DD280C51FA8`(Id INTEGER PRIMARY KEY AUTOINCREMENT,Name VARCHAR(255) NOT NULL,Did INTEGER NOT NULL,DevNo INTEGER NOT NULL,InodeNo INTEGER NOT NULL,UNIQUE (Did, Name), UNIQUE (DevNo, InodeNo));
DELETE FROM sqlite_sequence;
INSERT INTO sqlite_sequence VALUES('`830A28BBB084683384019DD280C51FA8`',16);
CREATE INDEX idx_volpath ON volumes(VolPath);
COMMIT;
sonarcloud[bot] commented 7 hours ago

Quality Gate Failed Quality Gate failed

Failed conditions
6 Security Hotspots

See analysis details on SonarQube Cloud