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

(-)src/util.c (-5 / +7 lines)
Lines 117-132 Link Here
117
    struct passwd *this_user;
117
    struct passwd *this_user;
118
118
119
    /* Default PID File */
119
    /* Default PID File */
120
    if (gc.pid_file->slen >= 0)
120
    if (pid_file == NULL) {
121
        gc.pid_file = bfromcstr("/var/run/pads.pid");
121
        pid_file = bfromcstr("/var/run/pads.pid");
122
        gc.pid_file = bfromcstr("/var/run/pads.pid"); // Needed to unlink
123
    }
122
124
123
    /* Create PID File */
125
    /* Create PID File */
124
    if ((fp = fopen(bdata(gc.pid_file), "w")) != NULL) {
126
    if ((fp = fopen(bdata(pid_file), "w")) != NULL) {
125
        pid = (int) getpid();
127
        pid = (int) getpid();
126
        fprintf(fp, "%d\n", pid);
128
        fprintf(fp, "%d\n", pid);
127
        fclose(fp);
129
        fclose(fp);
128
    } else {
130
    } else {
129
        err_message("Unable to create PID file (%s).\n", bdata(gc.pid_file));
131
        err_message("Unable to create PID file (%s).\n", bdata(pid_file));
130
    }
132
    }
131
133
132
    /* Change PID File's Ownership */
134
    /* Change PID File's Ownership */
Lines 137-143 Link Here
137
        err_message("'%s' group does not appear to exist.", bdata(group));
139
        err_message("'%s' group does not appear to exist.", bdata(group));
138
    if ((this_user = getpwnam(bdata(user))) == NULL)
140
    if ((this_user = getpwnam(bdata(user))) == NULL)
139
        err_message("'%s' user does not appear to exist.", bdata(user));
141
        err_message("'%s' user does not appear to exist.", bdata(user));
140
    if ((chown(pid_file, this_user->pw_uid, this_group->gr_gid)) != 0)
142
    if ((chown(bdata(pid_file), this_user->pw_uid, this_group->gr_gid)) != 0)
141
        err_message("Unable to change PID file's ownership.");
143
        err_message("Unable to change PID file's ownership.");
142
144
143
}
145
}

Return to bug 131591