do not use buffered file IO
ClosedPublic

Authored by dakon on May 24 2018, 6:05 PM.

Details

Summary

This is not necessary here. Additionally we can use O_CLOEXEC to make sure the file descriptors are not leaked by accident.

Diff Detail

Repository
R107 KWallet PAM Integration
Lint
Lint Skipped
Unit
Unit Tests Skipped
dakon created this revision.May 24 2018, 6:05 PM
Restricted Application added a project: Plasma. · View Herald TranscriptMay 24 2018, 6:05 PM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
dakon requested review of this revision.May 24 2018, 6:05 PM

have you tried this? because i have just tried it and it failed.

Aren't you missing a O_CREAT ?

aacid requested changes to this revision.Oct 8 2018, 8:56 PM
This revision now requires changes to proceed.Oct 8 2018, 8:56 PM
dakon updated this revision to Diff 43538.Oct 13 2018, 12:20 PM

O_CREAT was missing, as well as the file mode. O_CLOEXEC is available for a long time, there should be no need for the compat define.

aacid accepted this revision.Oct 25 2018, 10:30 PM

Please make me const-happy before commiting :)

pam_kwallet.c
696

const

704

const

755

const

764

const

This revision is now accepted and ready to land.Oct 25 2018, 10:30 PM
dakon added inline comments.Oct 27 2018, 5:13 PM
pam_kwallet.c
696

While this is "just an int", my personal taste is very much against using const on a file descriptor as this is not how this really works. I don't know.

704

ACK

aacid added inline comments.Oct 28 2018, 10:27 AM
pam_kwallet.c
696

It is how it really works. Think of as a handle value, you're promising not to assign that handle value to point somewhere else, not that you won't change the value it points to.

Why i want this const? Because when you see that you can be sure that the rest of the file there's no other fd = open() or similar, and thus you're sure that the rest of the operations in this function that use fd are over "path".

This revision was automatically updated to reflect the committed changes.