From owner-p4-projects@FreeBSD.ORG Thu Feb 10 20:25:01 2011 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 578F81065672; Thu, 10 Feb 2011 20:25:01 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1A2FD106564A for ; Thu, 10 Feb 2011 20:25:01 +0000 (UTC) (envelope-from trasz@freebsd.org) Received: from skunkworks.freebsd.org (skunkworks.freebsd.org [IPv6:2001:4f8:fff6::2d]) by mx1.freebsd.org (Postfix) with ESMTP id DD5E28FC13 for ; Thu, 10 Feb 2011 20:25:00 +0000 (UTC) Received: from skunkworks.freebsd.org (localhost [127.0.0.1]) by skunkworks.freebsd.org (8.14.4/8.14.4) with ESMTP id p1AKP0hG041712 for ; Thu, 10 Feb 2011 20:25:00 GMT (envelope-from trasz@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.4/8.14.4/Submit) id p1AKP073041709 for perforce@freebsd.org; Thu, 10 Feb 2011 20:25:00 GMT (envelope-from trasz@freebsd.org) Date: Thu, 10 Feb 2011 20:25:00 GMT Message-Id: <201102102025.p1AKP073041709@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to trasz@freebsd.org using -f From: Edward Tomasz Napierala To: Perforce Change Reviews Precedence: bulk Cc: Subject: PERFORCE change 188693 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Feb 2011 20:25:01 -0000 http://p4web.freebsd.org/@@188693?ac=10 Change 188693 by trasz@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",