#include "path.h"
#include "fileutils.h"
#ifdef AGETTY_RELOAD
-#include "netaddrq.h"
+# include "netaddrq.h"
+# if defined(RTMGRP_IPV4_IFADDR) && defined(RTMGRP_IPV6_IFADDR)
+# define USE_NETLINK
+# endif
#endif
#include "logindefs.h"
*/
#ifdef AGETTY_RELOAD
# include <sys/inotify.h>
-# include <linux/netlink.h>
-# include <linux/rtnetlink.h>
# define AGETTY_RELOAD_FILENAME "/run/agetty.reload" /* trigger file */
# define AGETTY_RELOAD_FDNONE -2 /* uninitialized fd */
static int inotify_fd = AGETTY_RELOAD_FDNONE;
+#endif
+#ifdef USE_NETLINK
static uint32_t netlink_groups;
#endif
char *mem;
size_t mem_sz;
-#ifdef AGETTY_RELOAD
+#ifdef USE_NETLINK
struct ul_nl_data nl;
+#endif
+#ifdef AGETTY_RELOAD
char *mem_old;
#endif
unsigned int do_tcsetattr : 1,
};
struct issue issue = {
.mem = NULL,
-#ifdef AGETTY_RELOAD
+#ifdef USE_NETLINK
.nl.fd = -1
#endif
};
FD_SET(inotify_fd, &rfds);
nfds = max(nfds, inotify_fd);
}
+
+#ifdef USE_NETLINK
if (ie->nl.fd >= 0) {
FD_SET(ie->nl.fd, &rfds);
nfds = max(nfds, ie->nl.fd);
}
-
+#endif
/* If waiting fails, just fall through, presumably reading input will fail */
if (select(nfds + 1, &rfds, NULL, NULL, NULL) < 0)
return 1;
}
+#ifdef USE_NETLINK
if (ie->nl.fd >= 0 && FD_ISSET(ie->nl.fd, &rfds)) {
int rc;
while (!rc || rc == UL_NL_SOFT_ERROR);
/* Just drain the inotify buffer */
- } else if (inotify_fd >= 0 && FD_ISSET(inotify_fd, &rfds)) {
+ } else
+#endif /* USE_NETLINK */
+ if (inotify_fd >= 0 && FD_ISSET(inotify_fd, &rfds)) {
while (read(inotify_fd, buffer, sizeof (buffer)) > 0);
}
if (!(op->flags & F_ISSUE))
goto done;
-#ifdef AGETTY_RELOAD
+#ifdef USE_NETLINK
/* TODO:
* Two pass processing for eval_issue_file()
* Implement pass 1: Just evaluate list of netlink_groups (IP protocols) and
ul_nl_close(&(ie->nl));
ie->nl.fd = -1;
skip:
-#endif
+#endif /* USE_NETLINK */
/*
* The custom issue file or directory list specified by:
* agetty --issue-file <path[:path]...>
{
struct issue ie = {
.output = NULL,
-#ifdef AGETTY_RELOAD
+#ifdef USE_NETLINK
.nl.fd = -1
#endif
};
va_end(ap);
}
-#ifdef AGETTY_RELOAD
+#ifdef USE_NETLINK
static void print_iface_best(struct issue *ie,
const char *ifname,
uint8_t ifa_family)
if (!first)
fputs("\n", ie->output);
}
-#endif /* AGETTY_RELOAD */
+#endif /* USE_NETLINK */
/*
* parses \x{argument}, if not argument specified then returns NULL, the @fd
fprintf (ie->output, "%d ", users);
break;
}
-#if defined(RTMGRP_IPV4_IFADDR) && defined(RTMGRP_IPV6_IFADDR)
+#ifdef USE_NETLINK
case '4':
case '6':
{
}
}
break;
-#endif
+#endif /* USE_NETLINK */
default:
putc(c, ie->output);
break;