X-Git-Url: https://git.wh0rd.org/?a=blobdiff_plain;ds=sidebyside;f=restore%2Ftape.c;h=395c99e9a81fb7a806a2acdca977653277c0146a;hb=f0ab1ab5331f9ed387ade32d96b24285b0cd5282;hp=fa4a9618f3a8323ef7f5ea3ea0e18ab46c6dea57;hpb=2e555f4100de1ce92bb01d09fd4b635fb0e133f4;p=dump.git diff --git a/restore/tape.c b/restore/tape.c index fa4a961..395c99e 100644 --- a/restore/tape.c +++ b/restore/tape.c @@ -42,7 +42,7 @@ #ifndef lint static const char rcsid[] = - "$Id: tape.c,v 1.94 2009/12/03 12:46:30 stelian Exp $"; + "$Id: tape.c,v 1.98 2010/06/11 09:57:31 stelian Exp $"; #endif /* not lint */ #include @@ -61,6 +61,8 @@ static const char rcsid[] = #include #include #include +#include +#include #ifdef __linux__ #include @@ -843,9 +845,52 @@ extractfile(struct entry *ep, int doremove) return (FAIL); case IFSOCK: - Vprintf(stdout, "skipped socket %s\n", name); + { + uid_t luid = curfile.dip->di_uid; + gid_t lgid = curfile.dip->di_gid; + + Vprintf(stdout, "extract socket %s\n", name); skipfile(); + if (Nflag) + return (GOOD); + if (! (spcl.c_flags & DR_METAONLY)) { + int sk; + struct sockaddr_un addr; + + if (uflag) + (void)unlink(name); + + if ((sk = socket(AF_UNIX, SOCK_DGRAM, 0)) < 0) { + warn("%s: cannot create socket", name); + return (FAIL); + } + addr.sun_family = AF_UNIX; + strcpy(addr.sun_path, name); + if (bind(sk, (const struct sockaddr *)&addr, sizeof(struct sockaddr_un)) < 0) { + warn("%s: cannot create socket", name); + return (FAIL); + } + close(sk); + } + (void) chown(name, luid, lgid); + (void) chmod(name, mode); + extractattr(name); + utimes(name, timep); + if (flags) +#ifdef __linux__ + (void) lsetflags(name, flags); +#else +#ifdef sunos + { + warn("%s: cannot call chflags", name); + /* (void) chflags(name, flags); */ + } +#else + (void) chflags(name, flags); +#endif +#endif return (GOOD); + } case IFDIR: { @@ -891,6 +936,10 @@ extractfile(struct entry *ep, int doremove) } case IFIFO: + { + uid_t luid = curfile.dip->di_uid; + gid_t lgid = curfile.dip->di_gid; + Vprintf(stdout, "extract fifo %s\n", name); skipfile(); if (Nflag) @@ -903,7 +952,7 @@ extractfile(struct entry *ep, int doremove) return (FAIL); } } - (void) chown(name, curfile.dip->di_uid, curfile.dip->di_gid); + (void) chown(name, luid, lgid); (void) chmod(name, mode); extractattr(name); utimes(name, timep); @@ -921,9 +970,14 @@ extractfile(struct entry *ep, int doremove) #endif #endif return (GOOD); - + } case IFCHR: case IFBLK: + { + uid_t luid = curfile.dip->di_uid; + gid_t lgid = curfile.dip->di_gid; + int lrdev = (int)curfile.dip->di_rdev; + Vprintf(stdout, "extract special file %s\n", name); skipfile(); if (Nflag) @@ -931,12 +985,12 @@ extractfile(struct entry *ep, int doremove) if (! (spcl.c_flags & DR_METAONLY)) { if (uflag) (void)unlink(name); - if (mknod(name, mode, (int)curfile.dip->di_rdev) < 0) { + if (mknod(name, mode, lrdev) < 0) { warn("%s: cannot create special file", name); return (FAIL); } } - (void) chown(name, curfile.dip->di_uid, curfile.dip->di_gid); + (void) chown(name, luid, lgid); (void) chmod(name, mode); extractattr(name); utimes(name, timep); @@ -960,7 +1014,7 @@ extractfile(struct entry *ep, int doremove) #endif #endif return (GOOD); - + } case IFREG: { uid_t luid = curfile.dip->di_uid; @@ -1229,12 +1283,20 @@ readxattr(char *buffer) skipfile(); return (FAIL); } - + memset(xattrbuf, 0, XATTR_MAXSIZE); xattrlen = 0; + /* + * ugly hack: cope with invalid spcl.c_addr[] records written by + * old versions of dump. + */ + readmapflag = 1; + getfile(xtrxattr, xtrnull); + readmapflag = 0; + memcpy(buffer, xattrbuf, XATTR_MAXSIZE); return (GOOD);