summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2008-11-09 10:45:13 +0000
committered <ed@FreeBSD.org>2008-11-09 10:45:13 +0000
commit9d3703b8426a4dbb7eb7244d73de96428caf1532 (patch)
tree54928970669608762abe861909dd03f729e065cb
parent43e6672f4c8f60d63328221a5abc0cc13663d14f (diff)
downloadFreeBSD-src-9d3703b8426a4dbb7eb7244d73de96428caf1532.zip
FreeBSD-src-9d3703b8426a4dbb7eb7244d73de96428caf1532.tar.gz
Mark uname(), getdomainname() and setdomainname() with COMPAT_FREEBSD4.
Looking at our source code history, it seems the uname(), getdomainname() and setdomainname() system calls got deprecated somewhere after FreeBSD 1.1, but they have never been phased out properly. Because we don't have a COMPAT_FREEBSD1, just use COMPAT_FREEBSD4. Also fix the Linuxolator to build without the setdomainname() routine by just making it call userland_sysctl on kern.domainname. Also replace the setdomainname()'s implementation to use this approach, because we're duplicating code with sysctl_domainname(). I wasn't able to keep these three routines working in our COMPAT_FREEBSD32, because that would require yet another keyword for syscalls.master (COMPAT4+NOPROTO). Because this routine is probably unused already, this won't be a problem in practice. If it turns out to be a problem, we'll just restore this functionality. Reviewed by: rdivacky, kib
-rw-r--r--lib/libc/amd64/sys/Makefile.inc3
-rw-r--r--lib/libc/arm/sys/Makefile.inc3
-rw-r--r--lib/libc/i386/sys/Makefile.inc3
-rw-r--r--lib/libc/ia64/sys/Makefile.inc3
-rw-r--r--lib/libc/mips/sys/Makefile.inc5
-rw-r--r--lib/libc/powerpc/sys/Makefile.inc3
-rw-r--r--lib/libc/sparc64/sys/Makefile.inc3
-rw-r--r--sys/amd64/linux32/syscalls.master2
-rw-r--r--sys/compat/freebsd32/syscalls.master8
-rw-r--r--sys/compat/linux/linux_misc.c28
-rw-r--r--sys/i386/linux/syscalls.master2
-rw-r--r--sys/kern/kern_xxx.c63
-rw-r--r--sys/kern/syscalls.master6
-rw-r--r--sys/sys/priv.h1
14 files changed, 68 insertions, 65 deletions
diff --git a/lib/libc/amd64/sys/Makefile.inc b/lib/libc/amd64/sys/Makefile.inc
index 5115819..c7b17e0 100644
--- a/lib/libc/amd64/sys/Makefile.inc
+++ b/lib/libc/amd64/sys/Makefile.inc
@@ -7,8 +7,7 @@ MDASM= vfork.S brk.S cerror.S exect.S getcontext.S pipe.S ptrace.S \
reboot.S sbrk.S setlogin.S sigreturn.S
# Don't generate default code for these syscalls:
-NOASM= break.o exit.o getdomainname.o getlogin.o openbsd_poll.o \
- setdomainname.o sstk.o uname.o vfork.o yield.o
+NOASM= break.o exit.o getlogin.o openbsd_poll.o sstk.o vfork.o yield.o
PSEUDO= _getlogin.o _exit.o
.if !defined(WITHOUT_SYSCALL_COMPAT)
diff --git a/lib/libc/arm/sys/Makefile.inc b/lib/libc/arm/sys/Makefile.inc
index 6c38e7d..1a58eae 100644
--- a/lib/libc/arm/sys/Makefile.inc
+++ b/lib/libc/arm/sys/Makefile.inc
@@ -3,8 +3,7 @@
MDASM= Ovfork.S brk.S cerror.S pipe.S ptrace.S sbrk.S shmat.S sigreturn.S syscall.S
# Don't generate default code for these syscalls:
-NOASM= break.o exit.o getdomainname.o getlogin.o openbsd_poll.o \
- setdomainname.o sstk.o uname.o vfork.o yield.o
+NOASM= break.o exit.o getlogin.o openbsd_poll.o sstk.o vfork.o yield.o
PSEUDO= _exit.o _getlogin.o
.if !defined(WITHOUT_SYSCALL_COMPAT)
diff --git a/lib/libc/i386/sys/Makefile.inc b/lib/libc/i386/sys/Makefile.inc
index 8da2ab8..593956b 100644
--- a/lib/libc/i386/sys/Makefile.inc
+++ b/lib/libc/i386/sys/Makefile.inc
@@ -12,8 +12,7 @@ MDASM= Ovfork.S brk.S cerror.S exect.S getcontext.S pipe.S ptrace.S \
reboot.S sbrk.S setlogin.S sigreturn.S syscall.S
# Don't generate default code for these syscalls:
-NOASM= break.o exit.o getdomainname.o getlogin.o openbsd_poll.o \
- setdomainname.o sstk.o uname.o vfork.o yield.o
+NOASM= break.o exit.o getlogin.o openbsd_poll.o sstk.o vfork.o yield.o
PSEUDO= _getlogin.o _exit.o
.if !defined(WITHOUT_SYSCALL_COMPAT)
diff --git a/lib/libc/ia64/sys/Makefile.inc b/lib/libc/ia64/sys/Makefile.inc
index 0b577b9..3876d3a 100644
--- a/lib/libc/ia64/sys/Makefile.inc
+++ b/lib/libc/ia64/sys/Makefile.inc
@@ -4,8 +4,7 @@ MDASM+= Ovfork.S brk.S cerror.S exect.S fork.S getcontext.S pipe.S ptrace.S \
sbrk.S setlogin.S sigreturn.S swapcontext.S
# Don't generate default code for these syscalls:
-NOASM= break.o exit.o getdomainname.o getlogin.o openbsd_poll.o \
- setdomainname.o sstk.o uname.o vfork.o yield.o
+NOASM= break.o exit.o getlogin.o openbsd_poll.o sstk.o vfork.o yield.o
PSEUDO= _getlogin.o _exit.o
.if !defined(WITHOUT_SYSCALL_COMPAT)
diff --git a/lib/libc/mips/sys/Makefile.inc b/lib/libc/mips/sys/Makefile.inc
index ab1c28f..d2e7291 100644
--- a/lib/libc/mips/sys/Makefile.inc
+++ b/lib/libc/mips/sys/Makefile.inc
@@ -4,9 +4,8 @@ MDASM= Ovfork.S brk.S cerror.S exect.S \
fork.S pipe.S ptrace.S sbrk.S shmat.S syscall.S
# Don't generate default code for these syscalls:
-NOASM= break.o exit.o ftruncate.o getdomainname.o getlogin.o \
- lseek.o mmap.o openbsd_poll.o pread.o \
- pwrite.o setdomainname.o sstk.o truncate.o uname.o vfork.o yield.o
+NOASM= break.o exit.o ftruncate.o getlogin.o lseek.o mmap.o \
+ openbsd_poll.o pread.o pwrite.o sstk.o truncate.o vfork.o yield.o
PSEUDO= _exit.o _getlogin.o
.if !defined(WITHOUT_SYSCALL_COMPAT)
diff --git a/lib/libc/powerpc/sys/Makefile.inc b/lib/libc/powerpc/sys/Makefile.inc
index 6ca7938..5193cc2 100644
--- a/lib/libc/powerpc/sys/Makefile.inc
+++ b/lib/libc/powerpc/sys/Makefile.inc
@@ -3,8 +3,7 @@
MDASM+= brk.S cerror.S exect.S pipe.S ptrace.S sbrk.S setlogin.S
# Don't generate default code for these syscalls:
-NOASM= break.o exit.o getdomainname.o getlogin.o openbsd_poll.o \
- setdomainname.o sstk.o uname.o yield.o
+NOASM= break.o exit.o getlogin.o openbsd_poll.o sstk.o yield.o
PSEUDO= _getlogin.o _exit.o
.if !defined(WITHOUT_SYSCALL_COMPAT)
diff --git a/lib/libc/sparc64/sys/Makefile.inc b/lib/libc/sparc64/sys/Makefile.inc
index b738a57..43e4edb 100644
--- a/lib/libc/sparc64/sys/Makefile.inc
+++ b/lib/libc/sparc64/sys/Makefile.inc
@@ -18,8 +18,7 @@ CFLAGS+= -DSUN4V
MDASM+= brk.S cerror.S exect.S pipe.S ptrace.S sbrk.S setlogin.S sigaction.S
# Don't generate default code for these syscalls:
-NOASM= break.o exit.o getdomainname.o getlogin.o openbsd_poll.o \
- setdomainname.o sstk.o uname.o yield.o
+NOASM= break.o exit.o getlogin.o openbsd_poll.o sstk.o yield.o
PSEUDO= _getlogin.o _exit.o
.if !defined(WITHOUT_SYSCALL_COMPAT)
diff --git a/sys/amd64/linux32/syscalls.master b/sys/amd64/linux32/syscalls.master
index 1b0857d..fe0485e 100644
--- a/sys/amd64/linux32/syscalls.master
+++ b/sys/amd64/linux32/syscalls.master
@@ -216,7 +216,7 @@
; linux uses some strange calling convention here so we have to use the dummy arg
120 AUE_RFORK STD { int linux_clone(l_int flags, void *stack, \
void *parent_tidptr, int dummy, void * child_tidptr); }
-121 AUE_SYSCTL NOPROTO { int setdomainname(char *name, \
+121 AUE_SYSCTL STD { int linux_setdomainname(char *name, \
int len); }
122 AUE_NULL STD { int linux_newuname( \
struct l_new_utsname *buf); }
diff --git a/sys/compat/freebsd32/syscalls.master b/sys/compat/freebsd32/syscalls.master
index d4c1d2e..dc06557 100644
--- a/sys/compat/freebsd32/syscalls.master
+++ b/sys/compat/freebsd32/syscalls.master
@@ -295,11 +295,9 @@
160 AUE_LGETFH UNIMPL lgetfh
161 AUE_NFS_GETFH NOPROTO { int getfh(char *fname, \
struct fhandle *fhp); }
-162 AUE_SYSCTL NOPROTO { int getdomainname(char *domainname, \
- int len); }
-163 AUE_SYSCTL NOPROTO { int setdomainname(char *domainname, \
- int len); }
-164 AUE_NULL NOPROTO { int uname(struct utsname *name); }
+162 AUE_NULL OBSOL getdomainname
+163 AUE_NULL OBSOL setdomainname
+164 AUE_NULL OBSOL uname
165 AUE_SYSARCH NOPROTO { int sysarch(int op, char *parms); }
166 AUE_RTPRIO NOPROTO { int rtprio(int function, pid_t pid, \
struct rtprio *rtp); }
diff --git a/sys/compat/linux/linux_misc.c b/sys/compat/linux/linux_misc.c
index 1be8f92..93f4297 100644
--- a/sys/compat/linux/linux_misc.c
+++ b/sys/compat/linux/linux_misc.c
@@ -1682,6 +1682,7 @@ int
linux_sethostname(struct thread *td, struct linux_sethostname_args *args)
{
int name[2];
+ int error;
#ifdef DEBUG
if (ldebug(sethostname))
@@ -1690,8 +1691,31 @@ linux_sethostname(struct thread *td, struct linux_sethostname_args *args)
name[0] = CTL_KERN;
name[1] = KERN_HOSTNAME;
- return (userland_sysctl(td, name, 2, 0, 0, 0, args->hostname,
- args->len, 0, 0));
+ mtx_lock(&Giant);
+ error = userland_sysctl(td, name, 2, 0, 0, 0, args->hostname,
+ args->len, 0, 0);
+ mtx_unlock(&Giant);
+ return (error);
+}
+
+int
+linux_setdomainname(struct thread *td, struct linux_setdomainname_args *args)
+{
+ int name[2];
+ int error;
+
+#ifdef DEBUG
+ if (ldebug(setdomainname))
+ printf(ARGS(setdomainname, "*, %i"), args->len);
+#endif
+
+ name[0] = CTL_KERN;
+ name[1] = KERN_NISDOMAINNAME;
+ mtx_lock(&Giant);
+ error = userland_sysctl(td, name, 2, 0, 0, 0, args->name,
+ args->len, 0, 0);
+ mtx_unlock(&Giant);
+ return (error);
}
int
diff --git a/sys/i386/linux/syscalls.master b/sys/i386/linux/syscalls.master
index f13741c..8622595 100644
--- a/sys/i386/linux/syscalls.master
+++ b/sys/i386/linux/syscalls.master
@@ -217,7 +217,7 @@
; linux uses some strange calling convention here so we have to use the dummy arg
120 AUE_RFORK STD { int linux_clone(l_int flags, void *stack, \
void *parent_tidptr, int dummy, void * child_tidptr); }
-121 AUE_SYSCTL NOPROTO { int setdomainname(char *name, \
+121 AUE_SYSCTL STD { int linux_setdomainname(char *name, \
int len); }
122 AUE_NULL STD { int linux_newuname( \
struct l_new_utsname *buf); }
diff --git a/sys/kern/kern_xxx.c b/sys/kern/kern_xxx.c
index aba4bbc..b894ae6 100644
--- a/sys/kern/kern_xxx.c
+++ b/sys/kern/kern_xxx.c
@@ -148,8 +148,9 @@ oquota(td, uap)
}
#endif /* COMPAT_43 */
+#ifdef COMPAT_FREEBSD4
/*
- * This is the FreeBSD-1.1 compatable uname(2) interface. These days it is
+ * This is the FreeBSD-1.1 compatible uname(2) interface. These days it is
* done in libc as a wrapper around a bunch of sysctl's. This must maintain
* the old 1.1 binary ABI.
*/
@@ -163,9 +164,7 @@ struct uname_args {
#endif
/* ARGSUSED */
int
-uname(td, uap)
- struct thread *td;
- struct uname_args *uap;
+freebsd4_uname(struct thread *td, struct freebsd4_uname_args *uap)
{
int name[2], error;
size_t len;
@@ -242,22 +241,20 @@ struct getdomainname_args {
#endif
/* ARGSUSED */
int
-getdomainname(td, uap)
- struct thread *td;
- struct getdomainname_args *uap;
+freebsd4_getdomainname(struct thread *td,
+ struct freebsd4_getdomainname_args *uap)
{
- INIT_VPROCG(TD_TO_VPROCG(td));
- char tmpdomainname[MAXHOSTNAMELEN];
- int domainnamelen;
-
- mtx_lock(&hostname_mtx);
- bcopy(V_domainname, tmpdomainname, sizeof(tmpdomainname));
- mtx_unlock(&hostname_mtx);
+ int name[2];
+ int error;
+ size_t len = uap->len;
- domainnamelen = strlen(tmpdomainname) + 1;
- if ((u_int)uap->len > domainnamelen)
- uap->len = domainnamelen;
- return (copyout(tmpdomainname, uap->domainname, uap->len));
+ name[0] = CTL_KERN;
+ name[1] = KERN_NISDOMAINNAME;
+ mtx_lock(&Giant);
+ error = userland_sysctl(td, name, 2, uap->domainname, &len,
+ 1, 0, 0, 0, 0);
+ mtx_unlock(&Giant);
+ return(error);
}
#ifndef _SYS_SYSPROTO_H_
@@ -268,26 +265,18 @@ struct setdomainname_args {
#endif
/* ARGSUSED */
int
-setdomainname(td, uap)
- struct thread *td;
- struct setdomainname_args *uap;
+freebsd4_setdomainname(struct thread *td,
+ struct freebsd4_setdomainname_args *uap)
{
- INIT_VPROCG(TD_TO_VPROCG(td));
- char tmpdomainname[MAXHOSTNAMELEN];
- int error, domainnamelen;
+ int name[2];
+ int error;
- error = priv_check(td, PRIV_SETDOMAINNAME);
- if (error)
- return (error);
- if ((u_int)uap->len > sizeof(tmpdomainname) - 1)
- return (EINVAL);
- domainnamelen = uap->len;
- error = copyin(uap->domainname, tmpdomainname, uap->len);
- if (error == 0) {
- tmpdomainname[domainnamelen] = 0;
- mtx_lock(&hostname_mtx);
- bcopy(tmpdomainname, V_domainname, sizeof(V_domainname));
- mtx_unlock(&hostname_mtx);
- }
+ name[0] = CTL_KERN;
+ name[1] = KERN_NISDOMAINNAME;
+ mtx_lock(&Giant);
+ error = userland_sysctl(td, name, 2, 0, 0, 0, uap->domainname,
+ uap->len, 0, 0);
+ mtx_unlock(&Giant);
return (error);
}
+#endif /* COMPAT_FREEBSD4 */
diff --git a/sys/kern/syscalls.master b/sys/kern/syscalls.master
index 924d750..7bfe935 100644
--- a/sys/kern/syscalls.master
+++ b/sys/kern/syscalls.master
@@ -320,11 +320,11 @@
struct fhandle *fhp); }
161 AUE_NFS_GETFH STD { int getfh(char *fname, \
struct fhandle *fhp); }
-162 AUE_SYSCTL STD { int getdomainname(char *domainname, \
+162 AUE_SYSCTL COMPAT4 { int getdomainname(char *domainname, \
int len); }
-163 AUE_SYSCTL STD { int setdomainname(char *domainname, \
+163 AUE_SYSCTL COMPAT4 { int setdomainname(char *domainname, \
int len); }
-164 AUE_NULL STD { int uname(struct utsname *name); }
+164 AUE_NULL COMPAT4 { int uname(struct utsname *name); }
165 AUE_SYSARCH STD { int sysarch(int op, char *parms); }
166 AUE_RTPRIO STD { int rtprio(int function, pid_t pid, \
struct rtprio *rtp); }
diff --git a/sys/sys/priv.h b/sys/sys/priv.h
index c56c99d..27b6f02 100644
--- a/sys/sys/priv.h
+++ b/sys/sys/priv.h
@@ -84,7 +84,6 @@
#define PRIV_CLOCK_SETTIME 17 /* Can call clock_settime. */
#define PRIV_SETTIMEOFDAY 18 /* Can call settimeofday. */
#define PRIV_SETHOSTID 19 /* Can call sethostid. */
-#define PRIV_SETDOMAINNAME 20 /* Can call setdomainname. */
/*
* Audit subsystem privileges.
OpenPOWER on IntegriCloud