2 * Copyright (c) 1997-2005 Kungliga Tekniska Högskolan
3 * (Royal Institute of Technology, Stockholm, Sweden).
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * 3. Neither the name of the Institute nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 #include "kpasswd_locl.h"
37 #include <kadm5/admin.h>
42 #include <kadm5/private.h>
43 #include <kadm5/kadm5_err.h>
45 static krb5_context context
;
46 static krb5_log_facility
*log_facility
;
48 static struct getarg_strings addresses_str
;
49 krb5_addresses explicit_addresses
;
51 static sig_atomic_t exit_flag
= 0;
54 add_one_address (const char *str
, int first
)
59 ret
= krb5_parse_address (context
, str
, &tmp
);
61 krb5_err (context
, 1, ret
, "parse_address `%s'", str
);
63 krb5_copy_addresses(context
, &tmp
, &explicit_addresses
);
65 krb5_append_addresses(context
, &explicit_addresses
, &tmp
);
66 krb5_free_addresses (context
, &tmp
);
78 uint16_t len
, ap_rep_len
;
83 ap_rep_len
= ap_rep
->length
;
87 len
= 6 + ap_rep_len
+ rest
->length
;
89 *p
++ = (len
>> 8) & 0xFF;
90 *p
++ = (len
>> 0) & 0xFF;
93 *p
++ = (ap_rep_len
>> 8) & 0xFF;
94 *p
++ = (ap_rep_len
>> 0) & 0xFF;
96 memset (&msghdr
, 0, sizeof(msghdr
));
97 msghdr
.msg_name
= (void *)sa
;
98 msghdr
.msg_namelen
= sa_size
;
100 msghdr
.msg_iovlen
= sizeof(iov
)/sizeof(*iov
);
102 msghdr
.msg_control
= NULL
;
103 msghdr
.msg_controllen
= 0;
106 iov
[0].iov_base
= (char *)header
;
109 iov
[1].iov_base
= ap_rep
->data
;
110 iov
[1].iov_len
= ap_rep
->length
;
112 iov
[1].iov_base
= NULL
;
115 iov
[2].iov_base
= rest
->data
;
116 iov
[2].iov_len
= rest
->length
;
118 if (sendmsg (s
, &msghdr
, 0) < 0)
119 krb5_warn (context
, errno
, "sendmsg");
123 make_result (krb5_data
*data
,
124 uint16_t result_code
,
130 sp
= krb5_storage_emem();
131 if (sp
== NULL
) goto out
;
132 ret
= krb5_store_uint16(sp
, result_code
);
134 ret
= krb5_store_stringz(sp
, expl
);
136 ret
= krb5_storage_to_data(sp
, data
);
138 krb5_storage_free(sp
);
143 krb5_storage_free(sp
);
145 krb5_warnx (context
, "Out of memory generating error reply");
150 reply_error (krb5_realm realm
,
154 krb5_error_code error_code
,
155 uint16_t result_code
,
159 krb5_data error_data
;
161 krb5_principal server
= NULL
;
163 if (make_result(&e_data
, result_code
, expl
))
167 ret
= krb5_make_principal (context
, &server
, realm
,
168 "kadmin", "changepw", NULL
);
170 krb5_data_free (&e_data
);
175 ret
= krb5_mk_error (context
,
185 krb5_free_principal(context
, server
);
186 krb5_data_free (&e_data
);
188 krb5_warn (context
, ret
, "Could not even generate error reply");
191 send_reply (s
, sa
, sa_size
, NULL
, &error_data
);
192 krb5_data_free (&error_data
);
196 reply_priv (krb5_auth_context auth_context
,
200 uint16_t result_code
,
204 krb5_data krb_priv_data
;
205 krb5_data ap_rep_data
;
208 ret
= krb5_mk_rep (context
,
212 krb5_warn (context
, ret
, "Could not even generate error reply");
216 if (make_result(&e_data
, result_code
, expl
))
219 ret
= krb5_mk_priv (context
,
224 krb5_data_free (&e_data
);
226 krb5_warn (context
, ret
, "Could not even generate error reply");
229 send_reply (s
, sa
, sa_size
, &ap_rep_data
, &krb_priv_data
);
230 krb5_data_free (&ap_rep_data
);
231 krb5_data_free (&krb_priv_data
);
235 * Change the password for `principal', sending the reply back on `s'
236 * (`sa', `sa_size') to `pwd_data'.
240 change (krb5_auth_context auth_context
,
241 krb5_principal admin_principal
,
249 char *client
= NULL
, *admin
= NULL
;
250 kadm5_config_params conf
;
251 void *kadm5_handle
= NULL
;
252 krb5_principal principal
= NULL
;
253 krb5_data
*pwd_data
= NULL
;
255 ChangePasswdDataMS chpw
;
257 memset (&conf
, 0, sizeof(conf
));
258 memset(&chpw
, 0, sizeof(chpw
));
260 if (version
== KRB5_KPASSWD_VERS_CHANGEPW
) {
261 ret
= krb5_copy_data(context
, in_data
, &pwd_data
);
263 krb5_warn (context
, ret
, "krb5_copy_data");
264 reply_priv (auth_context
, s
, sa
, sa_size
, KRB5_KPASSWD_MALFORMED
,
265 "out out memory copying password");
268 principal
= admin_principal
;
269 } else if (version
== KRB5_KPASSWD_VERS_SETPW
) {
272 ret
= decode_ChangePasswdDataMS(in_data
->data
, in_data
->length
,
275 krb5_warn (context
, ret
, "decode_ChangePasswdDataMS");
276 reply_priv (auth_context
, s
, sa
, sa_size
, KRB5_KPASSWD_MALFORMED
,
277 "malformed ChangePasswdData");
282 ret
= krb5_copy_data(context
, &chpw
.newpasswd
, &pwd_data
);
284 krb5_warn (context
, ret
, "krb5_copy_data");
285 reply_priv (auth_context
, s
, sa
, sa_size
, KRB5_KPASSWD_MALFORMED
,
286 "out out memory copying password");
290 if (chpw
.targname
== NULL
&& chpw
.targrealm
!= NULL
) {
291 krb5_warn (context
, ret
, "kadm5_init_with_password_ctx");
292 reply_priv (auth_context
, s
, sa
, sa_size
,
293 KRB5_KPASSWD_MALFORMED
,
294 "targrealm but not targname");
299 krb5_principal_data princ
;
301 memset(&princ
, 0, sizeof (princ
));
302 princ
.name
= *chpw
.targname
;
303 princ
.realm
= *chpw
.targrealm
;
304 if (princ
.realm
== NULL
) {
305 ret
= krb5_get_default_realm(context
, &princ
.realm
);
309 "kadm5_init_with_password_ctx: "
310 "failed to allocate realm");
311 reply_priv (auth_context
, s
, sa
, sa_size
,
312 KRB5_KPASSWD_SOFTERROR
,
313 "failed to allocate realm");
317 ret
= krb5_copy_principal(context
, &princ
, &principal
);
318 if (*chpw
.targrealm
== NULL
)
321 krb5_warn(context
, ret
, "krb5_copy_principal");
322 reply_priv(auth_context
, s
, sa
, sa_size
,
323 KRB5_KPASSWD_HARDERROR
,
324 "failed to allocate principal");
328 principal
= admin_principal
;
330 krb5_warnx (context
, "kadm5_init_with_password_ctx: unknown proto");
331 reply_priv (auth_context
, s
, sa
, sa_size
,
332 KRB5_KPASSWD_HARDERROR
,
333 "Unknown protocol used");
337 ret
= krb5_unparse_name (context
, admin_principal
, &admin
);
339 krb5_warn (context
, ret
, "unparse_name failed");
340 reply_priv (auth_context
, s
, sa
, sa_size
,
341 KRB5_KPASSWD_HARDERROR
, "out of memory error");
345 conf
.realm
= principal
->realm
;
346 conf
.mask
|= KADM5_CONFIG_REALM
;
348 ret
= kadm5_init_with_password_ctx(context
,
355 krb5_warn (context
, ret
, "kadm5_init_with_password_ctx");
356 reply_priv (auth_context
, s
, sa
, sa_size
, 2,
361 ret
= krb5_unparse_name(context
, principal
, &client
);
363 krb5_warn (context
, ret
, "unparse_name failed");
364 reply_priv (auth_context
, s
, sa
, sa_size
,
365 KRB5_KPASSWD_HARDERROR
, "out of memory error");
369 if (krb5_principal_compare(context
, admin_principal
, principal
) == FALSE
) {
370 ret
= _kadm5_acl_check_permission(kadm5_handle
, KADM5_PRIV_CPW
,
373 krb5_warn (context
, ret
,
374 "Check ACL failed for %s for changing %s password",
376 reply_priv (auth_context
, s
, sa
, sa_size
,
377 KRB5_KPASSWD_HARDERROR
, "permission denied");
380 krb5_warnx (context
, "%s is changing password for %s", admin
, client
);
382 krb5_warnx (context
, "Changing password for %s", client
);
385 ret
= krb5_data_realloc(pwd_data
, pwd_data
->length
+ 1);
387 krb5_warn (context
, ret
, "malloc: out of memory");
388 reply_priv (auth_context
, s
, sa
, sa_size
, KRB5_KPASSWD_HARDERROR
,
392 tmp
= pwd_data
->data
;
393 tmp
[pwd_data
->length
- 1] = '\0';
395 ret
= kadm5_s_chpass_principal_cond (kadm5_handle
, principal
, 1, tmp
);
396 krb5_free_data (context
, pwd_data
);
399 const char *str
= krb5_get_error_message(context
, ret
);
402 case KADM5_PASS_Q_TOOSHORT
:
403 case KADM5_PASS_Q_CLASS
:
404 case KADM5_PASS_Q_DICT
:
405 case KADM5_PASS_Q_GENERIC
:
407 "%s didn't pass password quality check with error: %s",
410 krb5_warnx(context
, "kadm5_s_chpass_principal_cond: %s", str
);
412 reply_priv (auth_context
, s
, sa
, sa_size
, KRB5_KPASSWD_SOFTERROR
,
413 str
? str
: "Internal error");
414 krb5_free_error_message(context
, str
);
417 reply_priv (auth_context
, s
, sa
, sa_size
, KRB5_KPASSWD_SUCCESS
,
420 free_ChangePasswdDataMS(&chpw
);
421 if (principal
!= admin_principal
)
422 krb5_free_principal(context
, principal
);
428 krb5_free_data(context
, pwd_data
);
430 kadm5_destroy (kadm5_handle
);
434 verify (krb5_auth_context
*auth_context
,
436 krb5_ticket
**ticket
,
444 krb5_address
*client_addr
)
447 uint16_t pkt_len
, pkt_ver
, ap_req_len
;
448 krb5_data ap_req_data
;
449 krb5_data krb_priv_data
;
450 krb5_const_realm client_realm
;
451 krb5_principal sprinc
;
455 * Only send an error reply if the request passes basic length
456 * verification. Otherwise, kpasswdd would reply to every UDP packet,
457 * allowing an attacker to set up a ping-pong DoS attack via a spoofed UDP
458 * packet with a source address of another UDP service that also replies
461 * Also suppress the error reply if ap_req_len is 0, which indicates
462 * either an invalid request or an error packet. An error packet may be
463 * the result of a ping-pong attacker pointing us at another kpasswdd.
465 pkt_len
= (msg
[0] << 8) | (msg
[1]);
466 pkt_ver
= (msg
[2] << 8) | (msg
[3]);
467 ap_req_len
= (msg
[4] << 8) | (msg
[5]);
468 if (pkt_len
!= len
) {
469 krb5_warnx (context
, "Strange len: %ld != %ld",
470 (long)pkt_len
, (long)len
);
473 if (ap_req_len
== 0) {
474 krb5_warnx (context
, "Request is error packet (ap_req_len == 0)");
477 if (pkt_ver
!= KRB5_KPASSWD_VERS_CHANGEPW
&&
478 pkt_ver
!= KRB5_KPASSWD_VERS_SETPW
) {
479 krb5_warnx (context
, "Bad version (%d)", pkt_ver
);
480 reply_error (NULL
, s
, sa
, sa_size
, 0, 1, "Wrong program version");
485 ap_req_data
.data
= msg
+ 6;
486 ap_req_data
.length
= ap_req_len
;
488 ret
= krb5_rd_req (context
,
496 krb5_warn (context
, ret
, "krb5_rd_req");
497 reply_error (NULL
, s
, sa
, sa_size
, ret
, 3, "Authentication failed");
501 if (!(*ticket
)->ticket
.flags
.initial
) {
502 krb5_warnx(context
, "initial flag not set");
503 reply_error((*ticket
)->server
->realm
, s
, sa
, sa_size
, ret
, 1,
509 * The service principal must be kadmin/changepw@CLIENT-REALM, there
510 * is no reason to require the KDC's default realm(s) to be the same
511 * as the realm(s) it serves. The only potential issue is when a KDC
512 * is a master for realm A and a slave for realm B, in which case it
513 * should not accept requests to change passwords for realm B, these
514 * should be sent to realm B's master. This same issue is present in
515 * the checks that only accepted local realms, there is no new risk.
518 client_realm
= krb5_principal_get_realm(context
, (*ticket
)->client
);
519 ret
= krb5_make_principal(context
, &sprinc
, client_realm
,
520 "kadmin", "changepw", NULL
);
523 same
= krb5_principal_compare(context
, sprinc
, (*ticket
)->server
);
524 krb5_free_principal(context
, sprinc
);
529 if (krb5_unparse_name(context
, (*ticket
)->server
, &sname
) != 0)
531 krb5_warnx(context
, "Invalid kpasswd service principal %s",
532 sname
? sname
: "<enomem>");
534 reply_error(NULL
, s
, sa
, sa_size
, ret
, 1, "Bad request");
537 krb_priv_data
.data
= msg
+ 6 + ap_req_len
;
538 krb_priv_data
.length
= len
- 6 - ap_req_len
;
541 * Only enforce client addresses on on tickets with addresses. If
542 * its addressless, we are guessing its behind NAT and really
543 * can't know this information.
546 if ((*ticket
)->ticket
.caddr
&& (*ticket
)->ticket
.caddr
->len
> 0) {
547 ret
= krb5_auth_con_setaddrs (context
, *auth_context
,
550 krb5_warn (context
, ret
, "krb5_auth_con_setaddr(this)");
555 ret
= krb5_rd_priv (context
,
562 krb5_warn (context
, ret
, "krb5_rd_priv");
563 reply_error ((*ticket
)->server
->realm
, s
, sa
, sa_size
, ret
, 3,
569 krb5_free_ticket (context
, *ticket
);
575 process (krb5_keytab keytab
,
577 krb5_address
*this_addr
,
584 krb5_auth_context auth_context
= NULL
;
587 krb5_address other_addr
;
590 memset(&other_addr
, 0, sizeof(other_addr
));
591 krb5_data_zero (&out_data
);
593 ret
= krb5_auth_con_init (context
, &auth_context
);
595 krb5_warn (context
, ret
, "krb5_auth_con_init");
599 krb5_auth_con_setflags (context
, auth_context
,
600 KRB5_AUTH_CONTEXT_DO_SEQUENCE
);
602 ret
= krb5_sockaddr2address (context
, sa
, &other_addr
);
604 krb5_warn (context
, ret
, "krb5_sockaddr2address");
608 ret
= krb5_auth_con_setaddrs (context
, auth_context
, this_addr
, NULL
);
610 krb5_warn (context
, ret
, "krb5_auth_con_setaddr(this)");
614 if (verify (&auth_context
, keytab
, &ticket
, &out_data
,
615 &version
, s
, sa
, sa_size
, msg
, len
, &other_addr
) == 0)
618 * We always set the client_addr, to assume that the client
619 * can ignore it if it choose to do so (just the server does
620 * so for addressless tickets).
622 ret
= krb5_auth_con_setaddrs (context
, auth_context
,
623 this_addr
, &other_addr
);
625 krb5_warn (context
, ret
, "krb5_auth_con_setaddr(other)");
629 change (auth_context
,
635 memset (out_data
.data
, 0, out_data
.length
);
636 krb5_free_ticket (context
, ticket
);
640 krb5_free_address(context
, &other_addr
);
641 krb5_data_free(&out_data
);
642 krb5_auth_con_free(context
, auth_context
);
645 static const char *check_library
= NULL
;
646 static const char *check_function
= NULL
;
647 static getarg_strings policy_libraries
= { 0, NULL
};
648 static char sHDB
[] = "HDBGET:";
649 static char *keytab_str
= sHDB
;
650 static char *realm_str
;
651 static int version_flag
;
652 static int help_flag
;
653 static int detach_from_console
;
654 static int daemon_child
= -1;
655 static char *port_str
;
656 static char *config_file
;
658 struct getargs args
[] = {
660 { "check-library", 0, arg_string
, &check_library
,
661 "library to load password check function from", "library" },
662 { "check-function", 0, arg_string
, &check_function
,
663 "password check function to load", "function" },
664 { "policy-libraries", 0, arg_strings
, &policy_libraries
,
665 "password check function to load", "function" },
667 { "addresses", 0, arg_strings
, &addresses_str
,
668 "addresses to listen on", "list of addresses" },
669 { "detach", 0, arg_flag
, &detach_from_console
,
670 "detach from console", NULL
},
671 { "daemon-child", 0 , arg_integer
, &daemon_child
,
672 "private argument, do not use", NULL
},
673 { "keytab", 'k', arg_string
, &keytab_str
,
674 "keytab to get authentication key from", "kspec" },
675 { "config-file", 'c', arg_string
, &config_file
, NULL
, NULL
},
676 { "realm", 'r', arg_string
, &realm_str
, "default realm", "realm" },
677 { "port", 'p', arg_string
, &port_str
, "port", NULL
},
678 { "version", 0, arg_flag
, &version_flag
, NULL
, NULL
},
679 { "help", 0, arg_flag
, &help_flag
, NULL
, NULL
}
681 int num_args
= sizeof(args
) / sizeof(args
[0]);
684 doit(krb5_keytab keytab
, int port
)
689 krb5_addresses addrs
;
692 struct sockaddr_storage __ss
;
693 struct sockaddr
*sa
= (struct sockaddr
*)&__ss
;
695 if (explicit_addresses
.len
) {
696 addrs
= explicit_addresses
;
698 ret
= krb5_get_all_server_addrs(context
, &addrs
);
700 krb5_err(context
, 1, ret
, "krb5_get_all_server_addrs");
704 sockets
= malloc(n
* sizeof(*sockets
));
706 krb5_errx(context
, 1, "out of memory");
708 FD_ZERO(&real_fdset
);
709 for (i
= 0; i
< n
; ++i
) {
710 krb5_socklen_t sa_size
= sizeof(__ss
);
712 krb5_addr2sockaddr(context
, &addrs
.val
[i
], sa
, &sa_size
, port
);
714 sockets
[i
] = socket(__ss
.ss_family
, SOCK_DGRAM
, 0);
716 krb5_err(context
, 1, errno
, "socket");
717 if (bind(sockets
[i
], sa
, sa_size
) < 0) {
720 int save_errno
= errno
;
722 ret
= krb5_print_address(&addrs
.val
[i
], str
, sizeof(str
), &len
);
724 strlcpy(str
, "unknown address", sizeof(str
));
725 krb5_warn(context
, save_errno
, "bind(%s)", str
);
728 maxfd
= max(maxfd
, sockets
[i
]);
729 if (maxfd
>= FD_SETSIZE
)
730 krb5_errx(context
, 1, "fd too large");
731 FD_SET(sockets
[i
], &real_fdset
);
734 krb5_errx(context
, 1, "No sockets!");
736 roken_detach_finish(NULL
, daemon_child
);
738 while (exit_flag
== 0) {
740 fd_set fdset
= real_fdset
;
742 retx
= select(maxfd
+ 1, &fdset
, NULL
, NULL
, NULL
);
747 krb5_err(context
, 1, errno
, "select");
749 for (i
= 0; i
< n
; ++i
)
750 if (FD_ISSET(sockets
[i
], &fdset
)) {
752 socklen_t addrlen
= sizeof(__ss
);
754 retx
= recvfrom(sockets
[i
], buf
, sizeof(buf
), 0,
760 krb5_err(context
, 1, errno
, "recvfrom");
763 process(keytab
, sockets
[i
],
770 for (i
= 0; i
< n
; ++i
)
774 krb5_free_addresses(context
, &addrs
);
775 krb5_free_context(context
);
786 main(int argc
, char **argv
)
794 krb5_program_setup(&context
, argc
, argv
, args
, num_args
, NULL
);
797 krb5_std_usage(0, args
, num_args
);
804 if (detach_from_console
> 0 && daemon_child
== -1)
805 daemon_child
= roken_detach_prep(argc
, argv
, "--daemon-child");
807 if (config_file
== NULL
) {
808 aret
= asprintf(&config_file
, "%s/kdc.conf", hdb_db_dir(context
));
810 errx(1, "out of memory");
813 ret
= krb5_prepend_config_files_default(config_file
, &files
);
815 krb5_err(context
, 1, ret
, "getting configuration files");
817 ret
= krb5_set_config_files(context
, files
);
818 krb5_free_config_files(files
);
820 krb5_err(context
, 1, ret
, "reading configuration files");
823 krb5_set_default_realm(context
, realm_str
);
825 krb5_openlog(context
, "kpasswdd", &log_facility
);
826 krb5_set_warn_dest(context
, log_facility
);
828 if (port_str
!= NULL
) {
829 struct servent
*s
= roken_getservbyname(port_str
, "udp");
836 port
= strtol(port_str
, &ptr
, 10);
837 if (port
== 0 && ptr
== port_str
)
838 krb5_errx(context
, 1, "bad port `%s'", port_str
);
842 port
= krb5_getportbyname(context
, "kpasswd", "udp", KPASSWD_PORT
);
844 ret
= krb5_kt_register(context
, &hdb_get_kt_ops
);
846 krb5_err(context
, 1, ret
, "krb5_kt_register");
848 ret
= krb5_kt_resolve(context
, keytab_str
, &keytab
);
850 krb5_err(context
, 1, ret
, "%s", keytab_str
);
852 kadm5_setup_passwd_quality_check(context
, check_library
, check_function
);
854 for (i
= 0; i
< policy_libraries
.num_strings
; i
++) {
855 ret
= kadm5_add_passwd_quality_verifier(context
,
856 policy_libraries
.strings
[i
]);
858 krb5_err(context
, 1, ret
, "kadm5_add_passwd_quality_verifier");
860 ret
= kadm5_add_passwd_quality_verifier(context
, NULL
);
862 krb5_err(context
, 1, ret
, "kadm5_add_passwd_quality_verifier");
865 explicit_addresses
.len
= 0;
867 if (addresses_str
.num_strings
) {
870 for (j
= 0; j
< addresses_str
.num_strings
; ++j
)
871 add_one_address(addresses_str
.strings
[j
], j
== 0);
872 free_getarg_strings(&addresses_str
);
874 char **foo
= krb5_config_get_strings(context
, NULL
,
875 "kdc", "addresses", NULL
);
878 add_one_address(*foo
++, TRUE
);
880 add_one_address(*foo
++, FALSE
);
884 #ifdef HAVE_SIGACTION
889 sa
.sa_handler
= sigterm
;
890 sigemptyset(&sa
.sa_mask
);
892 sigaction(SIGINT
, &sa
, NULL
);
893 sigaction(SIGTERM
, &sa
, NULL
);
896 signal(SIGINT
, sigterm
);
897 signal(SIGTERM
, sigterm
);
902 return doit(keytab
, port
);