+ /* run script */
+ if (obj->fce_notify_script) {
+ static bstring quote = NULL;
+ static bstring quoterep = NULL;
+ static bstring slash = NULL;
+ static bstring slashrep = NULL;
+
+ if (!quote) {
+ quote = bfromcstr("'");
+ quoterep = bfromcstr("'\\''");
+ slash = bfromcstr("\\");
+ slashrep = bfromcstr("\\\\");
+ }
+
+ bstring cmd = bformat("%s -v %d -e %s -i %" PRIu32 "",
+ obj->fce_notify_script,
+ FCE_PACKET_VERSION,
+ fce_event_names[event],
+ event_id);
+
+ if (path[0]) {
+ bstring bpath = bfromcstr(path);
+ bfindreplace(bpath, slash, slashrep, 0);
+ bfindreplace(bpath, quote, quoterep, 0);
+ bformata(cmd, " -P '%s'", bdata(bpath));
+ bdestroy(bpath);
+ }
+ if (fce_ev_info | FCE_EV_INFO_PID)
+ bformata(cmd, " -p %" PRIu64 "", (uint64_t)getpid());
+ if (fce_ev_info | FCE_EV_INFO_USER)
+ bformata(cmd, " -u %s", user);
+ if (oldpath) {
+ bstring boldpath = bfromcstr(oldpath);
+ bfindreplace(boldpath, slash, slashrep, 0);
+ bfindreplace(boldpath, quote, quoterep, 0);
+ bformata(cmd, " -S '%s'", bdata(boldpath));
+ bdestroy(boldpath);
+ }
+ (void)afprun_bg(1, bdata(cmd));
+ bdestroy(cmd);
+ }