Page MenuHomeFreeBSD

setusercontext(): umask: Set it only once (in the common case)
ClosedPublic

Authored by olce on May 31 2023, 2:30 PM.
Tags
None
Referenced Files
F102426800: D40344.diff
Tue, Nov 12, 3:07 AM
Unknown Object (File)
Thu, Nov 7, 11:31 PM
Unknown Object (File)
Tue, Nov 5, 9:04 PM
Unknown Object (File)
Tue, Nov 5, 10:18 AM
Unknown Object (File)
Tue, Nov 5, 10:18 AM
Unknown Object (File)
Thu, Oct 17, 5:20 AM
Unknown Object (File)
Wed, Oct 16, 12:01 PM
Unknown Object (File)
Wed, Oct 16, 10:08 AM

Details

Summary

Simplify the code and make it more coherent (umask was the only context
setting not modified by setlogincontext() directly).

Preserve the current behavior of not changing the umask if none is
specified in the login class capabilities database, but without the
superfluous umask() dance. (The only exception to this is that
a special value no user is likely to input in the database now stands
for no specification.)

If some user has a 'umask' override in its '~/.login_conf', the umask
will still be set twice as before (as is the case for all other context
settings overriden in '~/.login_conf').

Log a warning in case of an invalid umask specification.

This change makes it apparent that the value of LOGIN_DEFUMASK doesn't
matter. It will be removed in a subsequent commit.

PR: 271747

Test Plan

Local test.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 51796
Build 48687: arc lint + arc unit

Event Timeline

olce requested review of this revision.May 31 2023, 2:30 PM
lib/libutil/login_cap.h
36

This is the public macro, are you sure that removing it has no consequences for third-party sources?

lib/libutil/login_class.c
410

The indent looks wrong, it should be +4 spaces from the previous line.

olce marked an inline comment as done.Jun 9 2023, 2:01 PM
olce added inline comments.
lib/libutil/login_cap.h
36

GitHub code search and Google show no use of this symbol (the only results are from copies of the login_cap.h).

lib/libutil/login_class.c
410

Right. Fixing this.

olce marked an inline comment as done.
olce edited the summary of this revision. (Show Details)

Fix indent. Note in the commit message that there are a priori no out-of-tree
consumer for the removed symbol.

olce marked an inline comment as done.Jun 9 2023, 2:31 PM

Fix more style(9) problems.

lib/libutil/login_cap.h
36

You can request an exp-run for this patch to be certain it won't affect anything in the ports tree if necessary, but I suspect GitHub + Google results are sufficient to claim it is not an issue.

lib/libutil/login_class.c
400–403

Hrm, login_getcapnum has a somewhat unfortunate interface.

408

Perhaps adding || val == err_val does not change the generated code and does not generate a warning? That might be more clear than the comment.

lib/libutil/login_class.c
418

Suggest { } around the first block, even though it is only one statement it is wrapped over many lines.

(Even if not wrapped over many lines I think it's preferable to use braces on all blocks of an if-else if any do.)

if (x) {
        one_statement();
} else {
        a_lot();
        of_stuff();
        over_here();
}
olce marked 3 inline comments as done.Jan 23 2024, 9:31 PM
olce added inline comments.
lib/libutil/login_class.c
400–403

Yes... Ideally, the libutil interfaces should be revised, but this public interface has been there for so long that it also means reviewing and changing all the applications using it. Not sure how big of a job this is. Just wanted to avoid it as much as possible for this series.

408

Adding it doesn't change the produced assembly. That said, I find this test strange since it is redundant, which presses me to add a comment about that... So, since in both cases I'm putting a comment, I think I still prefer to forget about the redundant construct.

olce marked 2 inline comments as done.
olce edited the summary of this revision. (Show Details)

Add braces around a split statement. Update the commit message.

olce marked an inline comment as done.Jan 23 2024, 9:32 PM
lib/libutil/login_cap.h
36

I did. Please see PR 276570.

That said, if the exp-run doesn't pass because of this interface change, I'll just restore the suppressed #define, this is not per-se a blocker situation for this dev.

olce edited the summary of this revision. (Show Details)

Delay removing LOGIN_DEFUMASK in another commit (not to be MFCed now).

This revision is now accepted and ready to land.Jan 26 2024, 2:20 PM