本文整理汇总了C++中set_user函数的典型用法代码示例。如果您正苦于以下问题:C++ set_user函数的具体用法?C++ set_user怎么用?C++ set_user使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set_user函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: detected
void detected(int code, const char *msg)
{
char tmp[512] = "";
struct flag_record fr = { FR_GLOBAL, 0, 0, 0 };
int act = DET_WARN, do_fatal = 0, killbots = 0;
if (code == DETECT_LOGIN)
act = login;
if (code == DETECT_TRACE)
act = trace;
if (code == DETECT_PROMISC)
act = promisc;
#ifdef NOT_USED
if (code == DETECT_PROCESS)
act = badprocess;
#endif
if (code == DETECT_HIJACK)
act = hijack;
switch (act) {
case DET_IGNORE:
break;
case DET_WARN:
putlog(LOG_WARN, "*", msg);
break;
case DET_REJECT:
do_fork();
putlog(LOG_WARN, "*", STR("Setting myself +d: %s"), msg);
simple_snprintf(tmp, sizeof(tmp), "+d: %s", msg);
set_user(&USERENTRY_COMMENT, conf.bot->u, tmp);
fr.global = USER_DEOP;
fr.bot = 1;
set_user_flagrec(conf.bot->u, &fr, 0);
sleep(1);
break;
case DET_DIE:
putlog(LOG_WARN, "*", STR("Dying: %s"), msg);
simple_snprintf(tmp, sizeof(tmp), STR("Dying: %s"), msg);
set_user(&USERENTRY_COMMENT, conf.bot->u, tmp);
if (!conf.bot->hub)
nuke_server(STR("BBL"));
sleep(1);
killbots++;
do_fatal++;
break;
case DET_SUICIDE:
suicide(msg);
break;
}
if (killbots && conf.bot->localhub) {
conf_checkpids(conf.bots);
conf_killbot(conf.bots, NULL, NULL, SIGKILL);
}
if (do_fatal)
fatal(msg, 0);
}
示例2: chanprog
void chanprog()
{
struct utsname un;
sdprintf("I am: %s", conf.bot->nick);
/* Add the 'default' virtual channel.
The flags will be overwritten when the userfile is loaded,
but if there is no userfile yet, or no 'default' channel,
then it will take on the properties of 'def_chanset',
and then later save this to the userfile.
*/
channel_add(NULL, "default", def_chanset, 1);
if (conf.bot->hub) {
simple_snprintf(userfile, 121, "%s/.u", dirname(binname));
loading = 1;
checkchans(0);
readuserfile(userfile, &userlist);
checkchans(1);
var_parse_my_botset();
loading = 0;
}
load_internal_users();
add_myself_to_userlist();
if (conf.bot->localhub)
add_child_bots();
else if (!conf.bot->hub)
add_localhub();
rehash_ip();
/* set our shell info */
uname(&un);
set_user(&USERENTRY_OS, conf.bot->u, un.sysname);
set_user(&USERENTRY_USERNAME, conf.bot->u, conf.username);
set_user(&USERENTRY_NODENAME, conf.bot->u, un.nodename);
set_user(&USERENTRY_ARCH, conf.bot->u, un.machine);
set_user(&USERENTRY_OSVER, conf.bot->u, un.release);
var_parse_my_botset();
/* We should be safe now */
reaffirm_owners();
}
示例3: pass_set
static bool pass_set(struct userrec *u, struct user_entry *e, void *buf)
{
char *newpass = NULL;
register char *pass = (char *) buf;
if (e->u.extra)
free(e->u.extra);
if (!pass || !pass[0] || (pass[0] == '-'))
e->u.extra = NULL;
else {
unsigned char *p = (unsigned char *) pass;
if (u->bot || (pass[0] == '+'))
newpass = strdup(pass);
else {
while (*p) {
if ((*p <= 32) || (*p == 127))
*p = '?';
p++;
}
newpass = salted_sha1(pass);
}
e->u.extra = strdup(newpass);
}
if (!noshare)
shareout("c %s %s %s\n", e->type->name, u->handle, newpass ? newpass : "");
if (newpass)
free(newpass);
/* clear old records */
noshare = 1;
set_user(&USERENTRY_PASS1, u, NULL);
noshare = 0;
return 1;
}
示例4: sys_setuid
/*
* setuid() is implemented like SysV with SAVED_IDS
*
* Note that SAVED_ID's is deficient in that a setuid root program
* like sendmail, for example, cannot set its uid to be a normal
* user and then switch back, because if you're root, setuid() sets
* the saved uid too. If you don't like this, blame the bright people
* in the POSIX committee and/or USG. Note that the BSD-style setreuid()
* will allow a root program to temporarily drop privileges and be able to
* regain them by swapping the real and effective uid.
*/
asmlinkage long sys_setuid(uid_t uid)
{
int old_euid = current->euid;
int old_ruid, old_suid, new_ruid, new_suid;
int retval;
retval = security_task_setuid(uid, (uid_t)-1, (uid_t)-1, LSM_SETID_ID);
if (retval)
return retval;
old_ruid = new_ruid = current->uid;
old_suid = current->suid;
new_suid = old_suid;
if (capable(CAP_SETUID)) {
if (uid != old_ruid && set_user(uid, old_euid != uid) < 0)
return -EAGAIN;
new_suid = uid;
} else if ((uid != current->uid) && (uid != new_suid))
return -EPERM;
if (old_euid != uid)
{
current->mm->dumpable = 0;
wmb();
}
current->fsuid = current->euid = uid;
current->suid = new_suid;
return security_task_post_setuid(old_ruid, old_euid, old_suid, LSM_SETID_ID);
}
示例5: update_mod
void update_mod(char *handle, char *nick, char *cmd, char *par)
{
char tmp[100] = "";
simple_snprintf(tmp, sizeof tmp, "%li, %s (%s %s)", (long) now, nick, cmd, (par && par[0]) ? par : "");
set_user(&USERENTRY_MODIFIED, get_user_by_handle(userlist, handle), tmp);
}
示例6: write_key_file
/*%
* Write a key file to 'keyfile'. If 'user' is non-NULL,
* make that user the owner of the file. The key will have
* the name 'keyname' and the secret in the buffer 'secret'.
*/
void
write_key_file(const char *keyfile, const char *user,
const char *keyname, isc_buffer_t *secret,
dns_secalg_t alg) {
isc_result_t result;
const char *algname = alg_totext(alg);
FILE *fd = NULL;
DO("create keyfile", isc_file_safecreate(keyfile, &fd));
if (user != NULL) {
if (set_user(fd, user) == -1)
fatal("unable to set file owner\n");
}
fprintf(fd, "key \"%s\" {\n\talgorithm %s;\n"
"\tsecret \"%.*s\";\n};\n",
keyname, algname,
(int)isc_buffer_usedlength(secret),
(char *)isc_buffer_base(secret));
fflush(fd);
if (ferror(fd))
fatal("write to %s failed\n", keyfile);
if (fclose(fd))
fatal("fclose(%s) failed\n", keyfile);
fprintf(stderr, "wrote key file \"%s\"\n", keyfile);
}
示例7: sys_setuid
/*
* setuid() is implemented like SysV with SAVED_IDS
*
* Note that SAVED_ID's is deficient in that a setuid root program
* like sendmail, for example, cannot set its uid to be a normal
* user and then switch back, because if you're root, setuid() sets
* the saved uid too. If you don't like this, blame the bright people
* in the POSIX committee and/or USG. Note that the BSD-style setreuid()
* will allow a root program to temporarily drop privileges and be able to
* regain them by swapping the real and effective uid.
*/
asmlinkage long sys_setuid(uid_t uid)
{
int old_euid = current->euid;
int old_ruid, old_suid, new_suid;
int retval;
retval = security_task_setuid(uid, (uid_t)-1, (uid_t)-1, LSM_SETID_ID);
if (retval)
return retval;
old_ruid = current->uid;
old_suid = current->suid;
new_suid = old_suid;
if (capable(CAP_SETUID)) {
if (uid != old_ruid && set_user(uid, old_euid != uid) < 0)
return -EAGAIN;
new_suid = uid;
} else if ((uid != current->uid) && (uid != new_suid))
return -EPERM;
if (old_euid != uid) {
set_dumpable(current->mm, suid_dumpable);
smp_wmb();
}
current->fsuid = current->euid = uid;
current->suid = new_suid;
key_fsuid_changed(current);
proc_id_connector(current, PROC_EVENT_UID);
return security_task_post_setuid(old_ruid, old_euid, old_suid, LSM_SETID_ID);
}
示例8: main
void main(){
int i;
int read;
while(1){
data_sum=save_sum=0;
printf("使用するユーザ名を入力して下さい\n");
scanf("%s",login_user);
set_user();
set_cate();
if(set_data(login_user)==-1)printf("データがありません\n");
else{
printf("%sさんのデータ\n",login_user);
for(i=0;i<data_sum;i++){
printf("%d/%d/%d ",data[i].year,data[i].month,data[i].day);
printf("%s ",data[i].item);
printf("%d ",data[i].cate);
printf("%8d ",data[i].value);
printf("%d\n",data[i].inout);
}
save_dat();
}
printf("\n続行-->1 終了-->2\n");
scanf("%d",&read);
if(read==2)break;
}
}
示例9: console_store
static int
console_store(int idx, char *par, bool displaySave)
{
struct console_info *i = (struct console_info *) get_user(&USERENTRY_CONSOLE, dcc[idx].user);
if (!i)
i = (struct console_info *) my_calloc(1, sizeof(struct console_info));
if (i->channel)
free(i->channel);
i->channel = strdup(dcc[idx].u.chat->con_chan);
i->conflags = dcc[idx].u.chat->con_flags;
i->stripflags = dcc[idx].u.chat->strip_flags;
i->echoflags = (dcc[idx].status & STAT_ECHO) ? 1 : 0;
if (dcc[idx].status & STAT_PAGE)
i->page = dcc[idx].u.chat->max_line;
else
i->page = 0;
if (dcc[idx].status & STAT_COLOR)
i->color = 1;
else
i->color = 0;
if (dcc[idx].status & STAT_BANNER)
i->banner = 1;
else
i->banner = 0;
if (dcc[idx].status & STAT_CHANNELS)
i->channels = 1;
else
i->channels = 0;
if (dcc[idx].status & STAT_BOTS)
i->bots = 1;
else
i->bots = 0;
if (dcc[idx].status & STAT_WHOM)
i->whom = 1;
else
i->whom = 0;
i->conchan = dcc[idx].u.chat->channel;
if (par) {
dprintf(idx, "%s\n", "Saved your Console Settings:");
dprintf(idx, " %s %s\n", "Channel:", i->channel);
dprintf(idx, " %s %s, %s %s, %s %s\n", "Console flags:",
masktype(i->conflags), "",
stripmasktype(i->stripflags), "Echo:", i->echoflags ? "yes" : "no");
dprintf(idx, " %s %d, %s %d\n", "Page setting:", i->page, "Console channel:", i->conchan);
dprintf(idx, " Color: $b%s$b\n", i->color ? "on" : "off");
dprintf(idx, " Login settings:\n");
dprintf(idx, " Login settings:\n");
dprintf(idx, " Banner: $b%-3s$b Bots: $b%-3s$b\n", i->banner ? "on" : "off", i->bots ? "on" : "off");
dprintf(idx, " Channels: $b%-3s$b Whom: $b%-3s$b\n", i->channels ? "on" : "off", i->whom ? "on" : "off");
}
set_user(&USERENTRY_CONSOLE, dcc[idx].user, i);
dprintf(idx, "Console setting stored.\n");
if (conf.bot->hub)
write_userfile(displaySave ? idx : -1);
return 0;
}
示例10: stats_add
void stats_add(struct userrec *u, int islogin, int op)
{
if (!u || u->bot)
return;
char *s = (char *) get_user(&USERENTRY_STATS, u), s2[50] = "";
int sl, so;
if (s) {
strlcpy(s2, s, sizeof(s2));
} else
strlcpy(s2, "0 0", sizeof(s2));
s = strchr(s2, ' ');
if (s) {
s++;
so = atoi(s);
} else
so = 0;
sl = atoi(s2);
if (islogin)
sl++;
if (op)
so++;
simple_snprintf(s2, sizeof(s2), "%i %i", sl, so);
set_user(&USERENTRY_STATS, u, s2);
}
示例11: hippo_block_blog_person_update_from_xml
static gboolean
hippo_block_blog_person_update_from_xml (HippoBlock *block,
HippoDataCache *cache,
LmMessageNode *node)
{
HippoBlockBlogPerson *block_blog_person = HIPPO_BLOCK_BLOG_PERSON(block);
LmMessageNode *blog_node;
HippoPerson *user;
if (!HIPPO_BLOCK_CLASS(hippo_block_blog_person_parent_class)->update_from_xml(block, cache, node))
return FALSE;
#if 0
if (!hippo_xml_split(cache, node, NULL,
"blogPerson", HIPPO_SPLIT_NODE, &blog_node,
NULL))
return FALSE;
if (!hippo_xml_split(cache, blog_node, NULL,
"userId", HIPPO_SPLIT_PERSON, &user,
NULL))
return FALSE;
set_user(block_blog_person, user);
#endif
return TRUE;
}
示例12: main
int main(int argc, char *argv[]) {
Irc freenode;
struct pollfd pfd[4];
int i, ready, murm_listenfd = -1;
initialize(argc, argv);
for (i = 0; i < SIZE(pfd); i++) {
pfd[i].fd = -1;
pfd[i].events = POLLIN;
}
if (add_murmur_callbacks(cfg.murmur_port))
pfd[MURM_LISTEN].fd = murm_listenfd = sock_listen(LOCALHOST, CB_LISTEN_PORT_S);
else
fprintf(stderr, "Could not connect to Murmur\n");
if ((pfd[MPD].fd = mpdfd = mpd_connect(cfg.mpd_port)) < 0)
fprintf(stderr, "Could not connect to MPD\n");
// Connect to server and set IRC details
if (!(freenode = irc_connect(cfg.server, cfg.port)))
exit_msg("Irc connection failed");
pfd[IRC].fd = get_socket(freenode);
set_nick(freenode, cfg.nick);
set_user(freenode, cfg.user);
for (i = 0; i < cfg.channels_set; i++)
join_channel(freenode, cfg.channels[i]);
while ((ready = poll(pfd, SIZE(pfd), TIMEOUT)) > 0) {
// Keep reading & parsing lines as long the connection is active and act on any registered actions found
if (pfd[IRC].revents & POLLIN)
while (parse_irc_line(freenode) > 0);
if (pfd[MURM_LISTEN].revents & POLLIN)
if ((pfd[MURM_ACCEPT].fd = accept_murmur_connection(murm_listenfd)) > 0)
pfd[MURM_LISTEN].fd = -1; // Stop listening for connections
if (pfd[MURM_ACCEPT].revents & POLLIN) {
if (!listen_murmur_callbacks(freenode, pfd[MURM_ACCEPT].fd)) {
pfd[MURM_ACCEPT].fd = -1;
pfd[MURM_LISTEN].fd = murm_listenfd; // Start listening again for Murmur connections
}
}
if (pfd[MPD].revents & POLLIN)
if (!print_song(freenode, default_channel(freenode)))
pfd[MPD].fd = mpdfd = mpd_connect(cfg.mpd_port);
}
// If we reach here, it means we got disconnected from server. Exit with error (1)
if (ready == -1)
perror("poll");
else
fprintf(stderr, "%d minutes passed without getting a message, exiting...\n", TIMEOUT / 1000 / 60);
quit_server(freenode, cfg.quit_msg);
cleanup();
return 1;
}
示例13: bot_handshake
static void bot_handshake(int idx, char *par)
{
struct userrec *u = get_user_by_handle(userlist, dcc[idx].nick);
/* We *don't* want botnet passwords migrating */
noshare = 1;
set_user(&USERENTRY_PASS, u, par);
noshare = 0;
}
示例14: hippo_block_abstract_person_dispose
static void
hippo_block_abstract_person_dispose(GObject *object)
{
HippoBlockAbstractPerson *block_abstract_person = HIPPO_BLOCK_ABSTRACT_PERSON(object);
set_user(block_abstract_person, NULL);
G_OBJECT_CLASS(hippo_block_abstract_person_parent_class)->dispose(object);
}
示例15: bot_shellinfo
static void bot_shellinfo(int idx, char *par)
{
char *username = NULL, *sysname = NULL, *nodename = NULL, *arch = NULL, *botversion = NULL;
username = newsplit(&par);
sysname = newsplit(&par);
nodename = newsplit(&par);
arch = newsplit(&par);
botversion = newsplit(&par);
set_user(&USERENTRY_USERNAME, dcc[idx].user, username);
set_user(&USERENTRY_OS, dcc[idx].user, sysname);
dcc[idx].u.bot->sysname[0] = 0;
struct bot_info dummy;
strlcpy(dcc[idx].u.bot->sysname, sysname, sizeof(dummy.sysname));
set_user(&USERENTRY_NODENAME, dcc[idx].user, nodename);
set_user(&USERENTRY_ARCH, dcc[idx].user, arch);
set_user(&USERENTRY_OSVER, dcc[idx].user, botversion);
}