1/*- 2 * Copyright (c) 2011 James Gritton 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> |
28__FBSDID("$FreeBSD: head/usr.sbin/jail/config.c 239621 2012-08-23 19:39:23Z jamie $"); |
29 30#include <sys/types.h> 31#include <sys/errno.h> 32#include <sys/socket.h> 33#include <sys/sysctl.h> 34 35#include <arpa/inet.h> 36#include <netinet/in.h> --- 555 unchanged lines hidden (view full) --- 592 prefix = strtol(cs + 1, &ep, 10); 593 if (*ep == '.' 594 ? inet_pton(AF_INET, cs + 1, &addr4) != 1 595 : *ep || prefix < 0 || prefix > 32) { 596 jail_warnx(j, 597 "ip4.addr: bad netmask \"%s\"", cs); 598 error = -1; 599 } |
600 *cs = '\0'; |
601 s->len = cs - s->s; 602 } 603 } 604 } 605#endif 606#ifdef INET6 607 if (j->intparams[KP_IP6_ADDR] != NULL) { 608 TAILQ_FOREACH(s, &j->intparams[KP_IP6_ADDR]->val, tq) { --- 7 unchanged lines hidden (view full) --- 616 if ((cs = strchr(s->s, '/'))) { 617 prefix = strtol(cs + 1, &ep, 10); 618 if (*ep || prefix < 0 || prefix > 128) { 619 jail_warnx(j, 620 "ip6.addr: bad prefixlen \"%s\"", 621 cs); 622 error = -1; 623 } |
624 *cs = '\0'; |
625 s->len = cs - s->s; 626 } 627 } 628 } 629#endif 630#endif 631 632 /* --- 77 unchanged lines hidden (view full) --- 710 */ 711 vallen = 0; 712 TAILQ_FOREACH(s, &p->val, tq) 713 vallen += s->len + 1; 714 value = alloca(vallen); 715 cs = value; 716 TAILQ_FOREACH_SAFE(s, &p->val, tq, ts) { 717 memcpy(cs, s->s, s->len); |
718 cs += s->len + 1; 719 cs[-1] = ','; |
720 } |
721 value[vallen - 1] = '\0'; |
722 } 723 if (jailparam_import(jp, value) < 0) { 724 error = -1; 725 jail_warnx(j, "%s", jail_errmsg); 726 } 727 jp++; 728 } 729 if (error) { --- 103 unchanged lines hidden --- |