Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nixos/wpa_supplicant: prefer 'install' over 'touch/chmod/mkdir/chgrp' #121395

Merged
merged 1 commit into from
May 10, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 2 additions & 11 deletions nixos/modules/services/networking/supplicant.nix
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,10 @@ let

preStart = ''
${optionalString (suppl.configFile.path!=null) ''
touch -a ${suppl.configFile.path}
chmod 600 ${suppl.configFile.path}
(umask 077 && touch -a "${suppl.configFile.path}")
''}
${optionalString suppl.userControlled.enable ''
if ! test -e ${suppl.userControlled.socketDir}; then
mkdir -m 0770 -p ${suppl.userControlled.socketDir}
chgrp ${suppl.userControlled.group} ${suppl.userControlled.socketDir}
fi

if test "$(stat --printf '%G' ${suppl.userControlled.socketDir})" != "${suppl.userControlled.group}"; then
echo "ERROR: bad ownership on ${suppl.userControlled.socketDir}" >&2
exit 1
fi
Comment on lines -56 to -59
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a downside to overwriting the group of an existin directory? Maybe we should keep this but put it before the install.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a downside to overwriting the group of an existin directory?

I don't know. I'm not really familiar with wpa_supplicant. I tested if ACLs are preserved with install, and they are.

My thinking:

Old code: configure dir once and fail if group ownership differs later.
New code: configure dir always. (The code will only fail if there is insufficient permissions to configure things.)

I don't see any benefit of the old code. The new one automates something the old code would require user action to solve.

install -dm770 -g "${suppl.userControlled.group}" "${suppl.userControlled.socketDir}"
''}
'';

Expand Down