本文整理汇总了C++中debug1函数的典型用法代码示例。如果您正苦于以下问题:C++ debug1函数的具体用法?C++ debug1怎么用?C++ debug1使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了debug1函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: buffer_loop
//.........这里部分代码省略.........
debug("handling usr1flag");
usr1flag = FALSE;
/* close and re-open in order to flush
* the device's internal buffer before
* changing the sample rate. [OF]
*/
/* writer must block when sending SIGUSR1
* or we will lose all data processed
* in the meantime! [dk]
*/
xf->readindex = xf->freeindex;
/* We've nailed down the new starting location -
* writer is now safe to go on. [dk]
*/
if (xf->wakeme[XF_WRITER])
xfermem_putcmd(my_fd, XF_CMD_WAKEUP);
ao->rate = xf->rate;
ao->channels = xf->channels;
ao->format = xf->format;
if (reset_output(ao) < 0) {
error1("failed to reset audio: %s", strerror(errno));
exit(1);
}
}
if ( (bytes = xfermem_get_usedspace(xf)) < outburst ) {
/* if we got a buffer underrun we first
* fill 1/8 of the buffer before continue/start
* playing */
if (preload < xf->size>>3)
preload = xf->size>>3;
if(preload < outburst)
preload = outburst;
}
debug1("bytes: %i", bytes);
if(xf->justwait || bytes < preload) {
int cmd;
if (done && !bytes) {
break;
}
if(xf->justwait || !done) {
/* Don't spill into errno check below. */
errno = 0;
cmd = xfermem_block(XF_READER, xf);
debug1("got %i", cmd);
switch(cmd) {
/* More input pending. */
case XF_CMD_WAKEUP_INFO:
continue;
/* Yes, we know buffer is low but
* know we don't care.
*/
case XF_CMD_WAKEUP:
break; /* Proceed playing. */
case XF_CMD_ABORT: /* Immediate end, discard buffer contents. */
return; /* Cleanup happens outside of buffer_loop()*/
case XF_CMD_TERMINATE: /* Graceful end, playing stuff in buffer and then return. */
debug("going to terminate");
done = TRUE;
break;
case XF_CMD_RESYNC:
debug("ordered resync");
if (param.outmode == DECODE_AUDIO) ao->flush(ao);
开发者ID:github188,项目名称:SimpleCode,代码行数:66,代码来源:buffer.c
示例2: main_analysisd
int main_analysisd(int argc, char **argv)
#endif
{
int c = 0, m_queue = 0, test_config = 0,run_foreground = 0;
int debug_level = 0;
char *dir = DEFAULTDIR;
char *user = USER;
char *group = GROUPGLOBAL;
int uid = 0,gid = 0;
char *cfg = DEFAULTCPATH;
/* Setting the name */
OS_SetName(ARGV0);
thishour = 0;
today = 0;
prev_year = 0;
memset(prev_month, '\0', 4);
hourly_alerts = 0;
hourly_events = 0;
hourly_syscheck = 0;
hourly_firewall = 0;
while((c = getopt(argc, argv, "Vtdhfu:g:D:c:")) != -1){
switch(c){
case 'V':
print_version();
break;
case 'h':
help_analysisd();
break;
case 'd':
nowDebug();
debug_level = 1;
break;
case 'f':
run_foreground = 1;
break;
case 'u':
if(!optarg)
ErrorExit("%s: -u needs an argument",ARGV0);
user = optarg;
break;
case 'g':
if(!optarg)
ErrorExit("%s: -g needs an argument",ARGV0);
group = optarg;
break;
case 'D':
if(!optarg)
ErrorExit("%s: -D needs an argument",ARGV0);
dir = optarg;
break;
case 'c':
if(!optarg)
ErrorExit("%s: -c needs an argument",ARGV0);
cfg = optarg;
break;
case 't':
test_config = 1;
break;
default:
help_analysisd();
break;
}
}
/* Check current debug_level
* Command line setting takes precedence
*/
if (debug_level == 0)
{
/* Getting debug level */
debug_level = getDefine_Int("analysisd", "debug", 0, 2);
while(debug_level != 0)
{
nowDebug();
debug_level--;
}
}
/* Starting daemon */
debug1(STARTED_MSG,ARGV0);
DEBUG_MSG("%s: DEBUG: Starting on debug mode - %d ", ARGV0, (int)time(0));
/*Check if the user/group given are valid */
uid = Privsep_GetUser(user);
gid = Privsep_GetGroup(group);
if((uid < 0)||(gid < 0))
ErrorExit(USER_ERROR,ARGV0,user,group);
/* Found user */
debug1(FOUND_USER, ARGV0);
//.........这里部分代码省略.........
开发者ID:lionalka,项目名称:ossec-hids,代码行数:101,代码来源:analysisd.c
示例3: main
int main(int argc, char **argv)
{
int c, test_config = 0,run_foreground = 0;
int uid = 0,gid = 0;
const char *dir = DEFAULTDIR;
const char *user = MAILUSER;
const char *group = GROUPGLOBAL;
const char *cfg = DEFAULTCPATH;
/* Mail Structure */
MailConfig mail;
/* Setting the name */
OS_SetName(ARGV0);
while((c = getopt(argc, argv, "Vdhtfu:g:D:c:")) != -1){
switch(c){
case 'V':
print_version();
break;
case 'h':
help_maild();
break;
case 'd':
nowDebug();
break;
case 'f':
run_foreground = 1;
break;
case 'u':
if(!optarg)
ErrorExit("%s: -u needs an argument",ARGV0);
user=optarg;
break;
case 'g':
if(!optarg)
ErrorExit("%s: -g needs an argument",ARGV0);
group=optarg;
break;
case 'D':
if(!optarg)
ErrorExit("%s: -D needs an argument",ARGV0);
dir=optarg;
break;
case 'c':
if(!optarg)
ErrorExit("%s: -c needs an argument",ARGV0);
cfg = optarg;
break;
case 't':
test_config = 1;
break;
default:
help_maild();
break;
}
}
/* Starting daemon */
debug1(STARTED_MSG,ARGV0);
/*Check if the user/group given are valid */
uid = Privsep_GetUser(user);
gid = Privsep_GetGroup(group);
if((uid < 0)||(gid < 0))
ErrorExit(USER_ERROR,ARGV0,user,group);
/* Reading configuration */
if(MailConf(test_config, cfg, &mail) < 0)
ErrorExit(CONFIG_ERROR, ARGV0, cfg);
/* Reading internal options */
mail.strict_checking = getDefine_Int("maild",
"strict_checking",
0, 1);
/* Get groupping */
mail.groupping = getDefine_Int("maild",
"groupping",
0, 1);
/* Getting subject type */
mail.subject_full = getDefine_Int("maild",
"full_subject",
0, 1);
#ifdef GEOIP
/* Get GeoIP */
mail.geoip = getDefine_Int("maild",
"geoip",
0, 1);
#endif
/* Exit here if test config is set */
if(test_config)
//.........这里部分代码省略.........
开发者ID:Lullabot,项目名称:ossec-hids,代码行数:101,代码来源:maild.c
示例4: save_controlmsg
/* Save a control message received from an agent
* read_contromsg (other thread) is going to deal with it
* (only if message changed)
*/
void save_controlmsg(unsigned int agentid, char *r_msg)
{
char msg_ack[OS_FLSIZE + 1];
char *version;
/* Reply to the agent */
snprintf(msg_ack, OS_FLSIZE, "%s%s", CONTROL_HEADER, HC_ACK);
send_msg(agentid, msg_ack);
/* Check if there is a keep alive already for this agent */
if (_keep_alive[agentid] && _msg[agentid] &&
(strcmp(_msg[agentid], r_msg) == 0)) {
utimes(_keep_alive[agentid], NULL);
wdb_update_agent_keepalive(atoi(keys.keyentries[agentid]->id));
}
else if (strcmp(r_msg, HC_STARTUP) == 0) {
debug1("%s: DEBUG: Agent %s sent HC_STARTUP from %s.", ARGV0, keys.keyentries[agentid]->name, inet_ntoa(keys.keyentries[agentid]->peer_info.sin_addr));
return;
}
else {
FILE *fp;
char *uname = r_msg;
char *random_leftovers;
/* Lock mutex */
if (pthread_mutex_lock(&lastmsg_mutex) != 0) {
merror(MUTEX_ERROR, ARGV0);
return;
}
/* Update rmsg */
if (_msg[agentid]) {
free(_msg[agentid]);
}
os_strdup(r_msg, _msg[agentid]);
/* Unlock mutex */
if (pthread_mutex_unlock(&lastmsg_mutex) != 0) {
merror(MUTEX_ERROR, ARGV0);
return;
}
r_msg = strchr(r_msg, '\n');
if (!r_msg) {
merror("%s: WARN: Invalid message from agent id: '%d'(uname)",
ARGV0,
agentid);
return;
}
*r_msg = '\0';
random_leftovers = strchr(r_msg, '\n');
if (random_leftovers) {
*random_leftovers = '\0';
}
/* Update the keep alive */
if (!_keep_alive[agentid]) {
char agent_file[OS_SIZE_1024 + 1];
agent_file[OS_SIZE_1024] = '\0';
/* Write to the agent file */
snprintf(agent_file, OS_SIZE_1024, "%s/%s-%s",
AGENTINFO_DIR,
keys.keyentries[agentid]->name,
keys.keyentries[agentid]->ip->ip);
os_strdup(agent_file, _keep_alive[agentid]);
}
/* Write to the file */
fp = fopen(_keep_alive[agentid], "w");
if (fp) {
fprintf(fp, "%s\n", uname);
fclose(fp);
}
/* Store uname on database */
if ((version = strstr(uname, " - "))) {
int id = atoi(keys.keyentries[agentid]->id);
*version = '\0';
version += 3;
wdb_update_agent_version(id, uname, version);
wdb_update_agent_keepalive(id);
}
}
/* Lock now to notify of change */
if (pthread_mutex_lock(&lastmsg_mutex) != 0) {
//.........这里部分代码省略.........
开发者ID:Cryptophobia,项目名称:ossec-wazuh,代码行数:101,代码来源:manager.c
示例5: main
int main(int argc, char **argv)
{
FILE *fp;
// Bucket to keep pids in.
int process_pool[POOL_SIZE];
// Count of pids we are wait()ing on.
int c = 0, test_config = 0, use_ip_address = 0, pid = 0, status, i = 0, active_processes = 0;
int gid = 0, client_sock = 0, sock = 0, port = DEFAULT_PORT, ret = 0;
char *dir = DEFAULTDIR;
char *group = GROUPGLOBAL;
char *server_cert = NULL;
char *server_key = NULL;
char *ca_cert = NULL;
char buf[4096 +1];
SSL_CTX *ctx;
SSL *ssl;
char srcip[IPSIZE +1];
struct sockaddr_in _nc;
socklen_t _ncl;
/* Initializing some variables */
memset(srcip, '\0', IPSIZE + 1);
memset(process_pool, 0x0, POOL_SIZE);
bio_err = 0;
/* Setting the name */
OS_SetName(ARGV0);
/* add an option to use the ip on the socket to tie the name to a
specific address */
while((c = getopt(argc, argv, "Vdhtig:D:m:p:v:x:k:")) != -1)
{
switch(c){
case 'V':
print_version();
break;
case 'h':
help_authd();
break;
case 'd':
nowDebug();
break;
case 'i':
use_ip_address = 1;
break;
case 'g':
if(!optarg)
ErrorExit("%s: -g needs an argument",ARGV0);
group = optarg;
break;
case 'D':
if(!optarg)
ErrorExit("%s: -D needs an argument",ARGV0);
dir = optarg;
break;
case 't':
test_config = 1;
break;
case 'p':
if(!optarg)
ErrorExit("%s: -%c needs an argument",ARGV0, c);
port = atoi(optarg);
if(port <= 0 || port >= 65536)
{
ErrorExit("%s: Invalid port: %s", ARGV0, optarg);
}
break;
case 'v':
if (!optarg)
ErrorExit("%s: -%c needs an argument", ARGV0, c);
ca_cert = optarg;
break;
case 'x':
if (!optarg)
ErrorExit("%s: -%c needs an argument", ARGV0, c);
server_cert = optarg;
break;
case 'k':
if (!optarg)
ErrorExit("%s: -%c needs an argument", ARGV0, c);
server_key = optarg;
break;
default:
help_authd();
break;
}
}
/* Starting daemon -- NB: need to double fork and setsid */
debug1(STARTED_MSG,ARGV0);
/* Check if the user/group given are valid */
gid = Privsep_GetGroup(group);
if(gid < 0)
ErrorExit(USER_ERROR,ARGV0,"",group);
//.........这里部分代码省略.........
开发者ID:IFGHou,项目名称:ossec-hids,代码行数:101,代码来源:main-server.c
示例6: memset
//.........这里部分代码省略.........
snprintf(file, OS_SIZE_1024, "%s/%s",
SHAREDCFG_DIR,
tmp_msg);
fp = fopen(file, "w");
if(!fp)
{
merror(FOPEN_ERROR, ARGV0, file);
}
}
else if(strncmp(tmp_msg, FILE_CLOSE_HEADER,
strlen(FILE_CLOSE_HEADER)) == 0)
{
/* no error */
os_md5 currently_md5;
/* Making sure to close for the rename to work */
if(fp)
{
fclose(fp);
fp = NULL;
}
if(file[0] == '\0')
{
/* nada */
}
else if(OS_MD5_File(file, currently_md5) < 0)
{
/* Removing file */
unlink(file);
file[0] = '\0';
}
else
{
if(strcmp(currently_md5, file_sum) != 0)
{
debug1("%s: Failed md5 for: %s -- deleting.",
ARGV0, file);
unlink(file);
}
else
{
char *final_file;
/* Renaming the file to its orignal name */
final_file = strrchr(file, '/');
if(final_file)
{
if(strcmp(final_file + 1, SHAREDCFG_FILENAME) == 0)
{
UnmergeFiles(file, SHAREDCFG_DIR);
}
}
else
{
unlink(file);
}
}
file[0] = '\0';
}
}
else
{
merror("%s: WARN: Unknown message received from server.", ARGV0);
}
}
else if(fp)
{
available_server = (int)time(NULL);
fprintf(fp, "%s", tmp_msg);
}
else
{
merror("%s: WARN: Unknown message received. No action defined.",
ARGV0);
}
}
}
/* Cleaning up */
if(fp)
{
fclose(fp);
if(file[0] != '\0')
unlink(file);
}
return(NULL);
}
开发者ID:Ar0xA,项目名称:ossec-hids,代码行数:101,代码来源:receiver-win.c
示例7: main
/* main, v0.2, 2005/11/09
*/
int main(int argc, char **argv)
{
int c = 0;
int test_config = 0;
int debug_level = 0;
char *dir = DEFAULTDIR;
char *user = USER;
char *group = GROUPGLOBAL;
int uid = 0;
int gid = 0;
/* Setting the name */
OS_SetName(ARGV0);
while((c = getopt(argc, argv, "Vtdhu:g:D:")) != -1){
switch(c){
case 'V':
print_version();
break;
case 'h':
help(ARGV0);
break;
case 'd':
nowDebug();
debug_level = 1;
break;
case 'u':
if(!optarg)
ErrorExit("%s: -u needs an argument",ARGV0);
user = optarg;
break;
case 'g':
if(!optarg)
ErrorExit("%s: -g needs an argument",ARGV0);
group = optarg;
break;
case 't':
test_config = 1;
break;
case 'D':
if(!optarg)
ErrorExit("%s: -D needs an argument",ARGV0);
dir = optarg;
break;
}
}
debug1(STARTED_MSG, ARGV0);
logr = (agent *)calloc(1, sizeof(agent));
if(!logr)
{
ErrorExit(MEM_ERROR, ARGV0);
}
/* Check current debug_level
* Command line setting takes precedence
*/
if (debug_level == 0)
{
/* Getting debug level */
debug_level = getDefine_Int("agent","debug", 0, 2);
while(debug_level != 0)
{
nowDebug();
debug_level--;
}
}
/* Reading config */
if(ClientConf(DEFAULTCPATH) < 0)
{
ErrorExit(CLIENT_ERROR,ARGV0);
}
if(!logr->rip)
{
merror(AG_INV_IP, ARGV0);
ErrorExit(CLIENT_ERROR,ARGV0);
}
if(logr->notify_time == 0)
{
logr->notify_time = NOTIFY_TIME;
}
if(logr->max_time_reconnect_try == 0 )
{
logr->max_time_reconnect_try = NOTIFY_TIME * 3;
}
if(logr->max_time_reconnect_try <= logr->notify_time)
{
//.........这里部分代码省略.........
开发者ID:justintime32,项目名称:ossec-hids,代码行数:101,代码来源:main.c
示例8: db_init
/* opening or creation of database */
void
db_init (void)
{
gint res;
debug_enter ("db_init");
db_open ();
/* create info table/check versioning info */
debug1 (DEBUG_DB, "current DB schema version: %d", db_get_schema_version ());
if (-1 == db_get_schema_version ()) {
/* no schema version available -> first installation without tables... */
db_set_schema_version (SCHEMA_TARGET_VERSION);
/* nothing exists yet, tables will be created below */
}
if (SCHEMA_TARGET_VERSION < db_get_schema_version ())
g_error ("Fatal: The cache database was created by a newer version of Liferea than this one!");
if (SCHEMA_TARGET_VERSION > db_get_schema_version ()) {
/* do table migration */
if (db_get_schema_version () < 5)
g_error ("This version of Liferea doesn't support migrating from such an old DB file!");
if (db_get_schema_version () == 5 || db_get_schema_version () == 6) {
debug0 (DEBUG_DB, "dropping triggers in preparation of database migration");
db_exec ("BEGIN; "
"DROP TRIGGER item_removal; "
"DROP TRIGGER item_insert; "
"END;");
}
if (db_get_schema_version () == 5) {
/* 1.4.9 -> 1.4.10 adding parent_item_id to itemset relation */
debug0 (DEBUG_DB, "migrating from schema version 5 to 6 (this drops all comments)");
db_exec ("BEGIN; "
"DELETE FROM itemsets WHERE comment = 1; "
"DELETE FROM items WHERE comment = 1; "
"CREATE TEMPORARY TABLE itemsets_backup(item_id,node_id,read,comment); "
"INSERT INTO itemsets_backup SELECT item_id,node_id,read,comment FROM itemsets; "
"DROP TABLE itemsets; "
"CREATE TABLE itemsets ("
" item_id INTEGER,"
" parent_item_id INTEGER,"
" node_id TEXT,"
" read INTEGER,"
" comment INTEGER,"
" PRIMARY KEY (item_id, node_id)"
"); "
"INSERT INTO itemsets SELECT item_id,0,node_id,read,comment FROM itemsets_backup; "
"DROP TABLE itemsets_backup; "
"REPLACE INTO info (name, value) VALUES ('schemaVersion',6); "
"END;");
}
if (db_get_schema_version () == 6) {
/* 1.4.15 -> 1.4.16 adding parent_node_id to itemset relation */
debug0 (DEBUG_DB, "migrating from schema version 6 to 7 (this drops all comments)");
db_exec ("BEGIN; "
"DELETE FROM itemsets WHERE comment = 1; "
"DELETE FROM items WHERE comment = 1; "
"CREATE TEMPORARY TABLE itemsets_backup(item_id,node_id,read,comment); "
"INSERT INTO itemsets_backup SELECT item_id,node_id,read,comment FROM itemsets; "
"DROP TABLE itemsets; "
"CREATE TABLE itemsets ("
" item_id INTEGER,"
" parent_item_id INTEGER,"
" node_id TEXT,"
" parent_node_id TEXT,"
" read INTEGER,"
" comment INTEGER,"
" PRIMARY KEY (item_id, node_id)"
"); "
"INSERT INTO itemsets SELECT item_id,0,node_id,node_id,read,comment FROM itemsets_backup; "
"DROP TABLE itemsets_backup; "
"REPLACE INTO info (name, value) VALUES ('schemaVersion',7); "
"END;");
}
if (db_get_schema_version () == 7) {
/* 1.7.1 -> 1.7.2 dropping the itemsets and attention_stats relation */
db_exec ("BEGIN; "
"CREATE TEMPORARY TABLE items_backup("
" item_id, "
" title, "
" read, "
" updated, "
" popup, "
" marked, "
" source, "
" source_id, "
" valid_guid, "
" description, "
" date, "
" comment_feed_id, "
" comment); "
"INSERT into items_backup SELECT ROWID, title, read, updated, popup, marked, source, source_id, valid_guid, description, date, comment_feed_id, comment FROM items; "
//.........这里部分代码省略.........
开发者ID:skagedal,项目名称:liferea,代码行数:101,代码来源:db.c
示例9: json_api_get_items
GList *
json_api_get_items (const gchar *json, const gchar *root, jsonApiMapping *mapping, jsonApiItemCallbackFunc callback)
{
GList *items = NULL;
JsonParser *parser = json_parser_new ();
if (json_parser_load_from_data (parser, json, -1, NULL)) {
JsonArray *array = json_node_get_array (json_get_node (json_parser_get_root (parser), root));
GList *elements = json_array_get_elements (array);
GList *iter = elements;
debug1 (DEBUG_PARSING, "JSON API: found items root node \"%s\"", root);
while (iter) {
JsonNode *node = (JsonNode *)iter->data;
itemPtr item = item_new ();
/* Parse default feeds */
item_set_id (item, json_api_get_string (node, mapping->id));
item_set_title (item, json_api_get_string (node, mapping->title));
item_set_source (item, json_api_get_string (node, mapping->link));
item->time = json_api_get_int (node, mapping->updated);
item->readStatus = json_api_get_bool (node, mapping->read);
item->flagStatus = json_api_get_bool (node, mapping->flag);
if (mapping->negateRead)
item->readStatus = !item->readStatus;
/* Handling encoded content */
const gchar *content;
gchar *xhtml;
content = json_api_get_string (node, mapping->description);
if (mapping->xhtml) {
xhtml = xhtml_extract_from_string (content, NULL);
item_set_description (item, xhtml);
xmlFree (xhtml);
} else {
item_set_description (item, content);
}
/* Optional meta data */
const gchar *tmp = json_api_get_string (node, mapping->author);
if (tmp)
item->metadata = metadata_list_append (item->metadata, "author", tmp);
items = g_list_append (items, (gpointer)item);
/* Allow optional item callback to process stuff */
if (callback)
(*callback)(node, item);
iter = g_list_next (iter);
}
g_list_free (elements);
g_object_unref (parser);
} else {
debug1 (DEBUG_PARSING, "Could not parse JSON \"%s\"", json);
}
return items;
}
开发者ID:nonas,项目名称:debian-clang,代码行数:64,代码来源:json_api_mapper.c
示例10: FileAccess_PreludeLog
void FileAccess_PreludeLog(idmef_message_t *idmef,
int filenum,
char *filename,
char *md5,
char *sha1,
char *owner,
char *gowner,
int perm)
{
int _checksum_counter = 0;
char _prelude_section[128];
_prelude_section[127] = '\0';
debug1("%s: DEBUG: filename = %s.", ARGV0, filename);
debug1("%s: DEBUG: filenum = %d.", ARGV0, filenum);
if (filenum == 0) {
snprintf(_prelude_section, 128, "alert.target(0).file(%d).name", filenum);
add_idmef_object(idmef, _prelude_section, filename);
snprintf(_prelude_section, 128, "alert.target(0).file(%d).category", filenum);
add_idmef_object(idmef, _prelude_section, "original");
} else if (filenum == 1) {
snprintf(_prelude_section, 128, "alert.target(0).file(%d).name", filenum);
add_idmef_object(idmef, _prelude_section, filename);
snprintf(_prelude_section, 128, "alert.target(0).file(%d).category", filenum);
add_idmef_object(idmef, _prelude_section, "current");
} else {
return;
}
/* Add the hashes */
if (md5) {
snprintf(_prelude_section, 128, "alert.target(0).file(%d).checksum(%d).algorithm", filenum, _checksum_counter);
add_idmef_object(idmef, _prelude_section, "MD5");
snprintf(_prelude_section, 128, "alert.target(0).file(%d).checksum(%d).value", filenum, _checksum_counter);
add_idmef_object(idmef, _prelude_section, md5);
_checksum_counter++;
}
if (sha1) {
snprintf(_prelude_section, 128, "alert.target(0).file(%d).checksum(%d).algorithm", filenum, _checksum_counter);
add_idmef_object(idmef, _prelude_section, "SHA1");
snprintf(_prelude_section, 128, "alert.target(0).file(%d).checksum(%d).value", filenum, _checksum_counter);
add_idmef_object(idmef, _prelude_section, sha1);
_checksum_counter++;
}
/* Add the owner */
if (owner) {
debug1("%s: DEBUG: owner = %s.", ARGV0, owner);
snprintf(_prelude_section, 128, "alert.target(0).file(%d).File_Access(%d).user_id.number", filenum, FILE_USER);
add_idmef_object(idmef, _prelude_section, owner);
snprintf(_prelude_section, 128, "alert.target(0).file(%d).File_Access(%d).user_id.type", filenum, FILE_USER);
add_idmef_object(idmef, _prelude_section, "user-privs");
}
/* Add the group owner */
if (gowner) {
debug1("%s: DEBUG: gowner = %s.", ARGV0, gowner);
snprintf(_prelude_section, 128, "alert.target(0).file(%d).File_Access(%d).user_id.number", filenum, FILE_GROUP);
add_idmef_object(idmef, _prelude_section, gowner);
snprintf(_prelude_section, 128, "alert.target(0).file(%d).File_Access(%d).user_id.type", filenum, FILE_GROUP);
add_idmef_object(idmef, _prelude_section, "group-privs");
}
/* Add the permissions */
if (perm) {
if (perm & S_IWUSR) {
snprintf(_prelude_section, 128, "alert.target(0).file(%d).File_Access(%d).permission(0)", filenum, FILE_USER);
add_idmef_object(idmef, _prelude_section, "write");
snprintf(_prelude_section, 128, "alert.target(0).file(%d).File_Access(%d).permission(1)", filenum, FILE_USER);
add_idmef_object(idmef, _prelude_section, "delete");
}
if (perm & S_IXUSR) {
snprintf(_prelude_section, 128, "alert.target(0).file(%d).File_Access(%d).permission(2)", filenum, FILE_USER);
add_idmef_object(idmef, _prelude_section, "execute");
}
if (perm & S_IRUSR ) {
snprintf(_prelude_section, 128, "alert.target(0).file(%d).File_Access(%d).permission(3)", filenum, FILE_USER);
add_idmef_object(idmef, _prelude_section, "read");
}
if (perm & S_ISUID) {
snprintf(_prelude_section, 128, "alert.target(0).file(%d).File_Access(%d).permission(4)", filenum, FILE_USER);
add_idmef_object(idmef, _prelude_section, "executeAs");
}
if (perm & S_IWGRP) {
snprintf(_prelude_section, 128, "alert.target(0).file(%d).File_Access(%d).permission(0)", filenum, FILE_GROUP);
add_idmef_object(idmef, _prelude_section, "write");
snprintf(_prelude_section, 128, "alert.target(0).file(%d).File_Access(%d).permission(1)", filenum, FILE_GROUP);
add_idmef_object(idmef, _prelude_section, "delete");
}
if (perm & S_IXGRP) {
snprintf(_prelude_section, 128, "alert.target(0).file(%d).File_Access(%d).permission(2)", filenum, FILE_GROUP);
add_idmef_object(idmef, _prelude_section, "execute");
}
if (perm & S_IRGRP ) {
snprintf(_prelude_section, 128, "alert.target(0).file(%d).File_Access(%d).permission(3)", filenum, FILE_GROUP);
add_idmef_object(idmef, _prelude_section, "read");
}
if (perm & S_ISGID) {
//.........这里部分代码省略.........
开发者ID:nixfloyd,项目名称:ossec-hids,代码行数:101,代码来源:prelude.c
示例11: OS_PreludeLog
//.........这里部分代码省略.........
classification_counter);
snprintf(_prelude_data, 256, "http://www.ossec.net/wiki/Group:%s",
copy_group);
add_idmef_object(idmef, _prelude_section, _prelude_data);
classification_counter++;
copy_group = strtok(NULL, ",");
}
}
} /* end classification block */
/* Begin Node infomation block */
{
/* Set source info */
add_idmef_object(idmef, "alert.source(0).Spoofed", "no");
add_idmef_object(idmef, "alert.source(0).Node.Address(0).address",
lf->srcip);
add_idmef_object(idmef, "alert.source(0).Service.port", lf->srcport);
if (lf->srcuser) {
add_idmef_object(idmef, "alert.source(0).User.UserId(0).name", lf->srcuser);
}
/* Set target */
add_idmef_object(idmef, "alert.target(0).Service.name", lf->program_name);
add_idmef_object(idmef, "alert.target(0).Spoofed", "no");
if (lf->dstip) {
add_idmef_object(idmef, "alert.target(0).Node.Address(0).address",
lf->dstip);
} else {
char *tmp_str;
char new_prelude_target[256];
new_prelude_target[255] = '\0';
strncpy(new_prelude_target, lf->hostname, 255);
/* The messages can have the file, so we need to remove it
* Formats can be:
* enigma->/var/log/authlog
* (esqueleto2) 192.168.2.99->/var/log/squid/access.log
*/
tmp_str = strstr(new_prelude_target, "->");
if (tmp_str) {
*tmp_str = '\0';
}
add_idmef_object(idmef, "alert.target(0).Node.Address(0).address",
new_prelude_target);
}
add_idmef_object(idmef, "alert.target(0).Service.name", lf->hostname);
add_idmef_object(idmef, "alert.target(0).Service.port", lf->dstport);
if (lf->dstuser) {
add_idmef_object(idmef, "alert.target(0).User.category", "2");
add_idmef_object(idmef, "alert.target(0).User.UserId(0).name", lf->dstuser);
}
} /* end Node infomation block */
/* Set source file */
add_idmef_object(idmef, "alert.additional_data(0).type", "string");
add_idmef_object(idmef, "alert.additional_data(0).meaning", "Source file");
add_idmef_object(idmef, "alert.additional_data(0).data", lf->location);
additional_data_counter++;
/* Set full log */
add_idmef_object(idmef, "alert.additional_data(1).type", "string");
add_idmef_object(idmef, "alert.additional_data(1).meaning", "Full Log");
add_idmef_object(idmef, "alert.additional_data(1).data", lf->full_log);
additional_data_counter++;
idmef_alert_set_analyzer(idmef_message_get_alert(idmef),
idmef_analyzer_ref
(prelude_client_get_analyzer(prelude_client)),
IDMEF_LIST_PREPEND);
debug1("%s: DEBUG: lf->filename = %s.", ARGV0, lf->filename);
if (lf->filename) {
FileAccess_PreludeLog(idmef,
0,
lf->filename,
lf->md5_before,
lf->sha1_before,
lf->owner_before,
lf->gowner_before,
lf->perm_before);
FileAccess_PreludeLog(idmef,
1,
lf->filename,
lf->md5_after,
lf->sha1_after,
lf->owner_after,
lf->gowner_after,
lf->perm_after);
debug1("%s: DEBUG: done with alert.target(0).file(1)", ARGV0);
}
debug1("%s: DEBUG: Sending IDMEF alert", ARGV0);
prelude_client_send_idmef(prelude_client, idmef);
debug1("%s: DEBUG: destroying IDMEF alert", ARGV0);
idmef_message_destroy(idmef);
}
开发者ID:nixfloyd,项目名称:ossec-hids,代码行数:101,代码来源:prelude.c
示例12: term_handle_key
static void term_handle_key(mpg123_handle *fr, out123_handle *ao, char val)
{
debug1("term_handle_key: %c", val);
switch(tolower(val))
{
case MPG123_BACK_KEY:
out123_pause(ao);
out123_drop(ao);
if(paused) pause_cycle=(int)(LOOP_CYCLES/mpg123_tpf(fr));
if(mpg123_seek_frame(fr, 0, SEEK_SET) < 0)
error1("Seek to begin failed: %s", mpg123_strerror(fr));
framenum=0;
break;
case MPG123_NEXT_KEY:
out123_pause(ao);
out123_drop(ao);
next_track();
break;
case MPG123_NEXT_DIR_KEY:
out123_pause(ao);
out123_drop(ao);
next_dir();
break;
case MPG123_QUIT_KEY:
debug("QUIT");
if(stopped)
{
stopped = 0;
out123_pause(ao); /* no chance for annoying underrun warnings */
out123_drop(ao);
}
set_intflag();
offset = 0;
break;
case MPG123_PAUSE_KEY:
paused=1-paused;
out123_pause(ao); /* underrun awareness */
out123_drop(ao);
if(paused)
{
/* Not really sure if that is what is wanted
This jumps in audio output, but has direct reaction to pausing loop. */
out123_param_float(ao, OUT123_PRELOAD, 0.);
pause_recycle(fr);
}
else
out123_param_float(ao, OUT123_PRELOAD, param.preload);
if(stopped)
stopped=0;
if(param.verbose)
print_stat(fr, 0, ao);
else
fprintf(stderr, "%s", (paused) ? MPG123_PAUSED_STRING : MPG123_EMPTY_STRING);
break;
case MPG123_STOP_KEY:
case ' ':
/* TODO: Verify/ensure that there is no "chirp from the past" when
seeking while stopped. */
stopped=1-stopped;
if(paused) {
paused=0;
offset -= pause_cycle;
}
if(stopped)
out123_pause(ao);
else
{
if(offset) /* If position changed, old is outdated. */
out123_drop(ao);
/* No out123_continue(), that's triggered by out123_play(). */
}
if(param.verbose)
print_stat(fr, 0, ao);
else
fprintf(stderr, "%s", (stopped) ? MPG123_STOPPED_STRING : MPG123_EMPTY_STRING);
break;
case MPG123_FINE_REWIND_KEY:
seekmode(fr, ao);
offset--;
break;
case MPG123_FINE_FORWARD_KEY:
seekmode(fr, ao);
offset++;
break;
case MPG123_REWIND_KEY:
seekmode(fr, ao);
offset-=10;
break;
case MPG123_FORWARD_KEY:
seekmode(fr, ao);
offset+=10;
break;
case MPG123_FAST_REWIND_KEY:
seekmode(fr, ao);
offset-=50;
break;
case MPG123_FAST_FORWARD_KEY:
seekmode(fr, ao);
//.........这里部分代码省略.........
开发者ID:BenWBrown,项目名称:cs453_final_project,代码行数:101,代码来源:term.c
示例13: main
int main(int argc, char **argv)
{
int i = 0,c = 0;
int uid = 0, gid = 0;
int test_config = 0,run_foreground = 0;
char *cfg = DEFAULTCPATH;
char *dir = DEFAULTDIR;
char *user = REMUSER;
char *group = GROUPGLOBAL;
/* Setting the name -- must be done ASAP */
OS_SetName(ARGV0);
while((c = getopt(argc, argv, "Vdthfu:g:c:D:")) != -1){
switch(c){
case 'V':
print_version();
break;
case 'h':
help(ARGV0);
break;
case 'd':
nowDebug();
break;
case 'f':
run_foreground = 1;
break;
case 'u':
if(!optarg)
ErrorExit("%s: -u needs an argument",ARGV0);
user = optarg;
break;
case 'g':
if(!optarg)
ErrorExit("%s: -g needs an argument",ARGV0);
group = optarg;
break;
case 't':
test_config = 1;
break;
case 'c':
if (!optarg)
ErrorExit("%s: -c need an argument", ARGV0);
cfg = optarg;
break;
case 'D':
if(!optarg)
ErrorExit("%s: -D needs an argument",ARGV0);
dir = optarg;
}
}
debug1(STARTED_MSG,ARGV0);
/* Return 0 if not configured */
if(RemotedConfig(cfg, &logr) < 0)
{
ErrorExit(CONFIG_ERROR, ARGV0, cfg);
}
/* Exit if test_config is set */
if(test_config)
exit(0);
if(logr.conn == NULL)
{
/* Not configured. */
exit(0);
}
/* Check if the user and group given are valid */
uid = Privsep_GetUser(user);
gid = Privsep_GetGroup(group);
if((uid < 0)||(gid < 0))
ErrorExit(USER_ERROR, ARGV0, user, group);
/* pid before going daemon */
i = getpid();
if(!run_foreground)
{
nowDaemon();
goDaemon();
}
/* Setting new group */
if(Privsep_SetGroup(gid) < 0)
ErrorExit(SETGID_ERROR, ARGV0, group);
/* Going on chroot */
if(Privsep_Chroot(dir) < 0)
ErrorExit(CHROOT_ERROR,ARGV0,dir);
//.........这里部分代码省略.........
开发者ID:RobertoD91,项目名称:ossec,代码行数:101,代码来源:main.c
示例14: LogCollectorStart
/* Handle file management */
void LogCollectorStart()
{
int i = 0, r = 0;
int max_file = 0;
int f_check = 0;
time_t curr_time = 0;
char keepalive[1024];
/* To check for inode changes */
struct stat tmp_stat;
#ifndef WIN32
int int_error = 0;
struct timeval fp_timeout;
#else
/* Check if we are on Windows Vista */
checkVista();
/* Read vista descriptions */
if (isVista) {
win_read_vista_sec();
}
#endif
debug1("%s: DEBUG: Entering LogCollectorStart().", ARGV0);
/* Initialize each file and structure */
for (i = 0;; i++) {
if (logff[i].file == NULL) {
break;
}
/* Remove duplicate entries */
for (r = 0; r < i; r++) {
if (logff[r].file && strcmp(logff[i].file, logff[r].file) == 0) {
merror("%s: WARN: Duplicated log file given: '%s'.",
ARGV0, logff[i].file);
logff[i].file = NULL;
logff[i].command = NULL;
logff[i].fp = NULL;
break;
}
}
if (logff[i].file == NULL) {
/* Do nothing, duplicated entry */
}
else if (strcmp(logff[i].logformat, "eventlog") == 0) {
#ifdef WIN32
verbose(READING_EVTLOG, ARGV0, logff[i].file);
win_startel(logff[i].file);
#endif
logff[i].file = NULL;
logff[i].command = NULL;
logff[i].fp = NULL;
}
else if (strcmp(logff[i].logformat, "eventchannel") == 0) {
#ifdef WIN32
#ifdef EVENTCHANNEL_SUPPORT
verbose(READING_EVTLOG, ARGV0, logff[i].file);
win_start_event_channel(logff[i].file, logff[i].future, logff[i].query);
#else
merror("%s: WARN: eventchannel not available on this version of OSSEC", ARGV0);
#endif
#endif
logff[i].file = NULL;
logff[i].command = NULL;
logff[i].fp = NULL;
}
else if (strcmp(logff[i].logformat, "command") == 0) {
logff[i].file = NULL;
logff[i].fp = NULL;
logff[i].size = 0;
if (logff[i].command) {
logff[i].read = read_command;
verbose("%s: INFO: Monitoring output of command(%d): %s", ARGV0, logff[i].ign, logff[i].command);
if (!logff[i].alias) {
os_strdup(logff[i].command, logff[i].alias);
}
} else {
merror("%s: ERROR: Missing command argument. Ignoring it.",
ARGV0);
}
} else if (strcmp(logff[i].logformat, "full_command") == 0) {
logff[i].file = NULL;
logff[i].fp = NULL;
//.........这里部分代码省略.........
开发者ID:AiGangJingYe,项目名称:ossec-hids,代码行数:101,代码来源:logcollector.c
示例15: ttrss_subscription_process_update_result
static void
ttrss_subscription
|
请发表评论