-
Notifications
You must be signed in to change notification settings - Fork 16
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
Use SQLite instead of bbolt #779
base: main
Are you sure you want to change the base?
Conversation
Changes done by running: git rm "internal/*/testdata/golden/*" TESTS_UPDATE_GOLDEN=1 go test ./internal/... git add -A
We don't use our database as a cache anymore. It's time to reflect this in the package name.
We can't use the "AAAAATIME" placeholders anymore when using SQLite, because the schema only allows actual timestamps.
These files were forgotten in 5555836. Also simplify the testdata for the "pam_unix_non_existent" test case, because we don't need multiple users and groups for that test case.
763b8ed
to
99bfaab
Compare
// TODO: I don't see why we should fail here instead of just fixing the permissions. | ||
fileInfo, err := os.Stat(dbPath) | ||
if err != nil { | ||
return nil, fmt.Errorf("can't stat database file: %v", err) | ||
} | ||
perm := fileInfo.Mode().Perm() | ||
if perm != 0600 { | ||
return nil, fmt.Errorf("wrong file permission for %s: %o", dbPath, perm) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To the reviewer: I copied this from the old code but added this TODO comment:
// TODO: I don't see why we should fail here instead of just fixing the permissions.
Is there a good reason for failing or should we just fix the permissions?
// It prevents leaking of lastLogin, which is only relevant to the database. | ||
// TODO: The only consumer of this package is the users manager, which converts the UserDB into a types.UserEntry anyway, | ||
// | ||
// so there is no need to hide the lastLogin field (which complicates the code). | ||
type userRow struct { | ||
UserDB `yaml:",inline"` | ||
// TODO: Why do we store the last login time in the database? It's not used anywhere. | ||
LastLogin time.Time `yaml:"last_login,omitempty"` | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@didrocks @denisonbarbosa: Do you remember why we store the last login time even though it's not used?
CREATE TABLE IF NOT EXISTS users ( | ||
name TEXT NOT NULL UNIQUE, | ||
uid INTEGER NOT NULL UNIQUE, | ||
gid INTEGER NOT NULL, | ||
gecos TEXT DEFAULT "", | ||
home TEXT DEFAULT "", | ||
shell TEXT DEFAULT "/bin/bash", | ||
last_login DATE, | ||
broker_id TEXT DEFAULT "", | ||
PRIMARY KEY(uid) | ||
); | ||
CREATE UNIQUE INDEX "idx_user_name" ON users ("name"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jibel You mentioned in a call that you would prefer to not use the UNIQUE constraint in the schema, but I did not understand the reasoning. Can you please explain it again, so that I can update the schema and add a code comment with the reasoning?
Our database requirements are better met by a relational database than a key value store, so we now use SQLite instead of bbolt.
UDENG-4890