| 268 | } |
| 269 | |
| 270 | int main(int argc, char *argv[]) |
| 271 | { |
| 272 | int userdir = 0; /* ~userdir flag */ |
| 273 | uid_t uid; /* user information */ |
| 274 | gid_t gid; /* target group placeholder */ |
| 275 | char *target_uname; /* target user name */ |
| 276 | char *target_gname; /* target group name */ |
| 277 | char *target_homedir; /* target home directory */ |
| 278 | char *actual_uname; /* actual user name */ |
| 279 | char *actual_gname; /* actual group name */ |
| 280 | char *cmd; /* command to be executed */ |
| 281 | char cwd[AP_MAXPATH]; /* current working directory */ |
| 282 | char dwd[AP_MAXPATH]; /* docroot working directory */ |
| 283 | struct passwd *pw; /* password entry holder */ |
| 284 | struct group *gr; /* group entry holder */ |
| 285 | struct stat dir_info; /* directory info holder */ |
| 286 | struct stat prg_info; /* program info holder */ |
| 287 | |
| 288 | /* |
| 289 | * Start with a "clean" environment |
| 290 | */ |
| 291 | clean_env(); |
| 292 | |
| 293 | /* |
| 294 | * Check existence/validity of the UID of the user |
| 295 | * running this program. Error out if invalid. |
| 296 | */ |
| 297 | uid = getuid(); |
| 298 | if ((pw = getpwuid(uid)) == NULL) { |
| 299 | log_err("crit: invalid uid: (%lu)\n", (unsigned long)uid); |
| 300 | exit(102); |
| 301 | } |
| 302 | /* |
| 303 | * See if this is a 'how were you compiled' request, and |
| 304 | * comply if so. |
| 305 | */ |
| 306 | if ((argc > 1) |
| 307 | && (! strcmp(argv[1], "-V")) |
| 308 | && ((uid == 0) |
| 309 | #ifdef _OSD_POSIX |
| 310 | /* User name comparisons are case insensitive on BS2000/OSD */ |
| 311 | || (! strcasecmp(AP_HTTPD_USER, pw->pw_name))) |
| 312 | #else /* _OSD_POSIX */ |
| 313 | || (! strcmp(AP_HTTPD_USER, pw->pw_name))) |
| 314 | #endif /* _OSD_POSIX */ |
| 315 | ) { |
| 316 | #ifdef AP_DOC_ROOT |
| 317 | fprintf(stderr, " -D AP_DOC_ROOT=\"%s\"\n", AP_DOC_ROOT); |
| 318 | #endif |
| 319 | #ifdef AP_GID_MIN |
| 320 | fprintf(stderr, " -D AP_GID_MIN=%d\n", AP_GID_MIN); |
| 321 | #endif |
| 322 | #ifdef AP_HTTPD_USER |
| 323 | fprintf(stderr, " -D AP_HTTPD_USER=\"%s\"\n", AP_HTTPD_USER); |
| 324 | #endif |
| 325 | #if defined(AP_LOG_SYSLOG) |
| 326 | fprintf(stderr, " -D AP_LOG_SYSLOG\n"); |
| 327 | #elif defined(AP_LOG_EXEC) |
nothing calls this directly
no test coverage detected