Bug 1656639

Summary: systemctl doesn't recognize root unit names (-.mount, -.slice) on command-line
Product: [Fedora] Fedora Reporter: Steve <y9t7sypezp>
Component: systemdAssignee: systemd-maint
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 29CC: lnykryn, msekleta, ssahani, s, systemd-maint, zbyszek
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: systemd-240-1.fc30 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-01-11 12:40:59 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Steve 2018-12-05 22:39:19 UTC
Description of problem:
Systemctl accepts most unit names on the command-line. However, there are two failure cases:

$ systemctl status -.mount
systemctl: invalid option -- '.'

$ systemctl status -.slice
systemctl: invalid option -- '.'

The workaround is to interpose "--" in those two cases. Thus:

$ systemctl status -- -.mount
● -.mount - Root Mount
...

Version-Release number of selected component (if applicable):
systemd-239-6.git9f3aed1.fc29.x86_64

How reproducible:
Always.

Steps to Reproduce:
1. See above.

Actual results:
See above.

Expected results:
Systemctl recognizes root unit names on the command-line and handles them like any other unit name.

Additional info:

AFAICT, "-.mount" and "-.slice" are the only two cases:

$ systemctl list-units --all | fgrep -- '-.'
  -.mount  loaded    active   mounted   Root Mount                                                                                 
  -.slice  loaded    active   active    Root Slice         

"-.mount" and "-.slice" are documented in SYSTEMD.SPECIAL(7).

Comment 1 Zbigniew Jędrzejewski-Szmek 2018-12-06 14:10:17 UTC
https://github.com/systemd/systemd/pull/11065

Comment 2 Steve 2018-12-06 14:37:32 UTC
(In reply to Zbigniew Jędrzejewski-Szmek from comment #1)
> https://github.com/systemd/systemd/pull/11065

Thanks, although the message blames the user for using a *valid* systemd unit name:

log_notice("Hint: invalid to specify units starting with a dash, use \"--\":\n"

Nicer to say: "Hint: use \"--\" before units starting with a dash, ..."

Comment 3 Zbigniew Jędrzejewski-Szmek 2018-12-06 14:41:00 UTC
It's better to comment on github, since almost nobody looks here.
This was a just a copy&paste error from the previous line. I'll push a new version.

Comment 4 Steve 2018-12-06 15:27:07 UTC
(In reply to Zbigniew Jędrzejewski-Szmek from comment #3)
> It's better to comment on github, since almost nobody looks here.
> This was a just a copy&paste error from the previous line. I'll push a new
> version.

Thanks:

"Hint: to specify units starting with a dash, use \"--\":\n" ...

https://github.com/systemd/systemd/compare/f55dbf808f6735ff7ea232a70869fe95498824e6..7a5165f45e0224d8280a3c928ed30bc000f9384c

Comment 5 Zbigniew Jędrzejewski-Szmek 2019-01-11 12:40:59 UTC
This will be available in F30. Possibly also in F29 if systemd is upgraded to 241 there, but this is not certain yet.