]> granicus.if.org Git - sudo/commitdiff
Require POSIX regular expression support for sudoreplay.
authorTodd C. Miller <Todd.Miller@courtesan.com>
Thu, 5 Feb 2015 18:16:06 +0000 (11:16 -0700)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Thu, 5 Feb 2015 18:16:06 +0000 (11:16 -0700)
config.h.in
configure
configure.ac
doc/sudoreplay.cat
doc/sudoreplay.man.in
doc/sudoreplay.mdoc.in
plugins/sudoers/sudoreplay.c

index 809c34aa514543aefd932fd3441e4f85b76934c2..1a2bceb3dffcc397ace4eb20dc84492b37ae428b 100644 (file)
 /* Define to 1 if you have the `random' function. */
 #undef HAVE_RANDOM
 
-/* Define to 1 if you have the `regcomp' function. */
-#undef HAVE_REGCOMP
-
 /* Define to 1 if you have the `revoke' function. */
 #undef HAVE_REVOKE
 
index fd1c53844aa2092963cf55a6a27d4127cc76e574..944029fee029af91e0770734aaa95bdef09cfc73 100755 (executable)
--- a/configure
+++ b/configure
@@ -2828,7 +2828,6 @@ as_fn_append ac_header_list " sys/stropts.h"
 as_fn_append ac_header_list " sys/sysmacros.h"
 as_fn_append ac_func_list " killpg"
 as_fn_append ac_func_list " nl_langinfo"
-as_fn_append ac_func_list " regcomp"
 as_fn_append ac_func_list " strftime"
 as_fn_append ac_func_list " strrchr"
 as_fn_append ac_func_list " strtoll"
@@ -18052,8 +18051,6 @@ done
 
 
 
-
-
 for ac_func in getgrouplist
 do :
   ac_fn_c_check_func "$LINENO" "getgrouplist" "ac_cv_func_getgrouplist"
index 1fedd076318f584d99076c7a11b9e130ccd13a74..979cab51d07f8f031b9bbf1fc124887020fb70a7 100644 (file)
@@ -2339,7 +2339,7 @@ dnl
 dnl Function checks
 dnl
 AC_FUNC_GETGROUPS
-AC_CHECK_FUNCS_ONCE([killpg nl_langinfo regcomp strftime strrchr strtoll sysconf tzset])
+AC_CHECK_FUNCS_ONCE([killpg nl_langinfo strftime strrchr strtoll sysconf tzset])
 AC_CHECK_FUNCS([getgrouplist], [], [
     case "$host_os" in
     aix*)
index dfc4e637c5dfe4980736c6012a2a226204f1704e..dc41fbf80dc0fca11a6bb81ec8dbb20da4912f85 100644 (file)
@@ -58,11 +58,8 @@ D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
                  following predicates:
 
                  command _\bp_\ba_\bt_\bt_\be_\br_\bn
-                         Evaluates to true if the command run matches _\bp_\ba_\bt_\bt_\be_\br_\bn.
-                         On systems with POSIX regular expression support, the
-                         pattern may be an extended regular expression.  On
-                         systems without POSIX regular expression support, a
-                         simple sub-string match is performed instead.
+                         Evaluates to true if the command run matches the
+                         POSIX extended regular expression _\bp_\ba_\bt_\bt_\be_\br_\bn.
 
                  cwd _\bd_\bi_\br_\be_\bc_\bt_\bo_\br_\by
                          Evaluates to true if the command was run with the
@@ -274,4 +271,4 @@ D\bDI\bIS\bSC\bCL\bLA\bAI\bIM\bME\bER\bR
      file distributed with s\bsu\bud\bdo\bo or http://www.sudo.ws/license.html for
      complete details.
 
-Sudo 1.8.12                    December 4, 2014                    Sudo 1.8.12
+Sudo 1.8.12                    February 5, 2015                    Sudo 1.8.12
index caf714984f33b2de412ce1cee4e9132698f71c30..8c84bf848edbab01b1e6d1f7bcc043f39dc440e0 100644 (file)
@@ -1,7 +1,7 @@
 .\" DO NOT EDIT THIS FILE, IT IS NOT THE MASTER!
 .\" IT IS GENERATED AUTOMATICALLY FROM sudoreplay.mdoc.in
 .\"
-.\" Copyright (c) 2009-2014 Todd C. Miller <Todd.Miller@courtesan.com>
+.\" Copyright (c) 2009-2015 Todd C. Miller <Todd.Miller@courtesan.com>
 .\"
 .\" Permission to use, copy, modify, and distribute this software for any
 .\" purpose with or without fee is hereby granted, provided that the above
@@ -16,7 +16,7 @@
 .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 .\" ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 .\"
-.TH "SUDOREPLAY" "8" "December 4, 2014" "Sudo @PACKAGE_VERSION@" "System Manager's Manual"
+.TH "SUDOREPLAY" "8" "February 5, 2015" "Sudo @PACKAGE_VERSION@" "System Manager's Manual"
 .nh
 .if n .ad l
 .SH "NAME"
@@ -135,12 +135,9 @@ An expression is composed of the following predicates:
 .PD 0
 .TP 8n
 command \fIpattern\fR
-Evaluates to true if the command run matches
+Evaluates to true if the command run matches the POSIX extended
+regular expression
 \fIpattern\fR.
-On systems with POSIX regular expression support, the pattern may
-be an extended regular expression.
-On systems without POSIX regular expression support, a simple sub-string
-match is performed instead.
 .PD
 .TP 8n
 cwd \fIdirectory\fR
index 00c735362dac4857ad20e9f5bb8090eb3f5a3057..37be3700468abd92df53d14690e9e91eb863abf5 100644 (file)
@@ -1,5 +1,5 @@
 .\"
-.\" Copyright (c) 2009-2014 Todd C. Miller <Todd.Miller@courtesan.com>
+.\" Copyright (c) 2009-2015 Todd C. Miller <Todd.Miller@courtesan.com>
 .\"
 .\" Permission to use, copy, modify, and distribute this software for any
 .\" purpose with or without fee is hereby granted, provided that the above
@@ -14,7 +14,7 @@
 .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 .\" ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd December 4, 2014
+.Dd February 5, 2015
 .Dt SUDOREPLAY @mansectsu@
 .Os Sudo @PACKAGE_VERSION@
 .Sh NAME
@@ -124,12 +124,9 @@ is specified, it will be used to restrict the IDs that are displayed.
 An expression is composed of the following predicates:
 .Bl -tag -width 6n
 .It command Ar pattern
-Evaluates to true if the command run matches
+Evaluates to true if the command run matches the POSIX extended
+regular expression
 .Ar pattern .
-On systems with POSIX regular expression support, the pattern may
-be an extended regular expression.
-On systems without POSIX regular expression support, a simple sub-string
-match is performed instead.
 .It cwd Ar directory
 Evaluates to true if the command was run with the specified current
 working directory.
index a0ab984d8e324b2587f9f95b7c489ee474733702..dbe44af04d69a149fc36ad05b51a3b6a9337fcb1 100644 (file)
 #  include <ndir.h>
 # endif
 #endif
-#ifdef HAVE_REGCOMP
-# include <regex.h>
-#endif
-#ifdef HAVE_ZLIB_H
-# include <zlib.h>
-#endif
-#include <signal.h>
 #ifdef HAVE_STDBOOL_H
 # include <stdbool.h>
 #else
 # include "compat/stdbool.h"
 #endif /* HAVE_STDBOOL_H */
+#include <regex.h>
+#include <signal.h>
+#ifdef HAVE_ZLIB_H
+# include <zlib.h>
+#endif
 
 #include <pathnames.h>
 
@@ -151,11 +149,7 @@ struct search_node {
     bool negated;
     bool or;
     union {
-#ifdef HAVE_REGCOMP
        regex_t cmdre;
-#else
-       char *pattern;
-#endif
        time_t tstamp;
        char *cwd;
        char *tty;
@@ -205,12 +199,6 @@ static void sudoreplay_handler(int);
 static void usage(int);
 static void write_output(int fd, int what, void *v);
 
-#ifdef HAVE_REGCOMP
-# define REGEX_T       regex_t
-#else
-# define REGEX_T       char
-#endif
-
 #define VALID_ID(s) (isalnum((unsigned char)(s)[0]) && \
     isalnum((unsigned char)(s)[1]) && isalnum((unsigned char)(s)[2]) && \
     isalnum((unsigned char)(s)[3]) && isalnum((unsigned char)(s)[4]) && \
@@ -715,13 +703,10 @@ parse_expr(struct search_node_list *head, char *argv[], bool sub_expr)
        } else {
            if (*(++av) == NULL)
                sudo_fatalx(U_("%s requires an argument"), av[-1]);
-#ifdef HAVE_REGCOMP
            if (type == ST_PATTERN) {
                if (regcomp(&sn->u.cmdre, *av, REG_EXTENDED|REG_NOSUB) != 0)
                    sudo_fatalx(U_("invalid regular expression: %s"), *av);
-           } else
-#endif
-           if (type == ST_TODATE || type == ST_FROMDATE) {
+           } else if (type == ST_TODATE || type == ST_FROMDATE) {
                sn->u.tstamp = get_date(*av);
                if (sn->u.tstamp == -1)
                    sudo_fatalx(U_("could not parse date \"%s\""), *av);
@@ -771,7 +756,6 @@ match_expr(struct search_node_list *head, struct log_info *log, bool last_match)
            res = strcmp(sn->u.user, log->user) == 0;
            break;
        case ST_PATTERN:
-#ifdef HAVE_REGCOMP
            rc = regexec(&sn->u.cmdre, log->cmd, 0, NULL, 0);
            if (rc && rc != REG_NOMATCH) {
                char buf[BUFSIZ];
@@ -779,9 +763,6 @@ match_expr(struct search_node_list *head, struct log_info *log, bool last_match)
                sudo_fatalx("%s", buf);
            }
            res = rc == REG_NOMATCH ? 0 : 1;
-#else
-           res = strstr(log.cmd, sn->u.pattern) != NULL;
-#endif
            break;
        case ST_FROMDATE:
            res = log->tstamp >= sn->u.tstamp;
@@ -935,7 +916,7 @@ free_log_info(struct log_info *li)
 }
 
 static int
-list_session(char *logfile, REGEX_T *re, const char *user, const char *tty)
+list_session(char *logfile, regex_t *re, const char *user, const char *tty)
 {
     char idbuf[7], *idstr, *cp;
     const char *timestr;
@@ -992,7 +973,7 @@ session_compare(const void *v1, const void *v2)
 
 /* XXX - always returns 0, calls sudo_fatal() on failure */
 static int
-find_sessions(const char *dir, REGEX_T *re, const char *user, const char *tty)
+find_sessions(const char *dir, regex_t *re, const char *user, const char *tty)
 {
     DIR *d;
     struct dirent *dp;
@@ -1079,22 +1060,18 @@ static int
 list_sessions(int argc, char **argv, const char *pattern, const char *user,
     const char *tty)
 {
-    REGEX_T rebuf, *re = NULL;
+    regex_t rebuf, *re = NULL;
     debug_decl(list_sessions, SUDO_DEBUG_UTIL)
 
     /* Parse search expression if present */
     parse_expr(&search_expr, argv, false);
 
-#ifdef HAVE_REGCOMP
     /* optional regex */
     if (pattern) {
        re = &rebuf;
        if (regcomp(re, pattern, REG_EXTENDED|REG_NOSUB) != 0)
            sudo_fatalx(U_("invalid regular expression: %s"), pattern);
     }
-#else
-    re = (char *) pattern;
-#endif /* HAVE_REGCOMP */
 
     debug_return_int(find_sessions(session_dir, re, user, tty));
 }