Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
1
rated 0 times [  1] [ 0]  / answers: 1 / hits: 964  / 1 Year ago, sun, february 19, 2023, 4:11:54

When I login to Ubuntu via the text console, I can see that a /bin/login process is the parent process of my shell. login is run as follows: /bin/login -p --. This can be seen below:



$ ps -f -C login
UID PID PPID C STIME TTY TIME CMD
root 780 1 0 Apr27 tty2 00:00:00 /bin/login -p --


My question is, what is the significance of the final -- argument? This argument is not documented in the login manpage.


More From » login

 Answers
4

Other answers have described what the -- means (end of option processing). Here I will try to answer how and why it arises in the context of the TTY-based /bin/login process.



Specifically, if you take a look at the [Service] section of /lib/systemd/system/[email protected] you should see the following ExecStart line:



ExecStart=-/sbin/agetty -o '-p -- u' --noclear %I $TERM


The reason for adding the -- is documented in man agetty:




SECURITY NOTICE
If you use the --login-program and --login-options options, be aware
that a malicious user may try to enter lognames with embedded options,
which then get passed to the used login program. Agetty does check for
a leading "-" and makes sure the logname gets passed as one parameter
(so embedded spaces will not create yet another parameter), but depend‐
ing on how the login binary parses the command line that might not be
sufficient. Check that the used login program cannot be abused this
way.

Some programs use "--" to indicate that the rest of the commandline
should not be interpreted as options. Use this feature if available by
passing "--" before the username gets passed by u.


[#3681] Monday, February 20, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
hirtieve

Total Points: 207
Total Questions: 104
Total Answers: 114

Location: Cook Islands
Member since Thu, May 21, 2020
4 Years ago
hirtieve questions
;