Changeset 392
- Timestamp:
- 03/04/07 22:54:22
(2 years ago)
- Author:
- malte
- Message:
fixed multiple courier-authdaemon problem by cortex93
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r154 |
r392 |
|
| 1 | | |
|---|
| | 1 | #include <errno.h> |
|---|
| | 2 | #include <sys/types.h> |
|---|
| | 3 | #include <sys/stat.h> |
|---|
| | 4 | #include <fcntl.h> |
|---|
| | 5 | #include <sys/procfs.h> |
|---|
| | 6 | #include <unistd.h> |
|---|
| | 7 | #include <sys/param.h> |
|---|
| 2 | 8 | #include "lr_syntax.h" |
|---|
| 3 | | #include <sys/param.h> |
|---|
| 4 | 9 | |
|---|
| 5 | 10 | #if !defined(__OpenBSD__) && !defined(__FreeBSD__) |
|---|
| … | … | |
| 49 | 54 | |
|---|
| 50 | 55 | if (fork() == 0 ) { |
|---|
| | 56 | |
|---|
| | 57 | int fdres, dupres; |
|---|
| | 58 | char logfile[MAXPATHLEN]; |
|---|
| 51 | 59 | |
|---|
| 52 | 60 | /* |
|---|
| … | … | |
| 67 | 75 | strncpy(daemon_path, fname2, strlen(fname2)-strlen("daemon/vhcs2_daemon")); |
|---|
| 68 | 76 | strcat(daemon_path, "engine/vhcs2-rqst-mngr"); |
|---|
| 69 | | #endif |
|---|
| 70 | | memset((void *) &qcommand, '\0', (size_t) sizeof(MAX_MSG_SIZE)); |
|---|
| 71 | | #if !defined(__OpenBSD__) && !defined(__FreeBSD__) |
|---|
| 72 | | sprintf(qcommand, |
|---|
| 73 | | "%s 1>%s/%s.%ld 2>%s/%s.%ld", |
|---|
| 74 | | daemon_path, |
|---|
| 75 | | LOG_DIR, |
|---|
| 76 | | STDOUT_LOG, |
|---|
| 77 | | (long int) tim, |
|---|
| 78 | | LOG_DIR, |
|---|
| 79 | | STDERR_LOG, |
|---|
| 80 | | (long int) tim); |
|---|
| 81 | | #else |
|---|
| 82 | | sprintf(qcommand, |
|---|
| 83 | | "%s 1>%s/%s.%ld 2>%s/%s.%ld", |
|---|
| 84 | | QUERY_CMD, |
|---|
| 85 | | LOG_DIR, |
|---|
| 86 | | STDOUT_LOG, |
|---|
| 87 | | (long int) tim, |
|---|
| 88 | | LOG_DIR, |
|---|
| 89 | | STDERR_LOG, |
|---|
| 90 | | (long int) tim); |
|---|
| 91 | | #endif |
|---|
| 92 | | system(qcommand); |
|---|
| | 77 | |
|---|
| | 78 | fdres = open ( "/dev/null", O_RDONLY ); |
|---|
| | 79 | if(fdres == -1) |
|---|
| | 80 | { |
|---|
| | 81 | say("Error in reopening stdin: %s", strerror(errno) ); |
|---|
| | 82 | exit(128); |
|---|
| | 83 | } |
|---|
| | 84 | dupres = dup2(fdres, 0); /* reassign 0*/ |
|---|
| | 85 | if( dupres == -1) |
|---|
| | 86 | { |
|---|
| | 87 | say("Error in reassigning stdin: %s", strerror(errno) ); |
|---|
| | 88 | exit(128); |
|---|
| | 89 | } |
|---|
| | 90 | else if( dupres != fdres) close (fdres); |
|---|
| | 91 | |
|---|
| | 92 | memset(logfile, 0, sizeof (logfile)); |
|---|
| | 93 | sprintf(logfile, "%s.%ld", LOG_DIR"/"STDOUT_LOG , (long int) tim); |
|---|
| | 94 | fdres = creat( logfile, S_IRUSR | S_IWUSR ); |
|---|
| | 95 | if(fdres == -1) |
|---|
| | 96 | { |
|---|
| | 97 | say("Error in opening stdout: %s", strerror(errno) ); |
|---|
| | 98 | exit(128); |
|---|
| | 99 | } |
|---|
| | 100 | dupres = dup2(fdres, 0); /* reassign 0*/ |
|---|
| | 101 | if( dupres == -1) |
|---|
| | 102 | { |
|---|
| | 103 | say("Error in reassigning stdout: %s", strerror(errno) ); |
|---|
| | 104 | exit(128); |
|---|
| | 105 | } |
|---|
| | 106 | else if( dupres != fdres) close (fdres); |
|---|
| | 107 | |
|---|
| | 108 | memset(logfile, 0, sizeof (logfile)); |
|---|
| | 109 | sprintf(logfile, "%s.%ld", LOG_DIR"/"STDERR_LOG , (long int) tim); |
|---|
| | 110 | fdres = creat( logfile, S_IRUSR | S_IWUSR ); |
|---|
| | 111 | if(fdres == -1) |
|---|
| | 112 | { |
|---|
| | 113 | say("Error in opening stderr: %s", strerror(errno) ); |
|---|
| | 114 | exit(128); |
|---|
| | 115 | } |
|---|
| | 116 | dupres = dup2(fdres, 0); /* reassign 0*/ |
|---|
| | 117 | if( dupres == -1) |
|---|
| | 118 | { |
|---|
| | 119 | say("Error in reassigning stderr: %s", strerror(errno) ); |
|---|
| | 120 | exit(128); |
|---|
| | 121 | } |
|---|
| | 122 | else if( dupres != fdres) close (fdres); |
|---|
| | 123 | |
|---|
| | 124 | execl( daemon_path, "vhcs2-rqst-mngr" ,(char*)NULL ); |
|---|
| | 125 | |
|---|
| 93 | 126 | exit(0); |
|---|
| 94 | 127 | #if !defined(__OpenBSD__) && !defined(__FreeBSD__) |
|---|
|