//
// lws_plat_drop_app_privileges from 0xbc2a3c to 0xbc2b14 (216 bytes)
//
// 2 xrefs:
// > lws_create_context @ 0xbbf720
// > ??> @ 0x7d040
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
__int64 __fastcall lws_plat_drop_app_privileges(__int64 a1)
{
__uid_t v2; // w0
struct passwd *v3; // x0
const char **p_pw_name; // x20
int *v5; // x0
char *v6; // x0
__int64 result; // x0
int *v8; // x0
char *v9; // x0
v2 = *(_DWORD *)(a1 + 96);
if ( v2 != -1 )
{
v3 = getpwuid(v2);
p_pw_name = (const char **)&v3->pw_name;
if ( v3 )
{
initgroups(v3->pw_name, *(_DWORD *)(a1 + 92));
if ( setuid(*(_DWORD *)(a1 + 96)) )
{
v5 = (int *)__errno();
v6 = strerror(*v5);
lws_log(2, "setuid: %s\n", v6);
}
else
{
lws_log(4, " Set privs to user '%s'\n", *p_pw_name);
}
}
else
{
lws_log(2, "getpwuid: unable to find uid %d", *(_DWORD *)(a1 + 96));
}
}
result = *(unsigned int *)(a1 + 92);
if ( (_DWORD)result != -1 )
{
result = setgid(result);
if ( (_DWORD)result )
{
v8 = (int *)__errno();
v9 = strerror(*v8);
return lws_log(2, "setgid: %s\n", v9);
}
}
return result;
}