|
Lines 9-16
Link Here
|
| 9 |
- int fd, i; |
9 |
- int fd, i; |
| 10 |
+ int fd; |
10 |
+ int fd; |
| 11 |
+ char name[] = "/tmp/anacron.XXXXXX"; |
11 |
+ char name[] = "/tmp/anacron.XXXXXX"; |
| 12 |
+ |
|
|
| 13 |
+ fd = mkstemp(name); |
| 14 |
|
12 |
|
| 15 |
- i = 0; |
13 |
- i = 0; |
| 16 |
- name = NULL; |
14 |
- name = NULL; |
|
Lines 25-34
Link Here
|
| 25 |
- /* I'm not sure we actually need to be so persistent here */ |
23 |
- /* I'm not sure we actually need to be so persistent here */ |
| 26 |
- } while (fd == -1 && errno == EEXIST && i < max_retries); |
24 |
- } while (fd == -1 && errno == EEXIST && i < max_retries); |
| 27 |
- |
25 |
- |
|
|
26 |
+ fd = mkstemp(name); |
| 27 |
+ |
| 28 |
if (fd == -1) die_e("Can't open temporary file"); |
28 |
if (fd == -1) die_e("Can't open temporary file"); |
| 29 |
if (unlink(name)) die_e("Can't unlink temporary file"); |
29 |
if (unlink(name)) die_e("Can't unlink temporary file"); |
| 30 |
- free(name); |
30 |
- free(name); |
| 31 |
+ |
31 |
+ |
| 32 |
fcntl(fd, F_SETFD, 1); /* set close-on-exec flag */ |
32 |
fcntl(fd, F_SETFD, 1); /* set close-on-exec flag */ |
| 33 |
return fd; |
33 |
return fd; |
|
|
34 |
} |
| 35 |
@@ -84,7 +72,7 @@ username() |
| 36 |
} |
| 37 |
|
| 38 |
static void |
| 39 |
-xputenv(const char *s) |
| 40 |
+xputenv(char *s) |
| 41 |
{ |
| 42 |
if (putenv(s)) die_e("Can't set the environment"); |
| 34 |
} |
43 |
} |