1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-03 09:00:21 +00:00

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
This commit is contained in:
Ed Schouten 2008-11-09 10:45:13 +00:00
parent 37f1755cab
commit a1b5a8955e
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=184789
14 changed files with 68 additions and 65 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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); }

View File

@ -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); }

View File

@ -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

View File

@ -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); }

View File

@ -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;
int name[2];
int error;
size_t len = uap->len;
mtx_lock(&hostname_mtx);
bcopy(V_domainname, tmpdomainname, sizeof(tmpdomainname));
mtx_unlock(&hostname_mtx);
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 */

View File

@ -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); }

View File

@ -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.