Use $HOME instead of getpwuid for user's home directory.
Fixed messed up indentation.
This commit is contained in:
parent
f62b48712e
commit
154c99b8c2
|
@ -28,7 +28,6 @@
|
|||
#include <sys/types.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <pwd.h>
|
||||
#include <assert.h>
|
||||
#include <time.h>
|
||||
#include "windef.h"
|
||||
|
@ -715,8 +714,7 @@ static BOOL _savereg( LPKEYSTRUCT lpkey, char *fn, int all )
|
|||
*/
|
||||
void SHELL_SaveRegistry( void )
|
||||
{
|
||||
char *fn;
|
||||
struct passwd *pwd;
|
||||
char *fn, *home, *tmp;
|
||||
char buf[4];
|
||||
HKEY hkey;
|
||||
int all;
|
||||
|
@ -735,8 +733,7 @@ void SHELL_SaveRegistry( void )
|
|||
DWORD len,junk,type;
|
||||
|
||||
len=4;
|
||||
if ( (ERROR_SUCCESS!=RegQueryValueExA(
|
||||
hkey,
|
||||
if ((ERROR_SUCCESS!=RegQueryValueExA( hkey,
|
||||
VAL_SAVEUPDATED,
|
||||
&junk,
|
||||
&type,
|
||||
|
@ -748,24 +745,19 @@ void SHELL_SaveRegistry( void )
|
|||
RegCloseKey(hkey);
|
||||
}
|
||||
|
||||
if (lstrcmpiA(buf,"yes"))
|
||||
all=1;
|
||||
if (lstrcmpiA(buf,"yes")) all=1;
|
||||
|
||||
pwd=getpwuid(getuid());
|
||||
if ( (pwd!=NULL) && (pwd->pw_dir!=NULL))
|
||||
if (!(home = getenv( "HOME" )))
|
||||
{
|
||||
char *tmp;
|
||||
WARN(reg,"Failed to get homedirectory of UID %d.\n",getuid());
|
||||
return;
|
||||
}
|
||||
/*
|
||||
* Save HKEY_CURRENT_USER
|
||||
* Try first saving according to the defined location in .winerc
|
||||
*/
|
||||
fn = xmalloc( MAX_PATHNAME_LEN );
|
||||
if (PROFILE_GetWineIniString (
|
||||
"Registry",
|
||||
"UserFileName",
|
||||
"",
|
||||
fn,
|
||||
MAX_PATHNAME_LEN - 1))
|
||||
if (PROFILE_GetWineIniString ( "Registry", "UserFileName", "", fn, MAX_PATHNAME_LEN - 1))
|
||||
{
|
||||
_savereg(lookup_hkey(HKEY_CURRENT_USER),fn,all);
|
||||
usedCfgUser = 1;
|
||||
|
@ -774,12 +766,9 @@ void SHELL_SaveRegistry( void )
|
|||
|
||||
if (usedCfgUser != 1)
|
||||
{
|
||||
fn=(char*)xmalloc(
|
||||
strlen(pwd->pw_dir) +
|
||||
strlen(WINE_PREFIX) +
|
||||
fn=(char*)xmalloc( strlen(home) + strlen(WINE_PREFIX) +
|
||||
strlen(SAVE_CURRENT_USER) + 2 );
|
||||
|
||||
strcpy(fn,pwd->pw_dir);
|
||||
strcpy(fn,home);
|
||||
strcat(fn,WINE_PREFIX);
|
||||
|
||||
/* create the directory. don't care about errorcodes. */
|
||||
|
@ -805,11 +794,7 @@ void SHELL_SaveRegistry( void )
|
|||
* Try first saving according to the defined location in .winerc
|
||||
*/
|
||||
fn = xmalloc ( MAX_PATHNAME_LEN);
|
||||
if (PROFILE_GetWineIniString (
|
||||
"Registry",
|
||||
"LocalMachineFileName",
|
||||
"",
|
||||
fn,
|
||||
if (PROFILE_GetWineIniString ( "Registry", "LocalMachineFileName", "", fn,
|
||||
MAX_PATHNAME_LEN - 1))
|
||||
{
|
||||
_savereg(lookup_hkey(HKEY_LOCAL_MACHINE), fn, all);
|
||||
|
@ -819,12 +804,8 @@ void SHELL_SaveRegistry( void )
|
|||
|
||||
if ( usedCfgLM != 1)
|
||||
{
|
||||
fn=(char*)xmalloc(
|
||||
strlen(pwd->pw_dir)+
|
||||
strlen(WINE_PREFIX)+
|
||||
strlen(SAVE_LOCAL_MACHINE)+2);
|
||||
|
||||
strcpy(fn,pwd->pw_dir);
|
||||
fn=(char*)xmalloc( strlen(home)+ strlen(WINE_PREFIX)+ strlen(SAVE_LOCAL_MACHINE)+2);
|
||||
strcpy(fn,home);
|
||||
strcat(fn,WINE_PREFIX"/"SAVE_LOCAL_MACHINE);
|
||||
|
||||
tmp = (char*)xmalloc(strlen(fn)+strlen(".tmp")+1);
|
||||
|
@ -844,12 +825,9 @@ void SHELL_SaveRegistry( void )
|
|||
/*
|
||||
* Save HKEY_USERS
|
||||
*/
|
||||
fn=(char*)xmalloc(
|
||||
strlen(pwd->pw_dir)+
|
||||
strlen(WINE_PREFIX)+
|
||||
strlen(SAVE_LOCAL_USERS_DEFAULT)+2);
|
||||
fn=(char*)xmalloc( strlen(home)+ strlen(WINE_PREFIX)+ strlen(SAVE_LOCAL_USERS_DEFAULT)+2);
|
||||
|
||||
strcpy(fn,pwd->pw_dir);
|
||||
strcpy(fn,home);
|
||||
strcat(fn,WINE_PREFIX"/"SAVE_LOCAL_USERS_DEFAULT);
|
||||
|
||||
tmp = (char*)xmalloc(strlen(fn)+strlen(".tmp")+1);
|
||||
|
@ -863,11 +841,6 @@ void SHELL_SaveRegistry( void )
|
|||
free(tmp);
|
||||
free(fn);
|
||||
}
|
||||
else
|
||||
{
|
||||
WARN(reg,"Failed to get homedirectory of UID %d.\n",getuid());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/************************ LOAD Registry Function ****************************/
|
||||
|
@ -1912,8 +1885,7 @@ void _w31_loadreg(void) {
|
|||
*/
|
||||
void SHELL_LoadRegistry( void )
|
||||
{
|
||||
char *fn;
|
||||
struct passwd *pwd;
|
||||
char *fn, *home;
|
||||
LPKEYSTRUCT lpkey, HKCU, HKU, HKLM;
|
||||
HKEY hkey;
|
||||
|
||||
|
@ -1940,24 +1912,20 @@ void SHELL_LoadRegistry( void )
|
|||
*/
|
||||
_wine_loadreg( HKLM, SAVE_LOCAL_MACHINE_DEFAULT, 0);
|
||||
|
||||
/* Get current user info */
|
||||
pwd=getpwuid(getuid());
|
||||
|
||||
/*
|
||||
* Load the user saved registries
|
||||
*/
|
||||
if ( (pwd != NULL) &&
|
||||
(pwd->pw_dir != NULL) )
|
||||
if ((home = getenv( "HOME" )))
|
||||
{
|
||||
/*
|
||||
* Load user's personal versions of global HKU/.Default keys
|
||||
*/
|
||||
fn=(char*)xmalloc(
|
||||
strlen(pwd->pw_dir)+
|
||||
strlen(home)+
|
||||
strlen(WINE_PREFIX)+
|
||||
strlen(SAVE_LOCAL_USERS_DEFAULT)+2);
|
||||
|
||||
strcpy(fn, pwd->pw_dir);
|
||||
strcpy(fn, home);
|
||||
strcat(fn, WINE_PREFIX"/"SAVE_LOCAL_USERS_DEFAULT);
|
||||
_wine_loadreg(HKU, fn, REG_OPTION_TAINTED);
|
||||
free(fn);
|
||||
|
@ -1979,11 +1947,11 @@ void SHELL_LoadRegistry( void )
|
|||
free (fn);
|
||||
|
||||
fn=(char*)xmalloc(
|
||||
strlen(pwd->pw_dir)+
|
||||
strlen(home)+
|
||||
strlen(WINE_PREFIX)+
|
||||
strlen(SAVE_CURRENT_USER)+2);
|
||||
|
||||
strcpy(fn, pwd->pw_dir);
|
||||
strcpy(fn, home);
|
||||
strcat(fn, WINE_PREFIX"/"SAVE_CURRENT_USER);
|
||||
_wine_loadreg(HKCU, fn, REG_OPTION_TAINTED);
|
||||
free(fn);
|
||||
|
@ -2005,11 +1973,11 @@ void SHELL_LoadRegistry( void )
|
|||
free(fn);
|
||||
|
||||
fn=(char*)xmalloc(
|
||||
strlen(pwd->pw_dir)+
|
||||
strlen(home)+
|
||||
strlen(WINE_PREFIX)+
|
||||
strlen(SAVE_LOCAL_MACHINE)+2);
|
||||
|
||||
strcpy(fn,pwd->pw_dir);
|
||||
strcpy(fn,home);
|
||||
strcat(fn,WINE_PREFIX"/"SAVE_LOCAL_MACHINE);
|
||||
_wine_loadreg(HKLM, fn, REG_OPTION_TAINTED);
|
||||
free(fn);
|
||||
|
@ -2043,17 +2011,18 @@ void SHELL_LoadRegistry( void )
|
|||
_flush_registry(HKU);
|
||||
|
||||
/* Reload user's local HKU hive */
|
||||
fn=(char*)xmalloc(
|
||||
strlen(pwd->pw_dir)+
|
||||
strlen(WINE_PREFIX)+
|
||||
strlen(SAVE_LOCAL_USERS_DEFAULT)+2);
|
||||
if (home)
|
||||
{
|
||||
fn=(char*)xmalloc( strlen(home) + strlen(WINE_PREFIX)
|
||||
+ strlen(SAVE_LOCAL_USERS_DEFAULT) + 2);
|
||||
|
||||
strcpy(fn,pwd->pw_dir);
|
||||
strcpy(fn,home);
|
||||
strcat(fn,WINE_PREFIX"/"SAVE_LOCAL_USERS_DEFAULT);
|
||||
|
||||
_wine_loadreg( HKU, fn, REG_OPTION_TAINTED);
|
||||
|
||||
free(fn);
|
||||
}
|
||||
|
||||
/*
|
||||
* Make sure the update mode is there
|
||||
|
|
Loading…
Reference in New Issue