From owner-freebsd-bugs Thu May 2 7: 0:22 2002 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id D25A037B421 for ; Thu, 2 May 2002 07:00:03 -0700 (PDT) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g42E03N29643; Thu, 2 May 2002 07:00:03 -0700 (PDT) (envelope-from gnats) Received: from tapil.com (dsl092-068-186.bos1.dsl.speakeasy.net [66.92.68.186]) by hub.freebsd.org (Postfix) with ESMTP id BE72637B419 for ; Thu, 2 May 2002 06:56:18 -0700 (PDT) Received: (from madler@localhost) by tapil.com (8.11.6/8.11.6) id g42DuH215977; Thu, 2 May 2002 09:56:17 -0400 (EDT) (envelope-from madler) Message-Id: <200205021356.g42DuH215977@tapil.com> Date: Thu, 2 May 2002 09:56:17 -0400 (EDT) From: "Michael C. Adler" Reply-To: "Michael C. Adler" To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: bin/37665: restore does not recover uid, gid, etc. of symbolic link Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >Number: 37665 >Category: bin >Synopsis: restore does not recover uid, gid, etc. of symbolic link >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Thu May 02 07:00:03 PDT 2002 >Closed-Date: >Last-Modified: >Originator: Michael C. Adler >Release: FreeBSD 4.5-RELEASE-p3 i386 >Organization: >Environment: System: FreeBSD grumpy.tapil.com 4.5-RELEASE-p3 FreeBSD 4.5-RELEASE-p3 #3: Sat Apr 27 16:08:30 EDT 2002 madler@grumpy.tapil.com:/usr/obj/usr/src/sys/GRUMPY i386 >Description: /sbin/restore does not restore the uid, gid, mode or times associated with symbolic links. A nearly correct fix has been floating around on Usenet for about a year, first by Yoshihiko Sarumaru and modified by Matthew Jacob, though neither was quite correct. >How-To-Repeat: dump a file system with a symbolic link. restore the link with restore running as someone other than the owner/group of the original link. Note that the restored link is owned by the owner of the restore process. >Fix: Patch /usr/src/sbin/restore/tape.c: --- tape.c.~1~ Wed Aug 1 05:00:28 2001 +++ tape.c Thu May 2 09:28:19 2002 @@ -559,6 +559,14 @@ return (genliteraldir(name, curfile.ino)); case IFLNK: + { + uid_t uid; + gid_t gid; + int ret; + + uid = curfile.dip->di_uid; + gid = curfile.dip->di_gid; + lnkbuf[0] = '\0'; pathlen = 0; getfile(xtrlnkfile, xtrlnkskip); @@ -567,7 +575,17 @@ "%s: zero length symbolic link (ignored)\n", name); return (GOOD); } - return (linkit(lnkbuf, name, SYMLINK)); + ret = linkit(lnkbuf, name, SYMLINK); + if (ret == GOOD) { + if (lchown(name, uid, gid)) + perror(name); + if (lchmod(name, mode)) + perror(name); + lutimes(name, timep); + } + /* symbolic link doesn't have any flags */ + return (ret); + } case IFIFO: vprintf(stdout, "extract fifo %s\n", name); >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message