From: millert Date: Mon, 3 Apr 2000 02:52:11 +0000 (+0000) Subject: Add missing 'praliases user1 user2 ...' functionality from sendmail-8.10.1.Beta1 X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=5f8e85a90e0c537470dba23780d996b42cec1034;p=openbsd Add missing 'praliases user1 user2 ...' functionality from sendmail-8.10.1.Beta1 --- diff --git a/gnu/usr.sbin/sendmail/praliases/praliases.1 b/gnu/usr.sbin/sendmail/praliases/praliases.1 index 561a362e040..71bb33bedf1 100644 --- a/gnu/usr.sbin/sendmail/praliases/praliases.1 +++ b/gnu/usr.sbin/sendmail/praliases/praliases.1 @@ -1,4 +1,4 @@ -.\" Copyright (c) 1998, 1999 Sendmail, Inc. and its suppliers. +.\" Copyright (c) 1998-2000 Sendmail, Inc. and its suppliers. .\" All rights reserved. .\" .\" By using this file, you agree to the terms and conditions set @@ -6,7 +6,7 @@ .\" the sendmail distribution. .\" .\" -.\" $Sendmail: praliases.8,v 8.12 1999/09/01 22:15:16 gshapiro Exp $ +.\" $Sendmail: praliases.8,v 8.14 2000/03/17 07:32:46 gshapiro Exp $ .\" .TH PRALIASES 1 "April 25, 1996" .SH NAME @@ -18,6 +18,9 @@ .IR file ] .RB [ \-f .IR file ] +.RB [\c +.IR key +.IR ... ] .SH DESCRIPTION The .B praliases @@ -37,6 +40,9 @@ Read the specified file instead of the configured .B sendmail system aliases file(s). .PP +If one or more keys are specified on the command line, +only entries which match those keys are displayed. +.PP The .B praliases utility exits 0 on success, and >0 if an error occurs. diff --git a/gnu/usr.sbin/sendmail/praliases/praliases.c b/gnu/usr.sbin/sendmail/praliases/praliases.c index 9137ec512d0..e559fab9bc9 100644 --- a/gnu/usr.sbin/sendmail/praliases/praliases.c +++ b/gnu/usr.sbin/sendmail/praliases/praliases.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 1999 Sendmail, Inc. and its suppliers. + * Copyright (c) 1998-2000 Sendmail, Inc. and its suppliers. * All rights reserved. * Copyright (c) 1983 Eric P. Allman. All rights reserved. * Copyright (c) 1988, 1993 @@ -13,7 +13,7 @@ #ifndef lint static char copyright[] = -"@(#) Copyright (c) 1998, 1999 Sendmail, Inc. and its suppliers.\n\ +"@(#) Copyright (c) 1998-2000 Sendmail, Inc. and its suppliers.\n\ All rights reserved.\n\ Copyright (c) 1983 Eric P. Allman. All rights reserved.\n\ Copyright (c) 1988, 1993\n\ @@ -21,7 +21,7 @@ static char copyright[] = #endif /* ! lint */ #ifndef lint -static char id[] = "@(#)$Sendmail: praliases.c,v 8.57 1999/10/13 03:35:16 ca Exp $"; +static char id[] = "@(#)$Sendmail: praliases.c,v 8.59 2000/03/17 07:32:47 gshapiro Exp $"; #endif /* ! lint */ #include @@ -291,43 +291,66 @@ praliases(filename, argc, argv) goto fatal; } - memset(&db_key, '\0', sizeof db_key); - memset(&db_value, '\0', sizeof db_value); - - result = database->smdb_cursor(database, &cursor, 0); - if (result != SMDBE_OK) + if (argc == 0) { - fprintf(stderr, "praliases: %s: set cursor: %s\n", - db_name, errstring(result)); - goto fatal; - } + memset(&db_key, '\0', sizeof db_key); + memset(&db_value, '\0', sizeof db_value); - while ((result = cursor->smdbc_get(cursor, &db_key, &db_value, - SMDB_CURSOR_GET_NEXT)) == SMDBE_OK) - { + result = database->smdb_cursor(database, &cursor, 0); + if (result != SMDBE_OK) + { + fprintf(stderr, "praliases: %s: set cursor: %s\n", + db_name, errstring(result)); + goto fatal; + } + + while ((result = cursor->smdbc_get(cursor, &db_key, &db_value, + SMDB_CURSOR_GET_NEXT)) == + SMDBE_OK) + { #if 0 - /* skip magic @:@ entry */ - if (db_key.data.size == 2 && - db_key.data.data[0] == '@' && - db_key.data.data[1] == '\0' && - db_value.data.size == 2 && - db_value.data.data[0] == '@' && - db_value.data.data[1] == '\0') - continue; + /* skip magic @:@ entry */ + if (db_key.data.size == 2 && + db_key.data.data[0] == '@' && + db_key.data.data[1] == '\0' && + db_value.data.size == 2 && + db_value.data.data[0] == '@' && + db_value.data.data[1] == '\0') + continue; #endif /* 0 */ - printf("%.*s:%.*s\n", - (int) db_key.data.size, - (char *) db_key.data.data, - (int) db_value.data.size, - (char *) db_value.data.data); - } + printf("%.*s:%.*s\n", + (int) db_key.data.size, + (char *) db_key.data.data, + (int) db_value.data.size, + (char *) db_value.data.data); + } - if (result != SMDBE_OK && result != SMDBE_LAST_ENTRY) + if (result != SMDBE_OK && result != SMDBE_LAST_ENTRY) + { + fprintf(stderr, + "praliases: %s: get value at cursor: %s\n", + db_name, errstring(result)); + goto fatal; + } + } + else for (; *argv != NULL; ++argv) { - fprintf(stderr, "praliases: %s: get value at cursor: %s\n", - db_name, errstring(result)); - goto fatal; + memset(&db_key, '\0', sizeof db_key); + memset(&db_value, '\0', sizeof db_value); + db_key.data.data = *argv; + db_key.data.size = strlen(*argv) + 1; + if (database->smdb_get(database, &db_key, + &db_value, 0) == SMDBE_OK) + { + printf("%.*s:%.*s\n", + (int) db_key.data.size, + (char *) db_key.data.data, + (int) db_value.data.size, + (char *) db_value.data.data); + } + else + printf("%s: No such key\n", (char *) db_key.data.data); } fatal: