static void
AdjustPrivilege(const char* pkgname)
{
- void* handle = dlopen("libprivilege-control.so.0", RTLD_LAZY | RTLD_LOCAL);
- if (!handle)
- {
- fprintf(stderr, "Cannot open libprivilege-control.so.0\n");
- return;
- }
-
- char* msg = 0;
- dlerror();
-
- int (* ppriv_func)(const char*) = NULL;
-
- ppriv_func = reinterpret_cast <int (*)(const char*)>(dlsym(handle, "set_privilege"));
- msg = dlerror();
- if (msg != NULL)
- {
- fprintf(stderr, "Dlsym error: %s\n", msg);
-
- dlclose(handle);
- return;
- }
-
- int ret = (*ppriv_func)(pkgname);
- if (ret < 0)
- {
- fprintf(stderr, "set_privilege() returned %d\n", ret);
- }
-
- dlclose(handle);
+ set_privilege(pkgname);
}
extern "C" int capset(cap_user_header_t hdrp, const cap_user_data_t datap);