diff options
author | Erik Andersen <andersen@codepoet.org> | 2000-04-14 21:45:29 +0000 |
---|---|---|
committer | Erik Andersen <andersen@codepoet.org> | 2000-04-14 21:45:29 +0000 |
commit | 95c1c1e05f290ccbcc2ff863a62bcee5d57bf5c8 (patch) | |
tree | 3b89971f6401d4cf4f8d94d28e8b528bef789486 | |
parent | d5ba77d03ee32b6757005ebd58c04b845b3a151a (diff) | |
download | busybox-w32-95c1c1e05f290ccbcc2ff863a62bcee5d57bf5c8.tar.gz busybox-w32-95c1c1e05f290ccbcc2ff863a62bcee5d57bf5c8.tar.bz2 busybox-w32-95c1c1e05f290ccbcc2ff863a62bcee5d57bf5c8.zip |
Fix a tar bug: tar removed leading '/'s for symlink targets.
Fix a syslogd bug: Only the first sizeof(buffer) was read from the
/dev/log socket, causing (for most cases) only every other log item to be logged.
-Erik
-rw-r--r-- | TODO | 8 | ||||
-rw-r--r-- | archival/tar.c | 26 | ||||
-rw-r--r-- | docs/Makefile | 1 | ||||
-rw-r--r-- | sysklogd/syslogd.c | 64 | ||||
-rw-r--r-- | syslogd.c | 64 | ||||
-rw-r--r-- | tar.c | 26 |
6 files changed, 48 insertions, 141 deletions
@@ -23,7 +23,9 @@ around to it some time. If you have any good ideas, please let me know. | |||
23 | * stty | 23 | * stty |
24 | * cut | 24 | * cut |
25 | * expr | 25 | * expr |
26 | 26 | * wget (or whatever I call it) | |
27 | * tftp | ||
28 | * ftp | ||
27 | 29 | ||
28 | 30 | ||
29 | ----------------------- | 31 | ----------------------- |
@@ -31,24 +33,20 @@ around to it some time. If you have any good ideas, please let me know. | |||
31 | Compile with debugging on, run 'nm --size-sort ./busybox' | 33 | Compile with debugging on, run 'nm --size-sort ./busybox' |
32 | and then start with the biggest things and make them smaller... | 34 | and then start with the biggest things and make them smaller... |
33 | 35 | ||
34 | |||
35 | ----------------------- | 36 | ----------------------- |
36 | 37 | ||
37 | |||
38 | busybox.defs.h is too big and hard to follow. | 38 | busybox.defs.h is too big and hard to follow. |
39 | 39 | ||
40 | Perhaps I need to add a better build system (like the Linux kernel?) | 40 | Perhaps I need to add a better build system (like the Linux kernel?) |
41 | 41 | ||
42 | ----------------------- | 42 | ----------------------- |
43 | 43 | ||
44 | |||
45 | Feature request: | 44 | Feature request: |
46 | 45 | ||
47 | /bin/busybox --install -s which makes all links to commands that it | 46 | /bin/busybox --install -s which makes all links to commands that it |
48 | can support (an optionnal -s should be used for symbolic links instead | 47 | can support (an optionnal -s should be used for symbolic links instead |
49 | of hard links). | 48 | of hard links). |
50 | 49 | ||
51 | |||
52 | ----------------------- | 50 | ----------------------- |
53 | 51 | ||
54 | 52 | ||
diff --git a/archival/tar.c b/archival/tar.c index 4eda4c61a..9b3cb7d81 100644 --- a/archival/tar.c +++ b/archival/tar.c | |||
@@ -493,18 +493,6 @@ readTarHeader(struct TarHeader *rawHeader, struct TarInfo *header) | |||
493 | chksum = getOctal(rawHeader->chksum, sizeof(rawHeader->chksum)); | 493 | chksum = getOctal(rawHeader->chksum, sizeof(rawHeader->chksum)); |
494 | header->type = rawHeader->typeflag; | 494 | header->type = rawHeader->typeflag; |
495 | header->linkname = rawHeader->linkname; | 495 | header->linkname = rawHeader->linkname; |
496 | /* Check for and relativify any absolute paths */ | ||
497 | if ( *(header->linkname) == '/' ) { | ||
498 | static int alreadyWarned=FALSE; | ||
499 | |||
500 | while (*(header->linkname) == '/') | ||
501 | ++*(header->linkname); | ||
502 | |||
503 | if (alreadyWarned == FALSE) { | ||
504 | errorMsg("tar: Removing leading '/' from link names\n"); | ||
505 | alreadyWarned = TRUE; | ||
506 | } | ||
507 | } | ||
508 | header->devmajor = getOctal(rawHeader->devmajor, sizeof(rawHeader->devmajor)); | 496 | header->devmajor = getOctal(rawHeader->devmajor, sizeof(rawHeader->devmajor)); |
509 | header->devminor = getOctal(rawHeader->devminor, sizeof(rawHeader->devminor)); | 497 | header->devminor = getOctal(rawHeader->devminor, sizeof(rawHeader->devminor)); |
510 | 498 | ||
@@ -826,7 +814,7 @@ writeTarHeader(struct TarBallInfo *tbInfo, const char *fileName, struct stat *st | |||
826 | if (! *header.uname) | 814 | if (! *header.uname) |
827 | strcpy(header.uname, "root"); | 815 | strcpy(header.uname, "root"); |
828 | 816 | ||
829 | // FIXME (or most likely not): I break Hard Links | 817 | /* WARNING/NOTICE: I break Hard Links */ |
830 | if (S_ISLNK(statbuf->st_mode)) { | 818 | if (S_ISLNK(statbuf->st_mode)) { |
831 | char buffer[BUFSIZ]; | 819 | char buffer[BUFSIZ]; |
832 | header.typeflag = SYMTYPE; | 820 | header.typeflag = SYMTYPE; |
@@ -834,17 +822,7 @@ writeTarHeader(struct TarBallInfo *tbInfo, const char *fileName, struct stat *st | |||
834 | errorMsg("Error reading symlink '%s': %s\n", header.name, strerror(errno)); | 822 | errorMsg("Error reading symlink '%s': %s\n", header.name, strerror(errno)); |
835 | return ( FALSE); | 823 | return ( FALSE); |
836 | } | 824 | } |
837 | if (*buffer=='/') { | 825 | strncpy(header.linkname, buffer, sizeof(header.linkname)); |
838 | static int alreadyWarned=FALSE; | ||
839 | if (alreadyWarned==FALSE) { | ||
840 | errorMsg("tar: Removing leading '/' from link names\n"); | ||
841 | alreadyWarned=TRUE; | ||
842 | } | ||
843 | strncpy(header.linkname, buffer+1, sizeof(header.linkname)); | ||
844 | } | ||
845 | else { | ||
846 | strncpy(header.linkname, buffer, sizeof(header.linkname)); | ||
847 | } | ||
848 | } else if (S_ISDIR(statbuf->st_mode)) { | 826 | } else if (S_ISDIR(statbuf->st_mode)) { |
849 | header.typeflag = DIRTYPE; | 827 | header.typeflag = DIRTYPE; |
850 | strncat(header.name, "/", sizeof(header.name)); | 828 | strncat(header.name, "/", sizeof(header.name)); |
diff --git a/docs/Makefile b/docs/Makefile index aebe8a847..10550f6df 100644 --- a/docs/Makefile +++ b/docs/Makefile | |||
@@ -12,6 +12,7 @@ doc: | |||
12 | @rm pod2html-* | 12 | @rm pod2html-* |
13 | pod2man --center=BusyBox --release="version $(VERSION)" busybox.pod > ../BusyBox.1 | 13 | pod2man --center=BusyBox --release="version $(VERSION)" busybox.pod > ../BusyBox.1 |
14 | pod2text busybox.pod > ../BusyBox.txt | 14 | pod2text busybox.pod > ../BusyBox.txt |
15 | @rm -f pod2html* | ||
15 | 16 | ||
16 | clean:: | 17 | clean:: |
17 | @rm -f ../BusyBox.html ../BusyBox.1 ../BusyBox.txt pod2html* | 18 | @rm -f ../BusyBox.html ../BusyBox.1 ../BusyBox.txt pod2html* |
diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c index ec372fc56..8827265d5 100644 --- a/sysklogd/syslogd.c +++ b/sysklogd/syslogd.c | |||
@@ -81,21 +81,17 @@ static void message(char *fmt, ...) | |||
81 | int fd; | 81 | int fd; |
82 | va_list arguments; | 82 | va_list arguments; |
83 | 83 | ||
84 | if ( | 84 | if ( (fd = device_open(logFilePath, |
85 | (fd = | 85 | O_WRONLY | O_CREAT | O_NOCTTY | O_APPEND | |
86 | device_open(logFilePath, | 86 | O_NONBLOCK)) >= 0) { |
87 | O_WRONLY | O_CREAT | O_NOCTTY | O_APPEND | | ||
88 | O_NONBLOCK)) >= 0) { | ||
89 | va_start(arguments, fmt); | 87 | va_start(arguments, fmt); |
90 | vdprintf(fd, fmt, arguments); | 88 | vdprintf(fd, fmt, arguments); |
91 | va_end(arguments); | 89 | va_end(arguments); |
92 | close(fd); | 90 | close(fd); |
93 | } else { | 91 | } else { |
94 | /* Always send console messages to /dev/console so people will see them. */ | 92 | /* Always send console messages to /dev/console so people will see them. */ |
95 | if ( | 93 | if ( (fd = device_open(_PATH_CONSOLE, |
96 | (fd = | 94 | O_WRONLY | O_NOCTTY | O_NONBLOCK)) >= 0) { |
97 | device_open(_PATH_CONSOLE, | ||
98 | O_WRONLY | O_NOCTTY | O_NONBLOCK)) >= 0) { | ||
99 | va_start(arguments, fmt); | 95 | va_start(arguments, fmt); |
100 | vdprintf(fd, fmt, arguments); | 96 | vdprintf(fd, fmt, arguments); |
101 | va_end(arguments); | 97 | va_end(arguments); |
@@ -177,14 +173,10 @@ static void doSyslogd (void) | |||
177 | signal (SIGALRM, domark); | 173 | signal (SIGALRM, domark); |
178 | alarm (MarkInterval); | 174 | alarm (MarkInterval); |
179 | 175 | ||
180 | /* create the syslog file so realpath() can work | 176 | /* create the syslog file so realpath() can work */ |
181 | * (the ugle close(open()) stuff is just a cheap | 177 | close(open(_PATH_LOG, O_RDWR | O_CREAT, 0644)); |
182 | * touch command that avoids using system (system | ||
183 | * is always a bad thing to use) */ | ||
184 | close(open("touch " _PATH_LOG, O_RDWR | O_CREAT, 0644)); | ||
185 | if (realpath(_PATH_LOG, lfile) == NULL) { | 178 | if (realpath(_PATH_LOG, lfile) == NULL) { |
186 | perror("Could not resolv path to " _PATH_LOG); | 179 | fatalError("Could not resolv path to " _PATH_LOG); |
187 | exit (FALSE); | ||
188 | } | 180 | } |
189 | 181 | ||
190 | unlink (lfile); | 182 | unlink (lfile); |
@@ -194,20 +186,17 @@ static void doSyslogd (void) | |||
194 | sunx.sun_family = AF_UNIX; | 186 | sunx.sun_family = AF_UNIX; |
195 | strncpy (sunx.sun_path, lfile, sizeof(sunx.sun_path)); | 187 | strncpy (sunx.sun_path, lfile, sizeof(sunx.sun_path)); |
196 | if ((sock_fd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) { | 188 | if ((sock_fd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) { |
197 | perror ("Couldn't obtain descriptor for socket " _PATH_LOG); | 189 | fatalError ("Couldn't obtain descriptor for socket " _PATH_LOG); |
198 | exit (FALSE); | ||
199 | } | 190 | } |
200 | 191 | ||
201 | addrLength = sizeof (sunx.sun_family) + strlen (sunx.sun_path); | 192 | addrLength = sizeof (sunx.sun_family) + strlen (sunx.sun_path); |
202 | if ((bind (sock_fd, (struct sockaddr *) &sunx, addrLength)) || | 193 | if ((bind (sock_fd, (struct sockaddr *) &sunx, addrLength)) || |
203 | (listen (sock_fd, 5))) { | 194 | (listen (sock_fd, 5))) { |
204 | perror ("Could not connect to socket " _PATH_LOG); | 195 | fatalError ("Could not connect to socket " _PATH_LOG); |
205 | exit (FALSE); | ||
206 | } | 196 | } |
207 | 197 | ||
208 | if (chmod (lfile, 0666) < 0) { | 198 | if (chmod (lfile, 0666) < 0) { |
209 | perror ("Could not set permission on " _PATH_LOG); | 199 | fatalError ("Could not set permission on " _PATH_LOG); |
210 | exit (FALSE); | ||
211 | } | 200 | } |
212 | 201 | ||
213 | FD_ZERO (&readfds); | 202 | FD_ZERO (&readfds); |
@@ -221,19 +210,17 @@ static void doSyslogd (void) | |||
221 | 210 | ||
222 | if ((n_ready = select (FD_SETSIZE, &readfds, NULL, NULL, NULL)) < 0) { | 211 | if ((n_ready = select (FD_SETSIZE, &readfds, NULL, NULL, NULL)) < 0) { |
223 | if (errno == EINTR) continue; /* alarm may have happened. */ | 212 | if (errno == EINTR) continue; /* alarm may have happened. */ |
224 | perror ("select"); | 213 | fatalError( "select error: %s\n", strerror(errno)); |
225 | exit (FALSE); | ||
226 | } | 214 | } |
227 | 215 | ||
228 | /* Skip stdin, stdout, stderr */ | 216 | /* Skip stdin, stdout, stderr */ |
229 | for (fd = 3; fd <= FD_SETSIZE; fd++) { | 217 | for (fd = 3; fd < FD_SETSIZE; fd++) { |
230 | if (FD_ISSET (fd, &readfds)) { | 218 | if (FD_ISSET (fd, &readfds)) { |
231 | if (fd == sock_fd) { | 219 | if (fd == sock_fd) { |
232 | int conn; | 220 | int conn; |
233 | if ((conn = accept(sock_fd, (struct sockaddr *) &sunx, | 221 | if ((conn = accept(sock_fd, (struct sockaddr *) &sunx, |
234 | &addrLength)) < 0) { | 222 | &addrLength)) < 0) { |
235 | perror ("accept"); | 223 | fatalError( "accept error: %s\n", strerror(errno)); |
236 | exit (FALSE); /* #### ??? */ | ||
237 | } | 224 | } |
238 | FD_SET (conn, &readfds); | 225 | FD_SET (conn, &readfds); |
239 | } | 226 | } |
@@ -242,17 +229,11 @@ static void doSyslogd (void) | |||
242 | char buf[BUFSIZE]; | 229 | char buf[BUFSIZE]; |
243 | char *q, *p; | 230 | char *q, *p; |
244 | int n_read; | 231 | int n_read; |
232 | char line[BUFSIZE]; | ||
233 | unsigned char c; | ||
245 | 234 | ||
246 | n_read = read (fd, buf, BUFSIZE); | 235 | /* Keep reading stuff till there is nothing else to read */ |
247 | 236 | while( (n_read = read (fd, buf, BUFSIZE)) > 0 && errno != EOF) { | |
248 | if (n_read < 0) { | ||
249 | // FIXME .. fd isn't set | ||
250 | perror ("read error"); | ||
251 | goto close_fd; | ||
252 | } | ||
253 | else if (n_read > 0) { | ||
254 | char line[BUFSIZE]; | ||
255 | unsigned char c; | ||
256 | int pri = (LOG_USER | LOG_NOTICE); | 237 | int pri = (LOG_USER | LOG_NOTICE); |
257 | 238 | ||
258 | memset (line, 0, sizeof(line)); | 239 | memset (line, 0, sizeof(line)); |
@@ -281,14 +262,9 @@ static void doSyslogd (void) | |||
281 | 262 | ||
282 | /* Now log it */ | 263 | /* Now log it */ |
283 | logMessage(pri, line); | 264 | logMessage(pri, line); |
284 | |||
285 | close_fd: | ||
286 | close (fd); | ||
287 | FD_CLR (fd, &readfds); | ||
288 | } | ||
289 | else { /* EOF */ | ||
290 | goto close_fd; | ||
291 | } | 265 | } |
266 | close (fd); | ||
267 | FD_CLR (fd, &readfds); | ||
292 | } | 268 | } |
293 | } | 269 | } |
294 | } | 270 | } |
@@ -81,21 +81,17 @@ static void message(char *fmt, ...) | |||
81 | int fd; | 81 | int fd; |
82 | va_list arguments; | 82 | va_list arguments; |
83 | 83 | ||
84 | if ( | 84 | if ( (fd = device_open(logFilePath, |
85 | (fd = | 85 | O_WRONLY | O_CREAT | O_NOCTTY | O_APPEND | |
86 | device_open(logFilePath, | 86 | O_NONBLOCK)) >= 0) { |
87 | O_WRONLY | O_CREAT | O_NOCTTY | O_APPEND | | ||
88 | O_NONBLOCK)) >= 0) { | ||
89 | va_start(arguments, fmt); | 87 | va_start(arguments, fmt); |
90 | vdprintf(fd, fmt, arguments); | 88 | vdprintf(fd, fmt, arguments); |
91 | va_end(arguments); | 89 | va_end(arguments); |
92 | close(fd); | 90 | close(fd); |
93 | } else { | 91 | } else { |
94 | /* Always send console messages to /dev/console so people will see them. */ | 92 | /* Always send console messages to /dev/console so people will see them. */ |
95 | if ( | 93 | if ( (fd = device_open(_PATH_CONSOLE, |
96 | (fd = | 94 | O_WRONLY | O_NOCTTY | O_NONBLOCK)) >= 0) { |
97 | device_open(_PATH_CONSOLE, | ||
98 | O_WRONLY | O_NOCTTY | O_NONBLOCK)) >= 0) { | ||
99 | va_start(arguments, fmt); | 95 | va_start(arguments, fmt); |
100 | vdprintf(fd, fmt, arguments); | 96 | vdprintf(fd, fmt, arguments); |
101 | va_end(arguments); | 97 | va_end(arguments); |
@@ -177,14 +173,10 @@ static void doSyslogd (void) | |||
177 | signal (SIGALRM, domark); | 173 | signal (SIGALRM, domark); |
178 | alarm (MarkInterval); | 174 | alarm (MarkInterval); |
179 | 175 | ||
180 | /* create the syslog file so realpath() can work | 176 | /* create the syslog file so realpath() can work */ |
181 | * (the ugle close(open()) stuff is just a cheap | 177 | close(open(_PATH_LOG, O_RDWR | O_CREAT, 0644)); |
182 | * touch command that avoids using system (system | ||
183 | * is always a bad thing to use) */ | ||
184 | close(open("touch " _PATH_LOG, O_RDWR | O_CREAT, 0644)); | ||
185 | if (realpath(_PATH_LOG, lfile) == NULL) { | 178 | if (realpath(_PATH_LOG, lfile) == NULL) { |
186 | perror("Could not resolv path to " _PATH_LOG); | 179 | fatalError("Could not resolv path to " _PATH_LOG); |
187 | exit (FALSE); | ||
188 | } | 180 | } |
189 | 181 | ||
190 | unlink (lfile); | 182 | unlink (lfile); |
@@ -194,20 +186,17 @@ static void doSyslogd (void) | |||
194 | sunx.sun_family = AF_UNIX; | 186 | sunx.sun_family = AF_UNIX; |
195 | strncpy (sunx.sun_path, lfile, sizeof(sunx.sun_path)); | 187 | strncpy (sunx.sun_path, lfile, sizeof(sunx.sun_path)); |
196 | if ((sock_fd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) { | 188 | if ((sock_fd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) { |
197 | perror ("Couldn't obtain descriptor for socket " _PATH_LOG); | 189 | fatalError ("Couldn't obtain descriptor for socket " _PATH_LOG); |
198 | exit (FALSE); | ||
199 | } | 190 | } |
200 | 191 | ||
201 | addrLength = sizeof (sunx.sun_family) + strlen (sunx.sun_path); | 192 | addrLength = sizeof (sunx.sun_family) + strlen (sunx.sun_path); |
202 | if ((bind (sock_fd, (struct sockaddr *) &sunx, addrLength)) || | 193 | if ((bind (sock_fd, (struct sockaddr *) &sunx, addrLength)) || |
203 | (listen (sock_fd, 5))) { | 194 | (listen (sock_fd, 5))) { |
204 | perror ("Could not connect to socket " _PATH_LOG); | 195 | fatalError ("Could not connect to socket " _PATH_LOG); |
205 | exit (FALSE); | ||
206 | } | 196 | } |
207 | 197 | ||
208 | if (chmod (lfile, 0666) < 0) { | 198 | if (chmod (lfile, 0666) < 0) { |
209 | perror ("Could not set permission on " _PATH_LOG); | 199 | fatalError ("Could not set permission on " _PATH_LOG); |
210 | exit (FALSE); | ||
211 | } | 200 | } |
212 | 201 | ||
213 | FD_ZERO (&readfds); | 202 | FD_ZERO (&readfds); |
@@ -221,19 +210,17 @@ static void doSyslogd (void) | |||
221 | 210 | ||
222 | if ((n_ready = select (FD_SETSIZE, &readfds, NULL, NULL, NULL)) < 0) { | 211 | if ((n_ready = select (FD_SETSIZE, &readfds, NULL, NULL, NULL)) < 0) { |
223 | if (errno == EINTR) continue; /* alarm may have happened. */ | 212 | if (errno == EINTR) continue; /* alarm may have happened. */ |
224 | perror ("select"); | 213 | fatalError( "select error: %s\n", strerror(errno)); |
225 | exit (FALSE); | ||
226 | } | 214 | } |
227 | 215 | ||
228 | /* Skip stdin, stdout, stderr */ | 216 | /* Skip stdin, stdout, stderr */ |
229 | for (fd = 3; fd <= FD_SETSIZE; fd++) { | 217 | for (fd = 3; fd < FD_SETSIZE; fd++) { |
230 | if (FD_ISSET (fd, &readfds)) { | 218 | if (FD_ISSET (fd, &readfds)) { |
231 | if (fd == sock_fd) { | 219 | if (fd == sock_fd) { |
232 | int conn; | 220 | int conn; |
233 | if ((conn = accept(sock_fd, (struct sockaddr *) &sunx, | 221 | if ((conn = accept(sock_fd, (struct sockaddr *) &sunx, |
234 | &addrLength)) < 0) { | 222 | &addrLength)) < 0) { |
235 | perror ("accept"); | 223 | fatalError( "accept error: %s\n", strerror(errno)); |
236 | exit (FALSE); /* #### ??? */ | ||
237 | } | 224 | } |
238 | FD_SET (conn, &readfds); | 225 | FD_SET (conn, &readfds); |
239 | } | 226 | } |
@@ -242,17 +229,11 @@ static void doSyslogd (void) | |||
242 | char buf[BUFSIZE]; | 229 | char buf[BUFSIZE]; |
243 | char *q, *p; | 230 | char *q, *p; |
244 | int n_read; | 231 | int n_read; |
232 | char line[BUFSIZE]; | ||
233 | unsigned char c; | ||
245 | 234 | ||
246 | n_read = read (fd, buf, BUFSIZE); | 235 | /* Keep reading stuff till there is nothing else to read */ |
247 | 236 | while( (n_read = read (fd, buf, BUFSIZE)) > 0 && errno != EOF) { | |
248 | if (n_read < 0) { | ||
249 | // FIXME .. fd isn't set | ||
250 | perror ("read error"); | ||
251 | goto close_fd; | ||
252 | } | ||
253 | else if (n_read > 0) { | ||
254 | char line[BUFSIZE]; | ||
255 | unsigned char c; | ||
256 | int pri = (LOG_USER | LOG_NOTICE); | 237 | int pri = (LOG_USER | LOG_NOTICE); |
257 | 238 | ||
258 | memset (line, 0, sizeof(line)); | 239 | memset (line, 0, sizeof(line)); |
@@ -281,14 +262,9 @@ static void doSyslogd (void) | |||
281 | 262 | ||
282 | /* Now log it */ | 263 | /* Now log it */ |
283 | logMessage(pri, line); | 264 | logMessage(pri, line); |
284 | |||
285 | close_fd: | ||
286 | close (fd); | ||
287 | FD_CLR (fd, &readfds); | ||
288 | } | ||
289 | else { /* EOF */ | ||
290 | goto close_fd; | ||
291 | } | 265 | } |
266 | close (fd); | ||
267 | FD_CLR (fd, &readfds); | ||
292 | } | 268 | } |
293 | } | 269 | } |
294 | } | 270 | } |
@@ -493,18 +493,6 @@ readTarHeader(struct TarHeader *rawHeader, struct TarInfo *header) | |||
493 | chksum = getOctal(rawHeader->chksum, sizeof(rawHeader->chksum)); | 493 | chksum = getOctal(rawHeader->chksum, sizeof(rawHeader->chksum)); |
494 | header->type = rawHeader->typeflag; | 494 | header->type = rawHeader->typeflag; |
495 | header->linkname = rawHeader->linkname; | 495 | header->linkname = rawHeader->linkname; |
496 | /* Check for and relativify any absolute paths */ | ||
497 | if ( *(header->linkname) == '/' ) { | ||
498 | static int alreadyWarned=FALSE; | ||
499 | |||
500 | while (*(header->linkname) == '/') | ||
501 | ++*(header->linkname); | ||
502 | |||
503 | if (alreadyWarned == FALSE) { | ||
504 | errorMsg("tar: Removing leading '/' from link names\n"); | ||
505 | alreadyWarned = TRUE; | ||
506 | } | ||
507 | } | ||
508 | header->devmajor = getOctal(rawHeader->devmajor, sizeof(rawHeader->devmajor)); | 496 | header->devmajor = getOctal(rawHeader->devmajor, sizeof(rawHeader->devmajor)); |
509 | header->devminor = getOctal(rawHeader->devminor, sizeof(rawHeader->devminor)); | 497 | header->devminor = getOctal(rawHeader->devminor, sizeof(rawHeader->devminor)); |
510 | 498 | ||
@@ -826,7 +814,7 @@ writeTarHeader(struct TarBallInfo *tbInfo, const char *fileName, struct stat *st | |||
826 | if (! *header.uname) | 814 | if (! *header.uname) |
827 | strcpy(header.uname, "root"); | 815 | strcpy(header.uname, "root"); |
828 | 816 | ||
829 | // FIXME (or most likely not): I break Hard Links | 817 | /* WARNING/NOTICE: I break Hard Links */ |
830 | if (S_ISLNK(statbuf->st_mode)) { | 818 | if (S_ISLNK(statbuf->st_mode)) { |
831 | char buffer[BUFSIZ]; | 819 | char buffer[BUFSIZ]; |
832 | header.typeflag = SYMTYPE; | 820 | header.typeflag = SYMTYPE; |
@@ -834,17 +822,7 @@ writeTarHeader(struct TarBallInfo *tbInfo, const char *fileName, struct stat *st | |||
834 | errorMsg("Error reading symlink '%s': %s\n", header.name, strerror(errno)); | 822 | errorMsg("Error reading symlink '%s': %s\n", header.name, strerror(errno)); |
835 | return ( FALSE); | 823 | return ( FALSE); |
836 | } | 824 | } |
837 | if (*buffer=='/') { | 825 | strncpy(header.linkname, buffer, sizeof(header.linkname)); |
838 | static int alreadyWarned=FALSE; | ||
839 | if (alreadyWarned==FALSE) { | ||
840 | errorMsg("tar: Removing leading '/' from link names\n"); | ||
841 | alreadyWarned=TRUE; | ||
842 | } | ||
843 | strncpy(header.linkname, buffer+1, sizeof(header.linkname)); | ||
844 | } | ||
845 | else { | ||
846 | strncpy(header.linkname, buffer, sizeof(header.linkname)); | ||
847 | } | ||
848 | } else if (S_ISDIR(statbuf->st_mode)) { | 826 | } else if (S_ISDIR(statbuf->st_mode)) { |
849 | header.typeflag = DIRTYPE; | 827 | header.typeflag = DIRTYPE; |
850 | strncat(header.name, "/", sizeof(header.name)); | 828 | strncat(header.name, "/", sizeof(header.name)); |