summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormk <mk@openbsd.org>2006-05-28 01:35:38 +0000
committermk <mk@openbsd.org>2006-05-28 01:35:38 +0000
commit85f6bd4922c7082fde0d171f080909e7da2e1b87 (patch)
tree202e4ac69cb5d92eedd4aaf943bef57d35ee08ac
parentInclude device id in hotplug events. This will be used by ntpd to check (diff)
downloadwireguard-openbsd-85f6bd4922c7082fde0d171f080909e7da2e1b87.tar.xz
wireguard-openbsd-85f6bd4922c7082fde0d171f080909e7da2e1b87.zip
Include device id in hotplug event logging. id is passed as new
script parameter so only scripts that are picky about arg count needs updating. ok henning.
-rw-r--r--usr.sbin/hotplugd/hotplugd.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/usr.sbin/hotplugd/hotplugd.c b/usr.sbin/hotplugd/hotplugd.c
index 6d5e0289414..cca952d00ab 100644
--- a/usr.sbin/hotplugd/hotplugd.c
+++ b/usr.sbin/hotplugd/hotplugd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hotplugd.c,v 1.5 2006/04/05 08:22:21 grange Exp $ */
+/* $OpenBSD: hotplugd.c,v 1.6 2006/05/28 01:35:38 mk Exp $ */
/*
* Copyright (c) 2004 Alexander Yurchenko <grange@openbsd.org>
*
@@ -48,7 +48,7 @@ volatile sig_atomic_t quit = 0;
char *device = _PATH_DEV_HOTPLUG;
int devfd = -1;
-void exec_script(const char *, int, char *);
+void exec_script(const char *, int, char *, int);
void sigchild(int);
void sigquit(int);
@@ -104,16 +104,16 @@ main(int argc, char *argv[])
switch (he.he_type) {
case HOTPLUG_DEVAT:
- syslog(LOG_INFO, "%s attached, class %d",
- he.he_devname, he.he_devclass);
+ syslog(LOG_INFO, "%s attached, class %d, id %d",
+ he.he_devname, he.he_devclass, he.he_devid);
exec_script(_PATH_ETC_HOTPLUG_ATTACH, he.he_devclass,
- he.he_devname);
+ he.he_devname, he.he_devid);
break;
case HOTPLUG_DEVDT:
- syslog(LOG_INFO, "%s detached, class %d",
- he.he_devname, he.he_devclass);
+ syslog(LOG_INFO, "%s detached, class %d id %d",
+ he.he_devname, he.he_devclass, he.he_devid);
exec_script(_PATH_ETC_HOTPLUG_DETACH, he.he_devclass,
- he.he_devname);
+ he.he_devname, he.he_devid);
break;
default:
syslog(LOG_NOTICE, "unknown event (0x%x)", he.he_type);
@@ -129,12 +129,14 @@ main(int argc, char *argv[])
}
void
-exec_script(const char *file, int class, char *name)
+exec_script(const char *file, int class, char *name, int id)
{
char strclass[8];
+ char strid[8];
pid_t pid;
snprintf(strclass, sizeof(strclass), "%d", class);
+ snprintf(strid, sizeof(strid), "%d", id);
if (access(file, X_OK | R_OK))
/* do nothing if file can't be accessed */
@@ -146,7 +148,7 @@ exec_script(const char *file, int class, char *name)
}
if (pid == 0) {
/* child process */
- execl(file, basename(file), strclass, name, (char *)NULL);
+ execl(file, basename(file), strclass, name, strid, (char *)NULL);
syslog(LOG_ERR, "execl %s: %m", file);
_exit(1);
/* NOTREACHED */