aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGilles Chehade <gilles@poolp.org>2019-12-01 08:49:30 +0100
committerGitHub <noreply@github.com>2019-12-01 08:49:30 +0100
commit904340f95d2c2335be3f45f50de22e4704be2aae (patch)
treeedd82b738e909eda808f5b2e621286ee962166b1
parentsmtpctl: check correct egid at startup (diff)
downloadOpenSMTPD-904340f95d2c2335be3f45f50de22e4704be2aae.tar.xz
OpenSMTPD-904340f95d2c2335be3f45f50de22e4704be2aae.zip
Update smtpctl.c
do not make this check Linux related in the comment, get rid of temp egid variable used only for a single test, fix style
-rw-r--r--smtpd/smtpctl.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/smtpd/smtpctl.c b/smtpd/smtpctl.c
index 49d4a482..2c9deff0 100644
--- a/smtpd/smtpctl.c
+++ b/smtpd/smtpctl.c
@@ -1061,7 +1061,7 @@ do_spf_walk(int argc, struct parameter *argv)
int
main(int argc, char **argv)
{
- gid_t egid, gid;
+ gid_t gid;
struct group *gr;
int privileged;
char *argv_mailq[] = { "show", "queue", NULL };
@@ -1070,14 +1070,11 @@ main(int argc, char **argv)
__progname = ssh_get_progname(argv[0]);
#endif
- /* Sanity check that too many Linux distros fail */
- egid = getegid();
- gr = getgrnam(SMTPD_QUEUE_GROUP);
- if (gr == NULL)
- warnx("installation problem: unknown group %s", SMTPD_QUEUE_GROUP);
- if (gr != NULL && gr->gr_gid != egid)
- warnx("installation problem: this program must be setgid %s",
- SMTPD_QUEUE_GROUP);
+ /* check that smtpctl was installed setgid */
+ if ((gr = getgrnam(SMTPD_QUEUE_GROUP)) == NULL)
+ warnx("unknown group %s", SMTPD_QUEUE_GROUP);
+ else if (gr->gr_gid != getegid())
+ warnx("this program must be setgid %s", SMTPD_QUEUE_GROUP);
sendmail_compat(argc, argv);
privileged = geteuid() == 0;