]> git.wh0rd.org - dump.git/commitdiff
Create UNIX sockets instead of dummy files
authorStelian Pop <stelian@popies.net>
Fri, 11 Jun 2010 09:57:31 +0000 (09:57 +0000)
committerStelian Pop <stelian@popies.net>
Fri, 11 Jun 2010 09:57:31 +0000 (09:57 +0000)
CHANGES
restore/tape.c

diff --git a/CHANGES b/CHANGES
index f2d56fcb1badc48fe5606406eb6eaa6c35b0bcee..dcdf0463529f9b631db98336062c63751b3ad97d 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,4 +1,4 @@
-$Id: CHANGES,v 1.314 2010/06/11 09:51:59 stelian Exp $
+$Id: CHANGES,v 1.315 2010/06/11 09:57:31 stelian Exp $
 
 Changes between versions 0.4b42 and 0.4b43 (released ?????????????)
 ===================================================================
 
 Changes between versions 0.4b42 and 0.4b43 (released ?????????????)
 ===================================================================
@@ -54,11 +54,8 @@ Changes between versions 0.4b42 and 0.4b43 (released ?????????????)
        Kieran Clancy <codebeard@users.sourceforge.net> for reporting the
        bug (Sourceforge bug #2999207).
 
        Kieran Clancy <codebeard@users.sourceforge.net> for reporting the
        bug (Sourceforge bug #2999207).
 
-12.    Extract dumped UNIX sockets as dummy files, instead of not
-       restoring them at all. This will correct some warnings during
-       the restoration of incrementals, if the inodes previously occupied
-       by sockets gets reused by other files. See Sourceforge bug
-       #3007216 for details.
+12.    Extract dumped UNIX sockets instead of ignoring them.
+       (Sourceforge bug #3007216).
 
 Changes between versions 0.4b41 and 0.4b42 (released June 18, 2009)
 ===================================================================
 
 Changes between versions 0.4b41 and 0.4b42 (released June 18, 2009)
 ===================================================================
index 5ee9973f5fdf4bb996652060f28f3dd089af6854..395c99e9a81fb7a806a2acdca977653277c0146a 100644 (file)
@@ -42,7 +42,7 @@
 
 #ifndef lint
 static const char rcsid[] =
 
 #ifndef lint
 static const char rcsid[] =
-       "$Id: tape.c,v 1.97 2010/06/11 09:51:59 stelian Exp $";
+       "$Id: tape.c,v 1.98 2010/06/11 09:57:31 stelian Exp $";
 #endif /* not lint */
 
 #include <config.h>
 #endif /* not lint */
 
 #include <config.h>
@@ -61,6 +61,8 @@ static const char rcsid[] =
 #include <sys/file.h>
 #include <sys/mtio.h>
 #include <sys/stat.h>
 #include <sys/file.h>
 #include <sys/mtio.h>
 #include <sys/stat.h>
+#include <sys/socket.h>
+#include <sys/un.h>
 
 #ifdef __linux__
 #include <sys/time.h>
 
 #ifdef __linux__
 #include <sys/time.h>
@@ -847,19 +849,28 @@ extractfile(struct entry *ep, int doremove)
                uid_t luid = curfile.dip->di_uid;
                gid_t lgid = curfile.dip->di_gid;
 
                uid_t luid = curfile.dip->di_uid;
                gid_t lgid = curfile.dip->di_gid;
 
-               Vprintf(stdout, "extract socket as dummy file %s\n", name);
+               Vprintf(stdout, "extract socket %s\n", name);
                skipfile();
                if (Nflag)
                        return (GOOD);
                if (! (spcl.c_flags & DR_METAONLY)) {
                skipfile();
                if (Nflag)
                        return (GOOD);
                if (! (spcl.c_flags & DR_METAONLY)) {
-                       int fd;
+                       int sk;
+                       struct sockaddr_un addr;
+
                        if (uflag)
                                (void)unlink(name);
                        if (uflag)
                                (void)unlink(name);
-                       if ((fd = open(name, O_WRONLY | O_CREAT | O_TRUNC, 0666)) < 0) {
-                               warn("%s: cannot create dummy file", 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);
                        }
                                return (FAIL);
                        }
-                       close(fd);
+                       close(sk);
                }
                (void) chown(name, luid, lgid);
                (void) chmod(name, mode);
                }
                (void) chown(name, luid, lgid);
                (void) chmod(name, mode);