[Openvas-commits] r5447 - in trunk/openvas-client: . openvas
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Fri Oct 9 00:41:41 CEST 2009
Author: jan
Date: 2009-10-09 00:41:39 +0200 (Fri, 09 Oct 2009)
New Revision: 5447
Modified:
trunk/openvas-client/ChangeLog
trunk/openvas-client/openvas/preferences.c
Log:
* openvas/preferences.c (prefs_get_openvashome): Use g_get_home_dir() instead
of trying on our own.
(dlopen, dlsym, dlclose, w32_shgetfolderpath, standard_homedir): Removed.
These all were only trying to assist finding the homedir on our own.
Modified: trunk/openvas-client/ChangeLog
===================================================================
--- trunk/openvas-client/ChangeLog 2009-10-08 22:26:46 UTC (rev 5446)
+++ trunk/openvas-client/ChangeLog 2009-10-08 22:41:39 UTC (rev 5447)
@@ -1,5 +1,12 @@
2009-10-09 Jan-Oliver Wagner <jan-oliver.wagner at greenbone.net>
+ * openvas/preferences.c (prefs_get_openvashome): Use g_get_home_dir() instead
+ of trying on our own.
+ (dlopen, dlsym, dlclose, w32_shgetfolderpath, standard_homedir): Removed.
+ These all were only trying to assist finding the homedir on our own.
+
+2009-10-09 Jan-Oliver Wagner <jan-oliver.wagner at greenbone.net>
+
* openvas/preferences.c (prefs_get_default): Use g_get_user_name() instead
of own function to determine username.
(get_username): Removed.
Modified: trunk/openvas-client/openvas/preferences.c
===================================================================
--- trunk/openvas-client/openvas/preferences.c 2009-10-08 22:26:46 UTC (rev 5446)
+++ trunk/openvas-client/openvas/preferences.c 2009-10-08 22:41:39 UTC (rev 5447)
@@ -816,129 +816,6 @@
return 0;
}
-#ifdef _WIN32
-#include <windows.h>
-#include <shlobj.h>
-#include <io.h>
-
-#define OPENVAS_DEFAULT_HOMEDIR "c:\openvas"
-#define RTLD_LAZY 0
-
-static __inline__ void *
-dlopen (const char * name, int flag)
-{
- void * hd = LoadLibrary (name);
- return hd;
-}
-
-static __inline__ void *
-dlsym (void * hd, const char * sym)
-{
- if (hd && sym)
- {
- void * fnc = GetProcAddress (hd, sym);
- if (!fnc)
- return NULL;
- return fnc;
- }
- return NULL;
-}
-
-static __inline__ int
-dlclose (void * hd)
-{
- if (hd)
- {
- FreeLibrary (hd);
- return 0;
- }
- return -1;
-}
-
-
-/* This is a helper function to load and run a Windows function from
- either of one DLLs. */
-static HRESULT
-w32_shgetfolderpath (HWND a, int b, HANDLE c, DWORD d, LPSTR e)
-{
- static int initialized;
- static HRESULT (WINAPI * func)(HWND,int,HANDLE,DWORD,LPSTR);
-
- if (!initialized)
- {
- static char *dllnames[] = { "shell32.dll", "shfolder.dll", NULL };
- void *handle;
- int i;
-
- initialized = 1;
-
- for (i=0, handle = NULL; !handle && dllnames[i]; i++)
- {
- handle = dlopen (dllnames[i], RTLD_LAZY);
- if (handle)
- {
- func = dlsym (handle, "SHGetFolderPathA");
- if (!func)
- {
- dlclose (handle);
- handle = NULL;
- }
- }
- }
- }
-
- if (func)
- return func (a,b,c,d,e);
- else
- return -1;
-}
-
-#ifndef CSIDL_APPDATA
-#define CSIDL_APPDATA 0x001a
-#endif
-#ifndef CSIDL_LOCAL_APPDATA
-#define CSIDL_LOCAL_APPDATA 0x001c
-#endif
-#ifndef CSIDL_COMMON_APPDATA
-#define CSIDL_COMMON_APPDATA 0x0023
-#endif
-#ifndef CSIDL_FLAG_CREATE
-#define CSIDL_FLAG_CREATE 0x8000
-#endif
-
-/** @brief Get the standard home directory.
- * This function does not consider a registry value (under W32) or the
- * environment variable.
- */
-static char *
-standard_homedir (void)
-{
- static char *dir;
-
- if (!dir)
- {
- char path[MAX_PATH];
-
- /* It might be better to use LOCAL_APPDATA because this is
- defined as "non roaming" and thus more likely to be kept
- locally. For private keys this is desired. However, given
- that many users copy private keys anyway forth and back,
- using a system roaming services might be better than to let
- them do it manually. A security conscious user will anyway
- use the registry entry to have better control. */
- if (w32_shgetfolderpath (NULL, CSIDL_APPDATA|CSIDL_FLAG_CREATE,
- NULL, 0, path) >= 0)
- {
- dir = malloc (strlen (path) + 1);
- strcpy (dir, path);
- }
- else
- dir = OPENVAS_DEFAULT_HOMEDIR;
- }
- return dir;
-}
-#endif
-
char *
prefs_get_openvashome (void)
{
@@ -948,20 +825,9 @@
if (home)
return home;
-#ifdef _WIN32
- return standard_homedir ();
-#else
-
- struct passwd *pwd;
-
home = getenv ("HOME");
if (home)
return home;
- pwd = getpwuid (getuid());
- if (pwd && pwd->pw_dir)
- return pwd->pw_dir;
-
- return "";
-#endif
+ return((char *)g_get_home_dir ());
}
More information about the Openvas-commits
mailing list