Remove malloc() dependency on pledge() / unveil()

This change also fixes a bug with gettid() being incorrect after fork().
We now implement the ENOENT behavior for getauxval(). The getuid() etc.
system calls are now faster too. Plus issetugid() will work on BSDs.
This commit is contained in:
Justine Tunney 2022-07-24 19:40:32 -07:00
parent c921dc78f0
commit 3d2cf95af1
33 changed files with 270 additions and 100 deletions

View file

@ -16,10 +16,8 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/dce.h"
#include "libc/runtime/runtime.h"
#include "libc/str/str.h"
#include "libc/sysv/consts/auxv.h"
#include "libc/sysv/errfuns.h"
/**
* Returns auxiliary value, or zero if kernel didn't provide it.
@ -27,9 +25,10 @@
* This function is typically regarded as a libc implementation detail;
* thus, the source code is the documentation.
*
* @return aux val or 0 if not available
* @return auxiliary value or 0 if `at` not found
* @see libc/sysv/consts.sh
* @see System Five Application Binary Interface § 3.4.3
* @error ENOENT when value not found
* @asyncsignalsafe
*/
unsigned long getauxval(unsigned long at) {
@ -39,5 +38,6 @@ unsigned long getauxval(unsigned long at) {
return ap[1];
}
}
enoent();
return 0;
}