mirror of
https://github.com/sheumann/hush.git
synced 2024-09-12 00:55:11 +00:00
small size reduction by Bernhard Fischer <rep.nop@aon.at>
This commit is contained in:
parent
db1edde6d8
commit
bae7948a5a
@ -290,9 +290,6 @@ static void log_locally(char *msg)
|
|||||||
goto reopen;
|
goto reopen;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
#if ENABLE_FEATURE_ROTATE_LOGFILE
|
|
||||||
struct stat statf;
|
|
||||||
#endif
|
|
||||||
reopen:
|
reopen:
|
||||||
logFD = device_open(logFilePath, O_WRONLY | O_CREAT
|
logFD = device_open(logFilePath, O_WRONLY | O_CREAT
|
||||||
| O_NOCTTY | O_APPEND | O_NONBLOCK);
|
| O_NOCTTY | O_APPEND | O_NONBLOCK);
|
||||||
@ -307,9 +304,13 @@ static void log_locally(char *msg)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#if ENABLE_FEATURE_ROTATE_LOGFILE
|
#if ENABLE_FEATURE_ROTATE_LOGFILE
|
||||||
|
{
|
||||||
|
struct stat statf;
|
||||||
|
|
||||||
isRegular = (fstat(logFD, &statf) == 0 && (statf.st_mode & S_IFREG));
|
isRegular = (fstat(logFD, &statf) == 0 && (statf.st_mode & S_IFREG));
|
||||||
/* bug (mostly harmless): can wrap around if file > 4gb */
|
/* bug (mostly harmless): can wrap around if file > 4gb */
|
||||||
curFileSize = statf.st_size;
|
curFileSize = statf.st_size;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -381,12 +382,12 @@ static void parse_fac_prio_20(int pri, char *res20)
|
|||||||
* that there is no timestamp, short-cutting the test. */
|
* that there is no timestamp, short-cutting the test. */
|
||||||
static void timestamp_and_log(int pri, char *msg, int len)
|
static void timestamp_and_log(int pri, char *msg, int len)
|
||||||
{
|
{
|
||||||
time_t now;
|
|
||||||
char *timestamp;
|
char *timestamp;
|
||||||
|
|
||||||
if (len < 16 || msg[3] != ' ' || msg[6] != ' '
|
if (len < 16 || msg[3] != ' ' || msg[6] != ' '
|
||||||
|| msg[9] != ':' || msg[12] != ':' || msg[15] != ' '
|
|| msg[9] != ':' || msg[12] != ':' || msg[15] != ' '
|
||||||
) {
|
) {
|
||||||
|
time_t now;
|
||||||
time(&now);
|
time(&now);
|
||||||
timestamp = ctime(&now) + 4;
|
timestamp = ctime(&now) + 4;
|
||||||
} else {
|
} else {
|
||||||
@ -494,9 +495,7 @@ static void do_syslogd(void)
|
|||||||
strncpy(sunx.sun_path, dev_log_name, sizeof(sunx.sun_path));
|
strncpy(sunx.sun_path, dev_log_name, sizeof(sunx.sun_path));
|
||||||
sock_fd = xsocket(AF_UNIX, SOCK_DGRAM, 0);
|
sock_fd = xsocket(AF_UNIX, SOCK_DGRAM, 0);
|
||||||
addrLength = sizeof(sunx.sun_family) + strlen(sunx.sun_path);
|
addrLength = sizeof(sunx.sun_family) + strlen(sunx.sun_path);
|
||||||
if (bind(sock_fd, (struct sockaddr *) &sunx, addrLength) < 0) {
|
xbind(sock_fd, (struct sockaddr *) &sunx, addrLength);
|
||||||
bb_perror_msg_and_die("cannot connect to socket %s", dev_log_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (chmod(dev_log_name, 0666) < 0) {
|
if (chmod(dev_log_name, 0666) < 0) {
|
||||||
bb_perror_msg_and_die("cannot set permission on %s", dev_log_name);
|
bb_perror_msg_and_die("cannot set permission on %s", dev_log_name);
|
||||||
|
Loading…
Reference in New Issue
Block a user