From owner-freebsd-hackers@FreeBSD.ORG Fri Oct 8 00:35:00 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 61278106564A; Fri, 8 Oct 2010 00:35:00 +0000 (UTC) (envelope-from yanegomi@gmail.com) Received: from mail-iw0-f182.google.com (mail-iw0-f182.google.com [209.85.214.182]) by mx1.freebsd.org (Postfix) with ESMTP id BF1228FC17; Fri, 8 Oct 2010 00:34:59 +0000 (UTC) Received: by iwn8 with SMTP id 8so626526iwn.13 for ; Thu, 07 Oct 2010 17:34:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:sender:received :in-reply-to:references:date:x-google-sender-auth:message-id:subject :from:to:cc:content-type:content-transfer-encoding; bh=7VZ8J/UHzYdZQMnkzkDhj2aD8ZFKNaN1HYb/QL4sAPs=; b=lDxqLkBaEhhu/93j35DNpdihjCdIpsZNOEaJC4YXtXaUuKAxC/q3sku0kBFA73c8Qq zv8rGtCdiuEj38MXkv+ogXx+AucDVMbAfo8d4dn2Ec2xhn6qJDXPYmX4gVx3l59OhFt6 ywxnnlmullnu108EFLhCnbLsuXPc3yAOFRvWA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; b=S5DWGQh64tpviE+YaXCjoy7pvMYG6JIu3fFKzb3OvGayj87IT5x47XsP4Ob0Ld0SMK KxTewuH9vfwggaVp3l4P0kf79JgrpBRCoNPK2y4ryM+k4ra34wTqfMXIWSxPWtKZKyCe +cJxKvY5Kc1HjPsxF/FbYmBho5Q9qpx4sfToc= MIME-Version: 1.0 Received: by 10.231.174.84 with SMTP id s20mr1685166ibz.94.1286498099275; Thu, 07 Oct 2010 17:34:59 -0700 (PDT) Sender: yanegomi@gmail.com Received: by 10.231.184.3 with HTTP; Thu, 7 Oct 2010 17:34:59 -0700 (PDT) In-Reply-To: References: <20101005235054.GA45827@freebsd.org> <20101006173522.GA92402@freebsd.org> <20101007184549.GA76070@a91-153-123-205.elisa-laajakaista.fi> Date: Thu, 7 Oct 2010 17:34:59 -0700 X-Google-Sender-Auth: qcSHl39_5aoJvFGS6Dj888Pa0KU Message-ID: From: Garrett Cooper To: Sergey Kandaurov Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: Jaakko Heinonen , freebsd-hackers@freebsd.org, Alexander Best Subject: Re: issue with unsetting 'arch' flag X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Oct 2010 00:35:00 -0000 On Thu, Oct 7, 2010 at 12:43 PM, Sergey Kandaurov wrote= : > On 7 October 2010 22:45, Jaakko Heinonen wrote: >> On 2010-10-06, Alexander Best wrote: >>> $ sudo rm -d /tmp/chflags.XXXXXX >>> $ tmpfile=3D`mktemp /tmp/chflags.XXXXXX` >>> $ sudo chflags arch $tmpfile >>> $ chflags noarch $tmpfile >>> >>> is what's causing the problem. the last chflags call should fail, but i= t >>> doesn't. >> >> Here is a patch for UFS: >> >> %%% >> Index: sys/ufs/ufs/ufs_vnops.c >> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >> --- sys/ufs/ufs/ufs_vnops.c =A0 =A0 (revision 213507) >> +++ sys/ufs/ufs/ufs_vnops.c =A0 =A0 (working copy) >> @@ -556,6 +556,9 @@ ufs_setattr(ap) >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0& (SF_NOUNLINK | = SF_IMMUTABLE | SF_APPEND) || >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(vap->va_flags & = UF_SETTABLE) !=3D vap->va_flags) >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0return (E= PERM); >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if ((ip->i_flags & SF_SETT= ABLE) !=3D >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (vap->va_flags & S= F_SETTABLE)) >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 return (EP= ERM); >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0ip->i_flags &=3D SF_SETTA= BLE; >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0ip->i_flags |=3D (vap->va= _flags & UF_SETTABLE); >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0DIP_SET(ip, i_flags, ip->= i_flags); >> %%% >> >> The patch has a potential to break something if someone assumes that >> non-super-user can modify UF_SETTABLE flags with the SF_SETTABLE part >> set to zero. However with a quick peek this seems to be what NetBSD >> does. > > Just for reference: > this comes from NetBSD PR kern/3491 and fixed before 1.3R. > I just checked arch test, and it works as expected with the change. > All chflags tests from fstest suite passed as well. This only potentially fixes UFS though -- not ext*, msdosfs, ntfs, ZFS, etc, which that it can still fail the requirement in the chflags(2) manpage that states: [EOPNOTSUPP] The underlying file system does not support file flags. Or should it be a different requirement, i.e. EINVAL for bogus values? Thanks, -Garrett