From owner-freebsd-isp@FreeBSD.ORG Sun Feb 29 08:51:00 2004 Return-Path: Delivered-To: freebsd-isp@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D960216A4D4 for ; Sun, 29 Feb 2004 08:51:00 -0800 (PST) Received: from mail11.txucom.net (mail11.txucom.net [207.70.175.42]) by mx1.FreeBSD.org (Postfix) with SMTP id A32E443D1F for ; Sun, 29 Feb 2004 08:51:00 -0800 (PST) (envelope-from bob@buckhorn.net) Received: (qmail 4455 invoked from network); 29 Feb 2004 16:50:59 -0000 Received: from lfkn-adsl-dhcp-net1-197.txucom.net (HELO tardis.buckhorn.net) ([207.70.145.197]) (envelope-sender ) by mail11.txucom.net (qmail-ldap-1.03) with SMTP for ; 29 Feb 2004 16:50:59 -0000 Received: from buckhorn.net (localhost.buckhorn.net [127.0.0.1]) by tardis.buckhorn.net (Postfix) with ESMTP id B51E31B8F85; Sun, 29 Feb 2004 10:51:31 -0600 (CST) Message-ID: <40421893.6000303@buckhorn.net> Date: Sun, 29 Feb 2004 10:51:31 -0600 From: Bob Martin User-Agent: Mozilla/5.0 (X11; U; Linux i386; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 X-Accept-Language: en-us, en MIME-Version: 1.0 References: <20040228191105.M42305@scottah.com> <4040F1A8.1070108@buckhorn.net> <20040228211439.M89441@scottah.com> <404189B9.6040801@buckhorn.net> <20040229160038.GA36107@psconsult.nl> In-Reply-To: <20040229160038.GA36107@psconsult.nl> Content-Type: multipart/mixed; boundary="------------040604000603070307090603" cc: freebsd-isp@freebsd.org cc: "Scott St. John" Subject: Re: Final conversion questions X-BeenThere: freebsd-isp@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Internet Services Providers List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Feb 2004 16:51:01 -0000 This is a multi-part message in MIME format. --------------040604000603070307090603 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Scott, Paul is absolutely right. The perl script is missing a line: next unless $home =~ /home/; See new attachment. Sorry about that. I grabbed the wrong script. Bob Paul Schenkeveld wrote: > Hi Scott, Bob, All, > > PLEASE be VERY CAREFULL with the perl script. The first account > in /etc/passwd is root with / as its home directory, so everything > will be chown'd to root. Later they ge chown'd to operator, bin, tty, > kmem and so on because all these accounts have / as their home dir. > > Files for normal users will eventually be corrected once their accounts > are encountered later in the password file but ownership/group > membership of all system files and directories will be lost forever this > way. > > You could use this perl script on a copy op /etc/passwd with all > system accounts removed, leaving just the normal users and you'll > be fine. > > Or - without perl - the following lines can be cut-n-pasted directly > into a /bin/sh compatible shell to do what you want to do, assuming > all normal users have home directories living under /home. > > awk -F: '$6 ~ "^/home/" {print $6, $3, $4}' /etc/passwd | > while read dir uid gid > do > chown -R $uid:$gid $dir > done > > Regards, > > Paul Schenkeveld, Consultant > PSconsult ICT Services BV > > On Sun, Feb 29, 2004 at 12:42:01AM -0600, Bob Martin wrote: > >>Scott, >>After you move the directories, use the attached perl script (run as >>root). Use the -r option to scp, and you'll get all files, including . >>files. >> >>Bob Martin >> >> >> >>Scott St. John wrote: >> >>>Bob- >>> >>>I do not have a NFS connection between the two boxes, I am using scp to >>>transfer files between the Linux and the new FreebSD boxes. I used John >>>The Ripper to merge my passwd and shadow files and then used some awk >>>scripts from the OpenBSD site to format, then create my new passwd file >>>for BSD. I am almost sure the UID/GID will NOT be the same since BSD >>>starts at a different # than Linux where my first UID is 1000. >>> >>>If you have it, it sounds like the perl script would be the better trick >>>since it would check the passwd file instead of assuming the UID/GID were >>>the same. >>> >>>Thanks! >>> >>>-Scott >>> >>>On Sat, 28 Feb 2004 13:53:12 -0600, Bob Martin wrote >>> >>> >>>>Scott, >>>>I haven't followed this thread closely enough, but from what you're >>>>saying, it sounds like you have a NFS connection between the 2 boxen. >>>>That being the case, and since the UID/GID's are the same on both boxen >>>>(IIRC you moved the Linux accounts to the BSD box), the following >>>>command will get all of the files, and maintain the permissions: >>>> >>>>cp -pRP />>> >>>>If the UID/GID's have changed, then this command will fix them for you: >>>>(Note, this assumes you use bash as your shell) >>>>cd /home >>>>for a in `ls -1 /home`;do chown -R $a:users $a;done >>>> >>>>That command does assume that you have a 1 to 1 relationship between >>>>home directories and usernames. If not, let me know and I'll find my >>>>little perl script that reads /etc/passwd and sets the permissions. >>> >>> >>>_______________________________________________ >>>freebsd-isp@freebsd.org mailing list >>>http://lists.freebsd.org/mailman/listinfo/freebsd-isp >>>To unsubscribe, send any mail to "freebsd-isp-unsubscribe@freebsd.org" > > >>#!/usr/bin/perl >>$Home = "/home"; >> >>open(PASSWD, '/etc/passwd') or die("Can't open password: $!\n"); >>while () { >> chomp; >> ($login, $passwd, $uid, $gid, $gcos, $home, $shell) = split(/:/); >> system("chown -R $uid:$gid $home") or die("Error: $!\n"); >> print "$login, $uid, $gid, $home\n"; >>} > > >>_______________________________________________ >>freebsd-isp@freebsd.org mailing list >>http://lists.freebsd.org/mailman/listinfo/freebsd-isp >>To unsubscribe, send any mail to "freebsd-isp-unsubscribe@freebsd.org" > > > _______________________________________________ > freebsd-isp@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-isp > To unsubscribe, send any mail to "freebsd-isp-unsubscribe@freebsd.org" --------------040604000603070307090603 Content-Type: text/plain; name="HomePerms.pl" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="HomePerms.pl" #!/usr/bin/perl $Home = "/home"; open(PASSWD, '/etc/passwd') or die("Can't open password: $!\n"); while () { chomp; ($login, $passwd, $uid, $gid, $gcos, $home, $shell) = split(/:/); next unless $home =~ /home/; print "Processing: $home\n"; system("chown -R $uid:$gid $home"); } --------------040604000603070307090603--