Page MenuHomeFreeBSD

login: add a check for a post-condition when exporting the environment
ClosedPublic

Authored by pfg on Oct 27 2020, 4:29 AM.
Tags
None
Referenced Files
Unknown Object (File)
Jan 28 2024, 12:01 AM
Unknown Object (File)
Dec 20 2023, 4:21 AM
Unknown Object (File)
Dec 15 2023, 7:51 PM
Unknown Object (File)
Nov 26 2023, 12:03 AM
Unknown Object (File)
Sep 26 2023, 4:45 AM
Unknown Object (File)
Sep 12 2023, 2:45 AM
Unknown Object (File)
Sep 3 2023, 8:15 AM
Unknown Object (File)
Jul 25 2023, 10:36 PM
Subscribers

Details

Summary

FreeBSD's login code is used as an example case in the "Principles of Secure
Coding" coursera course. While FreeBSD correctly checks for wrong
preconditions it could also check for the setenv post-conditon.

It is clear that setenv(3) will not fail, however it wouldn't hurt to make sure
the return value matches our expectacions.

Credit for this change is due to Matthew Bishop, PhD

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

pfg requested review of this revision.Oct 27 2020, 4:30 AM
pfg retitled this revision from login: add a check for a precondition when exporting the environment to login: add a check for a post-condition when exporting the environment.Dec 19 2020, 2:01 AM
This revision was not accepted when it landed; it landed in state Needs Review.Dec 19 2020, 2:24 AM
This revision was automatically updated to reflect the committed changes.

Looks like export is only ever used in export_pam_environment(), where its return value is ignored.

Looks like export is only ever used in export_pam_environment(), where its return value is ignored.

Yes, I see :-/
So the change is useless, as are the checks for the pre-conditions.

It was really nice to see FreeBSD mentioned in a software security course though.

head/usr.bin/login/login.c
810

This is actually -1 : 1 is vener returned by setenv(3).

In D26966#618727, @pfg wrote:

Looks like export is only ever used in export_pam_environment(), where its return value is ignored.

Yes, I see :-/
So the change is useless, as are the checks for the pre-conditions.

It was really nice to see FreeBSD mentioned in a software security course though.

Preconditions are actually useful in that we do NOT set LD_* or other forbidden variables.