Changeset 1293
- Timestamp:
- 06/22/07 12:49:13 (1 year ago)
- Files:
-
- honeytrap/trunk/src/ctrl.c (modified) (3 diffs)
- honeytrap/trunk/src/signals.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
honeytrap/trunk/src/ctrl.c
r1292 r1293 127 127 DEBUG_FPRINTF(stdout, " Successfully changed into daemon environment.\n"); 128 128 fprintf(stdout, "\nhoneytrap v%s Copyright (C) 2005-2007 Tillmann Werner <tillmann.werner@gmx.de>\n", VERSION); 129 fflush( stdout);129 fflush(NULL); 130 130 exit(EXIT_SUCCESS); 131 131 } … … 133 133 134 134 /* change working directory to root directory */ 135 DEBUG_FPRINTF(stdout, " Current working directory is %s.\n", old_cwd); 136 DEBUG_FPRINTF(stdout, " Changing working directory to /.\n"); 135 DEBUG_FPRINTF(stdout, " Current working directory is %s, changing it to /.\n", old_cwd); 137 136 if (chdir("/") < 0) { 138 137 fprintf(stderr, " Error - Cannot change working directory: %s\n", strerror(errno)); … … 141 140 142 141 143 144 /* close open file descriptors */ 142 /* close open file descriptors, only keep logfile and signal pipe */ 145 143 if (rl.rlim_max == RLIM_INFINITY) rl.rlim_max = 1024; 146 for (i=0; i < rl.rlim_max; i++) if (i != logfile_fd) close(i); 144 for (i=0; i < rl.rlim_max; i++) 145 if ((i != logfile_fd) && (i != sigpipe[0]) && (i != sigpipe[1]) && (close(i) == -1)) 146 fprintf(stdout, " Warnging - Could not close file descriptor %d: %s.\n", i, strerror(errno)); 147 147 148 148 /* attach file descriptors 0, 1 and 2 to /dev/null to prevent accidentally standard IO */ 149 fd0 = open("/dev/null", O_RDWR); 150 fd1 = dup(fd0); 151 fd2 = dup(fd0); 149 if ((fd0 = open("/dev/null", O_RDWR)) == -1) { 150 fprintf(stderr, " Error - Unable to set stdin to /dev/null: %s.\n", strerror(errno)); 151 exit(EXIT_FAILURE); 152 } 153 if ((fd1 = dup(fd0)) == -1) { 154 fprintf(stderr, " Error - Unable to set stdout to /dev/null: %s.\n", strerror(errno)); 155 exit(EXIT_FAILURE); 156 } 157 if ((fd2 = dup(fd0)) == -1) { 158 fprintf(stderr, " Error - Unable to set stderr to /dev/null: %s.\n", strerror(errno)); 159 exit(EXIT_FAILURE); 160 } 161 fflush(NULL); 152 162 153 163 return(1); honeytrap/trunk/src/signals.c
r1292 r1293 143 143 /* create a pipe for process-internal signal delivery */ 144 144 if (pipe(sigpipe) == -1) { 145 logmsg(LOG_ERR, 1, "Error - Unable to create signal pipe: %s.\n", strerror(errno));145 fprintf(stderr, " Error - Unable to create signal pipe: %s.\n", strerror(errno)); 146 146 exit(EXIT_FAILURE); 147 147 }
