#include <sys/un.h>
#include <time.h>
#include <unistd.h>
-#include <limits.h>
#define ksyslog klogctl
extern int ksyslog(int type, char *buf, int len);
/* Note: There is also a function called "message()" in init.c */
/* Print a message to the log file. */
static void message(char *fmt, ...)
- __attribute__ ((format (printf, 1, 2)));
+ __attribute__ ((format (printf, 1, 2)));
static void message(char *fmt, ...)
{
int fd;
int sock_fd;
fd_set readfds;
char lfile[PATH_MAX];
- int t = readlink(_PATH_LOG, lfile, sizeof(lfile) - 1); /* Resolve symlinks */
/* Set up sig handlers */
signal (SIGINT, quit_signal);
signal (SIGALRM, domark);
alarm (MarkInterval);
- if (t == -1)
- strncpy(lfile, _PATH_LOG, sizeof(lfile));
- else
- lfile[t] = '\0';
+ /* create the syslog file so realpath() can work
+ * (the ugle close(open()) stuff is just a cheap
+ * touch command that avoids using system (system
+ * is always a bad thing to use) */
+ close(open("touch " _PATH_LOG, O_RDWR | O_CREAT, 0644));
+ if (realpath(_PATH_LOG, lfile) == NULL) {
+ perror("Could not resolv path to " _PATH_LOG);
+ exit (FALSE);
+ }
unlink (lfile);
n_read = read (fd, buf, BUFSIZE);
if (n_read < 0) {
+ // FIXME .. fd isn't set
perror ("read error");
goto close_fd;
}
#include <sys/un.h>
#include <time.h>
#include <unistd.h>
-#include <limits.h>
#define ksyslog klogctl
extern int ksyslog(int type, char *buf, int len);
/* Note: There is also a function called "message()" in init.c */
/* Print a message to the log file. */
static void message(char *fmt, ...)
- __attribute__ ((format (printf, 1, 2)));
+ __attribute__ ((format (printf, 1, 2)));
static void message(char *fmt, ...)
{
int fd;
int sock_fd;
fd_set readfds;
char lfile[PATH_MAX];
- int t = readlink(_PATH_LOG, lfile, sizeof(lfile) - 1); /* Resolve symlinks */
/* Set up sig handlers */
signal (SIGINT, quit_signal);
signal (SIGALRM, domark);
alarm (MarkInterval);
- if (t == -1)
- strncpy(lfile, _PATH_LOG, sizeof(lfile));
- else
- lfile[t] = '\0';
+ /* create the syslog file so realpath() can work
+ * (the ugle close(open()) stuff is just a cheap
+ * touch command that avoids using system (system
+ * is always a bad thing to use) */
+ close(open("touch " _PATH_LOG, O_RDWR | O_CREAT, 0644));
+ if (realpath(_PATH_LOG, lfile) == NULL) {
+ perror("Could not resolv path to " _PATH_LOG);
+ exit (FALSE);
+ }
unlink (lfile);
n_read = read (fd, buf, BUFSIZE);
if (n_read < 0) {
+ // FIXME .. fd isn't set
perror ("read error");
goto close_fd;
}