[Pkg-shadow-devel] why the nulls in cmdline?
Nicolas François
nicolas.francois at centraliens.net
Thu Jan 17 00:28:40 UTC 2008
Hello,
On Wed, Jan 16, 2008 at 07:07:11PM +0800, jidanni at jidanni.org wrote:
> Why the nulls?
> $ pstree -a|grep \ $|cat -e
> init $
> |-login -- $
> $ od -c /proc/`pidof login`/cmdline
> 0000000 / b i n / l o g i n \0 - - \0 \0 \0
> 0000020 \0 \0 \0 \0 \0 \0
> 0000026
> $ od -c /proc/1/cmdline
> 0000000 i n i t [ 2 ] \0 \0 \0
> 0000013
On the consoles, init runs some getty. When a username is entered to
the getty's prompt, getty executes login with:
login -- <username>
That is, in you case:
/proc/`pidof login`/cmdline:
0000000 / b i n / l o g i n \0 - - \0 j i
0000020 d a n n i \0
When login parses it arguments, it zeros the username
(strzero (argv[optind]); in login.c)
This changes /proc/`pidof login`/cmdline to the one you reported:
/proc/`pidof login`/cmdline:
0000000 / b i n / l o g i n \0 - - \0 \0 \0
0000020 \0 \0 \0 \0 \0 \0
In my opinion, this is a feature in case an user entered a password
instead of a username. Without this feature, some passwords could be
gathered by running a ps regularly.
Best Regards,
--
Nekral
More information about the Pkg-shadow-devel
mailing list