Guillem Jover
25278891d8
Mark local functions as static
...
Warned-by: gcc
2021-02-28 05:30:25 +01:00
Guillem Jover
e832b7687e
closefrom: Use close_range() on Linux when available
...
Closes : !11
Based-on-patch-by: cptpcrd <cptpcrd.git@gmail.com >
Signed-off-by: Guillem Jover <guillem@hadrons.org >
2021-02-08 04:02:46 +01:00
cptpcrd
c4fca5bb4f
closefrom: Handle lowfd < 0 properly
...
More important if close_range() is going to be used, since casting
negative values to 'unsigned int' might hide the errors.
[guillem@hadrons.org: Minor coding style fix. ]
Signed-off-by: Guillem Jover <guillem@hadrons.org>
2021-02-08 04:02:46 +01:00
Guillem Jover
a1f79978e8
closefrom: Import some changes from sudo
...
Take most of the changes done in sudo, but preserve the existing local
changes and refactoring.
In addition, refactor pstat implementation into closefrom_pstat(), so
that the code is easier to read, and requires no conditional
declarations.
2021-02-08 04:02:46 +01:00
Guillem Jover
01b77f0dcf
Add support for GNU/kFreeBSD for closefrom() and getentropy()
2015-12-02 03:32:13 +01:00
Guillem Jover
8641d8aed7
Make closefrom_procfs() fail when reallocarray() fails
2015-09-24 05:28:58 +02:00
Guillem Jover
30e328cbf1
Do not close file descriptors while scanning the /proc filesystem
...
Closing file descriptors changes the content of the fd directories in
the /proc filesystem, which means readdir() might get very confused.
Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=85663
2015-09-23 07:59:34 +02:00
Guillem Jover
4cc43915f2
Move procfs based implementation into a new closefrom_procfs() function
2015-09-23 07:59:34 +02:00
Guillem Jover
34df142665
Refactor file descriptor closure into a new closefrom_close()
2015-09-23 07:59:34 +02:00
Guillem Jover
3881c4fc68
Update closefrom() function
...
Import from sudo. Adapt the build system to detect the required features.
2015-09-23 07:59:34 +02:00
Guillem Jover
943939d0e5
Add new closefrom() function
...
Code taken from sudo, man page from FreeBSD.
2012-05-29 04:36:23 +02:00