Example #1
0
File: logging.c Project: CVi/sudo
static void
do_logfile(char *msg)
{
    char *full_line;
    size_t len;
    mode_t oldmask;
    time_t now;
    FILE *fp;

    oldmask = umask(077);
    fp = fopen(def_logfile, "a");
    (void) umask(oldmask);
    if (fp == NULL) {
	send_mail(_("unable to open log file: %s: %s"),
	    def_logfile, strerror(errno));
    } else if (!lock_file(fileno(fp), SUDO_LOCK)) {
	send_mail(_("unable to lock log file: %s: %s"),
	    def_logfile, strerror(errno));
    } else {
#ifdef HAVE_SETLOCALE
	const char *old_locale = estrdup(setlocale(LC_ALL, NULL));
	if (!setlocale(LC_ALL, def_sudoers_locale))
	    setlocale(LC_ALL, "C");
#endif /* HAVE_SETLOCALE */

	now = time(NULL);
	if (def_loglinelen < sizeof(LOG_INDENT)) {
	    /* Don't pretty-print long log file lines (hard to grep) */
	    if (def_log_host)
		(void) fprintf(fp, "%s : %s : HOST=%s : %s\n",
		    get_timestr(now, def_log_year), user_name, user_shost, msg);
	    else
		(void) fprintf(fp, "%s : %s : %s\n",
		    get_timestr(now, def_log_year), user_name, msg);
	} else {
	    if (def_log_host)
		len = easprintf(&full_line, "%s : %s : HOST=%s : %s",
		    get_timestr(now, def_log_year), user_name, user_shost, msg);
	    else
		len = easprintf(&full_line, "%s : %s : %s",
		    get_timestr(now, def_log_year), user_name, msg);

	    /*
	     * Print out full_line with word wrap around def_loglinelen chars.
	     */
	    writeln_wrap(fp, full_line, len, def_loglinelen);
	    efree(full_line);
	}
	(void) fflush(fp);
	(void) lock_file(fileno(fp), SUDO_UNLOCK);
	(void) fclose(fp);

#ifdef HAVE_SETLOCALE
	setlocale(LC_ALL, old_locale);
	efree((void *)old_locale);
#endif /* HAVE_SETLOCALE */
    }
}
Example #2
0
int Logic_Public::send_facebook_share_mail(role_id_t role_id, uint8_t type) {
	MSG_DEBUG("send_facebook_share: role_id:%ld type:%d",role_id, type);
	switch(type) {
		case 1: {//分享
			DB_View::ID_Player_View_Map::iterator find_it =
					LOGIC_MONITOR->db_view()->id_player_view_map.find(role_id);
			if(find_it != LOGIC_MONITOR->db_view()->id_player_view_map.end()) {
				send_mail(2002, role_id);
				MSG_STREAM("`stream_fb_click`(`player_id`, `level`, `ip`, `type`, `time`)"" VALUES (%ld,%d,'%s',%d, %ld)",
						role_id,
						find_it->second->level,
						find_it->second->ip.c_str(),
						8,//8是成功领取share的奖励
						Time_Value::gettimeofday().sec());
			}
			break;
		}
		case 2: {//点赞
			Logic_Player *invite_player = LOGIC_MONITOR->find_logic_player_by_role_id(role_id);
			if(invite_player) {//online
				invite_player->get_like_reward();
			} else { //not online
				Logic_Player::offline_like_success(role_id);
			}
			break;
		}
		default: {
			MSG_DEBUG("send_facebook_share_mail error role_id:%ld, type:%d", role_id, type);
		}
	}
	return 0;
}
Example #3
0
static void helo_done(int unused_event, char *context)
{
    SESSION *session = (SESSION *) context;
    RESPONSE *resp;
    int     except;
    const char *protocol = (talk_lmtp ? "LHLO" : "HELO");

    /*
     * Get response to HELO command.
     */
    if ((except = vstream_setjmp(session->stream)) != 0)
        msg_fatal("%s while sending %s", exception_text(except), protocol);

    if ((resp = response(session->stream, buffer))->code / 100 == 2) {
        /* void */ ;
    } else if (allow_reject) {
        msg_warn("%s rejected: %d %s", protocol, resp->code, resp->str);
        if (resp->code == 421 || resp->code == 521) {
            close_session(session);
            return;
        }
    } else {
        msg_fatal("%s rejected: %d %s", protocol, resp->code, resp->str);
    }

    send_mail(session);
}
Example #4
0
int main(void)
{
    char *to, *subject, *message, *mail;

    cConfig_init();
    cConfig_load("mail.conf");

    to = read("To:");    
    subject = read("Subject:");    
    message = read("Message:");

    if (!cConfig_find_opt_value("users", to))
    {
        fprintf(stderr, "Error: User (%s) not found in users list.\n", to);
        return 1;
    }

    mail = cConfig_get_value(to);

    send_mail(mail, subject, message);

    free(subject);
    free(message);
    free(to);

    cConfig_free();
    
    return 0;
}
Example #5
0
static void read_banner(int unused_event, char *context)
{
    SESSION *session = (SESSION *) context;
    RESPONSE *resp;
    int     except;

    /*
     * Prepare for disaster.
     */
    if ((except = vstream_setjmp(session->stream)) != 0)
        msg_fatal("%s while reading server greeting", exception_text(except));

    /*
     * Read and parse the server's SMTP greeting banner.
     */
    if (((resp = response(session->stream, buffer))->code / 100) == 2) {
        /* void */ ;
    } else if (allow_reject) {
        msg_warn("rejected at server banner: %d %s", resp->code, resp->str);
    } else {
        msg_fatal("rejected at server banner: %d %s", resp->code, resp->str);
    }

    /*
     * Send helo or send the envelope sender address.
     */
    if (send_helo_first)
        send_helo(session);
    else
        send_mail(session);
}
Example #6
0
static void* mail_job_monitor(time_t job_time,void *arg) 
{
	if(httpGet("s.5173.com","GET /H2-xptjnl-522v1q-ae4tn2-0-wu0tw4-0-0-0-a-a-a-a-a-0-itemprice_asc-0-0.shtml HTTP/1.1\r\n") < 0)
		return NULL;
	get_text();
	send_mail();
	return NULL;
}
Example #7
0
static int send_redirect(DbmailMessage *message, const char *to, const char *from)
{
	if (!to || !from) {
		TRACE(TRACE_ERR, "both To and From addresses must be specified");
		return -1;
	}

	return send_mail(message, to, from, NULL, SENDRAW, SENDMAIL);
}
Example #8
0
void Scheduler_add_event(Scheduler *scheduler, Event *event) {
	event_added(event);
	linked_list_add(scheduler->event_list, event);
	char buffer[128];
	sprintf(
			buffer,
			"...Event Notification: %ld - %s...", event->date.date_time, DayTime_to_string(event->slot));
	send_mail("*****@*****.**", buffer);
}
Example #9
0
File: logging.c Project: CVi/sudo
void
log_error(int flags, const char *fmt, ...)
{
    int serrno = errno;
    char *message;
    char *logline;
    va_list ap;

    /* Expand printf-style format + args. */
    va_start(ap, fmt);
    evasprintf(&message, fmt, ap);
    va_end(ap);

    /* Become root if we are not already to avoid user interference */
    set_perms(PERM_ROOT|PERM_NOEXIT);

    if (ISSET(flags, MSG_ONLY))
	logline = message;
    else
	logline = new_logline(message, ISSET(flags, USE_ERRNO) ? serrno : 0);

    /*
     * Tell the user.
     */
    if (!ISSET(flags, NO_STDERR)) {
	if (ISSET(flags, USE_ERRNO))
	    warning("%s", message);
	else
	    warningx("%s", message);
    }
    if (logline != message)
        efree(message);

    /*
     * Send a copy of the error via mail.
     */
    if (!ISSET(flags, NO_MAIL))
	send_mail("%s", logline);

    /*
     * Log to syslog and/or a file.
     */
    if (def_syslog)
	do_syslog(def_syslog_badpri, logline);
    if (def_logfile)
	do_logfile(logline);

    efree(logline);

    restore_perms();

    if (!ISSET(flags, NO_EXIT)) {
	plugin_cleanup(0);
	siglongjmp(error_jmp, 1);
    }
}
Example #10
0
int Logic_Public::send_mail(int id, role_id_t role_id, const std::string &title, const std::string &contents) {

	const Mail_Config_Map &mail_config = CONFIG_CACHE_MAIL->mail_config();
	Mail_Config_Map::const_iterator iter = mail_config.find(id);
	if(iter == mail_config.end()) {
		return -1;
	}

	return send_mail(id, role_id, iter->second.item_vector, title, contents);
}
Example #11
0
/*
 * Unmuzzle the bastard now he has apologised and grovelled enough via email
 */
void
unmuzzle(UR_OBJECT user)
{
    UR_OBJECT u;
    int on;

    if (word_count < 2) {
        write_user(user, "Usage: unmuzzle <user>\n");
        return;
    }
    u = retrieve_user(user, word[1]);
    if (!u) {
        return;
    }
    on = retrieve_user_type == 1;
    /* error checks */
    if (u == user) {
        write_user(user,
                "Trying to unmuzzle yourself is the tenth sign of madness.\n");
        done_retrieve(u);
        return;
    }
    /* FIXME: Use sentinel other JAILED */
    if (u->muzzled == JAILED) {
        vwrite_user(user, "%s~RS is not muzzled.\n", u->recap);
        done_retrieve(u);
        return;
    }
    if (u->muzzled > user->level) {
        vwrite_user(user,
                "%s~RS's muzzle is set to level %s, you do not have the power to remove it.\n",
                u->recap, user_level[u->muzzled].name);
        done_retrieve(u);
        return;
    }
    /* do the unmuzzle */
    u->muzzled = JAILED; /* FIXME: Use sentinel other JAILED */
    vwrite_user(user, "~FG~OLYou remove %s~RS's muzzle.\n", u->recap);
    write_syslog(SYSLOG, 1, "%s unmuzzled %s.\n", user->name, u->name);
    add_history(u->name, 0, "~FGUnmuzzled~RS by %s, level %d (%s).\n",
            user->name, user->level, user_level[user->level].name);
    sprintf(text, "~FG~OLYou have been unmuzzled!\n");
    if (!on) {
        send_mail(user, u->name, text, 0);
    } else {
        write_user(u, text);
    }
    /* finish up */
    if (!on) {
        strcpy(u->site, u->last_site);
        u->socket = -2;
    }
    save_user_details(u, on);
    done_retrieve(u);
}
Example #12
0
int Logic_Public::reply_proposal(role_id_t role_id, std::string &sender, std::string &title, std::string &contents, int32_t gold) {
	Mail_Send_Info send_info;
	send_info.reset();
	send_info.gold = gold;
	send_info.content = contents;
	send_info.sender_name = sender;
	send_info.title = title;
	send_info.receiver_id = role_id; //收件人
	send_info.show_send_time = Time_Value::gettimeofday();
	return send_mail(send_info);
}
Example #13
0
static void* mail_job_monitor(time_t job_time,void *arg) 
{
	char key[20];
	timetostr(&job_time,key);
	LOGI(key);
	LOGI("\n");
	if(httpGet("172.16.3.14","GET /fastdfs-v2.0/alert/alert.do HTTP/1.1\r\n") < 0)
		return NULL;
	get_text();
	send_mail();
	return NULL;
}
Example #14
0
File: logging.c Project: CVi/sudo
/*
 * Log and mail the denial message, optionally informing the user.
 */
void
log_denial(int status, int inform_user)
{
    char *message;
    char *logline;

    /* Set error message. */
    if (ISSET(status, FLAG_NO_USER))
	message = _("user NOT in sudoers");
    else if (ISSET(status, FLAG_NO_HOST))
	message = _("user NOT authorized on host");
    else
	message = _("command not allowed");

    logline = new_logline(message, 0);

    if (should_mail(status))
	send_mail("%s", logline);	/* send mail based on status */

    /* Inform the user if they failed to authenticate.  */
    if (inform_user) {
	if (ISSET(status, FLAG_NO_USER)) {
	    sudo_printf(SUDO_CONV_ERROR_MSG, _("%s is not in the sudoers "
		"file.  This incident will be reported.\n"), user_name);
	} else if (ISSET(status, FLAG_NO_HOST)) {
	    sudo_printf(SUDO_CONV_ERROR_MSG, _("%s is not allowed to run sudo "
		"on %s.  This incident will be reported.\n"),
		user_name, user_shost);
	} else if (ISSET(status, FLAG_NO_CHECK)) {
	    sudo_printf(SUDO_CONV_ERROR_MSG, _("Sorry, user %s may not run "
		"sudo on %s.\n"), user_name, user_shost);
	} else {
	    sudo_printf(SUDO_CONV_ERROR_MSG, _("Sorry, user %s is not allowed "
		"to execute '%s%s%s' as %s%s%s on %s.\n"),
		user_name, user_cmnd, user_args ? " " : "",
		user_args ? user_args : "",
		list_pw ? list_pw->pw_name : runas_pw ?
		runas_pw->pw_name : user_name, runas_gr ? ":" : "",
		runas_gr ? runas_gr->gr_name : "", user_host);
	}
    }

    /*
     * Log via syslog and/or a file.
     */
    if (def_syslog)
	do_syslog(def_syslog_badpri, logline);
    if (def_logfile)
	do_logfile(logline);

    efree(logline);
}
Example #15
0
static void startup(SESSION *session)
{
    if (message_count-- <= 0) {
        myfree((char *) session);
        session_count--;
        return;
    }
    if (session->stream == 0) {
        enqueue_connect(session);
    } else {
        send_mail(session);
    }
}
Example #16
0
void cpl_aux_process( int cmd_out, char *log_dir)
{
	struct cpl_cmd cmd;
	int len;

	/* this process will ignore SIGCHLD signal */
	if (signal( SIGCHLD, SIG_IGN)==SIG_ERR) {
		LOG(L_ERR,"ERROR:cpl_c:cpl_aux_process: cannot set to IGNORE "
			"SIGCHLD signal\n");
	}

	/* set the path for logging */
	if (log_dir) {
		strcpy( file, log_dir);
		file_ptr = file + strlen(log_dir);
		*(file_ptr++) = '/';
	}

	while(1) {
		/* let's read a command from pipe */
		len = read( cmd_out, &cmd, sizeof(struct cpl_cmd));
		if (len!=sizeof(struct cpl_cmd)) {
			if (len>=0) {
				LOG(L_ERR,"ERROR:cpl_aux_processes: truncated message"
					" read from pipe! -> discarded\n");
			} else if (errno!=EAGAIN) {
				LOG(L_ERR,"ERROR:cpl_aux_process: pipe reading failed: "
					" : %s\n",strerror(errno));
			}
			sleep(1);
			continue;
		}

		/* update the local config */
		cfg_update();

		/* process the command*/
		switch (cmd.code) {
			case CPL_LOG_CMD:
				write_log( &cmd );
				break;
			case CPL_MAIL_CMD:
				send_mail( &cmd );
				break;
			default:
				LOG(L_ERR,"ERROR:cpl_aux_process: unknown command (%d) "
					"received! -> ignoring\n",cmd.code);
		} /* end switch*/

	}
}
Example #17
0
int Logic_Public::send_mail(Role_Vec &role_vec, Mail_Send_Info &send_info) {
	//群发邮件 send_info至少包含(sender_id,发送人  send_type,邮件类型  title,标题  content,内容)
	if (send_info.title.size() > MAIL_TITLE_MAX_LEN || send_info.content.size() > MAIL_CONTENT_MAX_LEN) {
		MSG_USER("title:%s, content:%s", send_info.title.c_str(), send_info.content.c_str());
		return ERROR_CONTENT_TITLE;
	}
	if (send_info.sender_id) {
		send_info.sender_name = LOGIC_MONITOR->get_role_name_by_id(send_info.sender_id);
	}
	for(Role_Vec::iterator iter = role_vec.begin(); iter != role_vec.end(); ++iter) {
		send_info.show_send_time = Time_Value::gettimeofday();
		send_info.receiver_id = *iter;
		send_mail(send_info);
	}
	return 0;
}
int main(char argc, char *argv[])       {
              
if(argc < 2) {
        fprintf(stderr, "\n[Kde Kmail email-attachment symlink race exploit, by DiGiT - [email protected]]\n");
        fprintf(stderr, "[Syntax is: %s user host : ie %s root theboxyouron.com]\n", argv[0], argv[0]);
        fprintf(stderr, "[Make sure you hit the right email address]\n\n");
 
                        exit(0);
                }

                
        strncpy(username, argv[1], sizeof(username));
        strncpy(hostname, argv[2], sizeof(hostname));
                
                printf("starting the attack...\n");
   
                        send_mail();
        }
Example #19
0
File: logging.c Project: CVi/sudo
/*
 * Log and potentially mail the allowed command.
 */
void
log_allowed(int status)
{
    char *logline;

    logline = new_logline(NULL, 0);

    if (should_mail(status))
	send_mail("%s", logline);	/* send mail based on status */

    /*
     * Log via syslog and/or a file.
     */
    if (def_syslog)
	do_syslog(def_syslog_goodpri, logline);
    if (def_logfile)
	do_logfile(logline);

    efree(logline);
}
Example #20
0
int Logic_Public::send_mail(const role_id_t role_id, const std::string &sender_name, const std::string &title, const std::string &contents, const Item_Vec &item_vector) {
	Mail_Send_Info send_info;
	send_info.sender_id = 0;
	send_info.receiver_id = role_id;
	send_info.send_type = MAIL_TYPE_SYS;
	send_info.show_send_time = Time_Value::gettimeofday();
	send_info.sender_name = sender_name;
	send_info.title = title;
	send_info.content = contents;

	for(Item_Vec::const_iterator item_iter  = item_vector.begin(); item_iter != item_vector.end(); item_iter++) {
		const Item_Detail_Config *idc = CONFIG_CACHE_ITEM->find_item(item_iter->id_);
		if (!idc) {
			if(MAIL_ITEM_MAX_NUM < item_iter->amount_) {
				MSG_TRACE_ABORT("Mail Item amount ERROR");
				return ERROR_PERM_LIMIT;
			}
		} else if(MAIL_ITEM_MAX_NUM < item_iter->amount_ / idc->overlay) {
			MSG_TRACE_ABORT("Mail Item amount ERROR");
			return ERROR_PERM_LIMIT;
		}
		send_info.item_vector.push_back(*item_iter);
	}
	return send_mail(send_info);

//	bool has_send = true;
//	for(Item_Vec::const_iterator item_iter  = item_vector.begin(); item_iter != item_vector.end(); item_iter++) {
//		send_info.item_vector.push_back(*item_iter);
//		has_send = true;
//		if(send_info.item_vector.size() >= 4) {
//			send_mail(send_info);
//			has_send = false;
//			send_info.item_vector.clear();
//		}
//	}
//
//	if(has_send) {
//		send_mail(send_info);
//	}
	return 0;
}
Example #21
0
int Logic_Public::send_mail(int id, role_id_t role_id, const Item_Vec &item_vector, const std::string &title, const std::string &contents) {
	std::vector<Item_Basic_Info> item_base_vector;
	item_base_vector.clear();
	Item_Basic_Info base_info;
	for(Item_Vec::const_iterator iter = item_vector.begin(); iter != item_vector.end(); ++iter) {
		const Item_Detail_Config *idc = CONFIG_CACHE_ITEM->find_item(iter->id_);
		if (!idc) {
			if(MAIL_ITEM_MAX_NUM < iter->amount_) {
				MSG_TRACE_ABORT("Mail Item amount ERROR");
				return ERROR_PERM_LIMIT;
			}
		} else if(MAIL_ITEM_MAX_NUM < iter->amount_ / idc->overlay) {
			MSG_TRACE_ABORT("Mail Item amount ERROR");
			return ERROR_PERM_LIMIT;
		}
		base_info.reset();
		iter->set_item_basic_info(base_info);
		item_base_vector.push_back(base_info);
	}
	return send_mail(id, role_id, item_base_vector, title, contents);
}
Example #22
0
/*
 * Log and potentially mail the allowed command.
 */
bool
log_allowed(int status)
{
    char *logline;
    int oldlocale;
    bool uid_changed, ret = true;
    debug_decl(log_allowed, SUDOERS_DEBUG_LOGGING)

    /* Log and mail messages should be in the sudoers locale. */
    sudoers_setlocale(SUDOERS_LOCALE_SUDOERS, &oldlocale);

    if ((logline = new_logline(NULL, 0)) == NULL)
	debug_return_bool(false);

    /* Become root if we are not already. */
    uid_changed = set_perms(PERM_ROOT);

    /* XXX - return value */
    if (should_mail(status))
	send_mail("%s", logline);	/* send mail based on status */

    /*
     * Log via syslog and/or a file.
     */
    if (def_syslog)
	do_syslog(def_syslog_goodpri, logline);
    if (def_logfile && !do_logfile(logline))
	ret = false;

    if (uid_changed) {
	if (!restore_perms())
	    ret = false;		/* XXX - return -1 instead? */
    }

    free(logline);

    sudoers_setlocale(oldlocale, NULL);

    debug_return_bool(ret);
}
Example #23
0
void check_timers () {
  while (n > 0 && timer_timeout[top_heap()] <= get_time_usec()) {
    int id = poll_heap();
    struct message *m = get_stop_message();
    m->type = TIMEOUT_MESSAGE_TYPE;
    if (m != NULL) {
      struct alarm *alrm = (struct alarm *) malloc(sizeof(struct alarm));
      if (alrm == NULL) {
        free(m);
        myperror("malloc");
      } else {
        alrm->id = id;
        alrm->timeout = timer_timeout[id];
        alrm->inbox = NULL;
        m->data = alrm;
        send_mail(inbox[id], m);
        timer_timeout[id] = 0;
        inbox[id] = NULL;
      }
    }
  }
}
Example #24
0
/*
 * Send a vacation message. FIXME: this should provide
 * MIME support, to comply with the Sieve-Vacation spec.
 */
static int send_vacation(DbmailMessage *message,
		const char *to, const char *from,
		const char *subject, const char *body, const char *handle)
{
	int result;
	const char *x_dbmail_vacation = dbmail_message_get_header(message, "X-Dbmail-Vacation");

	if (x_dbmail_vacation) {
		TRACE(TRACE_NOTICE, "vacation loop detected [%s]", x_dbmail_vacation);
		return 0;
	}

	DbmailMessage *new_message = dbmail_message_new();
	new_message = dbmail_message_construct(new_message, to, from, subject, body);
	dbmail_message_set_header(new_message, "X-DBMail-Vacation", handle);

	result = send_mail(new_message, to, from, NULL, SENDMESSAGE, SENDMAIL);

	dbmail_message_free(new_message);

	return result;
}
Example #25
0
/* Helper to write mail to the output(s).  */
gpg_error_t
wks_send_mime (mime_maker_t mime)
{
  gpg_error_t err;
  estream_t mail;

  /* Without any option we take a short path.  */
  if (!opt.use_sendmail && !opt.output)
    {
      es_set_binary (es_stdout);
      return mime_maker_make (mime, es_stdout);
    }


  mail = es_fopenmem (0, "w+b");
  if (!mail)
    {
      err = gpg_error_from_syserror ();
      return err;
    }

  err = mime_maker_make (mime, mail);

  if (!err && opt.output)
    {
      es_rewind (mail);
      err = send_mail_to_file (mail, opt.output);
    }

  if (!err && opt.use_sendmail)
    {
      es_rewind (mail);
      err = send_mail (mail);
    }

  es_fclose (mail);
  return err;
}
Example #26
0
/*
 * Log, audit and mail the denial message, optionally informing the user.
 */
bool
log_denial(int status, bool inform_user)
{
    const char *message;
    char *logline;
    int oldlocale;
    bool uid_changed, ret = true;
    debug_decl(log_denial, SUDOERS_DEBUG_LOGGING)

    /* Handle auditing first (audit_failure() handles the locale itself). */
    if (ISSET(status, FLAG_NO_USER | FLAG_NO_HOST))
	audit_failure(NewArgc, NewArgv, N_("No user or host"));
    else
	audit_failure(NewArgc, NewArgv, N_("validation failure"));

    /* Log and mail messages should be in the sudoers locale. */
    sudoers_setlocale(SUDOERS_LOCALE_SUDOERS, &oldlocale);

    /* Set error message. */
    if (ISSET(status, FLAG_NO_USER))
	message = _("user NOT in sudoers");
    else if (ISSET(status, FLAG_NO_HOST))
	message = _("user NOT authorized on host");
    else
	message = _("command not allowed");

    logline = new_logline(message, 0);
    if (logline == NULL)
	debug_return_bool(false);

    /* Become root if we are not already. */
    uid_changed = set_perms(PERM_ROOT);

    if (should_mail(status))
	send_mail("%s", logline);	/* send mail based on status */

    /*
     * Log via syslog and/or a file.
     */
    if (def_syslog)
	do_syslog(def_syslog_badpri, logline);
    if (def_logfile && !do_logfile(logline))
	ret = false;

    if (uid_changed) {
	if (!restore_perms())
	    ret = false;		/* XXX - return -1 instead? */
    }

    free(logline);

    /* Restore locale. */
    sudoers_setlocale(oldlocale, NULL);

    /* Inform the user if they failed to authenticate (in their locale).  */
    if (inform_user) {
	sudoers_setlocale(SUDOERS_LOCALE_USER, &oldlocale);

	if (ISSET(status, FLAG_NO_USER)) {
	    sudo_printf(SUDO_CONV_ERROR_MSG, _("%s is not in the sudoers "
		"file.  This incident will be reported.\n"), user_name);
	} else if (ISSET(status, FLAG_NO_HOST)) {
	    sudo_printf(SUDO_CONV_ERROR_MSG, _("%s is not allowed to run sudo "
		"on %s.  This incident will be reported.\n"),
		user_name, user_srunhost);
	} else if (ISSET(status, FLAG_NO_CHECK)) {
	    sudo_printf(SUDO_CONV_ERROR_MSG, _("Sorry, user %s may not run "
		"sudo on %s.\n"), user_name, user_srunhost);
	} else {
	    sudo_printf(SUDO_CONV_ERROR_MSG, _("Sorry, user %s is not allowed "
		"to execute '%s%s%s' as %s%s%s on %s.\n"),
		user_name, user_cmnd, user_args ? " " : "",
		user_args ? user_args : "",
		list_pw ? list_pw->pw_name : runas_pw ?
		runas_pw->pw_name : user_name, runas_gr ? ":" : "",
		runas_gr ? runas_gr->gr_name : "", user_host);
	}
	sudoers_setlocale(oldlocale, NULL);
    }
    debug_return_bool(ret);
}
void suh::password_reminder(const std::string& name) {
	std::stringstream msg;
	msg << "Hello " << name << ",\nyour password is '" << get_password(name) << "'.\n\nHave fun playing Wesnoth :)";
	send_mail(name, "Wesnoth Password Reminder", msg.str());
}
Example #28
0
static int8 mn_email(menu_ctrl mctrl, int8 *mbuf)
{
#define SET_STAGE(next_name_v, cur_var_v) \
{ \
	if(strlen((char*)mbuf) > 31) printf("buf overflow - try again\r\n"); \
	else { \
		strcpy((char*)cur_var_v, (char*)mbuf); \
		printf("Type a "next_name_v"\r\n"); \
		stage++; \
	} \
}
	uint8 ret;
	static uint8 stage = 0, ip[4];
	static int8 sender[32], passwd[32], recipient[32], subject[32];

	if(mctrl == MC_START) {
		printf("Enter Mail Server Address [Domain Name/IP Address]\r\n");
	} else if(mctrl == MC_END) {
		stage = 0;
	} else if(mctrl == MC_DATA) {
		switch(stage) {
		case 0:	// Server IP
			if(ip_check(mbuf, ip) == RET_NOK) {
				if(dns_query(SOCK_DNS, (void *)mbuf, ip) == RET_OK) {
					printf("DNS success - IP Address is (%d.%d.%d.%d)\r\n\r\n",	
						ip[0], ip[1], ip[2], ip[3]);
					printf("Type a Sender\r\n");
					stage = 1;
				} else {
					printf("DNS failed\r\n\r\n");
					printf("Enter Mail Server Address [Domain Name/IP Address]\r\n");
				}
			} else {
				printf("Type a Sender\r\n");
				stage = 1;
			}
			break;
		case 1:	// Sender
			SET_STAGE("Password", sender);
			break;
		case 2:	// Password
			SET_STAGE("Recipient", passwd);
			break;
		case 3:	// Recipient
			SET_STAGE("Subject", recipient);
			break;
		case 4:	// Subject
			SET_STAGE("message" , subject); 
			break;
		case 5:	// Message
			ret = send_mail(SOCK_SMTP, (uint8*)sender, (uint8*)passwd, 
				(uint8*)recipient, (uint8*)subject, (uint8*)mbuf, ip);
			if(ret == RET_OK) printf("mail send success\r\n");
			else printf("mail send fail\r\n");
			return RET_OK;
		default: printf("wrong stage(%d)\r\n", stage);
		}
	}

	return RET_NOK;

#undef SET_STAGE
}
Example #29
0
/*******************************************************************************
* Function Name  : Main_Menu
* Description    : Display/Manage a Menu on HyperTerminal Window
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void Main_Menu(void)
{
	static char choice[3];
	static char subject[32], msg[256], sender[32], passwd[32], recipient[32], encodedText[256];
	static bool bTreat;
	static u8 Sip[4];
	static char key = 0;
	static wiz_NetInfo netinfo;
	
	
	while (1)
	{
		/* Display Menu on HyperTerminal Window */
		bTreat = (bool)RESET ;
   	        SerialPutString("\r\n====================== STM32-Discovery ===================\r\n");
		SerialPutString("This Application is basic example of UART interface with\r\n");
		SerialPutString("Windows Hyper Terminal. \r\n");
		SerialPutString("\r\n==========================================================\r\n");
		SerialPutString("                          APPLICATION MENU :\r\n");
		SerialPutString("\r\n==========================================================\r\n\n");
		SerialPutString(" 1 - Set LD1 on \r\n");
		SerialPutString(" 2 - Set LD1 off \r\n");
		SerialPutString(" 3 - Show network setting\r\n");
		SerialPutString(" 4 - Set  network setting\r\n");
		SerialPutString(" 5 - Run TCP Loopback\r\n");
		SerialPutString(" 6 - Run UDP Loopback\r\n");
		SerialPutString(" 7 - DNS test\r\n");
		SerialPutString(" 8 - BASE64 test\r\n");
		SerialPutString(" 9 - Send Mail\r\n");
		
		SerialPutString("Enter your choice : ");
		GetInputString(choice);
		/* Set LD1 on */
		if (strcmp(choice,"1")== 0)
		{
			bTreat = (bool)SET;
			LED3_onoff(ON);
			LED4_onoff(ON);
		}
		/* Set LD1 off */
		if ((strcmp(choice,"2") == 0))
		{
			bTreat = (bool)SET;
			LED3_onoff(OFF);
			LED4_onoff(OFF);
		}
		if (strcmp(choice,"3") == 0)
		{
			bTreat = (bool)SET;
			GetNetInfo(&netinfo);
			printf("\r\nIP : %d.%d.%d.%d", netinfo.IP[0],netinfo.IP[1],netinfo.IP[2],netinfo.IP[3]);
			printf("\r\nSN : %d.%d.%d.%d", netinfo.Subnet[0],netinfo.Subnet[1],netinfo.Subnet[2],netinfo.Subnet[3]);
			printf("\r\nGW : %d.%d.%d.%d", netinfo.Gateway[0],netinfo.Gateway[1],netinfo.Gateway[2],netinfo.Gateway[3]);
			printf("\r\nDNS server : %d.%d.%d.%d", netinfo.DNSServerIP[0],netinfo.DNSServerIP[1],netinfo.DNSServerIP[2],netinfo.DNSServerIP[3]);

		}

		if (strcmp(choice,"4") == 0)
		{
			bTreat = (bool)SET;
			// IP address
			SerialPutString("\r\nIP address : ");
			GetInputString(msg);
			if(!VerifyIPAddress(msg, netinfo.IP))
			{
				SerialPutString("\aInvalid.");
			}

			// Subnet mask
			SerialPutString("\r\nSubnet mask : ");
			GetInputString(msg);
			if(!VerifyIPAddress(msg, netinfo.Subnet))
			{
				SerialPutString("\aInvalid.");
			}
			
			// gateway address
			SerialPutString("\r\nGateway address : ");
			GetInputString(msg);
			if(!VerifyIPAddress(msg, netinfo.Gateway))
			{
				SerialPutString("\aInvalid.");
			}

			// DNS address
			SerialPutString("\r\nDNS address : ");
			GetInputString(msg);
			if(!VerifyIPAddress(msg, netinfo.DNSServerIP))
			{
				SerialPutString("\aInvalid.");
			}

			printf("\r\nIP : %d.%d.%d.%d", netinfo.IP[0],netinfo.IP[1],netinfo.IP[2],netinfo.IP[3]);
			printf("\r\nSN : %d.%d.%d.%d", netinfo.Subnet[0],netinfo.Subnet[1],netinfo.Subnet[2],netinfo.Subnet[3]);
			printf("\r\nGW : %d.%d.%d.%d", netinfo.Gateway[0],netinfo.Gateway[1],netinfo.Gateway[2],netinfo.Gateway[3]);
			printf("\r\nDNS server : %d.%d.%d.%d", netinfo.DNSServerIP[0],netinfo.DNSServerIP[1],netinfo.DNSServerIP[2],netinfo.DNSServerIP[3]);

			SetNetInfo(&netinfo);
		}
		

		if (strcmp(choice,"5") == 0)
		{
			bTreat = (bool)SET;
		  
			SerialPutString("\r\nRun TCP loopback");
			printf("\r\nRun TCP loopback, port number [%d] is listened", (u16)TCP_LISTEN_PORT);
			SerialPutString("\r\nTo Exit, press [Q]");
			
		  while(1) {

			if ((SerialKeyPressed((char*)&key) == 1) && (key == 'Q')) {
				SerialPutString("\r\n Stop ");
				
				break;
			}

			loopback_tcps(7, (u16)TCP_LISTEN_PORT);
		  }
		  

		}


		if (strcmp(choice,"6") == 0)
		{
			bTreat = (bool)SET;
		  
			SerialPutString("\r\nRun UDP loopback");
			printf("\r\nRun UDP loopback, port number [%d] is listened", (u16)UDP_LISTEN_PORT);
			SerialPutString("\r\nTo Exit, press [Q]");
			
			while(1) {

				if ((SerialKeyPressed((char*)&key) == 1) && (key == 'Q')) {
					SerialPutString("\r\n Stop ");
				
					break;

				}

				loopback_udp(7, (u16)UDP_LISTEN_PORT);
			}

		}


		if (strcmp(choice,"7")== 0)
		{
		  	bTreat = (bool)SET;
			
			SerialPutString("\r\nServer address : ");
			GetInputString(msg);

			SerialPutString("URL = ");
			SerialPutString(msg);
			  	
			if (dns_query(SOCK_DNS, (void *)msg, Sip) == 1) {

				printf("\r\nSIP : %d.%d.%d.%d", (u16)Sip[0],(u16)Sip[1],(u16)Sip[2],(u16)Sip[3]);

			}else {
				SerialPutString("\n\r DNS fail");

			}

			
		}


		if (strcmp(choice,"8")== 0)
		{
			bTreat = (bool)SET;
			
			memset(encodedText, '\0', 256);

			SerialPutString("\r\n");
			SerialPutString(" 1 - BASE64 Encode \r\n");
			SerialPutString(" 2 - BASE64 Decode \r\n");
			SerialPutString("Enter your choice : ");
			GetInputString(choice);

			if (strcmp(choice,"1")== 0) {

				SerialPutString("Type Plain Text\r\n");
				GetInputString(msg);
				base64_encode(msg, strlen(msg)+1, encodedText);
				SerialPutString("Encoded Text\r\n");
				printf("%s\r\n", encodedText);

			}else if(strcmp(choice,"2")== 0){

				SerialPutString("Type Encoded Text\r\n");
				GetInputString(msg);
				base64_decode(msg, (void *)encodedText, strlen(msg));
				SerialPutString("Decoded Text\r\n");
				printf("%s\r\n", encodedText);

			}

		}


		if (strcmp(choice,"9")== 0) {
		  	bTreat = (bool)SET;

			SerialPutString("\r\nServer address : ");
			GetInputString(msg);

			SerialPutString("URL = ");
			SerialPutString(msg);

			// DNS
			if (dns_query(SOCK_DNS, (void *)msg, Sip) == 1) {
				printf("\r\nSIP : %d.%d.%d.%d", (u16)Sip[0],(u16)Sip[1],(u16)Sip[2],(u16)Sip[3]);

				while(1) {

					SerialPutString("\r\nType a Sender: ");
					GetInputString(sender);

					SerialPutString("Type a Password: "******"Type a Recipient: ");
					GetInputString(recipient);

					SerialPutString("Type a Subject: ");
					GetInputString(subject);

					SerialPutString("Type a message: ");
					GetInputString(msg);

					send_mail(SOCK_SMTP, (void *)sender, (void *) passwd, (void *)recipient, (void *)subject, (void *)msg, Sip);

					SerialPutString("\r\nIf you want send another message? [YES]: any key, [NO]: Q");
					key = GetKey();

					if (key == 'Q') {
						SerialPutString("\r\n Stop ");

						break;

					}

				}

			}else {
				SerialPutString("\r\nDNS error");

			}
		}


		/* OTHERS CHOICE*/
		if (bTreat == (bool)RESET)
		{
			SerialPutString(" wrong choice  \r\n");
		}			
	} /* While(1)*/
}/* Main_Menu */
Example #30
0
int Logic_Public::send_mail(int id, Role_Vec &role_vec) {
	for(Role_Vec::iterator iter = role_vec.begin(); iter != role_vec.end(); ++iter) {
		send_mail(id, *iter);
	}
	return 0;
}