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

Fix sqlite3 path lookup #1553

Merged
merged 1 commit into from Mar 19, 2017
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Add lstat to pkgdb_syscall_overload. Fix filename-only path resolving.

…Resolves #1552
  • Loading branch information...
stromnet committed Mar 18, 2017
commit cb0d529d6c1e7d453d8a738eb8adc06f4a6d0846
@@ -964,44 +964,61 @@ pkgdb_open_repos(struct pkgdb *db, const char *reponame)
return (EPKG_OK);
}

static const char*
_dbdir_trim_path(const char*path) {
const char *p = strrchr(path, '/');
if(p == 0)
return path;
else
return p + 1;
}

static int
_dbdir_open(const char *path, int flags, int mode)
{
int dfd = pkg_get_dbdirfd();

return (openat(dfd, strrchr(path, '/') + 1, flags, mode));
return (openat(dfd, _dbdir_trim_path(path), flags, mode));
}

static int
_dbdir_access(const char *path, int mode)
{
int dfd = pkg_get_dbdirfd();

return (faccessat(dfd, strrchr(path, '/') + 1, mode, 0));
return (faccessat(dfd, _dbdir_trim_path(path), mode, 0));
}

static int
_dbdir_stat(const char * path, struct stat * sb)
{
int dfd = pkg_get_dbdirfd();

return (fstatat(dfd, strrchr(path, '/') + 1, sb, 0));
return (fstatat(dfd, _dbdir_trim_path(path), sb, 0));
}

static int
_dbdir_lstat(const char * path, struct stat * sb)
{
int dfd = pkg_get_dbdirfd();

return (fstatat(dfd, _dbdir_trim_path(path), sb, AT_SYMLINK_NOFOLLOW));
}

static int
_dbdir_unlink(const char *path)
{
int dfd = pkg_get_dbdirfd();

return (unlinkat(dfd, strrchr(path, '/') + 1, 0));
return (unlinkat(dfd, _dbdir_trim_path(path), 0));
}

static int
_dbdir_mkdir(const char *path, mode_t mode)
{
int dfd = pkg_get_dbdirfd();

return (mkdirat(dfd, strrchr(path, '/') + 1, mode));
return (mkdirat(dfd, _dbdir_trim_path(path), mode));
}

void
@@ -1013,6 +1030,7 @@ pkgdb_syscall_overload(void)
vfs->xSetSystemCall(vfs, "open", (sqlite3_syscall_ptr)_dbdir_open);
vfs->xSetSystemCall(vfs, "access", (sqlite3_syscall_ptr)_dbdir_access);
vfs->xSetSystemCall(vfs, "stat", (sqlite3_syscall_ptr)_dbdir_stat);
vfs->xSetSystemCall(vfs, "lstat", (sqlite3_syscall_ptr)_dbdir_lstat);
vfs->xSetSystemCall(vfs, "unlink", (sqlite3_syscall_ptr)_dbdir_unlink);
vfs->xSetSystemCall(vfs, "mkdir", (sqlite3_syscall_ptr)_dbdir_mkdir);
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.