*/
#ifndef lint
-static char rcsid[] = "$Id: sys-sunos4.c,v 1.8 1997/04/30 05:58:52 paulus Exp $";
+static char rcsid[] = "$Id: sys-sunos4.c,v 1.13 1999/03/12 06:07:23 paulus Exp $";
#endif
#include <stdio.h>
/*
* sys_check_options - check the options that the user specified
*/
-void
+int
sys_check_options()
{
+ return 1;
}
/* set mtu for ip as well */
memset(&ifr, 0, sizeof(ifr));
- strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
+ strlcpy(ifr.ifr_name, sizeof(ifr.ifr_name), ifname);
ifr.ifr_metric = link_mtu;
if (ioctl(sockfd, SIOCSIFMTU, &ifr) < 0) {
syslog(LOG_ERR, "Couldn't set IP MTU: %m");
{
struct ifreq ifr;
- strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
+ strlcpy(ifr.ifr_name, sizeof(ifr.ifr_name), ifname);
if (ioctl(sockfd, SIOCGIFFLAGS, &ifr) < 0) {
syslog(LOG_ERR, "Couldn't mark interface up (get): %m");
return 0;
{
struct ifreq ifr;
- strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
+ strlcpy(ifr.ifr_name, sizeof(ifr.ifr_name), ifname);
if (ioctl(sockfd, SIOCGIFFLAGS, &ifr) < 0) {
syslog(LOG_ERR, "Couldn't mark interface down (get): %m");
return 0;
struct ifreq ifr;
memset(&ifr, 0, sizeof(ifr));
- strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
+ strlcpy(ifr.ifr_name, sizeof(ifr.ifr_name), ifname);
ifr.ifr_addr.sa_family = AF_INET;
INET_ADDR(ifr.ifr_addr) = m;
if (ioctl(sockfd, SIOCSIFNETMASK, &ifr) < 0) {
* Check that the interface is up, and not point-to-point
* or loopback.
*/
- strncpy(ifreq.ifr_name, ifr->ifr_name, sizeof(ifreq.ifr_name));
+ strlcpy(ifreq.ifr_name, sizeof(ifreq.ifr_name), ifr->ifr_name);
if (ioctl(sockfd, SIOCGIFFLAGS, &ifreq) < 0)
continue;
if ((ifreq.ifr_flags &
syslog(LOG_ERR, "Couldn't open /dev/nit: %m");
return 0;
}
- strncpy(ifreq.ifr_name, ifr->ifr_name, sizeof(ifreq.ifr_name));
+ strlcpy(ifreq.ifr_name, sizeof(ifreq.ifr_name), ifr->ifr_name);
if (ioctl(nit_fd, NIOCBIND, &ifreq) < 0
|| ioctl(nit_fd, SIOCGIFADDR, &ifreq) < 0) {
syslog(LOG_ERR, "Couldn't get hardware address for %s: %m",
return 1;
}
+/*
+ * have_route_to - determine if the system has any route to
+ * a given IP address.
+ * For demand mode to work properly, we have to ignore routes
+ * through our own interface.
+ */
+int have_route_to(addr)
+ u_int32_t addr;
+{
+ return -1;
+}
+
#define WTMPFILE "/usr/adm/wtmp"
void
if ((fd = open(WTMPFILE, O_WRONLY|O_APPEND, 0)) < 0)
return;
if (!fstat(fd, &buf)) {
- (void)strncpy(ut.ut_line, line, sizeof(ut.ut_line));
- (void)strncpy(ut.ut_name, name, sizeof(ut.ut_name));
- (void)strncpy(ut.ut_host, host, sizeof(ut.ut_host));
+ strlcpy(ut.ut_line, sizeof(ut.ut_line), line);
+ strlcpy(ut.ut_name, sizeof(ut.ut_name), name);
+ strlcpy(ut.ut_host, sizeof(ut.ut_host), host);
(void)time(&ut.ut_time);
if (write(fd, (char *)&ut, sizeof(struct utmp)) != sizeof(struct utmp))
(void)ftruncate(fd, buf.st_size);
/*
* Check that the interface is up, and not point-to-point or loopback.
*/
- strncpy(ifreq.ifr_name, ifr->ifr_name, sizeof(ifreq.ifr_name));
+ strlcpy(ifreq.ifr_name, sizeof(ifreq.ifr_name), ifr->ifr_name);
if (ioctl(sockfd, SIOCGIFFLAGS, &ifreq) < 0)
continue;
if ((ifreq.ifr_flags & (IFF_UP|IFF_POINTOPOINT|IFF_LOOPBACK))
return 0;
}
+/*
+ * Use the hostid as part of the random number seed.
+ */
+int
+get_host_seed()
+{
+ return gethostid();
+}
+
/*
* Code for locking/unlocking the serial device.
* This code is derived from chat.c.
char hdb_lock_buffer[12];
int fd, pid, n;
char *p;
+ size_t l;
if ((p = strrchr(dev, '/')) != NULL)
dev = p + 1;
- lock_file = malloc(strlen(LOCK_PREFIX) + strlen(dev) + 1);
+ l = strlen(LOCK_PREFIX) + strlen(dev) + 1;
+ lock_file = malloc(l);
if (lock_file == NULL)
novm("lock file name");
- strcat(strcpy(lock_file, LOCK_PREFIX), dev);
+ slprintf(lock_file, l, "%s%s", LOCK_PREFIX, dev);
while ((fd = open(lock_file, O_EXCL | O_CREAT | O_RDWR, 0644)) < 0) {
if (errno == EEXIST