]> git.pond.sub.org Git - empserver/commitdiff
client: New option -r for restricted mode
authorMarisa Giancarla <fstltna@me.com>
Sat, 7 Dec 2013 15:43:13 +0000 (16:43 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Sun, 8 Mar 2015 16:30:46 +0000 (17:30 +0100)
Redirections and the execute command let the user read and write files
and run programs on the local system.

Restricted mode prevents such access.  This is useful when you want to
grant somebody access to just Empire, but not to the host system's
user account that runs the client.

Signed-off-by: Marisa Giancarla <fstltna@me.com>
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
man/empire.6
src/client/main.c
src/client/misc.h
src/client/servcmd.c

index 837b1349dcadfbc21fefa1ddcb8ea9dcd5b800cc..efb87060d0dff055f0847b9356ae945a3317a86b 100644 (file)
@@ -4,7 +4,7 @@ empire \- Empire client
 .SH SYNOPSIS
 .B empire
 [
-.B \-hkuv
+.B \-hkruv
 ]
 [
 .BI \-2 " outfile"
@@ -37,6 +37,9 @@ Help.  Print brief usage information and exit.
 .B \-k
 If someone else is connected to your country, kill their connection.
 .TP
+.B \-r
+Restricted mode: disable redirections and execute command.
+.TP
 .BI \-s " [host:]port"
 Specify server \fIhost\fR and \fIport\fR.
 .TP
index 8e1781707d5f249c24651a4959b736b7057d5d5e..74ab4271150993b1f34046f4726df564458282a4 100644 (file)
@@ -69,6 +69,7 @@ print_usage(char *program_name)
     printf("Usage: %s [OPTION]...[COUNTRY [PASSWORD]]\n"
           "  -2 FILE         Append log of session to FILE\n"
           "  -k              Kill connection\n"
+          "  -r              Restricted mode, no redirections\n"
           "  -s [HOST:]PORT  Specify server HOST and PORT\n"
           "  -u              Use UTF-8\n"
           "  -h              display this help and exit\n"
@@ -92,7 +93,7 @@ main(int argc, char **argv)
     char *colon;
     int sock;
 
-    while ((opt = getopt(argc, argv, "2:ks:uhv")) != EOF) {
+    while ((opt = getopt(argc, argv, "2:krs:uhv")) != EOF) {
        switch (opt) {
        case '2':
            auxfname = optarg;
@@ -100,6 +101,9 @@ main(int argc, char **argv)
        case 'k':
            send_kill = 1;
            break;
+       case 'r':
+           restricted = 1;
+           break;
        case 's':
            port = strdup(optarg);
            colon = strrchr(port, ':');
index 69a86aa603df5455171d875af6b490e7f3337565..1fd9f9bdc17481e44f0f2f0250b27729dda6c21e 100644 (file)
@@ -44,6 +44,7 @@ extern int eight_bit_clean;
 extern int input_fd;
 extern int send_eof;
 extern FILE *auxfp;
+extern int restricted;
 
 #ifdef HAVE_CURSES_TERMINFO
 void getsose(void);
index 2c4ac6e45cf7eece719f0ee7a6a3fed54a5ca051..0c33758f18ab9ec81450b119220a46eedfc91d19 100644 (file)
@@ -47,6 +47,7 @@
 
 int eight_bit_clean;
 FILE *auxfp;
+int restricted;
 
 static FILE *redir_fp;
 static int redir_is_pipe;
@@ -161,6 +162,11 @@ redir_authorized(char *arg, char *attempt, int expected)
 {
     size_t seen = seen_input(arg);
 
+    if (restricted) {
+       fprintf(stderr, "Can't %s in restricted mode\n", attempt);
+       return 0;
+    }
+
     if (executing) {
        fprintf(stderr, "Can't %s in a batch file\n", attempt);
        return 0;