VirtualBox

Ignore:
Timestamp:
Oct 6, 2009 6:07:06 AM (15 years ago)
Author:
vboxsync
Message:

crOpenGL: update to wine 1.1.30

Location:
trunk/src/VBox/Additions/WINNT/Graphics/Wine/libWine
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/libWine/config.c

    r19678 r23571  
    147147}
    148148
    149 /* initialize the server directory value */
    150 static void init_server_dir( dev_t dev, ino_t ino )
    151 {
    152     char *p;
    153 #ifdef HAVE_GETUID
    154     const unsigned int uid = getuid();
    155 #else
    156     const unsigned int uid = 0;
    157 #endif
    158 
    159     server_dir = xmalloc( sizeof(server_root_prefix) + 32 + sizeof(server_dir_prefix) +
    160                           2*sizeof(dev) + 2*sizeof(ino) );
    161     sprintf( server_dir, "%s%u%s", server_root_prefix, uid, server_dir_prefix );
    162     p = server_dir + strlen(server_dir);
    163 
    164     if (sizeof(dev) > sizeof(unsigned long) && dev > ~0UL)
    165         p += sprintf( p, "%lx%08lx-", (unsigned long)((unsigned long long)dev >> 32), (unsigned long)dev );
    166     else
    167         p += sprintf( p, "%lx-", (unsigned long)dev );
    168 
    169     if (sizeof(ino) > sizeof(unsigned long) && ino > ~0UL)
    170         sprintf( p, "%lx%08lx", (unsigned long)((unsigned long long)ino >> 32), (unsigned long)ino );
    171     else
    172         sprintf( p, "%lx", (unsigned long)ino );
    173 }
    174 
    175 /* retrieve the default dll dir */
    176 const char *get_dlldir( const char **default_dlldir )
    177 {
    178     *default_dlldir = DLLDIR;
    179     return dlldir;
    180 }
    181 
    182 /* initialize all the paths values */
    183 static void init_paths(void)
    184 {
    185     struct stat st;
    186 
    187     const char *home = getenv( "HOME" );
    188     const char *user = NULL;
    189     const char *prefix = getenv( "WINEPREFIX" );
    190 
    191 #ifdef HAVE_GETPWUID
    192     char uid_str[32];
    193     struct passwd *pwd = getpwuid( getuid() );
    194 
    195     if (pwd)
    196     {
    197         user = pwd->pw_name;
    198         if (!home) home = pwd->pw_dir;
    199     }
    200     if (!user)
    201     {
    202         sprintf( uid_str, "%lu", (unsigned long)getuid() );
    203         user = uid_str;
    204     }
    205 #else  /* HAVE_GETPWUID */
    206     if (!(user = getenv( "USER" )))
    207         fatal_error( "cannot determine your user name, set the USER environment variable\n" );
    208 #endif  /* HAVE_GETPWUID */
    209     user_name = xstrdup( user );
    210 
    211     /* build config_dir */
    212 
    213     if (prefix)
    214     {
    215         config_dir = xstrdup( prefix );
    216         remove_trailing_slashes( config_dir );
    217         if (config_dir[0] != '/')
    218             fatal_error( "invalid directory %s in WINEPREFIX: not an absolute path\n", prefix );
    219         if (stat( config_dir, &st ) == -1)
    220         {
    221             if (errno == ENOENT) return;  /* will be created later on */
    222             fatal_perror( "cannot open %s as specified in WINEPREFIX", config_dir );
    223         }
    224     }
    225     else
    226     {
    227         if (!home) fatal_error( "could not determine your home directory\n" );
    228         if (home[0] != '/') fatal_error( "your home directory %s is not an absolute path\n", home );
    229         config_dir = xmalloc( strlen(home) + sizeof(server_config_dir) );
    230         strcpy( config_dir, home );
    231         remove_trailing_slashes( config_dir );
    232         strcat( config_dir, server_config_dir );
    233         if (stat( config_dir, &st ) == -1)
    234         {
    235             if (errno == ENOENT) return;  /* will be created later on */
    236             fatal_perror( "cannot open %s", config_dir );
    237         }
    238     }
    239     if (!S_ISDIR(st.st_mode)) fatal_error( "%s is not a directory\n", config_dir );
    240 #ifdef HAVE_GETUID
    241     if (st.st_uid != getuid()) fatal_error( "%s is not owned by you\n", config_dir );
    242 #endif
    243 
    244     init_server_dir( st.st_dev, st.st_ino );
    245 }
    246 
    247 /* check if basedir is a valid build dir by checking for wineserver and ntdll */
    248 /* helper for running_from_build_dir */
    249 static inline int is_valid_build_dir( char *basedir, int baselen )
    250 {
    251     struct stat st;
    252 
    253     strcpy( basedir + baselen, "/server/wineserver" );
    254     if (stat( basedir, &st ) == -1) return 0;  /* no wineserver found */
    255     /* check for ntdll too to make sure */
    256     strcpy( basedir + baselen, "/dlls/ntdll/ntdll.dll.so" );
    257     if (stat( basedir, &st ) == -1) return 0;  /* no ntdll found */
    258 
    259     basedir[baselen] = 0;
    260     return 1;
    261 }
    262 
    263 /* check if we are running from the build directory */
    264 static char *running_from_build_dir( const char *basedir, const char *bindir )
    265 {
    266     struct stat st;
    267     const char *p;
    268     char *path;
    269     int res;
    270 
    271     if (!(path = build_path( bindir, "wineserver" ))) return NULL;
    272     res = stat( path, &st );
    273     free( path );
    274     if (res != -1) return NULL;  /* the real bindir is valid */
    275 
    276     /* remove last component from basedir */
    277     p = basedir + strlen(basedir) - 1;
    278     while (p > basedir && *p == '/') p--;
    279     while (p > basedir && *p != '/') p--;
    280     if (p == basedir) return NULL;
    281     path = xmalloc( p - basedir + sizeof("/dlls/ntdll/ntdll.dll.so") );
    282     memcpy( path, basedir, p - basedir );
    283 
    284     if (!is_valid_build_dir( path, p - basedir ))
    285     {
    286         /* remove another component */
    287         while (p > basedir && *p == '/') p--;
    288         while (p > basedir && *p != '/') p--;
    289         if (p == basedir || !is_valid_build_dir( path, p - basedir ))
    290         {
    291             free( path );
    292             return NULL;
    293         }
    294     }
    295     return path;
    296 }
    297 
    298 /* initialize the argv0 path */
    299 void wine_init_argv0_path( const char *argv0 )
    300 {
    301     size_t size, len;
    302     const char *p, *basename;
    303     char *cwd, *libdir;
    304 
    305     if (!(p = strrchr( argv0, '/' )))
    306         basename = argv0;
    307     else
    308         basename = p + 1;
    309 
    310     argv0_name = xstrdup( basename );
    311 
    312     if ((libdir = get_runtime_libdir()))
    313     {
    314         bindir = build_path( libdir, LIB_TO_BINDIR );
    315         if ((build_dir = running_from_build_dir( libdir, bindir )))
    316         {
    317             free( libdir );
    318             goto in_build_dir;
    319         }
    320         dlldir = build_path( libdir, LIB_TO_DLLDIR );
    321         datadir = build_path( libdir, LIB_TO_DATADIR );
    322         free( libdir );
    323         return;
    324     }
    325 
    326     if (!p) return;  /* if argv0 doesn't contain a path, don't store anything */
     149/* return the directory that contains the main exe at run-time */
     150static char *get_runtime_bindir( const char *argv0 )
     151{
     152    char *p, *bindir, *cwd;
     153    size_t len, size;
     154
     155#ifdef linux
     156    for (size = 256; ; size *= 2)
     157    {
     158        int ret;
     159        if (!(bindir = malloc( size ))) break;
     160        if ((ret = readlink( "/proc/self/exe", bindir, size )) == -1) break;
     161        if (ret != size)
     162        {
     163            if (!(p = memrchr( bindir, '/', ret ))) break;
     164            if (p == bindir) p++;
     165            *p = 0;
     166            return bindir;
     167        }
     168        free( bindir );
     169    }
     170    free( bindir );
     171#endif
     172
     173    if (!(p = strrchr( argv0, '/' ))) return NULL;
    327174
    328175    len = p - argv0;
     
    340187        for (size = 256 + len; ; size *= 2)
    341188        {
    342             if (!(cwd = malloc( size ))) return;
     189            if (!(cwd = malloc( size ))) return NULL;
    343190            if (getcwd( cwd, size - len ))
    344191            {
     
    351198            }
    352199            free( cwd );
    353             if (errno != ERANGE) return;
    354         }
    355     }
    356 
    357     if ((build_dir = running_from_build_dir( bindir, bindir ))) goto in_build_dir;
    358 
    359     dlldir = build_path( bindir, BIN_TO_DLLDIR );
    360     datadir = build_path( bindir, BIN_TO_DATADIR );
    361     return;
    362 
    363 in_build_dir:
    364     free( bindir );
    365     free( argv0_name );
    366     bindir = NULL;
    367     argv0_name = build_path( "loader/", basename );
     200            if (errno != ERANGE) return NULL;
     201        }
     202    }
     203    return bindir;
     204}
     205
     206/* initialize the server directory value */
     207static void init_server_dir( dev_t dev, ino_t ino )
     208{
     209    char *p;
     210#ifdef HAVE_GETUID
     211    const unsigned int uid = getuid();
     212#else
     213    const unsigned int uid = 0;
     214#endif
     215
     216    server_dir = xmalloc( sizeof(server_root_prefix) + 32 + sizeof(server_dir_prefix) +
     217                          2*sizeof(dev) + 2*sizeof(ino) );
     218    sprintf( server_dir, "%s%u%s", server_root_prefix, uid, server_dir_prefix );
     219    p = server_dir + strlen(server_dir);
     220
     221    if (sizeof(dev) > sizeof(unsigned long) && dev > ~0UL)
     222        p += sprintf( p, "%lx%08lx-", (unsigned long)((unsigned long long)dev >> 32), (unsigned long)dev );
     223    else
     224        p += sprintf( p, "%lx-", (unsigned long)dev );
     225
     226    if (sizeof(ino) > sizeof(unsigned long) && ino > ~0UL)
     227        sprintf( p, "%lx%08lx", (unsigned long)((unsigned long long)ino >> 32), (unsigned long)ino );
     228    else
     229        sprintf( p, "%lx", (unsigned long)ino );
     230}
     231
     232/* retrieve the default dll dir */
     233const char *get_dlldir( const char **default_dlldir )
     234{
     235    *default_dlldir = DLLDIR;
     236    return dlldir;
     237}
     238
     239/* initialize all the paths values */
     240static void init_paths(void)
     241{
     242    struct stat st;
     243
     244    const char *home = getenv( "HOME" );
     245    const char *user = NULL;
     246    const char *prefix = getenv( "WINEPREFIX" );
     247
     248#ifdef HAVE_GETPWUID
     249    char uid_str[32];
     250    struct passwd *pwd = getpwuid( getuid() );
     251
     252    if (pwd)
     253    {
     254        user = pwd->pw_name;
     255        if (!home) home = pwd->pw_dir;
     256    }
     257    if (!user)
     258    {
     259        sprintf( uid_str, "%lu", (unsigned long)getuid() );
     260        user = uid_str;
     261    }
     262#else  /* HAVE_GETPWUID */
     263    if (!(user = getenv( "USER" )))
     264        fatal_error( "cannot determine your user name, set the USER environment variable\n" );
     265#endif  /* HAVE_GETPWUID */
     266    user_name = xstrdup( user );
     267
     268    /* build config_dir */
     269
     270    if (prefix)
     271    {
     272        config_dir = xstrdup( prefix );
     273        remove_trailing_slashes( config_dir );
     274        if (config_dir[0] != '/')
     275            fatal_error( "invalid directory %s in WINEPREFIX: not an absolute path\n", prefix );
     276        if (stat( config_dir, &st ) == -1)
     277        {
     278            if (errno == ENOENT) return;  /* will be created later on */
     279            fatal_perror( "cannot open %s as specified in WINEPREFIX", config_dir );
     280        }
     281    }
     282    else
     283    {
     284        if (!home) fatal_error( "could not determine your home directory\n" );
     285        if (home[0] != '/') fatal_error( "your home directory %s is not an absolute path\n", home );
     286        config_dir = xmalloc( strlen(home) + sizeof(server_config_dir) );
     287        strcpy( config_dir, home );
     288        remove_trailing_slashes( config_dir );
     289        strcat( config_dir, server_config_dir );
     290        if (stat( config_dir, &st ) == -1)
     291        {
     292            if (errno == ENOENT) return;  /* will be created later on */
     293            fatal_perror( "cannot open %s", config_dir );
     294        }
     295    }
     296    if (!S_ISDIR(st.st_mode)) fatal_error( "%s is not a directory\n", config_dir );
     297#ifdef HAVE_GETUID
     298    if (st.st_uid != getuid()) fatal_error( "%s is not owned by you\n", config_dir );
     299#endif
     300
     301    init_server_dir( st.st_dev, st.st_ino );
     302}
     303
     304/* check if bindir is valid by checking for wineserver */
     305static int is_valid_bindir( const char *bindir )
     306{
     307    struct stat st;
     308    char *path = build_path( bindir, "wineserver" );
     309    int ret = (stat( path, &st ) != -1);
     310    free( path );
     311    return ret;
     312}
     313
     314/* check if basedir is a valid build dir by checking for wineserver and ntdll */
     315/* helper for running_from_build_dir */
     316static inline int is_valid_build_dir( char *basedir, int baselen )
     317{
     318    struct stat st;
     319
     320    strcpy( basedir + baselen, "/server/wineserver" );
     321    if (stat( basedir, &st ) == -1) return 0;  /* no wineserver found */
     322    /* check for ntdll too to make sure */
     323    strcpy( basedir + baselen, "/dlls/ntdll/ntdll.dll.so" );
     324    if (stat( basedir, &st ) == -1) return 0;  /* no ntdll found */
     325
     326    basedir[baselen] = 0;
     327    return 1;
     328}
     329
     330/* check if we are running from the build directory */
     331static char *running_from_build_dir( const char *basedir )
     332{
     333    const char *p;
     334    char *path;
     335
     336    /* remove last component from basedir */
     337    p = basedir + strlen(basedir) - 1;
     338    while (p > basedir && *p == '/') p--;
     339    while (p > basedir && *p != '/') p--;
     340    if (p == basedir) return NULL;
     341    path = xmalloc( p - basedir + sizeof("/dlls/ntdll/ntdll.dll.so") );
     342    memcpy( path, basedir, p - basedir );
     343
     344    if (!is_valid_build_dir( path, p - basedir ))
     345    {
     346        /* remove another component */
     347        while (p > basedir && *p == '/') p--;
     348        while (p > basedir && *p != '/') p--;
     349        if (p == basedir || !is_valid_build_dir( path, p - basedir ))
     350        {
     351            free( path );
     352            return NULL;
     353        }
     354    }
     355    return path;
     356}
     357
     358/* initialize the argv0 path */
     359void wine_init_argv0_path( const char *argv0 )
     360{
     361    const char *basename;
     362    char *libdir;
     363
     364    if (!(basename = strrchr( argv0, '/' ))) basename = argv0;
     365    else basename++;
     366
     367    bindir = get_runtime_bindir( argv0 );
     368    libdir = get_runtime_libdir();
     369
     370    if (bindir && !is_valid_bindir( bindir ))
     371    {
     372        build_dir = running_from_build_dir( bindir );
     373        free( bindir );
     374        bindir = NULL;
     375    }
     376    if (libdir && !bindir && !build_dir)
     377    {
     378        build_dir = running_from_build_dir( libdir );
     379        if (!build_dir) bindir = build_path( libdir, LIB_TO_BINDIR );
     380    }
     381
     382    if (build_dir)
     383    {
     384        argv0_name = build_path( "loader/", basename );
     385    }
     386    else
     387    {
     388        if (libdir) dlldir = build_path( libdir, LIB_TO_DLLDIR );
     389        else if (bindir) dlldir = build_path( bindir, BIN_TO_DLLDIR );
     390
     391        if (bindir) datadir = build_path( bindir, BIN_TO_DATADIR );
     392        argv0_name = xstrdup( basename );
     393    }
     394    free( libdir );
    368395}
    369396
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/libWine/loader.c

    r22496 r23571  
    159159}
    160160
     161/* check if the library is the correct architecture */
     162/* only returns false for a valid library of the wrong arch */
     163static int check_library_arch( int fd )
     164{
     165#ifdef __APPLE__
     166    struct  /* Mach-O header */
     167    {
     168        unsigned int magic;
     169        unsigned int cputype;
     170    } header;
     171
     172    if (read( fd, &header, sizeof(header) ) != sizeof(header)) return 1;
     173    if (header.magic != 0xfeedface) return 1;
     174    if (sizeof(void *) == sizeof(int)) return !(header.cputype >> 24);
     175    else return (header.cputype >> 24) == 1; /* CPU_ARCH_ABI64 */
     176#else
     177    struct  /* ELF header */
     178    {
     179        unsigned char magic[4];
     180        unsigned char class;
     181        unsigned char data;
     182        unsigned char version;
     183    } header;
     184
     185    if (read( fd, &header, sizeof(header) ) != sizeof(header)) return 1;
     186    if (memcmp( header.magic, "\177ELF", 4 )) return 1;
     187    if (header.version != 1 /* EV_CURRENT */) return 1;
     188#ifdef WORDS_BIGENDIAN
     189    if (header.data != 2 /* ELFDATA2MSB */) return 1;
     190#else
     191    if (header.data != 1 /* ELFDATA2LSB */) return 1;
     192#endif
     193    if (sizeof(void *) == sizeof(int)) return header.class == 1; /* ELFCLASS32 */
     194    else return header.class == 2; /* ELFCLASS64 */
     195#endif
     196}
     197
    161198/* check if a given file can be opened */
    162199static inline int file_exists( const char *name )
    163200{
     201    int ret = 0;
    164202    int fd = open( name, O_RDONLY );
    165     if (fd != -1) close( fd );
    166     return (fd != -1);
     203    if (fd != -1)
     204    {
     205        ret = check_library_arch( fd );
     206        close( fd );
     207    }
     208    return ret;
    167209}
    168210
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/libWine/version.c

    r22496 r23571  
    1 const char wine_build[] = "wine-1.1.27";
     1const char wine_build[] = "wine-1.1.30";
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette