Add -R restricted flag
parent
252428f97a
commit
10ae7bedbd
15
catgirl.1
15
catgirl.1
|
@ -1,4 +1,4 @@
|
||||||
.Dd February 10, 2020
|
.Dd February 11, 2020
|
||||||
.Dt CATGIRL 1
|
.Dt CATGIRL 1
|
||||||
.Os
|
.Os
|
||||||
.
|
.
|
||||||
|
@ -8,7 +8,7 @@
|
||||||
.
|
.
|
||||||
.Sh SYNOPSIS
|
.Sh SYNOPSIS
|
||||||
.Nm
|
.Nm
|
||||||
.Op Fl ev
|
.Op Fl Rev
|
||||||
.Op Fl C Ar copy
|
.Op Fl C Ar copy
|
||||||
.Op Fl H Ar hash
|
.Op Fl H Ar hash
|
||||||
.Op Fl O Ar open
|
.Op Fl O Ar open
|
||||||
|
@ -70,6 +70,17 @@ The default is the first available of
|
||||||
.Xr open 1 ,
|
.Xr open 1 ,
|
||||||
.Xr xdg-open 1 .
|
.Xr xdg-open 1 .
|
||||||
.
|
.
|
||||||
|
.It Fl R , Cm restrict
|
||||||
|
Disable the
|
||||||
|
.Ic /copy ,
|
||||||
|
.Ic /debug ,
|
||||||
|
.Ic /join ,
|
||||||
|
.Ic /msg ,
|
||||||
|
.Ic /open ,
|
||||||
|
.Ic /query ,
|
||||||
|
.Ic /quote
|
||||||
|
commands.
|
||||||
|
.
|
||||||
.It Fl a Ar user Ns : Ns Ar pass , Cm sasl-plain = Ar user Ns : Ns Ar pass
|
.It Fl a Ar user Ns : Ns Ar pass , Cm sasl-plain = Ar user Ns : Ns Ar pass
|
||||||
Authenticate as
|
Authenticate as
|
||||||
.Ar user
|
.Ar user
|
||||||
|
|
4
chat.c
4
chat.c
|
@ -93,12 +93,13 @@ int main(int argc, char *argv[]) {
|
||||||
const char *user = NULL;
|
const char *user = NULL;
|
||||||
const char *real = NULL;
|
const char *real = NULL;
|
||||||
|
|
||||||
const char *Opts = "!C:H:O:a:c:eh:j:k:n:p:r:s:u:vw:";
|
const char *Opts = "!C:H:O:Ra:c:eh:j:k:n:p:r:s:u:vw:";
|
||||||
const struct option LongOpts[] = {
|
const struct option LongOpts[] = {
|
||||||
{ "insecure", no_argument, NULL, '!' },
|
{ "insecure", no_argument, NULL, '!' },
|
||||||
{ "copy", required_argument, NULL, 'C' },
|
{ "copy", required_argument, NULL, 'C' },
|
||||||
{ "hash", required_argument, NULL, 'H' },
|
{ "hash", required_argument, NULL, 'H' },
|
||||||
{ "open", required_argument, NULL, 'O' },
|
{ "open", required_argument, NULL, 'O' },
|
||||||
|
{ "restrict", no_argument, NULL, 'R' },
|
||||||
{ "sasl-plain", required_argument, NULL, 'a' },
|
{ "sasl-plain", required_argument, NULL, 'a' },
|
||||||
{ "cert", required_argument, NULL, 'c' },
|
{ "cert", required_argument, NULL, 'c' },
|
||||||
{ "sasl-external", no_argument, NULL, 'e' },
|
{ "sasl-external", no_argument, NULL, 'e' },
|
||||||
|
@ -122,6 +123,7 @@ int main(int argc, char *argv[]) {
|
||||||
break; case 'C': urlCopyUtil = optarg;
|
break; case 'C': urlCopyUtil = optarg;
|
||||||
break; case 'H': hashInit = strtoul(optarg, NULL, 0);
|
break; case 'H': hashInit = strtoul(optarg, NULL, 0);
|
||||||
break; case 'O': urlOpenUtil = optarg;
|
break; case 'O': urlOpenUtil = optarg;
|
||||||
|
break; case 'R': self.restricted = true;
|
||||||
break; case 'a': sasl = true; self.plain = optarg;
|
break; case 'a': sasl = true; self.plain = optarg;
|
||||||
break; case 'c': cert = optarg;
|
break; case 'c': cert = optarg;
|
||||||
break; case 'e': sasl = true;
|
break; case 'e': sasl = true;
|
||||||
|
|
1
chat.h
1
chat.h
|
@ -85,6 +85,7 @@ enum Cap {
|
||||||
|
|
||||||
extern struct Self {
|
extern struct Self {
|
||||||
bool debug;
|
bool debug;
|
||||||
|
bool restricted;
|
||||||
char *plain;
|
char *plain;
|
||||||
const char *join;
|
const char *join;
|
||||||
enum Cap caps;
|
enum Cap caps;
|
||||||
|
|
40
command.c
40
command.c
|
@ -194,25 +194,26 @@ static void commandHelp(size_t id, char *params) {
|
||||||
static const struct Handler {
|
static const struct Handler {
|
||||||
const char *cmd;
|
const char *cmd;
|
||||||
Command *fn;
|
Command *fn;
|
||||||
|
bool restricted;
|
||||||
} Commands[] = {
|
} Commands[] = {
|
||||||
{ "/close", commandClose },
|
{ "/close", .fn = commandClose },
|
||||||
{ "/copy", commandCopy },
|
{ "/copy", .fn = commandCopy, .restricted = true },
|
||||||
{ "/debug", commandDebug },
|
{ "/debug", .fn = commandDebug, .restricted = true },
|
||||||
{ "/help", commandHelp },
|
{ "/help", .fn = commandHelp },
|
||||||
{ "/join", commandJoin },
|
{ "/join", .fn = commandJoin, .restricted = true },
|
||||||
{ "/me", commandMe },
|
{ "/me", .fn = commandMe },
|
||||||
{ "/msg", commandMsg },
|
{ "/msg", .fn = commandMsg, .restricted = true },
|
||||||
{ "/names", commandNames },
|
{ "/names", .fn = commandNames },
|
||||||
{ "/nick", commandNick },
|
{ "/nick", .fn = commandNick },
|
||||||
{ "/notice", commandNotice },
|
{ "/notice", .fn = commandNotice },
|
||||||
{ "/open", commandOpen },
|
{ "/open", .fn = commandOpen, .restricted = true },
|
||||||
{ "/part", commandPart },
|
{ "/part", .fn = commandPart },
|
||||||
{ "/query", commandQuery },
|
{ "/query", .fn = commandQuery, .restricted = true },
|
||||||
{ "/quit", commandQuit },
|
{ "/quit", .fn = commandQuit },
|
||||||
{ "/quote", commandQuote },
|
{ "/quote", .fn = commandQuote, .restricted = true },
|
||||||
{ "/topic", commandTopic },
|
{ "/topic", .fn = commandTopic },
|
||||||
{ "/whois", commandWhois },
|
{ "/whois", .fn = commandWhois },
|
||||||
{ "/window", commandWindow },
|
{ "/window", .fn = commandWindow },
|
||||||
};
|
};
|
||||||
|
|
||||||
static int compar(const void *cmd, const void *_handler) {
|
static int compar(const void *cmd, const void *_handler) {
|
||||||
|
@ -258,6 +259,9 @@ void command(size_t id, char *input) {
|
||||||
const struct Handler *handler = bsearch(
|
const struct Handler *handler = bsearch(
|
||||||
cmd, Commands, ARRAY_LEN(Commands), sizeof(*handler), compar
|
cmd, Commands, ARRAY_LEN(Commands), sizeof(*handler), compar
|
||||||
);
|
);
|
||||||
|
if (self.restricted && handler && handler->restricted) {
|
||||||
|
handler = NULL;
|
||||||
|
}
|
||||||
if (handler) {
|
if (handler) {
|
||||||
if (input) {
|
if (input) {
|
||||||
input += strspn(input, " ");
|
input += strspn(input, " ");
|
||||||
|
|
Loading…
Reference in New Issue