[Bug 280418] calendar -a trashes parent's pgrp login setting

From: <bugzilla-noreply_at_freebsd.org>
Date: Tue, 23 Jul 2024 18:10:21 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=280418

            Bug ID: 280418
           Summary: calendar -a trashes parent's pgrp login setting
           Product: Base System
           Version: 14.1-RELEASE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: bin
          Assignee: bugs@FreeBSD.org
          Reporter: steve@Watt.COM

Created attachment 252245
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=252245&action=edit
Patch for src/usr.bin/calendar/calendar.c to add the missing setsid()

The presenting symptom is that the daily and security emails from cron/periodic
were arriving with the envelope-sender set to some completely random user.

After much one-experiment-per-day debugging, I isolated it down to 300.calendar
changing the login userid. It seems to be missing its setsid() before calling
setusercontext().

Easy-to-demonstrate sample:
> (root@rivendell) 43# sh
> # id -p
> uid     root
> groups  users wheel www vboxusers
> # calendar -a
> # id -p
> login   _tss
> uid     root
> groups  users wheel www vboxusers
> # exit
> (root@rivendell) 44# id -p
> login   _tss
> uid     root
> (root@rivendell) 45#

The fix is startlingly simple, with a little help on -questions from Kyle
Evans, see attached.

-- 
You are receiving this mail because:
You are the assignee for the bug.