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

Silent exit instead of error message on DB access problem #2222

Open
nuclight opened this issue Jan 14, 2024 · 3 comments
Open

Silent exit instead of error message on DB access problem #2222

nuclight opened this issue Jan 14, 2024 · 3 comments

Comments

@nuclight
Copy link

If there is a problem with .sqlite in /var/db/pkg, then e.g. pkg upgrade pkg just silently exits without any error message (just $?=1), even with -dddd. Tracing problem with gdb found the cause:

pkgdb_check_access():
714                 retval = faccessat(dbdirfd, dbpath, R_OK|W_OK, AT_EACCESS);

And there is no sufficient checks for errno later.

How to reproduce, most easy way:

# chflags sunlnk,schg /var/db/pkg/repo-FreeBSD.sqlite
# pkg upgrade pkg

Solution is to add perror() (or whatever better style for pkg) later in this function in else branch for all unknown errno's.

@rilysh
Copy link
Contributor

rilysh commented Jan 18, 2024

I think this behavior is intentional(?), as pkgdb_check_access() only returns error codes, and doesn't print standard error messages. This issue also exists in some other commands as well (see #2211).

A simple "fix" can be done by adding a warning message (using warn(3) or perror(3)) whenever faccessat(3) fails.

root@freebsd:/home/rilysh/pkg # ./src/pkg install abc
pkg: faccessat: Operation not permitted
root@freebsd:/home/rilysh/pkg # echo $?
1

I'm not sure, if it's required in most cases, as you can always check for returned errors. Although I agree, having a clear error message is much better than just relying on returned values.

@nuclight
Copy link
Author

Well, this can't be intentional, because it creates UX from hell for the user. And even if the user is not just user but sysadmin, then bare faccessat: Operation not permitted is stil not enough - yopu want to know which file caused the problem. So that it can be fixed without consulting pkg sources. Because user do not call routines to check for error codes, user calls e.g. pkg upgrade.

So. The only debatable thing here is where to insert reporting to user, and by which function - this is what pkg maintainers know better than bugreporter.

@rilysh
Copy link
Contributor

rilysh commented Jan 21, 2024

Adding it in pkgdb_check_access() function is just fine. However, before any PR, it will be better to get some attention from maintainers with this issue.

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

No branches or pull requests

2 participants