static char * find_inst_dir () { return read_w32_registry_string ("HKEY_LOCAL_MACHINE", "Software\\freedesktop\\DBus", "Install Directory"); }
static char * find_env_in_registry (const char *name) { return read_w32_registry_string ("HKEY_LOCAL_MACHINE", "Software\\freedesktop\\DBus", name); }
/* Set up the default home directory. The usual --homedir option should be parsed later. */ const char * default_homedir (void) { const char *dir; #ifdef HAVE_W32_SYSTEM /* For a portable application we only use the standard homedir. */ w32_rootdir (); if (w32_portable_app) return standard_homedir (); #endif /*HAVE_W32_SYSTEM*/ dir = getenv ("GNUPGHOME"); #ifdef HAVE_W32_SYSTEM if (!dir || !*dir) { static const char *saved_dir; if (!saved_dir) { if (!dir || !*dir) { char *tmp; tmp = read_w32_registry_string (NULL, GNUPG_REGISTRY_DIR, "HomeDir"); if (tmp && !*tmp) { xfree (tmp); tmp = NULL; } if (tmp) saved_dir = tmp; } if (!saved_dir) saved_dir = standard_homedir (); } dir = saved_dir; } #endif /*HAVE_W32_SYSTEM*/ if (!dir || !*dir) dir = GNUPG_DEFAULT_HOMEDIR; else if (!is_gnupg_default_homedir (dir)) non_default_homedir = 1; return dir; }
symbol Path::get_daisy_home () { static symbol daisy_home; if (daisy_home == symbol ()) { // Check DAISYHOME const char* daisy_home_env = getenv ("DAISYHOME"); if (daisy_home_env) { Assertion::debug ("Has DAISYHOME environment variable"); daisy_home = daisy_home_env; } else { // Check MS Windows registry #if defined (_WIN32) || defined (__CYGWIN32__) const std::string key = "Software\\Daisy " + std::string (version); char *const daisy_w32_reg = read_w32_registry_string (NULL, key.c_str (), "Install Directory"); if (daisy_w32_reg) { Assertion::debug ("Has '" + key + "' registry entry."); symbol result = daisy_w32_reg; free (daisy_w32_reg); daisy_home = result; } else { Assertion::debug ("Using standard MS Windows home."); daisy_home = "C:/daisy"; } #else // !MS WINDOWS Assertion::debug ("Using standard Unix home."); daisy_home = "/opt/daisy"; #endif // !MS WINDOWS } } return daisy_home; }
/* Set up the default home directory. The usual --homedir option should be parsed later. */ const char * default_homedir (void) { const char *dir; dir = getenv ("GNUPGHOME"); #ifdef HAVE_W32_SYSTEM if (!dir || !*dir) { static const char *saved_dir; if (!saved_dir) { if (!dir || !*dir) { char *tmp; tmp = read_w32_registry_string (NULL, "Software\\GNU\\GnuPG", "HomeDir"); if (tmp && !*tmp) { xfree (tmp); tmp = NULL; } if (tmp) saved_dir = tmp; } if (!saved_dir) saved_dir = standard_homedir (); } dir = saved_dir; } #endif /*HAVE_W32_SYSTEM*/ if (!dir || !*dir) dir = GNUPG_DEFAULT_HOMEDIR; return dir; }
static void do_logv (int level, int ignore_arg_ptr, const char *fmt, va_list arg_ptr) { if (!logstream) { #ifdef HAVE_W32_SYSTEM char *tmp; tmp = (no_registry ? NULL : read_w32_registry_string (NULL, GNUPG_REGISTRY_DIR, "DefaultLogFile")); log_set_file (tmp && *tmp? tmp : NULL); xfree (tmp); #else log_set_file (NULL); /* Make sure a log stream has been set. */ #endif assert (logstream); } es_flockfile (logstream); if (missing_lf && level != GPGRT_LOG_CONT) es_putc_unlocked ('\n', logstream ); missing_lf = 0; if (level != GPGRT_LOG_CONT) { /* Note this does not work for multiple line logging as we would * need to print to a buffer first */ if (with_time && !force_prefixes) { struct tm *tp; time_t atime = time (NULL); tp = localtime (&atime); es_fprintf_unlocked (logstream, "%04d-%02d-%02d %02d:%02d:%02d ", 1900+tp->tm_year, tp->tm_mon+1, tp->tm_mday, tp->tm_hour, tp->tm_min, tp->tm_sec ); } if (with_prefix || force_prefixes) es_fputs_unlocked (prefix_buffer, logstream); if (with_pid || force_prefixes) { unsigned long pidsuf; int pidfmt; if (get_pid_suffix_cb && (pidfmt=get_pid_suffix_cb (&pidsuf))) es_fprintf_unlocked (logstream, pidfmt == 1? "[%u.%lu]":"[%u.%lx]", (unsigned int)getpid (), pidsuf); else es_fprintf_unlocked (logstream, "[%u]", (unsigned int)getpid ()); } if (!with_time || force_prefixes) es_putc_unlocked (':', logstream); /* A leading backspace suppresses the extra space so that we can correctly output, programname, filename and linenumber. */ if (fmt && *fmt == '\b') fmt++; else es_putc_unlocked (' ', logstream); } switch (level) { case GPGRT_LOG_BEGIN: break; case GPGRT_LOG_CONT: break; case GPGRT_LOG_INFO: break; case GPGRT_LOG_WARN: break; case GPGRT_LOG_ERROR: break; case GPGRT_LOG_FATAL: es_fputs_unlocked ("Fatal: ",logstream ); break; case GPGRT_LOG_BUG: es_fputs_unlocked ("Ohhhh jeeee: ", logstream); break; case GPGRT_LOG_DEBUG: es_fputs_unlocked ("DBG: ", logstream ); break; default: es_fprintf_unlocked (logstream,"[Unknown log level %d]: ", level); break; } if (fmt) { if (ignore_arg_ptr) es_fputs_unlocked (fmt, logstream); else es_vfprintf_unlocked (logstream, fmt, arg_ptr); if (*fmt && fmt[strlen(fmt)-1] != '\n') missing_lf = 1; } if (level == GPGRT_LOG_FATAL) { if (missing_lf) es_putc_unlocked ('\n', logstream); es_funlockfile (logstream); exit (2); } else if (level == GPGRT_LOG_BUG) { if (missing_lf) es_putc_unlocked ('\n', logstream ); es_funlockfile (logstream); abort (); } else es_funlockfile (logstream); }
/**************** * Load and initialize the winseed DLL * NOTE: winseed is not part of the GnuPG distribution. It should be available * at the GNU crypto FTP server site. * We do not load the DLL on demand to have a better control over the * location of the library. */ static void load_and_init_winseed( void ) { HANDLE hInstance; void *addr; unsigned int reason = 0; unsigned int n1, n2; const char *dllname; dllname = read_w32_registry_string( "HKEY_LOCAL_MACHINE", "Software\\GNU\\GnuPG", "EntropyDLL" ); if( !dllname ) dllname = "c:/gnupg/entropy.dll"; hInstance = LoadLibrary( dllname ); if( !hInstance ) goto failure; if( !(addr = GetProcAddress( hInstance, "WS_create_instance" )) ) goto failure; create_instance = addr; if( !(addr = GetProcAddress( hInstance, "WS_delete_instance" )) ) goto failure; delete_instance = addr; if( !(addr = GetProcAddress( hInstance, "WS_get_internal_seed_size" )) ) goto failure; get_internal_seed_size = addr; if( !(addr = GetProcAddress( hInstance, "WS_set_internal_seed_size" )) ) goto failure; set_internal_seed_size = addr; if( !(addr = GetProcAddress( hInstance, "WS_get_expected_seed_size" )) ) goto failure; get_expected_seed_size = addr; if( !(addr = GetProcAddress( hInstance, "WS_get_seed" )) ) goto failure; get_seed = addr; /* we have all the functions - init the system */ slow_seeder = create_instance( WIN32_SLOW_SEEDER, &reason); if( !slow_seeder ) { g10_log_fatal("error creating winseed slow seeder: rc=%u\n", reason ); goto failure; } fast_seeder = create_instance( WIN32_FAST_SEEDER, &reason); if( !fast_seeder ) { g10_log_fatal("error creating winseed fast seeder: rc=%u\n", reason ); goto failure; } n1 = get_internal_seed_size( slow_seeder ); /*g10_log_info("slow buffer size=%u\n", n1);*/ n2 = get_internal_seed_size( fast_seeder ); /*g10_log_info("fast buffer size=%u\n", n2);*/ entropy_buffer_size = n1 > n2? n1: n2; entropy_buffer = m_alloc( entropy_buffer_size ); /*g10_log_info("using a buffer of size=%u\n", entropy_buffer_size );*/ return; failure: g10_log_fatal("error loading winseed DLL `%s'\n", dllname ); }