win32 dbus-launch.bat replacement

Ralf Habacker ralf.habacker at freenet.de
Wed May 30 14:20:18 PDT 2007


Ralf Habacker schrieb:
> Ralf Habacker schrieb:
>   
>> I've appended an updated source for dbus-launch.c, with some MAX_PATH
>> related fixes, some additional error printing and stuff to distinguish
>> release/debug compilations.
>>
>> Are there any other issues with this code beside Tor's unicode
>> suggestions ? 
>>   
>>     
> The same code detecting the session config path and debug/release 
> version of dbus-daemon is required in the dbus-daemon.
>
> The autolaunch feature see _dbus_get_autolaunch_address() in 
> dbus/dbus-sysdeps-win.c uses the --session parameter to run the dbus-daemon.
>
> The dbus-daemon currently uses a hardcoded path 'etc/session.conf', 
> which only works if dbus-daemon is installed [1] and the working dir of 
> dbus-daemon is set to the dbus installation root and the path layout is 
> like shown below
>
> <dbus-install-root>/
>     bin/dbus-daemon.exe
>     etc/session.conf
>
> If dbus-daemon is running in the build environment the path layout looks 
> different
>
> <dbus-build-root>/
>     bin/dbus-daemon.exe
>     bus/session.conf
>
>
> The solution for this problem is to implement the session.conf search in 
> bus/main.c where the config_file parameter is set and to use the 
> --session parameter in dbus-launch to start dbus-daemon.exe. This would 
> fix also the limitation mentioned in [1]
>   
To be able to implement this feature a new function is required which 
returns the intallation root like shown below. How should this function 
be named and where should it be located. It will be used in bus\main.c

dbus_bool_t _dbus_get_install_root(char *s, int len)
{
  char *p;
  GetModuleFileName(NULL,s,len);
  if ((p = strstr(s,"\\bin\\")))
    {
      *(p+1)= '\0';
      return TRUE;
    }
  else
    {
      *s = '\0';
      return FALSE;
    }
}


bus\main.c

....
      else if (strcmp (arg, "--session") == 0)
        {
          check_two_config_files (&config_file, "session");

#ifdef DBUS_WIN
          char a_path[MAX_PATH*2];
          _dbus_get_install_root(a_path,sizeof(a_path));
          strcat(a_path,"etc\\session.conf");
          if (_dbus_file_exists(a_path))
            {
              printf("%s found",a_path);
              // find path from executable
              if (!_dbus_string_append (&config_file, a_path))
                exit (1);
            }
          else
            {
              _dbus_get_install_root(a_path,sizeof(a_path));
              strcat(a_path,"bus\\session.conf");

              if (_dbus_file_exists(a_path))
                {
                  printf("%s found",a_path);
                  if (!_dbus_string_append (&config_file, a_path))
                    exit (1);
                }
            }
#else
          if (!_dbus_string_append (&config_file, DBUS_SESSION_CONFIG_FILE))
            exit (1);
#endif


Ralf


More information about the dbus mailing list