Usenet comp.unix.tru64 (2000-2013)
 help / color / mirror / Atom feed
* Tru64 compile/link problem
@ 2003-10-17 19:48 Pablo Endres
  2003-10-17 20:10 ` Ann Majeske
  0 siblings, 1 reply; 3+ messages in thread
From: Pablo Endres @ 2003-10-17 19:48 UTC (permalink / 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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Tru64 compile/link problem
  2003-10-17 19:48 Tru64 compile/link problem Pablo Endres
@ 2003-10-17 20:10 ` Ann Majeske
  2003-11-20 20:24   ` Jeff Donsbach
  0 siblings, 1 reply; 3+ messages in thread
From: Ann Majeske @ 2003-10-17 20:10 UTC (permalink / raw)


"Pablo Endres" <pablo_endres@digitel.com.ve> wrote in message
news:336f1a66.0310171148.11eeb41e@posting.google.com...
>  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.

If all you're trying to do is find a way to log execv and execve calls,
why don't you look at the Audit subsystem?  Once it is built into
your system you can use it to log any syscall use on your system,
as well as other security related things like logins.  See the Security
Manual for more information.





^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Tru64 compile/link problem
  2003-10-17 20:10 ` Ann Majeske
@ 2003-11-20 20:24   ` Jeff Donsbach
  0 siblings, 0 replies; 3+ messages in thread
From: Jeff Donsbach @ 2003-11-20 20:24 UTC (permalink / raw)


Ann Majeske wrote:
> "Pablo Endres" <pablo_endres@digitel.com.ve> wrote in message
> news:336f1a66.0310171148.11eeb41e@posting.google.com...
> 
>> 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.
> 
> 
> If all you're trying to do is find a way to log execv and execve calls,
> why don't you look at the Audit subsystem?  Once it is built into
> your system you can use it to log any syscall use on your system,
> as well as other security related things like logins.  See the Security
> Manual for more information.
> 

This also looks like a very good candidate for an ATOM tool. And a 
pretty simple one at that.


--
Jeff Donsbach
Developer Resource Center	T/(978) 506-5227
HP Partner Technical Services	jeff.donsbach@hp.com



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-11-20 20:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-10-17 19:48 Tru64 compile/link problem Pablo Endres
2003-10-17 20:10 ` Ann Majeske
2003-11-20 20:24   ` Jeff Donsbach

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