Hi,
What do you think about that ? -- Tobias Gerschner Yoper Linux - www.yoper.com Knowing is not enough; we must apply. Willing is not enough; we must do. ---------- Forwarded message ---------- From: Per Øyvind Karlsen <[EMAIL PROTECTED]> Date: 22.02.2008 09:44 Subject: [PATCH]: logging of package install/remove to syslog To: [EMAIL PROTECTED] Here's an improved and more upstream friendly version of syslog patch from Mandriva which adds logging of install/remove of packages to syslog. It will be disabled by default, but can be activated by %_log_to_syslog macro. Any objections of commiting or ideas of improvement? -- Regards, Per Øyvind Karlsen Mandriva Norway
--- system.h.syslog 2008-02-07 21:18:54.000000000 +0100 +++ system.h 2008-02-21 16:19:10.339599193 +0100 @@ -9,6 +9,10 @@ #include "config.h" #endif +#ifdef HAVE_SYSLOG_H +#include <syslog.h> +#endif + #include <sys/types.h> #if defined(HAVE_STDINT_H) #include <stdint.h> --- config.h.in~ 2008-02-01 01:48:46.000000000 +0100 +++ config.h.in 2008-02-21 17:29:17.036456904 +0100 @@ -446,6 +446,9 @@ /* Define to 1 if you have the <string.h> header file. */ #undef HAVE_STRING_H +/* Define to 1 if you have the <syslog.h> header file. */ +#undef HAVE_SYSLOG_H + /* Define to 1 if you have the `strndup' function. */ #undef HAVE_STRNDUP --- configure.ac~ 2008-02-01 01:40:15.000000000 +0100 +++ configure.ac 2008-02-21 17:30:39.659798279 +0100 @@ -537,7 +537,7 @@ AC_CHECK_HEADERS([dnl sys/param.h sys/mount.h sys/mntctl.h sys/vmount.h dnl libio.h err.h mcheck.h limits.h libgen.h float.h dnl glob.h poll.h netinet/in.h arpa/inet.h stdint.h inttypes.h dnl - langinfo.h dnl + langinfo.h syslog.h dnl ]) dnl # GNU gettext support --- macros.in~ 2008-02-07 06:31:48.000000000 +0100 +++ macros.in 2008-02-21 17:54:59.113746456 +0100 @@ -900,6 +900,9 @@ print (t)\ # Set this to non-zero at your own risk, it's dangerous. %_rollback_transaction_on_failure 0 +# Log install/remove of packages to syslog. +%_use_syslog 0 + # Verify digest/signature flags for various rpm modes: # 0x30300 (_RPMVSF_NODIGESTS) --nohdrchk if set, don't check digest(s) # 0xc0c00 (_RPMVSF_NOSIGNATURES) --nosignature if set, don't check signature(s) --- lib/psm.c.syslog 2008-02-01 01:40:16.000000000 +0100 +++ lib/psm.c 2008-02-21 21:29:32.181686473 +0100 @@ -1656,6 +1656,11 @@ rpmRC rpmpsmStage(rpmpsm psm, pkgStage s int saveerrno; int xx; +#ifdef HAVE_SYSLOG_H + /* XXX log install and removal of packages in syslog */ + int use_syslog = rpmExpandNumeric("%{?_log_to_syslog:1}%{?!_log_to_syslog:0}"); +#endif + /* XXX hackery to assert(!scaremem) in rpmfiNew. */ if (fi->h == NULL && fi->te && fi->te->h != NULL) fi->h = headerLink(fi->te->h); #if 0 @@ -2453,6 +2458,16 @@ assert(psm->mi == NULL); else rc = rpmdbAdd(rpmtsGetRdb(ts), tid, fi->h, NULL); (void) rpmswExit(rpmtsOp(ts, RPMTS_OP_DBADD), 0); +#ifdef HAVE_SYSLOG_H + if(use_syslog) { + char *s; + + s = headerSprintf(fi->h, "%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}", + rpmTagTable, rpmHeaderFormats, NULL); + syslog(LOG_NOTICE, "[RPM] %s installed\n", s); + s = _free(s); + } +#endif } if (rc != RPMRC_OK) break; @@ -2473,6 +2488,16 @@ assert(psm->te != NULL); (void) rpmswEnter(rpmtsOp(ts, RPMTS_OP_DBREMOVE), 0); rc = rpmdbRemove(rpmtsGetRdb(ts), rpmtsGetTid(ts), fi->record, NULL); (void) rpmswExit(rpmtsOp(ts, RPMTS_OP_DBREMOVE), 0); +#ifdef HAVE_SYSLOG_H + if(use_syslog) { + char *s; + + s = headerSprintf(fi->h, "%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}", + rpmTagTable, rpmHeaderFormats, NULL); + syslog(LOG_NOTICE, "[RPM] %s removed\n", s); + s = _free(s); + } +#endif if (rc != RPMRC_OK) break;
_______________________________________________ yoper-dev mailing list yoper-dev@lists.yoper.com http://lists.frank-hosting.de/cgi-bin/mailman/listinfo/yoper-dev