Move all sanity checks to a separate function xrdp_sanity_check()

ulab-next-nosound
Pavel Roskin 9 years ago
parent cdb967c0f3
commit 86ec50789c

@ -293,65 +293,79 @@ xrdp_process_params(int argc, char **argv,
}
/*****************************************************************************/
int DEFAULT_CC
main(int argc, char **argv)
/* Basic sanity checks before any forking */
int
xrdp_sanity_check(void)
{
int test;
int intval = 1;
int host_be;
char cfg_file[256];
enum logReturns error;
struct xrdp_startup_params *startup_params;
int pid;
int fd;
int no_daemon;
char text[256];
char pid_file[256];
g_init("xrdp");
ssl_init();
for (test = 0; test < argc; test++)
{
DEBUG(("Argument %i - %s", test, argv[test]));
}
/* check compiled endian with actual endian */
test = 1;
host_be = !((int)(*(unsigned char *)(&test)));
host_be = !((int)(*(unsigned char *)(&intval)));
#if defined(B_ENDIAN)
if (!host_be)
{
g_writeln("Not a big endian machine, edit arch.h");
return 1;
}
#endif
#if defined(L_ENDIAN)
if (host_be)
if (host_be)
{
g_writeln("Not a little endian machine, edit arch.h");
return 1;
}
#endif
{
g_writeln("endian wrong, edit arch.h");
return 0;
}
/* check long, int and void* sizes */
if (sizeof(int) != 4)
{
g_writeln("unusable int size, must be 4");
return 0;
return 1;
}
if (sizeof(long) != sizeof(void *))
{
g_writeln("long size must match void* size");
return 0;
return 1;
}
if (sizeof(long) != 4 && sizeof(long) != 8)
{
g_writeln("unusable long size, must be 4 or 8");
return 0;
return 1;
}
if (sizeof(tui64) != 8)
{
g_writeln("unusable tui64 size, must be 8");
return 0;
return 1;
}
return 0;
}
/*****************************************************************************/
int DEFAULT_CC
main(int argc, char **argv)
{
int test;
char cfg_file[256];
enum logReturns error;
struct xrdp_startup_params *startup_params;
int pid;
int fd;
int no_daemon;
char text[256];
char pid_file[256];
g_init("xrdp");
ssl_init();
for (test = 0; test < argc; test++)
{
DEBUG(("Argument %i - %s", test, argv[test]));
}
g_snprintf(cfg_file, 255, "%s/xrdp.ini", XRDP_CFG_PATH);
@ -401,6 +415,13 @@ main(int argc, char **argv)
g_exit(0);
}
if (xrdp_sanity_check() != 0)
{
g_writeln("Fatal error occurred, exiting");
g_deinit();
g_exit(1);
}
if (startup_params->kill)
{
g_writeln("stopping xrdp");

Loading…
Cancel
Save