diff -cr ./src/pads.c ../pads-1.2-bianco/src/pads.c *** ./src/pads.c 2005-06-15 18:00:40.000000000 -0400 --- ../pads-1.2-bianco/src/pads.c 2007-06-05 09:57:07.000000000 -0400 *************** *** 187,193 **** /* Daemon Mode: fork child process */ if (gc.daemon_mode) { daemonize(); - init_pid_file(gc.pid_file, gc.priv_user, gc.priv_group); } /* Signal Trapping */ --- 187,192 ---- diff -cr ./src/util.c ../pads-1.2-bianco/src/util.c *** ./src/util.c 2005-03-10 20:31:15.000000000 -0500 --- ../pads-1.2-bianco/src/util.c 2007-06-05 09:58:47.000000000 -0400 *************** *** 83,89 **** pid_t pid; printf("[-] Daemonizing...\n"); - pid = fork(); if (pid > 0) { /* Parent */ --- 83,88 ---- *************** *** 95,100 **** --- 94,102 ---- } else { /* Child */ setsid(); + init_pid_file(gc.pid_file, gc.priv_user, gc.priv_group); + fflush(stdout); + fflush(stderr); close(0); close(1); close(2); *************** *** 115,132 **** FILE *fp; struct group *this_group; struct passwd *this_user; - /* Default PID File */ ! if (gc.pid_file->slen >= 0) ! gc.pid_file = bfromcstr("/var/run/pads.pid"); ! /* Create PID File */ ! if ((fp = fopen(bdata(gc.pid_file), "w")) != NULL) { pid = (int) getpid(); fprintf(fp, "%d\n", pid); fclose(fp); } else { ! err_message("Unable to create PID file (%s).\n", bdata(gc.pid_file)); } /* Change PID File's Ownership */ --- 117,134 ---- FILE *fp; struct group *this_group; struct passwd *this_user; /* Default PID File */ ! if (pid_file == NULL) { ! pid_file = bfromcstr("/var/run/pads.pid"); ! } ! /* Create PID File */ ! if ((fp = fopen(bdata(pid_file), "w")) != NULL) { pid = (int) getpid(); fprintf(fp, "%d\n", pid); fclose(fp); } else { ! err_message("Unable to create PID file (%s).\n", bdata(pid_file)); } /* Change PID File's Ownership */ *************** *** 137,143 **** err_message("'%s' group does not appear to exist.", bdata(group)); if ((this_user = getpwnam(bdata(user))) == NULL) err_message("'%s' user does not appear to exist.", bdata(user)); ! if ((chown(pid_file, this_user->pw_uid, this_group->gr_gid)) != 0) err_message("Unable to change PID file's ownership."); } --- 139,145 ---- err_message("'%s' group does not appear to exist.", bdata(group)); if ((this_user = getpwnam(bdata(user))) == NULL) err_message("'%s' user does not appear to exist.", bdata(user)); ! if ((chown(bdata(pid_file), this_user->pw_uid, this_group->gr_gid)) != 0) err_message("Unable to change PID file's ownership."); }