Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQLite CNID backend #1570

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

rdmark
Copy link
Member

@rdmark rdmark commented Sep 30, 2024

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

@rdmark rdmark linked an issue Sep 30, 2024 that may be closed by this pull request
@rdmark rdmark force-pushed the 1177-cnid-backend-using-modern-database-tech branch 2 times, most recently from 0e3a442 to 99b3751 Compare November 12, 2024 21:14
@rdmark rdmark marked this pull request as ready for review November 12, 2024 21:14
@rdmark rdmark force-pushed the 1177-cnid-backend-using-modern-database-tech branch 2 times, most recently from a69bfb0 to db22926 Compare November 12, 2024 21:34
@Netatalk Netatalk deleted a comment from sonarcloud bot Nov 12, 2024
@rdmark rdmark force-pushed the 1177-cnid-backend-using-modern-database-tech branch from eb5aecb to 90fc114 Compare November 14, 2024 21:39
@rdmark
Copy link
Member Author

rdmark commented Nov 14, 2024

@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
Copy link
Contributor

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;

@rdmark rdmark force-pushed the 1177-cnid-backend-using-modern-database-tech branch from b30a088 to 519e209 Compare November 15, 2024 21:57
Based on the Netatalk MySQL CNID backend by Ralph Boehme.
Adapted for SQLite by Christopher Kobayashi.
Ported to Netatalk 3 by dgsga.
Touched up for Netatalk 4 by Daniel Markstedt.
@rdmark rdmark force-pushed the 1177-cnid-backend-using-modern-database-tech branch from 3c7ba8d to 13b4456 Compare November 17, 2024 21:25
Copy link

sonarcloud bot commented Nov 17, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
6 Security Hotspots

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CNID backend using modern database tech
2 participants