| 176 | */ |
| 177 | |
| 178 | cups_file_t * /* O - File pointer */ |
| 179 | cupsdCreateConfFile( |
| 180 | const char *filename, /* I - Filename */ |
| 181 | mode_t mode) /* I - Permissions */ |
| 182 | { |
| 183 | cups_file_t *fp; /* File pointer */ |
| 184 | char newfile[1024]; /* filename.N */ |
| 185 | |
| 186 | |
| 187 | snprintf(newfile, sizeof(newfile), "%s.N", filename); |
| 188 | if ((fp = cupsFileOpen(newfile, "w")) == NULL) |
| 189 | { |
| 190 | cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to create \"%s\": %s", newfile, |
| 191 | strerror(errno)); |
| 192 | } |
| 193 | else |
| 194 | { |
| 195 | if (!getuid() && fchown(cupsFileNumber(fp), getuid(), Group)) |
| 196 | cupsdLogMessage(CUPSD_LOG_WARN, "Unable to change group for \"%s\": %s", |
| 197 | newfile, strerror(errno)); |
| 198 | |
| 199 | if (fchmod(cupsFileNumber(fp), mode)) |
| 200 | cupsdLogMessage(CUPSD_LOG_WARN, |
| 201 | "Unable to change permissions for \"%s\": %s", |
| 202 | newfile, strerror(errno)); |
| 203 | } |
| 204 | |
| 205 | return (fp); |
| 206 | } |
| 207 | |
| 208 | |
| 209 | /* |
no test coverage detected