Ejemplo n.º 1
0
Bool
DnDStagingDirectoryUsable(ConstUnicode pathName)  // IN:
{
   struct stat buf;

   if (Posix_Stat(pathName, &buf) < 0) {
      return FALSE;
   }

   return buf.st_uid == Id_GetEUid();
}
Ejemplo n.º 2
0
void
Id_EndSuperUser(uid_t uid)  // IN:
{
   if ((uid != (uid_t) -1) && (uid != Id_GetEUid())) {
      ASSERT(uid != 0);  // Don't allow cheating like this

#if defined(__APPLE__)
      if (syscall(SYS_settid, uid, getgid()) == -1) {
         Log("Failed to release super user privileges.\n");
      }
#else
      Id_SetRESUid((uid_t) -1, uid, (uid_t) -1); // revert to uid
#endif
   }
}
Ejemplo n.º 3
0
uid_t
Id_BeginSuperUser(void)
{
   uid_t uid = Id_GetEUid();

   ASSERT_NOT_IMPLEMENTED(uid != (uid_t) -1);

   if (uid == 0) {
      uid = (uid_t) -1; // already root; nothing to do
   } else {
#if defined(__APPLE__)
      syscall(SYS_settid, KAUTH_UID_NONE, KAUTH_GID_NONE /* Ignored. */);
#else
      Id_SetRESUid((uid_t) -1, (uid_t) 0, (uid_t) -1); // effectively root
#endif
   }

   return uid;
}
Ejemplo n.º 4
0
Bool
ProcMgr_GetImpersonatedUserInfo(char **userName,            // OUT
                                char **homeDir)             // OUT
{
   char buffer[BUFSIZ];
   struct passwd pw;
   struct passwd *ppw;

   *userName = NULL;
   *homeDir = NULL;

   ppw = &pw;
   if ((ppw = getpwuid_r(Id_GetEUid(), &pw, buffer, sizeof buffer)) == NULL) {
      return FALSE;
   }

   *userName = Unicode_Alloc(ppw->pw_name, STRING_ENCODING_DEFAULT);
   *homeDir = Unicode_Alloc(ppw->pw_dir, STRING_ENCODING_DEFAULT);

   return TRUE;
}
Ejemplo n.º 5
0
uid_t
Id_BeginSuperUser(void)
{
   uid_t uid = Id_GetEUid();

   VERIFY(uid != (uid_t) -1);

   if (uid == 0) {
      uid = (uid_t) -1; // already root; nothing to do
   } else {
#if defined(__APPLE__)
#if TARGET_OS_IPHONE
      Warning("XXXIOS: implement %s\n", __func__);
#else
      syscall(SYS_settid, KAUTH_UID_NONE, KAUTH_GID_NONE /* Ignored. */);
#endif
#else
      Id_SetRESUid((uid_t) -1, (uid_t) 0, (uid_t) -1); // effectively root
#endif
   }

   return uid;
}