예제 #1
0
static void _pam_dump_env(pam_handle_t *pamh)
{
    int i;

    D(("Listing environment of pamh=%p", pamh));
    D(("pamh->env = %p", pamh->env));
    D(("environment entries used = %d [of %d allocated]"
       , pamh->env->requested, pamh->env->entries));

    for (i=0; i<pamh->env->requested; ++i) {
	_pam_output_debug(">%-3d [%9p]:[%s]"
			  , i, pamh->env->list[i], pamh->env->list[i]);
    }
    _pam_output_debug("*NOTE* the last item should be (nil)");
}
예제 #2
0
static void _pam_output_xdebug_info(void)
{
    FILE *logfile;
    int must_close = 1, fd;

#ifdef O_NOFOLLOW
    if ((fd = open(_PAM_LOGFILE, O_WRONLY|O_NOFOLLOW|O_APPEND)) != -1) {
#else
    if ((fd = open(_PAM_LOGFILE, O_WRONLY|O_APPEND)) != -1) {
#endif
	if (!(logfile = fdopen(fd,"a"))) {
	    logfile = stderr;
	    must_close = 0;
	    close(fd);
	}
    } else {
	logfile = stderr;
	must_close = 0;
    }
    fprintf(logfile, "[%s:%s(%d)->%s()] ",
           last_file, last_call, last_line, last_fn);
    fflush(logfile);
    if (must_close)
        fclose(logfile);
}

static void hinder(void)
{
     if (on(PAM_MALLOC_PAUSE)) {
	  if (on(0)) err(("pause requested"));
	  sleep(pam_malloc_delay_length);
     }

     if (on(PAM_MALLOC_STOP)) {
	  if (on(0)) err(("stop requested"));
	  exit(1);
     }
}

/*
 * here are the memory pointer registering functions.. these actually
 * use malloc(!) but that's ok! ;^)
 */

struct reference {
     void *ptr;          /* pointer */
     int nelements;      /* number of elements */
     int size;           /* - each of this size */
     char *file;         /* where it was requested - filename */
     char *function;     /*                        - function */
     int line;           /*                        - line number */
/*
 * linking info
 */
     struct reference *next;
};

static void _dump(const char *say, const struct reference *ref)
{
    _pam_output_debug(" <%s: %p (#%d of %d) req. by %s(); %s line %d>\n"
		      , say
		      , ref->ptr,ref->nelements,ref->size
		      , ref->function,ref->file,ref->line);
}