Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 141377 | Differences between
and this patch

Collapse All | Expand All

(-)runjob.c.orig (-17 / +5 lines)
Lines 39-64 Link Here
39
temp_file()
39
temp_file()
40
/* Open a temporary file and return its file descriptor */
40
/* Open a temporary file and return its file descriptor */
41
{
41
{
42
    const int max_retries = 50;
42
    int fd;
43
    char *name;
43
    char name[] = "/tmp/anacron.XXXXXX";
44
    int fd, i;
44
45
    fd = mkstemp(name);
45
46
46
    i = 0;
47
    name = NULL;
48
    do
49
    {
50
	i++;
51
	free(name);
52
	name = tempnam(NULL, NULL);
53
	if (name == NULL) die("Can't find a unique temporary filename");
54
	fd = open(name, O_RDWR | O_CREAT | O_EXCL | O_APPEND,
55
		  S_IRUSR | S_IWUSR);
56
	/* I'm not sure we actually need to be so persistent here */
57
    } while (fd == -1 && errno == EEXIST && i < max_retries);
58
    
59
    if (fd == -1) die_e("Can't open temporary file");
47
    if (fd == -1) die_e("Can't open temporary file");
60
    if (unlink(name)) die_e("Can't unlink temporary file");
48
    if (unlink(name)) die_e("Can't unlink temporary file");
61
    free(name);
49
62
    fcntl(fd, F_SETFD, 1);    /* set close-on-exec flag */
50
    fcntl(fd, F_SETFD, 1);    /* set close-on-exec flag */
63
    return fd;
51
    return fd;
64
}
52
}

Return to bug 141377