View this PageEdit this PageUploads to this PageVersions of this PageHomeRecent ChangesSearchHelp Guide

Ejecutar xrt_auth desde cualquier Linux




Friday, 23 October 2009, 5:57:09 pm
Hecho también para solaris con marina/altair El hostname es marinasim, y los fuentes del parche están en /home/metro/src.xrtwrapper.

xtrwrapper.c (solaris)


Makefile (solaris)
/*
 * xrtwrapper.c
 *
 * Simple library that substitutes gethostname
 *
 * History:
 *       4/12/2008 Creation
 *
 * Author: Dario Rodriguez dario@softhome.net
 * (c) 2008 SICOSOFT
 */
#include <unistd.h>

#if defined(_XPG4_2)
extern int gethostname(char *__name, size_t __len)
#elif  defined(__EXTENSIONS__) || \
        (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE))
extern int gethostname(char *__name, int __len)
#endif
{
        int i;
        char myhost[]={"marinasim"};
        if(__len<sizeof(myhost))
                return(-1);
        for(i=0;myhost[i]!='\0';i++)
                __name[i]=myhost[i];
        __name[i]='\0';
        return(0);
}
all: xrtwrapper.so test

xrtwrapper.so: xrtwrapper.c
        #gcc -Wall -fPIC -shared -Wl,-soname,xrtwrapper.so xrtwrapper.c -o xrtwrapper.so
        gcc -Wall -fPIC -shared xrtwrapper.c -o xrtwrapper.so

test: test.c
        gcc test.c -o test

clean:
        rm -f xrtwrapper.so test


test.sh (solaris)
#!/bin/sh
./test
LD_PRELOAD=`pwd`/xrtwrapper.so ./test


En el test.c no hubo que cambiar nada con respecto al usado en Linux (ver más abajo para su código fuente).

Friday, 5 December 2008, 10:00:25 am
Solucionado con LD_PRELOAD Confirmado con la documentación de este blog, la solución más sencilla es usar LD_PRELOAD (no confundir con LD_LIBRARY_PATH). El código resultante es el siguiente:
xtrwrapper.c


Makefile
/*
 * xrtwrapper.c
 *
 * Simple library that substitutes gethostname
 *
 * History:
 *       4/12/2008 Creation
 *
 * Author: Dario Rodriguez dario@softhome.net
 * (c) 2008 SICOSOFT
 */
#include <unistd.h>

extern int gethostname (char *__name, size_t __len)
{
        int i;
        char myhost[]={"salchichasim"};
        if(__len<sizeof(myhost))
                return(-1);
        for(i=0;myhost[i]!='\0';i++)
                __name[i]=myhost[i];
        __name[i]='\0';
        return(0);
}
all: xrtwrapper.so test

xrtwrapper.so: xrtwrapper.c
        gcc -Wall -fPIC -shared -Wl,-soname,xrtwrapper.so xrtwrapper.c -o xrtwrapper.so

test: test.c
        gcc test.c -o test

clean:
        rm -f xrtwrapper.so test


test.c
/*
 * test.c
 *
 * Prueba el gethostbyname().
 *
 * Historia:
 *      4/12/2008 Creacion.
 *
 * (c) 2008 SICOSOFT.
 */

#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>

int
main(int argc, char *argv[])
{
        char Name[1024];
        if(gethostname(Name,sizeof(Name))!=0)
                printf("ERROR\n");
        else
                printf("%s\n",Name);
        return(0);
}


test.sh
#!/bin/sh
export LD_PRELOAD=`pwd`/xrtwrapper.so
ldd ./test 
./test


Descripción del proyecto


xrt_auth de las XRT está licenciado para salchicha, con IP 3.0.1.170. A salchicha lo vamos a virtualizar en aika (3.0.1.171), pero al cambiar la IP, la licencia protesta.

Esta página documenta los pasos realizados para que el salchicha virtualizado siga siendo 3.0.1.170 para xrt_auth