Usenet comp.unix.tru64 (2000-2013)
 help / color / mirror / Atom feed
From: pablo_endres@digitel.com.ve (Pablo Endres)
Subject: Tru64 compile/link problem
Date: 17 Oct 2003 12:48:36 -0700	[thread overview]
Message-ID: <336f1a66.0310171148.11eeb41e@posting.google.com> (raw)

I've been trying to port a linx program to Tru64 for sometime now
 but haven�t been able to do it.  I've learned a lot from your page
 and wan't to see if you can help me out.
 
 The software is called snoopylogger
 (http://www.citi.umich.edu/u/marius/snoopy/).
 
 Basiclly it works like this:
 
 You compile the software and place it first in the library_path.  All
 it does is log all the calls to execv and execve and then call the
 correct symbol in the C library.
 
 In Linux it works perfectlly, but when I try tu use it in Tru64 all
 I get is: seg fault.  The Linux/Solaris Makefile uses de '-ldl' flag,
 on Tru64 it doesn't work.  I'm using gcc-3.2.2 20030222.
 
 Could you help me out.  There must be some ld flag that I'm missing
 but i have no idea where else to look.

Here is the code:

#include <dlfcn.h>
#include <stdio.h>
#include <syslog.h>
#include "snoopy.h"

#if defined(RTLD_NEXT)
#  define REAL_LIBC RTLD_NEXT
#else
#  define REAL_LIBC ((void *) -1L)
#endif

#define FN(ptr,type,name,args)  ptr = (type (*)args)dlsym (REAL_LIBC, name)

inline void log(const char *filename, char **argv) {

        static char **ptr, *logstring;
        static int size = MAX;
        static int (*guid)(void);

        FN(guid,int,"getuid",(void));

        ptr       = (char **)&argv[1];
        logstring = (char *)malloc((size_t *)size+2);
        openlog("snoopy", LOG_PID, LOG_AUTHPRIV);

        size -= snprintf(logstring, size,"[%s, uid:%d sid:%d]: %s",
                        getlogin(), (*guid)(), getsid(0), filename);

        while (*ptr && size > 0)
                size -= snprintf((logstring+MAX-size), size," %s",&(**ptr++));

        syslog(LOG_INFO, "%s", logstring);
        free(logstring);
        closelog();
}

int execve(const char *filename, char **argv, char **envp) {
        static int (*func)(const char *, char **, char **);

        FN(func,int,"execve",(const char *, char **, char **));

#if ROOT_ONLY
if ((*guid)() != 0) return (*func) (filename, argv, envp);
#endif

        log(filename, argv);

        return (*func) (filename, argv, envp);
}

int execv(const char *filename, char **argv) {
        static int (*func)(const char *, char **);

        FN(func,int,"execv",(const char *, char **));

#if ROOT_ONLY
if ((*guid)() != 0) return (*func) (filename, argv);
#endif

        log(filename, argv);

        return (*func) (filename, argv);
}

 
 Thanks in advance
 Pablo


             reply	other threads:[~2003-10-17 19:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-10-17 19:48 Pablo Endres [this message]
2003-10-17 20:10 ` Tru64 compile/link problem Ann Majeske
2003-11-20 20:24   ` Jeff Donsbach
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox