]> granicus.if.org Git - sudo/commitdiff
Log lines and columns in the iolog file.
authorTodd C. Miller <Todd.Miller@courtesan.com>
Sat, 16 Feb 2013 16:12:48 +0000 (11:12 -0500)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Sat, 16 Feb 2013 16:12:48 +0000 (11:12 -0500)
plugins/sudoers/iolog.c

index 25e99df61bc6eb060adbe8048ede4ab6304579fa..1f530e52d1051ebf173a26aa3be2f7bfd3e913b2 100644 (file)
@@ -77,6 +77,8 @@ struct iolog_details {
     const char *iolog_path;
     struct passwd *runas_pw;
     struct group *runas_gr;
+    int lines;
+    int cols;
     int iolog_stdin;
     int iolog_stdout;
     int iolog_stderr;
@@ -317,15 +319,27 @@ iolog_deserialize_info(struct iolog_details *details, char * const user_info[],
     debug_decl(iolog_deserialize_info, SUDO_DEBUG_UTIL)
 
     memset(details, 0, sizeof(*details));
+    details->lines = 24;
+    details->cols = 80;
 
     for (cur = user_info; *cur != NULL; cur++) {
        switch (**cur) {
        case 'c':
+           if (strncmp(*cur, "cols=", sizeof("cols=") - 1) == 0) {
+               details->cols = atoi(*cur + sizeof("cols=") - 1);
+               continue;
+           }
            if (strncmp(*cur, "cwd=", sizeof("cwd=") - 1) == 0) {
                details->cwd = *cur + sizeof("cwd=") - 1;
                continue;
            }
            break;
+       case 'l':
+           if (strncmp(*cur, "lines=", sizeof("lines=") - 1) == 0) {
+               details->lines = atoi(*cur + sizeof("lines=") - 1);
+               continue;
+           }
+           break;
        case 't':
            if (strncmp(*cur, "tty=", sizeof("tty=") - 1) == 0) {
                details->tty = *cur + sizeof("tty=") - 1;
@@ -579,10 +593,10 @@ sudoers_io_open(unsigned int version, sudo_conv_t conversation,
 
     gettimeofday(&last_time, NULL);
 
-    fprintf(io_logfile, "%ld:%s:%s:%s:%s\n", (long)last_time.tv_sec,
+    fprintf(io_logfile, "%ld:%s:%s:%s:%s:%d:%d\n", (long)last_time.tv_sec,
        details.user ? details.user : "unknown", details.runas_pw->pw_name,
        details.runas_gr ? details.runas_gr->gr_name : "",
-       details.tty ? details.tty : "unknown");
+       details.tty ? details.tty : "unknown", details.lines, details.cols);
     fputs(details.cwd ? details.cwd : "unknown", io_logfile);
     fputc('\n', io_logfile);
     fputs(details.command ? details.command : "unknown", io_logfile);