Skip to content

systemctl: accept 'telinit' as program_invocation_short_name - #8305

Closed
yuwata wants to merge 1 commit into
systemd:masterfrom
yuwata:systemctl-symlink
Closed

yuwata wants to merge 1 commit into
systemd:masterfrom
yuwata:systemctl-symlink

Conversation

@yuwata

@yuwata yuwata commented Feb 28, 2018

Copy link
Copy Markdown
Member

init should be a symlink to systemd not systemctl.
See comments in #8300.

`init` should be a symlink to `systemd` not `systemctl`.
See comments in systemd#8300.
@keszybz keszybz added good-to-merge/waiting-for-ci 👍 PR is good to merge, but CI hasn't passed at time of review. Please merge if you see CI has passed and removed good-to-merge/waiting-for-ci 👍 PR is good to merge, but CI hasn't passed at time of review. Please merge if you see CI has passed labels Feb 28, 2018
@keszybz

keszybz commented Feb 28, 2018

Copy link
Copy Markdown
Member

Actually, I'm not sure if this is a good change. This is not relevant to any use of systemctl as a real init, and the only effect of this patch is that if somebody e.g. had linked myinit → systemctl, this would stop working now. This is a fringe case, but there just doesn't see to be a reason to do this.

Comment thread src/systemctl/systemctl.c
arg_action = ACTION_POWEROFF;
return shutdown_parse_argv(argc, argv);
} else if (strstr(program_invocation_short_name, "init")) {
} else if (strstr(program_invocation_short_name, "telinit")) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, this isn't right. note that we use "strstr()" here, not "streq()"...

On SysV "telinit" was the official command to communicate with PID 1, but "init" would redirect itself to "telinit" if called with PID != 1. We follow the same logic here still, though we add one level of indirection, as we implement "telinit" in "systemctl". Hence, for us if you invoke "init" you get "systemd", but it will execve() "systemctl" immediately with argv[] unmodified if PID is != 1. If you invoke "telinit" you directly get "systemctl". In both cases we shall do the same thing, which is why we do strstr(p_i_s_n, "init") here, as a quick way to match both.

Also see redirect_telinit() in src/core/main.c.

Hence, this patch isn't right, as it will break the path through systemd. However this path is really not obvious, hence I figure we should really document this better, by adding a comment right here that briefly explains the weird call chain.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I completely misunderstand the logic. Thank you for the explanation.

@poettering poettering added the reviewed/needs-rework 🔨 PR has been reviewed and needs another round of reworks label Feb 28, 2018
@yuwata

yuwata commented Feb 28, 2018

Copy link
Copy Markdown
Member Author

As already commented. This is based on my misunderstanding. Let's close this.

@yuwata yuwata closed this Feb 28, 2018
@yuwata
yuwata deleted the systemctl-symlink branch February 28, 2018 10:21
@poettering

Copy link
Copy Markdown
Member

I added a commit that adds a comment for this in #8296

poettering added a commit to poettering/systemd that referenced this pull request Mar 2, 2018
keszybz pushed a commit that referenced this pull request Mar 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

reviewed/needs-rework 🔨 PR has been reviewed and needs another round of reworks systemctl

Development

Successfully merging this pull request may close these issues.

3 participants