Skip to content

Commit

Permalink
Fix issue with inserting char "n" instead \n
Browse files Browse the repository at this point in the history
Without this fix I got next content in sudo file:
```
# sudo: auth account password sessionnnauth       sufficient     pam_tid.so
auth       sufficient     pam_smartcard.so
auth       required       pam_opendirectory.so
account    required       pam_permit.so
password   required       pam_deny.so
session    required       pam_permit.so
```

fix based on advice  https://stackoverflow.com/a/7567839/1149273
  • Loading branch information
berejant committed Jan 9, 2022
1 parent d076134 commit 218cb9e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion sudo-touchid.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ backup_ext='.bak'

touch_pam='auth sufficient pam_tid.so'
sudo_path='/etc/pam.d/sudo'
nl=$'\n'

# Source: https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh
getc() {
Expand Down Expand Up @@ -41,7 +42,7 @@ touch_pam_at_sudo_path_check_exists() {
}

touch_pam_at_sudo_path_insert() {
sudo sed -E -i "$backup_ext" "1s/^(#.*)$/\1\n$touch_pam/" "$sudo_path"
sudo sed -E -i "$backup_ext" "1s/^(#.*)$/\1\\${nl}$touch_pam/" "$sudo_path"
}

touch_pam_at_sudo_path_remove() {
Expand Down

0 comments on commit 218cb9e

Please sign in to comment.