Mercurial > emacs
comparison src/w32.c @ 78028:3a8b85706c0c
(_wsa_errlist): Fix typo in error message.
(init_environment): Ignore any environment variable
from the registry having a null value.
author | Juanma Barranquero <lekktu@gmail.com> |
---|---|
date | Wed, 20 Jun 2007 08:46:20 +0000 |
parents | 9ad6c99cdc71 |
children | 922696f363b0 |
comparison
equal
deleted
inserted
replaced
78027:5131a632194a | 78028:3a8b85706c0c |
---|---|
111 extern Lisp_Object Vw32_get_true_file_attributes; | 111 extern Lisp_Object Vw32_get_true_file_attributes; |
112 extern int w32_num_mouse_buttons; | 112 extern int w32_num_mouse_buttons; |
113 | 113 |
114 | 114 |
115 /* | 115 /* |
116 Initialization states | 116 Initialization states |
117 */ | 117 */ |
118 static BOOL g_b_init_is_windows_9x; | 118 static BOOL g_b_init_is_windows_9x; |
119 static BOOL g_b_init_open_process_token; | 119 static BOOL g_b_init_open_process_token; |
120 static BOOL g_b_init_get_token_information; | 120 static BOOL g_b_init_get_token_information; |
121 static BOOL g_b_init_lookup_account_sid; | 121 static BOOL g_b_init_lookup_account_sid; |
484 | 484 |
485 Use the relative portion of the identifier authority value from | 485 Use the relative portion of the identifier authority value from |
486 the user-sid as the user id value (same for group id using the | 486 the user-sid as the user id value (same for group id using the |
487 primary group sid from the process token). */ | 487 primary group sid from the process token). */ |
488 | 488 |
489 char user_sid[256], name[256], domain[256]; | 489 char user_sid[256], name[256], domain[256]; |
490 DWORD length = sizeof (name), dlength = sizeof (domain), trash; | 490 DWORD length = sizeof (name), dlength = sizeof (domain), trash; |
491 HANDLE token = NULL; | 491 HANDLE token = NULL; |
492 SID_NAME_USE user_type; | 492 SID_NAME_USE user_type; |
493 | 493 |
494 if ( | 494 if (open_process_token (GetCurrentProcess (), TOKEN_QUERY, &token) |
495 open_process_token (GetCurrentProcess (), TOKEN_QUERY, &token) | 495 && get_token_information (token, TokenUser, |
496 && get_token_information ( | 496 (PVOID) user_sid, sizeof (user_sid), &trash) |
497 token, TokenUser, | 497 && lookup_account_sid (NULL, *((PSID *) user_sid), name, &length, |
498 (PVOID) user_sid, sizeof (user_sid), &trash) | 498 domain, &dlength, &user_type)) |
499 && lookup_account_sid ( | |
500 NULL, *((PSID *) user_sid), name, &length, | |
501 domain, &dlength, &user_type) | |
502 ) | |
503 { | 499 { |
504 strcpy (the_passwd.pw_name, name); | 500 strcpy (the_passwd.pw_name, name); |
505 /* Determine a reasonable uid value. */ | 501 /* Determine a reasonable uid value. */ |
506 if (stricmp ("administrator", name) == 0) | 502 if (stricmp ("administrator", name) == 0) |
507 { | 503 { |
522 /* restrict to conventional uid range for normal users */ | 518 /* restrict to conventional uid range for normal users */ |
523 the_passwd.pw_uid = the_passwd.pw_uid % 60001; | 519 the_passwd.pw_uid = the_passwd.pw_uid % 60001; |
524 | 520 |
525 /* Get group id */ | 521 /* Get group id */ |
526 if (get_token_information (token, TokenPrimaryGroup, | 522 if (get_token_information (token, TokenPrimaryGroup, |
527 (PVOID) user_sid, sizeof (user_sid), &trash)) | 523 (PVOID) user_sid, sizeof (user_sid), &trash)) |
528 { | 524 { |
529 SID_IDENTIFIER_AUTHORITY * pSIA; | 525 SID_IDENTIFIER_AUTHORITY * pSIA; |
530 | 526 |
531 pSIA = get_sid_identifier_authority (*((PSID *) user_sid)); | 527 pSIA = get_sid_identifier_authority (*((PSID *) user_sid)); |
532 the_passwd.pw_gid = ((pSIA->Value[2] << 24) + | 528 the_passwd.pw_gid = ((pSIA->Value[2] << 24) + |
539 else | 535 else |
540 the_passwd.pw_gid = the_passwd.pw_uid; | 536 the_passwd.pw_gid = the_passwd.pw_uid; |
541 } | 537 } |
542 } | 538 } |
543 /* If security calls are not supported (presumably because we | 539 /* If security calls are not supported (presumably because we |
544 are running under Windows 95), fallback to this. */ | 540 are running under Windows 95), fallback to this. */ |
545 else if (GetUserName (name, &length)) | 541 else if (GetUserName (name, &length)) |
546 { | 542 { |
547 strcpy (the_passwd.pw_name, name); | 543 strcpy (the_passwd.pw_name, name); |
548 if (stricmp ("administrator", name) == 0) | 544 if (stricmp ("administrator", name) == 0) |
549 the_passwd.pw_uid = 0; | 545 the_passwd.pw_uid = 0; |
1108 { | 1104 { |
1109 if (!getenv (env_vars[i].name)) | 1105 if (!getenv (env_vars[i].name)) |
1110 { | 1106 { |
1111 int dont_free = 0; | 1107 int dont_free = 0; |
1112 | 1108 |
1113 if ((lpval = w32_get_resource (env_vars[i].name, &dwType)) == NULL) | 1109 if ((lpval = w32_get_resource (env_vars[i].name, &dwType)) == NULL |
1110 /* Also ignore empty environment variables. */ | |
1111 || *lpval == 0) | |
1114 { | 1112 { |
1115 lpval = env_vars[i].def_value; | 1113 lpval = env_vars[i].def_value; |
1116 dwType = REG_EXPAND_SZ; | 1114 dwType = REG_EXPAND_SZ; |
1117 dont_free = 1; | 1115 dont_free = 1; |
1118 } | 1116 } |
2479 && (fh = CreateFile (name, 0, 0, NULL, OPEN_EXISTING, | 2477 && (fh = CreateFile (name, 0, 0, NULL, OPEN_EXISTING, |
2480 FILE_FLAG_BACKUP_SEMANTICS, NULL)) | 2478 FILE_FLAG_BACKUP_SEMANTICS, NULL)) |
2481 != INVALID_HANDLE_VALUE) | 2479 != INVALID_HANDLE_VALUE) |
2482 { | 2480 { |
2483 /* This is more accurate in terms of gettting the correct number | 2481 /* This is more accurate in terms of gettting the correct number |
2484 of links, but is quite slow (it is noticable when Emacs is | 2482 of links, but is quite slow (it is noticeable when Emacs is |
2485 making a list of file name completions). */ | 2483 making a list of file name completions). */ |
2486 BY_HANDLE_FILE_INFORMATION info; | 2484 BY_HANDLE_FILE_INFORMATION info; |
2487 | 2485 |
2488 if (GetFileInformationByHandle (fh, &info)) | 2486 if (GetFileInformationByHandle (fh, &info)) |
2489 { | 2487 { |
2964 WSAENOMORE , "No more operations allowed", /* not sure */ | 2962 WSAENOMORE , "No more operations allowed", /* not sure */ |
2965 WSAECANCELLED , "Operation cancelled", /* not sure */ | 2963 WSAECANCELLED , "Operation cancelled", /* not sure */ |
2966 WSAEINVALIDPROCTABLE , "Invalid procedure table from service provider", | 2964 WSAEINVALIDPROCTABLE , "Invalid procedure table from service provider", |
2967 WSAEINVALIDPROVIDER , "Invalid service provider version number", | 2965 WSAEINVALIDPROVIDER , "Invalid service provider version number", |
2968 WSAEPROVIDERFAILEDINIT , "Unable to initialize a service provider", | 2966 WSAEPROVIDERFAILEDINIT , "Unable to initialize a service provider", |
2969 WSASYSCALLFAILURE , "System call failured", | 2967 WSASYSCALLFAILURE , "System call failure", |
2970 WSASERVICE_NOT_FOUND , "Service not found", /* not sure */ | 2968 WSASERVICE_NOT_FOUND , "Service not found", /* not sure */ |
2971 WSATYPE_NOT_FOUND , "Class type not found", | 2969 WSATYPE_NOT_FOUND , "Class type not found", |
2972 WSA_E_NO_MORE , "No more resources available", /* really not sure */ | 2970 WSA_E_NO_MORE , "No more resources available", /* really not sure */ |
2973 WSA_E_CANCELLED , "Operation already cancelled", /* really not sure */ | 2971 WSA_E_CANCELLED , "Operation already cancelled", /* really not sure */ |
2974 WSAEREFUSED , "Operation refused", /* not sure */ | 2972 WSAEREFUSED , "Operation refused", /* not sure */ |
4158 GUI modes, since we had to fool windows into thinking emacs is a | 4156 GUI modes, since we had to fool windows into thinking emacs is a |
4159 console application to get console mode to work. */ | 4157 console application to get console mode to work. */ |
4160 SetConsoleCtrlHandler(shutdown_handler, TRUE); | 4158 SetConsoleCtrlHandler(shutdown_handler, TRUE); |
4161 } | 4159 } |
4162 | 4160 |
4163 /* end of nt.c */ | 4161 /* end of w32.c */ |
4164 | 4162 |
4165 /* arch-tag: 90442dd3-37be-482b-b272-ac752e3049f1 | 4163 /* arch-tag: 90442dd3-37be-482b-b272-ac752e3049f1 |
4166 (do not change this comment) */ | 4164 (do not change this comment) */ |