OpenBSD Devname changes

This commit is contained in:
Jake S
2021-02-10 22:17:46 +00:00
parent 9f08770c08
commit a2775715ec

View File

@@ -555,6 +555,12 @@ static int os_open_tun(main_server_st * s, struct proc_st *proc)
if (fd < 0)
return fd;
#if defined(__OpenBSD__)
/* OpenBSD's devname does not return the correct name if unit_nr>=4.
* See https://gitlab.com/openconnect/ocserv/-/issues/399
*/
snprintf(proc->tun_lease.name, sizeof(proc->tun_lease.name), "tun%d", unit_nr);
#else
/* get tun name */
ret = fstat(fd, &st);
if (ret < 0) {
@@ -564,6 +570,7 @@ static int os_open_tun(main_server_st * s, struct proc_st *proc)
return -1;
}
strlcpy(proc->tun_lease.name, devname(st.st_rdev, S_IFCHR), sizeof(proc->tun_lease.name));
#endif
if (fd >= 0) {
int i, e, ret;