ibcs2_socksys.c (164033) | ibcs2_socksys.c (180291) |
---|---|
1/*- 2 * Copyright (c) 1994, 1995 Scott Bartram 3 * Copyright (c) 1994 Arne H Juul 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 10 unchanged lines hidden (view full) --- 19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 */ 25 26#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1994, 1995 Scott Bartram 3 * Copyright (c) 1994 Arne H Juul 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 10 unchanged lines hidden (view full) --- 19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 */ 25 26#include <sys/cdefs.h> |
27__FBSDID("$FreeBSD: head/sys/i386/ibcs2/ibcs2_socksys.c 164033 2006-11-06 13:42:10Z rwatson $"); | 27__FBSDID("$FreeBSD: head/sys/i386/ibcs2/ibcs2_socksys.c 180291 2008-07-05 13:10:10Z rwatson $"); |
28 29#include <sys/param.h> 30#include <sys/systm.h> 31#include <sys/sysproto.h> 32#include <sys/jail.h> 33#include <sys/kernel.h> | 28 29#include <sys/param.h> 30#include <sys/systm.h> 31#include <sys/sysproto.h> 32#include <sys/jail.h> 33#include <sys/kernel.h> |
34#include <sys/lock.h> 35#include <sys/mutex.h> |
|
34#include <sys/sysctl.h> 35 36#include <i386/ibcs2/ibcs2_socksys.h> 37#include <i386/ibcs2/ibcs2_util.h> 38 39/* Local structures */ 40struct getipdomainname_args { 41 char *ipdomainname; --- 128 unchanged lines hidden (view full) --- 170ibcs2_setipdomainname(td, uap) 171 struct thread *td; 172 struct setipdomainname_args *uap; 173{ 174 char hname[MAXHOSTNAMELEN], *ptr; 175 int error, sctl[2], hlen; 176 177 /* W/out a hostname a domain-name is nonsense */ | 36#include <sys/sysctl.h> 37 38#include <i386/ibcs2/ibcs2_socksys.h> 39#include <i386/ibcs2/ibcs2_util.h> 40 41/* Local structures */ 42struct getipdomainname_args { 43 char *ipdomainname; --- 128 unchanged lines hidden (view full) --- 172ibcs2_setipdomainname(td, uap) 173 struct thread *td; 174 struct setipdomainname_args *uap; 175{ 176 char hname[MAXHOSTNAMELEN], *ptr; 177 int error, sctl[2], hlen; 178 179 /* W/out a hostname a domain-name is nonsense */ |
178 if ( strlen(hostname) == 0 ) | 180 mtx_lock(&hostname_mtx); 181 if ( strlen(hostname) == 0 ) { 182 mtx_unlock(&hostname_mtx); |
179 return EINVAL; | 183 return EINVAL; |
184 } |
|
180 181 /* Get the host's unqualified name (strip off the domain) */ 182 snprintf(hname, sizeof(hname), "%s", hostname); | 185 186 /* Get the host's unqualified name (strip off the domain) */ 187 snprintf(hname, sizeof(hname), "%s", hostname); |
188 mtx_unlock(&hostname_mtx); |
|
183 ptr = index(hname, '.'); 184 if ( ptr != NULL ) { 185 ptr++; 186 *ptr = '\0'; 187 } else { 188 if (strlcat(hname, ".", sizeof(hname)) >= sizeof(hname)) 189 return (EINVAL); 190 } --- 18 unchanged lines hidden --- | 189 ptr = index(hname, '.'); 190 if ( ptr != NULL ) { 191 ptr++; 192 *ptr = '\0'; 193 } else { 194 if (strlcat(hname, ".", sizeof(hname)) >= sizeof(hname)) 195 return (EINVAL); 196 } --- 18 unchanged lines hidden --- |