-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
systemd_units: fix parsing #8381
Conversation
Depending on the environment it may or not may contain unicode characters
It fixes this error:
|
// not found or failed units might have a leading asterisk | ||
if data[0] == "*" { | ||
data = data[1:] | ||
} |
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.
The problem is that we remove things after the length check. There might be cases where you get four fields, but an asterix in the beginning and then end up with only three fields left in data.
How about adding
// not found or failed units might have a leading asterisk | |
if data[0] == "*" { | |
data = data[1:] | |
} | |
if strings.HasPrefix(line, "*") { | |
line = strings.Replace(line, "*", "", 1) | |
} |
above, directly after the assignment to line (line 148 I think) and before creating data?
Their first field will be an asteric: $ LC_ALL=C systemctl list-units --all --type=service --no-legend accounts-daemon.service loaded active running Accounts Service * acpid.service not-found inactive dead acpid.service alsa-store.service loaded active exited Store Sound Card State * apparmor.service not-found inactive dead apparmor.service audio-off.service loaded active exited Mute audio before suspend audit.service loaded active exited Kernel Auditing
Does this also relate to issue #7990? |
this might be resolved now as of #7991 |
Yes. |
Required for all PRs: