comparison src/w32.c @ 81416:4da3ed1bf5ad

(init_user_info): Fix weird formatting not following GNU coding guidelines.
author Juanma Barranquero <lekktu@gmail.com>
date Thu, 14 Jun 2007 10:01:04 +0000
parents 9ad6c99cdc71
children 5e608f6f217b
comparison
equal deleted inserted replaced
81415:7e22155b3083 81416:4da3ed1bf5ad
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;