From owner-freebsd-rc@FreeBSD.ORG Fri Dec 23 06:09:25 2005 Return-Path: X-Original-To: freebsd-rc@freebsd.org Delivered-To: freebsd-rc@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5859716A41F for ; Fri, 23 Dec 2005 06:09:25 +0000 (GMT) (envelope-from darren.pilgrim@bitfreak.org) Received: from mail.bitfreak.org (mail.bitfreak.org [65.75.198.146]) by mx1.FreeBSD.org (Postfix) with ESMTP id D1C4843D55 for ; Fri, 23 Dec 2005 06:09:24 +0000 (GMT) (envelope-from darren.pilgrim@bitfreak.org) Received: from smiley (mail.bitfreak.org [65.75.198.146]) by mail.bitfreak.org (Postfix) with ESMTP id D94B019F3F for ; Thu, 22 Dec 2005 22:09:23 -0800 (PST) From: "Darren Pilgrim" To: Date: Thu, 22 Dec 2005 22:09:15 -0800 Message-ID: <000d01c60787$6a431b40$652a15ac@smiley> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_000E_01C60744.5C1FDB40" X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.6626 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 Importance: Normal Subject: /etc/rc.d/devfs modification to allow wildcard device names in /etc/devfs.conf X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion related to /etc/rc.d design and implementation." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Dec 2005 06:09:25 -0000 This is a multi-part message in MIME format. ------=_NextPart_000_000E_01C60744.5C1FDB40 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable I recently needed to change the default permissions of some of the "dial out" serial devices on a system for use with NUT (sysutils/nut port). = For the sake of efficiency, I wanted to use a wildcard expression only to = find out that /etc/rc.d/devfs doesn't grok sh-style filename globbing. So I modified the script. I wrapped each sub-procedure in the case structure with a for...done that expands the device string into a list for = iteration. The result is that I can put lines like the following in = /etc/devfs.conf: own cuad[1,2]* nut:nut perm cuad[1,2]* 0660 The non-wildcard equivalent would be: own cuad1 nut:nut own cuad1.init nut:nut own cuad1.lock nut:nut own cuad2 nut:nut own cuad2.init nut:nut own cuad2.lock nut:nut perm cuad1 0660 perm cuad1.init 0660 perm cuad1.lock 0660 perm cuad2 0660 perm cuad2.init 0660 perm cuad2.lock 0660 I wrote two versions of the modification, one takes the device = expression literally (the _literal.patch file), the other explicitly expands it = with ls (the _backticked_ls.patch file). Both appear to work fine, but IMO the latter seems a safer approach. The modifications and testing were done = on a current RELENG_6_0 box where /etc/rc.d/devfs is v1.10. The v1.11 in = -HEAD is effectively identical, so it should apply cleanly to that version as well. ------=_NextPart_000_000E_01C60744.5C1FDB40 Content-Type: application/octet-stream; name="etc_rc.d_devfs_literal.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="etc_rc.d_devfs_literal.patch" --- /usr/src/etc/rc.d/devfs Fri Oct 22 23:50:50 2004=0A= +++ /etc/rc.d/devfs Wed Dec 21 01:16:24 2005=0A= @@ -41,19 +41,25 @@=0A= {=0A= if [ -r /etc/devfs.conf ]; then=0A= cd /dev=0A= - while read action device parameter; do=0A= + while read action devicelist parameter; do=0A= case "${action}" in=0A= - l*) if [ -c ${device} -a ! -e ${parameter} ]; then=0A= - ln -fs ${device} ${parameter}=0A= - fi=0A= + l*) for device in ${devicelist}; do=0A= + if [ -c ${device} -a ! -e ${parameter} ]; then=0A= + ln -fs ${device} ${parameter}=0A= + fi=0A= + done=0A= ;;=0A= - o*) if [ -c ${device} ]; then=0A= - chown ${parameter} ${device}=0A= - fi=0A= + o*) for device in ${devicelist}; do=0A= + if [ -c ${device} ]; then=0A= + chown ${parameter} ${device}=0A= + fi=0A= + done=0A= ;;=0A= - p*) if [ -c ${device} ]; then=0A= - chmod ${parameter} ${device}=0A= - fi=0A= + p*) for device in ${devicelist}; do=0A= + if [ -c ${device} ]; then=0A= + chmod ${parameter} ${device}=0A= + fi=0A= + done=0A= ;;=0A= esac=0A= done < /etc/devfs.conf=0A= ------=_NextPart_000_000E_01C60744.5C1FDB40 Content-Type: application/octet-stream; name="etc_rc.d_devfs_backticked_ls.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="etc_rc.d_devfs_backticked_ls.patch" --- /usr/src/etc/rc.d/devfs Fri Oct 22 23:50:50 2004=0A= +++ /etc/rc.d/devfs Thu Dec 22 21:33:50 2005=0A= @@ -41,19 +41,25 @@=0A= {=0A= if [ -r /etc/devfs.conf ]; then=0A= cd /dev=0A= - while read action device parameter; do=0A= + while read action devicelist parameter; do=0A= case "${action}" in=0A= - l*) if [ -c ${device} -a ! -e ${parameter} ]; then=0A= - ln -fs ${device} ${parameter}=0A= - fi=0A= + l*) for device in `ls ${devicelist}`; do=0A= + if [ -c ${device} -a ! -e ${parameter} ]; then=0A= + ln -fs ${device} ${parameter}=0A= + fi=0A= + done=0A= ;;=0A= - o*) if [ -c ${device} ]; then=0A= - chown ${parameter} ${device}=0A= - fi=0A= + o*) for device in `ls ${devicelist}`; do=0A= + if [ -c ${device} ]; then=0A= + chown ${parameter} ${device}=0A= + fi=0A= + done=0A= ;;=0A= - p*) if [ -c ${device} ]; then=0A= - chmod ${parameter} ${device}=0A= - fi=0A= + p*) for device in `ls ${devicelist}`; do=0A= + if [ -c ${device} ]; then=0A= + chmod ${parameter} ${device}=0A= + fi=0A= + done=0A= ;;=0A= esac=0A= done < /etc/devfs.conf=0A= ------=_NextPart_000_000E_01C60744.5C1FDB40--