asmlinkage long compat_sys_sethostname(char __user *name, u32 len)
{
	/* sign extend len */
	return sys_sethostname(name, (int)len);
}
Example #2
0
int hpux_utssys(char __user *ubuf, int n, int type)
{
	int len;
	int error;
	switch( type ) {
	case 0:
		
		return hpux_uname((struct hpux_utsname __user *)ubuf);
		break ;
	case 1:
		
		return -EFAULT ;
		break ;
	case 2:
		
		return hpux_ustat(new_decode_dev(n),
				  (struct hpux_ustat __user *)ubuf);
		break;
	case 3:
		if (!capable(CAP_SYS_ADMIN))
			return -EPERM;
		
		if ( n <= 0 )
			return -EINVAL ;
		
		len = (n <= __NEW_UTS_LEN) ? n : __NEW_UTS_LEN ;
		return sys_sethostname(ubuf, len);
		break ;
	case 4:
		if (!capable(CAP_SYS_ADMIN))
			return -EPERM;
		
		if ( n <= 0 )
			return -EINVAL ;
		
		len = (n <= __NEW_UTS_LEN) ? n : __NEW_UTS_LEN ;
		return sys_sethostname(ubuf, len);
		break ;
	case 5:
		
		if ( n <= 0 )
			return -EINVAL ;
		return sys_gethostname(ubuf, n);
		break ;
	case 6:
		if (!capable(CAP_SYS_ADMIN))
			return -EPERM;
		
		if ( n <= 0 )
			return -EINVAL ;
		
		len = (n <= __NEW_UTS_LEN) ? n : __NEW_UTS_LEN ;
		
		
		down_write(&uts_sem);
		error = -EFAULT;
		if (!copy_from_user(utsname()->sysname, ubuf, len)) {
			utsname()->sysname[len] = 0;
			error = 0;
		}
		up_write(&uts_sem);
		return error;
		break ;
	case 7:
		if (!capable(CAP_SYS_ADMIN))
			return -EPERM;
		
		if ( n <= 0 )
			return -EINVAL ;
		
		len = (n <= __NEW_UTS_LEN) ? n : __NEW_UTS_LEN ;
		
		
		down_write(&uts_sem);
		error = -EFAULT;
		if (!copy_from_user(utsname()->release, ubuf, len)) {
			utsname()->release[len] = 0;
			error = 0;
		}
		up_write(&uts_sem);
		return error;
		break ;
	default:
		return -EFAULT ;
	}
}
Example #3
0
/*  Note: HP-UX just uses the old suser() function to check perms
 *  in this system call.  We'll use capable(CAP_SYS_ADMIN).
 */
int hpux_utssys(char *ubuf, int n, int type)
{
	int len;
	int error;
	switch( type ) {
	case 0:
		/*  uname():  */
		return( hpux_uname( (struct hpux_utsname *)ubuf ) );
		break ;
	case 1:
		/*  Obsolete (used to be umask().)  */
		return -EFAULT ;
		break ;
	case 2:
		/*  ustat():  */
		return( hpux_ustat(new_decode_dev(n), (struct hpux_ustat *)ubuf) );
		break ;
	case 3:
		/*  setuname():
		 *
		 *  On linux (unlike HP-UX), utsname.nodename
		 *  is the same as the hostname.
		 *
		 *  sys_sethostname() is defined in linux/kernel/sys.c.
		 */
		if (!capable(CAP_SYS_ADMIN))
			return -EPERM;
		/*  Unlike Linux, HP-UX returns an error if n==0:  */
		if ( n <= 0 )
			return -EINVAL ;
		/*  Unlike Linux, HP-UX truncates it if n is too big:  */
		len = (n <= __NEW_UTS_LEN) ? n : __NEW_UTS_LEN ;
		return( sys_sethostname(ubuf, len) );
		break ;
	case 4:
		/*  sethostname():
		 *
		 *  sys_sethostname() is defined in linux/kernel/sys.c.
		 */
		if (!capable(CAP_SYS_ADMIN))
			return -EPERM;
		/*  Unlike Linux, HP-UX returns an error if n==0:  */
		if ( n <= 0 )
			return -EINVAL ;
		/*  Unlike Linux, HP-UX truncates it if n is too big:  */
		len = (n <= __NEW_UTS_LEN) ? n : __NEW_UTS_LEN ;
		return( sys_sethostname(ubuf, len) );
		break ;
	case 5:
		/*  gethostname():
		 *
		 *  sys_gethostname() is defined in linux/kernel/sys.c.
		 */
		/*  Unlike Linux, HP-UX returns an error if n==0:  */
		if ( n <= 0 )
			return -EINVAL ;
		return( sys_gethostname(ubuf, n) );
		break ;
	case 6:
		/*  Supposedly called from setuname() in libc.
		 *  TODO: When and why is this called?
		 *        Is it ever even called?
		 *
		 *  This code should look a lot like sys_sethostname(),
		 *  defined in linux/kernel/sys.c.  If that gets updated,
		 *  update this code similarly.
		 */
		if (!capable(CAP_SYS_ADMIN))
			return -EPERM;
		/*  Unlike Linux, HP-UX returns an error if n==0:  */
		if ( n <= 0 )
			return -EINVAL ;
		/*  Unlike Linux, HP-UX truncates it if n is too big:  */
		len = (n <= __NEW_UTS_LEN) ? n : __NEW_UTS_LEN ;
		/**/
		/*  TODO:  print a warning about using this?  */
		down_write(&uts_sem);
		error = -EFAULT;
		if (!copy_from_user(system_utsname.sysname, ubuf, len)) {
			system_utsname.sysname[len] = 0;
			error = 0;
		}
		up_write(&uts_sem);
		return error;
		break ;
	case 7:
		/*  Sets utsname.release, if you're allowed.
		 *  Undocumented.  Used by swinstall to change the
		 *  OS version, during OS updates.  Yuck!!!
		 *
		 *  This code should look a lot like sys_sethostname()
		 *  in linux/kernel/sys.c.  If that gets updated, update
		 *  this code similarly.
		 */
		if (!capable(CAP_SYS_ADMIN))
			return -EPERM;
		/*  Unlike Linux, HP-UX returns an error if n==0:  */
		if ( n <= 0 )
			return -EINVAL ;
		/*  Unlike Linux, HP-UX truncates it if n is too big:  */
		len = (n <= __NEW_UTS_LEN) ? n : __NEW_UTS_LEN ;
		/**/
		/*  TODO:  print a warning about this?  */
		down_write(&uts_sem);
		error = -EFAULT;
		if (!copy_from_user(system_utsname.release, ubuf, len)) {
			system_utsname.release[len] = 0;
			error = 0;
		}
		up_write(&uts_sem);
		return error;
		break ;
	default:
		/*  This system call returns -EFAULT if given an unknown type.
	 	 *  Why not -EINVAL?  I don't know, it's just not what they did.
	 	 */
		return -EFAULT ;
	}
}
Example #4
0
asmlinkage long compat_sys_sethostname(char __user *name, u32 len)
{
	
	return sys_sethostname(name, (int)len);
}