DWORD LwKrb5MoveCCacheToUserPath( krb5_context ctx, PCSTR pszNewCacheName, uid_t uid, gid_t gid ) { DWORD dwError = LW_ERROR_SUCCESS; PSTR pszCachePath = NULL; PCSTR pszCachePathReal = NULL; dwError = LwKrb5GetUserCachePath( uid, KRB5_File_Cache, &pszCachePath); BAIL_ON_LW_ERROR(dwError); if (strncasecmp(pszCachePath, "FILE:", sizeof("FILE:")-1)) { dwError = LW_ERROR_INTERNAL; BAIL_ON_LW_ERROR(dwError); } else { pszCachePathReal = pszCachePath + sizeof("FILE:") - 1; } dwError = LwMoveFile(pszNewCacheName, pszCachePathReal); BAIL_ON_LW_ERROR(dwError); /* Let the user read and write to their cache file (before this, only * root was allowed to read and write the file). */ dwError = LwChangeOwner(pszCachePathReal, uid, gid); BAIL_ON_LW_ERROR(dwError); cleanup: LW_SAFE_FREE_STRING(pszCachePath); return dwError; error: goto cleanup; }
DWORD LwChangeOwnerAndPermissions( PCSTR pszPath, uid_t uid, gid_t gid, mode_t dwFileMode ) { DWORD dwError = 0; dwError = LwChangeOwner(pszPath, uid, gid); BAIL_ON_LW_ERROR(dwError); dwError = LwChangePermissions(pszPath, dwFileMode); BAIL_ON_LW_ERROR(dwError); error: return dwError; }