forked from shadow-maint/shadow
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathHOWTO
1914 lines (1386 loc) · 66.8 KB
/
HOWTO
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
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
[ Note: the installation instructions in this document are somewhat
out of date - the package now uses GNU autoconf and is configured
just like most GNU packages: run ./configure then make. --marekm ]
Linux Shadow Password HOWTO
Michael H. Jackson, mhjack@tscnet.com
v1.3, 3 April 1996
This document aims to describe how to obtain, install, and configure
the Linux password Shadow Suite. It also discusses obtaining, and
reinstalling other software and network daemons that require access to
user passwords. This other software is not actually part of the
Shadow Suite, but these programs will need to be recompiled to support
the Shadow Suite. This document also contains a programming example
for adding shadow support to a program. Answers to some of the more
frequently asked questions are included near the end of this document.
1. Introduction.
This is the Linux Shadow-Password-HOWTO. This document describes why
and how to add shadow password support on a Linux system. Some
examples of how to use some of the Shadow Suite's features is also
included.
When installing the Shadow Suite and when using many of the utility
programs, you must be logged in as root. When installing the Shadow
Suite you will be making changes to system software, and it is highly
recommended that you make backup copies of programs as indicated. I
also recommend that you read and understand all the instructions
before you begin.
1.1. Changes from the previous release.
Additions:
Added a sub-section on why you might not want to install shadow
Added a sub-section on updating the xdm program
Added a section on how to put Shadow Suite features to work
Added a section containing frequently asked questions
Corrections/Updates:
Corrected html references on Sunsite
Corrected section on wu-ftp to reflect adding -lshadow to the Makefile
Corrected minor spelling and verbiage errors
Changed section on wu-ftpd to support ELF
Updated to reflect security problems in various login programs
Updated to recommend the Linux Shadow Suite by Marek Michalkiewicz
1.2. New versions of this document.
The latest released version of this document can always be retrieved
by anonymous FTP from:
sunsite.unc.edu
/pub/Linux/docs/HOWTO/Shadow-Password-HOWTO
or:
/pub/Linux/docs/HOWTO/other-formats/Shadow-Password-HOWTO{-html.tar,ps,dvi}.gz
or via the World Wide Web from the Linux Documentation Project Web
Server <http://sunsite.unc.edu/mdw/linux.html>, at page: Shadow-
Password-HOWTO <http://sunsite.unc.edu/linux/HOWTO/Shadow-Password-
HOWTO.html> or directly from me, <mhjack@tscnet.com>. It will also be
posted to the newsgroup: comp.os.linux.answers
This document is now packaged with the Shadow-YYDDMM packages.
1.3. Feedback.
Please send any comments, updates, or suggestions to me: Michael H.
Jackson <mhjack@tscnet.com> The sooner I get feedback, the sooner I
can update and correct this document. If you find any problems with
it, please mail me directly as I very rarely stay up-to-date on the
newsgroups.
2. Why shadow your passwd file?
By default, most current Linux distributions do not contain the Shadow
Suite installed. This includes Slackware 2.3, Slackware 3.0, and
other popular distributions. One of the reasons for this is that the
copyright notices in the original Shadow Suite were not clear on
redistribution if a fee was charged. Linux uses a GNU Copyright
(sometimes refereed to as a Copyleft) that allows people to package it
into a convenient package (like a CD-ROM distribution) and charge a
fee for it.
The current maintainer of the Shadow Suite, Marek Michalkiewicz
<marekm@i17linuxb.ists.pwr.wroc.pl> received the source code from the
original author under a BSD style copyright that allowed
redistribution. Now that the copyright issues are resolved, it is
expected that future distributions will contain password shadowing by
default. Until then, you will need to install it yourself.
If you installed your distribution from a CD-ROM, you may find that,
even though the distribution did not have the Shadow Suite installed,
some of the files you need to install the Shadow Suite may be on the
CD-ROM.
However, Shadow Suite versions 3.3.1, 3.3.1-2, and shadow-mk all have
security problems with their login program and several other suid root
programs that came with them, and should no longer be used.
All of the necessary files may be obtained via anonymous FTP or
through the World Wide Web.
On a Linux system without the Shadow Suite installed, user information
including passwords is stored in the /etc/passwd file. The password
is stored in an encrypted format. If you ask a cryptography expert,
however, he or she will tell you that the password is actually in an
encoded rather than encrypted format because when using crypt(3), the
text is set to null and the password is the key. Therefore, from here
on, I will use the term encoded in this document.
The algorithm used to encode the password field is technically
referred to as a one way hash function. This is an algorithm that is
easy to compute in one direction, but very difficult to calculate in
the reverse direction. More about the actual algorithm used can be
found in section 2.4 or your crypt(3) manual page.
When a user picks or is assigned a password, it is encoded with a
randomly generated value called the salt. This means that any
particular password could be stored in 4096 different ways. The salt
value is then stored with the encoded password.
When a user logs in and supplies a password, the salt is first
retrieved from the stored encoded password. Then the supplied
password is encoded with the salt value, and then compared with the
encoded password. If there is a match, then the user is
authenticated.
It is computationally difficult (but not impossible) to take a
randomly encoded password and recover the original password. However,
on any system with more than just a few users, at least some of the
passwords will be common words (or simple variations of common words).
System crackers know all this, and will simply encrypt a dictionary of
words and common passwords using all possible 4096 salt values. Then
they will compare the encoded passwords in your /etc/passwd file with
their database. Once they have found a match, they have the password
for another account. This is referred to as a dictionary attack, and
is one of the most common methods for gaining or expanding
unauthorized access to a system.
If you think about it, an 8 character password encodes to 4096 * 13
character strings. So a dictionary of say 400,000 common words,
names, passwords, and simple variations would easily fit on a 4GB hard
drive. The attacker need only sort them, and then check for matches.
Since a 4GB hard drive can be had for under $1000.00, this is well
within the means of most system crackers.
Also, if a cracker obtains your /etc/passwd file first, they only need
to encode the dictionary with the salt values actually contained in
your /etc/passwd file. This method is usable by your average teenager
with a couple of hundred spare Megabytes and a 486 class computer.
Even without lots of drive space, utilities like crack(1) can usually
break at least a couple of passwords on a system with enough users
(assuming the users of the system are allowed to pick their own
passwords).
The /etc/passwd file also contains information like user ID's and
group ID's that are used by many system programs. Therefore, the
/etc/passwd file must remain world readable. If you were to change
the /etc/passwd file so that nobody can read it, the first thing that
you would notice is that the ls -l command now displays user ID's
instead of names!
The Shadow Suite solves the problem by relocating the passwords to
another file (usually /etc/shadow). The /etc/shadow file is set so
that it cannot be read by just anyone. Only root will be able to read
and write to the /etc/shadow file. Some programs (like xlock) don't
need to be able to change passwords, they only need to be able to
verify them. These programs can either be run suid root or you can
set up a group shadow that is allowed read only access to the
/etc/shadow file. Then the program can be run sgid shadow.
By moving the passwords to the /etc/shadow file, we are effectively
keeping the attacker from having access to the encoded passwords with
which to perform a dictionary attack.
Additionally, the Shadow Suite adds lots of other nice features:
· A configuration file to set login defaults (/etc/login.defs)
· Utilities for adding, modifying, and deleting user accounts and
groups
· Password aging and expiration
· Account expiration and locking
· Shadowed group passwords (optional)
· Double length passwords (16 character passwords) NOT RECOMMENDED
· Better control over user's password selection
· Dial-up passwords
· Secondary authentication programs NOT RECOMMENDED
Installing the Shadow Suite contributes toward a more secure system,
but there are many other things that can also be done to improve the
security of a Linux system, and there will eventually be a series of
Linux Security HOWTO's that will discuss other security measures and
related issues.
For current information on other Linux security issues, including
warnings on known vulnerabilities see the Linux Security home page.
<http://bach.cis.temple.edu/linux/linux-security/>
2.1. Why you might NOT want to shadow your passwd file.
There are a few circumstances and configurations in which installing
the Shadow Suite would NOT be a good idea:
· The machine does not contain user accounts.
· Your machine is running on a LAN and is using NIS (Network
Information Services) to get or supply user names and passwords to
other machines on the network. (This can actually be done, but is
beyond the scope of this document, and really won't increase
security much anyway)
· Your machine is being used by terminal servers to verify users via
NFS (Network File System), NIS, or some other method.
· Your machine runs other software that validates users, and there is
no shadow version available, and you don't have the source code.
2.2. Format of the /etc/passwd file
A non-shadowed /etc/passwd file has the following format:
username:passwd:UID:GID:full_name:directory:shell
Where:
username
The user (login) name
passwd
The encoded password
UID
Numerical user ID
GID
Numerical default group ID
full_name
The user's full name - Actually this field is called the GECOS
(General Electric Comprehensive Operating System) field and can
store information other than just the full name. The Shadow
commands and manual pages refer to this field as the comment
field.
directory
User's home directory (Full pathname)
shell
User's login shell (Full Pathname)
For example:
username:Npge08pfz4wuk:503:100:Full Name:/home/username:/bin/sh
Where Np is the salt and ge08pfz4wuk is the encoded password. The
encoded salt/password could just as easily have been kbeMVnZM0oL7I and
the two are exactly the same password. There are 4096 possible encod
ings for the same password. (The example password in this case is
'password', a really bad password).
Once the shadow suite is installed, the /etc/passwd file would instead
contain:
username:x:503:100:Full Name:/home/username:/bin/sh
The x in the second field in this case is now just a place holder.
The format of the /etc/passwd file really didn't change, it just no
longer contains the encoded password. This means that any program
that reads the /etc/passwd file but does not actually need to verify
passwords will still operate correctly.
The passwords are now relocated to the shadow file (usually
/etc/shadow file).
2.3. Format of the shadow file
The /etc/shadow file contains the following information:
username:passwd:last:may:must:warn:expire:disable:reserved
Where:
username
The User Name
passwd
The Encoded password
last
Days since Jan 1, 1970 that password was last changed
may
Days before password may be changed
must
Days after which password must be changed
warn
Days before password is to expire that user is warned
expire
Days after password expires that account is disabled
disable
Days since Jan 1, 1970 that account is disabled
reserved
A reserved field
The previous example might then be:
username:Npge08pfz4wuk:9479:0:10000::::
2.4. Review of crypt(3).
From the crypt(3) manual page:
"crypt is the password encryption function. It is based on the Data
Encryption Standard algorithm with variations intended (among other
things) to discourage use of hardware implementations of a key search.
The key is a user's typed password. The encoded string is all NULLs
The salt is a two-character string chosen from the set a-zA-Z0-9./.
This string is used to perturb the algorithm in one of 4096 different
ways.
By taking the lowest 7 bits of each character of the key, a 56-bit key
is obtained. This 56-bit key is used to encrypt repeatedly a constant
string (usually a string consisting of all zeros). The returned value
points to the encrypted password, a series of 13 printable ASCII
characters (the first two characters represent the salt itself). The
return value points to static data whose content is overwritten by
each call.
Warning: The key space consists of 2**56 equal 7.2e16 possible values.
Exhaustive searches of this key space are possible using massively
parallel computers. Software, such as crack(1), is available which
will search the portion of this key space that is generally used by
humans for passwords. Hence, password selection should, at minimum,
avoid common words and names. The use of a passwd(1) program that
checks for crackable passwords during the selection process is
recommended.
The DES algorithm itself has a few quirks which make the use of the
crypt(3) interface a very poor choice for anything other than password
authentication. If you are planning on using the crypt(3) interface
for a cryptography project, don't do it: get a good book on encryption
and one of the widely available DES libraries."
Most Shadow Suites contain code for doubling the length of the
password to 16 characters. Experts in des recommend against this, as
the encoding is simply applied first to the left half and then to the
right half of the longer password. Because of the way crypt works,
this may make for a less secure encoded password then if double length
passwords were not used in the first place. Additionally, it is less
likely that a user will be able to remember a 16 character password.
There is development work under way that would allow the
authentication algorithm to be replaced with something more secure and
with support for longer passwords (specifically the MD5 algorithm) and
retain compatibility with the crypt method.
If you are looking for a good book on encryption, I recommend:
"Applied Cryptography: Protocols, Algorithms, and Source Code in C"
by Bruce Schneier <schneier@chinet.com>
ISBN: 0-471-59756-2
3. Getting the Shadow Suite.
3.1. History of the Shadow Suite for Linux
DO NOT USE THE PACKAGES IN THIS SECTION, THEY HAVE SECURITY PROBLEMS
The original Shadow Suite was written by Julianne F. Haugh
There are several versions that have been used on Linux systems:
· shadow-3.3.1 is the original.
· shadow-3.3.1-2 is Linux specific patch made by Florian La Roche
<flla@stud.uni-sb.de> and contains some further enhancements.
· shadow-mk was specifically packaged for Linux.
The shadow-mk package contains the shadow-3.3.1 package distributed by
Julianne F. Haugh with the shadow-3.3.1-2 patch installed, a few fixes
made by Mohan Kokal <magnus@texas.net> that make installation a lot
easier, a patch by Joseph R.M. Zbiciak for login1.c (login.secure)
that eliminates the -f, -h security holes in /bin/login, and some
other miscellaneous patches.
The shadow.mk package was the previously recommended package, but
should be replaced due to a security problem with the login program.
There are security problems with Shadow versions 3.3.1, 3.3.1-2, and
shadow-mk involving the login program. This login bug involves not
checking the length of a login name. This causes the buffer to
overflow causing crashes or worse. It has been rumored that this
buffer overflow can allow someone with an account on the system to use
this bug and the shared libraries to gain root access. I won't
discuss exactly how this is possible because there are a lot of Linux
systems that are affected, but systems with these Shadow Suites
installed, and most pre-ELF distributions without the Shadow Suite are
vulnerable!
For more information on this and other Linux security issues, see the
Linux Security home page (Shared Libraries and login Program
Vulnerability) <http://bach.cis.temple.edu/linux/linux-security/Linux-
Security-FAQ/Linux-telnetd.html>
3.2. Where to get the Shadow Suite.
The only recommended Shadow Suite is still in BETA testing, however
the latest versions are safe in a production environment and don't
contain a vulnerable login program.
The package uses the following naming convention:
shadow-YYMMDD.tar.gz
where YYMMDD is the issue date of the Suite.
This version will eventually be Version 3.3.3 when it is released from
Beta testing, and is maintained by Marek Michalkiewicz
<marekm@i17linuxb.ists.pwr.wroc.pl>. It's available as: shadow-
current.tar.gz
<ftp://i17linuxb.ists.pwr.wroc.pl/pub/linux/shadow/shadow-
current.tar.gz>.
The following mirror sites have also been established:
· ftp://ftp.icm.edu.pl/pub/Linux/shadow/shadow-current.tar.gz
· ftp://iguana.hut.fi/pub/linux/shadow/shadow-current.tar.gz
· ftp://ftp.cin.net/usr/ggallag/shadow/shadow-current.tar.gz
· ftp://ftp.netural.com/pub/linux/shadow/shadow-current.tar.gz
You should use the currently available version.
You should NOT use a version older than shadow-960129 as they also
have the login security problem discussed above.
When this document refers to the Shadow Suite I am referring to the
this package. It is assumed that this is the package that you are
using.
For reference, I used shadow-960129 to make these installation
instructions.
If you were previously using shadow-mk, you should upgrade to this
version and rebuild everything that you originally compiled.
3.3. What is included with the Shadow Suite.
The Shadow Suite contains replacement programs for:
su, login, passwd, newgrp, chfn, chsh
The package also contains the new programs:
chage, newusers, dpasswd, gpasswd, useradd, userdel, usermod,
groupadd, groupdel, groupmod, pwck, grpck, lastlog, pwconv,
and pwunconv
Additionally, the library: libshadow.a is included for writing and/or
compiling programs that need to access user passwords.
Also, manual pages for the programs are also included.
There is also a configuration file for the login program which will be
installed as /etc/login.defs.
4. Compiling the programs.
4.1. Unpacking the archive.
The first step after retrieving the package is unpacking it. The
package is in the tar (tape archive) format and compressed using gzip,
so first move it to /usr/src, then type:
tar -xzvf shadow-current.tar.gz
This will unpack it into the directory: /usr/src/shadow-YYMMDD
4.2. Configuring with the config.h file
The first thing that you need to do is to copy over the Makefile and
the config.h file:
cd /usr/src/shadow-YYMMDD
cp Makefile.linux Makefile
cp config.h.linux config.h
You should then take a look at the config.h file. This file contains
definitions for some of the configuration options. If you are using
the recommended package, I recommend that you disable group shadow
support for your first time around.
By default shadowed group passwords are enabled. To disable these
edit the config.h file, and change the #define SHADOWGRP to #undef
SHADOWGRP. I recommend that you disable them to start with, and then
if you really want group passwords and group administrators that you
enable it later and recompile. If you leave it enabled, you must
create the file /etc/gshadow.
Enabling the long passwords option is NOT recommended as discussed
above.
Do NOT change the setting: #undef AUTOSHADOW
The AUTOSHADOW option was originally designed so that programs that
were shadow ignorant would still function. This sounds good in
theory, but does not work correctly. If you enable this option, and
the program runs as root, it may call getpwnam() as root, and later
write the modified entry back to the /etc/passwd file (with the no-
longer-shadowed password). Such programs include chfn and chsh. (You
can't get around this by swapping real and effective uid before
calling getpwnam() because root may use chfn and chsh too.)
The same warning is also valid if you are building libc, it has a
SHADOW_COMPAT option which does the same thing. It should NOT be
used! If you start getting encoded passwords back in your /etc/passwd
file, this is the problem.
If you are using a libc version prior to 4.6.27, you will need to make
a couple more changes to config.h and the Makefile. To config.h edit
and change:
#define HAVE_BASENAME
to:
#undef HAVE_BASENAME
And then in the Makefile, change:
SOBJS = smain.o env.o entry.o susetup.o shell.o \
sub.o mail.o motd.o sulog.o age.o tz.o hushed.o
SSRCS = smain.c env.c entry.c setup.c shell.c \
pwent.c sub.c mail.c motd.c sulog.c shadow.c age.c pwpack.c rad64.c \
tz.c hushed.c
SOBJS = smain.o env.o entry.o susetup.o shell.o \
sub.o mail.o motd.o sulog.o age.o tz.o hushed.o basename.o
SSRCS = smain.c env.c entry.c setup.c shell.c \
pwent.c sub.c mail.c motd.c sulog.c shadow.c age.c pwpack.c rad64.c \
tz.c hushed.c basename.c
These changes add the code contained in basename.c which is contained
in libc 4.6.27 and later.
4.3. Making backup copies of your original programs.
It would also be a good idea to track down and make backup copies of
the programs that the shadow suite will replace. On a Slackware 3.0
system these are:
· /bin/su
· /bin/login
· /usr/bin/passwd
· /usr/bin/newgrp
· /usr/bin/chfn
· /usr/bin/chsh
The BETA package has a save target in the Makefile, but it's commented
out because different distributions place the programs in different
places.
You should also make a backup copy of your /etc/passwd file, but be
careful to name it something else if you place it in the same
directory so you don't overwrite the passwd command.
4.4. Running make
You need to be logged as root to do most of the installation.
Run make to compile the executables in the package:
make all
You may see the warning: rcsid defined but not used. This is fine, it
just happens because the author is using a version control package.
5. Installing
5.1. Have a boot disk handy in case you break anything.
If something goes terribly wrong, it would be handy to have a boot
disk. If you have a boot/root combination from your installation,
that will work, otherwise see the Bootdisk-HOWTO
<http://sunsite.unc.edu/mdw/HOWTO/Bootdisk-HOWTO.html>, which
describes how to make a bootable disk.
5.2. Removing duplicate man pages
You should also move the manual pages that are about to be replaced.
Even if you are brave enough install the Shadow Suite without making
backups, you will still want to remove the old manual pages. The new
manual pages won't normally overwrite the old ones because the old
ones are probably compressed.
You can use a combination of: man -aW command and locate command to
locate the manual pages that need to be (re)moved. It's generally
easier to figure out which are the older pages before you run make
install.
If you are using the Slackware 3.0 distribution, then the manual pages
you want to remove are:
· /usr/man/man1/chfn.1.gz
· /usr/man/man1/chsh.1.gz
· /usr/man/man1/login.1.gz
· /usr/man/man1/passwd.1.gz
· /usr/man/man1/su.1.gz
· /usr/man/man5/passwd.5.gz
There may also be man pages of the same name in the /var/man/cat[1-9]
subdirectories that should also be deleted.
5.3. Running make install
You are now ready to type: (do this as root)
make install
This will install the new and replacement programs and fix-up the file
permissions. It will also install the man pages.
This also takes care of installing the Shadow Suite include files in
the correct places in /usr/include/shadow.
Using the BETA package you must manually copy the file login.defs to
the /etc subdirectory and make sure that only root can make changes to
it.
cp login.defs /etc
chmod 700 /etc/login.defs
This file is the configuration file for the login program. You should
review and make changes to this file for your particular system. This
is where you decide which tty's root can login from, and set other
security policy settings (like password expiration defaults).
5.4. Running pwconv
The next step is to run pwconv. This must also be done as root, and
is best done from the /etc subdirectory:
cd /etc
/usr/sbin/pwconv
pwconv takes your /etc/passwd file and strips out the fields to create
two files: /etc/npasswd and /etc/nshadow.
A pwunconv program is also provided if you need to make a normal
/etc/passwd file out of an /etc/passwd and /etc/shadow combination.
5.5. Renaming npasswd and nshadow
Now that you have run pwconv you have created the files /etc/npasswd
and /etc/nshadow. These need to be copied over to /etc/passwd and
/etc/shadow. We also want to make a backup copy of the original
/etc/passwd file, and make sure only root can read it. We'll put the
backup in root's home directory:
cd /etc
cp passwd ~passwd
chmod 600 ~passwd
mv npasswd passwd
mv nshadow shadow
You should also ensure that the file ownerships and permissions are
correct. If you are going to be using X-Windows, the xlock and xdm
programs need to be able to read the shadow file (but not write it).
There are two ways that this can be done. You can set xlock to suid
root (xdm is usually run as root anyway). Or you can make the shadow
file owned by root with a group of shadow, but before you do this,
make sure that you have a shadow group (look in /etc/group). None of
the users on the system should actually be in the shadow group.
chown root.root passwd
chown root.shadow shadow
chmod 0644 passwd
chmod 0640 shadow
Your system now has the password file shadowed. You should now pop
over to another virtual terminal and verify that you can login.
Really, do this now!
If you can't, then something is wrong! To get back to a non-shadowed
state, do the following the following:
cd /etc
cp ~passwd passwd
chmod 644 passwd
You would then restore the files that you saved earlier to their
proper locations.
6. Other programs you may need to upgrade or patch
Even though the shadow suite contains replacement programs for most
programs that need to access passwords, there are a few additional
programs on most systems that require access to passwords.
If you are running a Debian Distribution (or even if you are not), you
can obtain Debian sources for the programs that need to be rebuild
from: ftp://ftp.debian.org/debian/stable/source/
The remainder of this section discusses how to upgrade adduser,
wu_ftpd, ftpd, pop3d, xlock, xdm and sudo so that they support the
shadow suite.
See the section ``Adding Shadow Support to a C program'' for a
discussion on how to put shadow support into any other program that
needs it (although the program must then be run SUID root or SGID
shadow to be able to actually access the shadow file).
6.1. Slackware adduser program
Slackware distributions (and possibly some others) contain a
interactive program for adding users called /sbin/adduser. A shadow
version of this program can be obtained from
ftp://sunsite.unc.edu/pub/Linux/
system/Admin/accounts/adduser.shadow-1.4.tar.gz.
I would encourage you to use the programs that are supplied with the
Shadow Suite (useradd, usermod, and userdel) instead of the slackware
adduser program. They take a little time to learn how to use, but
it's well worth the effort because you have much more control and they
perform proper file locking on the /etc/passwd and /etc/shadow file
(adduser doesn't).
See the section on ``Putting the Shadow Suite to use'' for more
information.
But if you gotta have it, here is what you do:
tar -xzvf adduser.shadow-1.4.tar.gz
cd adduser
make clean
make adduser
chmod 700 adduser
cp adduser /sbin
6.2. The wu_ftpd Server
Most Linux systems some with the wu_ftpd server. If your distribution
does not come with shadow installed, then your wu_ftpd will not be
compiled for shadow. wu_ftpd is launched from inetd/tcpd as a root
process. If you are running an old wu_ftpd daemon, you will want to
upgrade it anyway because older ones had a bug that would allow the
root account to be compromised (For more info see the Linux security
home page <http://bach.cis.temple.edu/linux/linux-security/Linux-
Security-FAQ/Linux-wu.ftpd-2.4-Update.html>).
Fortunately, you only need to get the source code and recompile it
with shadow enabled.
If you are not running an ELF system, The wu_ftp server can be found
on Sunsite as wu-ftp-2.4-fixed.tar.gz
<ftp://sunsite.unc.edu/pub/Linux/system/Network/file-transfer/wu-
ftpd-2.4-fixed.tar.gz>
Once you retrieve the server, put it in /usr/src, then type:
cd /usr/src
tar -xzvf wu-ftpd-2.4-fixed.tar.gz
cd wu-ftpd-2.4-fixed
cp ./src/config/config.lnx.shadow ./src/config/config.lnx
Then edit ./src/makefiles/Makefile.lnx, and change the line:
LIBES = -lbsd -support
to:
LIBES = -lbsd -support -lshadow
Now you are ready to run the build script and install:
cd /usr/src/wu-ftpd-2.4-fixed
/usr/src/wu-ftp-2.4.fixed/build lnx
cp /usr/sbin/wu.ftpd /usr/sbin/wu.ftpd.old
cp ./bin/ftpd /usr/sbin/wu.ftpd
This uses the Linux shadow configuration file, compiles and installs
the server.
On my Slackware 2.3 system I also had to do the following before
running build:
cd /usr/include/netinet
ln -s in_systm.h in_system.h
cd -
Problems have been reported compiling this package under ELF systems,
but the Beta version of the next release works fine. It can be found
as wu-ftp-2.4.2-beta-10.tar.gz
<ftp://tscnet.com/pub/linux/network/ftp/wu-ftpd-2.4.2-beta-10.tar.gz>
Once you retrieve the server, put it in /usr/src, then type:
cd /usr/src
tar -xzvf wu-ftpd-2.4.2-beta-9.tar.gz
cd wu-ftpd-beta-9
cd ./src/config
Then edit config.lnx, and change:
#undef SHADOW.PASSWORD
to:
#define SHADOW.PASSWORD
Then,
cd ../Makefiles
and edit the file Makefile.lnx and change:
LIBES = -lsupport -lbsd # -lshadow
to:
LIBES = -lsupport -lbsd -lshadow
Then build and install:
cd ..
build lnx
cp /usr/sbin/wu.ftpd /usr/sbin/wu.ftpd.old
cp ./bin/ftpd /usr/sbin/wu.ftpd
Note that you should check your /etc/inetd.conf file to make sure that
this is where your wu.ftpd server really lives. It has been reported
that some distributions place the server daemons in different places,
and then wu.ftpd in particular may be named something else.
6.3. Standard ftpd
If you are running the standard ftpd server, I would recommend that
you upgrade to the wu_ftpd server. Aside from the known bug discussed
above, it's generally thought to be more secure.
If you insist on the standard one, or you need NIS support, Sunsite
has ftpd-shadow-nis.tgz
<ftp://sunsite.unc.edu/pub/Linux/system/Network/file-transfer/ftpd-
shadow-nis.tgz>
6.4. pop3d (Post Office Protocol 3)
If you need to support the third Post Office Protocol (POP3), you will
need to recompile a pop3d program. pop3d is normally run by
inetd/tcpd as root.
There are two versions available from Sunsite:
pop3d-1.00.4.linux.shadow.tar.gz
<ftp://sunsite.unc.edu/pub/Linux/system/Mail/pop/pop3d-1.00.4.linux.shadow.tar.gz>
and pop3d+shadow+elf.tar.gz
<ftp://sunsite.unc.edu/pub/Linux/system/Mail/pop/pop3d+shadow+elf.tar.gz>
Both of these are fairly straight forward to install.
6.5. xlock
If you install the shadow suite, and then run X Windows System and
lock the screen without upgrading your xlock, you will have to use
CNTL-ALT-Fx to switch to another tty, login, and kill the xlock
process (or use CNTL-ALT-BS to kill the X server). Fortunately it's
fairly easy to upgrade your xlock program.
If you are running XFree86 Versions 3.x.x, you are probably using
xlockmore (which is a great screen-saver in addition to a lock). This
package supports shadow with a recompile. If you have an older xlock,
I recommend that you upgrade to this one.
xlockmore-3.5.tgz is available at:
<ftp://sunsite.unc.edu/pub/Linux/X11/xutils/screensavers/xlockmore-3.7.tgz>
Basically, this is what you need to do:
Get the xlockmore-3.7.tgz file and put it in /usr/src unpack it:
tar -xzvf xlockmore-3.7.tgz
Edit the file: /usr/X11R6/lib/X11/config/linux.cf, and change the
line:
#define HasShadowPasswd NO
to
#define HasShadowPasswd YES
Then build the executables:
cd /usr/src/xlockmore
xmkmf
make depend
make
Then move everything into place and update file ownerships and
permissions:
cp xlock /usr/X11R6/bin/
cp XLock /var/X11R6/lib/app-defaults/
chown root.shadow /usr/X11R6/bin/xlock
chmod 2755 /usr/X11R6/bin/xlock
chown root.shadow /etc/shadow
chmod 640 /etc/shadow
Your xlock will now work correctly.
6.6. xdm
xdm is a program that presents a login screen for X-Windows. Some
systems start xdm when the system is told to goto a specified run
level (see /etc/inittab.
With the Shadow Suite install, xdm will need to be updated.
Fortunately it's fairly easy to upgrade your xdm program.
xdm.tar.gz is available at:
<ftp://sunsite.unc.edu/pub/Linux/X11/xutils/xdm.tar.gz>
Get the xdm.tar.gz file and put it in /usr/src, then to unpack it:
tar -xzvf xdm.tar.gz
Edit the file: /usr/X11R6/lib/X11/config/linux.cf, and change the
line:
#define HasShadowPasswd NO
to
#define HasShadowPasswd YES
Then build the executables:
cd /usr/src/xdm
xmkmf
make depend
make
Then move everything into place:
cp xdm /usr/X11R6/bin/
xdm is run as root so you don't need to change it file permissions.
6.7. sudo
The program sudo allows a system administrator to let users run
programs that would normally require root access. This is handy
because it lets the administrator limit access to the root account
itself while still allowing users to do things like mounting drives.
sudo needs to read passwords because it verifies the users password
when it's invoked. sudo already runs SUID root, so accessing the
/etc/shadow file is not a problem.
sudo for the shadow suite, is available as at:
<ftp://sunsite.unc.edu/pub/Linux/system/Admin/sudo-1.2-shadow.tgz>
Warning: When you install sudo your /etc/sudoers file will be replaced
with a default one, so you need to make a backup of it if you have