aboutsummaryrefslogtreecommitdiff
path: root/riemann.fmi.uni-sofia.bg/ngetty/index.html
blob: 4e53767d86505bf51116dc48113f76d416652fde (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
<html>
<link rel="stylesheet" type="text/css" href="style.css">
<title>ngetty</title>
<body>

<div class="top">
<ul class="nav">
  <li><a href="all.html">All files</a>
</ul>

<h1>ngetty - one daemon for all virtual consoles</h1>
<div class="endtop"></div>
</div>

<table>
<ul>
<td>
<li>
  <a href=/ngetty/old/ngetty-1.0.tar.gz>
  ngetty-1.0.tar.gz</a> (old)
</li><li>
  <a href=/ngetty/ngetty-1.1.tar.gz>
  ngetty-1.1.tar.gz</a> (stable)
</li><li>
  <a href=all.html>Index</a>
</li>
</ul>

</td><td>
<ul>
<li>
   Manual <a href=/ngetty/ngetty.man> page</a>
</li><li>
   Other <a href=/ngetty/pr_other.html> programs</a>
</li><li>
   Binary <a href=/ngetty/binary/> packages</a>
</li>
</ul>

</td><td>
<ul>
<li>
  Recent <a href=News.txt>news</a>
</li><li>
  Security <a href=guarantee.html>guarantee</a>
</li>
</ul>
</td>

</table>

<h2>About</h2>
<b>ngetty</b> is a daemon that starts login sessions on virtual console
terminals, on demand.  It is a good replacement for all those getty
processes started from init that, most of the time, are only taking up
memory.  When compiled statically with dietlibc, the ngetty binary
size is only about 2k and uses considerably less 
<a href="pr_other.html#Memory">memory</a>
than a getty.  See pstree <a href=ps_tree>here</a>.
<a name="Resources">
<pre>
riemann$  ps uww -C ngetty 
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 145  0.0  0.0   8   8 ?   Ss   Jan05 0:00 ngetty 1 2 3 4
</pre>
</a>

Ngetty is designed to stop including <b>getty-like</b> code 
in init programs.
<br>
I used source and ideas from
<a href=http://sites.google.com/site/anbadeol/logind>logind</a>.
Many thanks, Andre!

<p>
<a name=List>
There is a
&#109;&#97;&#105;&#108;&#105;&#110;&#103;&#32;&#108;&#105;&#115;&#116;
for ngetty.  To &#115;&#117;&#98;&#115;&#99;&#114;&#105;&#98;&#101;&#44;
send an empty &#109;&#101;&#115;&#115;&#97;&#103;&#101;
to <br>
<font size=+1>
<a href=
&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#110;&#103;&#101;&#116;&#116;&#121;&#45;&#115;&#117;&#98;&#115;&#99;&#114;&#105;&#98;&#101;&#64;&#114;&#105;&#101;&#109;&#97;&#110;&#110;&#46;&#102;&#109;&#105;&#46;&#117;&#110;&#105;&#45;&#115;&#111;&#102;&#105;&#97;&#46;&#98;&#103;
>
&#110;&#103;&#101;&#116;&#116;&#121;&#45;&#115;&#117;&#98;&#115;&#99;&#114;&#105;&#98;&#101;&#64;&#114;&#105;&#101;&#109;&#97;&#110;&#110;&#46;&#102;&#109;&#105;&#46;&#117;&#110;&#105;&#45;&#115;&#111;&#102;&#105;&#97;&#46;&#98;&#103;
</a>
</font>
</a>
<br>
Some delay is possible due to
&#103;&#114;&#101;&#121;&#108;&#105;&#115;&#116;&#105;&#110;&#103;&#46;

<h2>Benefits</h2>
<ul>
<li> 
  one process (instead of many) using
  minimal <a href="#Resources">resources</a>
</li><li>
  work with different <a href="#Login">login</a> applications
<br> 
  can start any program with arbitrary arguments
</li><li>
  easy to start by
  <a href="#Init_d"><tt>init.d</tt></a>
or 
  <a href="#Inittab"><tt>/etc/inittab</tt></a><br>
  easy to start by other <a href="#Init">init</a> systems
</li><li>
  makes <b>utmp/wtmp</b> records<br>
  no need of <b>ngetty</b>-monitoring by some other process
</li><li>
  easy to setup modifying <tt>/etc/ngetty/Conf[.sed]</tt>
</li><li>
  modular (<tt>ngetty-helper</tt> and
  <tt>ngetty-argv</tt>)
</li><li>
  easy to upgrade <tt>ngetty-helper</tt><br>
  <tt>cp /path/to/new/ngetty-helper /sbin</tt>
</li><li>
  uses minimal <tt>libc</tt> library functions<br>
  easy to build by 
  <a href=http://www.fefe.de/dietlibc/>dietlibc</a> -
  <tt>make CC='diet -Os gcc'</tt>
</li><li> 
  small code size with <a href=guarantee.html>security</a> guarantee
<li> 
</ul>

<h2>Install</h2>
Ready to use binary packages are 
<a href=binary/>here</a>.
I prepared them using
<pre>
  make package CC='diet -Os gcc -W'
  make rpm
</pre>

If you have
<a href=http://www.fefe.de/dietlibc/>
dietlibc</a>  already installed do
<pre>
  wget http://riemann.fmi.uni-sofia.bg/ngetty/ngetty-1.1.tar.gz
  gzip -dc ngetty-1.1.tar.gz | tar -xv
  cd ngetty-1.1
  # Read the ngetty.8 manual page (man ./ngetty.8)
  # Browse lib.h (check if the LOGIN path is correct!)
  # Edit Makefile to taste
  make CC='diet -Os gcc -W'
  make install
  # If you want to install some additional programs do:
  make install_other
</pre>
To compile <tt>ngetty</tt> with glibc skip <tt>CC=...</tt> above.
<pre>
  make
  make install
</pre>
It is possible to do also
<pre>
  make dietbuild
  make install
</pre>
Last download and install dietlibc in current dir and then
compile ngetty.  It takes 
1-2 minutes to build dietlibc (depends on how fast ist your CPU).
See also <a href=pr_other.html>here</a>.

<h2>Post install</h2>
Browse the files: <tt>/etc/ngetty/Conf[.sed], /etc/ngetty/sample.Conf</tt>
<br>
<a name="Init_d">
Execute <tt>./init.d/ngetty start</tt></a>
<br>
If all is right you'll have working terminals on
<br>
<tt>/dev/tty{8|9|10}</tt> or <tt>/dev/vc/{8|9|10}</tt>
<br> 
Try to login/logout on some of them.  
<p>
  Some logins requires the TTY variable.  Set it in
  <tt>/etc/ngetty/Conf</tt>.  
  How to do this see the 
<a href=ngetty.man>manual</a> page of ngetty.  Examples:
<pre>
  tty4=environ=,TERM=linux,TTY=/dev/tty4
  tty5=environ=,TERM=linux,TTY=/dev/tty5
  tty6=environ=,TERM=linux,TTY=/dev/tty6
</pre>
If you can login in the system then
you can make ngetty default.  
</br>
You have to edit
<tt>/etc/inittab</tt> file.
<p>
Do this in two steps.  Fist comment default getty on
<tt>tty{4|5|6}</tt>
<br>
and edit
<tt>/etc/inittab</tt> like next:
<pre>
	 1:2345:respawn:/sbin/mingetty tty1
	 2:2345:respawn:/sbin/mingetty tty2
	 3:2345:respawn:/sbin/mingetty tty3
	 # 4:2345:respawn:/sbin/mingetty tty4
	 # 5:2345:respawn:/sbin/mingetty tty5
	 # 6:2345:respawn:/sbin/mingetty tty6

	 # Run ngetty in standard run-levels
	 ng:2345:respawn:/sbin/ngetty 4 5 6
</pre>
If your <tt>/etc/inittab</tt> have different entries only comment
the last three of them and add two lines for ngetty as above.
Now it's time to reboot the computer.  After the reboot
try to login/logout on <tt>tty{4|5|6}</tt>.
<p>
<a name=Inittab>
If it is successful change <tt>/etc/inittab</tt></a>
like:
<pre>
	 # 1:2345:respawn:/sbin/mingetty tty1
	 # 2:2345:respawn:/sbin/mingetty tty2
	 # 3:2345:respawn:/sbin/mingetty tty3
	 # 4:2345:respawn:/sbin/mingetty tty4
	 # 5:2345:respawn:/sbin/mingetty tty5
	 # 6:2345:respawn:/sbin/mingetty tty6

	 # Run ngetty in standard run-levels
	 ng:2345:respawn:/sbin/ngetty 1 2 3 4 5 6
</pre>
and reboot again. 
<br>
That's all.  You will have one ngetty instead of six 
<tt>{a|f|min}getty</tt>.
<br>
If  <tt>ngetty</tt> is compiled with dietlibc it will use 16k RAM only.
<p>
<font color=red>WARNING</font>:
May be it's possible to make all without reboot.  I don't use 
<tt>/sbin/init</tt> and don't know how to do this.  The manual page
<b>init</b>(8) says to use <tt>kill -HUP 1</tt>


<h2><a name="Init">Using ngetty with other init systems</a></h2>
If you use  
<a href=http://www.fefe.de/minit/>minit</a> or
<a href=/ninit/>ninit</a> you have
to make one new service <tt>ngetty</tt>, include it in
<br>
<tt>default/depends</tt> and comment running <tt>getty</tt>
there.
<p>
The preparation of service <tt>ngetty</tt> is simple:
<pre>
  mkdir /etc/ninit/ngetty
  cd /etc/ninit/ngetty
  ( echo '' ; echo TERM=linux ) > environ
  ( for f in 1 2 3 4 5 6 ; do echo $f ; done ) > params
  ln -s /sbin/ngetty run
</pre>
You can use ngetty also with <a href=http://smarden.org/runit/>runit</a>.
Start it as ordinary service.  Since ngetty does utmp/wtmp records there
is no need ot any additional setup.

<h2><a name="Login">Using ngetty with other logins</a></h2>
Ngetty uses the deafult <tt>/bin/login</tt> program.
It's easy to use another login also.
<br>
My login program is 
<a href=/programs/nlogin-0.3-pre.tar.gz>here</a>.  
Copy it to <tt>/bin/nlogin</tt> and add in 
<tt>/etc/ngetty/Conf</tt>
<pre>
=login-prog=/bin/nlogin
</pre>

It's possible to start any program with arbitrary arguments using
<tt>ngetty-argv</tt> helper.
<br>
To use ngetty with <a href=http://www.fefe.de/fgetty/>fgetty</a>
logins add in <tt>/etc/ngetty/Conf</tt>
<pre>
=echo-off
=login-prog=/bin/login1
   on debian system replace login1 with fgetty-login
</pre>

I still use 
startx script with my <a href=/programs/xinit.c>xinit.c</a>. 

<p>
<hr>

Author:  Nikola Vladov
<p>
Send comments and suggestions using
ngetty 
<a
href=#List>&#109;&#97;&#105;&#108;&#105;&#110;&#103;&#45;&#108;&#105;&#115;&#116;</a>
or
<a href=/email.html>qform</a>.
<p>
Last modified: 26 May 2010.
<br>
Some <a href=comments.txt>comments</a> about ngetty.
</body>
</html>