1 /* $NetBSD: isakmp_xauth.c,v 1.11.6.1 2007/08/07 04:49:24 manu Exp $ */
3 /* Id: isakmp_xauth.c,v 1.38 2006/08/22 18:17:17 manubsd Exp */
6 * Copyright (C) 2004-2005 Emmanuel Dreyfus
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. Neither the name of the project 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 PROJECT 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 PROJECT 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
36 #include <sys/types.h>
37 #include <sys/param.h>
38 #include <sys/socket.h>
39 #include <sys/queue.h>
41 #include <netinet/in.h>
49 #if TIME_WITH_SYS_TIME
50 # include <sys/time.h>
54 # include <sys/time.h>
78 #include "crypto_openssl.h"
79 #include "isakmp_var.h"
83 #include "remoteconf.h"
84 #include "isakmp_inf.h"
85 #include "isakmp_xauth.h"
86 #include "isakmp_unity.h"
87 #include "isakmp_cfg.h"
89 #include "ipsec_doi.h"
90 #include "remoteconf.h"
91 #include "localconf.h"
92 #include "vpn_control.h"
93 #include "vpn_control_var.h"
94 #include "ipsecSessionTracer.h"
95 #include "ipsecMessageTracer.h"
100 phase1_handle_t
*iph1
;
103 struct isakmp_pl_attr
*attr
;
104 struct isakmp_data
*typeattr
;
105 struct isakmp_data
*usrattr
;
106 struct isakmp_data
*pwdattr
;
107 struct xauth_state
*xst
= &iph1
->mode_cfg
->xauth
;
111 if (!FSM_STATE_IS_ESTABLISHED(iph1
->status
)) {
113 "Xauth request while phase 1 is not completed\n");
117 if (xst
->status
!= XAUTHST_NOTYET
) {
119 "Xauth request whith Xauth state %d\n", xst
->status
);
123 plog(ASL_LEVEL_NOTICE
, "Sending Xauth request\n");
125 tlen
= sizeof(*attr
) +
126 + sizeof(*typeattr
) +
130 if ((buffer
= vmalloc(tlen
)) == NULL
) {
131 plog(ASL_LEVEL_ERR
, "Cannot allocate buffer\n");
135 attr
= (struct isakmp_pl_attr
*)buffer
->v
;
136 memset(attr
, 0, tlen
);
138 attr
->h
.len
= htons(tlen
);
139 attr
->type
= ISAKMP_CFG_REQUEST
;
140 attr
->id
= htons(eay_random());
142 typeattr
= (struct isakmp_data
*)(attr
+ 1);
143 typeattr
->type
= htons(XAUTH_TYPE
| ISAKMP_GEN_TV
);
144 typeattr
->lorv
= htons(XAUTH_TYPE_GENERIC
);
146 usrattr
= (struct isakmp_data
*)(typeattr
+ 1);
147 usrattr
->type
= htons(XAUTH_USER_NAME
| ISAKMP_GEN_TLV
);
148 usrattr
->lorv
= htons(0);
150 pwdattr
= (struct isakmp_data
*)(usrattr
+ 1);
151 pwdattr
->type
= htons(XAUTH_USER_PASSWORD
| ISAKMP_GEN_TLV
);
152 pwdattr
->lorv
= htons(0);
154 isakmp_cfg_send(iph1
, buffer
,
155 ISAKMP_NPTYPE_ATTR
, ISAKMP_FLAG_E
, 1, 0, NULL
);
159 xst
->status
= XAUTHST_REQSENT
;
165 xauth_attr_reply(iph1
, attr
, id
)
166 phase1_handle_t
*iph1
;
167 struct isakmp_data
*attr
;
170 char **outlet
= NULL
;
173 struct xauth_state
*xst
= &iph1
->mode_cfg
->xauth
;
175 if ((iph1
->mode_cfg
->flags
& ISAKMP_CFG_VENDORID_XAUTH
) == 0) {
177 "Xauth reply but peer did not declare "
178 "itself as Xauth capable\n");
182 if (xst
->status
!= XAUTHST_REQSENT
) {
184 "Xauth reply while Xauth state is %d\n", xst
->status
);
188 type
= ntohs(attr
->type
) & ~ISAKMP_GEN_MASK
;
191 switch (ntohs(attr
->lorv
)) {
192 case XAUTH_TYPE_GENERIC
:
193 xst
->authtype
= XAUTH_TYPE_GENERIC
;
196 plog(ASL_LEVEL_WARNING
,
197 "Unexpected authentication type %d\n",
203 case XAUTH_USER_NAME
:
204 outlet
= &xst
->authdata
.generic
.usr
;
207 case XAUTH_USER_PASSWORD
:
208 outlet
= &xst
->authdata
.generic
.pwd
;
212 plog(ASL_LEVEL_WARNING
,
213 "ignored Xauth attribute %d\n", type
);
217 if (outlet
!= NULL
) {
218 alen
= ntohs(attr
->lorv
);
220 if ((*outlet
= racoon_realloc(*outlet
, alen
+ 1)) == NULL
) {
222 "Cannot allocate memory for Xauth Data\n");
226 memcpy(*outlet
, attr
+ 1, alen
);
227 (*outlet
)[alen
] = '\0';
232 if ((xst
->authdata
.generic
.usr
!= NULL
) &&
233 (xst
->authdata
.generic
.pwd
!= NULL
)) {
236 char *usr
= xst
->authdata
.generic
.usr
;
237 char *pwd
= xst
->authdata
.generic
.pwd
;
238 time_t throttle_delay
= 0;
240 #if 0 /* Real debug, don't do that at home */
241 plog(ASL_LEVEL_DEBUG
,
242 "Got username \"%s\", password \"%s\"\n", usr
, pwd
);
244 strlcpy(iph1
->mode_cfg
->login
, usr
, sizeof(iph1
->mode_cfg
->login
));
247 if ((port
= isakmp_cfg_getport(iph1
)) == -1) {
249 "Port pool depleted\n");
253 switch (isakmp_cfg_config
.authsource
) {
254 case ISAKMP_CFG_AUTH_SYSTEM
:
255 res
= xauth_login_system(usr
, pwd
);
260 "Unexpected authentication source\n");
266 * Optional group authentication
268 if (!res
&& (isakmp_cfg_config
.groupcount
))
269 res
= group_check(iph1
,
270 isakmp_cfg_config
.grouplist
,
271 isakmp_cfg_config
.groupcount
);
274 * On failure, throttle the connexion for the remote host
275 * in order to make password attacks more difficult.
277 throttle_delay
= throttle_host(iph1
->remote
, res
) - time(NULL
);
278 if (throttle_delay
> 0) {
281 str
= saddrwop2str((struct sockaddr
*)iph1
->remote
);
284 "Throttling in action for %s: delay %lds\n",
285 str
, (unsigned long)throttle_delay
);
292 if (throttle_delay
!= 0) {
293 struct xauth_reply_arg
*xra
;
295 if ((xra
= racoon_malloc(sizeof(*xra
))) == NULL
) {
297 "malloc failed, bypass throttling\n");
298 return xauth_reply(iph1
, port
, id
, res
);
302 * We need to store the ph1, but it might have
303 * disapeared when xauth_reply is called, so
304 * store the index instead.
306 xra
->index
= iph1
->index
;
310 sched_new(throttle_delay
, xauth_reply_stub
, xra
);
312 return xauth_reply(iph1
, port
, id
, res
);
320 xauth_reply_stub(args
)
323 struct xauth_reply_arg
*xra
= (struct xauth_reply_arg
*)args
;
324 phase1_handle_t
*iph1
;
326 if ((iph1
= ike_session_getph1byindex(NULL
, &xra
->index
)) != NULL
)
327 (void)xauth_reply(iph1
, xra
->port
, xra
->id
, xra
->res
);
330 "Delayed Xauth reply: phase 1 no longer exists.\n");
337 xauth_reply(iph1
, port
, id
, res
)
338 phase1_handle_t
*iph1
;
342 struct xauth_state
*xst
= &iph1
->mode_cfg
->xauth
;
343 char *usr
= xst
->authdata
.generic
.usr
;
345 if (iph1
->is_dying
) {
346 plog(ASL_LEVEL_NOTICE
,
347 "dropped login for user \"%s\"\n", usr
);
353 isakmp_cfg_putport(iph1
, port
);
355 plog(ASL_LEVEL_NOTICE
,
356 "login failed for user \"%s\"\n", usr
);
358 xauth_sendstatus(iph1
, XAUTH_STATUS_FAIL
, id
);
359 xst
->status
= XAUTHST_NOTYET
;
361 /* Delete Phase 1 SA */
362 if (FSM_STATE_IS_ESTABLISHED(iph1
->status
))
363 isakmp_info_send_d1(iph1
);
364 isakmp_ph1expire(iph1
);
369 xst
->status
= XAUTHST_OK
;
370 plog(ASL_LEVEL_NOTICE
,
371 "login succeeded for user \"%s\"\n", usr
);
373 xauth_sendstatus(iph1
, XAUTH_STATUS_OK
, id
);
379 xauth_sendstatus(iph1
, status
, id
)
380 phase1_handle_t
*iph1
;
385 struct isakmp_pl_attr
*attr
;
386 struct isakmp_data
*stattr
;
389 tlen
= sizeof(*attr
) +
392 if ((buffer
= vmalloc(tlen
)) == NULL
) {
393 plog(ASL_LEVEL_ERR
, "Cannot allocate buffer\n");
397 attr
= (struct isakmp_pl_attr
*)buffer
->v
;
398 memset(attr
, 0, tlen
);
400 attr
->h
.len
= htons(tlen
);
401 attr
->type
= ISAKMP_CFG_SET
;
402 attr
->id
= htons(id
);
404 stattr
= (struct isakmp_data
*)(attr
+ 1);
405 stattr
->type
= htons(XAUTH_STATUS
| ISAKMP_GEN_TV
);
406 stattr
->lorv
= htons(status
);
408 isakmp_cfg_send(iph1
, buffer
,
409 ISAKMP_NPTYPE_ATTR
, ISAKMP_FLAG_E
, 1, 0, NULL
);
418 xauth_login_system(usr
, pwd
)
428 if ((spw
= getspnam(usr
)) == NULL
)
431 syscryptpwd
= spw
->sp_pwdp
;
434 if ((pw
= getpwnam(usr
)) == NULL
)
437 #ifndef HAVE_SHADOW_H
438 syscryptpwd
= pw
->pw_passwd
;
441 /* No root login. Ever. */
445 if ((cryptpwd
= crypt(pwd
, syscryptpwd
)) == NULL
)
448 if (strcmp(cryptpwd
, syscryptpwd
) == 0)
455 xauth_group_system(usr
, grp
)
466 "the system group name \'%s\' is unknown\n",
471 while ((member
= gr
->gr_mem
[index
++])!=NULL
) {
472 if (!strcmp(member
,usr
)) {
473 plog(ASL_LEVEL_NOTICE
,
474 "membership validated\n");
484 phase1_handle_t
*iph1
;
486 struct xauth_state
*xst
= &iph1
->mode_cfg
->xauth
;
489 * Only the server side (edge device) really check for Xauth
490 * status. It does it if the chose authmethod is using Xauth.
491 * On the client side (roadwarrior), we don't check anything.
493 switch (AUTHMETHOD(iph1
)) {
494 case OAKLEY_ATTR_AUTH_METHOD_HYBRID_RSA_R
:
495 case OAKLEY_ATTR_AUTH_METHOD_XAUTH_RSASIG_R
:
496 case OAKLEY_ATTR_AUTH_METHOD_XAUTH_PSKEY_R
:
497 /* The following are not yet implemented */
498 case OAKLEY_ATTR_AUTH_METHOD_XAUTH_RSAENC_R
:
499 case OAKLEY_ATTR_AUTH_METHOD_XAUTH_RSAREV_R
:
500 if ((iph1
->mode_cfg
->flags
& ISAKMP_CFG_VENDORID_XAUTH
) == 0) {
502 "Hybrid auth negotiated but peer did not "
503 "announced as Xauth capable\n");
507 if (xst
->status
!= XAUTHST_OK
) {
509 "Hybrid auth negotiated but peer did not "
510 "succeed Xauth exchange\n");
525 group_check(iph1
, grp_list
, grp_count
)
526 phase1_handle_t
*iph1
;
534 /* check for presence of modecfg data */
536 if(iph1
->mode_cfg
== NULL
) {
538 "xauth group specified but modecfg not found\n");
542 /* loop through our group list */
544 for(; grp_index
< grp_count
; grp_index
++) {
546 /* check for presence of xauth data */
548 usr
= iph1
->mode_cfg
->xauth
.authdata
.generic
.usr
;
552 "xauth group specified but xauth not found\n");
556 /* call appropriate group validation funtion */
558 switch (isakmp_cfg_config
.groupsource
) {
560 case ISAKMP_CFG_GROUP_SYSTEM
:
561 res
= xauth_group_system(
563 grp_list
[grp_index
]);
567 /* we should never get here */
569 "Unknown group auth source\n");
574 plog(ASL_LEVEL_NOTICE
,
575 "user \"%s\" is a member of group \"%s\"\n",
577 grp_list
[grp_index
]);
580 plog(ASL_LEVEL_NOTICE
,
581 "user \"%s\" is not a member of group \"%s\"\n",
583 grp_list
[grp_index
]);
591 isakmp_xauth_req(iph1
, attr
)
592 phase1_handle_t
*iph1
;
593 struct isakmp_data
*attr
;
599 vchar_t
*buffer
= NULL
;
601 vchar_t
*mdata
= NULL
;
608 if ((iph1
->mode_cfg
->flags
& ISAKMP_CFG_VENDORID_XAUTH
) == 0) {
610 "Xauth mode config request but peer "
611 "did not declare itself as Xauth capable\n");
615 type
= ntohs(attr
->type
) & ~ISAKMP_GEN_MASK
;
620 if ((ntohs(attr
->type
) & ISAKMP_GEN_TV
) == 0) {
622 "Unexpected long XAUTH_TYPE attribute\n");
625 if (ntohs(attr
->lorv
) != XAUTH_TYPE_GENERIC
) {
627 "Unsupported Xauth authentication %d\n",
633 value
= XAUTH_TYPE_GENERIC
;
636 case XAUTH_USER_NAME
:
637 if (!iph1
->rmconf
->xauth
|| !iph1
->rmconf
->xauth
->login
) {
638 plog(ASL_LEVEL_ERR
, "Xauth performed "
639 "with no login supplied\n");
643 dlen
= iph1
->rmconf
->xauth
->login
->l
- 1;
644 iph1
->rmconf
->xauth
->state
|= XAUTH_SENT_USERNAME
;
647 case XAUTH_USER_PASSWORD
:
649 if (!iph1
->rmconf
->xauth
|| !iph1
->rmconf
->xauth
->login
)
652 skip
= sizeof(struct ipsecdoi_id_b
);
653 usr
= vmalloc(iph1
->rmconf
->xauth
->login
->l
- 1 + skip
);
656 "Cannot allocate memory\n");
659 memset(usr
->v
, 0, skip
);
660 memcpy(usr
->v
+ skip
,
661 iph1
->rmconf
->xauth
->login
->v
,
662 iph1
->rmconf
->xauth
->login
->l
- 1);
664 if (iph1
->rmconf
->xauth
->pass
) {
665 /* A key given through racoonctl */
666 pwd
= iph1
->rmconf
->xauth
->pass
;
668 if ((pwd
= getpskbyname(usr
)) == NULL
) {
670 "No password was found for login %s\n",
671 iph1
->rmconf
->xauth
->login
->v
);
675 /* We have to free it before returning */
680 iph1
->rmconf
->xauth
->state
|= XAUTH_SENT_PASSWORD
;
686 if ((ntohs(attr
->type
) & ISAKMP_GEN_TV
) == 0) {
687 dlen
= ntohs(attr
->lorv
);
689 mraw
= (char*)(attr
+ 1);
690 if ((mdata
= vmalloc(dlen
)) == NULL
) {
692 "Cannot allocate memory\n");
695 memcpy(mdata
->v
, mraw
, mdata
->l
);
696 plog(ASL_LEVEL_NOTICE
, "XAUTH Message: '%s'.\n",
697 binsanitize(mdata
->v
, mdata
->l
));
703 plog(ASL_LEVEL_WARNING
,
704 "Ignored attribute %s\n", s_isakmp_cfg_type(type
));
709 if ((buffer
= vmalloc(sizeof(*attr
) + dlen
)) == NULL
) {
711 "Cannot allocate memory\n");
715 attr
= (struct isakmp_data
*)buffer
->v
;
717 attr
->type
= htons(type
| ISAKMP_GEN_TV
);
718 attr
->lorv
= htons(value
);
722 attr
->type
= htons(type
| ISAKMP_GEN_TLV
);
723 attr
->lorv
= htons(dlen
);
724 data
= (char *)(attr
+ 1);
727 case XAUTH_USER_NAME
:
729 * iph1->rmconf->xauth->login->v is valid,
730 * we just checked it in the previous switch case
732 memcpy(data
, iph1
->rmconf
->xauth
->login
->v
, dlen
);
734 case XAUTH_USER_PASSWORD
:
736 memcpy(data
, pwd
->v
, dlen
);
750 isakmp_xauth_set(iph1
, attr
)
751 phase1_handle_t
*iph1
;
752 struct isakmp_data
*attr
;
755 vchar_t
*buffer
= NULL
;
756 struct xauth_state
*xst
;
759 vchar_t
*mdata
= NULL
;
761 if ((iph1
->mode_cfg
->flags
& ISAKMP_CFG_VENDORID_XAUTH
) == 0) {
762 IPSECSESSIONTRACEREVENT(iph1
->parent_session
,
763 IPSECSESSIONEVENTCODE_IKEV1_XAUTH_DROP
,
764 CONSTSTR("XAUTH is not supported by peer"),
765 CONSTSTR("XAUTH dropped (not supported by peer)"));
767 "Xauth mode config set but peer "
768 "did not declare itself as Xauth capable\n");
772 type
= ntohs(attr
->type
) & ~ISAKMP_GEN_MASK
;
777 * We should only receive ISAKMP mode_cfg SET XAUTH_STATUS
778 * when running as a client (initiator).
780 xst
= &iph1
->mode_cfg
->xauth
;
781 switch(AUTHMETHOD(iph1
)) {
782 case OAKLEY_ATTR_AUTH_METHOD_XAUTH_PSKEY_R
:
783 if (!iph1
->is_rekey
) {
784 IPSECSESSIONTRACEREVENT(iph1
->parent_session
,
785 IPSECSESSIONEVENTCODE_IKEV1_XAUTH_DROP
,
786 CONSTSTR("Unexpected XAUTH Status"),
787 CONSTSTR("Xauth dropped (unexpected Xauth status)... not a Phase 1 rekey"));
789 "Unexpected XAUTH_STATUS_OK... not a Phase 1 rekey\n");
792 case OAKLEY_ATTR_AUTH_METHOD_HYBRID_RSA_I
:
793 case FICTIVE_AUTH_METHOD_XAUTH_PSKEY_I
:
794 case OAKLEY_ATTR_AUTH_METHOD_XAUTH_RSASIG_I
:
795 /* Not implemented ... */
796 case OAKLEY_ATTR_AUTH_METHOD_XAUTH_RSAENC_I
:
797 case OAKLEY_ATTR_AUTH_METHOD_XAUTH_RSAREV_I
:
800 IPSECSESSIONTRACEREVENT(iph1
->parent_session
,
801 IPSECSESSIONEVENTCODE_IKEV1_XAUTH_DROP
,
802 CONSTSTR("Unexpected XAUTH Status"),
803 CONSTSTR("Xauth dropped (unexpected Xauth status)"));
805 "Unexpected XAUTH_STATUS_OK\n");
810 /* If we got a failure, delete iph1 */
811 if (ntohs(attr
->lorv
) != XAUTH_STATUS_OK
) {
812 IPSECSESSIONTRACEREVENT(iph1
->parent_session
,
813 IPSECSESSIONEVENTCODE_IKEV1_XAUTH_FAIL
,
814 CONSTSTR("XAUTH Status is not OK"),
815 CONSTSTR("Xauth Failed (status not ok)"));
817 "Xauth authentication failed\n");
819 vpncontrol_notify_ike_failed(VPNCTL_NTYPE_AUTHENTICATION_FAILED
, FROM_LOCAL
,
820 iph1_get_remote_v4_address(iph1
), 0, NULL
);
822 iph1
->mode_cfg
->flags
|= ISAKMP_CFG_DELETE_PH1
;
824 IPSECLOGASLMSG("IPSec Extended Authentication Failed.\n");
826 IPSECSESSIONTRACEREVENT(iph1
->parent_session
,
827 IPSECSESSIONEVENTCODE_IKEV1_XAUTH_SUCC
,
828 CONSTSTR("XAUTH Status is OK"),
830 if (iph1
->is_rekey
) {
831 xst
->status
= XAUTHST_OK
;
834 IPSECLOGASLMSG("IPSec Extended Authentication Passed.\n");
838 /* We acknowledge it */
841 if ((ntohs(attr
->type
) & ISAKMP_GEN_TV
) == 0) {
842 dlen
= ntohs(attr
->lorv
);
844 mraw
= (char*)(attr
+ 1);
845 if ((mdata
= vmalloc(dlen
)) == NULL
) {
847 "Cannot allocate memory\n");
850 memcpy(mdata
->v
, mraw
, mdata
->l
);
851 plog(ASL_LEVEL_NOTICE
, "XAUTH Message: '%s'.\n",
852 binsanitize(mdata
->v
, mdata
->l
));
858 IPSECSESSIONTRACEREVENT(iph1
->parent_session
,
859 IPSECSESSIONEVENTCODE_IKEV1_XAUTH_DROP
,
860 CONSTSTR("ignored attribute"),
861 CONSTSTR("Xauth dropped (ignored attribute)"));
862 plog(ASL_LEVEL_WARNING
,
863 "Ignored attribute %s\n", s_isakmp_cfg_type(type
));
868 if ((buffer
= vmalloc(sizeof(*attr
))) == NULL
) {
869 IPSECSESSIONTRACEREVENT(iph1
->parent_session
,
870 IPSECSESSIONEVENTCODE_IKEV1_XAUTH_DROP
,
871 CONSTSTR("Failed to allocate attribute"),
872 CONSTSTR("Xauth dropped (failed to allocate attribute)"));
874 "Cannot allocate memory\n");
878 attr
= (struct isakmp_data
*)buffer
->v
;
879 attr
->type
= htons(type
| ISAKMP_GEN_TV
);
880 attr
->lorv
= htons(0);
888 struct xauth_state
*xst
;
890 switch (xst
->authtype
) {
891 case XAUTH_TYPE_GENERIC
:
892 if (xst
->authdata
.generic
.usr
)
893 racoon_free(xst
->authdata
.generic
.usr
);
895 if (xst
->authdata
.generic
.pwd
)
896 racoon_free(xst
->authdata
.generic
.pwd
);
900 case XAUTH_TYPE_CHAP
:
902 case XAUTH_TYPE_SKEY
:
903 plog(ASL_LEVEL_WARNING
,
904 "Unsupported authtype %d\n", xst
->authtype
);
908 plog(ASL_LEVEL_WARNING
,
909 "Unexpected authtype %d\n", xst
->authtype
);
917 xauth_rmconf_used(xauth_rmconf
)
918 struct xauth_rmconf
**xauth_rmconf
;
920 if (*xauth_rmconf
== NULL
) {
921 *xauth_rmconf
= racoon_malloc(sizeof(**xauth_rmconf
));
922 if (*xauth_rmconf
== NULL
) {
924 "xauth_rmconf_used: malloc failed\n");
928 (*xauth_rmconf
)->login
= NULL
;
929 (*xauth_rmconf
)->pass
= NULL
;
930 (*xauth_rmconf
)->state
= 0;
932 if ((*xauth_rmconf
)->login
) {
933 vfree((*xauth_rmconf
)->login
);
934 (*xauth_rmconf
)->login
= NULL
;
936 if ((*xauth_rmconf
)->pass
!= NULL
) {
937 vfree((*xauth_rmconf
)->pass
);
938 (*xauth_rmconf
)->pass
= NULL
;
940 (*xauth_rmconf
)->state
= 0;
947 xauth_rmconf_delete(xauth_rmconf
)
948 struct xauth_rmconf
**xauth_rmconf
;
950 if (*xauth_rmconf
!= NULL
) {
951 if ((*xauth_rmconf
)->login
!= NULL
)
952 vfree((*xauth_rmconf
)->login
);
953 if ((*xauth_rmconf
)->pass
!= NULL
)
954 vfree((*xauth_rmconf
)->pass
);
956 racoon_free(*xauth_rmconf
);
957 *xauth_rmconf
= NULL
;