Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
dba83c8b
Commit
dba83c8b
authored
Aug 27, 2002
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added wine_get_user_name function and got rid of some of the getpwuid
portability stuff. More portable printf formats for 64-bit types.
parent
ef0e2af7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
41 additions
and
55 deletions
+41
-55
advapi.c
dlls/advapi32/advapi.c
+14
-23
sec.c
dlls/ntdll/sec.c
+1
-12
profile.c
files/profile.c
+0
-3
library.h
include/wine/library.h
+1
-0
config.c
library/config.c
+24
-4
client.c
scheduler/client.c
+0
-3
registry.c
server/registry.c
+1
-10
No files found.
dlls/advapi32/advapi.c
View file @
dba83c8b
...
...
@@ -24,15 +24,13 @@
#include <errno.h>
#include <stdio.h>
#include <string.h>
#ifdef HAVE_PWD_H
# include <pwd.h>
#endif
#include "winbase.h"
#include "windef.h"
#include "winnls.h"
#include "winerror.h"
#include "wine/library.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL
(
advapi
);
...
...
@@ -47,18 +45,7 @@ BOOL WINAPI
GetUserNameA
(
LPSTR
lpszName
,
LPDWORD
lpSize
)
{
size_t
len
;
char
*
name
;
#ifdef HAVE_GETPWUID
struct
passwd
*
pwd
=
getpwuid
(
getuid
()
);
name
=
pwd
?
pwd
->
pw_name
:
NULL
;
#else
name
=
getenv
(
"USER"
);
#endif
if
(
!
name
)
{
ERR
(
"Username lookup failed: %s
\n
"
,
strerror
(
errno
));
return
0
;
}
const
char
*
name
=
wine_get_user_name
();
/* We need to include the null character when determining the size of the buffer. */
len
=
strlen
(
name
)
+
1
;
...
...
@@ -84,15 +71,19 @@ GetUserNameA( LPSTR lpszName, LPDWORD lpSize )
BOOL
WINAPI
GetUserNameW
(
LPWSTR
lpszName
,
LPDWORD
lpSize
)
{
LPSTR
name
=
(
LPSTR
)
HeapAlloc
(
GetProcessHeap
(),
0
,
*
lpSize
);
DWORD
size
=
*
lpSize
;
BOOL
res
=
GetUserNameA
(
name
,
lpSize
);
const
char
*
name
=
wine_get_user_name
();
DWORD
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
name
,
-
1
,
NULL
,
0
);
/* FIXME: should set lpSize in WCHARs */
if
(
size
&&
!
MultiByteToWideChar
(
CP_ACP
,
0
,
name
,
-
1
,
lpszName
,
size
))
lpszName
[
size
-
1
]
=
0
;
HeapFree
(
GetProcessHeap
(),
0
,
name
);
return
res
;
if
(
len
>
*
lpSize
)
{
SetLastError
(
ERROR_MORE_DATA
);
*
lpSize
=
len
;
return
FALSE
;
}
*
lpSize
=
len
;
MultiByteToWideChar
(
CP_ACP
,
0
,
name
,
-
1
,
lpszName
,
len
);
return
TRUE
;
}
/******************************************************************************
...
...
dlls/ntdll/sec.c
View file @
dba83c8b
...
...
@@ -25,9 +25,6 @@
#include <time.h>
#include <ctype.h>
#include <math.h>
#ifdef HAVE_PWD_H
# include <pwd.h>
#endif
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
...
...
@@ -741,18 +738,10 @@ NTSTATUS WINAPI RtlConvertSidToUnicodeString(
PSID
Sid
,
BOOLEAN
AllocateString
)
{
const
char
*
p
;
const
char
*
p
=
wine_get_user_name
()
;
NTSTATUS
status
;
ANSI_STRING
AnsiStr
;
#ifdef HAVE_GETPWUID
struct
passwd
*
pwd
=
getpwuid
(
getuid
()
);
p
=
pwd
?
pwd
->
pw_name
:
NULL
;
#else
p
=
getenv
(
"USER"
);
#endif
p
=
p
?
p
:
".Default"
;
FIXME
(
"(%p %p %u)
\n
"
,
String
,
Sid
,
AllocateString
);
RtlInitAnsiString
(
&
AnsiStr
,
p
);
...
...
files/profile.c
View file @
dba83c8b
...
...
@@ -29,9 +29,6 @@
#include <stdio.h>
#include <sys/stat.h>
#include <sys/types.h>
#ifdef HAVE_PWD_H
# include <pwd.h>
#endif
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
...
...
include/wine/library.h
View file @
dba83c8b
...
...
@@ -28,6 +28,7 @@
extern
const
char
*
wine_get_config_dir
(
void
);
extern
const
char
*
wine_get_server_dir
(
void
);
extern
const
char
*
wine_get_user_name
(
void
);
/* dll loading */
...
...
library/config.c
View file @
dba83c8b
...
...
@@ -39,6 +39,7 @@ static const char * const server_dir_prefix = "/server-"; /* prefix for ser
static
char
*
config_dir
;
static
char
*
server_dir
;
static
char
*
user_name
;
#ifdef __GNUC__
static
void
fatal_error
(
const
char
*
err
,
...
)
__attribute__
((
noreturn
,
format
(
printf
,
1
,
2
)));
...
...
@@ -80,6 +81,15 @@ static void *xmalloc( size_t size )
return
res
;
}
/* strdup wrapper */
static
char
*
xstrdup
(
const
char
*
str
)
{
size_t
len
=
strlen
(
str
)
+
1
;
char
*
res
=
xmalloc
(
len
);
memcpy
(
res
,
str
,
len
);
return
res
;
}
/* remove all trailing slashes from a path name */
inline
static
void
remove_trailing_slashes
(
char
*
path
)
{
...
...
@@ -115,6 +125,7 @@ static void init_paths(void)
if
(
!
(
user
=
getenv
(
"USER"
)))
fatal_error
(
"cannot determine your user name, set the USER environment variable
\n
"
);
#endif
/* HAVE_GETPWUID */
user_name
=
xstrdup
(
user
);
/* build config_dir */
...
...
@@ -154,13 +165,15 @@ static void init_paths(void)
}
strcpy
(
p
,
server_dir_prefix
);
if
(
sizeof
(
st
.
st_dev
)
>
sizeof
(
unsigned
long
))
sprintf
(
server_dir
+
strlen
(
server_dir
),
"%llx-"
,
(
unsigned
long
long
)
st
.
st_dev
);
if
(
sizeof
(
st
.
st_dev
)
>
sizeof
(
unsigned
long
)
&&
st
.
st_dev
>
~
0UL
)
sprintf
(
server_dir
+
strlen
(
server_dir
),
"%lx%08lx-"
,
(
unsigned
long
)(
st
.
st_dev
>>
32
),
(
unsigned
long
)
st
.
st_dev
);
else
sprintf
(
server_dir
+
strlen
(
server_dir
),
"%lx-"
,
(
unsigned
long
)
st
.
st_dev
);
if
(
sizeof
(
st
.
st_ino
)
>
sizeof
(
unsigned
long
))
sprintf
(
server_dir
+
strlen
(
server_dir
),
"%llx"
,
(
unsigned
long
long
)
st
.
st_ino
);
if
(
sizeof
(
st
.
st_ino
)
>
sizeof
(
unsigned
long
)
&&
st
.
st_ino
>
~
0UL
)
sprintf
(
server_dir
+
strlen
(
server_dir
),
"%lx%08lx"
,
(
unsigned
long
)(
st
.
st_ino
>>
32
),
(
unsigned
long
)
st
.
st_ino
);
else
sprintf
(
server_dir
+
strlen
(
server_dir
),
"%lx"
,
(
unsigned
long
)
st
.
st_ino
);
}
...
...
@@ -178,3 +191,10 @@ const char *wine_get_server_dir(void)
if
(
!
server_dir
)
init_paths
();
return
server_dir
;
}
/* return the current user name */
const
char
*
wine_get_user_name
(
void
)
{
if
(
!
user_name
)
init_paths
();
return
user_name
;
}
scheduler/client.c
View file @
dba83c8b
...
...
@@ -25,9 +25,6 @@
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#ifdef HAVE_PWD_H
# include <pwd.h>
#endif
#include <signal.h>
#include <stdio.h>
#include <string.h>
...
...
server/registry.c
View file @
dba83c8b
...
...
@@ -37,7 +37,6 @@
#include <stdlib.h>
#include <sys/stat.h>
#include <unistd.h>
#include <pwd.h>
#include "object.h"
#include "handle.h"
#include "request.h"
...
...
@@ -942,15 +941,7 @@ static struct key *create_root_key( obj_handle_t hkey )
if
(
hkey
==
(
obj_handle_t
)
HKEY_CURRENT_USER
)
/* this one is special */
{
/* get the current user name */
char
buffer
[
10
];
struct
passwd
*
pwd
=
getpwuid
(
getuid
()
);
if
(
pwd
)
p
=
pwd
->
pw_name
;
else
{
sprintf
(
buffer
,
"%ld"
,
(
long
)
getuid
()
);
p
=
buffer
;
}
p
=
wine_get_user_name
();
while
(
*
p
&&
i
<
sizeof
(
keyname
)
/
sizeof
(
WCHAR
)
-
1
)
keyname
[
i
++
]
=
*
p
++
;
}
keyname
[
i
++
]
=
0
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment