Skip to content

Commit

Permalink
* XAUTH: Use incoming XAUTH VID when picking best connection
Browse files Browse the repository at this point in the history
I have prepared a patch witch solves for me following issue with Xauth
in Openswan.  Pluto may refuse to connect with a road warrior If some
misc connections (with and without Xauth) are configured. The reason is
that pluto do not regard Xauth policy in main_inI1_outR2 and may just
choose a not suitable connection for proceeding. In my patch I evaluate
XAUTH VID and use this information by connection finding.

Signed-off-by: Paul Wouters <paul@libreswan.org>
  • Loading branch information
Andrey Alexandrenko authored and Jehreg committed Jan 27, 2014
1 parent 706ce34 commit 0fc468c
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/libipsecconf/confread.c
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,10 @@ static int validate_end(struct starter_conn *conn_st
if (ugh) ERR_FOUND("bad %sprotoport=%s [%s]", leftright, value, ugh);
}

if(end->options_set[KNCF_XAUTHSERVER]) {
conn_st->policy |= POLICY_XAUTH;
}

/*
KSCF_SUBNETWITHIN --- not sure what to do with it.
KSCF_ESPENCKEY --- todo (manual keying)
Expand Down
2 changes: 1 addition & 1 deletion lib/libpluto/pluto_constants.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ const char *const sa_policy_bit_names[] = {
"GROUP",
"GROUTED",
"UP",
"dummy1(XAUTH)",
"XAUTH",
"MODECFGPULL",
"AGGRESSIVE",
"PERHOST",
Expand Down
7 changes: 7 additions & 0 deletions programs/pluto/connections.c
Original file line number Diff line number Diff line change
Expand Up @@ -1366,6 +1366,11 @@ add_connection(const struct whack_message *wm)
same_leftca = extract_end(&c->spd.this, &wm->left, "left");
same_rightca = extract_end(&c->spd.that, &wm->right, "right");

if (c->spd.this.xauth_server || c->spd.that.xauth_server)
{
c->policy |= POLICY_XAUTH;
}

if (same_rightca)
c->spd.that.ca = c->spd.this.ca;
else if (same_leftca)
Expand Down Expand Up @@ -2425,6 +2430,8 @@ find_host_connection2(const char *func
, c->name));
if(NEVER_NEGOTIATE(c->policy)) continue;

if ((policy & POLICY_XAUTH) != (c->policy & POLICY_XAUTH)) continue;

if ((c->policy & policy) == policy)
break;
}
Expand Down
7 changes: 7 additions & 0 deletions programs/pluto/ikev1_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,13 @@ main_inI1_outR1(struct msg_digest *md)
{
pb_stream pre_sa_pbs = sa_pd->pbs;
lset_t policy = preparse_isakmp_sa_body(&pre_sa_pbs);
/*
* If there is XAUTH VID, copy it to policies.
*/
if (md->quirks.xauth_vid == TRUE)
{
policy |= POLICY_XAUTH;
}
/* See if a wildcarded connection can be found.
* We cannot pick the right connection, so we're making a guess.
* All Road Warrior connections are fair game:
Expand Down
1 change: 1 addition & 0 deletions programs/pluto/quirks.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ struct isakmp_quirks {
* xauth set, such as for SSH Sentinel. */
bool modecfg_pull_mode; /* if the client should request his IP */
unsigned short nat_traversal_vid; /**< which NAT-type vendor IDs we got */
bool xauth_vid; /**< if the client has XAUTH */
};

extern void copy_quirks(struct isakmp_quirks *dq
Expand Down
1 change: 1 addition & 0 deletions programs/pluto/state.c
Original file line number Diff line number Diff line change
Expand Up @@ -1739,6 +1739,7 @@ void copy_quirks(struct isakmp_quirks *dq
dq->xauth_ack_msgid |= sq->xauth_ack_msgid;
dq->modecfg_pull_mode |= sq->modecfg_pull_mode;
dq->nat_traversal_vid |= sq->nat_traversal_vid;
dq->xauth_vid |= sq->xauth_vid;
}

void set_state_ike_endpoints(struct state *st
Expand Down
1 change: 1 addition & 0 deletions programs/pluto/vendor.c
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,7 @@ static void handle_known_vendorid (struct msg_digest *md
break;

case VID_MISC_XAUTH:
md->quirks.xauth_vid = TRUE;
vid_usefull=1;
break;
#endif
Expand Down

0 comments on commit 0fc468c

Please sign in to comment.