diff options
Diffstat (limited to 'syslogd.c')
| -rw-r--r-- | syslogd.c | 20 |
1 files changed, 10 insertions, 10 deletions
| @@ -181,7 +181,7 @@ static void logMessage (int pri, char *msg) | |||
| 181 | v->iov_len = strlen(msg); | 181 | v->iov_len = strlen(msg); |
| 182 | 182 | ||
| 183 | if ( -1 == writev(remotefd,iov, IOV_COUNT)){ | 183 | if ( -1 == writev(remotefd,iov, IOV_COUNT)){ |
| 184 | fatalError("syslogd: cannot write to remote file handle on" | 184 | error_msg_and_die("syslogd: cannot write to remote file handle on" |
| 185 | "%s:%d\n",RemoteHost,RemotePort); | 185 | "%s:%d\n",RemoteHost,RemotePort); |
| 186 | } | 186 | } |
| 187 | } | 187 | } |
| @@ -260,13 +260,13 @@ static void init_RemoteLog (void){ | |||
| 260 | remotefd = socket(AF_INET, SOCK_DGRAM, 0); | 260 | remotefd = socket(AF_INET, SOCK_DGRAM, 0); |
| 261 | 261 | ||
| 262 | if (remotefd < 0) { | 262 | if (remotefd < 0) { |
| 263 | fatalError("syslogd: cannot create socket\n"); | 263 | error_msg_and_die("syslogd: cannot create socket\n"); |
| 264 | } | 264 | } |
| 265 | 265 | ||
| 266 | hostinfo = (struct hostent *) gethostbyname(RemoteHost); | 266 | hostinfo = (struct hostent *) gethostbyname(RemoteHost); |
| 267 | 267 | ||
| 268 | if (!hostinfo) { | 268 | if (!hostinfo) { |
| 269 | fatalError("syslogd: cannot resolve remote host name [%s]\n", RemoteHost); | 269 | error_msg_and_die("syslogd: cannot resolve remote host name [%s]\n", RemoteHost); |
| 270 | } | 270 | } |
| 271 | 271 | ||
| 272 | remoteaddr.sin_family = AF_INET; | 272 | remoteaddr.sin_family = AF_INET; |
| @@ -278,7 +278,7 @@ static void init_RemoteLog (void){ | |||
| 278 | for future operations | 278 | for future operations |
| 279 | */ | 279 | */ |
| 280 | if ( 0 != (connect(remotefd, (struct sockaddr *) &remoteaddr, len))){ | 280 | if ( 0 != (connect(remotefd, (struct sockaddr *) &remoteaddr, len))){ |
| 281 | fatalError("syslogd: cannot connect to remote host %s:%d\n", RemoteHost, RemotePort); | 281 | error_msg_and_die("syslogd: cannot connect to remote host %s:%d\n", RemoteHost, RemotePort); |
| 282 | } | 282 | } |
| 283 | 283 | ||
| 284 | } | 284 | } |
| @@ -311,7 +311,7 @@ static void doSyslogd (void) | |||
| 311 | /* Create the syslog file so realpath() can work. */ | 311 | /* Create the syslog file so realpath() can work. */ |
| 312 | close (open (_PATH_LOG, O_RDWR | O_CREAT, 0644)); | 312 | close (open (_PATH_LOG, O_RDWR | O_CREAT, 0644)); |
| 313 | if (realpath (_PATH_LOG, lfile) == NULL) | 313 | if (realpath (_PATH_LOG, lfile) == NULL) |
| 314 | fatalError ("Could not resolve path to " _PATH_LOG ": %s\n", strerror (errno)); | 314 | error_msg_and_die ("Could not resolve path to " _PATH_LOG ": %s\n", strerror (errno)); |
| 315 | 315 | ||
| 316 | unlink (lfile); | 316 | unlink (lfile); |
| 317 | 317 | ||
| @@ -319,14 +319,14 @@ static void doSyslogd (void) | |||
| 319 | sunx.sun_family = AF_UNIX; | 319 | sunx.sun_family = AF_UNIX; |
| 320 | strncpy (sunx.sun_path, lfile, sizeof (sunx.sun_path)); | 320 | strncpy (sunx.sun_path, lfile, sizeof (sunx.sun_path)); |
| 321 | if ((sock_fd = socket (AF_UNIX, SOCK_STREAM, 0)) < 0) | 321 | if ((sock_fd = socket (AF_UNIX, SOCK_STREAM, 0)) < 0) |
| 322 | fatalError ("Couldn't obtain descriptor for socket " _PATH_LOG ": %s\n", strerror (errno)); | 322 | error_msg_and_die ("Couldn't obtain descriptor for socket " _PATH_LOG ": %s\n", strerror (errno)); |
| 323 | 323 | ||
| 324 | addrLength = sizeof (sunx.sun_family) + strlen (sunx.sun_path); | 324 | addrLength = sizeof (sunx.sun_family) + strlen (sunx.sun_path); |
| 325 | if ((bind (sock_fd, (struct sockaddr *) &sunx, addrLength)) || (listen (sock_fd, 5))) | 325 | if ((bind (sock_fd, (struct sockaddr *) &sunx, addrLength)) || (listen (sock_fd, 5))) |
| 326 | fatalError ("Could not connect to socket " _PATH_LOG ": %s\n", strerror (errno)); | 326 | error_msg_and_die ("Could not connect to socket " _PATH_LOG ": %s\n", strerror (errno)); |
| 327 | 327 | ||
| 328 | if (chmod (lfile, 0666) < 0) | 328 | if (chmod (lfile, 0666) < 0) |
| 329 | fatalError ("Could not set permission on " _PATH_LOG ": %s\n", strerror (errno)); | 329 | error_msg_and_die ("Could not set permission on " _PATH_LOG ": %s\n", strerror (errno)); |
| 330 | 330 | ||
| 331 | FD_ZERO (&fds); | 331 | FD_ZERO (&fds); |
| 332 | FD_SET (sock_fd, &fds); | 332 | FD_SET (sock_fd, &fds); |
| @@ -349,7 +349,7 @@ static void doSyslogd (void) | |||
| 349 | 349 | ||
| 350 | if ((n_ready = select (FD_SETSIZE, &readfds, NULL, NULL, NULL)) < 0) { | 350 | if ((n_ready = select (FD_SETSIZE, &readfds, NULL, NULL, NULL)) < 0) { |
| 351 | if (errno == EINTR) continue; /* alarm may have happened. */ | 351 | if (errno == EINTR) continue; /* alarm may have happened. */ |
| 352 | fatalError ("select error: %s\n", strerror (errno)); | 352 | error_msg_and_die ("select error: %s\n", strerror (errno)); |
| 353 | } | 353 | } |
| 354 | 354 | ||
| 355 | for (fd = 0; (n_ready > 0) && (fd < FD_SETSIZE); fd++) { | 355 | for (fd = 0; (n_ready > 0) && (fd < FD_SETSIZE); fd++) { |
| @@ -363,7 +363,7 @@ static void doSyslogd (void) | |||
| 363 | pid_t pid; | 363 | pid_t pid; |
| 364 | 364 | ||
| 365 | if ((conn = accept (sock_fd, (struct sockaddr *) &sunx, &addrLength)) < 0) { | 365 | if ((conn = accept (sock_fd, (struct sockaddr *) &sunx, &addrLength)) < 0) { |
| 366 | fatalError ("accept error: %s\n", strerror (errno)); | 366 | error_msg_and_die ("accept error: %s\n", strerror (errno)); |
| 367 | } | 367 | } |
| 368 | 368 | ||
| 369 | pid = fork(); | 369 | pid = fork(); |
