From owner-svn-src-all@FreeBSD.ORG Tue Nov 20 15:59:44 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 3DB208C9 for ; Tue, 20 Nov 2012 15:59:44 +0000 (UTC) (envelope-from lists@eitanadler.com) Received: from mail-la0-f54.google.com (mail-la0-f54.google.com [209.85.215.54]) by mx1.freebsd.org (Postfix) with ESMTP id 9FCB18FC16 for ; Tue, 20 Nov 2012 15:59:43 +0000 (UTC) Received: by mail-la0-f54.google.com with SMTP id j13so5823986lah.13 for ; Tue, 20 Nov 2012 07:59:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eitanadler.com; s=0xdeadbeef; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type; bh=kOVQHHPJB4ibOUySrNGj+yZtw6nR9vkbEKqoqFJCF+k=; b=b1Q4ZORyhJbtoFKxUb9GpM/J3O2H5VyXh7zJBFUbBrZSASZxalhsJSAW0MNlnFQNRA wDEVLHVuE8BMvkhl14aApKNJi72MevIy8d5JuHZPuh5f7GOw/kniCaJqrAnSr22aha/K qaRqzRo/RItKufyR5Fp/rCYg0f4zjz/emA/Ws= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type :x-gm-message-state; bh=kOVQHHPJB4ibOUySrNGj+yZtw6nR9vkbEKqoqFJCF+k=; b=l7o9XffAwP6JoTuIyg+r2W8Dxjq7N+3moIAHw+cEkR2Lz/+AcZLjCkgR8goJL8hxEO +1mf3Uoct7c8q0u60L0btZAHn8Q7nBbnGm/wGmD5UHyIEEJRKUiAu0HnT85YE7vC6boU uMp+0+UVSMtJSrqONm18PrqB4o0lQM2A4MvtsccPzATDAtU2L88yDGdHSeVlkp5QsfMj YzlRm4Kp/prZSf0xzwCFzv/944O94BoNU4LCsNnXBbN6JnlbXxKFcl2oS+tgqMzQqNYg jfesc62vfRBidecfUhGAiDrdrYHqUBIXWNns5UOdSs33WK3Y2m+NIl64P36Oi7QM6XKx sOCA== Received: by 10.112.13.140 with SMTP id h12mr6672160lbc.12.1353427182462; Tue, 20 Nov 2012 07:59:42 -0800 (PST) MIME-Version: 1.0 Sender: lists@eitanadler.com Received: by 10.112.25.166 with HTTP; Tue, 20 Nov 2012 07:59:12 -0800 (PST) In-Reply-To: <20121120133837.GK71195@ithaqua.etoilebsd.net> References: <201211200722.qAK7M7Im057617@svn.freebsd.org> <20121120122226.GA1828@a91-153-116-96.elisa-laajakaista.fi> <20121120133837.GK71195@ithaqua.etoilebsd.net> From: Eitan Adler Date: Tue, 20 Nov 2012 10:59:12 -0500 X-Google-Sender-Auth: f6YbkvaUPaHrDypDFFpqGlkypPM Message-ID: Subject: Re: svn commit: r243328 - head/lib/libutil To: Baptiste Daroussin Content-Type: text/plain; charset=UTF-8 X-Gm-Message-State: ALoCoQm3xQiRTTHRFV9DysF7xJzHj23jlC/md2F+JYoHbUFgt+mlEC+DLDOKXI4jEFPgecifJ1GK Cc: svn-src-head@freebsd.org, Jaakko Heinonen , svn-src-all@freebsd.org, src-committers@freebsd.org X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Nov 2012 15:59:44 -0000 On 20 November 2012 08:38, Baptiste Daroussin wrote: > On Tue, Nov 20, 2012 at 02:22:26PM +0200, Jaakko Heinonen wrote: >> >> Hi! >> >> On 2012-11-20, Baptiste Daroussin wrote: >> > change mode the group file to 0644 after a successfull rename(2) >> > >> > int >> > gr_mkdb(void) >> > { >> > - return (rename(tempname, group_file)); >> > + int ret; >> > + >> > + ret = rename(tempname, group_file); >> > + >> > + if (ret == 0) >> > + chmod(group_file, 0644); >> > + >> > + return (ret); >> > } >> >> Rename+chmod is not an atomic operation. There is a window when the file >> has wrong permissions. Also, you don't check the return value of >> chmod(). Maybe chmod first and then rename? >> >> -- >> Jaakko > > Does this looks better to you? > http://people.freebsd.org/~bapt/gr_util.diff This makes more sense. -- Eitan Adler Source, Ports, Doc committer Bugmeister, Ports Security teams