From nnd@nnd.itfs.nsk.su  Wed Nov 18 21:36:32 1998
Received: from nnd.itfs.nsk.su (nnd.itfs.nsk.su [193.124.36.42])
          by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id VAA12141
          for <FreeBSD-gnats-submit@freebsd.org>; Wed, 18 Nov 1998 21:36:18 -0800 (PST)
          (envelope-from nnd@nnd.itfs.nsk.su)
Received: (from nnd@localhost)
	by nnd.itfs.nsk.su (8.9.1/8.9.1) id LAA17771;
	Thu, 19 Nov 1998 11:35:33 +0600 (NS)
	(envelope-from nnd)
Message-Id: <199811190535.LAA17771@nnd.itfs.nsk.su>
Date: Thu, 19 Nov 1998 11:35:33 +0600 (NS)
From: nnd@nnd.itfs.nsk.su
Reply-To: nnd@nnd.itfs.nsk.su
To: FreeBSD-gnats-submit@freebsd.org
Subject: 'pw' command additional feature request
X-Send-Pr-Version: 3.2

>Number:         8756
>Category:       bin
>Synopsis:       'pw' command additional feature request
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    davidn
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Wed Nov 18 21:40:01 PST 1998
>Closed-Date:    Fri Jul 14 10:02:37 EST 2000
>Last-Modified:  Fri Jul 14 10:03:49 EST 2000
>Originator:     Nickolay N. Dudorov
>Release:        FreeBSD 3.0-BETA i386
>Organization:
STE Infoteka
>Environment:

	Any FreeBSD system with 'pw' command

>Description:

	When I as an ISP add new users with 'pw' command
I initialize their home-dir through some skeleton directory
containing f.e. Maildir and dot.qmail for their mailbox.
It is very useful to set 'sunlnk' flag for Maildir components
(new, cur, tmp) and 'schg' flag for .qmail file.
But this flags are not sets when 'pw' copies skeleton to user
home directory.

>How-To-Repeat:

	Create some skeleton and set some flags for it's files
and after that do 'pw user add' with this skeleton specified.
All flags will be lost in new user home directory.

>Fix:
	
	The next patch change the 'pw' in such a way that it
preserve all the flags for files and directories inside 
skeleton directory while copiing them to user home directory.

	I also change one call to 'chown' to 'fchown' call,
which can be some kind of optimization :-)

===================================================================

diff -rubN pw/cpdir.c pw.new/cpdir.c
--- pw/cpdir.c	Fri Oct 10 13:23:30 1997
+++ pw.new/cpdir.c	Thu Nov 19 11:10:10 1998
@@ -98,8 +98,9 @@
 								while ((b = read(infd, copybuf, 4096)) > 0)
 									write(outfd, copybuf, b);
 								close(infd);
+								fchown(outfd, uid, gid);
+								fchflags(outfd, st.st_flags);
 								close(outfd);
-								chown(dst, uid, gid);
 							}
 						}
 					}

>Release-Note:
>Audit-Trail:

From: "Nickolay N. Dudorov" <nnd@itfs.nsk.su>
To: FreeBSD-gnats-submit@FreeBSD.ORG, freebsd-bugs@FreeBSD.ORG
Cc:  Subject: Re: bin/8756: 'pw' command additional feature request
Date: Thu, 19 Nov 1998 11:50:17 +0600

 	I am very-very-very sorry, but there was incorrect
 patch included in my PR. Here is the correct one:
 
 
 diff -rubN pw/cpdir.c pw.new/cpdir.c
 --- pw/cpdir.c	Fri Oct 10 13:23:30 1997
 +++ pw.new/cpdir.c	Thu Nov 19 11:44:48 1998
 @@ -80,6 +80,7 @@
  						if (S_ISDIR(st.st_mode)) {	/* Recurse for this */
  							if (strcmp(e->d_name, ".") != 0 && strcmp(e->d_name, "..") != 0)
  								copymkdir(dst, src, (st.st_mode & 0777), uid, gid);
 +								chflags(dst, st.st_flags);
  							/*
  							 * Note: don't propogate 'special' attributes
  							 */
 @@ -98,8 +99,9 @@
  								while ((b = read(infd, copybuf, 4096)) > 0)
  									write(outfd, copybuf, b);
  								close(infd);
 +								fchown(outfd, uid, gid);
 +								fchflags(outfd, st.st_flags);
  								close(outfd);
 -								chown(dst, uid, gid);
  							}
  						}
  					}
Responsible-Changed-From-To: freebsd-bugs->davidn 
Responsible-Changed-By: nbm 
Responsible-Changed-When: Thu Jul 13 06:59:35 PDT 2000 
Responsible-Changed-Why:  
davidn might want to look at this 

http://www.freebsd.org/cgi/query-pr.cgi?pr=8756 
State-Changed-From-To: open->closed 
State-Changed-By: davidn 
State-Changed-When: Fri Jul 14 10:02:37 EST 2000 
State-Changed-Why:  
Feature incorporated into -current. 
Thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=8756 
>Unformatted:
