From owner-p4-projects@FreeBSD.ORG Mon Feb 8 18:26:37 2010 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 5294410656A3; Mon, 8 Feb 2010 18:26:37 +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 16FF1106568B for ; Mon, 8 Feb 2010 18:26:37 +0000 (UTC) (envelope-from trasz@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 055378FC19 for ; Mon, 8 Feb 2010 18:26:37 +0000 (UTC) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id o18IQa8x059373 for ; Mon, 8 Feb 2010 18:26:36 GMT (envelope-from trasz@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id o18IQaES059371 for perforce@freebsd.org; Mon, 8 Feb 2010 18:26:36 GMT (envelope-from trasz@freebsd.org) Date: Mon, 8 Feb 2010 18:26:36 GMT Message-Id: <201002081826.o18IQaES059371@repoman.freebsd.org> X-Authentication-Warning: repoman.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 174474 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: Mon, 08 Feb 2010 18:26:37 -0000 http://p4web.freebsd.org/chv.cgi?CH=174474 Change 174474 by trasz@trasz_victim on 2010/02/08 18:26:15 Prevent foot shooting by using HRL-enabled world without HRL-enabled kernel. Affected files ... .. //depot/projects/soc2009/trasz_limits/lib/libutil/login_class.c#5 edit Differences ... ==== //depot/projects/soc2009/trasz_limits/lib/libutil/login_class.c#5 (text+ko) ==== @@ -425,6 +425,7 @@ quad_t p; mode_t mymask; login_cap_t *llc = NULL; + sig_t prevsig; struct rtprio rtp; int error; @@ -512,13 +513,21 @@ return (-1); } - if (lc != NULL && lc->lc_class != NULL) { + if (lc != NULL && lc->lc_class != NULL && (flags & LOGIN_SETLOGINCLASS)) { /* Inform the kernel about current login class */ - if ((flags & LOGIN_SETLOGINCLASS) && - setloginclass(lc->lc_class) != 0) { + /* + * XXX: This is a workaround to fail gracefully in case the kernel + * does not support setloginclass(2). + */ + prevsig = signal(SIGSYS, SIG_IGN); + error = setloginclass(lc->lc_class); + signal(SIGSYS, prevsig); + if (error != 0) { syslog(LOG_ERR, "setloginclass(%s): %m", lc->lc_class); +#ifdef notyet login_close(llc); return (-1); +#endif } }