Commit f726e672 authored by Kaarle Ritvanen's avatar Kaarle Ritvanen Committed by Timo Teräs

db: assign write permission to lock file

Allows running apk as an unprivileged user, e.g. with fakeroot.
Opening the lock file fails without the write permission.
parent b80aba0b
......@@ -1513,7 +1513,7 @@ int apk_db_open(struct apk_database *db, struct apk_db_options *dbopts)
relocate_database(db);
db->lock_fd = openat(db->root_fd, apk_lock_file,
O_CREAT | O_RDWR | O_CLOEXEC, 0400);
O_CREAT | O_RDWR | O_CLOEXEC, 0600);
if (db->lock_fd < 0 && errno == ENOENT &&
(dbopts->open_flags & APK_OPENF_CREATE)) {
r = apk_db_create(db);
......@@ -1522,7 +1522,7 @@ int apk_db_open(struct apk_database *db, struct apk_db_options *dbopts)
goto ret_r;
}
db->lock_fd = openat(db->root_fd, apk_lock_file,
O_CREAT | O_RDWR | O_CLOEXEC, 0400);
O_CREAT | O_RDWR | O_CLOEXEC, 0600);
}
if (db->lock_fd < 0 ||
flock(db->lock_fd, LOCK_EX | LOCK_NB) < 0) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment