Release unused filedescriptors in the privileged X server process.

There is no reason to keep /dev/pci* and /dev/ttyC* open in this process.
pointed to  by deraadt. ok kettenis@ deraadt@
This commit is contained in:
matthieu
2020-04-20 18:17:25 +00:00
parent 806accb3da
commit ad9a065c46
6 changed files with 37 additions and 1 deletions

View File

@@ -375,6 +375,13 @@ OsVendorInit(void)
} }
} }
#ifdef X_PRIVSEP
void
priv_vendor_init(void)
{
}
#endif
KdCardFuncs ephyrFuncs = { KdCardFuncs ephyrFuncs = {
ephyrCardInit, /* cardinit */ ephyrCardInit, /* cardinit */
ephyrScreenInitialize, /* scrinit */ ephyrScreenInitialize, /* scrinit */

View File

@@ -219,6 +219,13 @@ OsVendorInit(void)
{ {
} }
#ifdef X_PRIVSEP
void
priv_vendor_init(void)
{
}
#endif
void void
OsVendorFatalError(const char *f, va_list args) OsVendorFatalError(const char *f, va_list args)
{ {

View File

@@ -820,4 +820,15 @@ xf86DropPriv(void)
} }
} }
} }
/*
* Called in the privileged child
*/
void
priv_vendor_init(void)
{
/* release resources it won't need */
pci_system_cleanup();
close(xf86Info.consoleFd);
}
#endif #endif

View File

@@ -156,6 +156,14 @@ OsVendorInit(void)
return; return;
} }
#ifdef X_PRIVSEP
void
priv_vendor_init(void)
{
return;
}
#endif
void void
OsVendorFatalError(const char *f, va_list args) OsVendorFatalError(const char *f, va_list args)
{ {

View File

@@ -314,6 +314,8 @@ extern _X_EXPORT int
ChownLock(uid_t, gid_t); ChownLock(uid_t, gid_t);
extern _X_EXPORT int extern _X_EXPORT int
priv_open_device(const char *); priv_open_device(const char *);
extern _X_EXPORT void
priv_vendor_init(void);
#endif #endif
extern _X_EXPORT int extern _X_EXPORT int

View File

@@ -1,4 +1,4 @@
/* $OpenBSD: privsep.c,v 1.31 2019/06/11 14:51:34 jcs Exp $ */ /* $OpenBSD: privsep.c,v 1.32 2020/04/20 18:17:26 matthieu Exp $ */
/* /*
* Copyright 2001 Niels Provos <provos@citi.umich.edu> * Copyright 2001 Niels Provos <provos@citi.umich.edu>
* All rights reserved. * All rights reserved.
@@ -279,6 +279,7 @@ priv_init(uid_t uid, gid_t gid)
signal(i, SIG_DFL); signal(i, SIG_DFL);
setproctitle("[priv]"); setproctitle("[priv]");
close(socks[1]); close(socks[1]);
priv_vendor_init();
for (dev = allowed_devices; dev->name != NULL; dev++) { for (dev = allowed_devices; dev->name != NULL; dev++) {
if (unveil(dev->name, "rw") == -1) if (unveil(dev->name, "rw") == -1)