Linux sagir-us1.hostever.us 5.14.0-570.51.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Oct 8 09:41:34 EDT 2025 x86_64
LiteSpeed
Server IP : 104.247.108.91 & Your IP : 216.73.216.105
Domains : 74 Domain
User : georgeto
Terminal
Auto Root
Create File
Create Folder
Localroot Suggester
Backdoor Destroyer
Readme
/
usr /
local /
apps /
lib /
imap /
c-client /
Delete
Unzip
Name
Size
Permission
Date
Action
ARCHIVE
258
B
-rw-r--r--
2023-01-11 06:22
CCTYPE
3
B
-rw-r--r--
2023-01-11 06:22
CFLAGS
74
B
-rw-r--r--
2023-01-11 06:22
LDFLAGS
118
B
-rw-r--r--
2023-01-11 06:22
Makefile
31.74
KB
-rw-r--r--
2023-01-11 06:22
Makefile.gss
1.28
KB
-rw-r--r--
2023-01-11 06:22
OSCFLAGS
535
B
-rw-r--r--
2023-01-11 06:22
OSTYPE
4
B
-rw-r--r--
2023-01-11 06:22
SPECIALS
1
B
-rw-r--r--
2023-01-11 06:22
auth_ext.c
2.88
KB
-rw-r--r--
2023-01-11 06:22
auth_gss.c
14.25
KB
-rw-r--r--
2023-01-11 06:22
auth_log.c
3.42
KB
-rw-r--r--
2023-01-11 06:22
auth_md5.c
16.71
KB
-rw-r--r--
2023-01-11 06:22
auth_pla.c
4.32
KB
-rw-r--r--
2023-01-11 06:22
auths.c
88
B
-rw-r--r--
2023-01-11 06:22
big5.c
111.09
KB
-rw-r--r--
2023-01-11 06:22
c-client.a
3.91
MB
-rw-r--r--
2023-01-11 06:22
c-client.h
1.65
KB
-rw-r--r--
2023-01-11 06:22
ckp_1st.c
1.48
KB
-rw-r--r--
2023-01-11 06:22
ckp_2nd.c
888
B
-rw-r--r--
2023-01-11 06:22
ckp_3rd.c
816
B
-rw-r--r--
2023-01-11 06:22
ckp_a41.c
1.41
KB
-rw-r--r--
2023-01-11 06:22
ckp_afs.c
1.84
KB
-rw-r--r--
2023-01-11 06:22
ckp_bsi.c
1.38
KB
-rw-r--r--
2023-01-11 06:22
ckp_cyg.c
1.75
KB
-rw-r--r--
2023-01-11 06:22
ckp_dce.c
2.56
KB
-rw-r--r--
2023-01-11 06:22
ckp_gss.c
3.01
KB
-rw-r--r--
2023-01-11 06:22
ckp_nul.c
1.04
KB
-rw-r--r--
2023-01-11 06:22
ckp_os4.c
2.11
KB
-rw-r--r--
2023-01-11 06:22
ckp_pam.c
3.99
KB
-rw-r--r--
2023-01-11 06:22
ckp_pmb.c
3.82
KB
-rw-r--r--
2023-01-11 06:22
ckp_psx.c
3.6
KB
-rw-r--r--
2023-01-11 06:22
ckp_sce.c
1.58
KB
-rw-r--r--
2023-01-11 06:22
ckp_sec.c
1.54
KB
-rw-r--r--
2023-01-11 06:22
ckp_ssn.c
1.58
KB
-rw-r--r--
2023-01-11 06:22
ckp_std.c
1.16
KB
-rw-r--r--
2023-01-11 06:22
ckp_sv4.c
3.17
KB
-rw-r--r--
2023-01-11 06:22
ckp_svo.c
3.11
KB
-rw-r--r--
2023-01-11 06:22
ckp_ult.c
1.07
KB
-rw-r--r--
2023-01-11 06:22
cns11643.c
505.24
KB
-rw-r--r--
2023-01-11 06:22
crexcl.c
2.44
KB
-rw-r--r--
2023-01-11 06:22
crx_nfs.c
2.44
KB
-rw-r--r--
2023-01-11 06:22
crx_std.c
1.21
KB
-rw-r--r--
2023-01-11 06:22
decomtab.c
163.37
KB
-rw-r--r--
2023-01-11 06:22
drivers
989
B
-rwxr-xr-x
2023-01-11 06:22
dummy.c
24.66
KB
-rw-r--r--
2023-01-11 06:22
dummy.h
1.49
KB
-rw-r--r--
2023-01-11 06:22
dummy.o
84.54
KB
-rw-r--r--
2023-01-11 06:22
env.h
1.47
KB
-rw-r--r--
2023-01-11 06:22
env_unix.c
61.15
KB
-rw-r--r--
2023-01-11 06:22
env_unix.h
2.86
KB
-rw-r--r--
2023-01-11 06:22
fdstring.c
2.76
KB
-rw-r--r--
2023-01-11 06:22
fdstring.h
1.05
KB
-rw-r--r--
2023-01-11 06:22
fdstring.o
7.73
KB
-rw-r--r--
2023-01-11 06:22
flockcyg.c
2.99
KB
-rw-r--r--
2023-01-11 06:22
flockcyg.h
1.34
KB
-rw-r--r--
2023-01-11 06:22
flocklnx.c
2.27
KB
-rw-r--r--
2023-01-11 06:22
flocksim.c
28.21
KB
-rw-r--r--
2023-01-11 06:22
flocksim.h
4.29
KB
-rw-r--r--
2023-01-11 06:22
flstring.c
2.37
KB
-rw-r--r--
2023-01-11 06:22
flstring.h
799
B
-rw-r--r--
2023-01-11 06:22
flstring.o
8.38
KB
-rw-r--r--
2023-01-11 06:22
fs.h
905
B
-rw-r--r--
2023-01-11 06:22
fs_unix.c
1.84
KB
-rw-r--r--
2023-01-11 06:22
fsync.c
910
B
-rw-r--r--
2023-01-11 06:22
ftl.h
825
B
-rw-r--r--
2023-01-11 06:22
ftl_unix.c
1002
B
-rw-r--r--
2023-01-11 06:22
gb_12345.c
64.81
KB
-rw-r--r--
2023-01-11 06:22
gb_2312.c
179.47
KB
-rw-r--r--
2023-01-11 06:22
gethstid.c
975
B
-rw-r--r--
2023-01-11 06:22
getspnam.c
1.55
KB
-rw-r--r--
2023-01-11 06:22
gr_wait.c
1.27
KB
-rw-r--r--
2023-01-11 06:22
gr_wait4.c
1.06
KB
-rw-r--r--
2023-01-11 06:22
gr_waitp.c
1.06
KB
-rw-r--r--
2023-01-11 06:22
ibm.c
16.66
KB
-rw-r--r--
2023-01-11 06:22
imap4r1.c
193.18
KB
-rw-r--r--
2023-01-11 06:22
imap4r1.h
8.01
KB
-rw-r--r--
2023-01-11 06:22
imap4r1.o
440.85
KB
-rw-r--r--
2023-01-11 06:22
ip4_unix.c
5.13
KB
-rw-r--r--
2023-01-11 06:22
ip6_unix.c
8.54
KB
-rw-r--r--
2023-01-11 06:22
ip_unix.c
5.13
KB
-rw-r--r--
2023-01-11 06:22
ipo_unix.c
5.04
KB
-rw-r--r--
2023-01-11 06:22
iso_8859.c
13.88
KB
-rw-r--r--
2023-01-11 06:22
jis_0208.c
62.77
KB
-rw-r--r--
2023-01-11 06:22
jis_0212.c
55.8
KB
-rw-r--r--
2023-01-11 06:22
kerb_mit.c
3
KB
-rw-r--r--
2023-01-11 06:22
koi8_r.c
1.76
KB
-rw-r--r--
2023-01-11 06:22
koi8_u.c
1.77
KB
-rw-r--r--
2023-01-11 06:22
ksc_5601.c
178.16
KB
-rw-r--r--
2023-01-11 06:22
linkage.c
1.2
KB
-rw-r--r--
2023-01-11 06:22
linkage.h
510
B
-rw-r--r--
2023-01-11 06:22
log_bsi.c
1.54
KB
-rw-r--r--
2023-01-11 06:22
log_cyg.c
1.24
KB
-rw-r--r--
2023-01-11 06:22
log_old.c
1.01
KB
-rw-r--r--
2023-01-11 06:22
log_os4.c
1.62
KB
-rw-r--r--
2023-01-11 06:22
log_sec.c
1.14
KB
-rw-r--r--
2023-01-11 06:22
log_std.c
1.12
KB
-rw-r--r--
2023-01-11 06:22
log_sv4.c
1.1
KB
-rw-r--r--
2023-01-11 06:22
mail.c
201.99
KB
-rw-r--r--
2023-01-11 06:22
mail.h
66.8
KB
-rw-r--r--
2023-01-11 06:22
mail.o
426.63
KB
-rw-r--r--
2023-01-11 06:22
mbx.c
61.93
KB
-rw-r--r--
2023-01-11 06:22
mbx.o
153.46
KB
-rw-r--r--
2023-01-11 06:22
memmove.c
993
B
-rw-r--r--
2023-01-11 06:22
memmove2.c
1.32
KB
-rw-r--r--
2023-01-11 06:22
memset.c
1010
B
-rw-r--r--
2023-01-11 06:22
mh.c
39.67
KB
-rw-r--r--
2023-01-11 06:22
mh.o
118.7
KB
-rw-r--r--
2023-01-11 06:22
misc.c
13.34
KB
-rw-r--r--
2023-01-11 06:22
misc.h
3.27
KB
-rw-r--r--
2023-01-11 06:22
misc.o
26.76
KB
-rw-r--r--
2023-01-11 06:22
mix.c
92.52
KB
-rw-r--r--
2023-01-11 06:22
mix.o
237.31
KB
-rw-r--r--
2023-01-11 06:22
mkauths
1.18
KB
-rwxr-xr-x
2023-01-11 06:22
mmdf.c
89.34
KB
-rw-r--r--
2023-01-11 06:22
mmdf.o
179.64
KB
-rw-r--r--
2023-01-11 06:22
mtx.c
45.09
KB
-rw-r--r--
2023-01-11 06:22
mtx.o
120.16
KB
-rw-r--r--
2023-01-11 06:22
mx.c
39.05
KB
-rw-r--r--
2023-01-11 06:22
mx.o
117.3
KB
-rw-r--r--
2023-01-11 06:22
netmsg.c
2.88
KB
-rw-r--r--
2023-01-11 06:22
netmsg.h
987
B
-rw-r--r--
2023-01-11 06:22
netmsg.o
13.83
KB
-rw-r--r--
2023-01-11 06:22
news.c
21.78
KB
-rw-r--r--
2023-01-11 06:22
news.o
70.97
KB
-rw-r--r--
2023-01-11 06:22
newsrc.c
16.67
KB
-rw-r--r--
2023-01-11 06:22
newsrc.h
1.45
KB
-rw-r--r--
2023-01-11 06:22
newsrc.o
59.16
KB
-rw-r--r--
2023-01-11 06:22
nl.h
939
B
-rw-r--r--
2023-01-11 06:22
nl_unix.c
2.56
KB
-rw-r--r--
2023-01-11 06:22
nntp.c
74.66
KB
-rw-r--r--
2023-01-11 06:22
nntp.h
1.58
KB
-rw-r--r--
2023-01-11 06:22
nntp.o
177.67
KB
-rw-r--r--
2023-01-11 06:22
opendir.c
1.94
KB
-rw-r--r--
2023-01-11 06:22
os_a32.c
1.44
KB
-rw-r--r--
2023-01-11 06:22
os_a32.h
1.2
KB
-rw-r--r--
2023-01-11 06:22
os_a41.c
1.53
KB
-rw-r--r--
2023-01-11 06:22
os_a41.h
1.2
KB
-rw-r--r--
2023-01-11 06:22
os_a52.c
1.57
KB
-rw-r--r--
2023-01-11 06:22
os_a52.h
1.27
KB
-rw-r--r--
2023-01-11 06:22
os_aix.c
1.5
KB
-rw-r--r--
2023-01-11 06:22
os_aix.h
1.1
KB
-rw-r--r--
2023-01-11 06:22
os_aos.c
1.5
KB
-rw-r--r--
2023-01-11 06:22
os_aos.h
1.26
KB
-rw-r--r--
2023-01-11 06:22
os_art.c
2.13
KB
-rw-r--r--
2023-01-11 06:22
os_art.h
2.01
KB
-rw-r--r--
2023-01-11 06:22
os_asv.c
1.7
KB
-rw-r--r--
2023-01-11 06:22
os_asv.h
1.91
KB
-rw-r--r--
2023-01-11 06:22
os_aux.c
1.51
KB
-rw-r--r--
2023-01-11 06:22
os_aux.h
1.18
KB
-rw-r--r--
2023-01-11 06:22
os_bsd.c
1.5
KB
-rw-r--r--
2023-01-11 06:22
os_bsd.h
1.33
KB
-rw-r--r--
2023-01-11 06:22
os_bsf.c
1.33
KB
-rw-r--r--
2023-01-11 06:22
os_bsf.h
1.05
KB
-rw-r--r--
2023-01-11 06:22
os_bsi.c
1.33
KB
-rw-r--r--
2023-01-11 06:22
os_bsi.h
1.03
KB
-rw-r--r--
2023-01-11 06:22
os_cvx.c
1.38
KB
-rw-r--r--
2023-01-11 06:22
os_cvx.h
1.09
KB
-rw-r--r--
2023-01-11 06:22
os_cyg.c
1.61
KB
-rw-r--r--
2023-01-11 06:22
os_cyg.h
1.6
KB
-rw-r--r--
2023-01-11 06:22
os_d-g.c
1.32
KB
-rw-r--r--
2023-01-11 06:22
os_d-g.h
1.35
KB
-rw-r--r--
2023-01-11 06:22
os_do4.c
1.4
KB
-rw-r--r--
2023-01-11 06:22
os_do4.h
1.23
KB
-rw-r--r--
2023-01-11 06:22
os_drs.c
1.39
KB
-rw-r--r--
2023-01-11 06:22
os_drs.h
1.42
KB
-rw-r--r--
2023-01-11 06:22
os_dyn.c
1.53
KB
-rw-r--r--
2023-01-11 06:22
os_dyn.h
1.5
KB
-rw-r--r--
2023-01-11 06:22
os_hpp.c
1.89
KB
-rw-r--r--
2023-01-11 06:22
os_hpp.h
1.36
KB
-rw-r--r--
2023-01-11 06:22
os_isc.c
1.65
KB
-rw-r--r--
2023-01-11 06:22
os_isc.h
1.68
KB
-rw-r--r--
2023-01-11 06:22
os_lnx.c
1.35
KB
-rw-r--r--
2023-01-11 06:22
os_lnx.h
1.45
KB
-rw-r--r--
2023-01-11 06:22
os_lyn.c
1.32
KB
-rw-r--r--
2023-01-11 06:22
os_lyn.h
1.03
KB
-rw-r--r--
2023-01-11 06:22
os_mct.c
1.29
KB
-rw-r--r--
2023-01-11 06:22
os_mct.h
1.05
KB
-rw-r--r--
2023-01-11 06:22
os_mnt.c
1.3
KB
-rw-r--r--
2023-01-11 06:22
os_mnt.h
1.18
KB
-rw-r--r--
2023-01-11 06:22
os_nto.c
1.84
KB
-rw-r--r--
2023-01-11 06:22
os_nto.h
1.64
KB
-rw-r--r--
2023-01-11 06:22
os_nxt.c
1.32
KB
-rw-r--r--
2023-01-11 06:22
os_nxt.h
1.18
KB
-rw-r--r--
2023-01-11 06:22
os_os4.c
1.38
KB
-rw-r--r--
2023-01-11 06:22
os_os4.h
1.17
KB
-rw-r--r--
2023-01-11 06:22
os_osf.c
1.35
KB
-rw-r--r--
2023-01-11 06:22
os_osf.h
1.17
KB
-rw-r--r--
2023-01-11 06:22
os_osx.c
1.33
KB
-rw-r--r--
2023-01-11 06:22
os_osx.h
1.26
KB
-rw-r--r--
2023-01-11 06:22
os_ptx.c
2.88
KB
-rw-r--r--
2023-01-11 06:22
os_ptx.h
1.7
KB
-rw-r--r--
2023-01-11 06:22
os_pyr.c
1.49
KB
-rw-r--r--
2023-01-11 06:22
os_pyr.h
1.42
KB
-rw-r--r--
2023-01-11 06:22
os_qnx.c
1.87
KB
-rw-r--r--
2023-01-11 06:22
os_qnx.h
1.42
KB
-rw-r--r--
2023-01-11 06:22
os_s40.c
1.58
KB
-rw-r--r--
2023-01-11 06:22
os_s40.h
957
B
-rw-r--r--
2023-01-11 06:22
os_sc5.c
1.56
KB
-rw-r--r--
2023-01-11 06:22
os_sc5.h
1.72
KB
-rw-r--r--
2023-01-11 06:22
os_sco.c
1.62
KB
-rw-r--r--
2023-01-11 06:22
os_sco.h
1.76
KB
-rw-r--r--
2023-01-11 06:22
os_sgi.c
1.38
KB
-rw-r--r--
2023-01-11 06:22
os_sgi.h
1.36
KB
-rw-r--r--
2023-01-11 06:22
os_shp.c
1.94
KB
-rw-r--r--
2023-01-11 06:22
os_shp.h
1.36
KB
-rw-r--r--
2023-01-11 06:22
os_slx.c
1.43
KB
-rw-r--r--
2023-01-11 06:22
os_slx.h
1.45
KB
-rw-r--r--
2023-01-11 06:22
os_sol.c
1.67
KB
-rw-r--r--
2023-01-11 06:22
os_soln.h
1.93
KB
-rw-r--r--
2023-01-11 06:22
os_solo.h
1.9
KB
-rw-r--r--
2023-01-11 06:22
os_sos.c
1.39
KB
-rw-r--r--
2023-01-11 06:22
os_sos.h
1.17
KB
-rw-r--r--
2023-01-11 06:22
os_sua.c
1.33
KB
-rw-r--r--
2023-01-11 06:22
os_sua.h
1.16
KB
-rw-r--r--
2023-01-11 06:22
os_sun.c
1.58
KB
-rw-r--r--
2023-01-11 06:22
os_sun.h
1.28
KB
-rw-r--r--
2023-01-11 06:22
os_sv2.c
2.82
KB
-rw-r--r--
2023-01-11 06:22
os_sv2.h
2.91
KB
-rw-r--r--
2023-01-11 06:22
os_sv4.c
1.6
KB
-rw-r--r--
2023-01-11 06:22
os_sv4.h
1.79
KB
-rw-r--r--
2023-01-11 06:22
os_ult.c
1.27
KB
-rw-r--r--
2023-01-11 06:22
os_ult.h
1.01
KB
-rw-r--r--
2023-01-11 06:22
os_vu2.c
2.01
KB
-rw-r--r--
2023-01-11 06:22
os_vu2.h
2.34
KB
-rw-r--r--
2023-01-11 06:22
osdep.c
32.49
KB
-rw-r--r--
2023-01-11 06:22
osdep.h
1.45
KB
-rw-r--r--
2023-01-11 06:22
osdep.o
415.75
KB
-rw-r--r--
2023-01-11 06:22
osdepbas.c
1.43
KB
-rw-r--r--
2023-01-11 06:22
osdepckp.c
3.6
KB
-rw-r--r--
2023-01-11 06:22
osdeplog.c
1.12
KB
-rw-r--r--
2023-01-11 06:22
osdepssl.c
26.33
KB
-rw-r--r--
2023-01-11 06:22
phile.c
16.28
KB
-rw-r--r--
2023-01-11 06:22
phile.o
55.77
KB
-rw-r--r--
2023-01-11 06:22
pmatch.c
2.77
KB
-rw-r--r--
2023-01-11 06:22
pop3.c
34.08
KB
-rw-r--r--
2023-01-11 06:22
pop3.o
100.79
KB
-rw-r--r--
2023-01-11 06:22
pseudo.c
1.24
KB
-rw-r--r--
2023-01-11 06:22
pseudo.h
838
B
-rw-r--r--
2023-01-11 06:22
pseudo.o
3.34
KB
-rw-r--r--
2023-01-11 06:22
rename.c
1.12
KB
-rw-r--r--
2023-01-11 06:22
rfc822.c
78.98
KB
-rw-r--r--
2023-01-11 06:22
rfc822.h
5.29
KB
-rw-r--r--
2023-01-11 06:22
rfc822.o
168.47
KB
-rw-r--r--
2023-01-11 06:22
scandir.c
2.61
KB
-rw-r--r--
2023-01-11 06:22
setpgrp.c
946
B
-rw-r--r--
2023-01-11 06:22
sig_bsd.c
954
B
-rw-r--r--
2023-01-11 06:22
sig_psx.c
1.3
KB
-rw-r--r--
2023-01-11 06:22
sig_sv4.c
955
B
-rw-r--r--
2023-01-11 06:22
siglocal.c
1.3
KB
-rw-r--r--
2023-01-11 06:22
siglocal.o
6.8
KB
-rw-r--r--
2023-01-11 06:22
smanager.c
3.54
KB
-rw-r--r--
2023-01-11 06:22
smanager.o
15.91
KB
-rw-r--r--
2023-01-11 06:22
smtp.c
26.33
KB
-rw-r--r--
2023-01-11 06:22
smtp.h
2.48
KB
-rw-r--r--
2023-01-11 06:22
smtp.o
79.52
KB
-rw-r--r--
2023-01-11 06:22
ssl_none.c
2.57
KB
-rw-r--r--
2023-01-11 06:22
ssl_unix.c
26.33
KB
-rw-r--r--
2023-01-11 06:22
sslio.h
2.25
KB
-rw-r--r--
2023-01-11 06:22
sslstdio.c
4.15
KB
-rw-r--r--
2023-01-11 06:22
strerror.c
981
B
-rw-r--r--
2023-01-11 06:22
strpbrk.c
1.1
KB
-rw-r--r--
2023-01-11 06:22
strstr.c
1.27
KB
-rw-r--r--
2023-01-11 06:22
strtok.c
2.02
KB
-rw-r--r--
2023-01-11 06:22
strtoul.c
2.33
KB
-rw-r--r--
2023-01-11 06:22
tcp.h
1.73
KB
-rw-r--r--
2023-01-11 06:22
tcp_unix.c
31.52
KB
-rw-r--r--
2023-01-11 06:22
tcp_unix.h
1.2
KB
-rw-r--r--
2023-01-11 06:22
tenex.c
48.69
KB
-rw-r--r--
2023-01-11 06:22
tenex.o
126.43
KB
-rw-r--r--
2023-01-11 06:22
tis_620.c
1.91
KB
-rw-r--r--
2023-01-11 06:22
tmap.c
84.45
KB
-rw-r--r--
2023-01-11 06:22
truncate.c
1.06
KB
-rw-r--r--
2023-01-11 06:22
tz_bsd.c
989
B
-rw-r--r--
2023-01-11 06:22
tz_nul.c
887
B
-rw-r--r--
2023-01-11 06:22
tz_sv4.c
1.02
KB
-rw-r--r--
2023-01-11 06:22
unix.c
92.97
KB
-rw-r--r--
2023-01-11 06:22
unix.h
6.55
KB
-rw-r--r--
2023-01-11 06:22
unix.o
203.15
KB
-rw-r--r--
2023-01-11 06:22
utf8.c
84
KB
-rw-r--r--
2023-01-11 06:22
utf8.h
22.43
KB
-rw-r--r--
2023-01-11 06:22
utf8.o
531.61
KB
-rw-r--r--
2023-01-11 06:22
utf8aux.c
14.12
KB
-rw-r--r--
2023-01-11 06:22
utf8aux.h
1.49
KB
-rw-r--r--
2023-01-11 06:22
utf8aux.o
30.01
KB
-rw-r--r--
2023-01-11 06:22
utime.c
1.22
KB
-rw-r--r--
2023-01-11 06:22
viscii.c
2.8
KB
-rw-r--r--
2023-01-11 06:22
widths.c
265.05
KB
-rw-r--r--
2023-01-11 06:22
windows.c
10.77
KB
-rw-r--r--
2023-01-11 06:22
write.c
1.74
KB
-rw-r--r--
2023-01-11 06:22
Save
Rename
/* ======================================================================== * Copyright 1988-2008 University of Washington * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * * ======================================================================== */ /* * Program: SSL authentication/encryption module * * Author: Mark Crispin * Networks and Distributed Computing * Computing & Communications * University of Washington * Administration Building, AG-44 * Seattle, WA 98195 * Internet: MRC@CAC.Washington.EDU * * Date: 22 September 1998 * Last Edited: 13 January 2007 */ #define crypt ssl_private_crypt #include <x509v3.h> #include <ssl.h> #include <err.h> #include <pem.h> #include <buffer.h> #include <bio.h> #include <crypto.h> #include <rand.h> #undef crypt #define SSLBUFLEN 8192 #define SSLCIPHERLIST "ALL:!LOW" /* SSL I/O stream */ typedef struct ssl_stream { TCPSTREAM *tcpstream; /* TCP stream */ SSL_CTX *context; /* SSL context */ SSL *con; /* SSL connection */ int ictr; /* input counter */ char *iptr; /* input pointer */ char ibuf[SSLBUFLEN]; /* input buffer */ } SSLSTREAM; #include "sslio.h" /* Function prototypes */ static SSLSTREAM *ssl_start(TCPSTREAM *tstream,char *host,unsigned long flags); static char *ssl_start_work (SSLSTREAM *stream,char *host,unsigned long flags); static int ssl_open_verify (int ok,X509_STORE_CTX *ctx); static char *ssl_validate_cert (X509 *cert,char *host); static long ssl_compare_hostnames (unsigned char *s,unsigned char *pat); static char *ssl_getline_work (SSLSTREAM *stream,unsigned long *size, long *contd); static long ssl_abort (SSLSTREAM *stream); static RSA *ssl_genkey (SSL *con,int export,int keylength); /* Secure Sockets Layer network driver dispatch */ static struct ssl_driver ssldriver = { ssl_open, /* open connection */ ssl_aopen, /* open preauthenticated connection */ ssl_getline, /* get a line */ ssl_getbuffer, /* get a buffer */ ssl_soutr, /* output pushed data */ ssl_sout, /* output string */ ssl_close, /* close connection */ ssl_host, /* return host name */ ssl_remotehost, /* return remote host name */ ssl_port, /* return port number */ ssl_localhost /* return local host name */ }; /* non-NIL if doing SSL primary I/O */ static SSLSTDIOSTREAM *sslstdio = NIL; static char *start_tls = NIL; /* non-NIL if start TLS requested */ /* One-time SSL initialization */ static int sslonceonly = 0; void ssl_onceonlyinit (void) { if (!sslonceonly++) { /* only need to call it once */ int fd; char tmp[MAILTMPLEN]; struct stat sbuf; /* if system doesn't have /dev/urandom */ if (stat ("/dev/urandom",&sbuf)) { while ((fd = open (tmpnam (tmp),O_WRONLY|O_CREAT|O_EXCL,0600)) < 0) sleep (1); unlink (tmp); /* don't need the file */ fstat (fd,&sbuf); /* get information about the file */ close (fd); /* flush descriptor */ /* not great but it'll have to do */ sprintf (tmp + strlen (tmp),"%.80s%lx%.80s%lx%lx%lx%lx%lx", tcp_serveraddr (),(unsigned long) tcp_serverport (), tcp_clientaddr (),(unsigned long) tcp_clientport (), (unsigned long) sbuf.st_ino,(unsigned long) time (0), (unsigned long) gethostid (),(unsigned long) getpid ()); RAND_seed (tmp,strlen (tmp)); } /* apply runtime linkage */ mail_parameters (NIL,SET_SSLDRIVER,(void *) &ssldriver); mail_parameters (NIL,SET_SSLSTART,(void *) ssl_start); SSL_library_init (); /* add all algorithms */ } } /* SSL open * Accepts: host name * contact service name * contact port number * Returns: SSL stream if success else NIL */ SSLSTREAM *ssl_open (char *host,char *service,unsigned long port) { TCPSTREAM *stream = tcp_open (host,service,port); return stream ? ssl_start (stream,host,port) : NIL; } /* SSL authenticated open * Accepts: host name * service name * returned user name buffer * Returns: SSL stream if success else NIL */ SSLSTREAM *ssl_aopen (NETMBX *mb,char *service,char *usrbuf) { return NIL; /* don't use this mechanism with SSL */ } /* Start SSL/TLS negotiations * Accepts: open TCP stream of session * user's host name * flags * Returns: SSL stream if success else NIL */ static SSLSTREAM *ssl_start (TCPSTREAM *tstream,char *host,unsigned long flags) { char *reason,tmp[MAILTMPLEN]; sslfailure_t sf = (sslfailure_t) mail_parameters (NIL,GET_SSLFAILURE,NIL); blocknotify_t bn = (blocknotify_t) mail_parameters (NIL,GET_BLOCKNOTIFY,NIL); void *data = (*bn) (BLOCK_SENSITIVE,NIL); SSLSTREAM *stream = (SSLSTREAM *) memset (fs_get (sizeof (SSLSTREAM)),0, sizeof (SSLSTREAM)); stream->tcpstream = tstream; /* bind TCP stream */ /* do the work */ reason = ssl_start_work (stream,host,flags); (*bn) (BLOCK_NONSENSITIVE,data); if (reason) { /* failed? */ ssl_close (stream); /* failed to do SSL */ stream = NIL; /* no stream returned */ switch (*reason) { /* analyze reason */ case '*': /* certificate failure */ ++reason; /* skip over certificate failure indication */ /* pass to error callback */ if (sf) (*sf) (host,reason,flags); else { /* no error callback, build error message */ sprintf (tmp,"Certificate failure for %.80s: %.512s",host,reason); mm_log (tmp,ERROR); } case '\0': /* user answered no to certificate callback */ if (flags & NET_TRYSSL) /* return dummy stream to stop tryssl */ stream = (SSLSTREAM *) memset (fs_get (sizeof (SSLSTREAM)),0, sizeof (SSLSTREAM)); break; default: /* non-certificate failure */ if (flags & NET_TRYSSL); /* no error output if tryssl */ /* pass to error callback */ else if (sf) (*sf) (host,reason,flags); else { /* no error callback, build error message */ sprintf (tmp,"TLS/SSL failure for %.80s: %.512s",host,reason); mm_log (tmp,ERROR); } break; } } return stream; } /* Start SSL/TLS negotiations worker routine * Accepts: SSL stream * user's host name * flags * Returns: NIL if success, else error reason */ /* evil but I had no choice */ static char *ssl_last_error = NIL; static char *ssl_last_host = NIL; static char *ssl_start_work (SSLSTREAM *stream,char *host,unsigned long flags) { BIO *bio; X509 *cert; unsigned long sl,tl; char *s,*t,*err,tmp[MAILTMPLEN]; sslcertificatequery_t scq = (sslcertificatequery_t) mail_parameters (NIL,GET_SSLCERTIFICATEQUERY,NIL); sslclientcert_t scc = (sslclientcert_t) mail_parameters (NIL,GET_SSLCLIENTCERT,NIL); sslclientkey_t sck = (sslclientkey_t) mail_parameters (NIL,GET_SSLCLIENTKEY,NIL); if (ssl_last_error) fs_give ((void **) &ssl_last_error); ssl_last_host = host; if (!(stream->context = SSL_CTX_new ((flags & NET_TLSCLIENT) ? TLSv1_client_method () : SSLv23_client_method ()))) return "SSL context failed"; SSL_CTX_set_options (stream->context,0); /* disable certificate validation? */ if (flags & NET_NOVALIDATECERT) SSL_CTX_set_verify (stream->context,SSL_VERIFY_NONE,NIL); else { #if OPENSSL_VERSION_NUMBER >= 0x10100000 X509_VERIFY_PARAM *param = SSL_CTX_get0_param(stream->context); X509_VERIFY_PARAM_set_hostflags(param, X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS); X509_VERIFY_PARAM_set1_host(param, host, 0); #endif SSL_CTX_set_verify (stream->context,SSL_VERIFY_PEER,ssl_open_verify); /* set default paths to CAs... */ } SSL_CTX_set_default_verify_paths (stream->context); /* ...unless a non-standard path desired */ if (s = (char *) mail_parameters (NIL,GET_SSLCAPATH,NIL)) SSL_CTX_load_verify_locations (stream->context,NIL,s); /* want to send client certificate? */ if (scc && (s = (*scc) ()) && (sl = strlen (s))) { if (cert = PEM_read_bio_X509 (bio = BIO_new_mem_buf (s,sl),NIL,NIL,NIL)) { SSL_CTX_use_certificate (stream->context,cert); X509_free (cert); } BIO_free (bio); if (!cert) return "SSL client certificate failed"; /* want to supply private key? */ if ((t = (sck ? (*sck) () : s)) && (tl = strlen (t))) { EVP_PKEY *key; if (key = PEM_read_bio_PrivateKey (bio = BIO_new_mem_buf (t,tl), NIL,NIL,"")) { SSL_CTX_use_PrivateKey (stream->context,key); EVP_PKEY_free (key); } BIO_free (bio); memset (t,0,tl); /* erase key */ } if (s != t) memset (s,0,sl);/* erase certificate if different from key */ } /* create connection */ if (!(stream->con = (SSL *) SSL_new (stream->context))) return "SSL connection failed"; bio = BIO_new_socket (stream->tcpstream->tcpsi,BIO_NOCLOSE); SSL_set_bio (stream->con,bio,bio); SSL_set_connect_state (stream->con); if (SSL_in_init (stream->con)) SSL_total_renegotiations (stream->con); /* now negotiate SSL */ if (SSL_write (stream->con,"",0) < 0) return ssl_last_error ? ssl_last_error : "SSL negotiation failed"; /* need to validate host names? */ #if OPENSSL_VERSION_NUMBER < 0x10100000 if (!(flags & NET_NOVALIDATECERT) && (err = ssl_validate_cert (cert = SSL_get_peer_certificate (stream->con), host))) { /* application callback */ if (scq) return (*scq) (err,host,cert ? cert->name : "???") ? NIL : ""; /* error message to return via mm_log() */ sprintf (tmp,"*%.128s: %.255s",err,cert ? cert->name : "???"); return ssl_last_error = cpystr (tmp); } #endif return NIL; } /* SSL certificate verification callback * Accepts: error flag * X509 context * Returns: error flag */ static int ssl_open_verify (int ok,X509_STORE_CTX *ctx) { char *err,cert[256],tmp[MAILTMPLEN]; sslcertificatequery_t scq = (sslcertificatequery_t) mail_parameters (NIL,GET_SSLCERTIFICATEQUERY,NIL); if (!ok) { /* in case failure */ err = (char *) X509_verify_cert_error_string (X509_STORE_CTX_get_error (ctx)); X509_NAME_oneline (X509_get_subject_name (X509_STORE_CTX_get_current_cert (ctx)),cert,255); if (!scq) { /* mm_log() error message if no callback */ sprintf (tmp,"*%.128s: %.255s",err,cert); ssl_last_error = cpystr (tmp); } /* ignore error if application says to */ else if ((*scq) (err,ssl_last_host,cert)) ok = T; /* application wants punt */ else ssl_last_error = cpystr (""); } return ok; } /* SSL validate certificate * Accepts: certificate * host to validate against * Returns: NIL if validated, else string of error message */ #if OPENSSL_VERSION_NUMBER < 0x10100000 static char *ssl_validate_cert (X509 *cert,char *host) { int i,n; char *s,*t,*ret; void *ext; GENERAL_NAME *name; /* make sure have a certificate */ if (!cert) ret = "No certificate from server"; /* and that it has a name */ else if (!cert->name) ret = "No name in certificate"; /* locate CN */ else if (s = strstr (cert->name,"/CN=")) { if (t = strchr (s += 4,'/')) *t = '\0'; /* host name matches pattern? */ ret = ssl_compare_hostnames (host,s) ? NIL : "Server name does not match certificate"; if (t) *t = '/'; /* restore smashed delimiter */ /* if mismatch, see if in extensions */ if (ret && (ext = X509_get_ext_d2i (cert,NID_subject_alt_name,NIL,NIL)) && (n = sk_GENERAL_NAME_num (ext))) /* older versions of OpenSSL use "ia5" instead of dNSName */ for (i = 0; ret && (i < n); i++) if ((name = sk_GENERAL_NAME_value (ext,i)) && (name->type = GEN_DNS) && (s = name->d.ia5->data) && ssl_compare_hostnames (host,s)) ret = NIL; } else ret = "Unable to locate common name in certificate"; return ret; } #endif /* Case-independent wildcard pattern match * Accepts: base string * pattern string * Returns: T if pattern matches base, else NIL */ static long ssl_compare_hostnames (unsigned char *s,unsigned char *pat) { long ret = NIL; switch (*pat) { case '*': /* wildcard */ if (pat[1]) { /* there must be a pattern suffix */ /* there is, scan base against it */ do if (ssl_compare_hostnames (s,pat+1)) ret = LONGT; while (!ret && (*s != '.') && *s++); } break; case '\0': /* end of pattern */ if (!*s) ret = LONGT; /* success if base is also at end */ break; default: /* non-wildcard, recurse if match */ if (!compare_uchar (*pat,*s)) ret = ssl_compare_hostnames (s+1,pat+1); break; } return ret; } /* SSL receive line * Accepts: SSL stream * Returns: text line string or NIL if failure */ char *ssl_getline (SSLSTREAM *stream) { unsigned long n,contd; char *ret = ssl_getline_work (stream,&n,&contd); if (ret && contd) { /* got a line needing continuation? */ STRINGLIST *stl = mail_newstringlist (); STRINGLIST *stc = stl; do { /* collect additional lines */ stc->text.data = (unsigned char *) ret; stc->text.size = n; stc = stc->next = mail_newstringlist (); ret = ssl_getline_work (stream,&n,&contd); } while (ret && contd); if (ret) { /* stash final part of line on list */ stc->text.data = (unsigned char *) ret; stc->text.size = n; /* determine how large a buffer we need */ for (n = 0, stc = stl; stc; stc = stc->next) n += stc->text.size; ret = fs_get (n + 1); /* copy parts into buffer */ for (n = 0, stc = stl; stc; n += stc->text.size, stc = stc->next) memcpy (ret + n,stc->text.data,stc->text.size); ret[n] = '\0'; } mail_free_stringlist (&stl);/* either way, done with list */ } return ret; } /* SSL receive line or partial line * Accepts: SSL stream * pointer to return size * pointer to return continuation flag * Returns: text line string, size and continuation flag, or NIL if failure */ static char *ssl_getline_work (SSLSTREAM *stream,unsigned long *size, long *contd) { unsigned long n; char *s,*ret,c,d; *contd = NIL; /* assume no continuation */ /* make sure have data */ if (!ssl_getdata (stream)) return NIL; for (s = stream->iptr, n = 0, c = '\0'; stream->ictr--; n++, c = d) { d = *stream->iptr++; /* slurp another character */ if ((c == '\015') && (d == '\012')) { ret = (char *) fs_get (n--); memcpy (ret,s,*size = n); /* copy into a free storage string */ ret[n] = '\0'; /* tie off string with null */ return ret; } } /* copy partial string from buffer */ memcpy ((ret = (char *) fs_get (n)),s,*size = n); /* get more data from the net */ if (!ssl_getdata (stream)) fs_give ((void **) &ret); /* special case of newline broken by buffer */ else if ((c == '\015') && (*stream->iptr == '\012')) { stream->iptr++; /* eat the line feed */ stream->ictr--; ret[*size = --n] = '\0'; /* tie off string with null */ } else *contd = LONGT; /* continuation needed */ return ret; } /* SSL receive buffer * Accepts: SSL stream * size in bytes * buffer to read into * Returns: T if success, NIL otherwise */ long ssl_getbuffer (SSLSTREAM *stream,unsigned long size,char *buffer) { unsigned long n; while (size > 0) { /* until request satisfied */ if (!ssl_getdata (stream)) return NIL; n = min (size,stream->ictr);/* number of bytes to transfer */ /* do the copy */ memcpy (buffer,stream->iptr,n); buffer += n; /* update pointer */ stream->iptr += n; size -= n; /* update # of bytes to do */ stream->ictr -= n; } buffer[0] = '\0'; /* tie off string */ return T; } /* SSL receive data * Accepts: TCP/IP stream * Returns: T if success, NIL otherwise */ long ssl_getdata (SSLSTREAM *stream) { int i,sock; fd_set fds,efds; struct timeval tmo; tcptimeout_t tmoh = (tcptimeout_t) mail_parameters (NIL,GET_TIMEOUT,NIL); long ttmo_read = (long) mail_parameters (NIL,GET_READTIMEOUT,NIL); time_t t = time (0); blocknotify_t bn = (blocknotify_t) mail_parameters (NIL,GET_BLOCKNOTIFY,NIL); if (!stream->con || ((sock = SSL_get_fd (stream->con)) < 0)) return NIL; /* tcp_unix should have prevented this */ if (sock >= FD_SETSIZE) fatal ("unselectable socket in ssl_getdata()"); (*bn) (BLOCK_TCPREAD,NIL); while (stream->ictr < 1) { /* if nothing in the buffer */ time_t tl = time (0); /* start of request */ time_t now = tl; int ti = ttmo_read ? now + ttmo_read : 0; if (SSL_pending (stream->con)) i = 1; else { if (tcpdebug) mm_log ("Reading SSL data",TCPDEBUG); tmo.tv_usec = 0; FD_ZERO (&fds); /* initialize selection vector */ FD_ZERO (&efds); /* handle errors too */ FD_SET (sock,&fds); /* set bit in selection vector */ FD_SET (sock,&efds); /* set bit in error selection vector */ errno = NIL; /* block and read */ do { /* block under timeout */ tmo.tv_sec = ti ? ti - now : 0; i = select (sock+1,&fds,0,&efds,ti ? &tmo : 0); now = time (0); /* fake timeout if interrupt & time expired */ if ((i < 0) && (errno == EINTR) && ti && (ti <= now)) i = 0; } while ((i < 0) && (errno == EINTR)); } if (i) { /* non-timeout result from select? */ errno = 0; /* just in case */ if (i > 0) /* read what we can */ while (((i = SSL_read (stream->con,stream->ibuf,SSLBUFLEN)) < 0) && ((errno == EINTR) || (SSL_get_error (stream->con,i) == SSL_ERROR_WANT_READ))); if (i <= 0) { /* error seen? */ if (tcpdebug) { char *s,tmp[MAILTMPLEN]; if (i) sprintf (s = tmp,"SSL data read I/O error %d SSL error %d", errno,SSL_get_error (stream->con,i)); else s = "SSL data read end of file"; mm_log (s,TCPDEBUG); } return ssl_abort (stream); } stream->iptr = stream->ibuf;/* point at TCP buffer */ stream->ictr = i; /* set new byte count */ if (tcpdebug) mm_log ("Successfully read SSL data",TCPDEBUG); } /* timeout, punt unless told not to */ else if (!tmoh || !(*tmoh) (now - t,now - tl)) { if (tcpdebug) mm_log ("SSL data read timeout",TCPDEBUG); return ssl_abort (stream); } } (*bn) (BLOCK_NONE,NIL); return T; } /* SSL send string as record * Accepts: SSL stream * string pointer * Returns: T if success else NIL */ long ssl_soutr (SSLSTREAM *stream,char *string) { return ssl_sout (stream,string,(unsigned long) strlen (string)); } /* SSL send string * Accepts: SSL stream * string pointer * byte count * Returns: T if success else NIL */ long ssl_sout (SSLSTREAM *stream,char *string,unsigned long size) { long i; blocknotify_t bn = (blocknotify_t) mail_parameters (NIL,GET_BLOCKNOTIFY,NIL); if (!stream->con) return NIL; (*bn) (BLOCK_TCPWRITE,NIL); if (tcpdebug) mm_log ("Writing to SSL",TCPDEBUG); /* until request satisfied */ for (i = 0; size > 0; string += i,size -= i) /* write as much as we can */ if ((i = SSL_write (stream->con,string,(int) min (SSLBUFLEN,size))) < 0) { if (tcpdebug) { char tmp[MAILTMPLEN]; sprintf (tmp,"SSL data write I/O error %d SSL error %d", errno,SSL_get_error (stream->con,i)); mm_log (tmp,TCPDEBUG); } return ssl_abort (stream);/* write failed */ } if (tcpdebug) mm_log ("successfully wrote to TCP",TCPDEBUG); (*bn) (BLOCK_NONE,NIL); return LONGT; /* all done */ } /* SSL close * Accepts: SSL stream */ void ssl_close (SSLSTREAM *stream) { ssl_abort (stream); /* nuke the stream */ fs_give ((void **) &stream); /* flush the stream */ } /* SSL abort stream * Accepts: SSL stream * Returns: NIL always */ static long ssl_abort (SSLSTREAM *stream) { blocknotify_t bn = (blocknotify_t) mail_parameters (NIL,GET_BLOCKNOTIFY,NIL); if (stream->con) { /* close SSL connection */ SSL_shutdown (stream->con); SSL_free (stream->con); stream->con = NIL; } if (stream->context) { /* clean up context */ SSL_CTX_free (stream->context); stream->context = NIL; } if (stream->tcpstream) { /* close TCP stream */ tcp_close (stream->tcpstream); stream->tcpstream = NIL; } (*bn) (BLOCK_NONE,NIL); return NIL; } /* SSL get host name * Accepts: SSL stream * Returns: host name for this stream */ char *ssl_host (SSLSTREAM *stream) { return tcp_host (stream->tcpstream); } /* SSL get remote host name * Accepts: SSL stream * Returns: host name for this stream */ char *ssl_remotehost (SSLSTREAM *stream) { return tcp_remotehost (stream->tcpstream); } /* SSL return port for this stream * Accepts: SSL stream * Returns: port number for this stream */ unsigned long ssl_port (SSLSTREAM *stream) { return tcp_port (stream->tcpstream); } /* SSL get local host name * Accepts: SSL stream * Returns: local host name */ char *ssl_localhost (SSLSTREAM *stream) { return tcp_localhost (stream->tcpstream); } /* Start TLS * Accepts: /etc/services service name * Returns: cpystr'd error string if TLS failed, else NIL for success */ char *ssl_start_tls (char *server) { char tmp[MAILTMPLEN]; struct stat sbuf; if (sslstdio) return cpystr ("Already in an SSL session"); if (start_tls) return cpystr ("TLS already started"); if (server) { /* build specific certificate/key file name */ sprintf (tmp,"%s/%s-%s.pem",SSL_CERT_DIRECTORY,server,tcp_serveraddr ()); if (stat (tmp,&sbuf)) { /* use non-specific name if no specific file */ sprintf (tmp,"%s/%s.pem",SSL_CERT_DIRECTORY,server); if (stat (tmp,&sbuf)) return cpystr ("Server certificate not installed"); } start_tls = server; /* switch to STARTTLS mode */ } return NIL; } /* Init server for SSL * Accepts: server name */ void ssl_server_init (char *server) { char cert[MAILTMPLEN],key[MAILTMPLEN]; unsigned long i; struct stat sbuf; SSLSTREAM *stream = (SSLSTREAM *) memset (fs_get (sizeof (SSLSTREAM)),0, sizeof (SSLSTREAM)); ssl_onceonlyinit (); /* make sure algorithms added */ ERR_load_crypto_strings (); SSL_load_error_strings (); /* build specific certificate/key file names */ sprintf (cert,"%s/%s-%s.pem",SSL_CERT_DIRECTORY,server,tcp_serveraddr ()); sprintf (key,"%s/%s-%s.pem",SSL_KEY_DIRECTORY,server,tcp_serveraddr ()); /* use non-specific name if no specific cert */ if (stat (cert,&sbuf)) sprintf (cert,"%s/%s.pem",SSL_CERT_DIRECTORY,server); if (stat (key,&sbuf)) { /* use non-specific name if no specific key */ sprintf (key,"%s/%s.pem",SSL_KEY_DIRECTORY,server); /* use cert file as fallback for key */ if (stat (key,&sbuf)) strcpy (key,cert); } /* create context */ if (!(stream->context = SSL_CTX_new (start_tls ? TLSv1_server_method () : SSLv23_server_method ()))) syslog (LOG_ALERT,"Unable to create SSL context, host=%.80s", tcp_clienthost ()); else { /* set context options */ SSL_CTX_set_options (stream->context,SSL_OP_ALL); /* set cipher list */ if (!SSL_CTX_set_cipher_list (stream->context,SSLCIPHERLIST)) syslog (LOG_ALERT,"Unable to set cipher list %.80s, host=%.80s", SSLCIPHERLIST,tcp_clienthost ()); /* load certificate */ else if (!SSL_CTX_use_certificate_chain_file (stream->context,cert)) syslog (LOG_ALERT,"Unable to load certificate from %.80s, host=%.80s", cert,tcp_clienthost ()); /* load key */ else if (!(SSL_CTX_use_RSAPrivateKey_file (stream->context,key, SSL_FILETYPE_PEM))) syslog (LOG_ALERT,"Unable to load private key from %.80s, host=%.80s", key,tcp_clienthost ()); else { /* generate key if needed */ if (SSL_CTX_need_tmp_RSA (stream->context)) SSL_CTX_set_tmp_rsa_callback (stream->context,ssl_genkey); /* create new SSL connection */ if (!(stream->con = SSL_new (stream->context))) syslog (LOG_ALERT,"Unable to create SSL connection, host=%.80s", tcp_clienthost ()); else { /* set file descriptor */ SSL_set_fd (stream->con,0); /* all OK if accepted */ if (SSL_accept (stream->con) < 0) syslog (LOG_INFO,"Unable to accept SSL connection, host=%.80s", tcp_clienthost ()); else { /* server set up */ sslstdio = (SSLSTDIOSTREAM *) memset (fs_get (sizeof(SSLSTDIOSTREAM)),0,sizeof (SSLSTDIOSTREAM)); sslstdio->sslstream = stream; /* available space in output buffer */ sslstdio->octr = SSLBUFLEN; /* current output buffer pointer */ sslstdio->optr = sslstdio->obuf; /* allow plaintext if disable value was 2 */ if ((long) mail_parameters (NIL,GET_DISABLEPLAINTEXT,NIL) > 1) mail_parameters (NIL,SET_DISABLEPLAINTEXT,NIL); /* unhide PLAIN SASL authenticator */ mail_parameters (NIL,UNHIDE_AUTHENTICATOR,"PLAIN"); mail_parameters (NIL,UNHIDE_AUTHENTICATOR,"LOGIN"); return; } } } } while (i = ERR_get_error ()) /* SSL failure */ syslog (LOG_ERR,"SSL error status: %.80s",ERR_error_string (i,NIL)); ssl_close (stream); /* punt stream */ exit (1); /* punt this program too */ } /* Generate one-time key for server * Accepts: SSL connection * export flag * keylength * Returns: generated key, always */ static RSA *ssl_genkey (SSL *con,int export,int keylength) { unsigned long i; static RSA *key = NIL; if (!key) { /* if don't have a key already */ /* generate key */ if (!(key = RSA_generate_key (export ? keylength : 1024,RSA_F4,NIL,NIL))) { syslog (LOG_ALERT,"Unable to generate temp key, host=%.80s", tcp_clienthost ()); while (i = ERR_get_error ()) syslog (LOG_ALERT,"SSL error status: %s",ERR_error_string (i,NIL)); exit (1); } } return key; } /* Wait for stdin input * Accepts: timeout in seconds * Returns: T if have input on stdin, else NIL */ long ssl_server_input_wait (long seconds) { int i,sock; fd_set fds,efd; struct timeval tmo; SSLSTREAM *stream; if (!sslstdio) return server_input_wait (seconds); /* input available in buffer */ if (((stream = sslstdio->sslstream)->ictr > 0) || !stream->con || ((sock = SSL_get_fd (stream->con)) < 0)) return LONGT; /* sock ought to be 0 always */ if (sock >= FD_SETSIZE) fatal ("unselectable socket in ssl_getdata()"); /* input available from SSL */ if (SSL_pending (stream->con) && ((i = SSL_read (stream->con,stream->ibuf,SSLBUFLEN)) > 0)) { stream->iptr = stream->ibuf;/* point at TCP buffer */ stream->ictr = i; /* set new byte count */ return LONGT; } FD_ZERO (&fds); /* initialize selection vector */ FD_ZERO (&efd); /* initialize selection vector */ FD_SET (sock,&fds); /* set bit in selection vector */ FD_SET (sock,&efd); /* set bit in selection vector */ tmo.tv_sec = seconds; tmo.tv_usec = 0; /* see if input available from the socket */ return select (sock+1,&fds,0,&efd,&tmo) ? LONGT : NIL; } #include "sslstdio.c"