Linux system cut, make an extremely streamlined linux-4-for streamlined Linux system to increase user login function

Source: Internet
Author: User

Chapter 4 Adding user login capabilities to streamlined Linux systems

4.1 Download mingetty and login program source code

This article uses the CentOS 5.11 Source code is in the official source site http://vault.centos.org can be downloaded,

go to http://vault.centos.org/5.11/os/Source/to find the Mingetty and login programs, such as:

?


?

the Mingetty and login programs belong to the mingetty-1.07-5.2.2 and util-linux-2.13-0.59.el5_8 packages, respectively:

[Email protected] ~]# Rpm-qf/sbin/mingetty

mingetty-1.07-5.2.2

[Email protected] ~]# Rpm-qf/bin/login

Util-linux-2.13-0.59.el5_8

?

4.2 Use Mingetty to open two terminals for Minilinux and run directly/binbash

??????????? Red Hat Linux runs the Mingetty implementation of the/etc/rc.d/rc.sysinit script after the boot process is executed according to the/etc/inittab configuration 6 Terminal and graphical interface, the user sees the "hostname logon:" The login prompt is thrown by the Mingetty program, the user entered the user name and password will also be processed through /bin/login .

here I directly generate two terminals via Mingetty and bypass the login program to open/bin/bash directly , these steps are all done on the source host (centos5lsrv01).

Step 1 : Modify The/etc/inittab file under the Minilinux system and modify it to the following content:

[Email protected] ~]# Cat/mnt/sysroot/etc/inittab

Id:3:initdefault:

Si::sysinit:/etc/rc.d/rc.sysinit

L0:0:wait:/etc/rc.d/rc.halt

L6:6:wait:/etc/rc.d/rc.reboot

?

1:2345:respawn:/sbin/mingetty tty1

2:2345:respawn:/sbin/mingetty Tty2

tip:mingetty has a parameter of "--login-prog=/bin/login", which is verified to add "--login-prog=/bin/bash" is invalid, the Minigetty source code must be modified .

?

Step 2 : Install mingetty Source code package, download the source rpm Package I put in the source system /root/softwares/source/ directory:

[Email protected] ~]# ll/root/softwares/source/

Total 2892

-rw-r--r--1 root root?? 19624 APR? 9? mingetty-1.07-5.2.2.src.rpm

-rw-r--r--1 root root 2933601 Nov? 9? util-linux-2.13-0.59.el5_8.src.rpm

[Email protected] ~]# CD softwares/source/

[Email protected] source]# RPM-IVH mingetty-1.07-5.2.2.src.rpm

?

Red Hat's source package is installed by default in the/usr/src/redhat/source directory:

[Email protected] source]# cd/usr/src/redhat/sources/

[Email protected] sources]# Ll|grep mingetty-1.07

-rw-rw-r--? 1 root root?? 13435 Nov 17? 2006 mingetty-1.07.tar.gz

?

Step 3 : Unzip the mingetty-1.07.tar.gz and enter the Mingetty source directory:

[Email protected] sources]# Tar XF mingetty-1.07.tar.gz

[Email protected] sources]# CD mingetty-1.07

[email protected] mingetty-1.07]# LL

Total 84

-rw-rw-r--1 2455 2459 17983 Feb 14? 1996 COPYING

-rw-rw-r--1 2455 2459?? 276 May 25? 2003 Makefile

-rw-rw-r--1 2455 2459? 3993 Feb 21? 2003 Mingetty-0.9.4-autologin.patch

-rw-rw-r--1 2455 2459? 2806 May 14? 2003 mingetty.8

-rw-rw-r--1 2455 2459 10295 Dec? 2 10:40 mingetty.c

-rw-rw-r--1 2455 2459 10264 Jan? 3? 2004 Mingetty.c.bak

-rw-r--r--1 root root 10672 Dec? 2 10:17 MINGETTY.O

?

Step 4 : Modify The source code file mingetty.c implementation Open two terminals and open/bin/bash directly :

[Email protected] mingetty-1.07]# VI mingetty.c

??? part of the source code is omitted here .....

??? */* Login program invoked */

*loginprog Static char = "/bin/login";? ? change this line to: static char *loginprog = "/bin/bash";????

??? part of the source code is omitted here ..... .....

??? 409/*????? if (autologin) {??????? */

??? 410/*????????????? Do_prompt (0);? */

??? 411/*????????????? printf ("Login:%s (automatic login) \ n", autologin);??? */

??? 412/*????????????? logname = Autologin;??? */

??? 413/*????? } else? */

??? 414/*????????????? while ((logname = Get_logname ()) = = 0)???????? */

415???????????????????????? /* do nothing */;

??? put 409 Line to 415 Line all commented out

??? 416

??? 417???????? if (ch_root)

??? 418???????????????? Chroot (Ch_root);

??? 419???????? if (Ch_dir)

??? 420???????????????? ChDir (Ch_dir);

??? 421???????? if (priority)

??? 422???????????????? Nice (priority);

??? 423

??? 424???????? Execl (Loginprog, Loginprog, autologin?) "-F": "--", logname, NULL);

??? 425???????? Error ("%s:can ' t exec%s:%s", TTY, Loginprog, Strerror (errno));

??? 426???????? Sleep (5);

??? 427???????? Exit (Exit_failure);

428}

?

save exit after modifying, and then compile directly to generate mingetty binary file:

[[email protected] mingetty-1.07]# make

Gcc-o2-wall-w-pipe-d_gnu_source?? -c-o mingetty.o mingetty.c

Mingetty.c:294:warning: ' get_logname ' defined but not used

mingetty.c:in function ' main ':

Mingetty.c:424:warning: ' logname ' is used uninitialized in this function

Gcc?? MINGETTY.O?? -O mingetty? generated the mingetty file

[email protected] mingetty-1.07]# LL

Total 84

-rw-rw-r--1 2455 2459 17983 Feb 14? 1996 COPYING

-rw-rw-r--1 2455 2459?? 276 May 25? 2003 Makefile

-rwxr-xr-x 1 root root 16122 Dec? 2 12:57 Mingetty

-rw-rw-r--1 2455 2459? 3993 Feb 21? 2003 Mingetty-0.9.4-autologin.patch

-rw-rw-r--1 2455 2459? 2806 May 14? 2003 mingetty.8

-rw-rw-r--1 2455 2459 10295 Dec? 2 10:40 mingetty.c

-rw-rw-r--1 2455 2459 10264 Jan? 3? 2004 Mingetty.c.bak

-rw-r--r--1 root root 10672 Dec? 2 12:57 MINGETTY.O

?

Step 5 : Copy the recompiled mingetty file to the Minilinux/sbin/ directory and copy the dependent library file:

[email protected] mingetty-1.07]# CP mingetty/mnt/sysroot/sbin/

[Email protected] mingetty-1.07]# Ldd/sbin/mingetty???? ? View the source system's Mingetty dependent library files

??????? Linux-vdso.so.1 =>? (0x00007fff923d9000)

??????? libc.so.6 =/lib64/libc.so.6 (0x0000003977400000)

??????? /lib64/ld-linux-x86-64.so.2 (0x0000003977000000)

?

complete the process of copying a library file using the function "LIBCP" of the previously written copy library file:

[Email protected] ~]# Cd/root

[Email protected] ~]# source bincp.sh

Input command What is want to copy to Minilinux:q????????? ? exit directly to get the libcp function .

[Email protected] ~]# [[email protected] ~]# libcp/lib64/libc.so.6

Copy Lib File/lib64/libc.so.6 finished.

[Email protected] ~]# libcp/lib64/ld-linux-x86-64.so.2

Copy Lib File/lib64/ld-linux-x86-64.so.2 finished.

?

Step 6 : Modify The Minilinux system Chinese /etc/rc.d/rc.sysinit file to the following:

[Email protected] ~]# Cat/mnt/sysroot/etc/rc.d/rc.sysinit

#!/bin/bash

#

Echo-e "\twelcome to \033[31mmy team \033[0m Linux."

Insmod/lib/modules/e1000.ko

Ifconfig eth0 192.168.0.91 netmask 255.255.255.0

Ifconfig eth0 up

/bin/bash??????????? ? Delete the original line

?

Step 7 : Modify complete, hang the origin system (centos5lsrv01), start the minilinux system test:



See, this is the Linux, open source system, anything can be modified according to your wishes, if you know it enough!!

?


Linux system cut, make an extremely streamlined linux-4-for streamlined Linux system to increase user login function

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.