Contents of /trunk/logrotate/patches/logrotate-3.7.1-no-tmpdir.patch
Parent Directory | Revision Log
Revision 153 -
(show annotations)
(download)
Tue May 8 20:52:56 2007 UTC (17 years, 4 months ago) by niro
File size: 1266 byte(s)
Tue May 8 20:52:56 2007 UTC (17 years, 4 months ago) by niro
File size: 1266 byte(s)
-import
1 | diff -u -ruN logrotate-3.7.1-cur/logrotate.c logrotate-3.7.1/logrotate.c |
2 | --- logrotate-3.7.1-cur/logrotate.c 2005-05-25 18:20:41.000000000 -0400 |
3 | +++ logrotate-3.7.1/logrotate.c 2005-05-25 18:21:10.000000000 -0400 |
4 | @@ -90,10 +90,7 @@ |
5 | } |
6 | |
7 | static int runScript(char * logfn, char * script) { |
8 | - int fd; |
9 | - char *filespec; |
10 | int rc; |
11 | - char buf[256]; |
12 | |
13 | if (debug) { |
14 | message(MESS_DEBUG, "running script with arg %s: \"%s\"\n", |
15 | @@ -101,38 +98,12 @@ |
16 | return 0; |
17 | } |
18 | |
19 | - filespec = buf; |
20 | - snprintf(buf, sizeof(buf), "%s/logrotate.XXXXXX", getenv("TMPDIR") ?: "/tmp"); |
21 | - fd = -1; |
22 | - if (!filespec || (fd = mkstemp(filespec)) < 0 || fchmod(fd, 0700)) { |
23 | - message(MESS_DEBUG, "error creating %s: %s\n", filespec, |
24 | - strerror(errno)); |
25 | - if (fd >= 0) { |
26 | - close(fd); |
27 | - unlink(filespec); |
28 | - } |
29 | - return -1; |
30 | - } |
31 | - |
32 | - if (write(fd, "#!/bin/sh\n\n", 11) != 11 || |
33 | - write(fd, script, strlen(script)) != strlen(script)) { |
34 | - message(MESS_DEBUG, "error writing %s\n", filespec); |
35 | - close(fd); |
36 | - unlink(filespec); |
37 | - return -1; |
38 | - } |
39 | - |
40 | - close(fd); |
41 | - |
42 | if (!fork()) { |
43 | - execlp(filespec, filespec, logfn, NULL); |
44 | + execl("/bin/sh", "sh", "-c", script, NULL); |
45 | exit(1); |
46 | } |
47 | |
48 | wait(&rc); |
49 | - |
50 | - unlink(filespec); |
51 | - |
52 | return rc; |
53 | } |
54 |