View | Details | Raw Unified | Return to bug 63140
Collapse All | Expand All

(-)a/server/log.c (-5 / +14 lines)
Lines 1524-1529 AP_DECLARE(void) ap_log_pid(apr_pool_t *p, const char *filename) Link Here
1524
    pid_t mypid;
1524
    pid_t mypid;
1525
    apr_status_t rv;
1525
    apr_status_t rv;
1526
    const char *fname;
1526
    const char *fname;
1527
    char *temp_fname;
1528
    apr_fileperms_t perms;
1527
1529
1528
    if (!filename) {
1530
    if (!filename) {
1529
        return;
1531
        return;
Lines 1535-1540 AP_DECLARE(void) ap_log_pid(apr_pool_t *p, const char *filename) Link Here
1535
                     ap_server_conf, APLOGNO(00097) "Invalid PID file path %s, ignoring.", filename);
1537
                     ap_server_conf, APLOGNO(00097) "Invalid PID file path %s, ignoring.", filename);
1536
        return;
1538
        return;
1537
    }
1539
    }
1540
    temp_fname = apr_psprintf(p, "%s.XXXXXX", filename);
1541
    if (!temp_fname) {
1542
        return;
1543
    }
1538
1544
1539
    mypid = getpid();
1545
    mypid = getpid();
1540
    if (mypid != saved_pid
1546
    if (mypid != saved_pid
Lines 1552-1570 AP_DECLARE(void) ap_log_pid(apr_pool_t *p, const char *filename) Link Here
1552
                      fname);
1558
                      fname);
1553
    }
1559
    }
1554
1560
1555
    if ((rv = apr_file_open(&pid_file, fname,
1561
    if ((rv = apr_file_mktemp(&pid_file, temp_fname,
1556
                            APR_WRITE | APR_CREATE | APR_TRUNCATE,
1562
                              APR_WRITE | APR_CREATE | APR_TRUNCATE, p))
1557
                            APR_UREAD | APR_UWRITE | APR_GREAD | APR_WREAD, p))
1558
        != APR_SUCCESS) {
1563
        != APR_SUCCESS) {
1559
        ap_log_error(APLOG_MARK, APLOG_ERR, rv, NULL, APLOGNO(00099)
1564
        ap_log_error(APLOG_MARK, APLOG_ERR, rv, NULL, APLOGNO(00099)
1560
                     "could not create %s", fname);
1565
                     "could not create %s", temp_fname);
1561
        ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL, APLOGNO(00100)
1566
        ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL, APLOGNO(00100)
1562
                     "%s: could not log pid to file %s",
1567
                     "%s: could not log pid to file %s",
1563
                     ap_server_argv0, fname);
1568
                     ap_server_argv0, fname);
1564
        exit(1);
1569
        exit(1);
1565
    }
1570
    }
1571
1572
    perms = APR_UREAD | APR_UWRITE | APR_GREAD | APR_WREAD;
1573
    apr_file_perms_set(temp_fname, perms);
1574
1566
    apr_file_printf(pid_file, "%" APR_PID_T_FMT APR_EOL_STR, mypid);
1575
    apr_file_printf(pid_file, "%" APR_PID_T_FMT APR_EOL_STR, mypid);
1567
    apr_file_close(pid_file);
1576
    apr_file_close(pid_file);
1577
    apr_file_rename(temp_fname, fname, p);
1568
    saved_pid = mypid;
1578
    saved_pid = mypid;
1569
}
1579
}
1570
1580
1571
- 

Return to bug 63140