6

I'm using laptop. And I want to take a photo when an incorrect password is entered or "wrong fingerprint scanned". I just found a question/answer about first part (Can I make the webcam take a picture when an incorrect password is entered?)

But there is no information about fingerprint. I made these steps but nothing works. I think this is about my fingerprint usage.

Here is my default "etc/pam.d/common-auth":

auth    [success=3 default=ignore]  pam_fprintd.so max_tries=1 timeout=10 # debug
auth    [success=2 default=ignore]  pam_unix.so nullok try_first_pass
auth    [success=1 default=ignore]  pam_sss.so use_first_pass
# here's the fallback if no module succeeds
auth    requisite           pam_deny.so
# prime the stack with a positive return value if there isn't one already;
# this avoids us returning an error just because nothing sets a success code
# since the modules above will each just jump around
auth    required            pam_permit.so
# and here are more per-package modules (the "Additional" block)
auth    optional            pam_cap.so 
# end of pam-auth-update config

How can I tidy this script like that way: If there are wrong password "or" wrong scanned fingerprint, will take photo? thanks in advance (sorry for bad English, it is not my native language)

asandikci
  • 71
  • 7
  • This is an interesting idea. I hope somebody can offer an answer – matigo Apr 12 '22 at 11:03
  • 1
    The PAM instructions in that post should still work with suitable adjustment - for each method for which you want to take pics on failure, put the `pam_exec` line after it. Accordingly bump up the `success` values so that enough lines are skipped to reach the `pam_deny.so`. Haven't you been able to get it working even for just one case, say `pam_sss.so`, which should be easiest to get working since it has the same `success` value as `pam_unix` in the other post? – muru Apr 12 '22 at 11:12
  • @muru I'm not sure where is my mistake. I've tried a lot of times. either 'pam_sss.so' or 'pam_unix.so' etc. The result was 'Sorry, try again' despite I was scanning my true finger. Although the session was unsuccessful there was no picture of me in 'tmp'. Then I gave up on using it with a fingerprint and tried it with a normal password. Didn't work... Now there are a problem like '/usr/local/bin/script failed: exit code 8'. I don't know where is my mistake. ( I tried these operations in the terminal with 'sudo a_random_command') Can you please leave a resource about Pam documentation? – asandikci Apr 13 '22 at 13:07

1 Answers1

1

Pam was always causing trouble, then I decided to apply the second answer in this post (Can I make the webcam take a picture when an incorrect password is entered?) This solved my problem with only a normal password login, but the fingerprint wrong login action still not working.

my TakePicture.sh Code: (Edited, Now Code Takes 3 Picture 0.5 second apart)

#!/bin/bash

while inotifywait -q -e modify /var/log/auth.log >/dev/null

do

        if (( $(tail -1 /var/log/auth.log | grep failure | wc -l) == 1))

        then

                echo "failed login"

                date_=`date  +%x`
                time_=`date  +%X`
                ffmpeg -f video4linux2 -s vga -i /dev/video0 -vframes 1 /tmp/WAR-$date_-$time_-1.jpg
                sleep 0.5
                time_=`date  +%X`
                ffmpeg -f video4linux2 -s vga -i /dev/video0 -vframes 1 /tmp/WAR-$date_-$time_-2.jpg
                sleep 0.5
                time_=`date  +%X`
                ffmpeg -f video4linux2 -s vga -i /dev/video0 -vframes 1 /tmp/WAR-$date_-$time_-3.jpg

        fi


done

my TakePicture.service code (in /etc/systemd/system/)

[Unit]
Description=Take Picture

[Service]
Type=Simple
ExecStart=/home/asandikci/TakePicture.sh

[Install]
WantedBy=multi-user.target
asandikci
  • 71
  • 7