On Tue, 15 Apr 2008 01:24:23 -0700 Mick Johnson <[EMAIL PROTECTED]> wrote:
MJ> Thanks for both your patches - I'll be looking to do a wrap-up release this MJ> week with those and a couple of other minor fixes. Hi Mick, Thanks for your reply and, encouraged by it :-), here is a patch to another tool, dspam_dump, similar to dspam_stats one: it also allows it to be used by normal users and corrects the man page to document the syntax really understood by the program. Thanks, VZ diff -r b2246e7d9208 man/dspam_dump.1 --- a/man/dspam_dump.1 Tue Apr 15 04:16:53 2008 +0200 +++ b/man/dspam_dump.1 Tue Apr 15 16:15:09 2008 +0200 @@ -16,9 +16,7 @@ dspam_dump - produce a dump of a user's .SH SYNOPSIS .na .B dspam_dump -[\c -.BI \ username \fR -] +.BI username \fR [\c .BI \ token \fR ] @@ -38,14 +36,15 @@ probability. .ne 3 .TP .BI \ username \fR\c -The username of the user to dump +The username of the user to dump. Only trusted users (or root) can use this +program for the usernames different from the current one. .n3 .TP .BI \ token \fR\c +.br The text string of the token to search for and dump. If no token is specified, -.B all tokens -will be dumped to stdout. +all tokens will be dumped to stdout. .SH EXAMPLES .B dspam_dump user "Subject*Viagra" diff -r b2246e7d9208 src/tools/dspam_dump.c --- a/src/tools/dspam_dump.c Tue Apr 15 04:16:53 2008 +0200 +++ b/src/tools/dspam_dump.c Tue Apr 15 16:15:09 2008 +0200 @@ -51,6 +51,11 @@ #include "config_api.h" #include "language.h" +#ifdef _WIN32 +/* no trusted users under Windows */ +#undef TRUSTED_USER_SECURITY +#endif + DSPAM_CTX *open_ctx; /* headers */ @@ -58,7 +63,7 @@ void dieout (int signal); void dieout (int signal); #define TSYNTAX \ - "syntax: dspam_dump [--profile=Profile] [-d sqlite_drv] [username [token]]" + "syntax: dspam_dump [--profile=Profile] [-d sqlite_drv] username [token]" #define SQL_SQLITE_DRV 1 @@ -68,10 +73,8 @@ main (int argc, char **argv) DSPAM_CTX *CTX; int r, sql = 0, i; char *username = NULL, *token = NULL; -#ifndef _WIN32 #ifdef TRUSTED_USER_SECURITY struct passwd *p = getpwuid (getuid ()); -#endif #endif /* Read dspam.conf */ @@ -88,15 +91,6 @@ main (int argc, char **argv) } libdspam_init(_ds_read_attribute(agent_config, "StorageDriver")); - -#ifndef WIN32 -#ifdef TRUSTED_USER_SECURITY - if (!_ds_match_attribute(agent_config, "Trust", p->pw_name) && p->pw_uid) { - fprintf(stderr, ERR_TRUSTED_MODE "\n"); - goto BAIL; - } -#endif -#endif open_ctx = NULL; signal (SIGINT, dieout); @@ -131,8 +125,17 @@ main (int argc, char **argv) goto BAIL; } } else { - if (username == NULL) + if (username == NULL) { username = argv[i]; +#ifdef TRUSTED_USER_SECURITY + if ( strcmp(username, p->pw_name) && + !_ds_match_attribute(agent_config, "Trust", p->pw_name) && + p->pw_uid) { + fprintf(stderr, ERR_TRUSTED_MODE "\n"); + goto BAIL; + } +#endif + } else token = argv[i]; }