Why calling agetty directly from bash doesn't seem to have any effect?
Clash Royale CLAN TAG#URR8PPP
I try to call /usr/bin/agetty -
from bash in a terminal-emulator(both X-based and Kernel-based), then it asked me to input a username, but after input that username, it just "freeze" a little while, then dropped me back into my original bash promote.
I started to wonder, agetty is started by systemd
as a service using the ttyx device and execve(/usr/bin/login)
so it will give me login promote, because login is configured with pam_systemd
, so a systemd session will be created. But that's not the result I get when I directly run agetty -
as I mentioned above, no new session is created when I check systemctl status
.
Then I thought if it was because agetty run as normal user, it might check its own EUID or something, but that just cause my bash to exit after I input the username.
Ok, I checked systemctl status
again, it told me systemd run this program as /sbin/agetty -o -p -- u --noclear tty2 linux
, ok, I login as root on tty2, then run agetty -o -p -- u --noclear - linux
, I got exactly the same situation as in the first place —— I was dropped back to bash again.
I need to understand these experiment results.
I'm using ArchLinux, /usr/bin/login
and /usr/bin/agetty
are both from the util-linux 2.33-2
package.
linux systemd login getty
add a comment |
I try to call /usr/bin/agetty -
from bash in a terminal-emulator(both X-based and Kernel-based), then it asked me to input a username, but after input that username, it just "freeze" a little while, then dropped me back into my original bash promote.
I started to wonder, agetty is started by systemd
as a service using the ttyx device and execve(/usr/bin/login)
so it will give me login promote, because login is configured with pam_systemd
, so a systemd session will be created. But that's not the result I get when I directly run agetty -
as I mentioned above, no new session is created when I check systemctl status
.
Then I thought if it was because agetty run as normal user, it might check its own EUID or something, but that just cause my bash to exit after I input the username.
Ok, I checked systemctl status
again, it told me systemd run this program as /sbin/agetty -o -p -- u --noclear tty2 linux
, ok, I login as root on tty2, then run agetty -o -p -- u --noclear - linux
, I got exactly the same situation as in the first place —— I was dropped back to bash again.
I need to understand these experiment results.
I'm using ArchLinux, /usr/bin/login
and /usr/bin/agetty
are both from the util-linux 2.33-2
package.
linux systemd login getty
1
Agetty
process opens the named port, prompts for a login name, callslogin
. If you have another process already using that port (eg your existing shell) then you may get conflicts with the terminal handling. Typically you would specify an unused port to start a new session on that port. What is it you are trying to do?
– Stephen Harris
Dec 30 '18 at 14:39
add a comment |
I try to call /usr/bin/agetty -
from bash in a terminal-emulator(both X-based and Kernel-based), then it asked me to input a username, but after input that username, it just "freeze" a little while, then dropped me back into my original bash promote.
I started to wonder, agetty is started by systemd
as a service using the ttyx device and execve(/usr/bin/login)
so it will give me login promote, because login is configured with pam_systemd
, so a systemd session will be created. But that's not the result I get when I directly run agetty -
as I mentioned above, no new session is created when I check systemctl status
.
Then I thought if it was because agetty run as normal user, it might check its own EUID or something, but that just cause my bash to exit after I input the username.
Ok, I checked systemctl status
again, it told me systemd run this program as /sbin/agetty -o -p -- u --noclear tty2 linux
, ok, I login as root on tty2, then run agetty -o -p -- u --noclear - linux
, I got exactly the same situation as in the first place —— I was dropped back to bash again.
I need to understand these experiment results.
I'm using ArchLinux, /usr/bin/login
and /usr/bin/agetty
are both from the util-linux 2.33-2
package.
linux systemd login getty
I try to call /usr/bin/agetty -
from bash in a terminal-emulator(both X-based and Kernel-based), then it asked me to input a username, but after input that username, it just "freeze" a little while, then dropped me back into my original bash promote.
I started to wonder, agetty is started by systemd
as a service using the ttyx device and execve(/usr/bin/login)
so it will give me login promote, because login is configured with pam_systemd
, so a systemd session will be created. But that's not the result I get when I directly run agetty -
as I mentioned above, no new session is created when I check systemctl status
.
Then I thought if it was because agetty run as normal user, it might check its own EUID or something, but that just cause my bash to exit after I input the username.
Ok, I checked systemctl status
again, it told me systemd run this program as /sbin/agetty -o -p -- u --noclear tty2 linux
, ok, I login as root on tty2, then run agetty -o -p -- u --noclear - linux
, I got exactly the same situation as in the first place —— I was dropped back to bash again.
I need to understand these experiment results.
I'm using ArchLinux, /usr/bin/login
and /usr/bin/agetty
are both from the util-linux 2.33-2
package.
linux systemd login getty
linux systemd login getty
edited Dec 30 '18 at 7:56
Rui F Ribeiro
39.4k1479131
39.4k1479131
asked Dec 30 '18 at 4:46
炸鱼薯条德里克炸鱼薯条德里克
426114
426114
1
Agetty
process opens the named port, prompts for a login name, callslogin
. If you have another process already using that port (eg your existing shell) then you may get conflicts with the terminal handling. Typically you would specify an unused port to start a new session on that port. What is it you are trying to do?
– Stephen Harris
Dec 30 '18 at 14:39
add a comment |
1
Agetty
process opens the named port, prompts for a login name, callslogin
. If you have another process already using that port (eg your existing shell) then you may get conflicts with the terminal handling. Typically you would specify an unused port to start a new session on that port. What is it you are trying to do?
– Stephen Harris
Dec 30 '18 at 14:39
1
1
A
getty
process opens the named port, prompts for a login name, calls login
. If you have another process already using that port (eg your existing shell) then you may get conflicts with the terminal handling. Typically you would specify an unused port to start a new session on that port. What is it you are trying to do?– Stephen Harris
Dec 30 '18 at 14:39
A
getty
process opens the named port, prompts for a login name, calls login
. If you have another process already using that port (eg your existing shell) then you may get conflicts with the terminal handling. Typically you would specify an unused port to start a new session on that port. What is it you are trying to do?– Stephen Harris
Dec 30 '18 at 14:39
add a comment |
1 Answer
1
active
oldest
votes
Apparently "recursive login
" used to do something useful, but it has not been expected to work on Linux for a while now.
I recommending sticking with the more commonly used techniques, such non-recursive login
, or su
and sudo
, because these are better understood, documented, etc for current systems.
Where possible, avoid su
in favour of su -l
, as this gives you a clean set of environment variables.
I do not know why you see the specific result you describe. But if you do need to understand the behaviour of "recursive login
", I can think of two specific points that you need to understand, about what can go wrong with it.
BUGS
The undocumented BSD -r option is not supported. This may be required
by some rlogind(8) programs.
A recursive login, as used to be possible in the good old days, no
longer works; for most purposes su(1) is a satisfactory substitute.
Indeed, for security reasons, login does a vhangup() system call to
remove any possible listening processes on the tty. This is to avoid
password sniffing. If one uses the command login, then the surrounding
shell gets killed by vhangup() because it's no longer the true owner of
the tty.
--
man login
And if you're using systemd, it tracks login sessions, but it does not allow them to be nested. This is a deliberate choice about how systemd login sessions should interact with "audit
sessions". su
/ sudo
do not escape the current "audit
session".
Currently, I can also see systemd noisily logging about this design every time I run sudo
. Do not ask me why this is considered desirable...
sudo[1079]: pam_systemd(sudo:session): Cannot create session: Already running in a session
Full disclosure: the quote from man login
continues:
If one uses the command login, then the surrounding shell gets killed by vhangup() because it's no longer the true owner of the tty. This can be avoided by using
exec login
in a top-level shell
or xterm.
1
ArchLinux doesn't get this, maybe you havepam_systemd
configured forsudo
in/etc/pam.d
.
– 炸鱼薯条德里克
Dec 31 '18 at 14:32
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f491543%2fwhy-calling-agetty-directly-from-bash-doesnt-seem-to-have-any-effect%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Apparently "recursive login
" used to do something useful, but it has not been expected to work on Linux for a while now.
I recommending sticking with the more commonly used techniques, such non-recursive login
, or su
and sudo
, because these are better understood, documented, etc for current systems.
Where possible, avoid su
in favour of su -l
, as this gives you a clean set of environment variables.
I do not know why you see the specific result you describe. But if you do need to understand the behaviour of "recursive login
", I can think of two specific points that you need to understand, about what can go wrong with it.
BUGS
The undocumented BSD -r option is not supported. This may be required
by some rlogind(8) programs.
A recursive login, as used to be possible in the good old days, no
longer works; for most purposes su(1) is a satisfactory substitute.
Indeed, for security reasons, login does a vhangup() system call to
remove any possible listening processes on the tty. This is to avoid
password sniffing. If one uses the command login, then the surrounding
shell gets killed by vhangup() because it's no longer the true owner of
the tty.
--
man login
And if you're using systemd, it tracks login sessions, but it does not allow them to be nested. This is a deliberate choice about how systemd login sessions should interact with "audit
sessions". su
/ sudo
do not escape the current "audit
session".
Currently, I can also see systemd noisily logging about this design every time I run sudo
. Do not ask me why this is considered desirable...
sudo[1079]: pam_systemd(sudo:session): Cannot create session: Already running in a session
Full disclosure: the quote from man login
continues:
If one uses the command login, then the surrounding shell gets killed by vhangup() because it's no longer the true owner of the tty. This can be avoided by using
exec login
in a top-level shell
or xterm.
1
ArchLinux doesn't get this, maybe you havepam_systemd
configured forsudo
in/etc/pam.d
.
– 炸鱼薯条德里克
Dec 31 '18 at 14:32
add a comment |
Apparently "recursive login
" used to do something useful, but it has not been expected to work on Linux for a while now.
I recommending sticking with the more commonly used techniques, such non-recursive login
, or su
and sudo
, because these are better understood, documented, etc for current systems.
Where possible, avoid su
in favour of su -l
, as this gives you a clean set of environment variables.
I do not know why you see the specific result you describe. But if you do need to understand the behaviour of "recursive login
", I can think of two specific points that you need to understand, about what can go wrong with it.
BUGS
The undocumented BSD -r option is not supported. This may be required
by some rlogind(8) programs.
A recursive login, as used to be possible in the good old days, no
longer works; for most purposes su(1) is a satisfactory substitute.
Indeed, for security reasons, login does a vhangup() system call to
remove any possible listening processes on the tty. This is to avoid
password sniffing. If one uses the command login, then the surrounding
shell gets killed by vhangup() because it's no longer the true owner of
the tty.
--
man login
And if you're using systemd, it tracks login sessions, but it does not allow them to be nested. This is a deliberate choice about how systemd login sessions should interact with "audit
sessions". su
/ sudo
do not escape the current "audit
session".
Currently, I can also see systemd noisily logging about this design every time I run sudo
. Do not ask me why this is considered desirable...
sudo[1079]: pam_systemd(sudo:session): Cannot create session: Already running in a session
Full disclosure: the quote from man login
continues:
If one uses the command login, then the surrounding shell gets killed by vhangup() because it's no longer the true owner of the tty. This can be avoided by using
exec login
in a top-level shell
or xterm.
1
ArchLinux doesn't get this, maybe you havepam_systemd
configured forsudo
in/etc/pam.d
.
– 炸鱼薯条德里克
Dec 31 '18 at 14:32
add a comment |
Apparently "recursive login
" used to do something useful, but it has not been expected to work on Linux for a while now.
I recommending sticking with the more commonly used techniques, such non-recursive login
, or su
and sudo
, because these are better understood, documented, etc for current systems.
Where possible, avoid su
in favour of su -l
, as this gives you a clean set of environment variables.
I do not know why you see the specific result you describe. But if you do need to understand the behaviour of "recursive login
", I can think of two specific points that you need to understand, about what can go wrong with it.
BUGS
The undocumented BSD -r option is not supported. This may be required
by some rlogind(8) programs.
A recursive login, as used to be possible in the good old days, no
longer works; for most purposes su(1) is a satisfactory substitute.
Indeed, for security reasons, login does a vhangup() system call to
remove any possible listening processes on the tty. This is to avoid
password sniffing. If one uses the command login, then the surrounding
shell gets killed by vhangup() because it's no longer the true owner of
the tty.
--
man login
And if you're using systemd, it tracks login sessions, but it does not allow them to be nested. This is a deliberate choice about how systemd login sessions should interact with "audit
sessions". su
/ sudo
do not escape the current "audit
session".
Currently, I can also see systemd noisily logging about this design every time I run sudo
. Do not ask me why this is considered desirable...
sudo[1079]: pam_systemd(sudo:session): Cannot create session: Already running in a session
Full disclosure: the quote from man login
continues:
If one uses the command login, then the surrounding shell gets killed by vhangup() because it's no longer the true owner of the tty. This can be avoided by using
exec login
in a top-level shell
or xterm.
Apparently "recursive login
" used to do something useful, but it has not been expected to work on Linux for a while now.
I recommending sticking with the more commonly used techniques, such non-recursive login
, or su
and sudo
, because these are better understood, documented, etc for current systems.
Where possible, avoid su
in favour of su -l
, as this gives you a clean set of environment variables.
I do not know why you see the specific result you describe. But if you do need to understand the behaviour of "recursive login
", I can think of two specific points that you need to understand, about what can go wrong with it.
BUGS
The undocumented BSD -r option is not supported. This may be required
by some rlogind(8) programs.
A recursive login, as used to be possible in the good old days, no
longer works; for most purposes su(1) is a satisfactory substitute.
Indeed, for security reasons, login does a vhangup() system call to
remove any possible listening processes on the tty. This is to avoid
password sniffing. If one uses the command login, then the surrounding
shell gets killed by vhangup() because it's no longer the true owner of
the tty.
--
man login
And if you're using systemd, it tracks login sessions, but it does not allow them to be nested. This is a deliberate choice about how systemd login sessions should interact with "audit
sessions". su
/ sudo
do not escape the current "audit
session".
Currently, I can also see systemd noisily logging about this design every time I run sudo
. Do not ask me why this is considered desirable...
sudo[1079]: pam_systemd(sudo:session): Cannot create session: Already running in a session
Full disclosure: the quote from man login
continues:
If one uses the command login, then the surrounding shell gets killed by vhangup() because it's no longer the true owner of the tty. This can be avoided by using
exec login
in a top-level shell
or xterm.
edited Dec 31 '18 at 12:26
answered Dec 31 '18 at 11:59
sourcejedisourcejedi
23.2k437102
23.2k437102
1
ArchLinux doesn't get this, maybe you havepam_systemd
configured forsudo
in/etc/pam.d
.
– 炸鱼薯条德里克
Dec 31 '18 at 14:32
add a comment |
1
ArchLinux doesn't get this, maybe you havepam_systemd
configured forsudo
in/etc/pam.d
.
– 炸鱼薯条德里克
Dec 31 '18 at 14:32
1
1
ArchLinux doesn't get this, maybe you have
pam_systemd
configured for sudo
in /etc/pam.d
.– 炸鱼薯条德里克
Dec 31 '18 at 14:32
ArchLinux doesn't get this, maybe you have
pam_systemd
configured for sudo
in /etc/pam.d
.– 炸鱼薯条德里克
Dec 31 '18 at 14:32
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f491543%2fwhy-calling-agetty-directly-from-bash-doesnt-seem-to-have-any-effect%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
A
getty
process opens the named port, prompts for a login name, callslogin
. If you have another process already using that port (eg your existing shell) then you may get conflicts with the terminal handling. Typically you would specify an unused port to start a new session on that port. What is it you are trying to do?– Stephen Harris
Dec 30 '18 at 14:39