Xserver: fixes for fakechroot
This commit is contained in:
Submodule project/jni/application/commandergenius/commandergenius updated: 13252e15db...1bcbadd1ea
@@ -140,7 +140,7 @@ void * unpackFilesThread(void * unused)
|
|||||||
|
|
||||||
__android_log_print(ANDROID_LOG_INFO, "XSDL", "Running postinstall scipt");
|
__android_log_print(ANDROID_LOG_INFO, "XSDL", "Running postinstall scipt");
|
||||||
|
|
||||||
fo = popen(fname, "w");
|
fo = popen(fname, "r");
|
||||||
if( !fo )
|
if( !fo )
|
||||||
{
|
{
|
||||||
__android_log_print(ANDROID_LOG_INFO, "XSDL", "ERROR: Cannot launch postinstall scipt");
|
__android_log_print(ANDROID_LOG_INFO, "XSDL", "ERROR: Cannot launch postinstall scipt");
|
||||||
@@ -192,7 +192,7 @@ void XSDL_showConfigMenu(int * resolutionW, int * displayW, int * resolutionH, i
|
|||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
int res = -1, dpi = -1;
|
int res = -1, dpi = -1;
|
||||||
char native[32] = "0x0";
|
char native[32] = "0x0";
|
||||||
float dpiScale = 1.0f;
|
//float dpiScale = 1.0f;
|
||||||
|
|
||||||
const char * resStr[] = {
|
const char * resStr[] = {
|
||||||
native, "1920x1080", "1280x960", "1280x720",
|
native, "1920x1080", "1280x960", "1280x720",
|
||||||
@@ -248,7 +248,7 @@ void XSDL_showConfigMenu(int * resolutionW, int * displayW, int * resolutionH, i
|
|||||||
SDL_Delay(200);
|
SDL_Delay(200);
|
||||||
SDL_Flip(SDL_GetVideoSurface());
|
SDL_Flip(SDL_GetVideoSurface());
|
||||||
}
|
}
|
||||||
dpiScale = (float)resVal[res][0] / (float)*resolutionW;
|
//dpiScale = (float)resVal[res][0] / (float)*resolutionW;
|
||||||
*resolutionW = resVal[res][0];
|
*resolutionW = resVal[res][0];
|
||||||
*resolutionH = resVal[res][1];
|
*resolutionH = resVal[res][1];
|
||||||
while ( dpi < 0 )
|
while ( dpi < 0 )
|
||||||
@@ -281,8 +281,8 @@ void XSDL_showConfigMenu(int * resolutionW, int * displayW, int * resolutionH, i
|
|||||||
SDL_Delay(200);
|
SDL_Delay(200);
|
||||||
SDL_Flip(SDL_GetVideoSurface());
|
SDL_Flip(SDL_GetVideoSurface());
|
||||||
}
|
}
|
||||||
*displayW = *displayW * (dpiScale / fontsVal[dpi]);
|
*displayW = *displayW / fontsVal[dpi];
|
||||||
*displayH = *displayH * (dpiScale / fontsVal[dpi]);
|
*displayH = *displayH / fontsVal[dpi];
|
||||||
}
|
}
|
||||||
|
|
||||||
void XSDL_generateBackground(const char * port, int showHelp)
|
void XSDL_generateBackground(const char * port, int showHelp)
|
||||||
|
|||||||
@@ -1,9 +1,13 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
#include <unistd.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#include <pwd.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
|
#include <sys/un.h>
|
||||||
|
#include <errno.h>
|
||||||
#include <SDL/SDL.h>
|
#include <SDL/SDL.h>
|
||||||
#include <android/log.h>
|
#include <android/log.h>
|
||||||
|
|
||||||
@@ -11,6 +15,8 @@
|
|||||||
|
|
||||||
extern int android_main( int argc, char *argv[], char *envp[] );
|
extern int android_main( int argc, char *argv[], char *envp[] );
|
||||||
|
|
||||||
|
static void setupEnv(void);
|
||||||
|
|
||||||
int main( int argc, char* argv[] )
|
int main( int argc, char* argv[] )
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@@ -38,6 +44,7 @@ int main( int argc, char* argv[] )
|
|||||||
int displayH = atoi(getenv("DISPLAY_HEIGHT_MM"));
|
int displayH = atoi(getenv("DISPLAY_HEIGHT_MM"));
|
||||||
|
|
||||||
__android_log_print(ANDROID_LOG_INFO, "XSDL", "Actual video resolution %d/%dx%d/%d", resolutionW, displayW, resolutionH, displayH);
|
__android_log_print(ANDROID_LOG_INFO, "XSDL", "Actual video resolution %d/%dx%d/%d", resolutionW, displayW, resolutionH, displayH);
|
||||||
|
setupEnv();
|
||||||
|
|
||||||
XSDL_initSDL();
|
XSDL_initSDL();
|
||||||
|
|
||||||
@@ -45,22 +52,51 @@ int main( int argc, char* argv[] )
|
|||||||
|
|
||||||
XSDL_showConfigMenu(&resolutionW, &displayW, &resolutionH, &displayH);
|
XSDL_showConfigMenu(&resolutionW, &displayW, &resolutionH, &displayH);
|
||||||
|
|
||||||
int s = socket(AF_INET, SOCK_STREAM, 0);
|
for(i = 0; i < 1024; i++)
|
||||||
if( s >= 0 )
|
|
||||||
{
|
{
|
||||||
for(i = 0; i < 1024; i++)
|
int s = socket(AF_INET, SOCK_STREAM, 0);
|
||||||
|
if( s >= 0 )
|
||||||
{
|
{
|
||||||
struct sockaddr_in addr;
|
struct sockaddr_in addr;
|
||||||
|
|
||||||
memset(&addr, 0, sizeof(addr));
|
memset(&addr, 0, sizeof(addr));
|
||||||
|
|
||||||
addr.sin_family = AF_INET;
|
addr.sin_family = AF_INET;
|
||||||
addr.sin_addr.s_addr = INADDR_ANY;
|
addr.sin_addr.s_addr = INADDR_ANY;
|
||||||
addr.sin_port = htons(6000 + i);
|
addr.sin_port = htons(6000 + i);
|
||||||
|
|
||||||
if( bind (s, (struct sockaddr *) &addr, sizeof(addr) ) < 0 )
|
if( bind (s, (struct sockaddr *) &addr, sizeof(addr) ) != 0 )
|
||||||
|
{
|
||||||
|
__android_log_print(ANDROID_LOG_INFO, "XSDL", "TCP port %d already used, trying next one: %s", 6000 + i, strerror(errno));
|
||||||
|
close(s);
|
||||||
continue;
|
continue;
|
||||||
sprintf( port, ":%d", i );
|
}
|
||||||
|
close(s);
|
||||||
}
|
}
|
||||||
close(s);
|
|
||||||
|
// Cannot create socket with non-existing path, but Xserver code somehow does that
|
||||||
|
/*
|
||||||
|
s = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||||
|
if( s >= 0 )
|
||||||
|
{
|
||||||
|
struct sockaddr_un addr;
|
||||||
|
|
||||||
|
memset(&addr, 0, sizeof(addr));
|
||||||
|
|
||||||
|
addr.sun_family = AF_UNIX;
|
||||||
|
sprintf(addr.sun_path, "/tmp/.X11-unix/X%d", i);
|
||||||
|
if( bind(s, (struct sockaddr *) &addr, strlen(addr.sun_path) + sizeof(addr.sun_family)) != 0 )
|
||||||
|
{
|
||||||
|
__android_log_print(ANDROID_LOG_INFO, "XSDL", "UNIX path %s already used, trying next one: %s", addr.sun_path, strerror(errno));
|
||||||
|
close(s);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
close(s);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
sprintf( port, ":%d", i );
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( argc > 1 && strcmp(argv[1], "-nohelp") == 0 )
|
if( argc > 1 && strcmp(argv[1], "-nohelp") == 0 )
|
||||||
@@ -97,3 +133,21 @@ int main( int argc, char* argv[] )
|
|||||||
|
|
||||||
return android_main( ARGNUM, args, envp );
|
return android_main( ARGNUM, args, envp );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setupEnv(void)
|
||||||
|
{
|
||||||
|
uid_t uid = geteuid();
|
||||||
|
struct passwd * pwd;
|
||||||
|
char buf[32];
|
||||||
|
errno = 0;
|
||||||
|
pwd = getpwuid(uid);
|
||||||
|
if( !pwd )
|
||||||
|
{
|
||||||
|
__android_log_print(ANDROID_LOG_INFO, "XSDL", "Cannot determine user name for ID %d: %s", uid, strerror(errno));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sprintf( buf, "%d", uid );
|
||||||
|
__android_log_print(ANDROID_LOG_INFO, "XSDL", "User %s ID %s", pwd->pw_name, buf);
|
||||||
|
setenv("USER_ID", buf, 1);
|
||||||
|
setenv("USER", pwd->pw_name, 1);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user