diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 4 | ||||
| -rw-r--r-- | src/w32.c | 24 |
2 files changed, 19 insertions, 9 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index bfe82a0d2a8..eee3f678e51 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,5 +1,9 @@ | |||
| 1 | 2008-02-16 Eli Zaretskii <eliz@gnu.org> | 1 | 2008-02-16 Eli Zaretskii <eliz@gnu.org> |
| 2 | 2 | ||
| 3 | * w32.c (init_user_info): Use TOKEN_USER and TOKEN_PRIMARY_GROUP | ||
| 4 | instead of char arrays. Enlarge the size of array passed to | ||
| 5 | get_token_information. | ||
| 6 | |||
| 3 | * font.c (Ffont_fill_gstring, Fget_font_glyphs): Fix compilation | 7 | * font.c (Ffont_fill_gstring, Fget_font_glyphs): Fix compilation |
| 4 | warnings. | 8 | warnings. |
| 5 | 9 | ||
| @@ -73,6 +73,7 @@ Boston, MA 02110-1301, USA. | |||
| 73 | #define _ANONYMOUS_STRUCT | 73 | #define _ANONYMOUS_STRUCT |
| 74 | #endif | 74 | #endif |
| 75 | #include <windows.h> | 75 | #include <windows.h> |
| 76 | #include <lmcons.h> | ||
| 76 | #include <shlobj.h> | 77 | #include <shlobj.h> |
| 77 | 78 | ||
| 78 | #ifdef HAVE_SOCKETS /* TCP connection support, if kernel can do it */ | 79 | #ifdef HAVE_SOCKETS /* TCP connection support, if kernel can do it */ |
| @@ -594,16 +595,20 @@ init_user_info () | |||
| 594 | the user-sid as the user id value (same for group id using the | 595 | the user-sid as the user id value (same for group id using the |
| 595 | primary group sid from the process token). */ | 596 | primary group sid from the process token). */ |
| 596 | 597 | ||
| 597 | char user_sid[256], name[256], domain[256]; | 598 | char name[UNLEN+1], domain[1025]; |
| 598 | DWORD length = sizeof (name), dlength = sizeof (domain), trash; | 599 | DWORD length = sizeof (name), dlength = sizeof (domain), trash; |
| 599 | HANDLE token = NULL; | 600 | HANDLE token = NULL; |
| 600 | SID_NAME_USE user_type; | 601 | SID_NAME_USE user_type; |
| 602 | unsigned char buf[1024]; | ||
| 603 | TOKEN_USER user_token; | ||
| 604 | TOKEN_PRIMARY_GROUP group_token; | ||
| 601 | 605 | ||
| 602 | if (open_process_token (GetCurrentProcess (), TOKEN_QUERY, &token) | 606 | if (open_process_token (GetCurrentProcess (), TOKEN_QUERY, &token) |
| 603 | && get_token_information (token, TokenUser, | 607 | && get_token_information (token, TokenUser, |
| 604 | (PVOID) user_sid, sizeof (user_sid), &trash) | 608 | (PVOID)buf, sizeof (buf), &trash) |
| 605 | && lookup_account_sid (NULL, *((PSID *) user_sid), name, &length, | 609 | && (memcpy (&user_token, buf, sizeof (user_token)), |
| 606 | domain, &dlength, &user_type)) | 610 | lookup_account_sid (NULL, user_token.User.Sid, name, &length, |
| 611 | domain, &dlength, &user_type))) | ||
| 607 | { | 612 | { |
| 608 | strcpy (the_passwd.pw_name, name); | 613 | strcpy (the_passwd.pw_name, name); |
| 609 | /* Determine a reasonable uid value. */ | 614 | /* Determine a reasonable uid value. */ |
| @@ -617,14 +622,14 @@ init_user_info () | |||
| 617 | /* Use the last sub-authority value of the RID, the relative | 622 | /* Use the last sub-authority value of the RID, the relative |
| 618 | portion of the SID, as user/group ID. */ | 623 | portion of the SID, as user/group ID. */ |
| 619 | DWORD n_subauthorities = | 624 | DWORD n_subauthorities = |
| 620 | *get_sid_sub_authority_count (*((PSID *) user_sid)); | 625 | *get_sid_sub_authority_count (user_token.User.Sid); |
| 621 | 626 | ||
| 622 | if (n_subauthorities < 1) | 627 | if (n_subauthorities < 1) |
| 623 | the_passwd.pw_uid = 0; /* the "World" RID */ | 628 | the_passwd.pw_uid = 0; /* the "World" RID */ |
| 624 | else | 629 | else |
| 625 | { | 630 | { |
| 626 | the_passwd.pw_uid = | 631 | the_passwd.pw_uid = |
| 627 | *get_sid_sub_authority (*((PSID *) user_sid), | 632 | *get_sid_sub_authority (user_token.User.Sid, |
| 628 | n_subauthorities - 1); | 633 | n_subauthorities - 1); |
| 629 | /* Restrict to conventional uid range for normal users. */ | 634 | /* Restrict to conventional uid range for normal users. */ |
| 630 | the_passwd.pw_uid %= 60001; | 635 | the_passwd.pw_uid %= 60001; |
| @@ -632,17 +637,18 @@ init_user_info () | |||
| 632 | 637 | ||
| 633 | /* Get group id */ | 638 | /* Get group id */ |
| 634 | if (get_token_information (token, TokenPrimaryGroup, | 639 | if (get_token_information (token, TokenPrimaryGroup, |
| 635 | (PVOID) user_sid, sizeof (user_sid), &trash)) | 640 | (PVOID)buf, sizeof (buf), &trash)) |
| 636 | { | 641 | { |
| 642 | memcpy (&group_token, buf, sizeof (group_token)); | ||
| 637 | n_subauthorities = | 643 | n_subauthorities = |
| 638 | *get_sid_sub_authority_count (*((PSID *) user_sid)); | 644 | *get_sid_sub_authority_count (group_token.PrimaryGroup); |
| 639 | 645 | ||
| 640 | if (n_subauthorities < 1) | 646 | if (n_subauthorities < 1) |
| 641 | the_passwd.pw_gid = 0; /* the "World" RID */ | 647 | the_passwd.pw_gid = 0; /* the "World" RID */ |
| 642 | else | 648 | else |
| 643 | { | 649 | { |
| 644 | the_passwd.pw_gid = | 650 | the_passwd.pw_gid = |
| 645 | *get_sid_sub_authority (*((PSID *) user_sid), | 651 | *get_sid_sub_authority (group_token.PrimaryGroup, |
| 646 | n_subauthorities - 1); | 652 | n_subauthorities - 1); |
| 647 | /* I don't know if this is necessary, but for safety... */ | 653 | /* I don't know if this is necessary, but for safety... */ |
| 648 | the_passwd.pw_gid %= 60001; | 654 | the_passwd.pw_gid %= 60001; |