summaryrefslogtreecommitdiff
path: root/Src/watch.c
diff options
context:
space:
mode:
authorAxel Beckert <abe@deuxchevaux.org>2015-05-05 23:32:59 +0200
committerAxel Beckert <abe@deuxchevaux.org>2015-05-05 23:58:59 +0200
commitdb38e167634b6c2217eec3a5aafc37c46d9e5a8d (patch)
treedaa342d423febbd3a5a7ef97053037677fab004a /Src/watch.c
parent01eea47617a6e06debdb4330f92ae69f92089fd2 (diff)
parent3c3c8d3d13fd4cf6c03f81ca8dc18a1efd561728 (diff)
downloadzsh-db38e167634b6c2217eec3a5aafc37c46d9e5a8d.tar.gz
zsh-db38e167634b6c2217eec3a5aafc37c46d9e5a8d.zip
Merge branch 'upstream' into debian
Diffstat (limited to 'Src/watch.c')
-rw-r--r--Src/watch.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/Src/watch.c b/Src/watch.c
index 8dea0b495..fe409f91a 100644
--- a/Src/watch.c
+++ b/Src/watch.c
@@ -372,6 +372,27 @@ watchlog2(int inout, WATCH_STRUCT_UTMP *u, char *fmt, int prnt, int fini)
return fmt;
}
+/* See if the watch entry matches */
+
+static int
+watchlog_match(char *teststr, char *actual, int len)
+{
+ int ret = 0;
+ Patprog pprog;
+ char *str = dupstring(teststr);
+
+ tokenize(str);
+
+ if ((pprog = patcompile(str, PAT_STATIC, 0))) {
+ queue_signals();
+ if (pattry(pprog, actual))
+ ret = 1;
+ unqueue_signals();
+ } else if (!strncmp(actual, teststr, len))
+ ret = 1;
+ return ret;
+}
+
/* check the List for login/logouts */
/**/
@@ -400,7 +421,7 @@ watchlog(int inout, WATCH_STRUCT_UTMP *u, char **w, char *fmt)
for (vv = v; *vv && *vv != '@' && *vv != '%'; vv++);
sav = *vv;
*vv = '\0';
- if (strncmp(u->ut_name, v, sizeof(u->ut_name)))
+ if (!watchlog_match(v, u->ut_name, sizeof(u->ut_name)))
bad = 1;
*vv = sav;
v = vv;
@@ -410,7 +431,7 @@ watchlog(int inout, WATCH_STRUCT_UTMP *u, char **w, char *fmt)
for (vv = ++v; *vv && *vv != '@'; vv++);
sav = *vv;
*vv = '\0';
- if (strncmp(u->ut_line, v, sizeof(u->ut_line)))
+ if (!watchlog_match(v, u->ut_line, sizeof(u->ut_line)))
bad = 1;
*vv = sav;
v = vv;
@@ -420,7 +441,7 @@ watchlog(int inout, WATCH_STRUCT_UTMP *u, char **w, char *fmt)
for (vv = ++v; *vv && *vv != '%'; vv++);
sav = *vv;
*vv = '\0';
- if (strncmp(u->ut_host, v, strlen(v)))
+ if (!watchlog_match(v, u->ut_host, strlen(v)))
bad = 1;
*vv = sav;
v = vv;