From owner-freebsd-questions@FreeBSD.ORG Sun Oct 28 17:12:16 2007 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D480C16A417 for ; Sun, 28 Oct 2007 17:12:16 +0000 (UTC) (envelope-from oscartheduck@gmail.com) Received: from rv-out-0910.google.com (rv-out-0910.google.com [209.85.198.189]) by mx1.freebsd.org (Postfix) with ESMTP id A391213C4C4 for ; Sun, 28 Oct 2007 17:12:16 +0000 (UTC) (envelope-from oscartheduck@gmail.com) Received: by rv-out-0910.google.com with SMTP id l15so1161028rvb for ; Sun, 28 Oct 2007 10:12:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; bh=iIGc/XGxyoeHxOJSyYtqD3VHtravlXy3tWx7gcS6IJA=; b=spYZpSqHyqxDlFYuU+6+7EK40SeYsdgi0PGOt2SJ7CXFQgZBwcP/aHomheb037XBgJJ9srbTzKOtqaROJJICFkb7QW9U/fNoDi+7IJ5tmBDsmuOloZqTlcOJpbSGJkUrmCBYIK2Up49e/bltmWP9Z07tfEC0qdE3vBzZEQSRFno= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=j1U1Vy7bjHmdbVJo3RUsaPx0VfQtU0bqtezTWj/Jra4XDXktS29/pJtnKMWJjUE02CwedTgYfkiVADG64L+etafQRrBxQTTB82oFyAh46FGgFQ3D14YauYR3lVEHXE95wYUbRoFhMsXB+bFQNHicZRtH2AHWaZ6EuWlOUanI4yw= Received: by 10.142.83.4 with SMTP id g4mr1147312wfb.1193591536106; Sun, 28 Oct 2007 10:12:16 -0700 (PDT) Received: by 10.142.232.11 with HTTP; Sun, 28 Oct 2007 10:12:16 -0700 (PDT) Message-ID: Date: Sun, 28 Oct 2007 11:12:16 -0600 From: James To: "Jonathan Horne" In-Reply-To: <200710280924.31680.freebsd@dfwlp.com> MIME-Version: 1.0 References: <200710280854.53041.freebsd@dfwlp.com> <200710280924.31680.freebsd@dfwlp.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: freebsd-questions@freebsd.org Subject: Re: best way to distribute an item to everyones homedir? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 Oct 2007 17:12:16 -0000 On 10/28/07, Jonathan Horne wrote: > > On Sunday 28 October 2007 09:21:55 you wrote: > > maildir=/path/to/your/custom/maildir > > > > for dir in `ls /usr/home` > > do > > cp -r $maildir /usr/home/$dir/ > > done > > thanks james. quick question... will that put the proper owner and chmod > of > the target homedirs, on the new directories? > > thanks, > -- > Jonathan Horne > http://dfwlpiki.dfwlp.org > freebsd@dfwlp.com > ...what an interesting question. Let me check. Okay, a couple of things. First, for the copy command, make sure that you don't include a trailing slash for the source directory, otherwise it copies the contents of the directory and not the directory itself. So: pclmills# cp -r COPYME ~james/ NOT: pclmills# cp -r COPYME/ ~james/ This will set the group permission correctly, not the user, and the permissions are in accordance with umask. So the result of the above copy is: [james@pclmills ~]$ ls -l | grep COPYME drwxr-xr-x 2 root james 512 Oct 28 11:03 COPYME And the file inside the directory gets: [james@pclmills ~]$ cd COPYME/ [james@pclmills ~/COPYME]$ ls -l total 0 -rw-r--r-- 1 root james 0 Oct 28 11:03 file As you've got configuration scripts, if your umask is the same as mine then this should be fine. It's reasonably trivial, of course, to add a line to the copy script to use chmod and chown to change the permissions as you want them to be changed. the $dir variable in the above for loop contains the name of the home directory. If this is the same name as the UID/GID (which it is by default) then even though it looks weird something like: chown -R $dir:$dir /usr/home/$dir/$maildir will get you close. Of course, remember this warning from man chown: -R Change the user ID and/or the group ID of the specified directory trees (recursively, including their contents) and files. Beware of unintentionally matching the ``..'' hard link to the parent directory when using wildcards like ``.*''. How I do something like this is to build the script one line at a time using test directories that I set up. Do that first and everything should be tickety boo. I put the mailing list's address back in the cc line of this email; use "reply all", not reply, to hit the whole mailing list and have people who are *far* better scripters than me chime in with helpful hints ;) James