PERFORCE change 100115 for review
Alex Lyashkov
als at FreeBSD.org
Tue Jun 27 05:15:04 UTC 2006
http://perforce.freebsd.org/chv.cgi?CH=100115
Change 100115 by als at als_head on 2006/06/27 05:14:20
whitespace fixes
Affected files ...
.. //depot/projects/jail2/sys/kern/kern_jail.c#3 edit
Differences ...
==== //depot/projects/jail2/sys/kern/kern_jail.c#3 (text+ko) ====
@@ -52,12 +52,12 @@
struct prisonlist allprison;
struct mtx allprison_mtx;
int lastprid = 0;
-int prisoncount = 1; /* root jail */
+int prisoncount = 1; /* root jail */
struct prison jail_0 = {
- .pr_id = 0,
+ .pr_id = 0,
.pr_flags = J_START_FL | J_SYSVIPC_ALLOW_FL,
- .pr_linux = NULL,
+ .pr_linux = NULL,
.pr_securelevel = -1,
};
@@ -78,7 +78,7 @@
LIST_INIT(&allprison);
/* init jail0 */
mtx_init(&jail_0.pr_mtx, "jail mutex", NULL, MTX_DEF);
- LIST_INSERT_HEAD(&allprison, &jail_0, pr_list);
+ LIST_INSERT_HEAD(&allprison, &jail_0, pr_list);
JAIL_DISKS_INIT(&jail_0);
JAIL_TASKS_INIT(&jail_0);
JAIL_IPC_INIT(&jail_0);
@@ -134,7 +134,7 @@
JAIL_TASKS_INIT(pr);
JAIL_IPC_INIT(pr);
JAIL_LIMITS_INIT(pr);
-
+
/* Determine next pr_id and add prison to allprison list. */
mtx_lock(&allprison_mtx);
tryprid = lastprid + 1;
@@ -152,7 +152,7 @@
goto next;
}
}
-
+
pr->pr_id = jaa.jid = lastprid = tryprid;
LIST_INSERT_HEAD(&allprison, pr, pr_list);
prisoncount++;
@@ -161,7 +161,7 @@
error = jail_attach(td, &jaa);
if (error)
goto e_dropprref;
-
+
prison_free(pr);
td->td_retval[0] = jaa.jid;
return (0);
@@ -191,16 +191,19 @@
return (error);
switch( JAIL2_CLASS(j.cmd) ) {
- case J_COMMON:
+ case J_COMMON:
error = jail2_common(td, &j);
break;
- case J_NETWORK:
+ case J_NETWORK:
error = jail2_network(td, &j);
break;
- case J_RESOURCE:
+ case J_RESOURCE:
error = jail2_resource(td, &j);
break;
- default:
+ case J_DISK:
+ error = jail2_disk(td, &j);
+ break;
+ default:
printf("wrong jail2 cmd class %d\n", JAIL2_CLASS(j.cmd) );
error = EOPNOTSUPP;
break;
@@ -215,7 +218,7 @@
uint32_t ver;
int error;
struct prison *jail = td->td_ucred->cr_prison;
-
+
if (jail != &jail_0)
return (EPERM);
@@ -224,7 +227,7 @@
return (error);
jprint("jail cmd v. %d\n", ver);
switch( ver ) {
- case 0:
+ case 0:
case 1:
error = jail_1(td, uap);
break;
@@ -238,7 +241,7 @@
return (error);
}
-int
+int
jail_migrate(struct thread *td, struct prison *pr)
{
int error = 0;
@@ -253,7 +256,7 @@
vn_lock(JAIL_VROOT(pr), LK_EXCLUSIVE | LK_RETRY, td);
if ((error = change_dir(JAIL_VROOT(pr), td)) != 0)
goto e_unlock;
-
+
#ifdef MAC
if ((error = mac_check_vnode_chroot(td->td_ucred, JAIL_VROOT(pr))))
goto e_unlock;
@@ -262,10 +265,10 @@
if((error = change_root(JAIL_VROOT(pr), td)) != 0)
goto e_unlock1;
VFS_UNLOCK_GIANT(vfslocked);
-
+
if((error = kern_chdir(td, "/", UIO_SYSSPACE)) != 0)
return (error);
-
+
p = td->td_proc;
newcred = crget();
PROC_LOCK(p);
@@ -277,9 +280,9 @@
prison_hold(pr);
PROC_UNLOCK(p);
crfree(oldcred);
-
+
return (0);
-
+
e_unlock:
VOP_UNLOCK(JAIL_VROOT(pr), 0, td);
e_unlock1:
@@ -298,7 +301,7 @@
{
struct prison *pr;
int error;
-
+
/*
* XXX: Note that there is a slight race here if two threads
* in the same privileged process attempt to attach to two
@@ -315,7 +318,7 @@
if (pr == NULL) {
return (ESRCH);
}
-
+
error = jail_migrate(td, pr);
prison_free(pr);
@@ -336,7 +339,7 @@
jprint("Already have prisons");
goto found;
}
-
+
LIST_INSERT_HEAD(&allprison, pr, pr_list);
prisoncount++;
mtx_unlock(&allprison_mtx);
@@ -381,7 +384,7 @@
{
jprint("destroy prison %d\n",pr->pr_id);
- mtx_lock(&allprison_mtx);
+ mtx_lock(&allprison_mtx);
LIST_REMOVE(pr, pr_list);
prisoncount--;
TASK_INIT(&pr->pr_task, 0, prison_complete, pr);
@@ -409,12 +412,12 @@
{
uint32_t tmp;
- if (!jailed(cred))
- return (0);
+ if (!jailed(cred))
+ return (0);
tmp = *ip;
jprint("prison_ip %x - %x - %x - %x - ",
- tmp, htonl(INADDR_ANY), htonl(INADDR_LOOPBACK),
+ tmp, htonl(INADDR_ANY), htonl(INADDR_LOOPBACK),
cred->cr_prison->pr_network.pr_ip);
if (tmp == htonl(INADDR_ANY)) {
jprint("any\n");
@@ -444,13 +447,13 @@
tmp = *ip;
jprint("prison_remote_ip %x - %x - ",
tmp, htonl(INADDR_LOOPBACK));
-
+
if (tmp == htonl(INADDR_LOOPBACK)) {
*ip = cred->cr_prison->pr_network.pr_ip;
jprint("loopback\n");
return;
}
- jprint("other\n");
+ jprint("other\n");
return;
}
@@ -603,7 +606,7 @@
free(sxp, M_TEMP);
goto retry;
}
-
+
LIST_FOREACH(pr, &allprison, pr_list) {
mtx_lock(&pr->pr_mtx);
xp->pr_version = XPRISON_VERSION;
More information about the p4-projects
mailing list