};
struct uwrap {
+ pthread_t tid;
+
struct {
void *handle;
struct uwrap_libc_fns fns;
{
uwrap.enabled = true;
+ /* We need to update to the new tid if we fork */
+ uwrap.tid = pthread_self();
+
UWRAP_UNLOCK(libc_symbol_binding);
UWRAP_UNLOCK(uwrap_id);
}
exit(-1);
}
+ uwrap.tid = tid;
uwrap.enabled = true;
UWRAP_LOG(UWRAP_LOG_DEBUG,
if (suid != (uid_t)-1) {
id->suid = suid;
}
+
+ /* Check If syscall is called from main thread. */
+ if (pthread_equal(id->tid, uwrap.tid)) {
+ if (ruid != (uid_t)-1) {
+ uwrap.ruid = ruid;
+ }
+
+ if (euid != (uid_t)-1) {
+ uwrap.euid = euid;
+ }
+
+ if (suid != (uid_t)-1) {
+ uwrap.suid = suid;
+ }
+ }
+
UWRAP_UNLOCK(uwrap_id);
return 0;
if (sgid != (gid_t)-1) {
id->sgid = sgid;
}
+
+ if (pthread_equal(id->tid, uwrap.tid)) {
+ if (rgid != (gid_t)-1) {
+ uwrap.rgid = rgid;
+ }
+
+ if (egid != (gid_t)-1) {
+ uwrap.egid = egid;
+ }
+
+ if (sgid != (gid_t)-1) {
+ uwrap.sgid = sgid;
+ }
+ }
UWRAP_UNLOCK(uwrap_id);
return 0;