/*
* Copyright (c) 1998-2002, 2004 Proofpoint, Inc. and its suppliers.
* All rights reserved.
* Copyright (c) 1992 Eric P. Allman. All rights reserved.
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* By using this file, you agree to the terms and conditions set
* forth in the LICENSE file which can be found at the top level of
* the sendmail distribution.
*
*/
#ifndef lint
"@(#) Copyright (c) 1998-2001 Proofpoint, Inc. and its suppliers.\n\
All rights reserved.\n\
Copyright (c) 1992 Eric P. Allman. All rights reserved.\n\
Copyright (c) 1992, 1993\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* ! lint */
#ifndef lint
#endif /* ! lint */
#ifndef ISC_UNIX
#endif /* ! ISC_UNIX */
#include <ctype.h>
#include <stdlib.h>
#include <unistd.h>
#ifdef EX_OK
#endif /* EX_OK */
#include <sysexits.h>
#include <assert.h>
#include <sendmail/sendmail.h>
#include <sendmail/pathnames.h>
char *RealUserName;
char *RunAsUserName;
bool DontInitGroups = false;
static void
char *progname;
{
"Usage: %s [-C cffile] [-N] [-f] [-q|-u|-x] maptype mapname key [ \"value ...\" ]\n",
progname);
}
int
int argc;
char **argv;
{
char *progname;
char *cfile;
bool verbose = false;
bool query = false;
bool update = false;
bool remove = false;
bool inclnull = false;
bool foldcase = true;
unsigned int nops = 0;
int exitstat;
int opt;
int mode;
int smode;
int putflags = 0;
#if HASFCHOWN
#endif /* HASFCHOWN */
extern char *optarg;
extern int optind;
progname++;
else
else
"Unknown UID %d", (int) RealUid);
{
switch (opt)
{
case 'C':
break;
case 'f':
foldcase = false;
break;
case 'q':
query = true;
nops++;
break;
case 'u':
update = true;
nops++;
break;
case 'x':
remove = true;
nops++;
break;
case 'v':
verbose = true;
break;
case 'N':
inclnull = true;
break;
default:
assert(0); /* NOTREACHED */
}
}
sff |= SFF_NOSLINK;
sff |= SFF_NOHLINK;
sff |= SFF_NOWLINK;
if ((nops != 1) ||
{
assert(0); /* NOTREACHED */
}
if (update)
if (foldcase)
{
char *p;
for (p = keyname; *p != '\0'; p++)
{
*p = tolower(*p);
}
}
#if HASFCHOWN
/* Find TrustedUser value in sendmail.cf */
{
}
{
register char *b;
*b = '\0';
b = buf;
switch (*b++)
{
case 'O': /* option */
{
b = strchr(b, '=');
if (b == NULL)
continue;
continue;
TrustedUid = atoi(b);
else
{
TrustedUid = 0;
"TrustedUser: unknown user %s\n", b);
else
}
# ifdef UID_MAX
if (TrustedUid > UID_MAX)
{
"TrustedUser: uid value (%ld) > UID_MAX (%ld)",
(long) TrustedUid,
(long) UID_MAX);
TrustedUid = 0;
}
# endif /* UID_MAX */
break;
}
default:
continue;
}
}
#endif /* HASFCHOWN */
if (query)
{
}
else
{
}
{
char *hint;
if (errno == SMDBE_UNSUPPORTED_DB_TYPE &&
"%s: Need to recompile with -D%s for %s support\n",
else
"%s: error opening type %s map %s: %s\n",
}
if (geteuid() == 0 && TrustedUid != 0)
{
{
"WARNING: ownership change on %s failed %s",
}
}
if (query)
{
if (inclnull)
{
/* XXX - Need to distinguish between not found */
"%s: couldn't find key %s in map %s\n",
}
else
{
}
}
else if (update)
{
if (inclnull)
if (inclnull)
putflags);
{
"%s: error updating (%s, %s) in map %s: %s\n",
}
}
else if (remove)
{
if (inclnull)
switch (errno)
{
case SMDBE_NOT_FOUND:
"%s: key %s doesn't exist in map %s\n",
/* Don't set exitstat */
break;
case SMDBE_OK:
/* All's well */
break;
default:
"%s: couldn't remove key %s in map %s (error)\n",
break;
}
}
else
{
assert(0); /* NOT REACHED */
}
/*
** Now close the database.
*/
{
}
/* NOTREACHED */
return exitstat;
}