Changeset 1939
- Timestamp:
- 05/12/2007 22:40:01 (4 years ago)
- File:
-
- 1 edited
-
box/chris/general/lib/win32/emu.cpp (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
box/chris/general/lib/win32/emu.cpp
r1814 r1939 165 165 struct passwd gTempPasswd; 166 166 167 bool EnableBackupRights( void)167 bool EnableBackupRights() 168 168 { 169 169 HANDLE hToken; … … 171 171 172 172 //open current process to adjust privileges 173 if( !OpenProcessToken( GetCurrentProcess( ), 174 TOKEN_ADJUST_PRIVILEGES, 175 &hToken )) 176 { 177 printf( "Cannot open process token: error %d\n", 178 (int)GetLastError() ); 173 if(!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, 174 &hToken)) 175 { 176 ::syslog(LOG_ERR, "Failed to open process token: %s", 177 GetErrorMessage(GetLastError()).c_str()); 179 178 return false; 180 179 } … … 183 182 //first, look up the LUID for the backup privilege 184 183 185 if( !LookupPrivilegeValue( NULL, //this system 184 if (!LookupPrivilegeValue( 185 NULL, //this system 186 186 SE_BACKUP_NAME, //the name of the privilege 187 &( token_priv.Privileges[0].Luid )) ) //result 188 { 189 printf( "Cannot lookup backup privilege: error %d\n", 190 (int)GetLastError( ) ); 187 &( token_priv.Privileges[0].Luid ))) //result 188 { 189 ::syslog(LOG_ERR, "Failed to lookup backup privilege: %s", 190 GetErrorMessage(GetLastError()).c_str()); 191 CloseHandle(hToken); 191 192 return false; 192 193 } … … 199 200 // any need to save current state 200 201 201 if( !AdjustTokenPrivileges( hToken, //our process token 202 if (!AdjustTokenPrivileges( 203 hToken, //our process token 202 204 false, //we're not disabling everything 203 205 &token_priv, //address of structure 204 sizeof( token_priv), //size of structure205 NULL, NULL )) //don't save current state206 sizeof(token_priv), //size of structure 207 NULL, NULL)) //don't save current state 206 208 { 207 209 //this function is a little tricky - if we were adjusting 208 210 //more than one privilege, it could return success but not 209 211 //adjust them all - in the general case, you need to trap this 210 printf( "Could not enable backup privileges: error %d\n", 211 (int)GetLastError( ) ); 212 ::syslog(LOG_ERR, "Failed to enable backup privilege: %s", 213 GetErrorMessage(GetLastError()).c_str()); 214 CloseHandle(hToken); 212 215 return false; 213 216 214 217 } 215 else 216 { 217 return true; 218 } 218 219 CloseHandle(hToken); 220 return true; 219 221 } 220 222 … … 703 705 ULARGE_INTEGER conv; 704 706 conv.HighPart = fi.nFileIndexHigh; 705 conv.LowPart = fi.nFileIndexLow;707 conv.LowPart = fi.nFileIndexLow; 706 708 st->st_ino = (_ino_t)conv.QuadPart; 707 709 … … 717 719 else 718 720 { 719 // size of the file 720 LARGE_INTEGER st_size; 721 memset(&st_size, 0, sizeof(st_size)); 722 723 if (!GetFileSizeEx(hdir, &st_size)) 724 { 725 ::syslog(LOG_WARNING, "Failed to get file size: " 726 "%s", GetErrorMessage(GetLastError()).c_str()); 727 errno = EACCES; 728 return -1; 729 } 730 731 conv.HighPart = st_size.HighPart; 732 conv.LowPart = st_size.LowPart; 721 conv.HighPart = fi.nFileSizeHigh; 722 conv.LowPart = fi.nFileSizeLow; 733 723 st->st_size = (_off_t)conv.QuadPart; 734 724 } … … 1079 1069 1080 1070 pDir->name = ConvertUtf8ToWideString(dirName.c_str()); 1081 // We are responsible for freeing dir->name 1071 // We are responsible for freeing dir->name with delete[] 1082 1072 1083 1073 if (pDir->name == NULL)
Note: See TracChangeset
for help on using the changeset viewer.
