Пример #1
0
/* Digests a string and prints the result.
 */
static void MDString(char *string)
{
    apr_md4_ctx_t context;
    unsigned char digest[APR_MD4_DIGESTSIZE];
    unsigned int len = strlen(string);

    apr_md4_init(&context);
    apr_md4_update(&context, (unsigned char *)string, len);
    apr_md4_final(digest, &context);

    apr_file_printf (out, "MD4 (\"%s\") = ", string);
    MDPrint(digest);
    apr_file_printf (out, "\n");
}
Пример #2
0
/* Prints a message digest in hexadecimal.
 */
static void MDPrint (unsigned char digest[APR_MD4_DIGESTSIZE])
{
    unsigned int i;

    for (i = 0; i < APR_MD4_DIGESTSIZE; i++)
        apr_file_printf(out, "%02x", digest[i]);
}
Пример #3
0
/* Create FNAME with global `lines' as initial data.  Use EOL_STR as
 * the end-of-line marker between lines, or if EOL_STR is NULL, choose
 * a random marker at each opportunity.  Use POOL for any temporary
 * allocation.
 */
static svn_error_t *
create_file(const char *fname, const char *eol_str, apr_pool_t *pool)
{
  apr_status_t apr_err;
  apr_file_t *f;
  apr_size_t i, j;

  apr_err = apr_file_open(&f, fname,
                          (APR_WRITE | APR_CREATE | APR_EXCL | APR_BINARY),
                          APR_OS_DEFAULT, pool);
  if (apr_err)
    return svn_error_create(apr_err, NULL, fname);

  for (i = 0; i < (sizeof(lines) / sizeof(*lines)); i++)
    {
      const char *this_eol_str = eol_str ? eol_str : random_eol_marker();

      apr_err = apr_file_printf(f, "%s", lines[i]);

      /* Is it overly paranoid to use putc(), because of worry about
         fprintf() doing a newline conversion? */
      for (j = 0; this_eol_str[j]; j++)
        {
          apr_err = apr_file_putc(this_eol_str[j], f);
          if (apr_err)
            return svn_error_create(apr_err, NULL, fname);
        }
    }

  apr_err = apr_file_close(f);
  if (apr_err)
    return svn_error_create(apr_err, NULL, fname);

  return SVN_NO_ERROR;
}
Пример #4
0
/*++

LogFormatV

    Adds an entry to the log file.

Arguments:
    level   - Log severity level.

    format  - Pointer to a buffer containing a printf-style format string.

    argList - Argument list to insert into 'format'.

Return Values:
    None.

Remarks:
    This function could be called before the logging subsystem is initialized.

--*/
void
LogFormatV(
    apr_uint32_t level,
    const char *format,
    va_list argList
    )
{
    apr_time_exp_t now;
    char *message;

    ASSERT(format != NULL);

    if (level <= maxLevel && handle != NULL) {
        // Write local time
        apr_time_exp_lt(&now, apr_time_now());
        apr_file_printf(handle, "%04d-%02d-%02d %02d:%02d:%02d - ",
            now.tm_year+1900, now.tm_mon, now.tm_mday,
            now.tm_hour, now.tm_min, now.tm_sec);

        // Format and write log message
        message = apr_pvsprintf(msgPool, format, argList);
        if (message == NULL) {
            message = "Unable to format message." APR_EOL_STR;
        }
        apr_file_puts(message, handle);
        apr_file_flush(handle);

        // Clear memory allocated when formatting the message
        apr_pool_clear(msgPool);
    }
}
Пример #5
0
static int generate_salt(char *s, size_t size, const char **errstr,
                         apr_pool_t *pool)
{
    unsigned char rnd[32];
    static const char itoa64[] =
        "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
    apr_size_t n;
    unsigned int val = 0, bits = 0;
    apr_status_t rv;

    n = (size * 6 + 7)/8;
    if (n > sizeof(rnd)) {
        apr_file_printf(errfile, "generate_salt(): BUG: Buffer too small");
        abort();
    }
    rv = apr_generate_random_bytes(rnd, n);
    if (rv) {
        *errstr = apr_psprintf(pool, "Unable to generate random bytes: %pm",
                               &rv);
        return ERR_RANDOM;
    }
    n = 0;
    while (size > 0) {
        if (bits < 6) {
            val |= (rnd[n++] << bits);
            bits += 8;
        }
        *s++ = itoa64[val & 0x3f];
        size--;
        val >>= 6;
        bits -= 6;
   }
   *s = '\0';
   return 0;
}
Пример #6
0
static void preserve_entry(request_rec *r, const char *query)
{
	logsql_state *cls = ap_get_module_config(r->server->module_config,
											&log_sql_module);
	#if defined(WITH_APACHE20)
		apr_file_t *fp;
		apr_status_t result;
	#elif defined(WITH_APACHE13)
		FILE *fp;
		int result;
	#endif
	/* If preserve file is disabled bail out */
	if (global_config.disablepreserve)
       return;
    #if defined(WITH_APACHE20)
		result = apr_file_open(&fp, cls->preserve_file,APR_APPEND | APR_WRITE | APR_CREATE, APR_OS_DEFAULT, r->pool);
    #elif defined(WITH_APACHE13)
		fp = ap_pfopen(r->pool, cls->preserve_file, "a");
		result = (fp)?0:errno;
    #endif
    if (result != APR_SUCCESS) {
		log_error(APLOG_MARK, APLOG_ERR, result, r->server,
			"attempted append of local preserve file '%s' but failed.",cls->preserve_file);
	} else {
		#if defined(WITH_APACHE20)
			apr_file_printf(fp,"%s;\n", query);
			apr_file_close(fp);
		#elif defined(WITH_APACHE13)
			fprintf(fp,"%s;\n", query);
			ap_pfclose(r->pool, fp);
		#endif
		log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
			"mod_log_sql: entry preserved in %s", cls->preserve_file);
	}
}
Пример #7
0
int logging_rotateLogFile(mm_logger* log) {
    mm_logger* ltmp;
    apr_finfo_t finfo;
    apr_time_t tnow;
    apr_time_exp_t texp;
    apr_status_t st;
    apr_size_t tbuflen,tbufmax=64;
    char tbuf[64],*newPath;

    st=apr_stat(&finfo,log->filepath,APR_FINFO_SIZE,log->p);

    if(finfo.size > log->maxLogFileSizeMB*1024*1024) {
        apr_file_printf(log->file,"Monitor File Size [%dB], Max Value [%dB].\r\n",finfo.size,log->maxLogFileSizeMB*1024*1024);
        logging_closeLogger(log);
        log->file=NULL;

        tnow=apr_time_now();
        memset(tbuf,'\0',64);
        apr_time_exp_lt(&texp,tnow);
        apr_strftime(tbuf,&tbuflen,tbufmax,"%F-%H_%M_%S",&texp);
        newPath=apr_psprintf(log->p,"%s.%s.%d",log->filepath,tbuf,texp.tm_usec);
        apr_file_rename(log->filepath,newPath,log->p);
        ltmp=logging_getLogger(log->p,log->filepath,log->maxLogFileSizeMB);
        log->file=ltmp->file;

        return TRUE;
    }
    return FALSE;
}
Пример #8
0
/*
 * called on SIGINT or SIGTERM
 */
static void setterm(int unused)
{
#ifdef DEBUG
    apr_file_printf(errfile, "interrupt" APR_EOL_STR);
#endif
    interrupted = 1;
}
Пример #9
0
static void usage(void)
{
    apr_file_printf(errfile, "Usage:" NL
        "\thtpasswd [-cimBdpsD] [-C cost] passwordfile username" NL
        "\thtpasswd -b[cmBdpsD] [-C cost] passwordfile username password" NL
        NL
        "\thtpasswd -n[imBdps] [-C cost] username" NL
        "\thtpasswd -nb[mBdps] [-C cost] username password" NL
        " -c  Create a new file." NL
        " -n  Don't update file; display results on stdout." NL
        " -b  Use the password from the command line rather than prompting "
            "for it." NL
        " -i  Read password from stdin without verification (for script usage)." NL
        " -m  Force MD5 encryption of the password (default)." NL
        " -B  Force bcrypt encryption of the password (very secure)." NL
        " -C  Set the computing time used for the bcrypt algorithm" NL
        "     (higher is more secure but slower, default: %d, valid: 4 to 31)." NL
        " -d  Force CRYPT encryption of the password (8 chars max, insecure)." NL
        " -s  Force SHA encryption of the password (insecure)." NL
        " -p  Do not encrypt the password (plaintext, insecure)." NL
        " -D  Delete the specified user." NL
        "On other systems than Windows and NetWare the '-p' flag will "
            "probably not work." NL
        "The SHA algorithm does not use a salt and is less secure than the "
            "MD5 algorithm." NL,
        BCRYPT_DEFAULT_COST
    );
    exit(ERR_SYNTAX);
}
Пример #10
0
static void test_bigfprintf(abts_case *tc, void *data)
{
    apr_file_t *f;
    const char *fname = "data/testbigfprintf.dat";
    char *to_write;
    int i;

    apr_file_remove(fname, p);

    APR_ASSERT_SUCCESS(tc, "open test file",
                       apr_file_open(&f, fname,
                                     APR_CREATE|APR_WRITE,
                                     APR_UREAD|APR_UWRITE, p));
    

    to_write = malloc(HUGE_STRING_LEN + 3);

    for (i = 0; i < HUGE_STRING_LEN + 1; ++i)
        to_write[i] = 'A' + i%26;

    strcpy(to_write + HUGE_STRING_LEN, "42");

    i = apr_file_printf(f, "%s", to_write);
    ABTS_INT_EQUAL(tc, HUGE_STRING_LEN + 2, i);

    apr_file_close(f);

    file_contents_equal(tc, fname, to_write, HUGE_STRING_LEN + 2);

    free(to_write);
}
/* Called from apr_proc_create() if there are errors during launch of child
 * process.  Mostly just lifted from mod_cgi. */
static void extchilderr(apr_pool_t *p, apr_status_t err, const char *desc)
{
    apr_file_t *stderr_log;
    char errbuf[200];
    apr_file_open_stderr(&stderr_log, p);
    apr_file_printf(stderr_log,"%s: (%d) %s\n", ap_escape_logitem(p,desc),
	err, apr_strerror(err,errbuf,sizeof(errbuf)));
}
Пример #12
0
SWITCH_DECLARE(int) switch_file_printf(switch_file_t *thefile, const char *format, ...)
{
	va_list ap;
	int ret;
	va_start(ap, format);
	ret = apr_file_printf(thefile, format, ap);
	va_end(ap);
	return ret;
}
Пример #13
0
static void fake_file_remove(char *pathname, apr_pool_t *p)
{
    apr_finfo_t info;

    /* stat and printing to simulate some deletion system load and to
       display what would actually have happened */
    apr_stat(&info, pathname, DIRINFO, p);
    apr_file_printf(errfile, "would delete %s" APR_EOL_STR, pathname);
}
BOOL LLStateDiagram::saveDotFile(const std::string& filename)
{
	LLAPRFile outfile ;
	outfile.open(filename, LL_APR_W);
	
	// <FS:ND> Remove LLVolatileAPRPool/apr_file_t and use FILE* instead
	// apr_file_t* dot_file = outfile.getFileHandle() ;
	LLAPRFile::tFiletype* dot_file = outfile.getFileHandle() ;
	// </FS:ND>

	if (!dot_file)
	{
		LL_WARNS() << "LLStateDiagram::saveDotFile() : Couldn't open " << filename << " to save state diagram." << LL_ENDL;
		return FALSE;
	}
	apr_file_printf(dot_file, "digraph StateMachine {\n\tsize=\"100,100\";\n\tfontsize=40;\n\tlabel=\"Finite State Machine\";\n\torientation=landscape\n\tratio=.77\n");
	
	StateMap::iterator state_it;
	for(state_it = mStates.begin(); state_it != mStates.end(); ++state_it)
	{
		apr_file_printf(dot_file, "\t\"%s\" [fontsize=28,shape=box]\n", state_it->first->getName().c_str());
	}
	apr_file_printf(dot_file, "\t\"All States\" [fontsize=30,style=bold,shape=box]\n");

	Transitions::iterator transitions_it;
	for(transitions_it = mDefaultTransitions.begin(); transitions_it != mDefaultTransitions.end(); ++transitions_it)
	{
		apr_file_printf(dot_file, "\t\"All States\" -> \"%s\" [label = \"%s\",fontsize=24];\n", transitions_it->second->getName().c_str(), 
			transitions_it->second->getName().c_str());
	}

	if (mDefaultState)
	{
		apr_file_printf(dot_file, "\t\"All States\" -> \"%s\";\n", mDefaultState->getName().c_str());
	}

	
	for(state_it = mStates.begin(); state_it != mStates.end(); ++state_it)
	{
		LLFSMState *state = state_it->first;

		Transitions::iterator transitions_it;
		for(transitions_it = state_it->second.begin();
			transitions_it != state_it->second.end();
			++transitions_it)
		{
			std::string state_name = state->getName();
			std::string target_name = transitions_it->second->getName();
			std::string transition_name = transitions_it->first->getName();
			apr_file_printf(dot_file, "\t\"%s\" -> \"%s\" [label = \"%s\",fontsize=24];\n", state->getName().c_str(), 
				target_name.c_str(), 
				transition_name.c_str());
		}
	}

	apr_file_printf(dot_file, "}\n");

	return TRUE;
}
Пример #15
0
void putline(apr_file_t *f, const char *l)
{
    apr_status_t rv;
    rv = apr_file_puts(l, f);
    if (rv != APR_SUCCESS) {
        apr_file_printf(errfile, "Error writing temp file: %pm", &rv);
        apr_file_close(f);
        exit(ERR_FILEPERM);
    }
}
Пример #16
0
void mmlog_printf(mm_logger* log,const char* a_format, ...) {
    va_list va;
    //apr_time_t tnow;
    //char tbuf[64];
    char buffer[BUFFERSIZE];
    memset(buffer, '\0', BUFFERSIZE);
    va_start(va, a_format);
    vsnprintf(buffer, BUFFERSIZE-1, a_format, va);
    apr_file_printf(log->file,"%s\r\n",buffer);
    va_end(va);
}
Пример #17
0
static apr_status_t seed_rand(void)
{
    int seed = 0;
    apr_status_t rv;
    rv = apr_generate_random_bytes((unsigned char*) &seed, sizeof(seed));
    if (rv) {
        apr_file_printf(errfile, "Unable to generate random bytes: %pm" NL, &rv);
        return rv;
    }
    srand(seed);
    return rv;
}
Пример #18
0
static void usage(void)
{
    const char *have_sdbm;
    const char *have_gdbm;
    const char *have_ndbm;
    const char *have_db;

#if APU_HAVE_SDBM
    have_sdbm = AVAIL;
#else
    have_sdbm = UNAVAIL;
#endif
#if APU_HAVE_GDBM
    have_gdbm = AVAIL;
#else
    have_gdbm = UNAVAIL;
#endif
#if APU_HAVE_NDBM
    have_ndbm = AVAIL;
#else
    have_ndbm = UNAVAIL;
#endif
#if APU_HAVE_DB
    have_db = AVAIL;
#else
    have_db = UNAVAIL;
#endif

    apr_file_printf(errfile,
    "%s -- Program to Create DBM Files for use by RewriteMap" NL
    "Usage: %s [-v] [-f format] -i SOURCE_TXT -o OUTPUT_DBM" NL
    NL
    "Options: " NL
    " -v    More verbose output"NL
    NL
    " -i    Source Text File. If '-', use stdin."NL
    NL
    " -o    Output DBM."NL
    NL
    " -f    DBM Format.  If not specified, will use the APR Default." NL
    "           GDBM for GDBM files (%s)" NL
    "           SDBM for SDBM files (%s)" NL
    "           DB   for berkeley DB files (%s)" NL
    "           NDBM for NDBM files (%s)" NL
    "           default for the default DBM type" NL
    NL,
    shortname,
    shortname,
    have_gdbm,
    have_sdbm,
    have_db,
    have_ndbm);
}
Пример #19
0
static void putline(apr_file_t *f, const char *l)
{
    apr_status_t rc;
    rc = apr_file_puts(l, f);
    if (rc != APR_SUCCESS) {
        char errstr[MAX_STRING_LEN];
        apr_strerror(rc, errstr, MAX_STRING_LEN);
        apr_file_printf(errfile, "Error writing temp file: %s" NL, errstr);
        apr_file_close(f);
        exit(ERR_FILEPERM);
    }
}
Пример #20
0
/* Digests a reference suite of strings and prints the results.
 */
static void MDTestSuite(void)
{
    apr_file_printf(out, "MD4 test suite:\n");

    MDString("");
    MDString("a");
    MDString("abc");
    MDString("message digest");
    MDString("abcdefghijklmnopqrstuvwxyz");
    MDString("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");
    MDString("12345678901234567890123456789012345678901234567890123456789012345678901234567890");
}
Пример #21
0
static void add_password(const char *user, const char *realm, apr_file_t *f)
{
    char *pw;
    apr_md5_ctx_t context;
    unsigned char digest[16];
    char string[MAX_STRING_LEN];
    char pwin[MAX_STRING_LEN];
    char pwv[MAX_STRING_LEN];
    unsigned int i;
    apr_size_t len = sizeof(pwin);

    if (apr_password_get("New password: "******"password too long");
        cleanup_tempfile_and_exit(5);
    }
    len = sizeof(pwin);
    apr_password_get("Re-type new password: "******"They don't match, sorry.\n");
        cleanup_tempfile_and_exit(1);
    }
    pw = pwin;
    apr_file_printf(f, "%s:%s:", user, realm);

    /* Do MD5 stuff */
    sprintf(string, "%s:%s:%s", user, realm, pw);

    apr_md5_init(&context);
#if APR_CHARSET_EBCDIC
    apr_md5_set_xlate(&context, to_ascii);
#endif
    apr_md5_update(&context, (unsigned char *) string, strlen(string));
    apr_md5_final(digest, &context);

    for (i = 0; i < 16; i++)
        apr_file_printf(f, "%02x", digest[i]);

    apr_file_printf(f, "\n");
}
Пример #22
0
AP_DECLARE(void) ap_log_pid(apr_pool_t *p, const char *filename)
{
    apr_file_t *pid_file = NULL;
    apr_finfo_t finfo;
    static pid_t saved_pid = -1;
    pid_t mypid;
    apr_status_t rv;
    const char *fname;

    if (!filename) {
        return;
    }

    fname = ap_server_root_relative(p, filename);
    if (!fname) {
        ap_log_error(APLOG_MARK, APLOG_STARTUP|APLOG_CRIT, APR_EBADPATH,
                     NULL, "Invalid PID file path %s, ignoring.", filename);
        return;
    }

    mypid = getpid();
    if (mypid != saved_pid
        && apr_stat(&finfo, fname, APR_FINFO_MTIME, p) == APR_SUCCESS) {
        /* AP_SIG_GRACEFUL and HUP call this on each restart.
         * Only warn on first time through for this pid.
         *
         * XXX: Could just write first time through too, although
         *      that may screw up scripts written to do something
         *      based on the last modification time of the pid file.
         */
        ap_log_perror(APLOG_MARK, APLOG_WARNING, 0, p,
                      "pid file %s overwritten -- Unclean "
                      "shutdown of previous Apache run?",
                      fname);
    }

    if ((rv = apr_file_open(&pid_file, fname,
                            APR_WRITE | APR_CREATE | APR_TRUNCATE,
                            APR_UREAD | APR_UWRITE | APR_GREAD | APR_WREAD, p))
        != APR_SUCCESS) {
        ap_log_error(APLOG_MARK, APLOG_ERR, rv, NULL,
                     "could not create %s", fname);
        ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL,
                     "%s: could not log pid to file %s",
                     ap_server_argv0, fname);
        exit(1);
    }
    apr_file_printf(pid_file, "%ld" APR_EOL_STR, (long)mypid);
    apr_file_close(pid_file);
    saved_pid = mypid;
}
Пример #23
0
/* Measures the time to digest TEST_BLOCK_COUNT TEST_BLOCK_LEN-byte
     blocks.
 */
static void MDTimeTrial(void)
{
    apr_md4_ctx_t context;
    apr_time_t endTime, startTime;
    apr_interval_time_t timeTaken;
    unsigned char block[TEST_BLOCK_LEN], digest[APR_MD4_DIGESTSIZE];
    unsigned int i;

    apr_file_printf(out, "MD4 time trial. Digesting %d %d-byte blocks ...", 
                     TEST_BLOCK_LEN, TEST_BLOCK_COUNT);

    /* Initialize block */
    for (i = 0; i < TEST_BLOCK_LEN; i++)
        block[i] = (unsigned char)(i & 0xff);

    /* Start timer */
    startTime = apr_time_now();

    /* Digest blocks */
    apr_md4_init(&context);
    for (i = 0; i < TEST_BLOCK_COUNT; i++)
        apr_md4_update(&context, block, TEST_BLOCK_LEN);

    apr_md4_final(digest, &context);

    /* Stop timer */
    endTime = apr_time_now();
    timeTaken = endTime - startTime;

    apr_file_printf(out, " done\n");
    apr_file_printf(out, "Digest = ");
    MDPrint(digest);

    apr_file_printf(out, "\nTime = %" APR_TIME_T_FMT " seconds\n", timeTaken);
    apr_file_printf(out, "Speed = % " APR_TIME_T_FMT " bytes/second\n",
                    TEST_BLOCK_LEN * TEST_BLOCK_COUNT/timeTaken);
}
Пример #24
0
static void dump_loaded_modules(apr_pool_t *p, server_rec *s)
{
    ap_module_symbol_t *modie;
    ap_module_symbol_t *modi;
    so_server_conf *sconf;
    int i;
    apr_file_t *out = NULL;

    if (!ap_exists_config_define("DUMP_MODULES")) {
        return;
    }

    apr_file_open_stderr(&out, p);

    apr_file_printf(out, "Loaded Modules:\n");

    sconf = (so_server_conf *)ap_get_module_config(s->module_config,
                                                   &so_module);
    for (i = 0; ; i++) {
        modi = &ap_prelinked_module_symbols[i];
        if (modi->name != NULL) {
            apr_file_printf(out, " %s (static)\n", modi->name);
        }
        else {
            break;
        }
    }

    modie = (ap_module_symbol_t *)sconf->loaded_modules->elts;
    for (i = 0; i < sconf->loaded_modules->nelts; i++) {
        modi = &modie[i];
        if (modi->name != NULL) {
            apr_file_printf(out, " %s (shared)\n", modi->name);
        }
    }
}
Пример #25
0
/* Digests the standard input and prints the result.
 */
static void MDFilter(void)
{
    apr_md4_ctx_t context;
    apr_size_t len = 16;
    unsigned char buffer[16], digest[16];

    apr_md4_init(&context);
    while (apr_file_read(in, buffer, &len) != APR_SUCCESS)
    {
        apr_md4_update(&context, buffer, len);
        len = 16;
    }
    apr_md4_update(&context, buffer, len);
    apr_md4_final(digest, &context);

    MDPrint(digest);
    apr_file_printf(out, "\n");
}
Пример #26
0
static void usage(void)
{
    apr_file_printf(errfile,
    "%s -- program for cleaning the disk cache."                             NL
    "Usage: %s [-Dvtrn] -pPATH -lLIMIT"                                      NL
    "       %s [-nti] -dINTERVAL -pPATH -lLIMIT"                             NL
                                                                             NL
    "Options:"                                                               NL
    "  -d   Daemonize and repeat cache cleaning every INTERVAL minutes."     NL
    "       This option is mutually exclusive with the -D, -v and -r"        NL
    "       options."                                                        NL
                                                                             NL
    "  -D   Do a dry run and don't delete anything. This option is mutually" NL
    "       exclusive with the -d option."                                   NL
                                                                             NL
    "  -v   Be verbose and print statistics. This option is mutually"        NL
    "       exclusive with the -d option."                                   NL
                                                                             NL
    "  -r   Clean thoroughly. This assumes that the Apache web server is "   NL
    "       not running. This option is mutually exclusive with the -d"      NL
    "       option and implies -t."                                          NL
                                                                             NL
    "  -n   Be nice. This causes slower processing in favour of other"       NL
    "       processes."                                                      NL
                                                                             NL
    "  -t   Delete all empty directories. By default only cache files are"   NL
    "       removed, however with some configurations the large number of"   NL
    "       directories created may require attention."                      NL
                                                                             NL
    "  -p   Specify PATH as the root directory of the disk cache."           NL
                                                                             NL
    "  -l   Specify LIMIT as the total disk cache size limit. Attach 'K'"    NL
    "       or 'M' to the number for specifying KBytes or MBytes."           NL
                                                                             NL
    "  -i   Be intelligent and run only when there was a modification of"    NL
    "       the disk cache. This option is only possible together with the"  NL
    "       -d option."                                                      NL,
    shortname,
    shortname,
    shortname
    );

    exit(1);
}
Пример #27
0
void logging_log(mm_logger* log,const char* a_format, ...) {
    va_list va;
    //int i=0;
    apr_time_t tnow;
    char tbuf[64];
    char buffer[BUFFERSIZE];
    memset(buffer, '\0', BUFFERSIZE);

    if(log->maxLogFileSizeMB>0) logging_rotateLogFile(log);

    va_start(va, a_format);
    vsnprintf(buffer, BUFFERSIZE-1, a_format, va);

    tnow=apr_time_now();
    memset(tbuf,'\0',64);
    apr_ctime(tbuf,tnow);
    apr_file_printf(log->file,"%s mm.monitor.refresh [%d] %s\r\n",tbuf,getpid(),buffer);
    va_end(va);
}
Пример #28
0
/** Record the master job pid into a file on disc. */
static int
trell_set_master_pid( trell_sconf_t* svr_conf,  request_rec* r, pid_t pid )
{
    apr_status_t rv;

    apr_file_t* pidfile = NULL;
    rv = apr_file_open( &pidfile, master_job_pidfile_path,
                        APR_FOPEN_CREATE | APR_WRITE | APR_TRUNCATE | APR_XTHREAD,
                        APR_OS_DEFAULT, r->pool );
    if( rv != APR_SUCCESS ) {
        ap_log_rerror( APLOG_MARK, APLOG_CRIT, rv, r, "mod_trell: Failed to open master job pid file for writing." );
        return rv;
    }
    
    apr_file_printf( pidfile, "%d\n", pid );
    apr_file_close( pidfile );
    
    return APR_SUCCESS;
}
static void child_errfn(apr_pool_t *pool, apr_status_t err, const char *description)
{
    request_rec *r;
    void *vr;
    apr_file_t *stderr_log;
    char errbuf[200];
    char time_str[APR_CTIME_LEN];

    apr_pool_userdata_get(&vr, ERRFN_USERDATA_KEY, pool);
    r = vr;
    apr_file_open_stderr(&stderr_log, pool);
    ap_recent_ctime(time_str, apr_time_now());
    apr_file_printf(stderr_log,
                    "[%s] [client %s] mod_ext_filter (%d)%s: %s\n",
                    time_str,
                    r->connection->remote_ip,
                    err,
                    apr_strerror(err, errbuf, sizeof(errbuf)),
                    description);
}
Пример #30
0
static void cgi_child_errfn(apr_pool_t *pool, apr_status_t err,
                            const char *description)
{
    apr_file_t *stderr_log;

    apr_file_open_stderr(&stderr_log, pool);
    /* Escape the logged string because it may be something that
     * came in over the network.
     */
    apr_file_printf(stderr_log,
                    "(%d)%pm: %s\n",
                    err,
                    &err,
#ifndef AP_UNSAFE_ERROR_LOG_UNESCAPED
                    ap_escape_logitem(pool,
#endif
                                      description
#ifndef AP_UNSAFE_ERROR_LOG_UNESCAPED
                                     )
#endif
                   );
}