1 /* $NetBSD: remoteconf.c,v 1.9.4.1 2007/08/01 11:52:22 vanhu Exp $ */
3 /* Id: remoteconf.c,v 1.38 2006/05/06 15:52:44 manubsd Exp */
6 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
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>
42 #include <netinet/in_systm.h>
43 #include <netinet/ip.h>
45 #ifndef HAVE_NETINET6_IPSEC
46 #include <netinet/ipsec.h>
48 #include <netinet6/ipsec.h>
64 #include "isakmp_var.h"
66 #include "isakmp_xauth.h"
69 #include "ipsec_doi.h"
71 #include "remoteconf.h"
72 #include "localconf.h"
73 #include "grabmyaddr.h"
79 #include "algorithm.h"
80 #include "nattraversal.h"
81 #include "isakmp_frag.h"
84 static TAILQ_HEAD(_rmtree
, remoteconf
) rmtree
;
87 * Script hook names and script hook paths
89 char *script_names
[SCRIPT_MAX
+ 1] = { "phase1_up", "phase1_down" };
93 * search remote configuration.
94 * don't use port number to search if its value is either IPSEC_PORT_ANY.
95 * If matching anonymous entry, then new entry is copied from anonymous entry.
96 * If no anonymous entry found, then return NULL.
98 * Other: remote configuration entry.
101 getrmconf_strict(remote
, allow_anon
)
102 struct sockaddr_storage
*remote
;
105 struct remoteconf
*p
;
106 struct remoteconf
*p_withport_besteffort
= NULL
;
107 struct remoteconf
*p_with_prefix
= NULL
;
108 struct remoteconf
*p_with_prefix_besteffort
= NULL
;
110 struct remoteconf
*anon
= NULL
;
113 char buf
[NI_MAXHOST
+ NI_MAXSERV
+ 10];
114 char addr
[NI_MAXHOST
], port
[NI_MAXSERV
];
119 * We never have ports set in our remote configurations, but when
120 * NAT-T is enabled, the kernel can have policies with ports and
121 * send us an acquire message for a destination that has a port set.
122 * If we do this port check here, we have to fallback to a best-effort result (without the port).
124 * In an ideal world, we would be able to have remote conf with
125 * port, and the port could be a wildcard. That test could be used.
127 switch (remote
->ss_family
) {
129 if (((struct sockaddr_in
*)remote
)->sin_port
!= IPSEC_PORT_ANY
)
134 if (((struct sockaddr_in6
*)remote
)->sin6_port
!= IPSEC_PORT_ANY
)
142 plog(LLV_ERROR2
, LOCATION
, NULL
,
143 "invalid ip address family: %d\n", remote
->ss_family
);
147 if (remote
->ss_family
== AF_UNSPEC
)
148 snprintf (buf
, sizeof(buf
), "%s", "anonymous");
150 GETNAMEINFO((struct sockaddr
*)remote
, addr
, port
);
151 snprintf(buf
, sizeof(buf
), "%s%s%s%s", addr
,
153 withport
? port
: "",
154 withport
? "]" : "");
157 TAILQ_FOREACH(p
, &rmtree
, chain
) {
158 if (p
->to_delete
|| p
->to_remove
) {
162 if (remote
->ss_family
== AF_UNSPEC
163 && remote
->ss_family
== p
->remote
->ss_family
) {
164 plog(LLV_DEBUG
, LOCATION
, NULL
,
165 "configuration found for %s.\n", buf
);
168 if (p
->remote_prefix
== 0) {
169 if ((!withport
&& cmpsaddrwop(remote
, p
->remote
) == 0)
170 || (withport
&& cmpsaddrstrict(remote
, p
->remote
) == 0)) {
171 plog(LLV_DEBUG
, LOCATION
, NULL
,
172 "configuration found for %s.\n", buf
);
174 } else if (withport
&& cmpsaddrwop(remote
, p
->remote
) == 0) {
175 // for withport: save the pointer for the best-effort search
176 p_withport_besteffort
= p
;
179 if ((!withport
&& cmpsaddrwop_withprefix(remote
, p
->remote
, p
->remote_prefix
) == 0)
180 || (withport
&& cmpsaddrstrict_withprefix(remote
, p
->remote
, p
->remote_prefix
) == 0)) {
181 if (p
->remote_prefix
>= last_prefix
) {
183 last_prefix
= p
->remote_prefix
;
185 } else if (withport
&& cmpsaddrwop_withprefix(remote
, p
->remote
, p
->remote_prefix
) == 0) {
186 if (p
->remote_prefix
>= last_prefix
) {
187 p_with_prefix_besteffort
= p
;
188 last_prefix
= p
->remote_prefix
;
193 /* save the pointer to the anonymous configuration */
194 if (p
->remote
->ss_family
== AF_UNSPEC
)
198 if (p_withport_besteffort
) {
199 plog(LLV_DEBUG
, LOCATION
, NULL
,
200 "configuration found for %s.\n", buf
);
201 return p_withport_besteffort
;
204 plog(LLV_DEBUG
, LOCATION
, NULL
,
205 "configuration found for %s.\n", buf
);
206 return p_with_prefix
;
208 if (p_with_prefix_besteffort
) {
209 plog(LLV_DEBUG
, LOCATION
, NULL
,
210 "configuration found for %s.\n", buf
);
211 return p_with_prefix_besteffort
;
213 if (allow_anon
&& anon
!= NULL
) {
214 plog(LLV_DEBUG
, LOCATION
, NULL
,
215 "anonymous configuration selected for %s.\n", buf
);
219 plog(LLV_DEBUG
, LOCATION
, NULL
,
220 "no remote configuration found.\n");
226 no_remote_configs(ignore_anonymous
)
227 int ignore_anonymous
;
230 struct remoteconf
*p
;
231 #if !TARGET_OS_EMBEDDED
232 static const char default_idv
[] = "macuser@localhost";
233 static const int default_idv_len
= sizeof(default_idv
) - 1;
236 TAILQ_FOREACH(p
, &rmtree
, chain
) {
237 if (ignore_anonymous
) {
238 if (p
->remote
->ss_family
== AF_UNSPEC
) /* anonymous */
241 #if !TARGET_OS_EMBEDDED
242 // ignore the default btmm ipv6 config thats always present in racoon.conf
243 if (p
->remote
->ss_family
== AF_INET6
&&
244 p
->idvtype
== IDTYPE_USERFQDN
&&
246 p
->idv
->l
== default_idv_len
&&
247 strncmp(p
->idv
->v
, default_idv
, p
->idv
->l
) == 0) {
258 struct sockaddr_storage
*remote
;
260 return getrmconf_strict(remote
, 1);
264 link_rmconf_to_ph1 (struct remoteconf
*new)
269 if (new->to_delete
||
273 new->linked_to_ph1
++;
278 unlink_rmconf_from_ph1 (struct remoteconf
*old
)
283 if (old
->linked_to_ph1
<= 0) {
286 old
->linked_to_ph1
--;
287 if (old
->linked_to_ph1
== 0) {
288 if (old
->to_remove
) {
291 if (old
->to_delete
) {
301 struct remoteconf
*new;
304 new = racoon_calloc(1, sizeof(*new));
308 new->proposal
= NULL
;
311 new->doitype
= IPSEC_DOI
;
312 new->sittype
= IPSECDOI_SIT_IDENTITY_ONLY
;
313 new->idvtype
= IDTYPE_UNDEFINED
;
314 new->idvl_p
= genlist_init();
315 new->nonce_size
= DEFAULT_NONCE_SIZE
;
316 new->passive
= FALSE
;
317 new->ike_frag
= ISAKMP_FRAG_FORCE
;
318 new->esp_frag
= IP_MAXPACKET
;
319 new->ini_contact
= TRUE
;
320 new->mode_cfg
= FALSE
;
321 new->pcheck_level
= PROP_CHECK_STRICT
;
322 new->verify_identifier
= FALSE
;
323 new->verify_cert
= TRUE
;
324 new->getcert_method
= ISAKMP_GETCERT_PAYLOAD
;
325 new->getcacert_method
= ISAKMP_GETCERT_LOCALFILE
;
326 new->cacerttype
= ISAKMP_CERT_X509SIGN
;
327 new->certtype
= ISAKMP_CERT_NONE
;
328 new->cacertfile
= NULL
;
329 new->send_cert
= TRUE
;
331 new->support_proxy
= FALSE
;
332 for (i
= 0; i
<= SCRIPT_MAX
; i
++)
333 new->script
[i
] = NULL
;
334 new->gen_policy
= FALSE
;
335 new->retry_counter
= lcconf
->retry_counter
;
336 new->retry_interval
= lcconf
->retry_interval
;
337 new->nat_traversal
= NATT_ON
;
338 new->natt_multiple_user
= FALSE
;
339 new->natt_keepalive
= TRUE
;
340 new->to_remove
= FALSE
;
341 new->to_delete
= FALSE
;
342 new->linked_to_ph1
= 0;
346 new->dpd
= TRUE
; /* Enable DPD support by default */
347 new->dpd_interval
= 0; /* Disable DPD checks by default */
349 new->dpd_maxfails
= 5;
350 new->dpd_algo
= DPD_ALGO_INBOUND_DETECT
;
351 new->idle_timeout
= 0;
353 new->weak_phase1_check
= 0;
358 new->initiate_ph1rekey
= TRUE
;
364 struct sockaddr_storage
*remote
;
366 struct remoteconf
*new, *old
;
368 old
= getrmconf_strict (remote
, 0);
370 plog (LLV_ERROR
, LOCATION
, NULL
,
371 "Remote configuration for '%s' not found!\n",
372 saddr2str((struct sockaddr
*)remote
));
376 new = duprmconf (old
);
387 struct idspec
*old
= (struct idspec
*) entry
;
389 if (!id
) return (void *) -1;
391 if (set_identifier(&id
->id
, old
->idtype
, old
->id
) != 0) {
396 id
->idtype
= old
->idtype
;
398 genlist_append(arg
, id
);
404 struct remoteconf
*rmconf
;
406 struct remoteconf
*new;
409 new = racoon_calloc(1, sizeof(*new));
412 memcpy (new, rmconf
, sizeof (*new));
413 // FIXME: We should duplicate remote, proposal, etc.
414 // This is now handled in the cfparse.y
415 // new->proposal = ...;
419 new->keychainCertRef
= NULL
; /* peristant keychain ref for cert */
420 new->shared_secret
= NULL
; /* shared secret */
421 new->open_dir_auth_group
= NULL
; /* group to be used to authorize user */
422 new->proposal
= NULL
;
423 new->cacertfile
= NULL
;
424 for (i
= 0; i
<= SCRIPT_MAX
; i
++)
425 new->script
[i
] = NULL
;
426 new->to_remove
= FALSE
;
427 new->to_delete
= FALSE
;
428 new->linked_to_ph1
= 0;
435 /* duplicate dynamic structures */
437 new->etypes
=dupetypes(new->etypes
);
438 new->idvl_p
= genlist_init();
439 genlist_foreach(rmconf
->idvl_p
, dupidvl
, new->idvl_p
);
445 idspec_free(void *data
)
447 vfree (((struct idspec
*)data
)->id
);
452 proposalspec_free(struct proposalspec
*head
)
455 struct proposalspec
* next_propsp
= head
;
457 while (next_propsp
) {
458 struct proposalspec
* curr_propsp
;
459 struct secprotospec
* next_protosp
;
461 curr_propsp
= next_propsp
;
462 next_propsp
= next_propsp
->next
;
463 next_protosp
= curr_propsp
->spspec
;
464 while (next_protosp
) {
465 struct secprotospec
* curr_protosp
;
467 curr_protosp
= next_protosp
;
468 next_protosp
= next_protosp
->next
;
470 if (curr_protosp
->gssid
)
471 free(curr_protosp
->gssid
);
472 if (curr_protosp
->remote
)
473 free(curr_protosp
->remote
);
474 racoon_free(curr_protosp
);
476 racoon_free(curr_propsp
);
482 struct remoteconf
*rmconf
;
484 if (rmconf
->linked_to_ph1
) {
485 rmconf
->to_delete
= TRUE
;
489 racoon_free(rmconf
->remote
);
492 xauth_rmconf_delete(&rmconf
->xauth
);
494 if (rmconf
->etypes
) {
495 deletypes(rmconf
->etypes
);
501 genlist_free(rmconf
->idvl_p
, idspec_free
);
503 oakley_dhgrp_free(rmconf
->dhgrp
);
504 if (rmconf
->proposal
)
505 delisakmpsa(rmconf
->proposal
);
506 if (rmconf
->mycertfile
)
507 racoon_free(rmconf
->mycertfile
);
508 if (rmconf
->myprivfile
)
509 racoon_free(rmconf
->myprivfile
);
510 if (rmconf
->peerscertfile
)
511 racoon_free(rmconf
->peerscertfile
);
512 if (rmconf
->cacertfile
)
513 racoon_free(rmconf
->cacertfile
);
515 proposalspec_free(rmconf
->prhead
);
516 if (rmconf
->shared_secret
)
517 vfree(rmconf
->shared_secret
);
518 if (rmconf
->keychainCertRef
)
519 vfree(rmconf
->keychainCertRef
);
520 if (rmconf
->open_dir_auth_group
)
521 vfree(rmconf
->open_dir_auth_group
);
531 oakley_dhgrp_free(sa
->dhgrp
);
533 delisakmpsa(sa
->next
);
550 new = racoon_malloc(sizeof(struct etypes
));
554 new->type
= orig
->type
;
558 new->next
=dupetypes(orig
->next
);
573 * insert into head of list.
577 struct remoteconf
*new;
579 TAILQ_INSERT_HEAD(&rmtree
, new, chain
);
584 struct remoteconf
*rmconf
;
586 if (rmconf
->linked_to_ph1
) {
587 rmconf
->to_remove
= TRUE
;
590 TAILQ_REMOVE(&rmtree
, rmconf
, chain
);
596 struct remoteconf
*p
, *next
;
598 for (p
= TAILQ_FIRST(&rmtree
); p
; p
= next
) {
599 next
= TAILQ_NEXT(p
, chain
);
611 /* check exchange type to be acceptable */
613 check_etypeok(rmconf
, etype
)
614 struct remoteconf
*rmconf
;
619 for (e
= rmconf
->etypes
; e
!= NULL
; e
= e
->next
) {
620 if (e
->type
== etype
)
631 struct isakmpsa
*new;
633 new = racoon_calloc(1, sizeof(*new));
638 * Just for sanity, make sure this is initialized. This is
639 * filled in for real when the ISAKMP proposal is configured.
641 new->vendorid
= VENDORID_UNKNOWN
;
653 * insert into tail of list.
656 insisakmpsa(new, rmconf
)
657 struct isakmpsa
*new;
658 struct remoteconf
*rmconf
;
662 new->rmconf
= rmconf
;
664 if (rmconf
->proposal
== NULL
) {
665 rmconf
->proposal
= new;
669 for (p
= rmconf
->proposal
; p
->next
!= NULL
; p
= p
->next
)
677 foreachrmconf(rmconf_func_t rmconf_func
, void *data
)
679 struct remoteconf
*p
, *ret
= NULL
;
681 TAILQ_FOREACH_REVERSE(p
, &rmtree
, _rmtree
, chain
) {
682 ret
= (*rmconf_func
)(p
, data
);
691 dump_peers_identifiers (void *entry
, void *arg
)
693 struct idspec
*id
= (struct idspec
*) entry
;
694 char buf
[1024], *pbuf
;
696 pbuf
+= snprintf (pbuf
, sizeof(buf
) - (pbuf
- buf
), "\tpeers_identifier %s",
697 s_idtype (id
->idtype
));
699 pbuf
+= snprintf (pbuf
, sizeof(buf
) - (pbuf
- buf
), " \"%s\"", id
->id
->v
);
700 plog(LLV_INFO
, LOCATION
, NULL
, "%s;\n", buf
);
704 static struct remoteconf
*
705 dump_rmconf_single (struct remoteconf
*p
, void *data
)
707 struct etypes
*etype
= p
->etypes
;
708 struct isakmpsa
*prop
= p
->proposal
;
709 char buf
[1024], *pbuf
;
712 if (p
->remote_prefix
)
713 pbuf
+= snprintf(pbuf
, sizeof(buf
) - (pbuf
- buf
), "remote %s",
714 saddr2str_with_prefix((struct sockaddr
*)p
->remote
, p
->remote_prefix
));
716 pbuf
+= snprintf(pbuf
, sizeof(buf
) - (pbuf
- buf
), "remote %s", saddr2str((struct sockaddr
*)p
->remote
));
717 if (p
->inherited_from
)
718 pbuf
+= snprintf(pbuf
, sizeof(buf
) - (pbuf
- buf
), " inherit %s",
719 saddr2str((struct sockaddr
*)p
->inherited_from
->remote
));
720 plog(LLV_INFO
, LOCATION
, NULL
, "%s {\n", buf
);
722 pbuf
+= snprintf(pbuf
, sizeof(buf
) - (pbuf
- buf
), "\texchange_type ");
724 pbuf
+= snprintf (pbuf
, sizeof(buf
) - (pbuf
- buf
), "%s%s", s_etype(etype
->type
),
725 etype
->next
!= NULL
? ", " : ";\n");
728 plog(LLV_INFO
, LOCATION
, NULL
, "%s", buf
);
729 plog(LLV_INFO
, LOCATION
, NULL
, "\tdoi %s;\n", s_doi(p
->doitype
));
731 pbuf
+= snprintf(pbuf
, sizeof(buf
) - (pbuf
- buf
), "\tmy_identifier %s", s_idtype (p
->idvtype
));
732 if (p
->idvtype
== IDTYPE_ASN1DN
) {
733 plog(LLV_INFO
, LOCATION
, NULL
, "%s;\n", buf
);
734 plog(LLV_INFO
, LOCATION
, NULL
, "\tcertificate_type %s \"%s\" \"%s\";\n",
735 p
->certtype
== ISAKMP_CERT_X509SIGN
? "x509" : "*UNKNOWN*",
736 p
->mycertfile
, p
->myprivfile
);
737 switch (p
->getcert_method
) {
740 case ISAKMP_GETCERT_PAYLOAD
:
741 plog(LLV_INFO
, LOCATION
, NULL
, "\t/* peers certificate from payload */\n");
743 case ISAKMP_GETCERT_LOCALFILE
:
744 plog(LLV_INFO
, LOCATION
, NULL
, "\tpeers_certfile \"%s\";\n", p
->peerscertfile
);
746 case ISAKMP_GETCERT_DNS
:
747 plog(LLV_INFO
, LOCATION
, NULL
, "\tpeer_certfile dnssec;\n");
750 plog(LLV_INFO
, LOCATION
, NULL
, "\tpeers_certfile *UNKNOWN* (%d)\n", p
->getcert_method
);
755 pbuf
+= snprintf (pbuf
, sizeof(buf
) - (pbuf
- buf
), " \"%s\"", p
->idv
->v
);
756 plog(LLV_INFO
, LOCATION
, NULL
, "%s;\n", buf
);
757 genlist_foreach(p
->idvl_p
, &dump_peers_identifiers
, NULL
);
760 plog(LLV_INFO
, LOCATION
, NULL
, "\tsend_cert %s;\n",
761 s_switch (p
->send_cert
));
762 plog(LLV_INFO
, LOCATION
, NULL
, "\tsend_cr %s;\n",
763 s_switch (p
->send_cr
));
764 plog(LLV_INFO
, LOCATION
, NULL
, "\tverify_cert %s;\n",
765 s_switch (p
->verify_cert
));
766 plog(LLV_INFO
, LOCATION
, NULL
, "\tverify_identifier %s;\n",
767 s_switch (p
->verify_identifier
));
768 plog(LLV_INFO
, LOCATION
, NULL
, "\tnat_traversal %s;\n",
769 p
->nat_traversal
== NATT_FORCE
?
770 "force" : s_switch (p
->nat_traversal
));
771 plog(LLV_INFO
, LOCATION
, NULL
, "\tnatt_multiple_user %s;\n",
772 s_switch (p
->natt_multiple_user
));
773 plog(LLV_INFO
, LOCATION
, NULL
, "\tnonce_size %d;\n",
775 plog(LLV_INFO
, LOCATION
, NULL
, "\tpassive %s;\n",
776 s_switch (p
->passive
));
777 plog(LLV_INFO
, LOCATION
, NULL
, "\tike_frag %s;\n",
778 p
->ike_frag
== ISAKMP_FRAG_FORCE
?
779 "force" : s_switch (p
->ike_frag
));
780 plog(LLV_INFO
, LOCATION
, NULL
, "\tesp_frag %d;\n", p
->esp_frag
);
781 plog(LLV_INFO
, LOCATION
, NULL
, "\tinitial_contact %s;\n",
782 s_switch (p
->ini_contact
));
783 plog(LLV_INFO
, LOCATION
, NULL
, "\tgenerate_policy %s;\n",
784 s_switch (p
->gen_policy
));
785 plog(LLV_INFO
, LOCATION
, NULL
, "\tsupport_proxy %s;\n",
786 s_switch (p
->support_proxy
));
789 plog(LLV_INFO
, LOCATION
, NULL
, "\n");
790 plog(LLV_INFO
, LOCATION
, NULL
,
791 "\t/* prop_no=%d, trns_no=%d, rmconf=%s */\n",
792 prop
->prop_no
, prop
->trns_no
,
793 saddr2str((struct sockaddr
*)prop
->rmconf
->remote
));
794 plog(LLV_INFO
, LOCATION
, NULL
, "\tproposal {\n");
795 plog(LLV_INFO
, LOCATION
, NULL
, "\t\tlifetime time %lu sec;\n",
796 (long)prop
->lifetime
);
797 plog(LLV_INFO
, LOCATION
, NULL
, "\t\tlifetime bytes %zd;\n",
799 plog(LLV_INFO
, LOCATION
, NULL
, "\t\tdh_group %s;\n",
800 alg_oakley_dhdef_name(prop
->dh_group
));
801 plog(LLV_INFO
, LOCATION
, NULL
, "\t\tencryption_algorithm %s;\n",
802 alg_oakley_encdef_name(prop
->enctype
));
803 plog(LLV_INFO
, LOCATION
, NULL
, "\t\thash_algorithm %s;\n",
804 alg_oakley_hashdef_name(prop
->hashtype
));
805 plog(LLV_INFO
, LOCATION
, NULL
, "\t\tauthentication_method %s;\n",
806 alg_oakley_authdef_name(prop
->authmethod
));
807 plog(LLV_INFO
, LOCATION
, NULL
, "\t}\n");
810 plog(LLV_INFO
, LOCATION
, NULL
, "}\n");
811 plog(LLV_INFO
, LOCATION
, NULL
, "\n");
819 foreachrmconf (dump_rmconf_single
, NULL
);
827 new = racoon_calloc(1, sizeof(*new));
830 new->idtype
= IDTYPE_ADDRESS
;
836 script_path_add(path
)
843 script_dir
= lcconf
->pathinfo
[LC_PATHTYPE_SCRIPT
];
845 /* Try to find the script in the script directory */
846 if ((path
->v
[0] != '/') && (script_dir
!= NULL
)) {
847 len
= strlen(script_dir
) + sizeof("/") + path
->l
+ 1;
849 if ((new_path
= vmalloc(len
)) == NULL
) {
850 plog(LLV_ERROR
, LOCATION
, NULL
,
851 "Cannot allocate memory: %s\n", strerror(errno
));
855 new_path
->v
[0] = '\0';
856 (void)strlcat(new_path
->v
, script_dir
, new_path
->l
);
857 (void)strlcat(new_path
->v
, "/", new_path
->l
);
858 (void)strlcat(new_path
->v
, path
->v
, new_path
->l
);
869 dupisakmpsa(struct isakmpsa
*sa
)
871 struct isakmpsa
*res
= NULL
;
882 res
->gssid
=vdup(sa
->gssid
);
886 if (sa
->dhgrp
!= NULL
)
887 oakley_setdhgroup(sa
->dh_group
, &(res
->dhgrp
));