mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-20 11:11:24 +00:00
Add counterparts to getcredhostname:
getcreddomainname, getcredhostuuid, getcredhostid Suggested by: rmacklem Approved by: bz
This commit is contained in:
parent
28f805cece
commit
7455b100af
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=194090
@ -716,7 +716,6 @@ linux_newuname(struct thread *td, struct linux_newuname_args *args)
|
||||
struct l_new_utsname utsname;
|
||||
char osname[LINUX_MAX_UTSNAME];
|
||||
char osrelease[LINUX_MAX_UTSNAME];
|
||||
struct prison *pr;
|
||||
char *p;
|
||||
|
||||
#ifdef DEBUG
|
||||
@ -730,6 +729,7 @@ linux_newuname(struct thread *td, struct linux_newuname_args *args)
|
||||
bzero(&utsname, sizeof(utsname));
|
||||
strlcpy(utsname.sysname, osname, LINUX_MAX_UTSNAME);
|
||||
getcredhostname(td->td_ucred, utsname.nodename, LINUX_MAX_UTSNAME);
|
||||
getcreddomainname(td->td_ucred, utsname.domainname, LINUX_MAX_UTSNAME);
|
||||
strlcpy(utsname.release, osrelease, LINUX_MAX_UTSNAME);
|
||||
strlcpy(utsname.version, version, LINUX_MAX_UTSNAME);
|
||||
for (p = utsname.version; *p != '\0'; ++p)
|
||||
@ -739,11 +739,6 @@ linux_newuname(struct thread *td, struct linux_newuname_args *args)
|
||||
}
|
||||
strlcpy(utsname.machine, linux_platform, LINUX_MAX_UTSNAME);
|
||||
|
||||
pr = td->td_ucred->cr_prison;
|
||||
mtx_lock(&pr->pr_mtx);
|
||||
strlcpy(utsname.domainname, pr->pr_domain, LINUX_MAX_UTSNAME);
|
||||
mtx_unlock(&pr->pr_mtx);
|
||||
|
||||
return (copyout(&utsname, args->buf, sizeof(utsname)));
|
||||
}
|
||||
|
||||
|
@ -411,10 +411,10 @@ svr4_sys_systeminfo(td, uap)
|
||||
struct thread *td;
|
||||
struct svr4_sys_systeminfo_args *uap;
|
||||
{
|
||||
struct prison *pr;
|
||||
char *str = NULL;
|
||||
int error = 0;
|
||||
register_t *retval = td->td_retval;
|
||||
u_long hostid;
|
||||
size_t len = 0;
|
||||
char buf[MAXHOSTNAMELEN];
|
||||
u_int rlen = uap->len;
|
||||
@ -458,10 +458,8 @@ svr4_sys_systeminfo(td, uap)
|
||||
break;
|
||||
|
||||
case SVR4_SI_HW_SERIAL:
|
||||
pr = td->td_ucred->cr_prison;
|
||||
mtx_lock(&pr->pr_mtx);
|
||||
snprintf(buf, sizeof(buf), "%lu", pr->pr_hostid);
|
||||
mtx_unlock(&pr->pr_mtx);
|
||||
getcredhostid(td->td_ucred, &hostid);
|
||||
snprintf(buf, sizeof(buf), "%lu", hostid);
|
||||
str = buf;
|
||||
break;
|
||||
|
||||
@ -470,10 +468,7 @@ svr4_sys_systeminfo(td, uap)
|
||||
break;
|
||||
|
||||
case SVR4_SI_SRPC_DOMAIN:
|
||||
pr = td->td_ucred->cr_prison;
|
||||
mtx_lock(&pr->pr_mtx);
|
||||
strlcpy(buf, pr->pr_domain, sizeof(buf));
|
||||
mtx_unlock(&pr->pr_mtx);
|
||||
getcreddomainname(td->td_ucred, buf, sizeof(buf));
|
||||
str = buf;
|
||||
break;
|
||||
|
||||
|
@ -3207,19 +3207,50 @@ jailed(struct ucred *cred)
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the correct hostname for the passed credential.
|
||||
* Return the correct hostname (domainname, et al) for the passed credential.
|
||||
*/
|
||||
void
|
||||
getcredhostname(struct ucred *cred, char *buf, size_t size)
|
||||
{
|
||||
struct prison *pr;
|
||||
|
||||
/*
|
||||
* A NULL credential can be used to shortcut to the physical
|
||||
* system's hostname.
|
||||
*/
|
||||
pr = (cred != NULL) ? cred->cr_prison : &prison0;
|
||||
mtx_lock(&pr->pr_mtx);
|
||||
strlcpy(buf, pr->pr_host, size);
|
||||
mtx_unlock(&pr->pr_mtx);
|
||||
}
|
||||
|
||||
void
|
||||
getcreddomainname(struct ucred *cred, char *buf, size_t size)
|
||||
{
|
||||
|
||||
mtx_lock(&cred->cr_prison->pr_mtx);
|
||||
strlcpy(buf, cred->cr_prison->pr_domain, size);
|
||||
mtx_unlock(&cred->cr_prison->pr_mtx);
|
||||
}
|
||||
|
||||
void
|
||||
getcredhostuuid(struct ucred *cred, char *buf, size_t size)
|
||||
{
|
||||
|
||||
mtx_lock(&cred->cr_prison->pr_mtx);
|
||||
strlcpy(buf, cred->cr_prison->pr_uuid, size);
|
||||
mtx_unlock(&cred->cr_prison->pr_mtx);
|
||||
}
|
||||
|
||||
void
|
||||
getcredhostid(struct ucred *cred, unsigned long *hostid)
|
||||
{
|
||||
|
||||
mtx_lock(&cred->cr_prison->pr_mtx);
|
||||
*hostid = cred->cr_prison->pr_hostid;
|
||||
mtx_unlock(&cred->cr_prison->pr_mtx);
|
||||
}
|
||||
|
||||
/*
|
||||
* Determine whether the subject represented by cred can "see"
|
||||
* status of a mount point.
|
||||
|
@ -304,7 +304,10 @@ struct mount;
|
||||
struct sockaddr;
|
||||
struct statfs;
|
||||
int jailed(struct ucred *cred);
|
||||
void getcredhostname(struct ucred *cred, char *, size_t);
|
||||
void getcredhostname(struct ucred *, char *, size_t);
|
||||
void getcreddomainname(struct ucred *, char *, size_t);
|
||||
void getcredhostuuid(struct ucred *, char *, size_t);
|
||||
void getcredhostid(struct ucred *, unsigned long *);
|
||||
int prison_allow(struct ucred *, unsigned);
|
||||
int prison_check(struct ucred *cred1, struct ucred *cred2);
|
||||
int prison_canseemount(struct ucred *cred, struct mount *mp);
|
||||
|
Loading…
Reference in New Issue
Block a user