-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Should the log/event driver automatically fallback to file driver if journal is not readable by user ? #19600
Comments
Note: even a dynamic user create "the normal way" via systemd cannot access it's own journal file:
For another project in my Amadeus (improving a bit security on our Jenkins nodes), I also wish to use one day systemd dynamic users to isolate different Jenkins build running on the same machine. If |
I don't think hardcoding based on UID is a good idea, this would mean we need to track upstream changes and so for possible changes then different distros could change it and so on. |
Well I wouldn't suggest to do that for every podman command. Only the first command after boot and then we could write the logger to a tmpfile so all commands after that can just read the tmpfile to know which driver is in use.
We cannot detect that in all cases. We simply get no results which is equal to no logs. And by the time someone runs podman logs it is already to late as the container was already created with the wrong log driver. |
That's an improvement but would still slow down containers on boot. They either all have to do the check concurrently or block on the first process doing it. It's an important use case for auto and Edge etc. But I am purely speculating at the moment, and have to idea how big of a cost the check would be.
Absolutely. I should have elaborated more: if we decide to not pay the performance penalty we may still consider improving the UX. |
I don't know anything about journald API (neither the official API, neither the go implementation (or binding) you use, but doesn't journal provide a way to know if a user can read its own journal ? I mean, of course I don't want to start hardcoding the system/dynamic user range on podman side, but it's hardcoded already in the C systemd libraries, so, if there is any official API to query that, it would still be fast (given the implementation on systemd side seems to really just check uid numbers) |
Ah right and based on CI flakes write journal followed by read journald is not reliable at all so we would need to some sleep back off which would make it very slow and unacceptable for these use cases. To my knowledge there is no systemd API to know if you can read logs or not. Based on your systemd-run example you can see that |
Actually it reads |
@msekletar is there an easy way to detect whether a user has read access to the journal? We care how long it takes to run the first container for some use cases, so I am also against a check that runs on every boot for detecting an unusual configuration as here. More in general, I think it is not a good idea to use a UID that could collide with systemd internal IDs and you should avoid that. You could end up with an unprivileged user that gains access to a system service because systemd picked that same ID for a system configured with |
While I agree with this, in practice some organization like ours have allocated these user ids even before systemd came up with the idea of this dynamic user range, which we couldn't really foresee ;) Also, one might want to use
Technically in https://0pointer.net/blog/dynamic-users-with-systemd.html that Lennart wrote when this was introduced, it's written:
|
what would happen if a user is added later on while there are already running services using that ID? Would these services be restarted? |
I don't know (as I don't know the code), but indeed I would expect in that case a temporary user id collision, until the systemd service stops and cleans up the temporary user. |
@giuseppe You can check manually by looking at individual files but I don't think this is easy. I'd suggest to use sd-journal API and try to open journal files owned by the user. For example, /* gcc -o user-journal-check user-journal-check.c -lsystemd */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <systemd/sd-journal.h>
int main(void) {
sd_journal *j;
int r;
r = sd_journal_open(&j, SD_JOURNAL_CURRENT_USER);
if (r < 0) {
fprintf(stderr, "Failed to open journal: %s\n", strerror(-r));
return EXIT_FAILURE;
}
if (sd_journal_has_runtime_files(j) == 0 &&
sd_journal_has_persistent_files(j) == 0)
printf("User has no journal files.\n");
sd_journal_close(j);
return 0;
} When we get no output we know user has some journal files, otherwise "User has no journal files." gets printed but what this tells us is really just what it says on the box. Maybe user had some journal files previously but they were deleted or user (non-root) never had any journal files and it never will because |
A friendly reminder that this issue had no activity for 30 days. |
@giuseppe @msekletar @Romain-Geissler-1A What should be done with this issue? |
Issue Description
Hi,
This is an issue which honestly I am not sure is on podman side or on systemd side. This is the result of a real bug report we had inside Amadeus with one of our developer. We use a global ldap server to authenticate our employees, and this ldap server is also the source of user ids for all our shared linux development servers. Over time, we had many employee, and it seems that user ids have always been growing up on our side. Last week, a user came to us saying "podman logs" doesn't work for me, while it was working for absolutely all other users on the very same machine. That user had user id 61308. And then we discovered the existence of the "dynamic user id" range on systemd side: https://systemd.io/UIDS-GIDS/ (from 61184 to 65519, hardcoded at compilation time in systemd, impossible to change at run time).
So, the top level description of the problem is: when running a systemd system, users in the range of the system user id (by default < 1000 (except root or user in the journald groups), but configurable with /etc/login.defs) and users in the dynamic user id range have a non working "podman logs" command. It just returns no output, nothing, and no clear error about what's going on. It's because journalctl doesn't work for them, these users CANNOT read their own journal (which is actually the system journal). I am not sure if this is by design of systemd or not (I could find recently this pull request systemd/systemd#27961 which seems to enable journalctl for system users, but I tried this systemd version and it changes nothing to the journalctl issue for system users).
The question is, in this case (either by checking only the uids, either by "detecting" at runtime of a user is able to read it's own journal by trying to log some non empty string then trying to read it), should podman automatically switch to the file driver as a fallback (when no explicit log/event driver was specified) ?
Note: obivously, we wondered on our side if it makes sense that our ldap have users with user ids in the range of this "dynamic user id" range that we didn't know about. While new users are now created out of this range, it's definitely not easy on our side to migrate existing users from this range to another userid (as it means remapping all their files to the new userids on the all the machines they used already, or asking them to duplicate their linux account and manually ask them to migrate from the old one to the new one).
Cheers,
Romain
Steps to reproduce the issue
Steps to reproduce the issue
podman
is already created (by your team), and I add to itsystemuser
(user id 500) anddynamicuser
(user id 62000):podman
, but not fordynamicuser
norsystemuser
. All 3 users use the systemd log driver:Describe the results you received
podman logs
doesn't work forsystemuser
anddynamicuser
.Describe the results you expected
podman logs
works for all users, by default, with no special configuration to make it work (ie automatic fallback to a file driver in these special cases ?)podman info output
Not needed (upsteam podman)
Podman in a container
Yes
Privileged Or Rootless
Rootless
Upstream Latest Release
Yes
Additional environment details
In our real life example (the case of the developer who opened us a bug report internally), we run a RHEL 9.2 server, with all the software updates applied. There is no "podman in podman" scenario like described in this bug report, but the issue is the same: no podman logs are seeable for this user in the dynamic user id range.
Additional information
No response
The text was updated successfully, but these errors were encountered: