Bug 2860 - "-lc" should be used for non-interactive session
Summary: "-lc" should be used for non-interactive session
Status: CLOSED WONTFIX
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: ssh (show other bugs)
Version: 7.7p1
Hardware: Other Linux
: P5 normal
Assignee: Assigned to nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-04-20 18:47 AEST by Tom Yan
Modified: 2018-10-19 17:17 AEDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tom Yan 2018-04-20 18:47:08 AEST
https://github.com/openssh/openssh-portable/blob/V_7_7/session.c#L1668

In interactive sessions, the shell would be started as "login shell", /etc/profile (or zprofile in the case of zsh) would be sourced.

However, when user instructs ssh to execute a command with a non-interactive session, because the shell is started without -l / -- login, the profile files would not be sourced, which leads to inconsistency among the two types of sessions (typically missing expected environment variables in the non-interactive session).

Is there any reason that the shell in a non-interactive session should not be started as "login shell"?
Comment 1 Damien Miller 2018-05-02 01:26:54 AEST
That inconsistency is intentional. Command execution sessions are assumed to be non-interactive and are essential to ssh's use as a transport for other protocols (e.g. rsync or git).

Shell profile scripts are allows to contain actions that write to stdout and these would interfere with ssh being used as a transport if sourced.
Comment 2 Tom Yan 2018-05-03 15:57:10 AEST
> Command execution sessions are assumed to be non-interactive

Of course, but login shell is not equivalent to interactive shell


> Shell profile scripts are allows to contain actions that write to stdout and these would interfere with ssh being used as a transport if sourced

It is the responsibility of the script writer that he/she should make sure such actions are only performed in interactive shell (e.g. by checking whether "$-" has i, or by putting them in the "rc" file instead).

It does not really make sense to break the non-interactive command execution environment just for that, because ssh is logging in either way.
Comment 3 Damien Miller 2018-05-04 02:43:25 AEST
We don't intend to change this for the reasons that I've already described.
Comment 4 Damien Miller 2018-10-19 17:17:23 AEDT
Close RESOLVED bugs with the release of openssh-8.0