Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 2 May 2002 09:56:17 -0400 (EDT)
From:      "Michael C. Adler" <mad1@tapil.com>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   bin/37665: restore does not recover uid, gid, etc. of symbolic link
Message-ID:  <200205021356.g42DuH215977@tapil.com>

next in thread | raw e-mail | index | archive | help

>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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200205021356.g42DuH215977>