PERFORCE change 188693 for review
Edward Tomasz Napierala
trasz at FreeBSD.org
Thu Feb 10 20:25:01 UTC 2011
http://p4web.freebsd.org/@@188693?ac=10
Change 188693 by trasz at trasz_victim on 2011/02/10 20:24:38
Use jail names instead of jail IDs.
Affected files ...
.. //depot/projects/soc2009/trasz_limits/sys/kern/kern_rctl.c#29 edit
Differences ...
==== //depot/projects/soc2009/trasz_limits/sys/kern/kern_rctl.c#29 (text+ko) ====
@@ -807,20 +807,14 @@
rule->rr_subject.hr_loginclass = NULL;
rule->rr_subject.rs_prison = NULL;
} else {
-
- /*
- * Loginclasses don't have any numerical ID's.
- */
- if (rule->rr_subject_type != RCTL_SUBJECT_TYPE_LOGINCLASS) {
- error = str2id(subject_idstr, &id);
- if (error != 0)
- goto out;
- }
switch (rule->rr_subject_type) {
case RCTL_SUBJECT_TYPE_UNDEFINED:
error = EINVAL;
goto out;
case RCTL_SUBJECT_TYPE_PROCESS:
+ error = str2id(subject_idstr, &id);
+ if (error != 0)
+ goto out;
sx_assert(&allproc_lock, SA_LOCKED);
rule->rr_subject.rs_proc = pfind(id);
if (rule->rr_subject.rs_proc == NULL) {
@@ -830,16 +824,30 @@
PROC_UNLOCK(rule->rr_subject.rs_proc);
break;
case RCTL_SUBJECT_TYPE_USER:
+ error = str2id(subject_idstr, &id);
+ if (error != 0)
+ goto out;
rule->rr_subject.rs_uip = uifind(id);
break;
case RCTL_SUBJECT_TYPE_LOGINCLASS:
- rule->rr_subject.hr_loginclass = loginclass_find(subject_idstr);
+ rule->rr_subject.hr_loginclass =
+ loginclass_find(subject_idstr);
break;
case RCTL_SUBJECT_TYPE_JAIL:
- rule->rr_subject.rs_prison = prison_find(id);
+ rule->rr_subject.rs_prison =
+ prison_find_name(&prison0, subject_idstr);
if (rule->rr_subject.rs_prison == NULL) {
- error = ESRCH;
- goto out;
+ /*
+ * No jail with that name; try with the JID.
+ */
+ error = str2id(subject_idstr, &id);
+ if (error != 0)
+ goto out;
+ rule->rr_subject.rs_prison = prison_find(id);
+ if (rule->rr_subject.rs_prison == NULL) {
+ error = ESRCH;
+ goto out;
+ }
}
/* prison_find() returns with mutex held. */
mtx_unlock(&rule->rr_subject.rs_prison->pr_mtx);
@@ -1104,7 +1112,7 @@
if (rule->rr_subject.rs_prison == NULL)
sbuf_printf(sb, ":");
else
- sbuf_printf(sb, "%d:", rule->rr_subject.rs_prison->pr_id);
+ sbuf_printf(sb, "%s:", rule->rr_subject.rs_prison->pr_name);
break;
default:
panic("rctl_rule_to_sbuf: unknown subject type %d",
More information about the p4-projects
mailing list