Initial work on getting privsets working.

This commit is contained in:
William Pitcock 2008-08-17 07:40:27 -05:00
parent 120b37f94f
commit b8be4a3f4c
3 changed files with 10 additions and 50 deletions

View File

@ -581,6 +581,7 @@ conf_end_oper(struct TopConf *tc)
yy_tmpoper->flags = yy_oper->flags;
yy_tmpoper->umodes = yy_oper->umodes;
yy_tmpoper->snomask = yy_oper->snomask;
yy_tmpoper->privset = yy_oper->privset;
#ifdef HAVE_LIBCRYPTO
if(yy_oper->rsa_pubkey_file)
@ -629,6 +630,12 @@ conf_set_oper_flags(void *data)
set_modes_from_table(&yy_oper->flags, "flag", oper_table, args);
}
static void
conf_set_oper_privset(void *data)
{
yy_oper->privset = privilegeset_get((char *) data);
}
static void
conf_set_oper_user(void *data)
{
@ -2027,6 +2034,7 @@ static struct ConfEntry conf_operator_table[] =
{ "rsa_public_key_file", CF_QSTRING, conf_set_oper_rsa_public_key_file, 0, NULL },
{ "flags", CF_STRING | CF_FLIST, conf_set_oper_flags, 0, NULL },
{ "umodes", CF_STRING | CF_FLIST, conf_set_oper_umodes, 0, NULL },
{ "privset", CF_QSTRING, conf_set_oper_privset, 0, NULL },
{ "snomask", CF_QSTRING, conf_set_oper_snomask, 0, NULL },
{ "user", CF_QSTRING, conf_set_oper_user, 0, NULL },
{ "password", CF_QSTRING, conf_set_oper_password, 0, NULL },

View File

@ -318,55 +318,6 @@ find_oper_conf(const char *username, const char *host, const char *locip, const
return NULL;
}
struct oper_flags
{
int flag;
const char *name;
};
static struct oper_flags oper_flagtable[] =
{
{ OPER_KLINE, "kline" },
{ OPER_XLINE, "xline" },
{ OPER_RESV, "resv" },
{ OPER_GLOBKILL, "global_kill" },
{ OPER_LOCKILL, "local_kill" },
{ OPER_REMOTE, "remote" },
{ OPER_UNKLINE, "unkline" },
{ OPER_REHASH, "rehash" },
{ OPER_DIE, "die" },
{ OPER_ADMIN, "admin" },
{ OPER_HADMIN, "hidden_admin" },
{ OPER_NICKS, "nick_changes" },
{ OPER_OPERWALL, "operwall" },
{ OPER_SPY, "spy" },
{ OPER_INVIS, "hidden_oper" },
{ OPER_REMOTEBAN, "remoteban" },
{ OPER_MASSNOTICE, "mass_notice" },
{ 0, NULL }
};
const char *
get_oper_privs(int flags)
{
static char buf[BUFSIZE];
char *p;
int i;
p = buf;
*p = '\0';
for(i = 0; oper_flagtable[i].flag; i++)
if (flags & oper_flagtable[i].flag)
{
if(*buf != '\0')
rb_strlcat(buf, ", ", sizeof(buf));
rb_strlcat(buf, oper_flagtable[i].name, sizeof(buf));
}
return buf;
}
struct server_conf *
make_server_conf(void)
{

View File

@ -1276,7 +1276,8 @@ oper_up(struct Client *source_p, struct oper_conf *oper_p)
sendto_one_numeric(source_p, RPL_SNOMASK, form_str(RPL_SNOMASK),
construct_snobuf(source_p->snomask));
sendto_one(source_p, form_str(RPL_YOUREOPER), me.name, source_p->name);
sendto_one_notice(source_p, ":*** Oper privs are %s", get_oper_privs(oper_p->flags));
sendto_one_notice(source_p, ":*** Oper privilege set is %s", oper_p->privset->name);
sendto_one_notice(source_p, ":*** Oper privs are %s", oper_p->privset->privs);
send_oper_motd(source_p);
return (1);