| 1 | #!/bin/shscip-shell filesystem . . `/bin/sh`. |
| 2 | |
| 3 | # Why not use "openct-tool rwait" instead of polling opensc-tool exit status? |
| 4 | # Well openct daemon has to be running which interferes with pcscd since both |
| 5 | # implement reader drivers, my particular CCID reader (SCM SCR331-LC1) doesn't |
| 6 | # work with the CCID driver in openct, however it does work with pcscd. |
| 7 | |
| 8 | # Why not use "opensc-tool --wait" instead of polling opensc-tool exit status? |
| 9 | # Although opensc-tool --help reports that there is a --wait option, it doesn't |
| 10 | # seem to be implemented. |
| 11 | |
| 12 | check_cardscip-shell shell shell-project 0.0.0 check_card().() { |
| 13 | cardfound=0 |
| 14 | |
| 15 | if /usr/bin/opensc-toolscip-shell filesystem . . `/usr/bin/opensc-tool`. -n >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1; then |
| 16 | cardfound=1 |
| 17 | fi |
| 18 | } |
| 19 | |
| 20 | wait_cardscip-shell shell shell-project 0.0.0 wait_card().() { |
| 21 | check_cardscip-shell shell shell-project 0.0.0 check_card(). |
| 22 | if [scip-shell system . . `[`. $cardfound = 0 ] ; then |
| 23 | echoscip-shell system . . echo. "Waiting for Smart Card..." >&2 |
| 24 | tries=0 |
| 25 | while [scip-shell system . . `[`. $cardfound = 0 ] && [scip-shell system . . `[`. $tries -lt 60 ] ; do |
| 26 | sleepscip-shell system . . sleep. 1 |
| 27 | check_cardscip-shell shell shell-project 0.0.0 check_card(). |
| 28 | tries=$(($tries + 1)) |
| 29 | done |
| 30 | if [scip-shell system . . `[`. $cardfound = 0 ] ; then |
| 31 | echoscip-shell system . . echo. 'Failed to find Smart Card card!' >&2 |
| 32 | exit 1 |
| 33 | fi |
| 34 | fi |
| 35 | } |
| 36 | |
| 37 | wait_cardscip-shell shell shell-project 0.0.0 wait_card(). |
| 38 | if [scip-shell system . . `[`. -x /bin/plymouthscip-shell filesystem . . `/bin/plymouth`. ] && plymouth --ping; then |
| 39 | # Get pin number from plymouth |
| 40 | /usr/bin/pkcs15-cryptscip-shell filesystem . . `/usr/bin/pkcs15-crypt`. --decipher --input "$1" --pkcs1 --raw \ |
| 41 | --pin "$(plymouth ask-for-password --prompt "Enter pin for $CRYPTTAB_NAME: ")" |
| 42 | else |
| 43 | # Get pin number from console |
| 44 | /usr/bin/pkcs15-cryptscip-shell filesystem . . `/usr/bin/pkcs15-crypt`. --decipher --input "$1" --pkcs1 --raw </dev/consolescip-shell filesystem . . `/dev/console`. 2>/dev/consolescip-shell filesystem . . `/dev/console`. |
| 45 | fi |
| 46 | exit $? |