Deleted Added
full compact
kern_xxx.c (180039) kern_xxx.c (180291)
1/*-
2 * Copyright (c) 1982, 1986, 1989, 1993
3 * The Regents of the University of California. 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

--- 16 unchanged lines hidden (view full) ---

25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * @(#)kern_xxx.c 8.2 (Berkeley) 11/14/93
30 */
31
32#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1982, 1986, 1989, 1993
3 * The Regents of the University of California. 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

--- 16 unchanged lines hidden (view full) ---

25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * @(#)kern_xxx.c 8.2 (Berkeley) 11/14/93
30 */
31
32#include <sys/cdefs.h>
33__FBSDID("$FreeBSD: head/sys/kern/kern_xxx.c 180039 2008-06-26 22:45:04Z julian $");
33__FBSDID("$FreeBSD: head/sys/kern/kern_xxx.c 180291 2008-07-05 13:10:10Z rwatson $");
34
35#include "opt_compat.h"
36
37#include <sys/param.h>
38#include <sys/systm.h>
39#include <sys/sysproto.h>
40#include <sys/kernel.h>
41#include <sys/priv.h>

--- 198 unchanged lines hidden (view full) ---

240};
241#endif
242/* ARGSUSED */
243int
244getdomainname(td, uap)
245 struct thread *td;
246 struct getdomainname_args *uap;
247{
34
35#include "opt_compat.h"
36
37#include <sys/param.h>
38#include <sys/systm.h>
39#include <sys/sysproto.h>
40#include <sys/kernel.h>
41#include <sys/priv.h>

--- 198 unchanged lines hidden (view full) ---

240};
241#endif
242/* ARGSUSED */
243int
244getdomainname(td, uap)
245 struct thread *td;
246 struct getdomainname_args *uap;
247{
248 char tmpdomainname[MAXHOSTNAMELEN];
248 int domainnamelen;
249 int domainnamelen;
249 int error;
250
250
251 mtx_lock(&Giant);
252 domainnamelen = strlen(domainname) + 1;
251 mtx_lock(&hostname_mtx);
252 bcopy(domainname, tmpdomainname, sizeof(tmpdomainname));
253 mtx_unlock(&hostname_mtx);
254
255 domainnamelen = strlen(tmpdomainname) + 1;
253 if ((u_int)uap->len > domainnamelen)
254 uap->len = domainnamelen;
256 if ((u_int)uap->len > domainnamelen)
257 uap->len = domainnamelen;
255 error = copyout(domainname, uap->domainname, uap->len);
256 mtx_unlock(&Giant);
257 return (error);
258 return (copyout(tmpdomainname, uap->domainname, uap->len));
258}
259
260#ifndef _SYS_SYSPROTO_H_
261struct setdomainname_args {
262 char *domainname;
263 int len;
264};
265#endif
266/* ARGSUSED */
267int
268setdomainname(td, uap)
269 struct thread *td;
270 struct setdomainname_args *uap;
271{
259}
260
261#ifndef _SYS_SYSPROTO_H_
262struct setdomainname_args {
263 char *domainname;
264 int len;
265};
266#endif
267/* ARGSUSED */
268int
269setdomainname(td, uap)
270 struct thread *td;
271 struct setdomainname_args *uap;
272{
273 char tmpdomainname[MAXHOSTNAMELEN];
272 int error, domainnamelen;
273
274 error = priv_check(td, PRIV_SETDOMAINNAME);
275 if (error)
276 return (error);
274 int error, domainnamelen;
275
276 error = priv_check(td, PRIV_SETDOMAINNAME);
277 if (error)
278 return (error);
277 mtx_lock(&Giant);
278 if ((u_int)uap->len > sizeof (domainname) - 1) {
279 error = EINVAL;
280 goto done2;
281 }
279 if ((u_int)uap->len > sizeof(tmpdomainname) - 1)
280 return (EINVAL);
282 domainnamelen = uap->len;
281 domainnamelen = uap->len;
283 error = copyin(uap->domainname, domainname, uap->len);
284 domainname[domainnamelen] = 0;
285done2:
286 mtx_unlock(&Giant);
282 error = copyin(uap->domainname, tmpdomainname, uap->len);
283 if (error == 0) {
284 tmpdomainname[domainnamelen] = 0;
285 mtx_lock(&hostname_mtx);
286 bcopy(tmpdomainname, domainname, sizeof(domainname));
287 mtx_unlock(&hostname_mtx);
288 }
287 return (error);
288}
289 return (error);
290}