2

lets say that I have a program that is running in tty1 displaying a menu, one of the entry of this menu is to have access to the shell, which command can I start to be able to have a prompt asking for login / password ?

Thanks.

6
  • 2
    You mean login? Commented Jun 25, 2019 at 13:58
  • 1
    maybe but starting login (without any options) doesn't ask for login nor password, I just have the cursor blinking, and that's all Commented Jun 25, 2019 at 14:09
  • 1
    You should make sure that the program that invokes login, is secure: no way to break out. Commented Jun 25, 2019 at 14:16
  • 1
    Ok, do you mean that the system must trust the program ? how do I say to the system that this program is secure ? Commented Jun 25, 2019 at 14:21
  • What user is this menu running as? Commented Jun 25, 2019 at 19:46

1 Answer 1

-1

The login command is what I need to display a normal login / password prompt. The trick is to start the command by using exec

The login program is used to establish a new session with the system. It is normally invoked automatically by responding to the "login:" prompt on the user's terminal. login may be special to the shell and may not be invoked as a sub-process. When called from a shell, login should be executed as exec login which will cause the user to exit from the current shell (and thus will prevent the new logged in user to return to the session of the caller). Attempting to execute login from any shell but the login shell will produce an error message.

Source : https://www.computerhope.com/unix/ulogin.htm

3
  • 1
    Welcome to Unix & Linux! :-) Although your answer is 100% correct, it might also become 100% useless if that link is moved, changed, merged into another one or the main site just disappears... :-( Therefore, please edit your answer, and copy the relevant steps from the link into your answer, thereby guaranteeing your answer for 100% of the lifetime of this site! ;-) You can always leave the link in at the bottom of your answer as a source for your material... Commented Jun 25, 2019 at 14:28
  • 1
    And start it as root, as login(1) is not setuid. Have you considered using su(1)? Commented Jun 25, 2019 at 14:28
  • @mosvy thank you, my menu app is running under root, so it works, thanks for you tip Commented Jun 26, 2019 at 7:51

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.