/*
* Copyright (c) 2001 Proofpoint, Inc. and its suppliers.
* 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.
*
*/
/*
** This program checks to see if your version of setgid works.
** Compile it, make it set-group-ID guest, and run it as yourself (NOT as
** root and not as member of the group guest).
**
** Compilation is trivial -- just "cc t_dropgid.c". Make it set-group-ID
** guest and then execute it as a non-root user.
*/
#include <unistd.h>
#include <stdio.h>
#ifndef lint
#endif /* ! lint */
static void
char *str;
gid_t r, e;
{
}
/* define only one of these */
#if HASSETEGID
#endif /* HASSETEGID */
#if HASSETREGID
#endif /* HASSETREGID */
#if HASSETRESGID
#endif /* HASSETRESGID */
#ifndef SETGIDCALL
#endif /* ! SETGIDCALL */
int
int argc;
char **argv;
{
int fail = 0;
int res;
{
printf("SETUP ERROR: re-run set-group-ID guest\n");
printf("Use chgrp(1) and chmod(1)\n");
printf("For example, do this as root ");
printf("(nobody is the name of a group in this example):\n");
exit(1);
}
#if HASSETREGID
#endif /* HASSETREGID */
#if HASSETRESGID
#endif /* HASSETRESGID */
#if HASSETEGID
#endif /* HASSETEGID */
{
fail++;
printf("MAYDAY! Wrong effective gid\n");
}
{
fail++;
printf("MAYDAY! Wrong real gid\n");
}
/* do activity here */
{
fail++;
printf("MAYDAY! setgid(%d) succeeded (should have failed)\n",
effgid);
}
else
{
}
{
fail++;
printf("MAYDAY! Wrong effective gid\n");
}
{
fail++;
printf("MAYDAY! Wrong real gid\n");
}
printf("\n");
if (fail > 0)
{
printf("\nThis system cannot use %s to give up set-group-ID rights\n",
#if !HASSETEGID
printf("Maybe compile with -DHASSETEGID and try again\n");
#endif /* !HASSETEGID */
#if !HASSETREGID
printf("Maybe compile with -DHASSETREGID and try again\n");
#endif /* !HASSETREGID */
#if !HASSETRESGID
printf("Maybe compile with -DHASSETRESGID and try again\n");
#endif /* !HASSETRESGID */
exit(1);
}
exit(0);
}