Changeset 910 for trunk/src/z-file.c
- Timestamp:
- 05/17/08 07:40:39 (3 months ago)
- Files:
-
- trunk/src/z-file.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/z-file.c
r894 r910 31 31 32 32 #ifdef MACH_O_CARBON 33 # include < SystemConfiguration/SCDynamicStoreCopySpecific.h>33 # include <Carbon/Carbon.h> 34 34 #endif 35 35 … … 148 148 } 149 149 150 #ifndef MACH_O_CARBON 151 150 152 /* Fallback -- try the "current" user */ 151 153 if (username[0] == '\0') … … 153 155 154 156 /* Look up a user (or "current" user) */ 155 #ifndef MACH_O_CARBON156 157 if (username) pw = getpwnam(username); 157 158 else pw = getpwuid(getuid()); 158 159 159 #else /* MACH_O_CARBON */ 160 160 161 /* On Macs look up the console user to avoid problems with invalid root detection */ 162 uid_t uid; 163 SCDynamicStoreCopyConsoleUser(NULL, &uid, NULL); 164 pw = getpwuid(uid); 161 /* On Macs getlogin() can incorrectly return root, so get the username via system frameworks */ 162 CFStringRef cfusername = CSCopyUserName(TRUE); 163 CFIndex cfbufferlength = CFStringGetMaximumSizeForEncoding(CFStringGetLength(cfusername), kCFStringEncodingUTF8) + 1; 164 char *macusername = mem_alloc(cfbufferlength); 165 CFStringGetCString(cfusername, macusername, cfbufferlength, kCFStringEncodingUTF8); 166 CFRelease(cfusername); 167 168 /* Look up the user */ 169 pw = getpwnam(macusername); 170 mem_free(macusername); 165 171 #endif /* !MACH_O_CARBON */ 166 172 167 173 if (!pw) return; 168 174
