Compare commits
348 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4612c1f3ed | |||
| ca216a32af | |||
| 944493e472 | |||
| 34f24cbe19 | |||
| 9314069a88 | |||
| 66e21eac8f | |||
| f73429f062 | |||
| c18ebaf9da | |||
| 4a80bfacec | |||
| 52058c1ea0 | |||
| 22cdc0a7ea | |||
| 043fcaafec | |||
| bf2236620e | |||
| 0122d351f9 | |||
| 4435706d20 | |||
| c5877bbc12 | |||
| a170a3a09f | |||
| a76af6ce71 | |||
| 34a24eac77 | |||
| 47751548b2 | |||
| a30c45629e | |||
| 3242b99410 | |||
| 5ccb9ba0ec | |||
| f4eaacd0ec | |||
| 34b21fa917 | |||
| 2d98d4543f | |||
| 8c46fddd03 | |||
| 3a00643d5b | |||
| eb73e024e1 | |||
| a4b06c2219 | |||
| 5ccaa094a0 | |||
| fc7e4d0e5c | |||
| 583cd870d8 | |||
| 2ca2d5e62c | |||
| c5c81a2ea8 | |||
| c0ad5880a4 | |||
| 2dc3a4e2c5 | |||
| 3b0d93bcc2 | |||
| eac171ab0f | |||
| 7533f63a06 | |||
| a38917ab26 | |||
| a92b8e5f60 | |||
| 29f34cf23c | |||
| a10f0dc22d | |||
| 267b322f6d | |||
| 3b83240e57 | |||
| 897cbd341e | |||
| 9d0305ea05 | |||
| 3dbfdabe01 | |||
| 45cf63d589 | |||
| 29ed88a50a | |||
| e301779c20 | |||
| be5d283a3e | |||
| ebfcbdd13e | |||
| ec7376d7e6 | |||
| df568e1ce1 | |||
| 7ee61393ec | |||
| 57ca0dc95e | |||
| 85ba309e9d | |||
| 3f2174676e | |||
| 5e18d46971 | |||
| a8bd2bc25e | |||
| 88a627f187 | |||
| a8818f9bfb | |||
| c5a3089f89 | |||
| 5de1261df6 | |||
| e5c82d7b96 | |||
| 9c842e2c2f | |||
| ec5cce083c | |||
| ab8118bde2 | |||
| 08fb209aed | |||
| 6eb9f263fd | |||
| 74d05e7996 | |||
| 83cd09ba2f | |||
| 8ed77829a7 | |||
| b63c76319f | |||
| fd9a86eca4 | |||
| 38ba7199b7 | |||
| 827baff301 | |||
| 6a5d46c8b0 | |||
| 1ae0f4926d | |||
| e1c2698807 | |||
| b14bfd8226 | |||
| 1e2f360ade | |||
| 778a8540aa | |||
| 4e707f0d31 | |||
| 4c78012103 | |||
| e59f3cbc4f | |||
| 1a860aa882 | |||
| a183b779ec | |||
| 9d6c7eb1a9 | |||
| 110c0018a2 | |||
| 5611317c72 | |||
| 0904c8a527 | |||
| a681996d1d | |||
| 4e7cf47a3d | |||
| 9d3f3fcaca | |||
| 30474a6546 | |||
| 93bad82540 | |||
| e224913b80 | |||
| b2cae5cccf | |||
| 3419901f65 | |||
| c85ca09e35 | |||
| ecc02cb588 | |||
| 091f373109 | |||
| f6eb3b3ea5 | |||
| d7ca9e6095 | |||
| 6797928884 | |||
| d6c70be822 | |||
| d33a7c7e9d | |||
| 94d3a18dcd | |||
| 5635383c96 | |||
| ac98b881be | |||
| 629f7fcc11 | |||
| 5a703baa20 | |||
| 6641cb6da8 | |||
| 870b48637a | |||
| 4b0cde81fd | |||
| 59b3d2af8d | |||
| 93bcac946e | |||
| a5063dc0e4 | |||
| 5fbc38c938 | |||
| c42e627ddd | |||
| 2fd86624e5 | |||
| 6dc699ae6f | |||
| e075d37590 | |||
| 18d6a86e9d | |||
| 14051cac76 | |||
| 4e47222962 | |||
| c07a63da99 | |||
| 812a3552a6 | |||
| ff06a301f0 | |||
| 19353c971c | |||
| 290e56023f | |||
| efe92a7c33 | |||
| a7cf0ae3b2 | |||
| ba60533f71 | |||
| fcd2d65490 | |||
| 6dd010f05c | |||
| 714f499ab6 | |||
| d72c802415 | |||
| 184e1bd4d0 | |||
| f401f399a8 | |||
| 3dd0018f23 | |||
| 90298134a2 | |||
| 8ff4360750 | |||
| fd733e55be | |||
| 6a1fffae82 | |||
| 47bd3f7fbb | |||
| 4f3589c0dc | |||
| eccd790df7 | |||
| bc29114a2c | |||
| cf95187268 | |||
| 23c37cd9b5 | |||
| 967e4f24ed | |||
| d7fec03f24 | |||
| 4a3ae5ccaf | |||
| e828ea3b2d | |||
| d27872ff86 | |||
| cfbded36e1 | |||
| 072fbc2b46 | |||
| 7846359b65 | |||
| 08339a0648 | |||
| 3dd10b4b37 | |||
| bee2e154b1 | |||
| 27f0b64d03 | |||
| f4ee2f86a3 | |||
| 04829ed39f | |||
| 756a80a63e | |||
| b861500a9f | |||
| 154d0c0373 | |||
| b2cdc1ed1e | |||
| ab47e03f05 | |||
| f92801a15c | |||
| 086ceb98ab | |||
| 8bdbc7e2b0 | |||
| 1f8bb1abd4 | |||
| 47d55a97c4 | |||
| 657b90a066 | |||
| 3821b96ca5 | |||
| 22ad9b5ae8 | |||
| 2ddc8a86a2 | |||
| 930cae4647 | |||
| 5e9624bef5 | |||
| efac52d94f | |||
| af18aa35e5 | |||
| 0d7a703200 | |||
| ad19c49e2e | |||
| a8de1003a4 | |||
| cefe939141 | |||
| 24cd986476 | |||
| 06480c7994 | |||
| b2ad590891 | |||
| 85aad7bb01 | |||
| 0fb4f3b021 | |||
| 21564885ea | |||
| 6064e30200 | |||
| fd8297306c | |||
| e7f804e9fc | |||
| 0e993d92e2 | |||
| b312a5e540 | |||
| c12778ec5b | |||
| dbabd4d7d3 | |||
| db1865eb3e | |||
| 10a3e75937 | |||
| 01ea517a97 | |||
| 3a98ef646b | |||
| 750a815fdf | |||
| 53fcf52989 | |||
| 52e12459df | |||
| 554df2a8d9 | |||
| 681bd1ed2a | |||
| 8890732194 | |||
| 7dac81dcad | |||
| 1ecae1d014 | |||
| ba7a45d3f8 | |||
| 49dced5566 | |||
| e25544a8f0 | |||
| ee8589ec9d | |||
| 580cceb50e | |||
| b90b21f26b | |||
| 6d583cb5d8 | |||
| c776068cd2 | |||
| b8d80fcb35 | |||
| 32c2ccdd8c | |||
| 58784f7002 | |||
| f295e6c571 | |||
| b02825620a | |||
| 2327307b81 | |||
| 7c1ae363a8 | |||
| a18af36a03 | |||
| 526b2e8c53 | |||
| 73625233f6 | |||
| 08de7e33a4 | |||
| c871dfc998 | |||
| dccc5796b6 | |||
| 0994cc314e | |||
| 09b1f1f1db | |||
| e10417a907 | |||
| 8f75563920 | |||
| 2e00c7a4b1 | |||
| 72d8a0f512 | |||
| 130d6cdb63 | |||
| e2fd52190a | |||
| 7d8450e5ab | |||
| 95e95d2910 | |||
| 75aeff4acd | |||
| bebd3d2a98 | |||
| 0e2bf7e804 | |||
| f5a2c21f90 | |||
| 53d80c1474 | |||
| 9bed3bed3f | |||
| 1a094c1a09 | |||
| 4ed46deaf2 | |||
| 0724413eda | |||
| eb6dbb6953 | |||
| 5c5849dca7 | |||
| 048181ae7f | |||
| 8e3345a60f | |||
| 33a21b5089 | |||
| dd006382f5 | |||
| a34432ccf9 | |||
| f2804921a3 | |||
| 74577a6806 | |||
| 2076025208 | |||
| 77126ccf1f | |||
| 46b7d7c1a7 | |||
| 791a208afd | |||
| b832002c97 | |||
| 8a2f276003 | |||
| aab923e3cd | |||
| cc4bac3410 | |||
| 18d4aa6d7d | |||
| 046ec8dbf4 | |||
| 874b4556ef | |||
| c2aa5c0b9a | |||
| f745c49112 | |||
| 319d859107 | |||
| b97903f781 | |||
| a30697a28d | |||
| aad3212d22 | |||
| 3624bcb114 | |||
| 8fbc59a258 | |||
| 5a8da0022a | |||
| 6089ba6f40 | |||
| ee6e8a6fa3 | |||
| 42f5280a03 | |||
| affffaf134 | |||
| 6ab270fb1a | |||
| 2d0bed6b13 | |||
| c43134e36f | |||
| b9d23ddb87 | |||
| 205dedae4f | |||
| d70f15b5e8 | |||
| 6f63beb1fc | |||
| f7557c6ee7 | |||
| 0b598965b0 | |||
| 8325d347d6 | |||
| 0bdf801043 | |||
| 6e3b053372 | |||
| c6e72c5f28 | |||
| 986a42bcd1 | |||
| 0c6bab8640 | |||
| b99afd19f0 | |||
| 3d6dfabd8d | |||
| 67adcb59ed | |||
| db0ab55bef | |||
| 00b79d1a2f | |||
| f1517af09a | |||
| c0bf1515fd | |||
| 872089883c | |||
| 431755becd | |||
| 0a42b90390 | |||
| cd3ed2e450 | |||
| c929d39df1 | |||
| 1a5ef6c5a7 | |||
| ce3406b20f | |||
| 0d407db171 | |||
| 4eb751a218 | |||
| 0f44267ea1 | |||
| 9baea4494b | |||
| 41afbd1ced | |||
| f2d6921b74 | |||
| b690daa95f | |||
| deb3c25e51 | |||
| a520896325 | |||
| 707ed01059 | |||
| 6903c36157 | |||
| d0df422f9b | |||
| 882740f8a1 | |||
| 5043ef3c7d | |||
| cdd79a0935 | |||
| 776b4f4cec | |||
| 31bfd1b055 | |||
| 74838f9efc | |||
| 54ba81191e | |||
| 521ba9b124 | |||
| 3db69c2c2f | |||
| b2ff316e20 | |||
| 94f54c0638 | |||
| 9c8d062669 | |||
| ca482036c7 | |||
| d7821aa790 | |||
| 16cb1a8ec6 | |||
| 31ba9ebea4 | |||
| 8893c2f906 | |||
| 3520cb56d1 | |||
| 96444b4156 |
7
.git-blame-ignore-revs
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# The commits that did automated reformatting. You can ignore them
|
||||||
|
# during git-blame with `--ignore-rev` or `--ignore-revs-file`.
|
||||||
|
#
|
||||||
|
# $ git config --add 'blame.ignoreRevsFile' '.git-blame-ignore-revs'
|
||||||
|
#
|
||||||
|
|
||||||
|
f73429f06226f5423c92b1c504313657c9b6f9b5
|
||||||
37
.gitignore
vendored
@ -1,46 +1,11 @@
|
|||||||
/*.bak
|
/*.bak
|
||||||
/*.lo
|
|
||||||
/*.o
|
/*.o
|
||||||
/*.orig
|
/*.orig
|
||||||
/*.rej
|
/*.rej
|
||||||
/*.tab.c
|
/*.tab.c
|
||||||
/*~
|
/*~
|
||||||
/.*.sw[nop]
|
/.*.sw[nop]
|
||||||
/.deps
|
|
||||||
/.dirstamp
|
/.dirstamp
|
||||||
/.gitignore
|
/.gitignore
|
||||||
/.libs
|
/_build
|
||||||
/GPATH
|
|
||||||
/GRTAGS
|
|
||||||
/GSYMS
|
|
||||||
/GTAGS
|
|
||||||
/ID
|
|
||||||
/Makefile
|
|
||||||
/Makefile.in
|
|
||||||
/TAGS
|
|
||||||
/_libs
|
|
||||||
/autom4te.cache
|
|
||||||
/config.cache
|
|
||||||
/config.h
|
|
||||||
/config.log
|
|
||||||
/config.lt
|
|
||||||
/config.status
|
|
||||||
/config.status.lineno
|
|
||||||
/configure
|
|
||||||
/configure.lineno
|
|
||||||
/intltool-extract.in
|
|
||||||
/intltool-merge.in
|
|
||||||
/intltool-update.in
|
|
||||||
/libtool
|
|
||||||
/po/*.gmo
|
|
||||||
/po/*.mo
|
|
||||||
/po/.intltool-merge-cache
|
|
||||||
/po/Makefile
|
|
||||||
/po/Makefile.in
|
|
||||||
/po/Makefile.in.in
|
|
||||||
/po/POTFILES
|
|
||||||
/po/fprintd.pot
|
|
||||||
/po/stamp-it
|
|
||||||
/so_locations
|
|
||||||
/stamp-h1
|
|
||||||
/tags
|
/tags
|
||||||
|
|||||||
137
.gitlab-ci.yml
@ -1,36 +1,127 @@
|
|||||||
image: fedora:rawhide
|
include:
|
||||||
|
- project: 'libfprint/libfprint'
|
||||||
|
ref: master
|
||||||
|
file: '/.gitlab-ci/libfprint-templates.yaml'
|
||||||
|
- project: 'wayland/ci-templates'
|
||||||
|
ref: master
|
||||||
|
file: '/templates/fedora.yml'
|
||||||
|
|
||||||
variables:
|
variables:
|
||||||
DEPENDENCIES: dbus-glib-devel pam-devel polkit-devel
|
extends: .libfprint_common_variables
|
||||||
gtk-doc meson intltool autoconf automake libtool
|
FDO_DISTRIBUTION_TAG: latest
|
||||||
gcc gcc-c++ glibc-devel make
|
FDO_DISTRIBUTION_VERSION: rawhide
|
||||||
DEPENDENCIES_STABLE: $DEPENDENCIES libfprint-devel
|
FEDORA_IMAGE: "$CI_REGISTRY/libfprint/$CI_PROJECT_NAME/fedora/$FDO_DISTRIBUTION_VERSION:$FDO_DISTRIBUTION_TAG"
|
||||||
DEPENDENCIES_DEV: $DEPENDENCIES git
|
DEPENDENCIES: dbus-glib-devel
|
||||||
# Sync'ed up with https://gitlab.freedesktop.org/libfprint/libfprint/blob/master/.gitlab-ci.yml
|
gcc
|
||||||
DEPENDENCIES_LIBFPRINT: libusb1-devel glib2-devel nss-devel pixman-devel systemd
|
gcovr
|
||||||
meson gtk-doc gcc gcc-c++ glibc-devel libX11-devel
|
gettext
|
||||||
libXv-devel
|
git
|
||||||
|
glibc-devel
|
||||||
|
gtk-doc
|
||||||
|
libasan
|
||||||
|
libfprint-devel
|
||||||
|
meson
|
||||||
|
pam-devel
|
||||||
|
polkit-devel
|
||||||
|
python3-dbusmock
|
||||||
|
python3-libpamtest
|
||||||
|
systemd-devel
|
||||||
|
|
||||||
build_stable:
|
image: "$FEDORA_IMAGE"
|
||||||
before_script:
|
|
||||||
- dnf update -y --nogpgcheck && dnf install -y --nogpgcheck $DEPENDENCIES_STABLE
|
|
||||||
script:
|
|
||||||
- ./autogen.sh --disable-dependency-tracking
|
|
||||||
- make
|
|
||||||
- make install
|
|
||||||
|
|
||||||
build_dev:
|
stages:
|
||||||
|
- check-source
|
||||||
|
- build
|
||||||
|
- test
|
||||||
|
|
||||||
|
.fprintd_build_preconditions:
|
||||||
|
except:
|
||||||
|
variables:
|
||||||
|
- $FPRINT_CRON_TASK == "BUILD_CI_IMAGES"
|
||||||
|
|
||||||
|
.install_libfprint_dev:
|
||||||
before_script:
|
before_script:
|
||||||
- dnf update -y --nogpgcheck && dnf install -y --nogpgcheck $DEPENDENCIES_LIBFPRINT $DEPENDENCIES_DEV
|
# Make sure we don't build or link against the system libfprint
|
||||||
|
- dnf remove -y libfprint-devel
|
||||||
- git clone https://gitlab.freedesktop.org/libfprint/libfprint.git
|
- git clone https://gitlab.freedesktop.org/libfprint/libfprint.git
|
||||||
- cd libfprint
|
- cd libfprint
|
||||||
- meson . _build --prefix=/usr
|
- meson . _build --prefix=/usr -Ddrivers=virtual_image -Ddoc=false
|
||||||
- ninja -C _build
|
- ninja -C _build
|
||||||
- ninja -C _build install
|
- ninja -C _build install
|
||||||
- cd ..
|
- cd ..
|
||||||
# So we don't get error about this libfprint file
|
# So we don't get error about this libfprint file
|
||||||
- echo "libfprint/demo/gtk-libfprint-test.ui" >> po/POTFILES.skip
|
- echo "libfprint/demo/gtk-libfprint-test.ui" >> po/POTFILES.skip
|
||||||
|
|
||||||
|
test_indent:
|
||||||
|
stage: check-source
|
||||||
|
extends: .fprintd_build_preconditions
|
||||||
script:
|
script:
|
||||||
- ./autogen.sh --disable-dependency-tracking
|
- scripts/uncrustify.sh
|
||||||
- make
|
- git diff
|
||||||
- make install
|
- "! git status -s | grep -q ."
|
||||||
|
|
||||||
|
build_stable:
|
||||||
|
extends: .fprintd_build_preconditions
|
||||||
|
stage: build
|
||||||
|
script:
|
||||||
|
- meson _build
|
||||||
|
- ninja -C _build -v
|
||||||
|
- ninja -C _build -v install
|
||||||
|
|
||||||
|
build_dev:
|
||||||
|
extends:
|
||||||
|
- .fprintd_build_preconditions
|
||||||
|
- .install_libfprint_dev
|
||||||
|
stage: build
|
||||||
|
script:
|
||||||
|
- meson _build --werror -Dgtk_doc=true
|
||||||
|
- ninja -C _build -v
|
||||||
|
- ninja -C _build -v install
|
||||||
|
artifacts:
|
||||||
|
name: log
|
||||||
|
when: on_failure
|
||||||
|
paths:
|
||||||
|
- _build/meson-logs/*.txt
|
||||||
|
|
||||||
|
test_dev:
|
||||||
|
extends:
|
||||||
|
- .fprintd_build_preconditions
|
||||||
|
- .install_libfprint_dev
|
||||||
|
stage: test
|
||||||
|
script:
|
||||||
|
- meson _build -Db_coverage=true
|
||||||
|
- meson test -C _build --verbose --no-stdsplit --timeout-multiplier 3
|
||||||
|
- ninja -C _build coverage
|
||||||
|
- cat _build/meson-logs/coverage.txt
|
||||||
|
artifacts:
|
||||||
|
name: log-and-coverage
|
||||||
|
when: always
|
||||||
|
paths:
|
||||||
|
- _build/meson-logs
|
||||||
|
|
||||||
|
test_dev_with_sanitizer:
|
||||||
|
extends:
|
||||||
|
- .fprintd_build_preconditions
|
||||||
|
- .install_libfprint_dev
|
||||||
|
stage: test
|
||||||
|
script:
|
||||||
|
- meson _build -Db_sanitize=address
|
||||||
|
- meson test -C _build --verbose --no-stdsplit --timeout-multiplier 5
|
||||||
|
artifacts:
|
||||||
|
name: meson-logs
|
||||||
|
when: on_failure
|
||||||
|
paths:
|
||||||
|
- _build/meson-logs
|
||||||
|
|
||||||
|
# CONTAINERS creation stage
|
||||||
|
container_fedora_build:
|
||||||
|
extends: .fdo.container-build@fedora
|
||||||
|
only:
|
||||||
|
variables:
|
||||||
|
- $FPRINT_CRON_TASK == "BUILD_CI_IMAGES"
|
||||||
|
variables:
|
||||||
|
GIT_STRATEGY: none # no need to pull the whole tree for rebuilding the image
|
||||||
|
# a list of packages to install
|
||||||
|
FDO_DISTRIBUTION_PACKAGES:
|
||||||
|
$DEPENDENCIES
|
||||||
|
$LIBFPRINT_DEPENDENCIES
|
||||||
|
|||||||
237
INSTALL
@ -1,237 +0,0 @@
|
|||||||
Installation Instructions
|
|
||||||
*************************
|
|
||||||
|
|
||||||
Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
|
|
||||||
2006, 2007 Free Software Foundation, Inc.
|
|
||||||
|
|
||||||
This file is free documentation; the Free Software Foundation gives
|
|
||||||
unlimited permission to copy, distribute and modify it.
|
|
||||||
|
|
||||||
Basic Installation
|
|
||||||
==================
|
|
||||||
|
|
||||||
Briefly, the shell commands `./configure; make; make install' should
|
|
||||||
configure, build, and install this package. The following
|
|
||||||
more-detailed instructions are generic; see the `README' file for
|
|
||||||
instructions specific to this package.
|
|
||||||
|
|
||||||
The `configure' shell script attempts to guess correct values for
|
|
||||||
various system-dependent variables used during compilation. It uses
|
|
||||||
those values to create a `Makefile' in each directory of the package.
|
|
||||||
It may also create one or more `.h' files containing system-dependent
|
|
||||||
definitions. Finally, it creates a shell script `config.status' that
|
|
||||||
you can run in the future to recreate the current configuration, and a
|
|
||||||
file `config.log' containing compiler output (useful mainly for
|
|
||||||
debugging `configure').
|
|
||||||
|
|
||||||
It can also use an optional file (typically called `config.cache'
|
|
||||||
and enabled with `--cache-file=config.cache' or simply `-C') that saves
|
|
||||||
the results of its tests to speed up reconfiguring. Caching is
|
|
||||||
disabled by default to prevent problems with accidental use of stale
|
|
||||||
cache files.
|
|
||||||
|
|
||||||
If you need to do unusual things to compile the package, please try
|
|
||||||
to figure out how `configure' could check whether to do them, and mail
|
|
||||||
diffs or instructions to the address given in the `README' so they can
|
|
||||||
be considered for the next release. If you are using the cache, and at
|
|
||||||
some point `config.cache' contains results you don't want to keep, you
|
|
||||||
may remove or edit it.
|
|
||||||
|
|
||||||
The file `configure.ac' (or `configure.in') is used to create
|
|
||||||
`configure' by a program called `autoconf'. You need `configure.ac' if
|
|
||||||
you want to change it or regenerate `configure' using a newer version
|
|
||||||
of `autoconf'.
|
|
||||||
|
|
||||||
The simplest way to compile this package is:
|
|
||||||
|
|
||||||
1. `cd' to the directory containing the package's source code and type
|
|
||||||
`./configure' to configure the package for your system.
|
|
||||||
|
|
||||||
Running `configure' might take a while. While running, it prints
|
|
||||||
some messages telling which features it is checking for.
|
|
||||||
|
|
||||||
2. Type `make' to compile the package.
|
|
||||||
|
|
||||||
3. Optionally, type `make check' to run any self-tests that come with
|
|
||||||
the package.
|
|
||||||
|
|
||||||
4. Type `make install' to install the programs and any data files and
|
|
||||||
documentation.
|
|
||||||
|
|
||||||
5. You can remove the program binaries and object files from the
|
|
||||||
source code directory by typing `make clean'. To also remove the
|
|
||||||
files that `configure' created (so you can compile the package for
|
|
||||||
a different kind of computer), type `make distclean'. There is
|
|
||||||
also a `make maintainer-clean' target, but that is intended mainly
|
|
||||||
for the package's developers. If you use it, you may have to get
|
|
||||||
all sorts of other programs in order to regenerate files that came
|
|
||||||
with the distribution.
|
|
||||||
|
|
||||||
6. Often, you can also type `make uninstall' to remove the installed
|
|
||||||
files again.
|
|
||||||
|
|
||||||
Compilers and Options
|
|
||||||
=====================
|
|
||||||
|
|
||||||
Some systems require unusual options for compilation or linking that the
|
|
||||||
`configure' script does not know about. Run `./configure --help' for
|
|
||||||
details on some of the pertinent environment variables.
|
|
||||||
|
|
||||||
You can give `configure' initial values for configuration parameters
|
|
||||||
by setting variables in the command line or in the environment. Here
|
|
||||||
is an example:
|
|
||||||
|
|
||||||
./configure CC=c99 CFLAGS=-g LIBS=-lposix
|
|
||||||
|
|
||||||
*Note Defining Variables::, for more details.
|
|
||||||
|
|
||||||
Compiling For Multiple Architectures
|
|
||||||
====================================
|
|
||||||
|
|
||||||
You can compile the package for more than one kind of computer at the
|
|
||||||
same time, by placing the object files for each architecture in their
|
|
||||||
own directory. To do this, you can use GNU `make'. `cd' to the
|
|
||||||
directory where you want the object files and executables to go and run
|
|
||||||
the `configure' script. `configure' automatically checks for the
|
|
||||||
source code in the directory that `configure' is in and in `..'.
|
|
||||||
|
|
||||||
With a non-GNU `make', it is safer to compile the package for one
|
|
||||||
architecture at a time in the source code directory. After you have
|
|
||||||
installed the package for one architecture, use `make distclean' before
|
|
||||||
reconfiguring for another architecture.
|
|
||||||
|
|
||||||
Installation Names
|
|
||||||
==================
|
|
||||||
|
|
||||||
By default, `make install' installs the package's commands under
|
|
||||||
`/usr/local/bin', include files under `/usr/local/include', etc. You
|
|
||||||
can specify an installation prefix other than `/usr/local' by giving
|
|
||||||
`configure' the option `--prefix=PREFIX'.
|
|
||||||
|
|
||||||
You can specify separate installation prefixes for
|
|
||||||
architecture-specific files and architecture-independent files. If you
|
|
||||||
pass the option `--exec-prefix=PREFIX' to `configure', the package uses
|
|
||||||
PREFIX as the prefix for installing programs and libraries.
|
|
||||||
Documentation and other data files still use the regular prefix.
|
|
||||||
|
|
||||||
In addition, if you use an unusual directory layout you can give
|
|
||||||
options like `--bindir=DIR' to specify different values for particular
|
|
||||||
kinds of files. Run `configure --help' for a list of the directories
|
|
||||||
you can set and what kinds of files go in them.
|
|
||||||
|
|
||||||
If the package supports it, you can cause programs to be installed
|
|
||||||
with an extra prefix or suffix on their names by giving `configure' the
|
|
||||||
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
|
|
||||||
|
|
||||||
Optional Features
|
|
||||||
=================
|
|
||||||
|
|
||||||
Some packages pay attention to `--enable-FEATURE' options to
|
|
||||||
`configure', where FEATURE indicates an optional part of the package.
|
|
||||||
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
|
|
||||||
is something like `gnu-as' or `x' (for the X Window System). The
|
|
||||||
`README' should mention any `--enable-' and `--with-' options that the
|
|
||||||
package recognizes.
|
|
||||||
|
|
||||||
For packages that use the X Window System, `configure' can usually
|
|
||||||
find the X include and library files automatically, but if it doesn't,
|
|
||||||
you can use the `configure' options `--x-includes=DIR' and
|
|
||||||
`--x-libraries=DIR' to specify their locations.
|
|
||||||
|
|
||||||
Specifying the System Type
|
|
||||||
==========================
|
|
||||||
|
|
||||||
There may be some features `configure' cannot figure out automatically,
|
|
||||||
but needs to determine by the type of machine the package will run on.
|
|
||||||
Usually, assuming the package is built to be run on the _same_
|
|
||||||
architectures, `configure' can figure that out, but if it prints a
|
|
||||||
message saying it cannot guess the machine type, give it the
|
|
||||||
`--build=TYPE' option. TYPE can either be a short name for the system
|
|
||||||
type, such as `sun4', or a canonical name which has the form:
|
|
||||||
|
|
||||||
CPU-COMPANY-SYSTEM
|
|
||||||
|
|
||||||
where SYSTEM can have one of these forms:
|
|
||||||
|
|
||||||
OS KERNEL-OS
|
|
||||||
|
|
||||||
See the file `config.sub' for the possible values of each field. If
|
|
||||||
`config.sub' isn't included in this package, then this package doesn't
|
|
||||||
need to know the machine type.
|
|
||||||
|
|
||||||
If you are _building_ compiler tools for cross-compiling, you should
|
|
||||||
use the option `--target=TYPE' to select the type of system they will
|
|
||||||
produce code for.
|
|
||||||
|
|
||||||
If you want to _use_ a cross compiler, that generates code for a
|
|
||||||
platform different from the build platform, you should specify the
|
|
||||||
"host" platform (i.e., that on which the generated programs will
|
|
||||||
eventually be run) with `--host=TYPE'.
|
|
||||||
|
|
||||||
Sharing Defaults
|
|
||||||
================
|
|
||||||
|
|
||||||
If you want to set default values for `configure' scripts to share, you
|
|
||||||
can create a site shell script called `config.site' that gives default
|
|
||||||
values for variables like `CC', `cache_file', and `prefix'.
|
|
||||||
`configure' looks for `PREFIX/share/config.site' if it exists, then
|
|
||||||
`PREFIX/etc/config.site' if it exists. Or, you can set the
|
|
||||||
`CONFIG_SITE' environment variable to the location of the site script.
|
|
||||||
A warning: not all `configure' scripts look for a site script.
|
|
||||||
|
|
||||||
Defining Variables
|
|
||||||
==================
|
|
||||||
|
|
||||||
Variables not defined in a site shell script can be set in the
|
|
||||||
environment passed to `configure'. However, some packages may run
|
|
||||||
configure again during the build, and the customized values of these
|
|
||||||
variables may be lost. In order to avoid this problem, you should set
|
|
||||||
them in the `configure' command line, using `VAR=value'. For example:
|
|
||||||
|
|
||||||
./configure CC=/usr/local2/bin/gcc
|
|
||||||
|
|
||||||
causes the specified `gcc' to be used as the C compiler (unless it is
|
|
||||||
overridden in the site shell script).
|
|
||||||
|
|
||||||
Unfortunately, this technique does not work for `CONFIG_SHELL' due to
|
|
||||||
an Autoconf bug. Until the bug is fixed you can use this workaround:
|
|
||||||
|
|
||||||
CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash
|
|
||||||
|
|
||||||
`configure' Invocation
|
|
||||||
======================
|
|
||||||
|
|
||||||
`configure' recognizes the following options to control how it operates.
|
|
||||||
|
|
||||||
`--help'
|
|
||||||
`-h'
|
|
||||||
Print a summary of the options to `configure', and exit.
|
|
||||||
|
|
||||||
`--version'
|
|
||||||
`-V'
|
|
||||||
Print the version of Autoconf used to generate the `configure'
|
|
||||||
script, and exit.
|
|
||||||
|
|
||||||
`--cache-file=FILE'
|
|
||||||
Enable the cache: use and save the results of the tests in FILE,
|
|
||||||
traditionally `config.cache'. FILE defaults to `/dev/null' to
|
|
||||||
disable caching.
|
|
||||||
|
|
||||||
`--config-cache'
|
|
||||||
`-C'
|
|
||||||
Alias for `--cache-file=config.cache'.
|
|
||||||
|
|
||||||
`--quiet'
|
|
||||||
`--silent'
|
|
||||||
`-q'
|
|
||||||
Do not print messages saying which checks are being made. To
|
|
||||||
suppress all normal output, redirect it to `/dev/null' (any error
|
|
||||||
messages will still be shown).
|
|
||||||
|
|
||||||
`--srcdir=DIR'
|
|
||||||
Look for the package's source code in directory DIR. Usually
|
|
||||||
`configure' can determine that directory automatically.
|
|
||||||
|
|
||||||
`configure' also accepts some other, not widely useful, options. Run
|
|
||||||
`configure --help' for more details.
|
|
||||||
|
|
||||||
29
Makefile.am
@ -1,29 +0,0 @@
|
|||||||
AUTOMAKE_OPTIONS = dist-bzip2
|
|
||||||
SUBDIRS = src data tests pam doc po
|
|
||||||
EXTRA_DIST = TODO intltool-extract.in intltool-merge.in intltool-update.in
|
|
||||||
|
|
||||||
DISTCHECK_CONFIGURE_FLAGS = --enable-gtk-doc --with-systemdsystemunitdir='$${libdir}/systemd/system-distcheck'
|
|
||||||
|
|
||||||
all: check create-pot
|
|
||||||
|
|
||||||
check: check-translations
|
|
||||||
|
|
||||||
create-pot:
|
|
||||||
$(MAKE) -C po fprintd.pot
|
|
||||||
|
|
||||||
check-translations:
|
|
||||||
@for i in $(top_srcdir)/po/*.po ; do \
|
|
||||||
if ! grep -q `basename $$i | sed 's,.po,,'` $(top_srcdir)/po/LINGUAS ; then \
|
|
||||||
echo '**********************************'; \
|
|
||||||
echo '***' `basename $$i | sed 's,.po,,'` missing from po/LINGUAS '***' ; \
|
|
||||||
echo '**********************************'; \
|
|
||||||
exit 1; \
|
|
||||||
fi; \
|
|
||||||
done;
|
|
||||||
|
|
||||||
update-translations: create-pot check-translations
|
|
||||||
@tx -r $(srcdir) pull --all --force --skip
|
|
||||||
@if [ ! -d .tx ] ; then mkdir .tx ; fi ; if [ x$(srcdir) != x$(builddir) ] ; then cp -f $(srcdir)/.tx/config .tx/ ; fi
|
|
||||||
@tx push --source
|
|
||||||
|
|
||||||
-include $(top_srcdir)/git.mk
|
|
||||||
66
NEWS
@ -1,6 +1,72 @@
|
|||||||
This file lists notable changes in each release. For the full history of all
|
This file lists notable changes in each release. For the full history of all
|
||||||
changes, see ChangeLog.
|
changes, see ChangeLog.
|
||||||
|
|
||||||
|
Version 1.90.7:
|
||||||
|
|
||||||
|
While 1.90.6 fixed a number of issues, we did have a bad regression due
|
||||||
|
causing pam_fprintd to crash when there are no fingerprint devices
|
||||||
|
installed.
|
||||||
|
|
||||||
|
Highlights:
|
||||||
|
- pam: Guard strdup calls against NULL pointers
|
||||||
|
|
||||||
|
|
||||||
|
Version 1.90.6:
|
||||||
|
|
||||||
|
The 1.90.5 release was unusable due to a number of inter-related issues
|
||||||
|
with the DBus interface and authorization. We also found a number of
|
||||||
|
problems with possible security implications.
|
||||||
|
|
||||||
|
Currently fprintd will do interactive authorization even if this was not
|
||||||
|
requested using the correct DBus method call flag. All API users MUST be
|
||||||
|
updated to set the flag as it will be enabled in the future!
|
||||||
|
|
||||||
|
Highlights:
|
||||||
|
- Fix fprintd DBus configuration
|
||||||
|
- Change details of what requires authorization
|
||||||
|
- Fix various race conditions in pam_fprintd
|
||||||
|
- Permit interactive authorization from fprintd utilities
|
||||||
|
- Do not allow deletion while another operation is ongoing
|
||||||
|
|
||||||
|
|
||||||
|
Version 1.90.5:
|
||||||
|
|
||||||
|
The 1.90.4 release contained some bad errors, this release addresses those.
|
||||||
|
|
||||||
|
Highlights:
|
||||||
|
- Permit building with polkit older than 0.114
|
||||||
|
- Fix possible issues with PAM test
|
||||||
|
- Fix incorrect DBus policy
|
||||||
|
- Fix build so that CFLAGS enviroment is correctly used
|
||||||
|
- Skip hotplug test with older libfprint (which times out otherwise)
|
||||||
|
|
||||||
|
Version 1.90.4:
|
||||||
|
|
||||||
|
This fprintd release contains major core reworkings and improved testing.
|
||||||
|
As such, only the most important changes are listed here, focusing on
|
||||||
|
changes relevant to distributors.
|
||||||
|
|
||||||
|
Highlights:
|
||||||
|
- Authentication is now required to enroll a new print (#5)
|
||||||
|
- Add support for the libfprint early reporting mechanism
|
||||||
|
- Proper hotplug support together with libfprint 1.90.4
|
||||||
|
- Handle STATE_DIRECTORY containing multiple paths
|
||||||
|
|
||||||
|
version 1.90.1:
|
||||||
|
- Add support for prints saved on the fingerprint device itself
|
||||||
|
- Add integration tests using the virtual image driver, and further
|
||||||
|
tests for the utilities
|
||||||
|
- Port build system to meson
|
||||||
|
- Loads of build warnings and memory leak fixes
|
||||||
|
|
||||||
|
- PAM module:
|
||||||
|
- Port PAM module to sd-bus from dbus-glib
|
||||||
|
- Use systemd to not ask for a fingerprint scan on remote logins
|
||||||
|
- Add man page for PAM module
|
||||||
|
- Add tests
|
||||||
|
|
||||||
|
This version requires libfprint 1.90.1, a 2.0 pre-release.
|
||||||
|
|
||||||
version 0.9.0:
|
version 0.9.0:
|
||||||
- Fix hangs when there the verification error was "retry"
|
- Fix hangs when there the verification error was "retry"
|
||||||
- Update for fp_get_pollfds() changes
|
- Update for fp_get_pollfds() changes
|
||||||
|
|||||||
@ -1,7 +1,13 @@
|
|||||||
Transifex.net Token Verification
|
Updating translations
|
||||||
=================================
|
=====================
|
||||||
|
|
||||||
The list of tokens bellow guarantee the respective users to be able to enable
|
The update-transifex.sh script should be run regularly to both pull
|
||||||
|
translations from the Transifex service, and push new strings to translate.
|
||||||
|
|
||||||
|
Transifex.net Token Verification
|
||||||
|
================================
|
||||||
|
|
||||||
|
The list of tokens below guarantee the respective users to be able to enable
|
||||||
submission on components using the following repository url:
|
submission on components using the following repository url:
|
||||||
|
|
||||||
https://gitlab.freedesktop.org/libfprint/fprintd/
|
https://gitlab.freedesktop.org/libfprint/fprintd/
|
||||||
|
|||||||
182
acinclude.m4
@ -1,182 +0,0 @@
|
|||||||
dnl AS_AC_EXPAND(VAR, CONFIGURE_VAR)
|
|
||||||
dnl
|
|
||||||
dnl example
|
|
||||||
dnl AS_AC_EXPAND(SYSCONFDIR, $sysconfdir)
|
|
||||||
dnl will set SYSCONFDIR to /usr/local/etc if prefix=/usr/local
|
|
||||||
|
|
||||||
AC_DEFUN([AS_AC_EXPAND],
|
|
||||||
[
|
|
||||||
EXP_VAR=[$1]
|
|
||||||
FROM_VAR=[$2]
|
|
||||||
|
|
||||||
dnl first expand prefix and exec_prefix if necessary
|
|
||||||
prefix_save=$prefix
|
|
||||||
exec_prefix_save=$exec_prefix
|
|
||||||
|
|
||||||
dnl if no prefix given, then use /usr/local, the default prefix
|
|
||||||
if test "x$prefix" = "xNONE"; then
|
|
||||||
prefix=$ac_default_prefix
|
|
||||||
fi
|
|
||||||
dnl if no exec_prefix given, then use prefix
|
|
||||||
if test "x$exec_prefix" = "xNONE"; then
|
|
||||||
exec_prefix=$prefix
|
|
||||||
fi
|
|
||||||
|
|
||||||
full_var="$FROM_VAR"
|
|
||||||
dnl loop until it doesn't change anymore
|
|
||||||
while true; do
|
|
||||||
new_full_var="`eval echo $full_var`"
|
|
||||||
if test "x$new_full_var"="x$full_var"; then break; fi
|
|
||||||
full_var=$new_full_var
|
|
||||||
done
|
|
||||||
|
|
||||||
dnl clean up
|
|
||||||
full_var=$new_full_var
|
|
||||||
AC_SUBST([$1], "$full_var")
|
|
||||||
|
|
||||||
dnl restore prefix and exec_prefix
|
|
||||||
prefix=$prefix_save
|
|
||||||
exec_prefix=$exec_prefix_save
|
|
||||||
])
|
|
||||||
|
|
||||||
dnl GNOME_COMPILE_WARNINGS
|
|
||||||
dnl Turn on many useful compiler warnings
|
|
||||||
dnl For now, only works on GCC
|
|
||||||
AC_DEFUN([GNOME_COMPILE_WARNINGS],[
|
|
||||||
dnl ******************************
|
|
||||||
dnl More compiler warnings
|
|
||||||
dnl ******************************
|
|
||||||
|
|
||||||
AC_ARG_ENABLE(compile-warnings,
|
|
||||||
AC_HELP_STRING([--enable-compile-warnings=@<:@no/minimum/yes/maximum/error@:>@],
|
|
||||||
[Turn on compiler warnings]),,
|
|
||||||
[enable_compile_warnings="m4_default([$1],[yes])"])
|
|
||||||
|
|
||||||
warnCFLAGS=
|
|
||||||
if test "x$GCC" != xyes; then
|
|
||||||
enable_compile_warnings=no
|
|
||||||
fi
|
|
||||||
|
|
||||||
warning_flags=
|
|
||||||
realsave_CFLAGS="$CFLAGS"
|
|
||||||
|
|
||||||
case "$enable_compile_warnings" in
|
|
||||||
no)
|
|
||||||
warning_flags=
|
|
||||||
;;
|
|
||||||
minimum)
|
|
||||||
warning_flags="-Wall"
|
|
||||||
;;
|
|
||||||
yes)
|
|
||||||
warning_flags="-Wall -Wmissing-prototypes"
|
|
||||||
;;
|
|
||||||
maximum|error)
|
|
||||||
warning_flags="-Wall -Wmissing-prototypes -Wnested-externs -Wpointer-arith"
|
|
||||||
CFLAGS="$warning_flags $CFLAGS"
|
|
||||||
for option in -Wno-sign-compare; do
|
|
||||||
SAVE_CFLAGS="$CFLAGS"
|
|
||||||
CFLAGS="$CFLAGS $option"
|
|
||||||
AC_MSG_CHECKING([whether gcc understands $option])
|
|
||||||
AC_TRY_COMPILE([], [],
|
|
||||||
has_option=yes,
|
|
||||||
has_option=no,)
|
|
||||||
CFLAGS="$SAVE_CFLAGS"
|
|
||||||
AC_MSG_RESULT($has_option)
|
|
||||||
if test $has_option = yes; then
|
|
||||||
warning_flags="$warning_flags $option"
|
|
||||||
fi
|
|
||||||
unset has_option
|
|
||||||
unset SAVE_CFLAGS
|
|
||||||
done
|
|
||||||
unset option
|
|
||||||
if test "$enable_compile_warnings" = "error" ; then
|
|
||||||
warning_flags="$warning_flags -Werror"
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
AC_MSG_ERROR(Unknown argument '$enable_compile_warnings' to --enable-compile-warnings)
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
CFLAGS="$realsave_CFLAGS"
|
|
||||||
AC_MSG_CHECKING(what warning flags to pass to the C compiler)
|
|
||||||
AC_MSG_RESULT($warning_flags)
|
|
||||||
|
|
||||||
AC_ARG_ENABLE(iso-c,
|
|
||||||
AC_HELP_STRING([--enable-iso-c],
|
|
||||||
[Try to warn if code is not ISO C ]),,
|
|
||||||
[enable_iso_c=no])
|
|
||||||
|
|
||||||
AC_MSG_CHECKING(what language compliance flags to pass to the C compiler)
|
|
||||||
complCFLAGS=
|
|
||||||
if test "x$enable_iso_c" != "xno"; then
|
|
||||||
if test "x$GCC" = "xyes"; then
|
|
||||||
case " $CFLAGS " in
|
|
||||||
*[\ \ ]-ansi[\ \ ]*) ;;
|
|
||||||
*) complCFLAGS="$complCFLAGS -ansi" ;;
|
|
||||||
esac
|
|
||||||
case " $CFLAGS " in
|
|
||||||
*[\ \ ]-pedantic[\ \ ]*) ;;
|
|
||||||
*) complCFLAGS="$complCFLAGS -pedantic" ;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
AC_MSG_RESULT($complCFLAGS)
|
|
||||||
|
|
||||||
WARN_CFLAGS="$warning_flags $complCFLAGS"
|
|
||||||
AC_SUBST(WARN_CFLAGS)
|
|
||||||
])
|
|
||||||
|
|
||||||
dnl For C++, do basically the same thing.
|
|
||||||
|
|
||||||
AC_DEFUN([GNOME_CXX_WARNINGS],[
|
|
||||||
AC_ARG_ENABLE(cxx-warnings,
|
|
||||||
AC_HELP_STRING([--enable-cxx-warnings=@<:@no/minimum/yes@:>@]
|
|
||||||
[Turn on compiler warnings.]),,
|
|
||||||
[enable_cxx_warnings="m4_default([$1],[minimum])"])
|
|
||||||
|
|
||||||
AC_MSG_CHECKING(what warning flags to pass to the C++ compiler)
|
|
||||||
warnCXXFLAGS=
|
|
||||||
if test "x$GXX" != xyes; then
|
|
||||||
enable_cxx_warnings=no
|
|
||||||
fi
|
|
||||||
if test "x$enable_cxx_warnings" != "xno"; then
|
|
||||||
if test "x$GXX" = "xyes"; then
|
|
||||||
case " $CXXFLAGS " in
|
|
||||||
*[\ \ ]-Wall[\ \ ]*) ;;
|
|
||||||
*) warnCXXFLAGS="-Wall -Wno-unused" ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
## -W is not all that useful. And it cannot be controlled
|
|
||||||
## with individual -Wno-xxx flags, unlike -Wall
|
|
||||||
if test "x$enable_cxx_warnings" = "xyes"; then
|
|
||||||
warnCXXFLAGS="$warnCXXFLAGS -Wshadow -Woverloaded-virtual"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
AC_MSG_RESULT($warnCXXFLAGS)
|
|
||||||
|
|
||||||
AC_ARG_ENABLE(iso-cxx,
|
|
||||||
AC_HELP_STRING([--enable-iso-cxx],
|
|
||||||
[Try to warn if code is not ISO C++ ]),,
|
|
||||||
[enable_iso_cxx=no])
|
|
||||||
|
|
||||||
AC_MSG_CHECKING(what language compliance flags to pass to the C++ compiler)
|
|
||||||
complCXXFLAGS=
|
|
||||||
if test "x$enable_iso_cxx" != "xno"; then
|
|
||||||
if test "x$GXX" = "xyes"; then
|
|
||||||
case " $CXXFLAGS " in
|
|
||||||
*[\ \ ]-ansi[\ \ ]*) ;;
|
|
||||||
*) complCXXFLAGS="$complCXXFLAGS -ansi" ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
case " $CXXFLAGS " in
|
|
||||||
*[\ \ ]-pedantic[\ \ ]*) ;;
|
|
||||||
*) complCXXFLAGS="$complCXXFLAGS -pedantic" ;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
AC_MSG_RESULT($complCXXFLAGS)
|
|
||||||
|
|
||||||
WARN_CXXFLAGS="$CXXFLAGS $warnCXXFLAGS $complCXXFLAGS"
|
|
||||||
AC_SUBST(WARN_CXXFLAGS)
|
|
||||||
])
|
|
||||||
22
autogen.sh
@ -1,22 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
srcdir=`dirname $0`
|
|
||||||
test -z "$srcdir" && srcdir=.
|
|
||||||
|
|
||||||
olddir=`pwd`
|
|
||||||
cd "$srcdir"
|
|
||||||
|
|
||||||
aclocal || exit 1
|
|
||||||
autoheader || exit 1
|
|
||||||
glib-gettextize -f -c || exit 1
|
|
||||||
gtkdocize --copy || exit 1
|
|
||||||
intltoolize -c -f || exit 1
|
|
||||||
libtoolize -c || exit 1
|
|
||||||
autoconf || exit 1
|
|
||||||
automake -a -c || exit 1
|
|
||||||
|
|
||||||
cd "$olddir"
|
|
||||||
|
|
||||||
if test -z "$NOCONFIGURE"; then
|
|
||||||
$srcdir/configure --enable-maintainer-mode $*
|
|
||||||
fi
|
|
||||||
14
config.h.in
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
/* Define to the Gettext package name */
|
||||||
|
#mesondefine GETTEXT_PACKAGE
|
||||||
|
|
||||||
|
/* Version number of package */
|
||||||
|
#mesondefine PACKAGE_VERSION
|
||||||
|
|
||||||
|
/* Where the configuration file will be located */
|
||||||
|
#mesondefine SYSCONFDIR
|
||||||
|
|
||||||
|
/* Define to the version of this package. */
|
||||||
|
#mesondefine VERSION
|
||||||
|
|
||||||
|
/* Whether current polkit version supports autopointers */
|
||||||
|
#mesondefine POLKIT_HAS_AUTOPOINTERS
|
||||||
90
configure.ac
@ -1,90 +0,0 @@
|
|||||||
AC_INIT([fprintd], [0.9.0])
|
|
||||||
AM_INIT_AUTOMAKE([1.11 dist-xz no-dist-gzip check-news])
|
|
||||||
AC_CONFIG_SRCDIR([src/main.c])
|
|
||||||
AC_CONFIG_HEADERS([config.h])
|
|
||||||
|
|
||||||
# Enable silent build when available (Automake 1.11)
|
|
||||||
m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
|
|
||||||
|
|
||||||
AC_PREREQ([2.50])
|
|
||||||
AC_PROG_LIBTOOL
|
|
||||||
AC_PROG_CC
|
|
||||||
AM_PROG_CC_C_O
|
|
||||||
|
|
||||||
GETTEXT_PACKAGE=fprintd
|
|
||||||
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, ["$GETTEXT_PACKAGE"], [Define to the Gettext package name])
|
|
||||||
AC_SUBST(GETTEXT_PACKAGE)
|
|
||||||
AM_GLIB_GNU_GETTEXT
|
|
||||||
IT_PROG_INTLTOOL([0.35.0])
|
|
||||||
|
|
||||||
PKG_CHECK_MODULES(FPRINT, [libfprint > 0.1.0])
|
|
||||||
AC_SUBST(FPRINT_LIBS)
|
|
||||||
AC_SUBST(FPRINT_CFLAGS)
|
|
||||||
|
|
||||||
PKG_CHECK_MODULES(GLIB, glib-2.0 dbus-glib-1)
|
|
||||||
AC_SUBST(GLIB_CFLAGS)
|
|
||||||
AC_SUBST(GLIB_LIBS)
|
|
||||||
|
|
||||||
PKG_CHECK_MODULES(DAEMON, glib-2.0 dbus-glib-1 gmodule-2.0 polkit-gobject-1 >= 0.91 gio-2.0 >= 2.26)
|
|
||||||
AC_SUBST(DAEMON_LIBS)
|
|
||||||
AC_SUBST(DAEMON_CFLAGS)
|
|
||||||
|
|
||||||
AC_ARG_ENABLE(pam, AC_HELP_STRING([--enable-pam],[Build the fprintd PAM module]), enable_pam="$enableval", enable_pam=yes)
|
|
||||||
has_pam=no
|
|
||||||
if test x$enable_pam = xyes; then
|
|
||||||
has_pam=yes
|
|
||||||
AC_CHECK_HEADER([security/pam_modules.h], [has_pam=yes] , [has_pam=no])
|
|
||||||
if test x$has_pam = xyes; then
|
|
||||||
has_pam=no
|
|
||||||
AC_CHECK_LIB(pam, pam_start, [PAM_LIBS="-lpam"
|
|
||||||
has_pam=yes],
|
|
||||||
has_pam=no)
|
|
||||||
fi
|
|
||||||
AC_SUBST(PAM_LIBS)
|
|
||||||
fi
|
|
||||||
AM_CONDITIONAL(HAVE_PAM, test "x$has_pam" = "xyes")
|
|
||||||
|
|
||||||
AC_MSG_CHECKING(for PAM headers and library)
|
|
||||||
AC_MSG_RESULT([$has_pam])
|
|
||||||
|
|
||||||
|
|
||||||
AC_CHECK_PROG([XMLLINT], [xmllint], [xmllint])
|
|
||||||
AC_CHECK_PROG([XSLTPROC], [xsltproc], [xsltproc])
|
|
||||||
AC_CHECK_PROG([POD2MAN], [pod2man], [pod2man])
|
|
||||||
AM_CONDITIONAL(BUILD_MAN, test x"$POD2MAN" != "x")
|
|
||||||
|
|
||||||
GTK_DOC_CHECK([1.3])
|
|
||||||
|
|
||||||
AC_ARG_WITH([systemdsystemunitdir],
|
|
||||||
AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files]),
|
|
||||||
[],
|
|
||||||
[with_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)])
|
|
||||||
AS_IF([test "x$with_systemdsystemunitdir" != "xno"], [
|
|
||||||
# StateDirectory was introduced in systemd 235
|
|
||||||
PKG_CHECK_MODULES(SYSTEMD, systemd >= 235)
|
|
||||||
AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])
|
|
||||||
])
|
|
||||||
AM_CONDITIONAL(HAVE_SYSTEMD, [test -n "$systemdsystemunitdir"])
|
|
||||||
|
|
||||||
AS_AC_EXPAND(DATADIR, $datadir)
|
|
||||||
|
|
||||||
DBUS_SERVICES_DIR="$DATADIR/dbus-1/services"
|
|
||||||
AC_SUBST(DBUS_SERVICES_DIR)
|
|
||||||
AC_DEFINE_UNQUOTED(DBUS_SERVICES_DIR, "$DBUS_SERVICES_DIR", [Where services dir for DBUS is])
|
|
||||||
|
|
||||||
AS_AC_EXPAND(SYSCONFDIR, $sysconfdir)
|
|
||||||
AC_DEFINE_UNQUOTED(SYSCONFDIR, "$SYSCONFDIR", [Where the configuration file will be located])
|
|
||||||
|
|
||||||
GNOME_COMPILE_WARNINGS
|
|
||||||
|
|
||||||
AC_OUTPUT([
|
|
||||||
Makefile
|
|
||||||
src/Makefile
|
|
||||||
data/Makefile
|
|
||||||
tests/Makefile
|
|
||||||
pam/Makefile
|
|
||||||
doc/Makefile
|
|
||||||
doc/version.xml
|
|
||||||
doc/dbus/Makefile
|
|
||||||
po/Makefile.in
|
|
||||||
])
|
|
||||||
@ -1,44 +0,0 @@
|
|||||||
|
|
||||||
dbus_servicesdir = $(datadir)/dbus-1/system-services
|
|
||||||
dbus_services_in_files = net.reactivated.Fprint.service.in
|
|
||||||
dbus_services_DATA = $(dbus_services_in_files:.service.in=.service)
|
|
||||||
|
|
||||||
$(dbus_services_DATA): $(dbus_services_in_files)
|
|
||||||
sed -e "s|\@LIBEXECDIR\@|$(libexecdir)|" $< > $@
|
|
||||||
|
|
||||||
dbus_confdir = $(sysconfdir)/dbus-1/system.d
|
|
||||||
dbus_conf_DATA = net.reactivated.Fprint.conf
|
|
||||||
|
|
||||||
systemdservice_in_files = fprintd.service.in
|
|
||||||
|
|
||||||
if HAVE_SYSTEMD
|
|
||||||
systemdservicedir = $(systemdsystemunitdir)
|
|
||||||
systemdservice_DATA = $(systemdservice_in_files:.service.in=.service)
|
|
||||||
$(systemdservice_DATA): $(systemdservice_in_files) Makefile
|
|
||||||
@sed -e "s|\@libexecdir\@|$(libexecdir)|" $< > $@
|
|
||||||
endif
|
|
||||||
|
|
||||||
polkitdir = $(datadir)/polkit-1/actions
|
|
||||||
polkit_in_files = net.reactivated.fprint.device.policy.in
|
|
||||||
|
|
||||||
@INTLTOOL_POLICY_RULE@
|
|
||||||
polkit_DATA = $(polkit_in_files:.policy.in=.policy)
|
|
||||||
|
|
||||||
confdir = $(sysconfdir)/
|
|
||||||
conf_DATA = fprintd.conf
|
|
||||||
|
|
||||||
man_MANS =
|
|
||||||
|
|
||||||
if BUILD_MAN
|
|
||||||
man_MANS += fprintd.1
|
|
||||||
fprintd.1: fprintd.pod
|
|
||||||
$(AM_V_GEN) pod2man -c "" -s 1 -q none -n fprintd -r freedesktop $< > $@
|
|
||||||
endif
|
|
||||||
|
|
||||||
EXTRA_DIST = $(dbus_services_in_files) $(dbus_conf_DATA) $(polkit_in_files) $(conf_DATA) $(systemdservice_in_files) fprintd.pod
|
|
||||||
CLEANFILES = $(polkit_DATA) $(dbus_services_DATA) $(systemdservice_DATA) fprintd.1
|
|
||||||
|
|
||||||
check:
|
|
||||||
@$(XMLLINT) --noout $(polkit_DATA)
|
|
||||||
|
|
||||||
|
|
||||||
@ -1,4 +1,4 @@
|
|||||||
.\" Automatically generated by Pod::Man 2.23 (Pod::Simple 3.14)
|
.\" Automatically generated by Pod::Man 4.12 (Pod::Simple 3.39)
|
||||||
.\"
|
.\"
|
||||||
.\" Standard preamble:
|
.\" Standard preamble:
|
||||||
.\" ========================================================================
|
.\" ========================================================================
|
||||||
@ -38,27 +38,36 @@
|
|||||||
. ds PI \(*p
|
. ds PI \(*p
|
||||||
. ds L" ``
|
. ds L" ``
|
||||||
. ds R" ''
|
. ds R" ''
|
||||||
|
. ds C`
|
||||||
|
. ds C'
|
||||||
'br\}
|
'br\}
|
||||||
.\"
|
.\"
|
||||||
.\" Escape single quotes in literal strings from groff's Unicode transform.
|
.\" Escape single quotes in literal strings from groff's Unicode transform.
|
||||||
.ie \n(.g .ds Aq \(aq
|
.ie \n(.g .ds Aq \(aq
|
||||||
.el .ds Aq '
|
.el .ds Aq '
|
||||||
.\"
|
.\"
|
||||||
.\" If the F register is turned on, we'll generate index entries on stderr for
|
.\" If the F register is >0, we'll generate index entries on stderr for
|
||||||
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
|
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
|
||||||
.\" entries marked with X<> in POD. Of course, you'll have to process the
|
.\" entries marked with X<> in POD. Of course, you'll have to process the
|
||||||
.\" output yourself in some meaningful fashion.
|
.\" output yourself in some meaningful fashion.
|
||||||
.ie \nF \{\
|
.\"
|
||||||
. de IX
|
.\" Avoid warning from groff about undefined register 'F'.
|
||||||
. tm Index:\\$1\t\\n%\t"\\$2"
|
.de IX
|
||||||
..
|
..
|
||||||
. nr % 0
|
.nr rF 0
|
||||||
. rr F
|
.if \n(.g .if rF .nr rF 1
|
||||||
.\}
|
.if (\n(rF:(\n(.g==0)) \{\
|
||||||
.el \{\
|
. if \nF \{\
|
||||||
. de IX
|
. de IX
|
||||||
|
. tm Index:\\$1\t\\n%\t"\\$2"
|
||||||
..
|
..
|
||||||
|
. if !\nF==2 \{\
|
||||||
|
. nr % 0
|
||||||
|
. nr F 2
|
||||||
|
. \}
|
||||||
|
. \}
|
||||||
.\}
|
.\}
|
||||||
|
.rr rF
|
||||||
.\"
|
.\"
|
||||||
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
|
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
|
||||||
.\" Fear. Run. Save yourself. No user-serviceable parts.
|
.\" Fear. Run. Save yourself. No user-serviceable parts.
|
||||||
@ -124,16 +133,16 @@
|
|||||||
.\" ========================================================================
|
.\" ========================================================================
|
||||||
.\"
|
.\"
|
||||||
.IX Title "fprintd 1"
|
.IX Title "fprintd 1"
|
||||||
.TH fprintd 1 "2010-08-16" "freedesktop" ""
|
.TH fprintd 1 "2020-01-24" "freedesktop" ""
|
||||||
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
|
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
|
||||||
.\" way too many mistakes in technical documents.
|
.\" way too many mistakes in technical documents.
|
||||||
.if n .ad l
|
.if n .ad l
|
||||||
.nh
|
.nh
|
||||||
.SH "NAME"
|
.SH "NAME"
|
||||||
fprintd \- Fingerprint management daemon, and test applications
|
fprintd \- Fingerprint management daemon, and test applications
|
||||||
.SH "SYNOPSYS"
|
.SH "SYNOPSIS"
|
||||||
.IX Header "SYNOPSYS"
|
.IX Header "SYNOPSIS"
|
||||||
\&\fBfprintd-enroll\fR [username]
|
\&\fBfprintd-enroll\fR [\-f finger] [usename]
|
||||||
.PP
|
.PP
|
||||||
\&\fBfprintd-list\fR username [usernames...]
|
\&\fBfprintd-list\fR username [usernames...]
|
||||||
.PP
|
.PP
|
||||||
@ -185,7 +194,7 @@ Will list the user's enrolled fingerprints.
|
|||||||
.SS "fprintd-verify"
|
.SS "fprintd-verify"
|
||||||
.IX Subsection "fprintd-verify"
|
.IX Subsection "fprintd-verify"
|
||||||
.RS 8
|
.RS 8
|
||||||
Will enroll the user's right index finger into the database.
|
Will verify the user's fingerprints against the database.
|
||||||
.RE
|
.RE
|
||||||
.SS "fprintd-enroll"
|
.SS "fprintd-enroll"
|
||||||
.IX Subsection "fprintd-enroll"
|
.IX Subsection "fprintd-enroll"
|
||||||
@ -200,5 +209,5 @@ Will enroll the user's right index finger into the database.
|
|||||||
By default, fprintd stores the fingerprints in \fB/var/lib/fprint/\fR
|
By default, fprintd stores the fingerprints in \fB/var/lib/fprint/\fR
|
||||||
.SH "SEE ALSO"
|
.SH "SEE ALSO"
|
||||||
.IX Header "SEE ALSO"
|
.IX Header "SEE ALSO"
|
||||||
.IP "\fBdbus-daemon\fR, \fBgnome-about-me\fR" 8
|
.IP "\fBgnome-control-center\fR" 8
|
||||||
.IX Item "dbus-daemon, gnome-about-me"
|
.IX Item "gnome-control-center"
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
fprintd - Fingerprint management daemon, and test applications
|
fprintd - Fingerprint management daemon, and test applications
|
||||||
|
|
||||||
=head1 SYNOPSYS
|
=head1 SYNOPSIS
|
||||||
|
|
||||||
B<fprintd-enroll> [-f finger] [usename]
|
B<fprintd-enroll> [-f finger] [usename]
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ Will list the user's enrolled fingerprints.
|
|||||||
|
|
||||||
=over 8
|
=over 8
|
||||||
|
|
||||||
Will enroll the user's right index finger into the database.
|
Will verify the user's fingerprints against the database.
|
||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
@ -99,7 +99,7 @@ By default, fprintd stores the fingerprints in B</var/lib/fprint/>
|
|||||||
|
|
||||||
=over 8
|
=over 8
|
||||||
|
|
||||||
=item B<dbus-daemon>, B<gnome-about-me>
|
=item B<gnome-control-center>
|
||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
|
|||||||
70
data/meson.build
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
install_data('net.reactivated.Fprint.conf',
|
||||||
|
install_dir: dbus_conf_dir)
|
||||||
|
|
||||||
|
configure_file(
|
||||||
|
configuration: configuration_data({
|
||||||
|
'LIBEXECDIR': fprintd_installdir,
|
||||||
|
}),
|
||||||
|
input: 'net.reactivated.Fprint.service.in',
|
||||||
|
output: 'net.reactivated.Fprint.service',
|
||||||
|
install: true,
|
||||||
|
install_dir: dbus_service_dir,
|
||||||
|
)
|
||||||
|
|
||||||
|
configure_file(
|
||||||
|
configuration: configuration_data({
|
||||||
|
'libexecdir': fprintd_installdir,
|
||||||
|
}),
|
||||||
|
input: 'fprintd.service.in',
|
||||||
|
output: 'fprintd.service',
|
||||||
|
install: true,
|
||||||
|
install_dir: systemd_unit_dir,
|
||||||
|
)
|
||||||
|
|
||||||
|
polkit_policy = 'net.reactivated.fprint.device.policy'
|
||||||
|
polkit_policy_target = i18n.merge_file(polkit_policy,
|
||||||
|
input: '@0@.in'.format(polkit_policy),
|
||||||
|
output: polkit_policy,
|
||||||
|
po_dir: meson.source_root() / 'po',
|
||||||
|
install: true,
|
||||||
|
install_dir: polkit_policy_directory,
|
||||||
|
)
|
||||||
|
|
||||||
|
if xmllint.found()
|
||||||
|
test(polkit_policy,
|
||||||
|
xmllint,
|
||||||
|
depends: polkit_policy_target,
|
||||||
|
args: [
|
||||||
|
'--noout',
|
||||||
|
polkit_policy_target.full_path(),
|
||||||
|
])
|
||||||
|
endif
|
||||||
|
|
||||||
|
install_data('fprintd.conf',
|
||||||
|
install_dir: sysconfdir)
|
||||||
|
|
||||||
|
if get_option('man')
|
||||||
|
manfiles = {
|
||||||
|
'fprintd': 1,
|
||||||
|
'pam_fprintd': 8,
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach man_name, man_section: manfiles
|
||||||
|
custom_target('man_' + man_name + '.' + man_section.to_string(),
|
||||||
|
input: man_name + '.pod',
|
||||||
|
output: man_name + '.' + man_section.to_string(),
|
||||||
|
command: [
|
||||||
|
pod2man,
|
||||||
|
'-c', '',
|
||||||
|
'-s', man_section.to_string(),
|
||||||
|
'-q', 'none',
|
||||||
|
'-n', man_name,
|
||||||
|
'-r', 'freedesktop',
|
||||||
|
'@INPUT@',
|
||||||
|
'@OUTPUT@',
|
||||||
|
],
|
||||||
|
install: true,
|
||||||
|
install_dir: datadir / 'man' / 'man' + man_section.to_string(),
|
||||||
|
)
|
||||||
|
endforeach
|
||||||
|
endif
|
||||||
@ -12,8 +12,18 @@
|
|||||||
|
|
||||||
<!-- Anyone can talk to the service -->
|
<!-- Anyone can talk to the service -->
|
||||||
<policy context="default">
|
<policy context="default">
|
||||||
<allow send_destination="net.reactivated.Fprint"/>
|
<allow send_destination="net.reactivated.Fprint"
|
||||||
<allow send_interface="net.reactivated.Fprint"/>
|
send_interface="net.reactivated.Fprint.Manager"/>
|
||||||
|
<allow send_destination="net.reactivated.Fprint"
|
||||||
|
send_interface="net.reactivated.Fprint.Device"/>
|
||||||
|
|
||||||
|
<!-- Basic D-Bus API stuff -->
|
||||||
|
<allow send_destination="net.reactivated.Fprint"
|
||||||
|
send_interface="org.freedesktop.DBus.Introspectable"/>
|
||||||
|
<allow send_destination="net.reactivated.Fprint"
|
||||||
|
send_interface="org.freedesktop.DBus.Properties"/>
|
||||||
|
<allow send_destination="net.reactivated.Fprint"
|
||||||
|
send_interface="org.freedesktop.DBus.ObjectManager"/>
|
||||||
</policy>
|
</policy>
|
||||||
|
|
||||||
</busconfig>
|
</busconfig>
|
||||||
|
|||||||
@ -10,8 +10,8 @@
|
|||||||
<icon_name>fprint</icon_name>
|
<icon_name>fprint</icon_name>
|
||||||
|
|
||||||
<action id="net.reactivated.fprint.device.verify">
|
<action id="net.reactivated.fprint.device.verify">
|
||||||
<_description>Verify a fingerprint</_description>
|
<description>Verify a fingerprint</description>
|
||||||
<_message>Privileges are required to verify fingerprints.</_message>
|
<message>Privileges are required to verify fingerprints.</message>
|
||||||
<defaults>
|
<defaults>
|
||||||
<allow_any>no</allow_any>
|
<allow_any>no</allow_any>
|
||||||
<allow_inactive>no</allow_inactive>
|
<allow_inactive>no</allow_inactive>
|
||||||
@ -20,18 +20,18 @@
|
|||||||
</action>
|
</action>
|
||||||
|
|
||||||
<action id="net.reactivated.fprint.device.enroll">
|
<action id="net.reactivated.fprint.device.enroll">
|
||||||
<_description>Enroll new fingerprints</_description>
|
<description>Enroll new fingerprints</description>
|
||||||
<_message>Privileges are required to enroll new fingerprints.</_message>
|
<message>Privileges are required to enroll new fingerprints.</message>
|
||||||
<defaults>
|
<defaults>
|
||||||
<allow_any>no</allow_any>
|
<allow_any>no</allow_any>
|
||||||
<allow_inactive>no</allow_inactive>
|
<allow_inactive>no</allow_inactive>
|
||||||
<allow_active>yes</allow_active>
|
<allow_active>auth_self_keep</allow_active>
|
||||||
</defaults>
|
</defaults>
|
||||||
</action>
|
</action>
|
||||||
|
|
||||||
<action id="net.reactivated.fprint.device.setusername">
|
<action id="net.reactivated.fprint.device.setusername">
|
||||||
<_description>Select a user to enroll</_description>
|
<description>Select a user to enroll</description>
|
||||||
<_message>Privileges are required to enroll new fingerprints for other users.</_message>
|
<message>Privileges are required to enroll new fingerprints for other users.</message>
|
||||||
<defaults>
|
<defaults>
|
||||||
<allow_any>no</allow_any>
|
<allow_any>no</allow_any>
|
||||||
<allow_inactive>no</allow_inactive>
|
<allow_inactive>no</allow_inactive>
|
||||||
|
|||||||
184
data/pam_fprintd.8
Normal file
@ -0,0 +1,184 @@
|
|||||||
|
.\" Automatically generated by Pod::Man 4.12 (Pod::Simple 3.39)
|
||||||
|
.\"
|
||||||
|
.\" Standard preamble:
|
||||||
|
.\" ========================================================================
|
||||||
|
.de Sp \" Vertical space (when we can't use .PP)
|
||||||
|
.if t .sp .5v
|
||||||
|
.if n .sp
|
||||||
|
..
|
||||||
|
.de Vb \" Begin verbatim text
|
||||||
|
.ft CW
|
||||||
|
.nf
|
||||||
|
.ne \\$1
|
||||||
|
..
|
||||||
|
.de Ve \" End verbatim text
|
||||||
|
.ft R
|
||||||
|
.fi
|
||||||
|
..
|
||||||
|
.\" Set up some character translations and predefined strings. \*(-- will
|
||||||
|
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
|
||||||
|
.\" double quote, and \*(R" will give a right double quote. \*(C+ will
|
||||||
|
.\" give a nicer C++. Capital omega is used to do unbreakable dashes and
|
||||||
|
.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
|
||||||
|
.\" nothing in troff, for use with C<>.
|
||||||
|
.tr \(*W-
|
||||||
|
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
|
||||||
|
.ie n \{\
|
||||||
|
. ds -- \(*W-
|
||||||
|
. ds PI pi
|
||||||
|
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
|
||||||
|
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
|
||||||
|
. ds L" ""
|
||||||
|
. ds R" ""
|
||||||
|
. ds C`
|
||||||
|
. ds C'
|
||||||
|
'br\}
|
||||||
|
.el\{\
|
||||||
|
. ds -- \|\(em\|
|
||||||
|
. ds PI \(*p
|
||||||
|
. ds L" ``
|
||||||
|
. ds R" ''
|
||||||
|
. ds C`
|
||||||
|
. ds C'
|
||||||
|
'br\}
|
||||||
|
.\"
|
||||||
|
.\" Escape single quotes in literal strings from groff's Unicode transform.
|
||||||
|
.ie \n(.g .ds Aq \(aq
|
||||||
|
.el .ds Aq '
|
||||||
|
.\"
|
||||||
|
.\" If the F register is >0, we'll generate index entries on stderr for
|
||||||
|
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
|
||||||
|
.\" entries marked with X<> in POD. Of course, you'll have to process the
|
||||||
|
.\" output yourself in some meaningful fashion.
|
||||||
|
.\"
|
||||||
|
.\" Avoid warning from groff about undefined register 'F'.
|
||||||
|
.de IX
|
||||||
|
..
|
||||||
|
.nr rF 0
|
||||||
|
.if \n(.g .if rF .nr rF 1
|
||||||
|
.if (\n(rF:(\n(.g==0)) \{\
|
||||||
|
. if \nF \{\
|
||||||
|
. de IX
|
||||||
|
. tm Index:\\$1\t\\n%\t"\\$2"
|
||||||
|
..
|
||||||
|
. if !\nF==2 \{\
|
||||||
|
. nr % 0
|
||||||
|
. nr F 2
|
||||||
|
. \}
|
||||||
|
. \}
|
||||||
|
.\}
|
||||||
|
.rr rF
|
||||||
|
.\"
|
||||||
|
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
|
||||||
|
.\" Fear. Run. Save yourself. No user-serviceable parts.
|
||||||
|
. \" fudge factors for nroff and troff
|
||||||
|
.if n \{\
|
||||||
|
. ds #H 0
|
||||||
|
. ds #V .8m
|
||||||
|
. ds #F .3m
|
||||||
|
. ds #[ \f1
|
||||||
|
. ds #] \fP
|
||||||
|
.\}
|
||||||
|
.if t \{\
|
||||||
|
. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
|
||||||
|
. ds #V .6m
|
||||||
|
. ds #F 0
|
||||||
|
. ds #[ \&
|
||||||
|
. ds #] \&
|
||||||
|
.\}
|
||||||
|
. \" simple accents for nroff and troff
|
||||||
|
.if n \{\
|
||||||
|
. ds ' \&
|
||||||
|
. ds ` \&
|
||||||
|
. ds ^ \&
|
||||||
|
. ds , \&
|
||||||
|
. ds ~ ~
|
||||||
|
. ds /
|
||||||
|
.\}
|
||||||
|
.if t \{\
|
||||||
|
. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
|
||||||
|
. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
|
||||||
|
. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
|
||||||
|
. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
|
||||||
|
. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
|
||||||
|
. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
|
||||||
|
.\}
|
||||||
|
. \" troff and (daisy-wheel) nroff accents
|
||||||
|
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
|
||||||
|
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
|
||||||
|
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
|
||||||
|
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
|
||||||
|
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
|
||||||
|
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
|
||||||
|
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
|
||||||
|
.ds ae a\h'-(\w'a'u*4/10)'e
|
||||||
|
.ds Ae A\h'-(\w'A'u*4/10)'E
|
||||||
|
. \" corrections for vroff
|
||||||
|
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
|
||||||
|
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
|
||||||
|
. \" for low resolution devices (crt and lpr)
|
||||||
|
.if \n(.H>23 .if \n(.V>19 \
|
||||||
|
\{\
|
||||||
|
. ds : e
|
||||||
|
. ds 8 ss
|
||||||
|
. ds o a
|
||||||
|
. ds d- d\h'-1'\(ga
|
||||||
|
. ds D- D\h'-1'\(hy
|
||||||
|
. ds th \o'bp'
|
||||||
|
. ds Th \o'LP'
|
||||||
|
. ds ae ae
|
||||||
|
. ds Ae AE
|
||||||
|
.\}
|
||||||
|
.rm #[ #] #H #V #F C
|
||||||
|
.\" ========================================================================
|
||||||
|
.\"
|
||||||
|
.IX Title "pam_fprintd 8"
|
||||||
|
.TH pam_fprintd 8 "2020-01-24" "freedesktop" ""
|
||||||
|
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
|
||||||
|
.\" way too many mistakes in technical documents.
|
||||||
|
.if n .ad l
|
||||||
|
.nh
|
||||||
|
.SH "NAME"
|
||||||
|
pam_fprintd \- PAM module to authenticate against fprintd, the fingerprint daemon
|
||||||
|
.SH "SYNOPSIS"
|
||||||
|
.IX Header "SYNOPSIS"
|
||||||
|
\&\fBpam_fprintd.so\fR [debug|debug=[\fIon\fR|\fIoff\fR|\fItrue\fR|\fIfalse\fR|\fI1\fR|\fI0\fR]] [max\-tries=\fI\s-1MAX_TRIES\s0\fR] [timeout=\fI\s-1TIMEOUT\s0\fR]
|
||||||
|
.SH "DESCRIPTION"
|
||||||
|
.IX Header "DESCRIPTION"
|
||||||
|
The pam_fprintd module is used to verify a user's fingerprints against fingerprints
|
||||||
|
enrolled using fprintd, the fingerprint management daemon.
|
||||||
|
.SH "OPTIONS"
|
||||||
|
.IX Header "OPTIONS"
|
||||||
|
.IP "\fBdebug\fR" 8
|
||||||
|
.IX Item "debug"
|
||||||
|
.PD 0
|
||||||
|
.IP "\fBdebug=[\f(BIon\fB|\f(BIoff\fB|\f(BItrue\fB|\f(BIfalse\fB|\f(BI1\fB|\f(BI0\fB]\fR" 8
|
||||||
|
.IX Item "debug=[on|off|true|false|1|0]"
|
||||||
|
.PD
|
||||||
|
Whether debug should be turned on or off. Debug messages will be generated using
|
||||||
|
pam_syslog which means that they will be saved in the systemd journal by default.
|
||||||
|
.IP "\fBmax\-tries=\f(BI\s-1MAX_TRIES\s0\fB\fR" 8
|
||||||
|
.IX Item "max-tries=MAX_TRIES"
|
||||||
|
The number of attempts at fingerprint authentication to try before returning an
|
||||||
|
authentication failure. The minimum, and default, number of tries is 3.
|
||||||
|
.IP "\fBtimeout=\f(BI\s-1TIMEOUT\s0\fB\fR" 8
|
||||||
|
.IX Item "timeout=TIMEOUT"
|
||||||
|
The amount of time before returning an authentication failure. The default timeout
|
||||||
|
is 30 seconds, with 10 seconds being the minimum.
|
||||||
|
.SH "LIMITATIONS"
|
||||||
|
.IX Header "LIMITATIONS"
|
||||||
|
The \s-1PAM\s0 stack is by design a serialised authentication, so it is not
|
||||||
|
possible for pam_fprintd to allow authentication through passwords and
|
||||||
|
fingerprints at the same time.
|
||||||
|
.PP
|
||||||
|
It is up to the application using the \s-1PAM\s0 services to implement separate
|
||||||
|
\&\s-1PAM\s0 processes and run separate authentication stacks separately. This
|
||||||
|
is the way multiple authentication methods are made available to users
|
||||||
|
of gdm for example.
|
||||||
|
.SH "AUTHOR"
|
||||||
|
.IX Header "AUTHOR"
|
||||||
|
\&\fBfprintd\fR was written by Bastien Nocera.
|
||||||
|
.SH "SEE ALSO"
|
||||||
|
.IX Header "SEE ALSO"
|
||||||
|
.IP "\fBfprintd\fR, \fB\s-1PAM\s0\fR" 8
|
||||||
|
.IX Item "fprintd, PAM"
|
||||||
63
data/pam_fprintd.pod
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
=head1 NAME
|
||||||
|
|
||||||
|
pam_fprintd - PAM module to authenticate against fprintd, the fingerprint daemon
|
||||||
|
|
||||||
|
=head1 SYNOPSIS
|
||||||
|
|
||||||
|
B<pam_fprintd.so> [debug|debug=[I<on>|I<off>|I<true>|I<false>|I<1>|I<0>]] [max-tries=I<MAX_TRIES>] [timeout=I<TIMEOUT>]
|
||||||
|
|
||||||
|
=head1 DESCRIPTION
|
||||||
|
|
||||||
|
The pam_fprintd module is used to verify a user's fingerprints against fingerprints
|
||||||
|
enrolled using fprintd, the fingerprint management daemon.
|
||||||
|
|
||||||
|
=head1 OPTIONS
|
||||||
|
|
||||||
|
=over 8
|
||||||
|
|
||||||
|
=item B<debug>
|
||||||
|
|
||||||
|
=item B<debug=[I<on>|I<off>|I<true>|I<false>|I<1>|I<0>]>
|
||||||
|
|
||||||
|
Whether debug should be turned on or off. Debug messages will be generated using
|
||||||
|
pam_syslog which means that they will be saved in the systemd journal by default.
|
||||||
|
|
||||||
|
=item B<max-tries=I<MAX_TRIES>>
|
||||||
|
|
||||||
|
The number of attempts at fingerprint authentication to try before returning an
|
||||||
|
authentication failure. The minimum, and default, number of tries is 3.
|
||||||
|
|
||||||
|
=item B<timeout=I<TIMEOUT>>
|
||||||
|
|
||||||
|
The amount of time before returning an authentication failure. The default timeout
|
||||||
|
is 30 seconds, with 10 seconds being the minimum.
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
=head1 LIMITATIONS
|
||||||
|
|
||||||
|
=over 8
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
The PAM stack is by design a serialised authentication, so it is not
|
||||||
|
possible for pam_fprintd to allow authentication through passwords and
|
||||||
|
fingerprints at the same time.
|
||||||
|
|
||||||
|
It is up to the application using the PAM services to implement separate
|
||||||
|
PAM processes and run separate authentication stacks separately. This
|
||||||
|
is the way multiple authentication methods are made available to users
|
||||||
|
of gdm for example.
|
||||||
|
|
||||||
|
=head1 AUTHOR
|
||||||
|
|
||||||
|
B<fprintd> was written by Bastien Nocera.
|
||||||
|
|
||||||
|
=head1 SEE ALSO
|
||||||
|
|
||||||
|
=over 8
|
||||||
|
|
||||||
|
=item B<fprintd>, B<PAM>
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
@ -1,81 +0,0 @@
|
|||||||
|
|
||||||
SUBDIRS = dbus
|
|
||||||
|
|
||||||
NULL =
|
|
||||||
|
|
||||||
AUTOMAKE_OPTIONS = 1.7
|
|
||||||
|
|
||||||
# The name of the module.
|
|
||||||
DOC_MODULE=fprintd
|
|
||||||
|
|
||||||
# The top-level SGML file.
|
|
||||||
DOC_MAIN_SGML_FILE=fprintd-docs.xml
|
|
||||||
|
|
||||||
# Extra options to supply to gtkdoc-scan
|
|
||||||
SCAN_OPTIONS=--ignore-headers=config.h
|
|
||||||
|
|
||||||
# The directory containing the source code. Relative to $(srcdir)
|
|
||||||
DOC_SOURCE_DIR=../src
|
|
||||||
|
|
||||||
# Used for dependencies
|
|
||||||
HFILE_GLOB=
|
|
||||||
#$(top_srcdir)/policy/*.h
|
|
||||||
CFILE_GLOB=
|
|
||||||
#$(top_srcdir)/policy/*.c
|
|
||||||
|
|
||||||
# Headers to ignore
|
|
||||||
IGNORE_HFILES= \
|
|
||||||
$(NULL)
|
|
||||||
|
|
||||||
# CFLAGS and LDFLAGS for compiling scan program. Only needed
|
|
||||||
# if $(DOC_MODULE).types is non-empty.
|
|
||||||
INCLUDES = \
|
|
||||||
$(GLIB_CFLAGS) \
|
|
||||||
-I$(top_srcdir)/src \
|
|
||||||
$(NULL)
|
|
||||||
|
|
||||||
GTKDOC_LIBS = \
|
|
||||||
$(GLIB_LIBS) \
|
|
||||||
$(top_builddir)/src/libfprintd.la \
|
|
||||||
$(NULL)
|
|
||||||
|
|
||||||
# Extra options to supply to gtkdoc-mkdb
|
|
||||||
MKDB_OPTIONS=--sgml-mode --output-format=xml
|
|
||||||
|
|
||||||
# Extra options to supply to gtkdoc-mktmpl
|
|
||||||
MKTMPL_OPTIONS=
|
|
||||||
|
|
||||||
# Non-autogenerated SGML files to be included in $(DOC_MAIN_SGML_FILE)
|
|
||||||
content_files = \
|
|
||||||
version.xml \
|
|
||||||
dbus/net.reactivated.Fprint.Manager.ref.xml \
|
|
||||||
dbus/net.reactivated.Fprint.Device.ref.xml \
|
|
||||||
$(NULL)
|
|
||||||
|
|
||||||
# Images to copy into HTML directory
|
|
||||||
HTML_IMAGES = \
|
|
||||||
$(NULL)
|
|
||||||
|
|
||||||
# Extra options to supply to gtkdoc-fixref
|
|
||||||
FIXXREF_OPTIONS=
|
|
||||||
|
|
||||||
DISTCLEANFILES = \
|
|
||||||
net.reactivated.Fprint.Manager.ref.xml \
|
|
||||||
net.reactivated.Fprint.Device.ref.xml
|
|
||||||
|
|
||||||
MAINTAINERCLEANFILES = \
|
|
||||||
*~ \
|
|
||||||
Makefile.in \
|
|
||||||
fprintd.types \
|
|
||||||
fprintd-*.txt \
|
|
||||||
$(NULL)
|
|
||||||
|
|
||||||
if ENABLE_GTK_DOC
|
|
||||||
include $(top_srcdir)/gtk-doc.make
|
|
||||||
else
|
|
||||||
EXTRA_DIST = fprintd-docs.xml
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Version information for marking the documentation
|
|
||||||
EXTRA_DIST += version.xml.in
|
|
||||||
|
|
||||||
@ -1,15 +0,0 @@
|
|||||||
|
|
||||||
noinst_DATA = net.reactivated.Fprint.Manager.ref.xml net.reactivated.Fprint.Device.ref.xml
|
|
||||||
|
|
||||||
net.reactivated.Fprint.Manager.ref.xml : $(top_srcdir)/src/manager.xml $(top_srcdir)/doc/dbus/spec-to-docbook.xsl
|
|
||||||
echo "<?xml version=\"1.0\"?>""<!DOCTYPE refentry PUBLIC \"-//OASIS//DTD DocBook XML V4.1.2//EN\" \"http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd\">" > $@
|
|
||||||
$(XSLTPROC) $(top_srcdir)/doc/dbus/spec-to-docbook.xsl $< | tail -n +2 >> $@
|
|
||||||
|
|
||||||
net.reactivated.Fprint.Device.ref.xml : $(top_srcdir)/src/device.xml $(top_srcdir)/doc/dbus/spec-to-docbook.xsl
|
|
||||||
echo "<?xml version=\"1.0\"?>""<!DOCTYPE refentry PUBLIC \"-//OASIS//DTD DocBook XML V4.1.2//EN\" \"http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd\">" > $@
|
|
||||||
$(XSLTPROC) $(top_srcdir)/doc/dbus/spec-to-docbook.xsl $< | tail -n +2 >> $@
|
|
||||||
|
|
||||||
EXTRA_DIST = spec-to-docbook.xsl dbus-introspect-docs.dtd
|
|
||||||
|
|
||||||
clean-local :
|
|
||||||
rm -f *~ *.ref.xml
|
|
||||||
29
doc/dbus/meson.build
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
docbook_xml_header = custom_target('docbook_xml_header',
|
||||||
|
output: 'docbook-xml-header.xml',
|
||||||
|
command: [
|
||||||
|
'echo', '-n',
|
||||||
|
'<?xml version="1.0"?>\n',
|
||||||
|
'<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">\n',
|
||||||
|
],
|
||||||
|
capture: true,
|
||||||
|
)
|
||||||
|
|
||||||
|
dbus_interfaces_refs = []
|
||||||
|
foreach interface_file: dbus_interfaces_files
|
||||||
|
basename = run_command('basename', interface_file.full_path(), '.xml').stdout().strip()
|
||||||
|
dbus_interfaces_refs += custom_target(basename + '_ref',
|
||||||
|
input: docbook_xml_header,
|
||||||
|
output: basename + '.ref.xml',
|
||||||
|
build_by_default: true,
|
||||||
|
depends: interface_file,
|
||||||
|
capture: true,
|
||||||
|
command: [
|
||||||
|
bash, '-c',
|
||||||
|
'cat @INPUT@;' +
|
||||||
|
xsltproc.path() + ' @0@/@1@ '.format(
|
||||||
|
meson.source_root(),
|
||||||
|
files('spec-to-docbook.xsl')[0]) +
|
||||||
|
interface_file.full_path() + '| tail -n +2;',
|
||||||
|
],
|
||||||
|
)
|
||||||
|
endforeach
|
||||||
27
doc/meson.build
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
subdir('dbus')
|
||||||
|
|
||||||
|
version_file = configure_file(
|
||||||
|
input: 'version.xml.in',
|
||||||
|
output: 'version.xml',
|
||||||
|
configuration: configuration_data({
|
||||||
|
'VERSION': meson.project_version(),
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
|
||||||
|
gnome.gtkdoc(meson.project_name(),
|
||||||
|
main_xml: 'fprintd-docs.xml',
|
||||||
|
src_dir: meson.source_root() / 'src',
|
||||||
|
dependencies: [
|
||||||
|
declare_dependency(
|
||||||
|
sources: dbus_interfaces_refs,
|
||||||
|
link_with: libfprintd_private,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
content_files: [
|
||||||
|
version_file,
|
||||||
|
dbus_interfaces_refs,
|
||||||
|
],
|
||||||
|
ignore_headers: [
|
||||||
|
'config.h',
|
||||||
|
],
|
||||||
|
install: true)
|
||||||
196
git.mk
@ -1,196 +0,0 @@
|
|||||||
# git.mk
|
|
||||||
#
|
|
||||||
# Copyright 2009, Red Hat, Inc.
|
|
||||||
# Written by Behdad Esfahbod
|
|
||||||
#
|
|
||||||
# Copying and distribution of this file, with or without modification,
|
|
||||||
# are permitted in any medium without royalty provided the copyright
|
|
||||||
# notice and this notice are preserved.
|
|
||||||
#
|
|
||||||
# The canonical source for this file is pango/git.mk, or whereever the
|
|
||||||
# header of pango/git.mk suggests in the future.
|
|
||||||
#
|
|
||||||
# To use in your project, import this file in your git repo's toplevel,
|
|
||||||
# then do "make -f git.mk". This modifies all Makefile.am files in
|
|
||||||
# your project to include git.mk.
|
|
||||||
#
|
|
||||||
# This enables automatic .gitignore generation. If you need to ignore
|
|
||||||
# more files, add them to the GITIGNOREFILES variable in your Makefile.am.
|
|
||||||
# But think twice before doing that. If a file has to be in .gitignore,
|
|
||||||
# chances are very high that it's a generated file and should be in one
|
|
||||||
# of MOSTLYCLEANFILES, CLEANFILES, DISTCLEANFILES, or MAINTAINERCLEANFILES.
|
|
||||||
#
|
|
||||||
# The only case that you need to manually add a file to GITIGNOREFILES is
|
|
||||||
# when remove files in one of mostlyclean-local, clean-local, distclean-local,
|
|
||||||
# or maintainer-clean-local.
|
|
||||||
#
|
|
||||||
# Note that for files like editor backup, etc, there are better places to
|
|
||||||
# ignore them. See "man gitignore".
|
|
||||||
#
|
|
||||||
# If "make maintainer-clean" removes the files but they are not recognized
|
|
||||||
# by this script (that is, if "git status" shows untracked files still), send
|
|
||||||
# me the output of "git status" as well as your Makefile.am and Makefile for
|
|
||||||
# the directories involved.
|
|
||||||
#
|
|
||||||
# For a list of toplevel files that should be in MAINTAINERCLEANFILES, see
|
|
||||||
# pango/Makefile.am.
|
|
||||||
#
|
|
||||||
# Don't EXTRA_DIST this file. It is supposed to only live in git clones,
|
|
||||||
# not tarballs. It serves no useful purpose in tarballs and clutters the
|
|
||||||
# build dir.
|
|
||||||
#
|
|
||||||
# This file knows how to handle autoconf, automake, libtool, gtk-doc,
|
|
||||||
# gnome-doc-utils, intltool, GSettings.
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# KNOWN ISSUES:
|
|
||||||
#
|
|
||||||
# - Recursive configure doesn't work as $(top_srcdir)/git.mk inside the
|
|
||||||
# submodule doesn't find us. If you have configure.{in,ac} files in
|
|
||||||
# subdirs, add a proxy git.mk file in those dirs that simply does:
|
|
||||||
# "include $(top_srcdir)/../git.mk". Add more ..'s to your taste.
|
|
||||||
# And add those files to git. See vte/gnome-pty-helper/git.mk for
|
|
||||||
# example.
|
|
||||||
#
|
|
||||||
|
|
||||||
git-all: git-mk-install
|
|
||||||
|
|
||||||
git-mk-install:
|
|
||||||
@echo Installing git makefile
|
|
||||||
@any_failed=; find $(top_srcdir) -name Makefile.am | while read x; do \
|
|
||||||
if grep 'include .*/git.mk' $$x >/dev/null; then \
|
|
||||||
echo $$x already includes git.mk; \
|
|
||||||
else \
|
|
||||||
failed=; \
|
|
||||||
echo "Updating $$x"; \
|
|
||||||
{ cat $$x; \
|
|
||||||
echo ''; \
|
|
||||||
echo '-include $$(top_srcdir)/git.mk'; \
|
|
||||||
} > $$x.tmp || failed=1; \
|
|
||||||
if test x$$failed = x; then \
|
|
||||||
mv $$x.tmp $$x || failed=1; \
|
|
||||||
fi; \
|
|
||||||
if test x$$failed = x; then : else \
|
|
||||||
echo Failed updating $$x; >&2 \
|
|
||||||
any_failed=1; \
|
|
||||||
fi; \
|
|
||||||
fi; done; test -z "$$any_failed"
|
|
||||||
|
|
||||||
.PHONY: git-all git-mk-install
|
|
||||||
|
|
||||||
|
|
||||||
### .gitignore generation
|
|
||||||
|
|
||||||
$(srcdir)/.gitignore: Makefile.am $(top_srcdir)/git.mk
|
|
||||||
$(AM_V_GEN) \
|
|
||||||
{ \
|
|
||||||
if test "x$(DOC_MODULE)" = x -o "x$(DOC_MAIN_SGML_FILE)" = x; then :; else \
|
|
||||||
for x in \
|
|
||||||
$(DOC_MODULE)-decl-list.txt \
|
|
||||||
$(DOC_MODULE)-decl.txt \
|
|
||||||
tmpl/$(DOC_MODULE)-unused.sgml \
|
|
||||||
"tmpl/*.bak" \
|
|
||||||
xml html \
|
|
||||||
; do echo /$$x; done; \
|
|
||||||
fi; \
|
|
||||||
if test "x$(DOC_MODULE)" = x -o "x$(DOC_LINGUAS)" = x; then :; else \
|
|
||||||
for x in \
|
|
||||||
$(_DOC_C_DOCS) \
|
|
||||||
$(_DOC_LC_DOCS) \
|
|
||||||
$(_DOC_OMF_ALL) \
|
|
||||||
$(_DOC_DSK_ALL) \
|
|
||||||
$(_DOC_HTML_ALL) \
|
|
||||||
$(_DOC_POFILES) \
|
|
||||||
$(_DOC_MOFILES) \
|
|
||||||
$(DOC_H_FILE) \
|
|
||||||
"*/.xml2po.mo" \
|
|
||||||
"*/*.omf.out" \
|
|
||||||
; do echo /$$x; done; \
|
|
||||||
fi; \
|
|
||||||
if test "x$(gsettings_SCHEMAS)" = x; then :; else \
|
|
||||||
for x in \
|
|
||||||
$(gsettings_SCHEMAS:.xml=.valid) \
|
|
||||||
$(gsettings__enum_file) \
|
|
||||||
; do echo /$$x; done; \
|
|
||||||
fi; \
|
|
||||||
if test -f $(srcdir)/po/Makefile.in.in; then \
|
|
||||||
for x in \
|
|
||||||
po/Makefile.in.in \
|
|
||||||
po/Makefile.in \
|
|
||||||
po/Makefile \
|
|
||||||
po/POTFILES \
|
|
||||||
po/stamp-it \
|
|
||||||
po/.intltool-merge-cache \
|
|
||||||
"po/*.gmo" \
|
|
||||||
"po/*.mo" \
|
|
||||||
po/$(GETTEXT_PACKAGE).pot \
|
|
||||||
intltool-extract.in \
|
|
||||||
intltool-merge.in \
|
|
||||||
intltool-update.in \
|
|
||||||
; do echo /$$x; done; \
|
|
||||||
fi; \
|
|
||||||
if test -f $(srcdir)/configure; then \
|
|
||||||
for x in \
|
|
||||||
autom4te.cache \
|
|
||||||
configure \
|
|
||||||
config.h \
|
|
||||||
stamp-h1 \
|
|
||||||
libtool \
|
|
||||||
config.lt \
|
|
||||||
; do echo /$$x; done; \
|
|
||||||
fi; \
|
|
||||||
for x in \
|
|
||||||
.gitignore \
|
|
||||||
$(GITIGNOREFILES) \
|
|
||||||
$(CLEANFILES) \
|
|
||||||
$(PROGRAMS) \
|
|
||||||
$(check_PROGRAMS) \
|
|
||||||
$(EXTRA_PROGRAMS) \
|
|
||||||
$(LTLIBRARIES) \
|
|
||||||
so_locations \
|
|
||||||
.libs _libs \
|
|
||||||
$(MOSTLYCLEANFILES) \
|
|
||||||
"*.$(OBJEXT)" \
|
|
||||||
"*.lo" \
|
|
||||||
$(DISTCLEANFILES) \
|
|
||||||
$(am__CONFIG_DISTCLEAN_FILES) \
|
|
||||||
$(CONFIG_CLEAN_FILES) \
|
|
||||||
TAGS ID GTAGS GRTAGS GSYMS GPATH tags \
|
|
||||||
"*.tab.c" \
|
|
||||||
$(MAINTAINERCLEANFILES) \
|
|
||||||
$(BUILT_SOURCES) \
|
|
||||||
$(DEPDIR) \
|
|
||||||
Makefile \
|
|
||||||
Makefile.in \
|
|
||||||
"*.orig" \
|
|
||||||
"*.rej" \
|
|
||||||
"*.bak" \
|
|
||||||
"*~" \
|
|
||||||
".*.sw[nop]" \
|
|
||||||
".dirstamp" \
|
|
||||||
; do echo /$$x; done; \
|
|
||||||
} | \
|
|
||||||
sed "s@^/`echo "$(srcdir)" | sed 's/\(.\)/[\1]/g'`/@/@" | \
|
|
||||||
sed 's@/[.]/@/@g' | \
|
|
||||||
LC_ALL=C sort | uniq > $@.tmp && \
|
|
||||||
mv $@.tmp $@;
|
|
||||||
|
|
||||||
all: $(srcdir)/.gitignore gitignore-recurse-maybe
|
|
||||||
gitignore-recurse-maybe:
|
|
||||||
@if test "x$(SUBDIRS)" = "x$(DIST_SUBDIRS)"; then :; else \
|
|
||||||
$(MAKE) $(AM_MAKEFLAGS) gitignore-recurse; \
|
|
||||||
fi;
|
|
||||||
gitignore-recurse:
|
|
||||||
@for subdir in $(DIST_SUBDIRS); do \
|
|
||||||
case " $(SUBDIRS) " in \
|
|
||||||
*" $$subdir "*) :;; \
|
|
||||||
*) test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) .gitignore gitignore-recurse || echo "Skipping $$subdir");; \
|
|
||||||
esac; \
|
|
||||||
done
|
|
||||||
gitignore: $(srcdir)/.gitignore gitignore-recurse
|
|
||||||
|
|
||||||
maintainer-clean: gitignore-clean
|
|
||||||
gitignore-clean:
|
|
||||||
-rm -f $(srcdir)/.gitignore
|
|
||||||
|
|
||||||
.PHONY: gitignore-clean gitignore gitignore-recurse gitignore-recurse-maybe
|
|
||||||
195
meson.build
Normal file
@ -0,0 +1,195 @@
|
|||||||
|
project('fprintd', 'c',
|
||||||
|
version: '1.90.7',
|
||||||
|
license: 'GPLv2+',
|
||||||
|
default_options: [
|
||||||
|
'buildtype=debugoptimized',
|
||||||
|
'warning_level=3',
|
||||||
|
'c_std=gnu99',
|
||||||
|
],
|
||||||
|
meson_version: '>= 0.50.0')
|
||||||
|
|
||||||
|
gnome = import('gnome')
|
||||||
|
i18n = import('i18n')
|
||||||
|
|
||||||
|
cc = meson.get_compiler('c')
|
||||||
|
common_cflags = cc.get_supported_arguments([
|
||||||
|
'-fno-strict-aliasing',
|
||||||
|
'-Wcast-align',
|
||||||
|
'-Werror=address',
|
||||||
|
'-Werror=array-bounds',
|
||||||
|
'-Werror=empty-body',
|
||||||
|
'-Werror=implicit',
|
||||||
|
'-Werror=init-self',
|
||||||
|
'-Werror=int-to-pointer-cast',
|
||||||
|
'-Werror=main',
|
||||||
|
'-Werror=missing-braces',
|
||||||
|
'-Werror=nonnull',
|
||||||
|
'-Werror=pointer-to-int-cast',
|
||||||
|
'-Werror=redundant-decls',
|
||||||
|
'-Werror=return-type',
|
||||||
|
'-Werror=sequence-point',
|
||||||
|
'-Werror=trigraphs',
|
||||||
|
'-Werror=write-strings',
|
||||||
|
'-Wformat-nonliteral',
|
||||||
|
'-Wformat-security',
|
||||||
|
'-Wformat=2',
|
||||||
|
'-Wignored-qualifiers',
|
||||||
|
'-Wimplicit-function-declaration',
|
||||||
|
'-Wlogical-op',
|
||||||
|
'-Wmissing-declarations',
|
||||||
|
'-Wmissing-format-attribute',
|
||||||
|
'-Wmissing-include-dirs',
|
||||||
|
'-Wmissing-noreturn',
|
||||||
|
'-Wmissing-prototypes',
|
||||||
|
'-Wnested-externs',
|
||||||
|
'-Wold-style-definition',
|
||||||
|
'-Wpointer-arith',
|
||||||
|
'-Wshadow',
|
||||||
|
'-Wstrict-prototypes',
|
||||||
|
'-Wtype-limits',
|
||||||
|
'-Wundef',
|
||||||
|
'-Wunused',
|
||||||
|
])
|
||||||
|
add_project_arguments(common_cflags, language: 'c')
|
||||||
|
|
||||||
|
common_cflags = cc.get_supported_arguments([
|
||||||
|
# The stub passes a lot of params that we do not use, maybe a good idea to
|
||||||
|
# mark it appropriately, but this works well for now.
|
||||||
|
'-Wno-unused-parameter',
|
||||||
|
# We use g_signal_handlers_disconnect_* which is not compatible with -Wpedantic
|
||||||
|
'-Wno-pedantic',
|
||||||
|
])
|
||||||
|
add_project_arguments(common_cflags, language: 'c')
|
||||||
|
|
||||||
|
host_system = host_machine.system()
|
||||||
|
# NOTE: Bump gdbus-codegen min version once we can depend on 2.64!
|
||||||
|
glib_min_version = '2.56'
|
||||||
|
libfprint_min_version = '1.90.1'
|
||||||
|
|
||||||
|
fprintd_installdir = get_option('prefix') / get_option('libexecdir')
|
||||||
|
fprintd_plugindir = get_option('prefix') / get_option('libdir') / meson.project_name() / 'modules'
|
||||||
|
storage_path = get_option('prefix') / get_option('localstatedir') / 'lib/fprint'
|
||||||
|
localedir = get_option('prefix') / get_option('localedir')
|
||||||
|
datadir = get_option('prefix') / get_option('datadir')
|
||||||
|
sysconfdir = get_option('sysconfdir')
|
||||||
|
if get_option('prefix') != '/usr'
|
||||||
|
sysconfdir = get_option('prefix') / sysconfdir
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Dependencies
|
||||||
|
glib_dep = dependency('glib-2.0', version: '>=' + glib_min_version)
|
||||||
|
gio_dep = dependency('gio-2.0', version: '>=' + glib_min_version)
|
||||||
|
gio_unix_dep = dependency('gio-unix-2.0', version: '>=' + glib_min_version)
|
||||||
|
gmodule_dep = dependency('gmodule-2.0', version: '>=' + glib_min_version)
|
||||||
|
libfprint_dep = dependency('libfprint-2', version: '>=' + libfprint_min_version)
|
||||||
|
polkit_gobject_dep = dependency('polkit-gobject-1', version: '>= 0.91')
|
||||||
|
dbus_dep = dependency('dbus-1', required: false)
|
||||||
|
libsystemd_dep = dependency('libsystemd', required: get_option('pam'))
|
||||||
|
pam_dep = cc.find_library('pam',
|
||||||
|
required: get_option('pam'),
|
||||||
|
has_headers: 'security/pam_modules.h',
|
||||||
|
)
|
||||||
|
|
||||||
|
pod2man = find_program('pod2man', required: get_option('man'))
|
||||||
|
xsltproc = find_program('xsltproc', required: get_option('gtk_doc'))
|
||||||
|
|
||||||
|
# StateDirectory was introduced in systemd 235
|
||||||
|
systemd_dep = dependency('systemd', version: '>= 235')
|
||||||
|
systemd_unit_dir = get_option('systemd_system_unit_dir')
|
||||||
|
|
||||||
|
if systemd_unit_dir == ''
|
||||||
|
systemd_unit_dir = systemd_dep.get_pkgconfig_variable('systemdsystemunitdir')
|
||||||
|
endif
|
||||||
|
|
||||||
|
dbus_service_dir = get_option('dbus_service_dir')
|
||||||
|
dbus_data_dir = datadir
|
||||||
|
dbus_interfaces_dir = ''
|
||||||
|
|
||||||
|
if dbus_dep.found()
|
||||||
|
if dbus_service_dir == ''
|
||||||
|
dbus_service_dir = dbus_dep.get_pkgconfig_variable('system_bus_services_dir')
|
||||||
|
endif
|
||||||
|
dbus_interfaces_dir = dbus_dep.get_pkgconfig_variable('interfaces_dir')
|
||||||
|
dbus_data_dir = dbus_dep.get_pkgconfig_variable('datadir')
|
||||||
|
endif
|
||||||
|
|
||||||
|
dbus_conf_dir = dbus_data_dir / 'dbus-1/system.d'
|
||||||
|
|
||||||
|
if dbus_service_dir == ''
|
||||||
|
dbus_service_dir = datadir / 'dbus-1/system-services'
|
||||||
|
endif
|
||||||
|
if dbus_interfaces_dir == ''
|
||||||
|
dbus_interfaces_dir = datadir / 'dbus-1/interfaces'
|
||||||
|
endif
|
||||||
|
|
||||||
|
polkit_policy_directory = polkit_gobject_dep.get_pkgconfig_variable('policydir')
|
||||||
|
|
||||||
|
# Tests dependencies
|
||||||
|
pam_wrapper_dep = dependency('pam_wrapper', required: get_option('pam'))
|
||||||
|
|
||||||
|
xmllint = find_program('xmllint', required: false)
|
||||||
|
python3 = find_program('python3') # No meson without it!
|
||||||
|
python3_test_modules = {
|
||||||
|
'cairo': true,
|
||||||
|
'dbus': true,
|
||||||
|
'dbusmock': true,
|
||||||
|
'gi': true,
|
||||||
|
'gi.repository.FPrint': true,
|
||||||
|
'pypamtest': get_option('pam'),
|
||||||
|
}
|
||||||
|
python3_available_modules = []
|
||||||
|
|
||||||
|
foreach module, required : python3_test_modules
|
||||||
|
if required and run_command(python3, '-c', 'import @0@'.format(module)).returncode() != 0
|
||||||
|
error('Python3 module \'' + module + '\' required by test suite not found')
|
||||||
|
endif
|
||||||
|
endforeach
|
||||||
|
|
||||||
|
cdata = configuration_data()
|
||||||
|
cdata.set_quoted('GETTEXT_PACKAGE', meson.project_name())
|
||||||
|
cdata.set_quoted('PACKAGE_VERSION', meson.project_version())
|
||||||
|
cdata.set_quoted('VERSION', meson.project_version())
|
||||||
|
cdata.set_quoted('SYSCONFDIR', sysconfdir)
|
||||||
|
cdata.set('POLKIT_HAS_AUTOPOINTERS', polkit_gobject_dep.version().version_compare('>= 0.114'))
|
||||||
|
|
||||||
|
config_h = configure_file(
|
||||||
|
input: 'config.h.in',
|
||||||
|
output: 'config.h',
|
||||||
|
configuration: cdata
|
||||||
|
)
|
||||||
|
|
||||||
|
subdir('src')
|
||||||
|
subdir('data')
|
||||||
|
subdir('utils')
|
||||||
|
if get_option('pam')
|
||||||
|
subdir('pam')
|
||||||
|
endif
|
||||||
|
if get_option('gtk_doc')
|
||||||
|
subdir('doc')
|
||||||
|
endif
|
||||||
|
subdir('tests')
|
||||||
|
subdir('po')
|
||||||
|
|
||||||
|
output = []
|
||||||
|
output += 'System paths:'
|
||||||
|
output += ' prefix: ' + get_option('prefix')
|
||||||
|
output += ' fprintd daemon directory: ' + fprintd_installdir
|
||||||
|
output += ' fprintd modules directory: ' + fprintd_plugindir
|
||||||
|
output += ' fprintd prints storage directory: ' + storage_path
|
||||||
|
output += ' DBus configuration directory: ' + dbus_conf_dir
|
||||||
|
output += ' DBus service directory: ' + dbus_service_dir
|
||||||
|
output += ' DBus interfaces directory: ' + dbus_interfaces_dir
|
||||||
|
output += ' Polkit policy directory: ' + polkit_policy_directory
|
||||||
|
output += ' Systemd service directory: ' + systemd_unit_dir
|
||||||
|
if get_option('pam')
|
||||||
|
output += ' PAM module directory: ' + pam_modules_dir
|
||||||
|
endif
|
||||||
|
output += '\nOptional features:\n'
|
||||||
|
output += ' PAM module: ' + pam_dep.found().to_string()
|
||||||
|
output += ' Manuals: ' + get_option('man').to_string()
|
||||||
|
output += ' GTK Doc: ' + get_option('gtk_doc').to_string()
|
||||||
|
output += ' XML Linter ' + xmllint.found().to_string()
|
||||||
|
output += '\nTest setup:\n'
|
||||||
|
output += ' With address sanitizer: ' + address_sanitizer.to_string()
|
||||||
|
|
||||||
|
message('\n'+'\n'.join(output)+'\n')
|
||||||
21
meson_options.txt
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
option('pam',
|
||||||
|
description: 'Build the fprintd PAM module',
|
||||||
|
type: 'boolean',
|
||||||
|
value: true)
|
||||||
|
option('man',
|
||||||
|
description: 'Generate the man files',
|
||||||
|
type: 'boolean',
|
||||||
|
value: true)
|
||||||
|
option('systemd_system_unit_dir',
|
||||||
|
description: 'Directory for systemd service files',
|
||||||
|
type: 'string')
|
||||||
|
option('dbus_service_dir',
|
||||||
|
description: 'Directory for dbus service files',
|
||||||
|
type: 'string')
|
||||||
|
option('pam_modules_dir',
|
||||||
|
description: 'Directory for PAM modules',
|
||||||
|
type: 'string')
|
||||||
|
option('gtk_doc',
|
||||||
|
type: 'boolean',
|
||||||
|
value: false,
|
||||||
|
description: 'Use gtk-doc to build documentation')
|
||||||
@ -1,22 +0,0 @@
|
|||||||
if HAVE_PAM
|
|
||||||
|
|
||||||
pammod_LTLIBRARIES = pam_fprintd.la
|
|
||||||
pammoddir=$(libdir)/security
|
|
||||||
|
|
||||||
pam_fprintd_la_SOURCES = pam_fprintd.c $(MARSHALFILES)
|
|
||||||
pam_fprintd_la_CFLAGS = -fPIC $(WARN_CFLAGS) $(GLIB_CFLAGS) -DLOCALEDIR="\"$(localedir)\""
|
|
||||||
pam_fprintd_la_LDFLAGS = -avoid-version -module -Wl,-z,nodelete
|
|
||||||
pam_fprintd_la_LIBADD = $(PAM_LIBS) $(GLIB_LIBS)
|
|
||||||
|
|
||||||
MARSHALFILES = marshal.c marshal.h
|
|
||||||
GLIB_GENMARSHAL=`pkg-config --variable=glib_genmarshal glib-2.0`
|
|
||||||
BUILT_SOURCES = $(MARSHALFILES)
|
|
||||||
|
|
||||||
marshal.h: $(top_srcdir)/src/fprintd-marshal.list
|
|
||||||
( $(GLIB_GENMARSHAL) --prefix=fprintd_marshal $(top_srcdir)/src/fprintd-marshal.list --header > marshal.h )
|
|
||||||
marshal.c: marshal.h
|
|
||||||
( $(GLIB_GENMARSHAL) --prefix=fprintd_marshal $(top_srcdir)/src/fprintd-marshal.list --body --header > marshal.c )
|
|
||||||
|
|
||||||
endif
|
|
||||||
|
|
||||||
EXTRA_DIST = pam_fprintd.c fingerprint-strings.h
|
|
||||||
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Helper functions to translate statuses and actions to strings
|
* Helper functions to translate statuses and actions to strings
|
||||||
* Copyright (C) 2008 Bastien Nocera <hadess@hadess.net>
|
* Copyright (C) 2008 Bastien Nocera <hadess@hadess.net>
|
||||||
*
|
*
|
||||||
* Experimental code. This will be moved out of fprintd into it's own
|
* Experimental code. This will be moved out of fprintd into it's own
|
||||||
* package once the system has matured.
|
* package once the system has matured.
|
||||||
*
|
*
|
||||||
@ -9,109 +9,147 @@
|
|||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License along
|
* You should have received a copy of the GNU General Public License along
|
||||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct {
|
#ifndef _GNU_SOURCE
|
||||||
const char *dbus_name;
|
#error _GNU_SOURCE must be defined
|
||||||
const char *place_str_generic;
|
#endif
|
||||||
const char *place_str_specific;
|
#include <stdio.h>
|
||||||
const char *swipe_str_generic;
|
#include <stdbool.h>
|
||||||
const char *swipe_str_specific;
|
|
||||||
|
#define GNUC_UNUSED __attribute__((__unused__))
|
||||||
|
|
||||||
|
static bool
|
||||||
|
str_equal (const char *a, const char *b)
|
||||||
|
{
|
||||||
|
if (a == NULL && b == NULL)
|
||||||
|
return true;
|
||||||
|
if (a == NULL || b == NULL)
|
||||||
|
return false;
|
||||||
|
return strcmp (a, b) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
const char *dbus_name;
|
||||||
|
const char *place_str_generic;
|
||||||
|
const char *place_str_specific;
|
||||||
|
const char *swipe_str_generic;
|
||||||
|
const char *swipe_str_specific;
|
||||||
} fingers[] = {
|
} fingers[] = {
|
||||||
{ "any",
|
{ "any",
|
||||||
N_("Place your finger on the fingerprint reader"),
|
N_("Place your finger on the fingerprint reader"),
|
||||||
N_("Place your finger on %s"),
|
N_("Place your finger on %s"),
|
||||||
N_("Swipe your finger across the fingerprint reader"),
|
N_("Swipe your finger across the fingerprint reader"),
|
||||||
N_("Swipe your finger across %s") },
|
N_("Swipe your finger across %s") },
|
||||||
{ "left-thumb",
|
{ "left-thumb",
|
||||||
N_("Place your left thumb on the fingerprint reader"),
|
N_("Place your left thumb on the fingerprint reader"),
|
||||||
N_("Place your left thumb on %s"),
|
N_("Place your left thumb on %s"),
|
||||||
N_("Swipe your left thumb across the fingerprint reader"),
|
N_("Swipe your left thumb across the fingerprint reader"),
|
||||||
N_("Swipe your left thumb across %s") },
|
N_("Swipe your left thumb across %s") },
|
||||||
{ "left-index-finger",
|
{ "left-index-finger",
|
||||||
N_("Place your left index finger on the fingerprint reader"),
|
N_("Place your left index finger on the fingerprint reader"),
|
||||||
N_("Place your left index finger on %s"),
|
N_("Place your left index finger on %s"),
|
||||||
N_("Swipe your left index finger across the fingerprint reader"),
|
N_("Swipe your left index finger across the fingerprint reader"),
|
||||||
N_("Swipe your left index finger across %s") },
|
N_("Swipe your left index finger across %s") },
|
||||||
{ "left-middle-finger",
|
{ "left-middle-finger",
|
||||||
N_("Place your left middle finger on the fingerprint reader"),
|
N_("Place your left middle finger on the fingerprint reader"),
|
||||||
N_("Place your left middle finger on %s"),
|
N_("Place your left middle finger on %s"),
|
||||||
N_("Swipe your left middle finger across the fingerprint reader"),
|
N_("Swipe your left middle finger across the fingerprint reader"),
|
||||||
N_("Swipe your left middle finger across %s") },
|
N_("Swipe your left middle finger across %s") },
|
||||||
{ "left-ring-finger",
|
{ "left-ring-finger",
|
||||||
N_("Place your left ring finger on the fingerprint reader"),
|
N_("Place your left ring finger on the fingerprint reader"),
|
||||||
N_("Place your left ring finger on %s"),
|
N_("Place your left ring finger on %s"),
|
||||||
N_("Swipe your left ring finger across the fingerprint reader"),
|
N_("Swipe your left ring finger across the fingerprint reader"),
|
||||||
N_("Swipe your left ring finger across %s") },
|
N_("Swipe your left ring finger across %s") },
|
||||||
{ "left-little-finger",
|
{ "left-little-finger",
|
||||||
N_("Place your left little finger on the fingerprint reader"),
|
N_("Place your left little finger on the fingerprint reader"),
|
||||||
N_("Place your left little finger on %s"),
|
N_("Place your left little finger on %s"),
|
||||||
N_("Swipe your left little finger across the fingerprint reader"),
|
N_("Swipe your left little finger across the fingerprint reader"),
|
||||||
N_("Swipe your left little finger across %s") },
|
N_("Swipe your left little finger across %s") },
|
||||||
{ "right-thumb",
|
{ "right-thumb",
|
||||||
N_("Place your right thumb on the fingerprint reader"),
|
N_("Place your right thumb on the fingerprint reader"),
|
||||||
N_("Place your right thumb on %s"),
|
N_("Place your right thumb on %s"),
|
||||||
N_("Swipe your right thumb across the fingerprint reader"),
|
N_("Swipe your right thumb across the fingerprint reader"),
|
||||||
N_("Swipe your right thumb across %s") },
|
N_("Swipe your right thumb across %s") },
|
||||||
{ "right-index-finger",
|
{ "right-index-finger",
|
||||||
N_("Place your right index finger on the fingerprint reader"),
|
N_("Place your right index finger on the fingerprint reader"),
|
||||||
N_("Place your right index finger on %s"),
|
N_("Place your right index finger on %s"),
|
||||||
N_("Swipe your right index finger across the fingerprint reader"),
|
N_("Swipe your right index finger across the fingerprint reader"),
|
||||||
N_("Swipe your right index finger across %s") },
|
N_("Swipe your right index finger across %s") },
|
||||||
{ "right-middle-finger",
|
{ "right-middle-finger",
|
||||||
N_("Place your right middle finger on the fingerprint reader"),
|
N_("Place your right middle finger on the fingerprint reader"),
|
||||||
N_("Place your right middle finger on %s"),
|
N_("Place your right middle finger on %s"),
|
||||||
N_("Swipe your right middle finger across the fingerprint reader"),
|
N_("Swipe your right middle finger across the fingerprint reader"),
|
||||||
N_("Swipe your right middle finger across %s") },
|
N_("Swipe your right middle finger across %s") },
|
||||||
{ "right-ring-finger",
|
{ "right-ring-finger",
|
||||||
N_("Place your right ring finger on the fingerprint reader"),
|
N_("Place your right ring finger on the fingerprint reader"),
|
||||||
N_("Place your right ring finger on %s"),
|
N_("Place your right ring finger on %s"),
|
||||||
N_("Swipe your right ring finger across the fingerprint reader"),
|
N_("Swipe your right ring finger across the fingerprint reader"),
|
||||||
N_("Swipe your right ring finger across %s") },
|
N_("Swipe your right ring finger across %s") },
|
||||||
{ "right-little-finger",
|
{ "right-little-finger",
|
||||||
N_("Place your right little finger on the fingerprint reader"),
|
N_("Place your right little finger on the fingerprint reader"),
|
||||||
N_("Place your right little finger on %s"),
|
N_("Place your right little finger on %s"),
|
||||||
N_("Swipe your right little finger across the fingerprint reader"),
|
N_("Swipe your right little finger across the fingerprint reader"),
|
||||||
N_("Swipe your right little finger across %s") },
|
N_("Swipe your right little finger across %s") },
|
||||||
{ NULL, NULL, NULL, NULL, NULL }
|
{ NULL, NULL, NULL, NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
|
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
|
||||||
|
|
||||||
G_GNUC_UNUSED static char *finger_str_to_msg(const char *finger_name, const char *driver_name, gboolean is_swipe)
|
GNUC_UNUSED static char *
|
||||||
|
finger_str_to_msg (const char *finger_name, const char *driver_name, bool is_swipe)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (finger_name == NULL)
|
if (finger_name == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
for (i = 0; fingers[i].dbus_name != NULL; i++) {
|
for (i = 0; fingers[i].dbus_name != NULL; i++)
|
||||||
if (g_str_equal (fingers[i].dbus_name, finger_name)) {
|
{
|
||||||
if (is_swipe == FALSE) {
|
if (!str_equal (fingers[i].dbus_name, finger_name))
|
||||||
if (driver_name)
|
continue;
|
||||||
return g_strdup_printf (TR (fingers[i].place_str_specific), driver_name);
|
if (is_swipe == false)
|
||||||
else
|
{
|
||||||
return g_strdup (TR (fingers[i].place_str_generic));
|
if (driver_name)
|
||||||
} else {
|
{
|
||||||
if (driver_name)
|
char *s;
|
||||||
return g_strdup_printf (TR (fingers[i].swipe_str_specific), driver_name);
|
int ret;
|
||||||
else
|
ret = asprintf (&s, TR (fingers[i].place_str_specific), driver_name);
|
||||||
return g_strdup (TR (fingers[i].swipe_str_generic));
|
return ret >= 0 ? s : NULL;
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
}
|
{
|
||||||
|
return strdup (TR (fingers[i].place_str_generic));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (driver_name)
|
||||||
|
{
|
||||||
|
char *s;
|
||||||
|
int ret;
|
||||||
|
ret = asprintf (&s, TR (fingers[i].swipe_str_specific), driver_name);
|
||||||
|
return ret >= 0 ? s : NULL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return strdup (TR (fingers[i].swipe_str_generic));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
@ -121,25 +159,27 @@ G_GNUC_UNUSED static char *finger_str_to_msg(const char *finger_name, const char
|
|||||||
* verify-match
|
* verify-match
|
||||||
* verify-unknown-error
|
* verify-unknown-error
|
||||||
*/
|
*/
|
||||||
G_GNUC_UNUSED static const char *verify_result_str_to_msg(const char *result, gboolean is_swipe)
|
GNUC_UNUSED static const char *
|
||||||
|
verify_result_str_to_msg (const char *result, bool is_swipe)
|
||||||
{
|
{
|
||||||
if (result == NULL)
|
if (result == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (strcmp (result, "verify-retry-scan") == 0) {
|
if (strcmp (result, "verify-retry-scan") == 0)
|
||||||
if (is_swipe == FALSE)
|
{
|
||||||
return N_("Place your finger on the reader again");
|
if (is_swipe == false)
|
||||||
else
|
return TR (N_("Place your finger on the reader again"));
|
||||||
return N_("Swipe your finger again");
|
else
|
||||||
}
|
return TR (N_("Swipe your finger again"));
|
||||||
if (strcmp (result, "verify-swipe-too-short") == 0)
|
}
|
||||||
return N_("Swipe was too short, try again");
|
if (strcmp (result, "verify-swipe-too-short") == 0)
|
||||||
if (strcmp (result, "verify-finger-not-centered") == 0)
|
return TR (N_("Swipe was too short, try again"));
|
||||||
return N_("Your finger was not centered, try swiping your finger again");
|
if (strcmp (result, "verify-finger-not-centered") == 0)
|
||||||
if (strcmp (result, "verify-remove-and-retry") == 0)
|
return TR (N_("Your finger was not centered, try swiping your finger again"));
|
||||||
return N_("Remove your finger, and try swiping your finger again");
|
if (strcmp (result, "verify-remove-and-retry") == 0)
|
||||||
|
return TR (N_("Remove your finger, and try swiping your finger again"));
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Cases not handled:
|
/* Cases not handled:
|
||||||
@ -147,24 +187,25 @@ G_GNUC_UNUSED static const char *verify_result_str_to_msg(const char *result, gb
|
|||||||
* enroll-failed
|
* enroll-failed
|
||||||
* enroll-unknown-error
|
* enroll-unknown-error
|
||||||
*/
|
*/
|
||||||
G_GNUC_UNUSED static const char *enroll_result_str_to_msg(const char *result, gboolean is_swipe)
|
GNUC_UNUSED static const char *
|
||||||
|
enroll_result_str_to_msg (const char *result, bool is_swipe)
|
||||||
{
|
{
|
||||||
if (result == NULL)
|
if (result == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (strcmp (result, "enroll-retry-scan") == 0 || strcmp (result, "enroll-stage-passed") == 0) {
|
if (strcmp (result, "enroll-retry-scan") == 0 || strcmp (result, "enroll-stage-passed") == 0)
|
||||||
if (is_swipe == FALSE)
|
{
|
||||||
return N_("Place your finger on the reader again");
|
if (is_swipe == false)
|
||||||
else
|
return TR (N_("Place your finger on the reader again"));
|
||||||
return N_("Swipe your finger again");
|
else
|
||||||
}
|
return TR (N_("Swipe your finger again"));
|
||||||
if (strcmp (result, "enroll-swipe-too-short") == 0)
|
}
|
||||||
return N_("Swipe was too short, try again");
|
if (strcmp (result, "enroll-swipe-too-short") == 0)
|
||||||
if (strcmp (result, "enroll-finger-not-centered") == 0)
|
return TR (N_("Swipe was too short, try again"));
|
||||||
return N_("Your finger was not centered, try swiping your finger again");
|
if (strcmp (result, "enroll-finger-not-centered") == 0)
|
||||||
if (strcmp (result, "enroll-remove-and-retry") == 0)
|
return TR (N_("Your finger was not centered, try swiping your finger again"));
|
||||||
return N_("Remove your finger, and try swiping your finger again");
|
if (strcmp (result, "enroll-remove-and-retry") == 0)
|
||||||
|
return TR (N_("Remove your finger, and try swiping your finger again"));
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
30
pam/meson.build
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
mapfile = files('pam_fprintd.ver')
|
||||||
|
pam_modules_dir = get_option('pam_modules_dir')
|
||||||
|
if pam_modules_dir == ''
|
||||||
|
pam_modules_dir = '/' / get_option('libdir') / 'security'
|
||||||
|
endif
|
||||||
|
|
||||||
|
pam_fprintd = shared_module('pam_fprintd',
|
||||||
|
name_prefix: '',
|
||||||
|
include_directories: [
|
||||||
|
include_directories('..'),
|
||||||
|
],
|
||||||
|
sources: [
|
||||||
|
'pam_fprintd.c',
|
||||||
|
'fingerprint-strings.h',
|
||||||
|
],
|
||||||
|
dependencies: [
|
||||||
|
libsystemd_dep,
|
||||||
|
pam_dep,
|
||||||
|
],
|
||||||
|
c_args: [
|
||||||
|
'-DLOCALEDIR="@0@"'.format(localedir),
|
||||||
|
],
|
||||||
|
link_args: [
|
||||||
|
'-Wl,--version-script,@0@/@1@'.format(meson.source_root(), mapfile[0]),
|
||||||
|
'-Wl,--unresolved-symbols=report-all',
|
||||||
|
],
|
||||||
|
link_depends: mapfile,
|
||||||
|
install: true,
|
||||||
|
install_dir: pam_modules_dir,
|
||||||
|
)
|
||||||
1101
pam/pam_fprintd.c
6
pam/pam_fprintd.ver
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
global:
|
||||||
|
pam_*;
|
||||||
|
local:
|
||||||
|
*;
|
||||||
|
};
|
||||||
61
pam/pam_fprintd_autoptrs.h
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
/*
|
||||||
|
* pam_fprint: PAM module for fingerprint authentication through fprintd
|
||||||
|
* Copyright (C) 2020 Marco Trevisan <marco.trevisan@canonical.com>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
/* Define auto-pointers functions, based on GLib Macros */
|
||||||
|
|
||||||
|
#define _CLEANUP_FUNC(func) __attribute__((cleanup (func)))
|
||||||
|
|
||||||
|
#define _PF_AUTOPTR_FUNC_NAME(TypeName) pf_autoptr_cleanup_ ## TypeName
|
||||||
|
#define _PF_AUTOPTR_TYPENAME(TypeName) TypeName ## _pf_autoptr
|
||||||
|
|
||||||
|
#define PF_DEFINE_AUTOPTR_CLEANUP_FUNC(TypeName, cleanup) \
|
||||||
|
typedef TypeName *_PF_AUTOPTR_TYPENAME (TypeName); \
|
||||||
|
static __attribute__((__unused__)) inline void \
|
||||||
|
_PF_AUTOPTR_FUNC_NAME (TypeName) (TypeName **_ptr) \
|
||||||
|
{ if (_ptr) (cleanup) (*_ptr); }
|
||||||
|
|
||||||
|
#define PF_DEFINE_AUTO_CLEAN_FUNC(TypeName, cleanup) \
|
||||||
|
static __attribute__((__unused__)) inline void \
|
||||||
|
_PF_AUTOPTR_FUNC_NAME (TypeName) (TypeName *_ptr) \
|
||||||
|
{ cleanup (_ptr); }
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
autoptr_cleanup_generic_free (void *p)
|
||||||
|
{
|
||||||
|
void **pp = (void **) p;
|
||||||
|
|
||||||
|
free (*pp);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define pf_autofree _CLEANUP_FUNC (autoptr_cleanup_generic_free)
|
||||||
|
#define pf_autoptr(TypeName) \
|
||||||
|
_CLEANUP_FUNC (_PF_AUTOPTR_FUNC_NAME (TypeName)) \
|
||||||
|
_PF_AUTOPTR_TYPENAME (TypeName)
|
||||||
|
#define pf_auto(TypeName) \
|
||||||
|
_CLEANUP_FUNC (_PF_AUTOPTR_FUNC_NAME (TypeName)) TypeName
|
||||||
|
|
||||||
|
PF_DEFINE_AUTOPTR_CLEANUP_FUNC (sd_bus, sd_bus_unref)
|
||||||
|
PF_DEFINE_AUTOPTR_CLEANUP_FUNC (sd_bus_message, sd_bus_message_unref)
|
||||||
|
PF_DEFINE_AUTOPTR_CLEANUP_FUNC (sd_bus_slot, sd_bus_slot_unref)
|
||||||
|
|
||||||
|
PF_DEFINE_AUTO_CLEAN_FUNC (sd_bus_error, sd_bus_error_free)
|
||||||
@ -3,3 +3,4 @@ src/main.c
|
|||||||
src/manager.c
|
src/manager.c
|
||||||
src/device.c
|
src/device.c
|
||||||
pam/fingerprint-strings.h
|
pam/fingerprint-strings.h
|
||||||
|
pam/pam_fprintd.c
|
||||||
|
|||||||
14
po/check-translations.sh
Executable file
@ -0,0 +1,14 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
po_dir=$(dirname $0)
|
||||||
|
|
||||||
|
for i in $po_dir/*.po ; do
|
||||||
|
if ! grep -q `basename $i | sed 's,.po,,'` $po_dir/LINGUAS; then
|
||||||
|
echo '**********************************';
|
||||||
|
echo '***' `basename $i | sed 's,.po,,'` missing from po/LINGUAS '***' ;
|
||||||
|
echo '**********************************';
|
||||||
|
exit 1;
|
||||||
|
fi;
|
||||||
|
done;
|
||||||
|
|
||||||
|
exit 0
|
||||||
6
po/meson.build
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
i18n.gettext(meson.project_name(), preset: 'glib')
|
||||||
|
|
||||||
|
test('check-translations',
|
||||||
|
find_program('check-translations.sh'),
|
||||||
|
suite: ['dist'],
|
||||||
|
)
|
||||||
137
scripts/uncrustify.cfg
Normal file
@ -0,0 +1,137 @@
|
|||||||
|
newlines lf
|
||||||
|
|
||||||
|
input_tab_size 8
|
||||||
|
output_tab_size 8
|
||||||
|
|
||||||
|
string_escape_char 92
|
||||||
|
string_escape_char2 0
|
||||||
|
|
||||||
|
# indenting
|
||||||
|
indent_columns 2
|
||||||
|
indent_with_tabs 0
|
||||||
|
indent_align_string True
|
||||||
|
indent_brace 2
|
||||||
|
indent_braces false
|
||||||
|
indent_braces_no_func True
|
||||||
|
indent_func_call_param false
|
||||||
|
indent_func_def_param false
|
||||||
|
indent_func_proto_param false
|
||||||
|
indent_switch_case 0
|
||||||
|
indent_case_brace 2
|
||||||
|
indent_paren_close 1
|
||||||
|
|
||||||
|
# spacing
|
||||||
|
sp_arith Add
|
||||||
|
sp_assign Add
|
||||||
|
sp_enum_assign Add
|
||||||
|
sp_bool Add
|
||||||
|
sp_compare Add
|
||||||
|
sp_inside_paren Remove
|
||||||
|
sp_inside_fparens Remove
|
||||||
|
sp_func_def_paren Force
|
||||||
|
sp_func_proto_paren Force
|
||||||
|
sp_paren_paren Remove
|
||||||
|
sp_balance_nested_parens False
|
||||||
|
sp_paren_brace Remove
|
||||||
|
sp_before_square Remove
|
||||||
|
sp_before_squares Remove
|
||||||
|
sp_inside_square Remove
|
||||||
|
sp_before_ptr_star Add
|
||||||
|
sp_between_ptr_star Remove
|
||||||
|
sp_after_comma Add
|
||||||
|
sp_before_comma Remove
|
||||||
|
sp_after_cast Add
|
||||||
|
sp_sizeof_paren Add
|
||||||
|
sp_not Remove
|
||||||
|
sp_inv Remove
|
||||||
|
sp_addr Remove
|
||||||
|
sp_member Remove
|
||||||
|
sp_deref Remove
|
||||||
|
sp_sign Remove
|
||||||
|
sp_incdec Remove
|
||||||
|
sp_attribute_paren remove
|
||||||
|
sp_macro Force
|
||||||
|
sp_func_call_paren Force
|
||||||
|
sp_func_call_user_paren Remove
|
||||||
|
set func_call_user _ N_ C_ g_autoptr g_auto
|
||||||
|
sp_brace_typedef add
|
||||||
|
sp_cond_colon add
|
||||||
|
sp_cond_question add
|
||||||
|
sp_defined_paren remove
|
||||||
|
|
||||||
|
# alignment
|
||||||
|
align_keep_tabs False
|
||||||
|
align_with_tabs False
|
||||||
|
align_on_tabstop False
|
||||||
|
align_number_right False
|
||||||
|
align_func_params True
|
||||||
|
align_var_def_span 0
|
||||||
|
align_var_def_amp_style 1
|
||||||
|
align_var_def_colon true
|
||||||
|
align_enum_equ_span 0
|
||||||
|
align_var_struct_span 2
|
||||||
|
align_var_def_star_style 2
|
||||||
|
align_var_def_amp_style 2
|
||||||
|
align_typedef_span 2
|
||||||
|
align_typedef_func 0
|
||||||
|
align_typedef_star_style 2
|
||||||
|
align_typedef_amp_style 2
|
||||||
|
|
||||||
|
# newlines
|
||||||
|
nl_assign_leave_one_liners True
|
||||||
|
nl_enum_leave_one_liners False
|
||||||
|
nl_func_leave_one_liners False
|
||||||
|
nl_if_leave_one_liners False
|
||||||
|
nl_end_of_file Add
|
||||||
|
nl_assign_brace Remove
|
||||||
|
nl_func_var_def_blk 1
|
||||||
|
nl_fcall_brace Add
|
||||||
|
nl_enum_brace Remove
|
||||||
|
nl_struct_brace Force
|
||||||
|
nl_union_brace Force
|
||||||
|
nl_if_brace Force
|
||||||
|
nl_brace_else Force
|
||||||
|
nl_elseif_brace Force
|
||||||
|
nl_else_brace Add
|
||||||
|
nl_for_brace Force
|
||||||
|
nl_while_brace Force
|
||||||
|
nl_do_brace Force
|
||||||
|
nl_brace_while Force
|
||||||
|
nl_switch_brace Force
|
||||||
|
nl_before_case True
|
||||||
|
nl_after_case False
|
||||||
|
nl_func_type_name Force
|
||||||
|
nl_func_proto_type_name Remove
|
||||||
|
nl_func_paren Remove
|
||||||
|
nl_func_decl_start Remove
|
||||||
|
nl_func_decl_args Force
|
||||||
|
nl_func_decl_end Remove
|
||||||
|
nl_fdef_brace Force
|
||||||
|
nl_after_return False
|
||||||
|
nl_define_macro False
|
||||||
|
nl_create_if_one_liner False
|
||||||
|
nl_create_for_one_liner False
|
||||||
|
nl_create_while_one_liner False
|
||||||
|
nl_after_semicolon True
|
||||||
|
nl_multi_line_cond true
|
||||||
|
|
||||||
|
# mod
|
||||||
|
# I'd like these to be remove, but that removes brackets in if { if { foo } }, which i dislike
|
||||||
|
# Not clear what to do about that...
|
||||||
|
mod_full_brace_for Remove
|
||||||
|
mod_full_brace_if Remove
|
||||||
|
mod_full_brace_if_chain True
|
||||||
|
mod_full_brace_while Remove
|
||||||
|
mod_full_brace_do Remove
|
||||||
|
mod_full_brace_nl 3
|
||||||
|
mod_paren_on_return Remove
|
||||||
|
|
||||||
|
# line splitting
|
||||||
|
#code_width = 78
|
||||||
|
ls_for_split_full True
|
||||||
|
ls_func_split_full True
|
||||||
|
|
||||||
|
# positioning
|
||||||
|
pos_bool Trail
|
||||||
|
pos_conditional Trail
|
||||||
|
|
||||||
19
scripts/uncrustify.sh
Executable file
@ -0,0 +1,19 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
SRCROOT=`git rev-parse --show-toplevel`
|
||||||
|
CFG="$SRCROOT/scripts/uncrustify.cfg"
|
||||||
|
echo "srcroot: $SRCROOT"
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
-c|--check)
|
||||||
|
OPTS="--check"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
OPTS="--replace --no-backup"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
pushd "$SRCROOT"
|
||||||
|
uncrustify -c "$CFG" $OPTS `git ls-tree --name-only -r HEAD | grep -E '.*\.[ch]$' | grep -v build/`
|
||||||
|
RES=$?
|
||||||
|
popd
|
||||||
|
exit $RES
|
||||||
@ -1,55 +0,0 @@
|
|||||||
BUILT_SOURCES = manager-dbus-glue.h device-dbus-glue.h $(MARSHALFILES) $(interfaces_DATA)
|
|
||||||
noinst_HEADERS = $(BUILT_SOURCES)
|
|
||||||
|
|
||||||
CLEANFILES = $(BUILT_SOURCES)
|
|
||||||
EXTRA_DIST = manager.xml device.xml fprintd-marshal.list
|
|
||||||
|
|
||||||
libexec_PROGRAMS = fprintd
|
|
||||||
noinst_LTLIBRARIES = libfprintd.la
|
|
||||||
|
|
||||||
AM_CFLAGS = \
|
|
||||||
$(WARN_CFLAGS) \
|
|
||||||
$(FPRINT_CFLAGS) \
|
|
||||||
$(DAEMON_CFLAGS) \
|
|
||||||
-DG_LOG_DOMAIN=\""fprintd"\" \
|
|
||||||
-DLOCALEDIR=\""$(datadir)/locale"\" \
|
|
||||||
-DPLUGINDIR=\""$(libdir)/fprintd/modules"\"
|
|
||||||
|
|
||||||
libfprintd_la_SOURCES = \
|
|
||||||
manager.c device.c \
|
|
||||||
$(MARSHALFILES) \
|
|
||||||
fprintd.h
|
|
||||||
libfprintd_la_LIBADD = $(FPRINT_LIBS) $(DAEMON_LIBS)
|
|
||||||
libfprintd_la_LDFLAGS = -no-undefined
|
|
||||||
|
|
||||||
fprintd_SOURCES = \
|
|
||||||
main.c \
|
|
||||||
loop.c loop.h \
|
|
||||||
file_storage.c file_storage.h storage.h
|
|
||||||
fprintd_LDADD = libfprintd.la
|
|
||||||
|
|
||||||
interfaces_DATA = net.reactivated.Fprint.Manager.xml net.reactivated.Fprint.Device.xml
|
|
||||||
net.reactivated.Fprint.Manager.xml: manager.xml
|
|
||||||
cat $< > $@
|
|
||||||
net.reactivated.Fprint.Device.xml: device.xml
|
|
||||||
cat $< > $@
|
|
||||||
interfacesdir = $(datadir)/dbus-1/interfaces/
|
|
||||||
|
|
||||||
manager-dbus-glue.h: manager.xml
|
|
||||||
dbus-binding-tool --prefix=fprint_manager --mode=glib-server $< --output=$@
|
|
||||||
|
|
||||||
device-dbus-glue.h: device.xml
|
|
||||||
dbus-binding-tool --prefix=fprint_device --mode=glib-server $< --output=$@
|
|
||||||
|
|
||||||
MARSHALFILES = fprintd-marshal.c fprintd-marshal.h
|
|
||||||
GLIB_GENMARSHAL=`pkg-config --variable=glib_genmarshal glib-2.0`
|
|
||||||
|
|
||||||
fprintd-marshal.h: fprintd-marshal.list
|
|
||||||
( $(GLIB_GENMARSHAL) --prefix=fprintd_marshal $(srcdir)/fprintd-marshal.list --header > fprintd-marshal.h )
|
|
||||||
fprintd-marshal.c: fprintd-marshal.h
|
|
||||||
( $(GLIB_GENMARSHAL) --prefix=fprintd_marshal $(srcdir)/fprintd-marshal.list --body --header > fprintd-marshal.c )
|
|
||||||
|
|
||||||
install-data-hook:
|
|
||||||
if test -w $(DESTDIR)$(prefix)/; then \
|
|
||||||
mkdir -p $(DESTDIR)$(localstatedir)/lib/fprint; \
|
|
||||||
fi
|
|
||||||
110
src/dbus-interactive-auth.patch
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
--- a/src/fprintd-dbus.c 2020-12-04 16:38:28.527712626 +0100
|
||||||
|
+++ b/src/fprintd-dbus.c 2020-12-04 16:40:03.561692619 +0100
|
||||||
|
@@ -1149,7 +1149,7 @@
|
||||||
|
"ListEnrolledFingers",
|
||||||
|
g_variant_new ("(s)",
|
||||||
|
arg_username),
|
||||||
|
- G_DBUS_CALL_FLAGS_NONE,
|
||||||
|
+ G_DBUS_CALL_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION,
|
||||||
|
-1,
|
||||||
|
cancellable,
|
||||||
|
callback,
|
||||||
|
@@ -1213,7 +1213,7 @@
|
||||||
|
"ListEnrolledFingers",
|
||||||
|
g_variant_new ("(s)",
|
||||||
|
arg_username),
|
||||||
|
- G_DBUS_CALL_FLAGS_NONE,
|
||||||
|
+ G_DBUS_CALL_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION,
|
||||||
|
-1,
|
||||||
|
cancellable,
|
||||||
|
error);
|
||||||
|
@@ -1253,7 +1253,7 @@
|
||||||
|
"DeleteEnrolledFingers",
|
||||||
|
g_variant_new ("(s)",
|
||||||
|
arg_username),
|
||||||
|
- G_DBUS_CALL_FLAGS_NONE,
|
||||||
|
+ G_DBUS_CALL_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION,
|
||||||
|
-1,
|
||||||
|
cancellable,
|
||||||
|
callback,
|
||||||
|
@@ -1312,7 +1312,7 @@
|
||||||
|
"DeleteEnrolledFingers",
|
||||||
|
g_variant_new ("(s)",
|
||||||
|
arg_username),
|
||||||
|
- G_DBUS_CALL_FLAGS_NONE,
|
||||||
|
+ G_DBUS_CALL_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION,
|
||||||
|
-1,
|
||||||
|
cancellable,
|
||||||
|
error);
|
||||||
|
@@ -1348,7 +1348,7 @@
|
||||||
|
g_dbus_proxy_call (G_DBUS_PROXY (proxy),
|
||||||
|
"DeleteEnrolledFingers2",
|
||||||
|
g_variant_new ("()"),
|
||||||
|
- G_DBUS_CALL_FLAGS_NONE,
|
||||||
|
+ G_DBUS_CALL_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION,
|
||||||
|
-1,
|
||||||
|
cancellable,
|
||||||
|
callback,
|
||||||
|
@@ -1404,7 +1404,7 @@
|
||||||
|
_ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
|
||||||
|
"DeleteEnrolledFingers2",
|
||||||
|
g_variant_new ("()"),
|
||||||
|
- G_DBUS_CALL_FLAGS_NONE,
|
||||||
|
+ G_DBUS_CALL_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION,
|
||||||
|
-1,
|
||||||
|
cancellable,
|
||||||
|
error);
|
||||||
|
@@ -1443,7 +1443,7 @@
|
||||||
|
"Claim",
|
||||||
|
g_variant_new ("(s)",
|
||||||
|
arg_username),
|
||||||
|
- G_DBUS_CALL_FLAGS_NONE,
|
||||||
|
+ G_DBUS_CALL_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION,
|
||||||
|
-1,
|
||||||
|
cancellable,
|
||||||
|
callback,
|
||||||
|
@@ -1502,7 +1502,7 @@
|
||||||
|
"Claim",
|
||||||
|
g_variant_new ("(s)",
|
||||||
|
arg_username),
|
||||||
|
- G_DBUS_CALL_FLAGS_NONE,
|
||||||
|
+ G_DBUS_CALL_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION,
|
||||||
|
-1,
|
||||||
|
cancellable,
|
||||||
|
error);
|
||||||
|
@@ -1633,7 +1633,7 @@
|
||||||
|
"VerifyStart",
|
||||||
|
g_variant_new ("(s)",
|
||||||
|
arg_finger_name),
|
||||||
|
- G_DBUS_CALL_FLAGS_NONE,
|
||||||
|
+ G_DBUS_CALL_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION,
|
||||||
|
-1,
|
||||||
|
cancellable,
|
||||||
|
callback,
|
||||||
|
@@ -1692,7 +1692,7 @@
|
||||||
|
"VerifyStart",
|
||||||
|
g_variant_new ("(s)",
|
||||||
|
arg_finger_name),
|
||||||
|
- G_DBUS_CALL_FLAGS_NONE,
|
||||||
|
+ G_DBUS_CALL_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION,
|
||||||
|
-1,
|
||||||
|
cancellable,
|
||||||
|
error);
|
||||||
|
@@ -1823,7 +1823,7 @@
|
||||||
|
"EnrollStart",
|
||||||
|
g_variant_new ("(s)",
|
||||||
|
arg_finger_name),
|
||||||
|
- G_DBUS_CALL_FLAGS_NONE,
|
||||||
|
+ G_DBUS_CALL_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION,
|
||||||
|
-1,
|
||||||
|
cancellable,
|
||||||
|
callback,
|
||||||
|
@@ -1882,7 +1882,7 @@
|
||||||
|
"EnrollStart",
|
||||||
|
g_variant_new ("(s)",
|
||||||
|
arg_finger_name),
|
||||||
|
- G_DBUS_CALL_FLAGS_NONE,
|
||||||
|
+ G_DBUS_CALL_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION,
|
||||||
|
-1,
|
||||||
|
cancellable,
|
||||||
|
error);
|
||||||
2895
src/device.c
@ -12,9 +12,6 @@
|
|||||||
|
|
||||||
<node name="/" xmlns:doc="http://www.freedesktop.org/dbus/1.0/doc.dtd">
|
<node name="/" xmlns:doc="http://www.freedesktop.org/dbus/1.0/doc.dtd">
|
||||||
<interface name="net.reactivated.Fprint.Device">
|
<interface name="net.reactivated.Fprint.Device">
|
||||||
<annotation name="org.freedesktop.DBus.GLib.CSymbol"
|
|
||||||
value="fprint_device" />
|
|
||||||
|
|
||||||
<doc:doc>
|
<doc:doc>
|
||||||
<doc:title id="polkit-integration">
|
<doc:title id="polkit-integration">
|
||||||
PolicyKit integration
|
PolicyKit integration
|
||||||
@ -245,6 +242,16 @@
|
|||||||
The user should remove their finger from the reader and retry scanning their finger, the enrollment is still ongoing.
|
The user should remove their finger from the reader and retry scanning their finger, the enrollment is still ongoing.
|
||||||
</doc:definition>
|
</doc:definition>
|
||||||
</doc:item>
|
</doc:item>
|
||||||
|
<doc:item>
|
||||||
|
<doc:term>enroll-data-full</doc:term>
|
||||||
|
<doc:definition>
|
||||||
|
No further prints can be enrolled on this device, <doc:ref type="method" to="Device.EnrollStop">Device.EnrollStop</doc:ref> should now be called.
|
||||||
|
|
||||||
|
<doc:ref type="method" to="DeleteEnrolledFingers2">Delete other prints</doc:ref> from the device first to continue
|
||||||
|
(e.g. from other users). Note that old prints or prints from other operating systems may be deleted automatically
|
||||||
|
to resolve this error without any notification.
|
||||||
|
</doc:definition>
|
||||||
|
</doc:item>
|
||||||
<doc:item>
|
<doc:item>
|
||||||
<doc:term>enroll-disconnected</doc:term>
|
<doc:term>enroll-disconnected</doc:term>
|
||||||
<doc:definition>
|
<doc:definition>
|
||||||
@ -272,8 +279,6 @@
|
|||||||
<arg type="as" name="enrolled_fingers" direction="out">
|
<arg type="as" name="enrolled_fingers" direction="out">
|
||||||
<doc:doc><doc:summary>An array of strings representing the enrolled fingerprints. See <doc:ref type="description" to="fingerprint-names">Fingerprint names</doc:ref>.</doc:summary></doc:doc>
|
<doc:doc><doc:summary>An array of strings representing the enrolled fingerprints. See <doc:ref type="description" to="fingerprint-names">Fingerprint names</doc:ref>.</doc:summary></doc:doc>
|
||||||
</arg>
|
</arg>
|
||||||
<annotation name="org.freedesktop.DBus.GLib.Async" value="" />
|
|
||||||
|
|
||||||
<doc:doc>
|
<doc:doc>
|
||||||
<doc:description>
|
<doc:description>
|
||||||
<doc:para>
|
<doc:para>
|
||||||
@ -294,13 +299,32 @@
|
|||||||
<arg type="s" name="username" direction="in">
|
<arg type="s" name="username" direction="in">
|
||||||
<doc:doc><doc:summary>The username for whom to delete the enrolled fingerprints. See <doc:ref type="description" to="usernames">Usernames</doc:ref>.</doc:summary></doc:doc>
|
<doc:doc><doc:summary>The username for whom to delete the enrolled fingerprints. See <doc:ref type="description" to="usernames">Usernames</doc:ref>.</doc:summary></doc:doc>
|
||||||
</arg>
|
</arg>
|
||||||
<annotation name="org.freedesktop.DBus.GLib.Async" value="" />
|
|
||||||
|
|
||||||
<doc:doc>
|
<doc:doc>
|
||||||
<doc:description>
|
<doc:description>
|
||||||
<doc:para>
|
<doc:para>
|
||||||
Delete all the enrolled fingerprints for the chosen user.
|
Delete all the enrolled fingerprints for the chosen user.
|
||||||
</doc:para>
|
</doc:para>
|
||||||
|
<doc:para>
|
||||||
|
This call only exists for compatibility reasons, you should instead claim the device using
|
||||||
|
<doc:ref type="method" to="Device.Claim">Device.Claim</doc:ref> and then call
|
||||||
|
<doc:ref type="method" to="DeleteEnrolledFingers2">DeleteEnrolledFingers2</doc:ref>.
|
||||||
|
</doc:para>
|
||||||
|
</doc:description>
|
||||||
|
|
||||||
|
<doc:errors>
|
||||||
|
<doc:error name="&ERROR_PERMISSION_DENIED;">if the caller lacks the appropriate PolicyKit authorization</doc:error>
|
||||||
|
</doc:errors>
|
||||||
|
</doc:doc>
|
||||||
|
</method>
|
||||||
|
|
||||||
|
<!-- ************************************************************ -->
|
||||||
|
|
||||||
|
<method name="DeleteEnrolledFingers2">
|
||||||
|
<doc:doc>
|
||||||
|
<doc:description>
|
||||||
|
<doc:para>
|
||||||
|
Delete all the enrolled fingerprints for the user currently claiming the device with <doc:ref type="method" to="Device.Claim">Device.Claim</doc:ref>.
|
||||||
|
</doc:para>
|
||||||
</doc:description>
|
</doc:description>
|
||||||
|
|
||||||
<doc:errors>
|
<doc:errors>
|
||||||
@ -315,8 +339,6 @@
|
|||||||
<arg type="s" name="username" direction="in">
|
<arg type="s" name="username" direction="in">
|
||||||
<doc:doc><doc:summary>The username for whom to claim the device. See <doc:ref type="description" to="usernames">Usernames</doc:ref>.</doc:summary></doc:doc>
|
<doc:doc><doc:summary>The username for whom to claim the device. See <doc:ref type="description" to="usernames">Usernames</doc:ref>.</doc:summary></doc:doc>
|
||||||
</arg>
|
</arg>
|
||||||
<annotation name="org.freedesktop.DBus.GLib.Async" value="" />
|
|
||||||
|
|
||||||
<doc:doc>
|
<doc:doc>
|
||||||
<doc:description>
|
<doc:description>
|
||||||
<doc:para>
|
<doc:para>
|
||||||
@ -335,8 +357,6 @@
|
|||||||
<!-- ************************************************************ -->
|
<!-- ************************************************************ -->
|
||||||
|
|
||||||
<method name="Release">
|
<method name="Release">
|
||||||
<annotation name="org.freedesktop.DBus.GLib.Async" value="" />
|
|
||||||
|
|
||||||
<doc:doc>
|
<doc:doc>
|
||||||
<doc:description>
|
<doc:description>
|
||||||
<doc:para>
|
<doc:para>
|
||||||
@ -357,8 +377,6 @@
|
|||||||
<arg type="s" name="finger_name" direction="in">
|
<arg type="s" name="finger_name" direction="in">
|
||||||
<doc:doc><doc:summary>A string representing the finger to verify. See <doc:ref type="description" to="fingerprint-names">Fingerprint names</doc:ref>.</doc:summary></doc:doc>
|
<doc:doc><doc:summary>A string representing the finger to verify. See <doc:ref type="description" to="fingerprint-names">Fingerprint names</doc:ref>.</doc:summary></doc:doc>
|
||||||
</arg>
|
</arg>
|
||||||
<annotation name="org.freedesktop.DBus.GLib.Async" value="" />
|
|
||||||
|
|
||||||
<doc:doc>
|
<doc:doc>
|
||||||
<doc:description>
|
<doc:description>
|
||||||
<doc:para>
|
<doc:para>
|
||||||
@ -382,8 +400,6 @@
|
|||||||
<!-- ************************************************************ -->
|
<!-- ************************************************************ -->
|
||||||
|
|
||||||
<method name="VerifyStop">
|
<method name="VerifyStop">
|
||||||
<annotation name="org.freedesktop.DBus.GLib.Async" value="" />
|
|
||||||
|
|
||||||
<doc:doc>
|
<doc:doc>
|
||||||
<doc:description>
|
<doc:description>
|
||||||
<doc:para>
|
<doc:para>
|
||||||
@ -453,12 +469,10 @@
|
|||||||
<doc:ref type="description" to="fingerprint-names">Fingerprint names</doc:ref>.
|
<doc:ref type="description" to="fingerprint-names">Fingerprint names</doc:ref>.
|
||||||
Note that "any" is not a valid finger name for this method.</doc:summary></doc:doc>
|
Note that "any" is not a valid finger name for this method.</doc:summary></doc:doc>
|
||||||
</arg>
|
</arg>
|
||||||
<annotation name="org.freedesktop.DBus.GLib.Async" value="" />
|
|
||||||
|
|
||||||
<doc:doc>
|
<doc:doc>
|
||||||
<doc:description>
|
<doc:description>
|
||||||
<doc:para>
|
<doc:para>
|
||||||
Start enrollemnt for the selected finger. You need to have claimed the device using
|
Start enrollment for the selected finger. You need to have claimed the device using
|
||||||
<doc:ref type="method" to="Device.Claim">Device.Claim</doc:ref> before calling
|
<doc:ref type="method" to="Device.Claim">Device.Claim</doc:ref> before calling
|
||||||
this method. Enrollment status is sent through <doc:ref type="signal" to="Device::EnrollStatus">Device::EnrollStatus</doc:ref>.
|
this method. Enrollment status is sent through <doc:ref type="signal" to="Device::EnrollStatus">Device::EnrollStatus</doc:ref>.
|
||||||
</doc:para>
|
</doc:para>
|
||||||
@ -468,7 +482,7 @@
|
|||||||
<doc:error name="&ERROR_PERMISSION_DENIED;">if the caller lacks the appropriate PolicyKit authorization</doc:error>
|
<doc:error name="&ERROR_PERMISSION_DENIED;">if the caller lacks the appropriate PolicyKit authorization</doc:error>
|
||||||
<doc:error name="&ERROR_CLAIM_DEVICE;">if the device was not claimed</doc:error>
|
<doc:error name="&ERROR_CLAIM_DEVICE;">if the device was not claimed</doc:error>
|
||||||
<doc:error name="&ERROR_ALREADY_IN_USE;">if the device was already being used</doc:error>
|
<doc:error name="&ERROR_ALREADY_IN_USE;">if the device was already being used</doc:error>
|
||||||
<doc:error name="&ERROR_INVALID_FINGERNAME;">if there are no enrolled prints for the chosen user</doc:error>
|
<doc:error name="&ERROR_INVALID_FINGERNAME;">if the finger name passed is invalid</doc:error>
|
||||||
<doc:error name="&ERROR_INTERNAL;">if there was an internal error</doc:error>
|
<doc:error name="&ERROR_INTERNAL;">if there was an internal error</doc:error>
|
||||||
</doc:errors>
|
</doc:errors>
|
||||||
|
|
||||||
@ -478,8 +492,6 @@
|
|||||||
<!-- ************************************************************ -->
|
<!-- ************************************************************ -->
|
||||||
|
|
||||||
<method name="EnrollStop">
|
<method name="EnrollStop">
|
||||||
<annotation name="org.freedesktop.DBus.GLib.Async" value="" />
|
|
||||||
|
|
||||||
<doc:doc>
|
<doc:doc>
|
||||||
<doc:description>
|
<doc:description>
|
||||||
<doc:para>
|
<doc:para>
|
||||||
|
|||||||
@ -7,12 +7,12 @@
|
|||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License along
|
* You should have received a copy of the GNU General Public License along
|
||||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
@ -35,247 +35,306 @@
|
|||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <glib/gstdio.h>
|
#include <glib/gstdio.h>
|
||||||
|
|
||||||
#include <libfprint/fprint.h>
|
#include <fprint.h>
|
||||||
|
|
||||||
#include "file_storage.h"
|
#include "file_storage.h"
|
||||||
|
|
||||||
#define FILE_STORAGE_PATH "/var/lib/fprint"
|
#define FILE_STORAGE_PATH "/var/lib/fprint"
|
||||||
#define DIR_PERMS 0700
|
#define DIR_PERMS 0700
|
||||||
|
|
||||||
#define FP_FINGER_IS_VALID(finger) \
|
static char *storage_path = NULL;
|
||||||
((finger) >= LEFT_THUMB && (finger) <= RIGHT_LITTLE)
|
|
||||||
|
|
||||||
static char *get_path_to_storedir(uint16_t driver_id, uint32_t devtype, char *base_store)
|
static const char *
|
||||||
|
get_storage_path (void)
|
||||||
{
|
{
|
||||||
char idstr[5];
|
const char *path = NULL;
|
||||||
char devtypestr[9];
|
|
||||||
|
|
||||||
g_snprintf(idstr, sizeof(idstr), "%04x", driver_id);
|
if (storage_path != NULL)
|
||||||
g_snprintf(devtypestr, sizeof(devtypestr), "%08x", devtype);
|
return storage_path;
|
||||||
|
|
||||||
return g_build_filename(base_store, idstr, devtypestr, NULL);
|
/* set by systemd >= 240 to an absolute path
|
||||||
|
* taking into account the StateDirectory
|
||||||
|
* unit file setting */
|
||||||
|
path = g_getenv ("STATE_DIRECTORY");
|
||||||
|
if (path != NULL)
|
||||||
|
{
|
||||||
|
/* If multiple directories are set, then in the environment variable
|
||||||
|
* the paths are concatenated with colon (":"). */
|
||||||
|
if (strchr (path, ':'))
|
||||||
|
{
|
||||||
|
g_auto(GStrv) elems = NULL;
|
||||||
|
elems = g_strsplit (path, ":", -1);
|
||||||
|
storage_path = g_strdup (elems[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (storage_path == NULL)
|
||||||
|
storage_path = g_strdup (FILE_STORAGE_PATH);
|
||||||
|
|
||||||
|
return storage_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *__get_path_to_print(uint16_t driver_id, uint32_t devtype,
|
static char *
|
||||||
enum fp_finger finger, char *base_store)
|
get_path_to_storedir (const char *driver, const char * device_id, char *base_store)
|
||||||
{
|
{
|
||||||
char *dirpath;
|
return g_build_filename (base_store, driver, device_id, NULL);
|
||||||
char *path;
|
|
||||||
char fingername[2];
|
|
||||||
|
|
||||||
g_snprintf(fingername, 2, "%x", finger);
|
|
||||||
|
|
||||||
dirpath = get_path_to_storedir(driver_id, devtype, base_store);
|
|
||||||
path = g_build_filename(dirpath, fingername, NULL);
|
|
||||||
g_free(dirpath);
|
|
||||||
return path;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *get_path_to_print(struct fp_dev *dev, enum fp_finger finger, char *base_store)
|
static char *
|
||||||
|
__get_path_to_print (const char *driver, const char * device_id,
|
||||||
|
FpFinger finger, char *base_store)
|
||||||
{
|
{
|
||||||
return __get_path_to_print(fp_driver_get_driver_id(fp_dev_get_driver(dev)),
|
g_autofree char *dirpath = NULL;
|
||||||
fp_dev_get_devtype(dev), finger, base_store);
|
char *path;
|
||||||
|
char fingername[2];
|
||||||
|
|
||||||
|
g_snprintf (fingername, 2, "%x", finger);
|
||||||
|
|
||||||
|
dirpath = get_path_to_storedir (driver, device_id, base_store);
|
||||||
|
path = g_build_filename (dirpath, fingername, NULL);
|
||||||
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *get_path_to_print_dscv(struct fp_dscv_dev *dev, enum fp_finger finger, char *base_store)
|
static char *
|
||||||
|
get_path_to_print (FpDevice *dev, FpFinger finger, char *base_store)
|
||||||
{
|
{
|
||||||
return __get_path_to_print(fp_driver_get_driver_id(fp_dscv_dev_get_driver(dev)),
|
return __get_path_to_print (fp_device_get_driver (dev),
|
||||||
fp_dscv_dev_get_devtype(dev), finger, base_store);
|
fp_device_get_device_id (dev),
|
||||||
|
finger,
|
||||||
|
base_store);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *file_storage_get_basestore_for_username(const char *username)
|
static char *
|
||||||
|
get_path_to_print_dscv (FpDevice *dev, FpFinger finger, char *base_store)
|
||||||
{
|
{
|
||||||
return g_build_filename(FILE_STORAGE_PATH, username, NULL);
|
return __get_path_to_print (fp_device_get_driver (dev),
|
||||||
|
fp_device_get_device_id (dev),
|
||||||
|
finger,
|
||||||
|
base_store);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if username == NULL function will use current username */
|
static char *
|
||||||
int file_storage_print_data_save(struct fp_print_data *data,
|
file_storage_get_basestore_for_username (const char *username)
|
||||||
enum fp_finger finger, const char *username)
|
|
||||||
{
|
{
|
||||||
GError *err = NULL;
|
return g_build_filename (get_storage_path (), username, NULL);
|
||||||
char *path, *dirpath;
|
|
||||||
size_t len;
|
|
||||||
int r;
|
|
||||||
char *base_store = NULL;
|
|
||||||
char *buf = NULL;
|
|
||||||
|
|
||||||
base_store = file_storage_get_basestore_for_username(username);
|
|
||||||
|
|
||||||
len = fp_print_data_get_data(data, (guchar **) &buf);
|
|
||||||
if (!len) {
|
|
||||||
g_free(base_store);
|
|
||||||
return -ENOMEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
path = __get_path_to_print(fp_print_data_get_driver_id(data), fp_print_data_get_devtype(data), finger, base_store);
|
|
||||||
dirpath = g_path_get_dirname(path);
|
|
||||||
r = g_mkdir_with_parents(dirpath, DIR_PERMS);
|
|
||||||
if (r < 0) {
|
|
||||||
g_debug("file_storage_print_data_save(): could not mkdir(\"%s\"): %s",
|
|
||||||
dirpath, g_strerror(r));
|
|
||||||
g_free(dirpath);
|
|
||||||
g_free(path);
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
g_free(dirpath);
|
|
||||||
|
|
||||||
//fp_dbg("saving to %s", path);
|
|
||||||
g_file_set_contents(path, buf, len, &err);
|
|
||||||
g_free(path);
|
|
||||||
if (err) {
|
|
||||||
r = err->code;
|
|
||||||
g_debug("file_storage_print_data_save(): could not save '%s': %s",
|
|
||||||
path, err->message);
|
|
||||||
g_error_free(err);
|
|
||||||
/* FIXME interpret error codes */
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
out:
|
|
||||||
g_clear_pointer(&buf, free);
|
|
||||||
g_clear_pointer(&base_store, g_free);
|
|
||||||
return r;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int load_from_file(char *path, struct fp_print_data **data)
|
int
|
||||||
|
file_storage_print_data_save (FpPrint *print)
|
||||||
{
|
{
|
||||||
gsize length;
|
g_autoptr(GError) err = NULL;
|
||||||
char *contents;
|
g_autofree char *path = NULL;
|
||||||
GError *err = NULL;
|
g_autofree char *dirpath = NULL;
|
||||||
struct fp_print_data *fdata;
|
g_autofree char *base_store = NULL;
|
||||||
|
g_autofree char *buf = NULL;
|
||||||
|
gsize len;
|
||||||
|
int r;
|
||||||
|
|
||||||
//fp_dbg("from %s", path);
|
base_store = file_storage_get_basestore_for_username (fp_print_get_username (print));
|
||||||
g_file_get_contents(path, &contents, &length, &err);
|
|
||||||
if (err) {
|
|
||||||
int r = err->code;
|
|
||||||
g_error_free(err);
|
|
||||||
/* FIXME interpret more error codes */
|
|
||||||
if (r == G_FILE_ERROR_NOENT)
|
|
||||||
return -ENOENT;
|
|
||||||
else
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
fdata = fp_print_data_from_data((guchar *) contents, length);
|
if (!fp_print_serialize (print, (guchar **) &buf, &len, &err))
|
||||||
g_free(contents);
|
{
|
||||||
if (!fdata)
|
g_warning ("Error serializing data: %s", err->message);
|
||||||
return -EIO;
|
return -ENOMEM;
|
||||||
*data = fdata;
|
}
|
||||||
return 0;
|
|
||||||
|
path = __get_path_to_print (fp_print_get_driver (print),
|
||||||
|
fp_print_get_device_id (print),
|
||||||
|
fp_print_get_finger (print),
|
||||||
|
base_store);
|
||||||
|
dirpath = g_path_get_dirname (path);
|
||||||
|
r = g_mkdir_with_parents (dirpath, DIR_PERMS);
|
||||||
|
if (r < 0)
|
||||||
|
{
|
||||||
|
g_debug ("file_storage_print_data_save(): could not mkdir(\"%s\"): %s",
|
||||||
|
dirpath, g_strerror (r));
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
//fp_dbg("saving to %s", path);
|
||||||
|
g_file_set_contents (path, buf, len, &err);
|
||||||
|
if (err)
|
||||||
|
{
|
||||||
|
g_debug ("file_storage_print_data_save(): could not save '%s': %s",
|
||||||
|
path, err->message);
|
||||||
|
/* FIXME interpret error codes */
|
||||||
|
return err->code;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int file_storage_print_data_load(struct fp_dev *dev,
|
static int
|
||||||
enum fp_finger finger, struct fp_print_data **data, const char *username)
|
load_from_file (char *path, FpPrint **print)
|
||||||
{
|
{
|
||||||
gchar *path;
|
g_autoptr(GError) err = NULL;
|
||||||
struct fp_print_data *fdata = NULL;
|
gsize length;
|
||||||
int r;
|
g_autofree char *contents = NULL;
|
||||||
char *base_store = NULL;
|
FpPrint *new;
|
||||||
|
|
||||||
base_store = file_storage_get_basestore_for_username(username);
|
//fp_dbg("from %s", path);
|
||||||
|
g_file_get_contents (path, &contents, &length, &err);
|
||||||
|
if (err)
|
||||||
|
{
|
||||||
|
int r = err->code;
|
||||||
|
/* FIXME interpret more error codes */
|
||||||
|
if (r == G_FILE_ERROR_NOENT)
|
||||||
|
return -ENOENT;
|
||||||
|
else
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
path = get_path_to_print(dev, finger, base_store);
|
new = fp_print_deserialize ((guchar *) contents, length, &err);
|
||||||
r = load_from_file(path, &fdata);
|
if (!new)
|
||||||
g_debug ("file_storage_print_data_load(): loaded '%s' %s",
|
{
|
||||||
path, g_strerror(r));
|
g_print ("Error deserializing data: %s", err->message);
|
||||||
g_free(path);
|
return -EIO;
|
||||||
g_free(base_store);
|
}
|
||||||
if (r)
|
|
||||||
return r;
|
|
||||||
|
|
||||||
if (!fp_dev_supports_print_data(dev, fdata)) {
|
*print = new;
|
||||||
fp_print_data_free(fdata);
|
return 0;
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
*data = fdata;
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int file_storage_print_data_delete(struct fp_dscv_dev *dev,
|
int
|
||||||
enum fp_finger finger, const char *username)
|
file_storage_print_data_load (FpDevice *dev,
|
||||||
|
FpFinger finger,
|
||||||
|
const char *username,
|
||||||
|
FpPrint **print)
|
||||||
{
|
{
|
||||||
int r;
|
g_autofree gchar *path = NULL;
|
||||||
char *base_store, *path;
|
g_autofree gchar *base_store = NULL;
|
||||||
|
|
||||||
base_store = file_storage_get_basestore_for_username(username);
|
g_autoptr(FpPrint) new = NULL;
|
||||||
path = get_path_to_print_dscv(dev, finger, base_store);
|
int r;
|
||||||
|
|
||||||
r = g_unlink(path);
|
base_store = file_storage_get_basestore_for_username (username);
|
||||||
g_debug("file_storage_print_data_delete(): unlink(\"%s\") %s",
|
|
||||||
path, g_strerror(r));
|
|
||||||
g_free(path);
|
|
||||||
g_free(base_store);
|
|
||||||
|
|
||||||
/* FIXME: cleanup empty directory */
|
path = get_path_to_print (dev, finger, base_store);
|
||||||
return r;
|
r = load_from_file (path, &new);
|
||||||
|
g_debug ("file_storage_print_data_load(): loaded '%s' %s",
|
||||||
|
path, g_strerror (r));
|
||||||
|
if (r)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
if (!fp_print_compatible (new, dev))
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
*print = g_steal_pointer (&new);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GSList *scan_dev_storedir(char *devpath, uint16_t driver_id,
|
int
|
||||||
uint32_t devtype, GSList *list)
|
file_storage_print_data_delete (FpDevice *dev, FpFinger finger, const char *username)
|
||||||
{
|
{
|
||||||
GError *err = NULL;
|
g_autofree gchar *base_store = NULL;
|
||||||
const gchar *ent;
|
g_autofree gchar *path = NULL;
|
||||||
|
int r;
|
||||||
|
|
||||||
GDir *dir = g_dir_open(devpath, 0, &err);
|
base_store = file_storage_get_basestore_for_username (username);
|
||||||
if (!dir) {
|
|
||||||
g_debug("scan_dev_storedir(): opendir(\"%s\") failed: %s", devpath, err->message);
|
|
||||||
g_error_free(err);
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
while ((ent = g_dir_read_name(dir))) {
|
path = get_path_to_print_dscv (dev, finger, base_store);
|
||||||
/* ent is an 1 hex character fp_finger code */
|
|
||||||
guint64 val;
|
|
||||||
gchar *endptr;
|
|
||||||
|
|
||||||
if (*ent == 0 || strlen(ent) != 1)
|
r = g_unlink (path);
|
||||||
continue;
|
g_debug ("file_storage_print_data_delete(): unlink(\"%s\") %s",
|
||||||
|
path, g_strerror (r));
|
||||||
|
|
||||||
val = g_ascii_strtoull(ent, &endptr, 16);
|
/* FIXME: cleanup empty directory */
|
||||||
if (endptr == ent || !FP_FINGER_IS_VALID(val)) {
|
return g_unlink (path);
|
||||||
g_debug("scan_dev_storedir(): skipping print file '%s'", ent);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
list = g_slist_prepend(list, GINT_TO_POINTER(val));
|
|
||||||
}
|
|
||||||
|
|
||||||
g_dir_close(dir);
|
|
||||||
return list;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GSList *file_storage_discover_prints(struct fp_dscv_dev *dev, const char *username)
|
static GSList *
|
||||||
|
scan_dev_storedir (char *devpath,
|
||||||
|
GSList *list)
|
||||||
{
|
{
|
||||||
GSList *list = NULL;
|
g_autoptr(GError) err = NULL;
|
||||||
char *base_store = NULL;
|
const gchar *ent;
|
||||||
char *storedir = NULL;
|
|
||||||
|
|
||||||
base_store = file_storage_get_basestore_for_username(username);
|
GDir *dir = g_dir_open (devpath, 0, &err);
|
||||||
|
|
||||||
storedir = get_path_to_storedir(fp_driver_get_driver_id(fp_dscv_dev_get_driver(dev)),
|
if (!dir)
|
||||||
fp_dscv_dev_get_devtype(dev), base_store);
|
{
|
||||||
|
g_debug ("scan_dev_storedir(): opendir(\"%s\") failed: %s", devpath, err->message);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
g_debug ("file_storage_discover_prints() for user '%s' in '%s'",
|
while ((ent = g_dir_read_name (dir)))
|
||||||
username, storedir);
|
{
|
||||||
|
/* ent is an 1 hex character fp_finger code */
|
||||||
|
guint64 val;
|
||||||
|
gchar *endptr;
|
||||||
|
|
||||||
list = scan_dev_storedir(storedir, fp_driver_get_driver_id(fp_dscv_dev_get_driver(dev)),
|
if (*ent == 0 || strlen (ent) != 1)
|
||||||
fp_dscv_dev_get_devtype(dev), list);
|
continue;
|
||||||
|
|
||||||
g_free(base_store);
|
val = g_ascii_strtoull (ent, &endptr, 16);
|
||||||
g_free(storedir);
|
if (endptr == ent || !FP_FINGER_IS_VALID (val))
|
||||||
|
{
|
||||||
|
g_debug ("scan_dev_storedir(): skipping print file '%s'", ent);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
return list;
|
list = g_slist_prepend (list, GUINT_TO_POINTER (val));
|
||||||
|
}
|
||||||
|
|
||||||
|
g_dir_close (dir);
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
int file_storage_init(void)
|
GSList *
|
||||||
|
file_storage_discover_prints (FpDevice *dev, const char *username)
|
||||||
{
|
{
|
||||||
/* Nothing to do */
|
GSList *list = NULL;
|
||||||
return 0;
|
g_autofree gchar *base_store = NULL;
|
||||||
|
g_autofree gchar *storedir = NULL;
|
||||||
|
|
||||||
|
base_store = file_storage_get_basestore_for_username (username);
|
||||||
|
|
||||||
|
storedir = get_path_to_storedir (fp_device_get_driver (dev),
|
||||||
|
fp_device_get_device_id (dev),
|
||||||
|
base_store);
|
||||||
|
|
||||||
|
g_debug ("file_storage_discover_prints() for user '%s' in '%s'",
|
||||||
|
username, storedir);
|
||||||
|
|
||||||
|
list = scan_dev_storedir (storedir, list);
|
||||||
|
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
int file_storage_deinit(void)
|
GSList *
|
||||||
|
file_storage_discover_users (void)
|
||||||
{
|
{
|
||||||
/* Nothing to do */
|
g_autoptr(GError) err = NULL;
|
||||||
return 0;
|
GSList *list = NULL;
|
||||||
|
const gchar *ent;
|
||||||
|
GDir *dir = g_dir_open (get_storage_path (), 0, &err);
|
||||||
|
|
||||||
|
if (!dir)
|
||||||
|
return list;
|
||||||
|
|
||||||
|
while ((ent = g_dir_read_name (dir)))
|
||||||
|
{
|
||||||
|
/* ent is a username */
|
||||||
|
if (*ent == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
list = g_slist_prepend (list, g_strdup (ent));
|
||||||
|
}
|
||||||
|
|
||||||
|
g_dir_close (dir);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
file_storage_init (void)
|
||||||
|
{
|
||||||
|
/* Nothing to do */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
file_storage_deinit (void)
|
||||||
|
{
|
||||||
|
g_clear_pointer (&storage_path, g_free);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,36 +6,35 @@
|
|||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License along
|
* You should have received a copy of the GNU General Public License along
|
||||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef FILE_STORAGE_H
|
#pragma once
|
||||||
|
|
||||||
#define FILE_STORAGE_H
|
int file_storage_print_data_save (FpPrint *print);
|
||||||
|
|
||||||
int file_storage_print_data_save(struct fp_print_data *data,
|
int file_storage_print_data_load (FpDevice *dev,
|
||||||
enum fp_finger finger, const char *username);
|
FpFinger finger,
|
||||||
|
const char *username,
|
||||||
|
FpPrint **print);
|
||||||
|
|
||||||
|
int file_storage_print_data_delete (FpDevice *dev,
|
||||||
|
FpFinger finger,
|
||||||
|
const char *username);
|
||||||
|
|
||||||
int file_storage_print_data_load(struct fp_dev *dev,
|
int file_storage_init (void);
|
||||||
enum fp_finger finger, struct fp_print_data **data, const char *username);
|
|
||||||
|
|
||||||
int file_storage_print_data_delete(struct fp_dscv_dev *dev,
|
int file_storage_deinit (void);
|
||||||
enum fp_finger finger, const char *username);
|
|
||||||
|
|
||||||
int file_storage_init(void);
|
GSList *file_storage_discover_prints (FpDevice *dev,
|
||||||
|
const char *username);
|
||||||
int file_storage_deinit(void);
|
GSList *file_storage_discover_users (void);
|
||||||
|
|
||||||
GSList *file_storage_discover_prints(struct fp_dscv_dev *dev, const char *username);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|||||||
@ -1 +0,0 @@
|
|||||||
VOID:STRING,BOOLEAN
|
|
||||||
116
src/fprintd.h
@ -6,98 +6,88 @@
|
|||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License along
|
* You should have received a copy of the GNU General Public License along
|
||||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __FPRINTD_H__
|
#pragma once
|
||||||
#define __FPRINTD_H__
|
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <dbus/dbus-glib.h>
|
#include <gio/gio.h>
|
||||||
|
#include <fprint.h>
|
||||||
|
#include "fprintd-enums.h"
|
||||||
|
#include "fprintd-dbus.h"
|
||||||
|
|
||||||
/* General */
|
/* General */
|
||||||
#define TIMEOUT 30
|
#define TIMEOUT 30
|
||||||
#define FPRINT_SERVICE_NAME "net.reactivated.Fprint"
|
#define FPRINT_SERVICE_NAME "net.reactivated.Fprint"
|
||||||
extern DBusGConnection *fprintd_dbus_conn;
|
#define FPRINT_SERVICE_PATH "/net/reactivated/Fprint"
|
||||||
|
|
||||||
/* Errors */
|
/* Errors */
|
||||||
GQuark fprint_error_quark(void);
|
GQuark fprint_error_quark (void);
|
||||||
GType fprint_error_get_type(void);
|
|
||||||
|
|
||||||
#define FPRINT_ERROR fprint_error_quark()
|
#define FPRINT_ERROR fprint_error_quark ()
|
||||||
#define FPRINT_TYPE_ERROR fprint_error_get_type()
|
|
||||||
#define FPRINT_ERROR_DBUS_INTERFACE "net.reactivated.Fprint.Error"
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
FPRINT_ERROR_CLAIM_DEVICE, /* developer didn't claim the device */
|
/* developer didn't claim the device */
|
||||||
FPRINT_ERROR_ALREADY_IN_USE, /* device is already claimed by somebody else */
|
FPRINT_ERROR_CLAIM_DEVICE, /*< nick=net.reactivated.Fprint.Error.ClaimDevice >*/
|
||||||
FPRINT_ERROR_INTERNAL, /* internal error occured */
|
/* device is already claimed by somebody else */
|
||||||
FPRINT_ERROR_PERMISSION_DENIED, /* PolicyKit refused the action */
|
FPRINT_ERROR_ALREADY_IN_USE, /*< nick=net.reactivated.Fprint.Error.AlreadyInUse >*/
|
||||||
FPRINT_ERROR_NO_ENROLLED_PRINTS, /* No prints are enrolled */
|
/* internal error occurred */
|
||||||
FPRINT_ERROR_NO_ACTION_IN_PROGRESS, /* No actions currently in progress */
|
FPRINT_ERROR_INTERNAL, /*< nick=net.reactivated.Fprint.Error.Internal >*/
|
||||||
FPRINT_ERROR_INVALID_FINGERNAME, /* the finger name passed was invalid */
|
/* PolicyKit refused the action */
|
||||||
FPRINT_ERROR_NO_SUCH_DEVICE, /* device does not exist */
|
FPRINT_ERROR_PERMISSION_DENIED, /*< nick=net.reactivated.Fprint.Error.PermissionDenied >*/
|
||||||
|
/* No prints are enrolled */
|
||||||
|
FPRINT_ERROR_NO_ENROLLED_PRINTS, /*< nick=net.reactivated.Fprint.Error.NoEnrolledPrints >*/
|
||||||
|
/* No actions currently in progress */
|
||||||
|
FPRINT_ERROR_NO_ACTION_IN_PROGRESS, /*< nick=net.reactivated.Fprint.Error.NoActionInProgress >*/
|
||||||
|
/* the finger name passed was invalid */
|
||||||
|
FPRINT_ERROR_INVALID_FINGERNAME, /*< nick=net.reactivated.Fprint.Error.InvalidFingername >*/
|
||||||
|
/* device does not exist */
|
||||||
|
FPRINT_ERROR_NO_SUCH_DEVICE, /*< nick=net.reactivated.Fprint.Error.NoSuchDevice >*/
|
||||||
} FprintError;
|
} FprintError;
|
||||||
|
|
||||||
|
/* Enum of possible permissions, orders and nick matter here:
|
||||||
|
- The order controls the priority of a required permission when various are
|
||||||
|
accepted: the lowest the value, the more priorty it has.
|
||||||
|
- Nick must match the relative polkit rule.
|
||||||
|
*/
|
||||||
|
typedef enum {
|
||||||
|
FPRINT_DEVICE_PERMISSION_NONE = 0,
|
||||||
|
FPRINT_DEVICE_PERMISSION_VERIFY = (1 << 0), /*< nick=net.reactivated.fprint.device.verify >*/
|
||||||
|
FPRINT_DEVICE_PERMISSION_ENROLL = (1 << 1), /*< nick=net.reactivated.fprint.device.enroll >*/
|
||||||
|
FPRINT_DEVICE_PERMISSION_SETUSERNAME = (1 << 2), /*< nick=net.reactivated.fprint.device.setusername >*/
|
||||||
|
} FprintDevicePermission;
|
||||||
|
|
||||||
/* Manager */
|
/* Manager */
|
||||||
#define FPRINT_TYPE_MANAGER (fprint_manager_get_type())
|
#define FPRINT_TYPE_MANAGER (fprint_manager_get_type ())
|
||||||
#define FPRINT_MANAGER(object) (G_TYPE_CHECK_INSTANCE_CAST((object), FPRINT_TYPE_MANAGER, FprintManager))
|
G_DECLARE_FINAL_TYPE (FprintManager, fprint_manager, FPRINT, MANAGER, GObject)
|
||||||
#define FPRINT_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), FPRINT_TYPE_MANAGER, FprintManagerClass))
|
|
||||||
#define FPRINT_IS_MANAGER(object) (G_TYPE_CHECK_INSTANCE_TYPE((object), FPRINT_TYPE_MANAGER))
|
|
||||||
#define FPRINT_IS_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), FPRINT_TYPE_MANAGER))
|
|
||||||
#define FPRINT_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), FPRINT_TYPE_MANAGER, FprintManagerClass))
|
|
||||||
|
|
||||||
struct FprintManager {
|
struct _FprintManager
|
||||||
GObject parent;
|
{
|
||||||
|
GObject parent;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct FprintManagerClass {
|
FprintManager *fprint_manager_new (GDBusConnection *connection,
|
||||||
GObjectClass parent;
|
gboolean no_timeout);
|
||||||
};
|
|
||||||
|
|
||||||
typedef struct FprintManager FprintManager;
|
|
||||||
typedef struct FprintManagerClass FprintManagerClass;
|
|
||||||
|
|
||||||
FprintManager *fprint_manager_new(gboolean no_timeout);
|
|
||||||
GType fprint_manager_get_type(void);
|
|
||||||
|
|
||||||
/* Device */
|
/* Device */
|
||||||
#define FPRINT_TYPE_DEVICE (fprint_device_get_type())
|
#define FPRINT_TYPE_DEVICE (fprint_device_get_type ())
|
||||||
#define FPRINT_DEVICE(object) (G_TYPE_CHECK_INSTANCE_CAST((object), FPRINT_DEVICE_TYPE, FprintDevice))
|
G_DECLARE_FINAL_TYPE (FprintDevice, fprint_device, FPRINT, DEVICE,
|
||||||
#define FPRINT_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), FPRINT_DEVICE_TYPE, FprintDeviceClass))
|
FprintDBusDeviceSkeleton)
|
||||||
#define FPRINT_IS_DEVICE(object) (G_TYPE_CHECK_INSTANCE_TYPE((object), FPRINT_TYPE_DEVICE))
|
|
||||||
#define FPRINT_IS_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), FPRINT_TYPE_DEVICE))
|
|
||||||
#define FPRINT_DEVICE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), FPRINT_TYPE_DEVICE, FprintDeviceClass))
|
|
||||||
|
|
||||||
struct FprintDevice {
|
struct _FprintDevice
|
||||||
GObject parent;
|
{
|
||||||
|
FprintDBusDeviceSkeleton parent;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct FprintDeviceClass {
|
FprintDevice *fprint_device_new (FpDevice *dev);
|
||||||
GObjectClass parent;
|
guint32 _fprint_device_get_id (FprintDevice *rdev);
|
||||||
};
|
|
||||||
|
|
||||||
typedef struct FprintDevice FprintDevice;
|
|
||||||
typedef struct FprintDeviceClass FprintDeviceClass;
|
|
||||||
|
|
||||||
FprintDevice *fprint_device_new(struct fp_dscv_dev *ddev);
|
|
||||||
GType fprint_device_get_type(void);
|
|
||||||
guint32 _fprint_device_get_id(FprintDevice *rdev);
|
|
||||||
/* Print */
|
/* Print */
|
||||||
/* TODO */
|
/* TODO */
|
||||||
|
|
||||||
/* Binding data included in main.c thorugh server-bindings.h which individual
|
|
||||||
* class implementations need to access.
|
|
||||||
*/
|
|
||||||
extern const DBusGObjectInfo dbus_glib_fprint_manager_object_info;
|
|
||||||
extern const DBusGObjectInfo dbus_glib_fprint_device_object_info;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|||||||
196
src/loop.c
@ -1,196 +0,0 @@
|
|||||||
/*
|
|
||||||
* fprint D-Bus daemon
|
|
||||||
* Copyright (C) 2008 Daniel Drake <dsd@gentoo.org>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along
|
|
||||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "config.h"
|
|
||||||
|
|
||||||
#include <glib.h>
|
|
||||||
#include <libfprint/fprint.h>
|
|
||||||
|
|
||||||
#include <poll.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#include "loop.h"
|
|
||||||
|
|
||||||
struct fdsource {
|
|
||||||
GSource source;
|
|
||||||
GSList *pollfds;
|
|
||||||
};
|
|
||||||
|
|
||||||
static gboolean source_prepare(GSource *source, gint *timeout)
|
|
||||||
{
|
|
||||||
int r;
|
|
||||||
struct timeval tv;
|
|
||||||
|
|
||||||
r = fp_get_next_timeout(&tv);
|
|
||||||
if (r == 0) {
|
|
||||||
*timeout = -1;
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!timerisset(&tv))
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
*timeout = (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean source_check(GSource *source)
|
|
||||||
{
|
|
||||||
struct fdsource *_fdsource = (struct fdsource *) source;
|
|
||||||
GSList *l;
|
|
||||||
struct timeval tv;
|
|
||||||
int r;
|
|
||||||
|
|
||||||
if (!_fdsource->pollfds)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
for (l = _fdsource->pollfds; l != NULL; l = l->next) {
|
|
||||||
GPollFD *pollfd = l->data;
|
|
||||||
|
|
||||||
if (pollfd->revents)
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
r = fp_get_next_timeout(&tv);
|
|
||||||
if (r == 1 && !timerisset(&tv))
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean source_dispatch(GSource *source, GSourceFunc callback,
|
|
||||||
gpointer data)
|
|
||||||
{
|
|
||||||
struct timeval zerotimeout = {
|
|
||||||
.tv_sec = 0,
|
|
||||||
.tv_usec = 0,
|
|
||||||
};
|
|
||||||
|
|
||||||
/* FIXME error handling */
|
|
||||||
fp_handle_events_timeout(&zerotimeout);
|
|
||||||
|
|
||||||
/* FIXME whats the return value used for? */
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void source_finalize(GSource *source)
|
|
||||||
{
|
|
||||||
struct fdsource *_fdsource = (struct fdsource *) source;
|
|
||||||
GSList *l;
|
|
||||||
|
|
||||||
if (!_fdsource->pollfds)
|
|
||||||
return;
|
|
||||||
|
|
||||||
for (l = _fdsource->pollfds; l != NULL; l = l->next) {
|
|
||||||
GPollFD *pollfd = l->data;
|
|
||||||
|
|
||||||
g_source_remove_poll((GSource *) _fdsource, pollfd);
|
|
||||||
g_slice_free(GPollFD, pollfd);
|
|
||||||
_fdsource->pollfds = g_slist_delete_link(_fdsource->pollfds, l);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_slist_free(_fdsource->pollfds);
|
|
||||||
}
|
|
||||||
|
|
||||||
static GSourceFuncs sourcefuncs = {
|
|
||||||
.prepare = source_prepare,
|
|
||||||
.check = source_check,
|
|
||||||
.dispatch = source_dispatch,
|
|
||||||
.finalize = source_finalize,
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct fdsource *fdsource = NULL;
|
|
||||||
|
|
||||||
static void pollfd_add(int fd, short events)
|
|
||||||
{
|
|
||||||
GPollFD *pollfd;
|
|
||||||
|
|
||||||
pollfd = g_slice_new(GPollFD);
|
|
||||||
pollfd->fd = fd;
|
|
||||||
pollfd->events = 0;
|
|
||||||
pollfd->revents = 0;
|
|
||||||
if (events & POLLIN)
|
|
||||||
pollfd->events |= G_IO_IN;
|
|
||||||
if (events & POLLOUT)
|
|
||||||
pollfd->events |= G_IO_OUT;
|
|
||||||
|
|
||||||
fdsource->pollfds = g_slist_prepend(fdsource->pollfds, pollfd);
|
|
||||||
g_source_add_poll((GSource *) fdsource, pollfd);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void pollfd_added_cb(int fd, short events)
|
|
||||||
{
|
|
||||||
g_debug("now monitoring fd %d", fd);
|
|
||||||
pollfd_add(fd, events);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void pollfd_removed_cb(int fd)
|
|
||||||
{
|
|
||||||
GSList *l;
|
|
||||||
|
|
||||||
g_debug("no longer monitoring fd %d", fd);
|
|
||||||
|
|
||||||
if (!fdsource->pollfds) {
|
|
||||||
g_debug("cannot remove from list as list is empty?");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (l = fdsource->pollfds; l != NULL; l = l->next) {
|
|
||||||
GPollFD *pollfd = l->data;
|
|
||||||
|
|
||||||
if (pollfd->fd != fd)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
g_source_remove_poll((GSource *) fdsource, pollfd);
|
|
||||||
g_slice_free(GPollFD, pollfd);
|
|
||||||
fdsource->pollfds = g_slist_delete_link(fdsource->pollfds, l);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_error("couldn't find fd %d in list\n", fd);
|
|
||||||
}
|
|
||||||
|
|
||||||
int setup_pollfds(void)
|
|
||||||
{
|
|
||||||
ssize_t numfds;
|
|
||||||
size_t i;
|
|
||||||
struct fp_pollfd *fpfds;
|
|
||||||
GSource *gsource;
|
|
||||||
|
|
||||||
gsource = g_source_new(&sourcefuncs, sizeof(struct fdsource));
|
|
||||||
fdsource = (struct fdsource *) gsource;
|
|
||||||
fdsource->pollfds = NULL;
|
|
||||||
|
|
||||||
numfds = fp_get_pollfds(&fpfds);
|
|
||||||
if (numfds < 0) {
|
|
||||||
if (fpfds)
|
|
||||||
free(fpfds);
|
|
||||||
return (int) numfds;
|
|
||||||
} else if (numfds > 0) {
|
|
||||||
for (i = 0; i < numfds; i++) {
|
|
||||||
struct fp_pollfd *fpfd = &fpfds[i];
|
|
||||||
pollfd_add(fpfd->fd, fpfd->events);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
free(fpfds);
|
|
||||||
fp_set_pollfd_notifiers(pollfd_added_cb, pollfd_removed_cb);
|
|
||||||
g_source_attach(gsource, NULL);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
27
src/loop.h
@ -1,27 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2008 Daniel Drake <dsd@gentoo.org>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along
|
|
||||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef POLL_H
|
|
||||||
|
|
||||||
#define POLL_H
|
|
||||||
|
|
||||||
int setup_pollfds(void);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
317
src/main.c
@ -1,17 +1,18 @@
|
|||||||
/*
|
/*
|
||||||
* fprint D-Bus daemon
|
* fprint D-Bus daemon
|
||||||
* Copyright (C) 2008 Daniel Drake <dsd@gentoo.org>
|
* Copyright (C) 2008 Daniel Drake <dsd@gentoo.org>
|
||||||
|
* Copyright (C) 2020 Marco Trevisan <marco.trevisan@canonical.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License along
|
* You should have received a copy of the GNU General Public License along
|
||||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
@ -19,207 +20,203 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <locale.h>
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <dbus/dbus-glib-bindings.h>
|
#include <gio/gio.h>
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <glib/gi18n.h>
|
#include <glib/gi18n.h>
|
||||||
#include <libfprint/fprint.h>
|
#include <fprint.h>
|
||||||
#include <glib-object.h>
|
#include <glib-object.h>
|
||||||
|
#include <glib-unix.h>
|
||||||
#include <gmodule.h>
|
#include <gmodule.h>
|
||||||
|
|
||||||
#include "fprintd.h"
|
#include "fprintd.h"
|
||||||
#include "loop.h"
|
|
||||||
#include "storage.h"
|
#include "storage.h"
|
||||||
#include "file_storage.h"
|
#include "file_storage.h"
|
||||||
|
|
||||||
extern DBusGConnection *fprintd_dbus_conn;
|
fp_storage store;
|
||||||
|
|
||||||
static gboolean no_timeout = FALSE;
|
static gboolean no_timeout = FALSE;
|
||||||
static gboolean g_fatal_warnings = FALSE;
|
static gboolean g_fatal_warnings = FALSE;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
set_storage_file (void)
|
set_storage_file (void)
|
||||||
{
|
{
|
||||||
store.init = &file_storage_init;
|
store.init = &file_storage_init;
|
||||||
store.deinit = &file_storage_deinit;
|
store.deinit = &file_storage_deinit;
|
||||||
store.print_data_save = &file_storage_print_data_save;
|
store.print_data_save = &file_storage_print_data_save;
|
||||||
store.print_data_load = &file_storage_print_data_load;
|
store.print_data_load = &file_storage_print_data_load;
|
||||||
store.print_data_delete = &file_storage_print_data_delete;
|
store.print_data_delete = &file_storage_print_data_delete;
|
||||||
store.discover_prints = &file_storage_discover_prints;
|
store.discover_prints = &file_storage_discover_prints;
|
||||||
|
store.discover_users = &file_storage_discover_users;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
load_storage_module (const char *module_name)
|
load_storage_module (const char *module_name)
|
||||||
{
|
{
|
||||||
GModule *module;
|
GModule *module;
|
||||||
char *filename;
|
g_autofree char *filename = NULL;
|
||||||
|
|
||||||
filename = g_module_build_path (PLUGINDIR, module_name);
|
filename = g_module_build_path (PLUGINDIR, module_name);
|
||||||
module = g_module_open (filename, 0);
|
module = g_module_open (filename, 0);
|
||||||
g_free (filename);
|
if (module == NULL)
|
||||||
if (module == NULL)
|
return FALSE;
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
if (!g_module_symbol (module, "init", (gpointer *) &store.init) ||
|
if (!g_module_symbol (module, "init", (gpointer *) &store.init) ||
|
||||||
!g_module_symbol (module, "deinit", (gpointer *) &store.deinit) ||
|
!g_module_symbol (module, "deinit", (gpointer *) &store.deinit) ||
|
||||||
!g_module_symbol (module, "print_data_save", (gpointer *) &store.print_data_save) ||
|
!g_module_symbol (module, "print_data_save", (gpointer *) &store.print_data_save) ||
|
||||||
!g_module_symbol (module, "print_data_load", (gpointer *) &store.print_data_load) ||
|
!g_module_symbol (module, "print_data_load", (gpointer *) &store.print_data_load) ||
|
||||||
!g_module_symbol (module, "print_data_delete", (gpointer *) &store.print_data_delete) ||
|
!g_module_symbol (module, "print_data_delete", (gpointer *) &store.print_data_delete) ||
|
||||||
!g_module_symbol (module, "discover_prints", (gpointer *) &store.discover_prints)) {
|
!g_module_symbol (module, "discover_prints", (gpointer *) &store.discover_prints))
|
||||||
g_module_close (module);
|
{
|
||||||
return FALSE;
|
g_module_close (module);
|
||||||
}
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
g_module_make_resident (module);
|
g_module_make_resident (module);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
load_conf (void)
|
load_conf (void)
|
||||||
{
|
{
|
||||||
GKeyFile *file;
|
g_autofree char *filename = NULL;
|
||||||
char *filename;
|
g_autofree char *module_name = NULL;
|
||||||
char *module_name;
|
|
||||||
GError *error = NULL;
|
|
||||||
gboolean ret;
|
|
||||||
|
|
||||||
filename = g_build_filename (SYSCONFDIR, "fprintd.conf", NULL);
|
g_autoptr(GKeyFile) file = NULL;
|
||||||
file = g_key_file_new ();
|
g_autoptr(GError) error = NULL;
|
||||||
g_debug("About to load configuration file '%s'", filename);
|
|
||||||
if (!g_key_file_load_from_file (file, filename, G_KEY_FILE_NONE, &error)) {
|
|
||||||
g_warning ("Could not open \"%s\": %s\n", filename, error->message);
|
|
||||||
goto bail;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_free (filename);
|
filename = g_build_filename (SYSCONFDIR, "fprintd.conf", NULL);
|
||||||
filename = NULL;
|
file = g_key_file_new ();
|
||||||
|
g_debug ("About to load configuration file '%s'", filename);
|
||||||
|
if (!g_key_file_load_from_file (file, filename, G_KEY_FILE_NONE, &error))
|
||||||
|
{
|
||||||
|
g_warning ("Could not open \"%s\": %s\n", filename, error->message);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
module_name = g_key_file_get_string (file, "storage", "type", &error);
|
module_name = g_key_file_get_string (file, "storage", "type", &error);
|
||||||
if (module_name == NULL)
|
if (module_name == NULL)
|
||||||
goto bail;
|
return FALSE;
|
||||||
|
|
||||||
g_key_file_free (file);
|
if (g_str_equal (module_name, "file"))
|
||||||
|
{
|
||||||
|
set_storage_file ();
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
if (g_str_equal (module_name, "file")) {
|
return load_storage_module (module_name);
|
||||||
g_free (module_name);
|
|
||||||
set_storage_file ();
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = load_storage_module (module_name);
|
|
||||||
g_free (module_name);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
bail:
|
|
||||||
g_key_file_free (file);
|
|
||||||
g_free (filename);
|
|
||||||
g_error_free (error);
|
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const GOptionEntry entries[] = {
|
static const GOptionEntry entries[] = {
|
||||||
{"g-fatal-warnings", 0, 0, G_OPTION_ARG_NONE, &g_fatal_warnings, "Make all warnings fatal", NULL},
|
{"g-fatal-warnings", 0, 0, G_OPTION_ARG_NONE, &g_fatal_warnings, "Make all warnings fatal", NULL},
|
||||||
{"no-timeout", 't', 0, G_OPTION_ARG_NONE, &no_timeout, "Do not exit after unused for a while", NULL},
|
{"no-timeout", 't', 0, G_OPTION_ARG_NONE, &no_timeout, "Do not exit after unused for a while", NULL},
|
||||||
{ NULL }
|
{ NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
static gboolean
|
||||||
|
sigterm_callback (gpointer data)
|
||||||
{
|
{
|
||||||
GOptionContext *context;
|
GMainLoop *loop = data;
|
||||||
GMainLoop *loop;
|
|
||||||
GError *error = NULL;
|
|
||||||
FprintManager *manager;
|
|
||||||
DBusGProxy *driver_proxy;
|
|
||||||
guint32 request_name_ret;
|
|
||||||
int r = 0;
|
|
||||||
|
|
||||||
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
|
g_main_loop_quit (loop);
|
||||||
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
|
return FALSE;
|
||||||
textdomain (GETTEXT_PACKAGE);
|
|
||||||
|
|
||||||
context = g_option_context_new ("Fingerprint handler daemon");
|
|
||||||
g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
|
|
||||||
|
|
||||||
#if !GLIB_CHECK_VERSION (2, 36, 0)
|
|
||||||
g_type_init();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (g_option_context_parse (context, &argc, &argv, &error) == FALSE) {
|
|
||||||
g_warning ("couldn't parse command-line options: %s\n", error->message);
|
|
||||||
g_error_free (error);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (g_fatal_warnings) {
|
|
||||||
GLogLevelFlags fatal_mask;
|
|
||||||
|
|
||||||
fatal_mask = g_log_set_always_fatal (G_LOG_FATAL_MASK);
|
|
||||||
fatal_mask |= G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL;
|
|
||||||
g_log_set_always_fatal (fatal_mask);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Obtain a connection to the session bus */
|
|
||||||
fprintd_dbus_conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error);
|
|
||||||
if (fprintd_dbus_conn == NULL) {
|
|
||||||
g_warning("Failed to open connection to bus: %s", error->message);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
driver_proxy = dbus_g_proxy_new_for_name(fprintd_dbus_conn,
|
|
||||||
DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS);
|
|
||||||
|
|
||||||
|
|
||||||
if (!org_freedesktop_DBus_request_name(driver_proxy, FPRINT_SERVICE_NAME,
|
|
||||||
0, &request_name_ret, &error)) {
|
|
||||||
g_warning("Failed to get name: %s", error->message);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (request_name_ret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
|
|
||||||
g_warning ("Got result code %u from requesting name", request_name_ret);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Load the configuration file,
|
|
||||||
* and the default storage plugin */
|
|
||||||
if (!load_conf())
|
|
||||||
set_storage_file ();
|
|
||||||
store.init ();
|
|
||||||
|
|
||||||
r = fp_init();
|
|
||||||
if (r < 0) {
|
|
||||||
g_warning("fprint init failed with error %d\n", r);
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
loop = g_main_loop_new(NULL, FALSE);
|
|
||||||
|
|
||||||
r = setup_pollfds();
|
|
||||||
if (r < 0) {
|
|
||||||
g_warning("pollfd setup failed\n");
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_debug("Launching FprintObject");
|
|
||||||
|
|
||||||
/* create the one instance of the Manager object to be shared between
|
|
||||||
* all fprintd users */
|
|
||||||
manager = fprint_manager_new(no_timeout);
|
|
||||||
|
|
||||||
g_debug("D-Bus service launched with name: %s", FPRINT_SERVICE_NAME);
|
|
||||||
|
|
||||||
g_debug("entering main loop");
|
|
||||||
g_main_loop_run(loop);
|
|
||||||
g_debug("main loop completed");
|
|
||||||
|
|
||||||
g_object_unref (manager);
|
|
||||||
|
|
||||||
err:
|
|
||||||
fp_exit();
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
on_name_acquired (GDBusConnection *connection,
|
||||||
|
const char *name,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
g_debug ("D-Bus service launched with name: %s", name);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
on_name_lost (GDBusConnection *connection,
|
||||||
|
const char *name,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
GMainLoop *loop = user_data;
|
||||||
|
|
||||||
|
g_warning ("Failed to get name: %s", name);
|
||||||
|
|
||||||
|
g_main_loop_quit (loop);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main (int argc, char **argv)
|
||||||
|
{
|
||||||
|
g_autoptr(GOptionContext) context = NULL;
|
||||||
|
g_autoptr(GMainLoop) loop = NULL;
|
||||||
|
g_autoptr(GError) error = NULL;
|
||||||
|
g_autoptr(FprintManager) manager = NULL;
|
||||||
|
g_autoptr(GDBusConnection) connection = NULL;
|
||||||
|
guint32 request_name_ret;
|
||||||
|
|
||||||
|
setlocale (LC_ALL, "");
|
||||||
|
|
||||||
|
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
|
||||||
|
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
|
||||||
|
textdomain (GETTEXT_PACKAGE);
|
||||||
|
|
||||||
|
context = g_option_context_new ("Fingerprint handler daemon");
|
||||||
|
g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
|
||||||
|
|
||||||
|
if (g_option_context_parse (context, &argc, &argv, &error) == FALSE)
|
||||||
|
{
|
||||||
|
g_warning ("couldn't parse command-line options: %s\n", error->message);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (g_fatal_warnings)
|
||||||
|
{
|
||||||
|
GLogLevelFlags fatal_mask;
|
||||||
|
|
||||||
|
fatal_mask = g_log_set_always_fatal (G_LOG_FATAL_MASK);
|
||||||
|
fatal_mask |= G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL;
|
||||||
|
g_log_set_always_fatal (fatal_mask);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Obtain a connection to the system bus */
|
||||||
|
connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
|
||||||
|
if (!G_IS_DBUS_CONNECTION (connection))
|
||||||
|
{
|
||||||
|
g_warning ("Failed to open connection to bus: %s", error->message);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Load the configuration file,
|
||||||
|
* and the default storage plugin */
|
||||||
|
if (!load_conf ())
|
||||||
|
set_storage_file ();
|
||||||
|
store.init ();
|
||||||
|
|
||||||
|
loop = g_main_loop_new (NULL, FALSE);
|
||||||
|
g_unix_signal_add (SIGTERM, sigterm_callback, loop);
|
||||||
|
|
||||||
|
g_debug ("Launching FprintObject");
|
||||||
|
|
||||||
|
/* create the one instance of the Manager object to be shared between
|
||||||
|
* all fprintd users. This blocks until all the devices are enumerated */
|
||||||
|
manager = fprint_manager_new (connection, no_timeout);
|
||||||
|
|
||||||
|
/* Obtain the well-known name after the manager has been initialized.
|
||||||
|
* Otherwise a client immediately enumerating the devices will not see
|
||||||
|
* any. */
|
||||||
|
request_name_ret = g_bus_own_name_on_connection (connection,
|
||||||
|
FPRINT_SERVICE_NAME,
|
||||||
|
G_BUS_NAME_OWNER_FLAGS_NONE,
|
||||||
|
on_name_acquired,
|
||||||
|
on_name_lost,
|
||||||
|
loop, NULL);
|
||||||
|
|
||||||
|
g_debug ("entering main loop");
|
||||||
|
g_main_loop_run (loop);
|
||||||
|
g_bus_unown_name (request_name_ret);
|
||||||
|
g_debug ("main loop completed");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|||||||
521
src/manager.c
@ -1,17 +1,18 @@
|
|||||||
/*
|
/*
|
||||||
* /net/reactivated/Fprint/Manager object implementation
|
* /net/reactivated/Fprint/Manager object implementation
|
||||||
* Copyright (C) 2008 Daniel Drake <dsd@gentoo.org>
|
* Copyright (C) 2008 Daniel Drake <dsd@gentoo.org>
|
||||||
|
* Copyright (C) 2020 Marco Trevisan <marco.trevisan@canonical.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License along
|
* You should have received a copy of the GNU General Public License along
|
||||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
@ -19,210 +20,438 @@
|
|||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <dbus/dbus-glib-bindings.h>
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <glib/gi18n.h>
|
#include <glib/gi18n.h>
|
||||||
#include <libfprint/fprint.h>
|
#include <fprint.h>
|
||||||
#include <glib-object.h>
|
#include <glib-object.h>
|
||||||
|
|
||||||
#include "fprintd.h"
|
#include "fprintd.h"
|
||||||
|
|
||||||
DBusGConnection *fprintd_dbus_conn;
|
static void fprint_manager_constructed (GObject *object);
|
||||||
|
static gboolean fprint_manager_get_devices (FprintManager *manager,
|
||||||
static gboolean fprint_manager_get_devices(FprintManager *manager,
|
GPtrArray **devices,
|
||||||
GPtrArray **devices, GError **error);
|
GError **error);
|
||||||
static gboolean fprint_manager_get_default_device(FprintManager *manager,
|
static gboolean fprint_manager_get_default_device (FprintManager *manager,
|
||||||
const char **device, GError **error);
|
const char **device,
|
||||||
#include "manager-dbus-glue.h"
|
GError **error);
|
||||||
|
|
||||||
static GObjectClass *parent_class = NULL;
|
|
||||||
|
|
||||||
G_DEFINE_TYPE(FprintManager, fprint_manager, G_TYPE_OBJECT);
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
GSList *dev_registry;
|
GDBusConnection *connection;
|
||||||
gboolean no_timeout;
|
GDBusObjectManager *object_manager;
|
||||||
guint timeout_id;
|
FprintDBusManager *dbus_manager;
|
||||||
|
FpContext *context;
|
||||||
|
gboolean no_timeout;
|
||||||
|
guint timeout_id;
|
||||||
} FprintManagerPrivate;
|
} FprintManagerPrivate;
|
||||||
|
|
||||||
#define FPRINT_MANAGER_GET_PRIVATE(o) \
|
G_DEFINE_TYPE_WITH_CODE (FprintManager, fprint_manager, G_TYPE_OBJECT, G_ADD_PRIVATE (FprintManager))
|
||||||
(G_TYPE_INSTANCE_GET_PRIVATE ((o), FPRINT_TYPE_MANAGER, FprintManagerPrivate))
|
|
||||||
|
|
||||||
static void fprint_manager_finalize(GObject *object)
|
enum {
|
||||||
|
PROP_0,
|
||||||
|
FPRINT_MANAGER_CONNECTION,
|
||||||
|
N_PROPS
|
||||||
|
};
|
||||||
|
|
||||||
|
static GParamSpec *properties[N_PROPS];
|
||||||
|
|
||||||
|
static void
|
||||||
|
fprint_manager_finalize (GObject *object)
|
||||||
{
|
{
|
||||||
FprintManagerPrivate *priv = FPRINT_MANAGER_GET_PRIVATE (object);
|
FprintManagerPrivate *priv = fprint_manager_get_instance_private (FPRINT_MANAGER (object));
|
||||||
|
|
||||||
g_slist_free(priv->dev_registry);
|
g_clear_object (&priv->object_manager);
|
||||||
|
g_clear_object (&priv->dbus_manager);
|
||||||
|
g_clear_object (&priv->connection);
|
||||||
|
g_clear_object (&priv->context);
|
||||||
|
|
||||||
G_OBJECT_CLASS(parent_class)->finalize(object);
|
G_OBJECT_CLASS (fprint_manager_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fprint_manager_class_init(FprintManagerClass *klass)
|
static FprintDevice *
|
||||||
|
fprint_dbus_object_skeleton_get_device (FprintDBusObjectSkeleton *object)
|
||||||
{
|
{
|
||||||
dbus_g_object_type_install_info(FPRINT_TYPE_MANAGER,
|
FprintDevice *rdev;
|
||||||
&dbus_glib_fprint_manager_object_info);
|
|
||||||
dbus_g_error_domain_register (FPRINT_ERROR, FPRINT_ERROR_DBUS_INTERFACE, FPRINT_TYPE_ERROR);
|
|
||||||
|
|
||||||
g_type_class_add_private ((GObjectClass *) klass, sizeof (FprintManagerPrivate));
|
g_object_get (object, "device", &rdev, NULL);
|
||||||
|
return rdev;
|
||||||
G_OBJECT_CLASS(klass)->finalize = fprint_manager_finalize;
|
|
||||||
parent_class = g_type_class_peek_parent(klass);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gchar *get_device_path(FprintDevice *rdev)
|
static void
|
||||||
|
fprint_manager_set_property (GObject *object, guint property_id,
|
||||||
|
const GValue *value, GParamSpec *pspec)
|
||||||
{
|
{
|
||||||
return g_strdup_printf("/net/reactivated/Fprint/Device/%d",
|
FprintManager *self = FPRINT_MANAGER (object);
|
||||||
_fprint_device_get_id(rdev));
|
FprintManagerPrivate *priv = fprint_manager_get_instance_private (self);
|
||||||
|
|
||||||
|
switch (property_id)
|
||||||
|
{
|
||||||
|
case FPRINT_MANAGER_CONNECTION:
|
||||||
|
priv->connection = g_value_dup_object (value);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
fprint_manager_get_property (GObject *object, guint property_id,
|
||||||
|
GValue *value, GParamSpec *pspec)
|
||||||
|
{
|
||||||
|
FprintManager *self = FPRINT_MANAGER (object);
|
||||||
|
FprintManagerPrivate *priv = fprint_manager_get_instance_private (self);
|
||||||
|
|
||||||
|
switch (property_id)
|
||||||
|
{
|
||||||
|
case FPRINT_MANAGER_CONNECTION:
|
||||||
|
g_value_set_object (value, priv->connection);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
fprint_manager_class_init (FprintManagerClass *klass)
|
||||||
|
{
|
||||||
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
|
||||||
|
object_class->constructed = fprint_manager_constructed;
|
||||||
|
object_class->set_property = fprint_manager_set_property;
|
||||||
|
object_class->get_property = fprint_manager_get_property;
|
||||||
|
object_class->finalize = fprint_manager_finalize;
|
||||||
|
|
||||||
|
properties[FPRINT_MANAGER_CONNECTION] =
|
||||||
|
g_param_spec_object ("connection",
|
||||||
|
"Connection",
|
||||||
|
"Set GDBus connection property",
|
||||||
|
G_TYPE_DBUS_CONNECTION,
|
||||||
|
G_PARAM_CONSTRUCT_ONLY |
|
||||||
|
G_PARAM_READWRITE);
|
||||||
|
|
||||||
|
g_object_class_install_properties (object_class, N_PROPS, properties);
|
||||||
|
}
|
||||||
|
|
||||||
|
static gchar *
|
||||||
|
get_device_path (FprintDevice *rdev)
|
||||||
|
{
|
||||||
|
return g_strdup_printf (FPRINT_SERVICE_PATH "/Device/%d",
|
||||||
|
_fprint_device_get_id (rdev));
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
fprint_manager_timeout_cb (FprintManager *manager)
|
fprint_manager_timeout_cb (FprintManager *manager)
|
||||||
{
|
{
|
||||||
//FIXME kill all the devices
|
//FIXME kill all the devices
|
||||||
exit(0);
|
exit (0);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
fprint_manager_in_use_notified (FprintDevice *rdev, GParamSpec *spec, FprintManager *manager)
|
fprint_manager_in_use_notified (FprintDevice *rdev, GParamSpec *spec, FprintManager *manager)
|
||||||
{
|
{
|
||||||
FprintManagerPrivate *priv = FPRINT_MANAGER_GET_PRIVATE (manager);
|
FprintManagerPrivate *priv = fprint_manager_get_instance_private (manager);
|
||||||
guint num_devices_used = 0;
|
guint num_devices_used = 0;
|
||||||
GSList *l;
|
|
||||||
gboolean in_use;
|
|
||||||
|
|
||||||
if (priv->timeout_id > 0) {
|
g_autolist (GDBusObject) devices = NULL;
|
||||||
g_source_remove (priv->timeout_id);
|
GList *l;
|
||||||
priv->timeout_id = 0;
|
gboolean in_use;
|
||||||
}
|
|
||||||
if (priv->no_timeout)
|
|
||||||
return;
|
|
||||||
|
|
||||||
for (l = priv->dev_registry; l != NULL; l = l->next) {
|
if (priv->timeout_id > 0)
|
||||||
FprintDevice *dev = l->data;
|
{
|
||||||
|
g_source_remove (priv->timeout_id);
|
||||||
|
priv->timeout_id = 0;
|
||||||
|
}
|
||||||
|
if (priv->no_timeout)
|
||||||
|
return;
|
||||||
|
|
||||||
g_object_get (G_OBJECT(dev), "in-use", &in_use, NULL);
|
devices = g_dbus_object_manager_get_objects (priv->object_manager);
|
||||||
if (in_use != FALSE)
|
|
||||||
num_devices_used++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (num_devices_used == 0)
|
for (l = devices; l != NULL; l = l->next)
|
||||||
priv->timeout_id = g_timeout_add_seconds (TIMEOUT, (GSourceFunc) fprint_manager_timeout_cb, manager);
|
{
|
||||||
|
g_autoptr(FprintDevice) dev = NULL;
|
||||||
|
FprintDBusObjectSkeleton *object = l->data;
|
||||||
|
|
||||||
|
dev = fprint_dbus_object_skeleton_get_device (object);
|
||||||
|
g_object_get (G_OBJECT (dev), "in-use", &in_use, NULL);
|
||||||
|
if (in_use != FALSE)
|
||||||
|
num_devices_used++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (num_devices_used == 0)
|
||||||
|
priv->timeout_id = g_timeout_add_seconds (TIMEOUT, (GSourceFunc) fprint_manager_timeout_cb, manager);
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
handle_get_devices (FprintManager *manager, GDBusMethodInvocation *invocation,
|
||||||
|
FprintDBusManager *skeleton)
|
||||||
|
{
|
||||||
|
g_autoptr(GPtrArray) devices = NULL;
|
||||||
|
g_autoptr(GError) error = NULL;
|
||||||
|
|
||||||
|
if (!fprint_manager_get_devices (manager, &devices, &error))
|
||||||
|
{
|
||||||
|
g_dbus_method_invocation_return_gerror (invocation, error);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
fprint_dbus_manager_complete_get_devices (skeleton, invocation,
|
||||||
|
(const gchar *const *)
|
||||||
|
devices->pdata);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
handle_get_default_device (FprintManager *manager,
|
||||||
|
GDBusMethodInvocation *invocation,
|
||||||
|
FprintDBusManager *skeleton)
|
||||||
|
{
|
||||||
|
const gchar *device;
|
||||||
|
|
||||||
|
g_autoptr(GError) error = NULL;
|
||||||
|
|
||||||
|
if (!fprint_manager_get_default_device (manager, &device, &error))
|
||||||
|
{
|
||||||
|
g_dbus_method_invocation_return_gerror (invocation, error);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
fprint_dbus_manager_complete_get_default_device (skeleton, invocation,
|
||||||
|
device);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
device_added_cb (FprintManager *manager, FpDevice *device, FpContext *context)
|
||||||
|
{
|
||||||
|
FprintManagerPrivate *priv = fprint_manager_get_instance_private (manager);
|
||||||
|
|
||||||
|
g_autoptr(FprintDBusObjectSkeleton) object = NULL;
|
||||||
|
g_autoptr(FprintDevice) rdev = NULL;
|
||||||
|
g_autofree gchar *path = NULL;
|
||||||
|
|
||||||
|
rdev = fprint_device_new (device);
|
||||||
|
|
||||||
|
g_signal_connect (G_OBJECT (rdev), "notify::in-use",
|
||||||
|
G_CALLBACK (fprint_manager_in_use_notified), manager);
|
||||||
|
|
||||||
|
path = get_device_path (rdev);
|
||||||
|
|
||||||
|
object = fprint_dbus_object_skeleton_new (path);
|
||||||
|
fprint_dbus_object_skeleton_set_device (object,
|
||||||
|
FPRINT_DBUS_DEVICE (rdev));
|
||||||
|
g_dbus_object_manager_server_export (
|
||||||
|
G_DBUS_OBJECT_MANAGER_SERVER (priv->object_manager),
|
||||||
|
G_DBUS_OBJECT_SKELETON (object));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
device_removed_cb (FprintManager *manager, FpDevice *device, FpContext *context)
|
||||||
|
{
|
||||||
|
FprintManagerPrivate *priv = fprint_manager_get_instance_private (manager);
|
||||||
|
|
||||||
|
g_autolist (FprintDBusObjectSkeleton) objects = NULL;
|
||||||
|
GList *item;
|
||||||
|
|
||||||
|
objects = g_dbus_object_manager_get_objects (priv->object_manager);
|
||||||
|
|
||||||
|
for (item = objects; item; item = item->next)
|
||||||
|
{
|
||||||
|
g_autoptr(FprintDevice) rdev = NULL;
|
||||||
|
g_autoptr(FpDevice) dev = NULL;
|
||||||
|
FprintDBusObjectSkeleton *object = item->data;
|
||||||
|
|
||||||
|
rdev = fprint_dbus_object_skeleton_get_device (object);
|
||||||
|
g_object_get (rdev, "dev", &dev, NULL);
|
||||||
|
if (dev != device)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
g_dbus_object_manager_server_unexport (
|
||||||
|
G_DBUS_OBJECT_MANAGER_SERVER (priv->object_manager),
|
||||||
|
g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (rdev)));
|
||||||
|
|
||||||
|
g_signal_handlers_disconnect_by_data (rdev, manager);
|
||||||
|
|
||||||
|
/* We cannot continue to iterate at this point, but we don't need to either */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The device that disappeared might have been in-use.
|
||||||
|
* Do we need to do anything else in this case to clean up more gracefully? */
|
||||||
|
fprint_manager_in_use_notified (NULL, NULL, manager);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
fprint_manager_constructed (GObject *object)
|
||||||
|
{
|
||||||
|
FprintManager *manager = FPRINT_MANAGER (object);
|
||||||
|
FprintManagerPrivate *priv = fprint_manager_get_instance_private (manager);
|
||||||
|
GDBusObjectManagerServer *object_manager_server;
|
||||||
|
|
||||||
|
object_manager_server =
|
||||||
|
g_dbus_object_manager_server_new (FPRINT_SERVICE_PATH "/Device");
|
||||||
|
|
||||||
|
priv->object_manager = G_DBUS_OBJECT_MANAGER (object_manager_server);
|
||||||
|
priv->dbus_manager = fprint_dbus_manager_skeleton_new ();
|
||||||
|
priv->context = fp_context_new ();
|
||||||
|
|
||||||
|
g_signal_connect_object (priv->dbus_manager,
|
||||||
|
"handle-get-devices",
|
||||||
|
G_CALLBACK (handle_get_devices),
|
||||||
|
manager,
|
||||||
|
G_CONNECT_SWAPPED);
|
||||||
|
g_signal_connect_object (priv->dbus_manager,
|
||||||
|
"handle-get-default-device",
|
||||||
|
G_CALLBACK (handle_get_default_device),
|
||||||
|
manager,
|
||||||
|
G_CONNECT_SWAPPED);
|
||||||
|
|
||||||
|
g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (priv->dbus_manager),
|
||||||
|
priv->connection,
|
||||||
|
FPRINT_SERVICE_PATH "/Manager", NULL);
|
||||||
|
|
||||||
|
g_dbus_object_manager_server_set_connection (object_manager_server,
|
||||||
|
priv->connection);
|
||||||
|
|
||||||
|
/* And register the signals for initial enumeration and hotplug. */
|
||||||
|
g_signal_connect_object (priv->context,
|
||||||
|
"device-added",
|
||||||
|
(GCallback) device_added_cb,
|
||||||
|
manager,
|
||||||
|
G_CONNECT_SWAPPED);
|
||||||
|
|
||||||
|
g_signal_connect_object (priv->context,
|
||||||
|
"device-removed",
|
||||||
|
(GCallback) device_removed_cb,
|
||||||
|
manager,
|
||||||
|
G_CONNECT_SWAPPED);
|
||||||
|
|
||||||
|
/* Prepare everything by enumerating all devices.
|
||||||
|
* This blocks the main loop until the existing devices are enumerated
|
||||||
|
*/
|
||||||
|
fp_context_enumerate (priv->context);
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (fprint_manager_parent_class)->constructed (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
fprint_manager_init (FprintManager *manager)
|
fprint_manager_init (FprintManager *manager)
|
||||||
{
|
{
|
||||||
FprintManagerPrivate *priv = FPRINT_MANAGER_GET_PRIVATE (manager);
|
|
||||||
struct fp_dscv_dev **discovered_devs = fp_discover_devs();
|
|
||||||
struct fp_dscv_dev *ddev;
|
|
||||||
int i = 0;
|
|
||||||
|
|
||||||
dbus_g_connection_register_g_object(fprintd_dbus_conn,
|
|
||||||
"/net/reactivated/Fprint/Manager", G_OBJECT(manager));
|
|
||||||
|
|
||||||
if (discovered_devs == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
while ((ddev = discovered_devs[i++]) != NULL) {
|
|
||||||
FprintDevice *rdev = fprint_device_new(ddev);
|
|
||||||
gchar *path;
|
|
||||||
|
|
||||||
g_signal_connect (G_OBJECT(rdev), "notify::in-use",
|
|
||||||
G_CALLBACK (fprint_manager_in_use_notified), manager);
|
|
||||||
|
|
||||||
priv->dev_registry = g_slist_prepend(priv->dev_registry, rdev);
|
|
||||||
path = get_device_path(rdev);
|
|
||||||
dbus_g_connection_register_g_object(fprintd_dbus_conn, path,
|
|
||||||
G_OBJECT(rdev));
|
|
||||||
g_free(path);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FprintManager *fprint_manager_new(gboolean no_timeout)
|
FprintManager *
|
||||||
|
fprint_manager_new (GDBusConnection *connection, gboolean no_timeout)
|
||||||
{
|
{
|
||||||
FprintManagerPrivate *priv;
|
FprintManagerPrivate *priv;
|
||||||
GObject *object;
|
GObject *object;
|
||||||
|
|
||||||
object = g_object_new(FPRINT_TYPE_MANAGER, NULL);
|
object = g_object_new (FPRINT_TYPE_MANAGER, "connection", connection, NULL);
|
||||||
priv = FPRINT_MANAGER_GET_PRIVATE (object);
|
priv = fprint_manager_get_instance_private (FPRINT_MANAGER (object));
|
||||||
priv->no_timeout = no_timeout;
|
priv->no_timeout = no_timeout;
|
||||||
|
|
||||||
if (!priv->no_timeout)
|
if (!priv->no_timeout)
|
||||||
priv->timeout_id = g_timeout_add_seconds (TIMEOUT, (GSourceFunc) fprint_manager_timeout_cb, object);
|
priv->timeout_id = g_timeout_add_seconds (TIMEOUT, (GSourceFunc) fprint_manager_timeout_cb, object);
|
||||||
|
|
||||||
return FPRINT_MANAGER (object);
|
return FPRINT_MANAGER (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean fprint_manager_get_devices(FprintManager *manager,
|
static gboolean
|
||||||
GPtrArray **devices, GError **error)
|
fprint_manager_get_devices (FprintManager *manager,
|
||||||
|
GPtrArray **devices, GError **error)
|
||||||
{
|
{
|
||||||
FprintManagerPrivate *priv = FPRINT_MANAGER_GET_PRIVATE (manager);
|
FprintManagerPrivate *priv = fprint_manager_get_instance_private (manager);
|
||||||
GSList *elem = g_slist_reverse(g_slist_copy(priv->dev_registry));
|
|
||||||
GSList *l;
|
|
||||||
int num_open = g_slist_length(elem);
|
|
||||||
GPtrArray *devs = g_ptr_array_sized_new(num_open);
|
|
||||||
|
|
||||||
if (num_open > 0) {
|
g_autolist (FprintDBusObjectSkeleton) objects = NULL;
|
||||||
for (l = elem; l != NULL; l = l->next) {
|
GList *l;
|
||||||
FprintDevice *rdev = l->data;
|
int num_open;
|
||||||
g_ptr_array_add(devs, get_device_path(rdev));
|
GPtrArray *devs;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
g_slist_free(elem);
|
objects = g_dbus_object_manager_get_objects (priv->object_manager);
|
||||||
|
objects = g_list_reverse (objects);
|
||||||
|
|
||||||
*devices = devs;
|
num_open = g_list_length (objects);
|
||||||
return TRUE;
|
devs = g_ptr_array_sized_new (num_open);
|
||||||
|
|
||||||
|
if (num_open > 0)
|
||||||
|
{
|
||||||
|
for (l = objects; l != NULL; l = l->next)
|
||||||
|
{
|
||||||
|
g_autoptr(FprintDevice) rdev = NULL;
|
||||||
|
FprintDBusObjectSkeleton *object = l->data;
|
||||||
|
const char *path;
|
||||||
|
|
||||||
|
rdev = fprint_dbus_object_skeleton_get_device (object);
|
||||||
|
path = g_dbus_interface_skeleton_get_object_path (
|
||||||
|
G_DBUS_INTERFACE_SKELETON (rdev));
|
||||||
|
g_ptr_array_add (devs, (char *) path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
g_ptr_array_add (devs, NULL);
|
||||||
|
|
||||||
|
*devices = devs;
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean fprint_manager_get_default_device(FprintManager *manager,
|
static gboolean
|
||||||
const char **device, GError **error)
|
fprint_manager_get_default_device (FprintManager *manager,
|
||||||
|
const char **device, GError **error)
|
||||||
{
|
{
|
||||||
FprintManagerPrivate *priv = FPRINT_MANAGER_GET_PRIVATE (manager);
|
FprintManagerPrivate *priv = fprint_manager_get_instance_private (manager);
|
||||||
GSList *elem = priv->dev_registry;
|
|
||||||
int num_open = g_slist_length(elem);
|
|
||||||
|
|
||||||
if (num_open > 0) {
|
g_autolist (FprintDBusObjectSkeleton) objects = NULL;
|
||||||
*device = get_device_path (g_slist_last (elem)->data);
|
int num_open;
|
||||||
return TRUE;
|
|
||||||
} else {
|
objects = g_dbus_object_manager_get_objects (priv->object_manager);
|
||||||
g_set_error (error, FPRINT_ERROR, FPRINT_ERROR_NO_SUCH_DEVICE,
|
num_open = g_list_length (objects);
|
||||||
"No devices available");
|
|
||||||
*device = NULL;
|
if (num_open > 0)
|
||||||
return FALSE;
|
{
|
||||||
}
|
g_autoptr(FprintDevice) rdev = NULL;
|
||||||
|
FprintDBusObjectSkeleton *object = g_list_last (objects)->data;
|
||||||
|
|
||||||
|
rdev = fprint_dbus_object_skeleton_get_device (object);
|
||||||
|
*device = g_dbus_interface_skeleton_get_object_path (
|
||||||
|
G_DBUS_INTERFACE_SKELETON (rdev));
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g_set_error (error, FPRINT_ERROR, FPRINT_ERROR_NO_SUCH_DEVICE,
|
||||||
|
"No devices available");
|
||||||
|
*device = NULL;
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GQuark fprint_error_quark(void)
|
GQuark
|
||||||
|
fprint_error_quark (void)
|
||||||
{
|
{
|
||||||
static GQuark quark = 0;
|
static volatile gsize quark = 0;
|
||||||
if (!quark)
|
|
||||||
quark = g_quark_from_static_string("fprintd-error-quark");
|
|
||||||
return quark;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC }
|
if (g_once_init_enter (&quark))
|
||||||
GType
|
{
|
||||||
fprint_error_get_type (void)
|
g_autoptr(GEnumClass) errors_enum = NULL;
|
||||||
{
|
GQuark domain;
|
||||||
static GType etype = 0;
|
unsigned i;
|
||||||
|
|
||||||
if (etype == 0) {
|
domain = g_quark_from_static_string ("fprintd-error-quark");
|
||||||
static const GEnumValue values[] =
|
errors_enum = g_type_class_ref (FPRINT_TYPE_ERROR);
|
||||||
{
|
|
||||||
ENUM_ENTRY (FPRINT_ERROR_CLAIM_DEVICE, "ClaimDevice"),
|
for (i = 0; i < errors_enum->n_values; ++i)
|
||||||
ENUM_ENTRY (FPRINT_ERROR_ALREADY_IN_USE, "AlreadyInUse"),
|
{
|
||||||
ENUM_ENTRY (FPRINT_ERROR_INTERNAL, "Internal"),
|
GEnumValue *value = &errors_enum->values[i];
|
||||||
ENUM_ENTRY (FPRINT_ERROR_PERMISSION_DENIED, "PermissionDenied"),
|
|
||||||
ENUM_ENTRY (FPRINT_ERROR_NO_ENROLLED_PRINTS, "NoEnrolledPrints"),
|
g_dbus_error_register_error (domain, value->value,
|
||||||
ENUM_ENTRY (FPRINT_ERROR_NO_ACTION_IN_PROGRESS, "NoActionInProgress"),
|
value->value_nick);
|
||||||
ENUM_ENTRY (FPRINT_ERROR_INVALID_FINGERNAME, "InvalidFingername"),
|
}
|
||||||
ENUM_ENTRY (FPRINT_ERROR_NO_SUCH_DEVICE, "NoSuchDevice"),
|
|
||||||
{ 0, 0, 0 }
|
g_once_init_leave (&quark, domain);
|
||||||
};
|
}
|
||||||
etype = g_enum_register_static ("FprintError", values);
|
return (GQuark) quark;
|
||||||
}
|
|
||||||
return etype;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,8 +5,6 @@
|
|||||||
]>
|
]>
|
||||||
<node name="/" xmlns:doc="http://www.freedesktop.org/dbus/1.0/doc.dtd">
|
<node name="/" xmlns:doc="http://www.freedesktop.org/dbus/1.0/doc.dtd">
|
||||||
<interface name="net.reactivated.Fprint.Manager">
|
<interface name="net.reactivated.Fprint.Manager">
|
||||||
<annotation name="org.freedesktop.DBus.GLib.CSymbol"
|
|
||||||
value="fprint_manager" />
|
|
||||||
|
|
||||||
<!-- ************************************************************ -->
|
<!-- ************************************************************ -->
|
||||||
|
|
||||||
|
|||||||
93
src/meson.build
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
bash = find_program('bash')
|
||||||
|
dbus_interfaces = ['Manager', 'Device']
|
||||||
|
dbus_interfaces_files = []
|
||||||
|
|
||||||
|
foreach interface_name: dbus_interfaces
|
||||||
|
interface = interface_name.to_lower()
|
||||||
|
interface_file = interface + '.xml'
|
||||||
|
dbus_interfaces_files += custom_target('dbus_interface_' + interface,
|
||||||
|
input: interface_file,
|
||||||
|
output: 'net.reactivated.Fprint.@0@.xml'.format(interface_name),
|
||||||
|
command: ['cp', '@INPUT@', '@OUTPUT@'],
|
||||||
|
install: true,
|
||||||
|
install_dir: dbus_interfaces_dir,
|
||||||
|
)
|
||||||
|
endforeach
|
||||||
|
|
||||||
|
# NOTE: We should pass "--glib-min-required 2.64" but cannot
|
||||||
|
fprintd_dbus_sources_base = gnome.gdbus_codegen('fprintd-dbus',
|
||||||
|
sources: dbus_interfaces_files,
|
||||||
|
autocleanup: 'all',
|
||||||
|
interface_prefix: 'net.reactivated.Fprint.',
|
||||||
|
namespace: 'FprintDBus',
|
||||||
|
object_manager: true,
|
||||||
|
)
|
||||||
|
|
||||||
|
# FIXME: remove this and just use fprintd_dbus_sources when we're on glib 2.64
|
||||||
|
fprintd_dbus_sources = [
|
||||||
|
fprintd_dbus_sources_base[1] # header file
|
||||||
|
]
|
||||||
|
|
||||||
|
fprintd_dbus_sources += custom_target('fprintd-dbus-interactive',
|
||||||
|
input: fprintd_dbus_sources_base[0], # c file,
|
||||||
|
output: 'fprintd-dbus-interactive.c',
|
||||||
|
command: [
|
||||||
|
find_program('patch'),
|
||||||
|
'-p1',
|
||||||
|
'--merge',
|
||||||
|
'@INPUT@',
|
||||||
|
files('dbus-interactive-auth.patch'),
|
||||||
|
'-o', '@OUTPUT@',
|
||||||
|
])
|
||||||
|
|
||||||
|
fprintd_enum_files = gnome.mkenums_simple('fprintd-enums',
|
||||||
|
sources: 'fprintd.h',
|
||||||
|
)
|
||||||
|
|
||||||
|
fprintd_deps = declare_dependency(
|
||||||
|
include_directories: [
|
||||||
|
include_directories('..'),
|
||||||
|
],
|
||||||
|
sources: [
|
||||||
|
fprintd_enum_files,
|
||||||
|
fprintd_dbus_sources,
|
||||||
|
],
|
||||||
|
dependencies: [
|
||||||
|
glib_dep,
|
||||||
|
gio_dep,
|
||||||
|
gio_unix_dep,
|
||||||
|
gmodule_dep,
|
||||||
|
libfprint_dep,
|
||||||
|
polkit_gobject_dep,
|
||||||
|
],
|
||||||
|
compile_args: [
|
||||||
|
'-DG_LOG_DOMAIN="@0@"'.format(meson.project_name()),
|
||||||
|
'-DLOCALEDIR="@0@"'.format(localedir),
|
||||||
|
'-DPLUGINDIR="@0@"'.format(fprintd_plugindir),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
libfprintd_private = static_library('fprintd-private',
|
||||||
|
sources: [
|
||||||
|
'device.c',
|
||||||
|
'fprintd.h',
|
||||||
|
'manager.c',
|
||||||
|
],
|
||||||
|
dependencies: fprintd_deps,
|
||||||
|
gnu_symbol_visibility: 'hidden',
|
||||||
|
)
|
||||||
|
|
||||||
|
fprintd = executable('fprintd',
|
||||||
|
sources: [
|
||||||
|
'file_storage.c',
|
||||||
|
'file_storage.h',
|
||||||
|
'fprintd.h',
|
||||||
|
'main.c',
|
||||||
|
'storage.h',
|
||||||
|
],
|
||||||
|
dependencies: fprintd_deps,
|
||||||
|
link_with: libfprintd_private,
|
||||||
|
gnu_symbol_visibility: 'hidden',
|
||||||
|
install: true,
|
||||||
|
install_dir: fprintd_installdir,
|
||||||
|
)
|
||||||
@ -6,45 +6,46 @@
|
|||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License along
|
* You should have received a copy of the GNU General Public License along
|
||||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef STORAGE_H
|
#pragma once
|
||||||
|
|
||||||
#define STORAGE_H
|
typedef int (*storage_print_data_save)(FpPrint *print);
|
||||||
|
typedef int (*storage_print_data_load)(FpDevice *dev,
|
||||||
typedef int (*storage_print_data_save)(struct fp_print_data *data,
|
FpFinger finger,
|
||||||
enum fp_finger finger, const char *username);
|
const char *username,
|
||||||
typedef int (*storage_print_data_load)(struct fp_dev *dev,
|
FpPrint **print);
|
||||||
enum fp_finger finger, struct fp_print_data **data, const char *username);
|
typedef int (*storage_print_data_delete)(FpDevice *dev,
|
||||||
typedef int (*storage_print_data_delete)(struct fp_dscv_dev *dev,
|
FpFinger finger,
|
||||||
enum fp_finger finger, const char *username);
|
const char *username);
|
||||||
typedef GSList *(*storage_discover_prints)(struct fp_dscv_dev *dev, const char *username);
|
typedef GSList *(*storage_discover_prints)(FpDevice *dev,
|
||||||
|
const char *username);
|
||||||
|
typedef GSList *(*storage_discover_users)(void);
|
||||||
typedef int (*storage_init)(void);
|
typedef int (*storage_init)(void);
|
||||||
typedef int (*storage_deinit)(void);
|
typedef int (*storage_deinit)(void);
|
||||||
|
|
||||||
struct storage {
|
struct storage
|
||||||
storage_init init;
|
{
|
||||||
storage_deinit deinit;
|
storage_init init;
|
||||||
storage_print_data_save print_data_save;
|
storage_deinit deinit;
|
||||||
storage_print_data_load print_data_load;
|
storage_print_data_save print_data_save;
|
||||||
storage_print_data_delete print_data_delete;
|
storage_print_data_load print_data_load;
|
||||||
storage_discover_prints discover_prints;
|
storage_print_data_delete print_data_delete;
|
||||||
|
storage_discover_prints discover_prints;
|
||||||
|
storage_discover_users discover_users;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct storage fp_storage;
|
typedef struct storage fp_storage;
|
||||||
|
|
||||||
/* The currently setup store */
|
/* The currently setup store */
|
||||||
fp_storage store;
|
extern fp_storage store;
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|||||||
4
tests/LSAN-leaks-suppress.txt
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
leak:initialize_device
|
||||||
|
leak:usbi_alloc_device
|
||||||
|
leak:libusb-1.0.so.*
|
||||||
|
leak:PyMem_RawMalloc
|
||||||
@ -1,35 +0,0 @@
|
|||||||
BUILT_SOURCES = manager-dbus-glue.h device-dbus-glue.h $(MARSHALFILES)
|
|
||||||
noinst_HEADERS = $(BUILT_SOURCES)
|
|
||||||
CLEANFILES = $(BUILT_SOURCES)
|
|
||||||
|
|
||||||
bin_PROGRAMS = fprintd-verify fprintd-enroll fprintd-list fprintd-delete
|
|
||||||
|
|
||||||
fprintd_verify_SOURCES = verify.c $(MARSHALFILES)
|
|
||||||
fprintd_verify_CFLAGS = $(WARN_CFLAGS) $(GLIB_CFLAGS)
|
|
||||||
fprintd_verify_LDADD = $(GLIB_LIBS)
|
|
||||||
|
|
||||||
fprintd_enroll_SOURCES = enroll.c $(MARSHALFILES)
|
|
||||||
fprintd_enroll_CFLAGS = $(WARN_CFLAGS) $(GLIB_CFLAGS) -I$(top_srcdir)/pam
|
|
||||||
fprintd_enroll_LDADD = $(GLIB_LIBS)
|
|
||||||
|
|
||||||
fprintd_list_SOURCES = list.c
|
|
||||||
fprintd_list_CFLAGS = $(WARN_CFLAGS) $(GLIB_CFLAGS)
|
|
||||||
fprintd_list_LDADD = $(GLIB_LIBS)
|
|
||||||
|
|
||||||
fprintd_delete_SOURCES = delete.c
|
|
||||||
fprintd_delete_CFLAGS = $(WARN_CFLAGS) $(GLIB_CFLAGS)
|
|
||||||
fprintd_delete_LDADD = $(GLIB_LIBS)
|
|
||||||
|
|
||||||
manager-dbus-glue.h: ../src/manager.xml
|
|
||||||
dbus-binding-tool --prefix=fprint_manager --mode=glib-client $< --output=$@
|
|
||||||
|
|
||||||
device-dbus-glue.h: ../src/device.xml
|
|
||||||
dbus-binding-tool --prefix=fprint_device --mode=glib-client $< --output=$@
|
|
||||||
|
|
||||||
MARSHALFILES = marshal.c marshal.h
|
|
||||||
GLIB_GENMARSHAL=`pkg-config --variable=glib_genmarshal glib-2.0`
|
|
||||||
|
|
||||||
marshal.h: $(top_srcdir)/src/fprintd-marshal.list
|
|
||||||
( $(GLIB_GENMARSHAL) --prefix=fprintd_marshal $(top_srcdir)/src/fprintd-marshal.list --header > marshal.h )
|
|
||||||
marshal.c: marshal.h
|
|
||||||
( $(GLIB_GENMARSHAL) --prefix=fprintd_marshal $(top_srcdir)/src/fprintd-marshal.list --body --header > marshal.c )
|
|
||||||
439
tests/dbusmock/fprintd.py
Normal file
@ -0,0 +1,439 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
'''fprintd mock template
|
||||||
|
|
||||||
|
This creates the expected methods and properties of the
|
||||||
|
net.reactivated.Fprint.Manager object (/net/reactivated/Fprint/Manager)
|
||||||
|
but no devices.
|
||||||
|
'''
|
||||||
|
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU Lesser General Public License as published by the Free
|
||||||
|
# Software Foundation; either version 3 of the License, or (at your option) any
|
||||||
|
# later version. See http://www.gnu.org/copyleft/lgpl.html for the full text
|
||||||
|
# of the license.
|
||||||
|
|
||||||
|
__author__ = 'Bastien Nocera'
|
||||||
|
__email__ = 'hadess@hadess.net'
|
||||||
|
__copyright__ = '(c) 2020 Red Hat Inc.'
|
||||||
|
__license__ = 'LGPL 3+'
|
||||||
|
|
||||||
|
import sys
|
||||||
|
from gi.repository import GLib
|
||||||
|
import dbus
|
||||||
|
import asyncio
|
||||||
|
|
||||||
|
from dbusmock import MOCK_IFACE, mockobject
|
||||||
|
|
||||||
|
BUS_NAME = 'net.reactivated.Fprint'
|
||||||
|
MAIN_OBJ = '/net/reactivated/Fprint/Manager'
|
||||||
|
SYSTEM_BUS = True
|
||||||
|
IS_OBJECT_MANAGER = False
|
||||||
|
|
||||||
|
MAIN_IFACE = 'net.reactivated.Fprint.Manager'
|
||||||
|
MANAGER_MOCK_IFACE = 'net.reactivated.Fprint.Manager.Mock'
|
||||||
|
|
||||||
|
DEVICE_IFACE = 'net.reactivated.Fprint.Device'
|
||||||
|
DEVICE_MOCK_IFACE = 'net.reactivated.Fprint.Device.Mock'
|
||||||
|
|
||||||
|
VALID_FINGER_NAMES = [
|
||||||
|
'left-thumb',
|
||||||
|
'left-index-finger',
|
||||||
|
'left-middle-finger',
|
||||||
|
'left-ring-finger',
|
||||||
|
'left-little-finger',
|
||||||
|
'right-thumb',
|
||||||
|
'right-index-finger',
|
||||||
|
'right-middle-finger',
|
||||||
|
'right-ring-finger',
|
||||||
|
'right-little-finger'
|
||||||
|
]
|
||||||
|
|
||||||
|
VALID_VERIFY_STATUS = [
|
||||||
|
'verify-no-match',
|
||||||
|
'verify-match',
|
||||||
|
'verify-retry-scan',
|
||||||
|
'verify-swipe-too-short',
|
||||||
|
'verify-finger-not-centered',
|
||||||
|
'verify-remove-and-retry',
|
||||||
|
'verify-disconnected',
|
||||||
|
'verify-unknown-error'
|
||||||
|
]
|
||||||
|
|
||||||
|
VALID_ENROLL_STATUS = [
|
||||||
|
'enroll-completed',
|
||||||
|
'enroll-failed',
|
||||||
|
'enroll-stage-passed',
|
||||||
|
'enroll-retry-scan',
|
||||||
|
'enroll-swipe-too-short',
|
||||||
|
'enroll-finger-not-centered',
|
||||||
|
'enroll-remove-and-retry',
|
||||||
|
'enroll-data-full',
|
||||||
|
'enroll-disconnected',
|
||||||
|
'enroll-unknown-error'
|
||||||
|
]
|
||||||
|
|
||||||
|
def load(mock, parameters):
|
||||||
|
fprintd = mockobject.objects[MAIN_OBJ]
|
||||||
|
mock.last_device_id = 0
|
||||||
|
fprintd.fingers = {}
|
||||||
|
mock.loop = asyncio.new_event_loop()
|
||||||
|
|
||||||
|
@dbus.service.method(MAIN_IFACE,
|
||||||
|
in_signature='', out_signature='ao')
|
||||||
|
def GetDevices(self):
|
||||||
|
return [(k) for k in mockobject.objects.keys() if "/Device/" in k]
|
||||||
|
|
||||||
|
@dbus.service.method(MAIN_IFACE,
|
||||||
|
in_signature='', out_signature='o')
|
||||||
|
def GetDefaultDevice(self):
|
||||||
|
devices = self.GetDevices()
|
||||||
|
if len(devices) < 1:
|
||||||
|
raise dbus.exceptions.DBusException(
|
||||||
|
'No devices available',
|
||||||
|
name='net.reactivated.Fprint.Error.NoSuchDevice')
|
||||||
|
return devices[0]
|
||||||
|
|
||||||
|
@dbus.service.method(MANAGER_MOCK_IFACE,
|
||||||
|
in_signature='sisb', out_signature='s')
|
||||||
|
def AddDevice(self, device_name, num_enroll_stages, scan_type,
|
||||||
|
has_identification=False):
|
||||||
|
'''Convenience method to add a fingerprint reader device
|
||||||
|
|
||||||
|
You have to specify a device name, the number of enrollment
|
||||||
|
stages it would use (> 0) and the scan type, as a string
|
||||||
|
(either 'press' or 'swipe')
|
||||||
|
'''
|
||||||
|
|
||||||
|
if scan_type not in ['swipe', 'press']:
|
||||||
|
raise dbus.exceptions.DBusException(
|
||||||
|
'Invalid scan_type \'%s\'.' % scan_type,
|
||||||
|
name='org.freedesktop.DBus.Error.InvalidArgs')
|
||||||
|
|
||||||
|
if num_enroll_stages <= 0:
|
||||||
|
raise dbus.exceptions.DBusException(
|
||||||
|
'Invalid num_enroll_stages \'%s\'.' % num_enroll_stages,
|
||||||
|
name='org.freedesktop.DBus.Error.InvalidArgs')
|
||||||
|
|
||||||
|
self.last_device_id += 1
|
||||||
|
path = '/net/reactivated/Fprint/Device/%d' % self.last_device_id
|
||||||
|
device_properties = {
|
||||||
|
'name': dbus.String(device_name, variant_level=1),
|
||||||
|
'num-enroll-stages': dbus.Int32(num_enroll_stages, variant_level=1),
|
||||||
|
'scan-type': scan_type
|
||||||
|
}
|
||||||
|
|
||||||
|
self.AddObject(path,
|
||||||
|
DEVICE_IFACE,
|
||||||
|
# Properties
|
||||||
|
device_properties,
|
||||||
|
# Methods
|
||||||
|
[
|
||||||
|
('ListEnrolledFingers', 's', 'as', ListEnrolledFingers),
|
||||||
|
('DeleteEnrolledFingers', 's', '', DeleteEnrolledFingers),
|
||||||
|
('DeleteEnrolledFingers2', '', '', DeleteEnrolledFingers2),
|
||||||
|
('Claim', 's', '', Claim),
|
||||||
|
('Release', '', '', Release),
|
||||||
|
('VerifyStart', 's', '', VerifyStart),
|
||||||
|
('VerifyStop', '', '', VerifyStop),
|
||||||
|
('EnrollStart', 's', '', EnrollStart),
|
||||||
|
('EnrollStop', '', '', EnrollStop)
|
||||||
|
])
|
||||||
|
|
||||||
|
device = mockobject.objects[path]
|
||||||
|
device.fingers = {}
|
||||||
|
device.has_identification = has_identification
|
||||||
|
device.claimed_user = None
|
||||||
|
device.action = None
|
||||||
|
device.selected_finger = None
|
||||||
|
device.verify_script = []
|
||||||
|
|
||||||
|
return path
|
||||||
|
|
||||||
|
@dbus.service.method(MANAGER_MOCK_IFACE,
|
||||||
|
in_signature='o')
|
||||||
|
def RemoveDevice(self, path):
|
||||||
|
# This isn't compatible with hotplugging devices, which fprintd doesn't
|
||||||
|
# support yet, but it's meant to remove devices added to the mock for
|
||||||
|
# testing purposes.
|
||||||
|
if not path:
|
||||||
|
raise dbus.exceptions.DBusException(
|
||||||
|
'Invalid empty path.',
|
||||||
|
name='org.freedesktop.DBus.Error.InvalidArgs')
|
||||||
|
|
||||||
|
self.RemoveObject(path)
|
||||||
|
|
||||||
|
@dbus.service.method(DEVICE_IFACE,
|
||||||
|
in_signature='s', out_signature='as')
|
||||||
|
def ListEnrolledFingers(device, user):
|
||||||
|
if user in device.fingers:
|
||||||
|
return device.fingers[user]
|
||||||
|
raise dbus.exceptions.DBusException(
|
||||||
|
'No enrolled prints in device %s for user %s' % (device.path, user),
|
||||||
|
name='net.reactivated.Fprint.Error.NoEnrolledPrints')
|
||||||
|
|
||||||
|
@dbus.service.method(DEVICE_IFACE,
|
||||||
|
in_signature='s', out_signature='')
|
||||||
|
def DeleteEnrolledFingers(device, user):
|
||||||
|
device.fingers[user] = []
|
||||||
|
|
||||||
|
@dbus.service.method(DEVICE_IFACE,
|
||||||
|
in_signature='', out_signature='')
|
||||||
|
def DeleteEnrolledFingers2(device):
|
||||||
|
if not device.claimed_user:
|
||||||
|
raise dbus.exceptions.DBusException(
|
||||||
|
'Device was not claimed before use',
|
||||||
|
name='net.reactivated.Fprint.Error.ClaimDevice')
|
||||||
|
device.fingers[device.claimed_user] = []
|
||||||
|
|
||||||
|
@dbus.service.method(DEVICE_IFACE,
|
||||||
|
in_signature='s', out_signature='')
|
||||||
|
def Claim(device, user):
|
||||||
|
if device.claimed_user:
|
||||||
|
raise dbus.exceptions.DBusException(
|
||||||
|
'Device already in use by %s' % device.claimed_user,
|
||||||
|
name='net.reactivated.Fprint.Error.AlreadyInUse')
|
||||||
|
|
||||||
|
device.claimed_user = user
|
||||||
|
|
||||||
|
@dbus.service.method(DEVICE_IFACE,
|
||||||
|
in_signature='', out_signature='')
|
||||||
|
def Release(device):
|
||||||
|
if not device.claimed_user:
|
||||||
|
raise dbus.exceptions.DBusException(
|
||||||
|
'Device was not claimed before use',
|
||||||
|
name='net.reactivated.Fprint.Error.ClaimDevice')
|
||||||
|
device.claimed_user = None
|
||||||
|
device.action = None
|
||||||
|
device.selected_finger = None
|
||||||
|
|
||||||
|
def can_verify_finger(device, finger_name):
|
||||||
|
# We should already have checked that there are enrolled fingers
|
||||||
|
if finger_name == 'any':
|
||||||
|
return True
|
||||||
|
if finger_name in device.fingers[device.claimed_user]:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
def glib_sleep(timeout):
|
||||||
|
waiting = True
|
||||||
|
|
||||||
|
def done_waiting():
|
||||||
|
nonlocal waiting
|
||||||
|
waiting = False
|
||||||
|
|
||||||
|
GLib.timeout_add(timeout, done_waiting)
|
||||||
|
while (waiting):
|
||||||
|
GLib.main_context_default().iteration(True)
|
||||||
|
|
||||||
|
def device_run_script(device, result, done):
|
||||||
|
if result == 'MOCK: quit':
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
# Emit signal
|
||||||
|
device.EmitSignal(DEVICE_IFACE, 'VerifyStatus', 'sb', [
|
||||||
|
result,
|
||||||
|
done
|
||||||
|
])
|
||||||
|
|
||||||
|
@dbus.service.method(DEVICE_IFACE,
|
||||||
|
in_signature='s', out_signature='')
|
||||||
|
def VerifyStart(device, finger_name):
|
||||||
|
if not device.claimed_user:
|
||||||
|
raise dbus.exceptions.DBusException(
|
||||||
|
'Device was not claimed before use',
|
||||||
|
name='net.reactivated.Fprint.Error.ClaimDevice')
|
||||||
|
if device.claimed_user not in device.fingers:
|
||||||
|
raise dbus.exceptions.DBusException(
|
||||||
|
'No enrolled prints for user \'%s\'' % device.claimed_user,
|
||||||
|
name='net.reactivated.Fprint.Error.NoEnrolledPrints')
|
||||||
|
if not finger_name:
|
||||||
|
raise dbus.exceptions.DBusException(
|
||||||
|
'Invalid empty finger_name.',
|
||||||
|
name='org.freedesktop.DBus.Error.InvalidArgs')
|
||||||
|
if not can_verify_finger(device, finger_name):
|
||||||
|
raise dbus.exceptions.DBusException(
|
||||||
|
'Finger \'%s\' not enrolled.' % finger_name,
|
||||||
|
name='org.freedesktop.DBus.Error.Internal')
|
||||||
|
if device.action:
|
||||||
|
raise dbus.exceptions.DBusException(
|
||||||
|
'Action \'%s\' already in progress' % device.action,
|
||||||
|
name='net.reactivated.Fprint.Error.AlreadyInUse')
|
||||||
|
device.action = 'verify'
|
||||||
|
|
||||||
|
if finger_name == 'any' and not device.has_identification:
|
||||||
|
finger_name = device.fingers[device.claimed_user][0]
|
||||||
|
device.selected_finger = finger_name
|
||||||
|
# Needs to happen after method return
|
||||||
|
GLib.idle_add(device.EmitSignal,
|
||||||
|
DEVICE_IFACE, 'VerifyFingerSelected', 's', [
|
||||||
|
device.selected_finger
|
||||||
|
])
|
||||||
|
|
||||||
|
error = None
|
||||||
|
base_delay = 0
|
||||||
|
while device.verify_script is not None and len(device.verify_script) > 0:
|
||||||
|
result, done, timeout = device.verify_script.pop(0)
|
||||||
|
|
||||||
|
# We stop when "timeout >= 0 and done"
|
||||||
|
if result == 'MOCK: no-prints':
|
||||||
|
# Special case to change return value of DBus call, ignores timeout
|
||||||
|
error = dbus.exceptions.DBusException(
|
||||||
|
'No enrolled prints for user \'%s\'' % device.claimed_user,
|
||||||
|
name='net.reactivated.Fprint.Error.NoEnrolledPrints')
|
||||||
|
|
||||||
|
elif timeout < 0:
|
||||||
|
# Negative timeouts mean emitting before the DBus call returns
|
||||||
|
device_run_script(device, result, done)
|
||||||
|
glib_sleep(-timeout)
|
||||||
|
|
||||||
|
else:
|
||||||
|
# Positive or zero means emitting afterwards the given timeout
|
||||||
|
base_delay += timeout
|
||||||
|
GLib.timeout_add(base_delay,
|
||||||
|
device_run_script,
|
||||||
|
device,
|
||||||
|
result,
|
||||||
|
done)
|
||||||
|
|
||||||
|
# Stop processing commands when the done flag is set
|
||||||
|
if done:
|
||||||
|
break
|
||||||
|
|
||||||
|
if error:
|
||||||
|
raise error
|
||||||
|
|
||||||
|
@dbus.service.method(DEVICE_MOCK_IFACE,
|
||||||
|
in_signature='sb', out_signature='')
|
||||||
|
def EmitVerifyStatus(device, result, done):
|
||||||
|
if (not device.action) or (device.action != 'verify'):
|
||||||
|
raise dbus.exceptions.DBusException(
|
||||||
|
'Cannot send verify statuses when not verifying',
|
||||||
|
name='org.freedesktop.DBus.Error.InvalidArgs')
|
||||||
|
if result not in VALID_VERIFY_STATUS:
|
||||||
|
raise dbus.exceptions.DBusException(
|
||||||
|
'Unknown verify status \'%s\'' % result,
|
||||||
|
name='org.freedesktop.DBus.Error.InvalidArgs')
|
||||||
|
device.EmitSignal(DEVICE_IFACE, 'VerifyStatus', 'sb', [
|
||||||
|
result,
|
||||||
|
done
|
||||||
|
])
|
||||||
|
|
||||||
|
@dbus.service.method(DEVICE_IFACE,
|
||||||
|
in_signature='', out_signature='')
|
||||||
|
def VerifyStop(device):
|
||||||
|
if device.action != 'verify':
|
||||||
|
raise dbus.exceptions.DBusException(
|
||||||
|
'No verification to stop',
|
||||||
|
name='net.reactivated.Fprint.Error.NoActionInProgress')
|
||||||
|
device.action = None
|
||||||
|
device.selected_finger = None
|
||||||
|
|
||||||
|
@dbus.service.method(DEVICE_IFACE,
|
||||||
|
in_signature='s', out_signature='')
|
||||||
|
def EnrollStart(device, finger_name):
|
||||||
|
if finger_name not in VALID_FINGER_NAMES:
|
||||||
|
raise dbus.exceptions.DBusException(
|
||||||
|
'Invalid finger name \'%s\'' % finger_name,
|
||||||
|
name='net.reactivated.Fprint.Error.InvalidFingername')
|
||||||
|
if not device.claimed_user:
|
||||||
|
raise dbus.exceptions.DBusException(
|
||||||
|
'Device was not claimed before use',
|
||||||
|
name='net.reactivated.Fprint.Error.ClaimDevice')
|
||||||
|
if device.action:
|
||||||
|
raise dbus.exceptions.DBusException(
|
||||||
|
'Action \'%s\' already in progress' % device.action,
|
||||||
|
name='net.reactivated.Fprint.Error.AlreadyInUse')
|
||||||
|
device.action = 'enroll'
|
||||||
|
|
||||||
|
@dbus.service.method(DEVICE_MOCK_IFACE,
|
||||||
|
in_signature='sb', out_signature='')
|
||||||
|
def EmitEnrollStatus(device, result, done):
|
||||||
|
if (not device.action) or (device.action != 'enroll'):
|
||||||
|
raise dbus.exceptions.DBusException(
|
||||||
|
'Cannot send enroll statuses when not enrolling',
|
||||||
|
name='org.freedesktop.DBus.Error.InvalidArgs')
|
||||||
|
if result not in VALID_ENROLL_STATUS:
|
||||||
|
raise dbus.exceptions.DBusException(
|
||||||
|
'Unknown enroll status \'%s\'' % result,
|
||||||
|
name='org.freedesktop.DBus.Error.InvalidArgs')
|
||||||
|
device.EmitSignal(DEVICE_IFACE, 'EnrollStatus', 'sb', [
|
||||||
|
result,
|
||||||
|
done
|
||||||
|
])
|
||||||
|
# FIXME save enrolled finger?
|
||||||
|
|
||||||
|
@dbus.service.method(DEVICE_IFACE,
|
||||||
|
in_signature='', out_signature='')
|
||||||
|
def EnrollStop(device):
|
||||||
|
if device.action != 'enroll':
|
||||||
|
raise dbus.exceptions.DBusException(
|
||||||
|
'No enrollment to stop',
|
||||||
|
name='net.reactivated.Fprint.Error.NoActionInProgress')
|
||||||
|
device.action = None
|
||||||
|
|
||||||
|
@dbus.service.method(DEVICE_MOCK_IFACE,
|
||||||
|
in_signature='sas', out_signature='')
|
||||||
|
def SetEnrolledFingers(device, user, fingers):
|
||||||
|
'''Convenience method to set the list of enrolled fingers.
|
||||||
|
|
||||||
|
The device_path is the return value from AddDevice(), and the
|
||||||
|
array of fingers must only contain valid finger names.
|
||||||
|
|
||||||
|
Returns nothing.
|
||||||
|
'''
|
||||||
|
|
||||||
|
for k in fingers:
|
||||||
|
if k not in VALID_FINGER_NAMES:
|
||||||
|
raise dbus.exceptions.DBusException(
|
||||||
|
'Invalid finger name \'%s\'' % k,
|
||||||
|
name='org.freedesktop.DBus.Error.InvalidArgs')
|
||||||
|
|
||||||
|
device.fingers[user] = fingers
|
||||||
|
|
||||||
|
@dbus.service.method(DEVICE_MOCK_IFACE,
|
||||||
|
in_signature='', out_signature='s')
|
||||||
|
def GetSelectedFinger(device):
|
||||||
|
'''Convenience method to get the finger under verification
|
||||||
|
|
||||||
|
Returns the finger name that the user has selected for verifying
|
||||||
|
'''
|
||||||
|
if not device.selected_finger:
|
||||||
|
raise dbus.exceptions.DBusException(
|
||||||
|
'Device is not verifying',
|
||||||
|
name='net.reactivated.Fprint.Error.NoActionInProgress')
|
||||||
|
|
||||||
|
return device.selected_finger
|
||||||
|
|
||||||
|
@dbus.service.method(DEVICE_MOCK_IFACE,
|
||||||
|
in_signature='', out_signature='b')
|
||||||
|
def HasIdentification(device):
|
||||||
|
'''Convenience method to get if a device supports identification
|
||||||
|
|
||||||
|
Returns whether identification is supported.
|
||||||
|
'''
|
||||||
|
|
||||||
|
return device.has_identification
|
||||||
|
|
||||||
|
@dbus.service.method(DEVICE_MOCK_IFACE,
|
||||||
|
in_signature='a(sbi)', out_signature='')
|
||||||
|
def SetVerifyScript(device, script):
|
||||||
|
'''Convenience method to set the verification script.
|
||||||
|
|
||||||
|
After VerifyStart is called, signal results will be sent in order after
|
||||||
|
a certain timeout declared in seconds. The array contains each
|
||||||
|
'result' followed by the 'done' argument for VerifyStatus, and the
|
||||||
|
amount of time to wait before each signal is sent.
|
||||||
|
|
||||||
|
Returns nothing.
|
||||||
|
'''
|
||||||
|
|
||||||
|
device.verify_script = script
|
||||||
|
|
||||||
|
@dbus.service.method(DEVICE_MOCK_IFACE,
|
||||||
|
in_signature='s', out_signature='')
|
||||||
|
def SetClaimed(device, user):
|
||||||
|
if user == '':
|
||||||
|
device.claimed_user = None
|
||||||
|
else:
|
||||||
|
device.claimed_user = user
|
||||||
113
tests/dbusmock/polkitd.py
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
'''polkit mock template
|
||||||
|
|
||||||
|
This creates the basic methods and properties of the
|
||||||
|
org.freedesktop.PolicyKit1.Authority object, so that we can use it async
|
||||||
|
'''
|
||||||
|
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU Lesser General Public License as published by the Free
|
||||||
|
# Software Foundation; either version 3 of the License, or (at your option) any
|
||||||
|
# later version. See http://www.gnu.org/copyleft/lgpl.html for the full text
|
||||||
|
# of the license.
|
||||||
|
|
||||||
|
__author__ = 'Marco Trevisan'
|
||||||
|
__email__ = 'marco.trevisan@canonical.com'
|
||||||
|
__copyright__ = '(c) 2020 Canonical Ltd.'
|
||||||
|
__license__ = 'LGPL 3+'
|
||||||
|
|
||||||
|
import dbus
|
||||||
|
import time
|
||||||
|
|
||||||
|
from dbusmock import MOCK_IFACE, mockobject
|
||||||
|
|
||||||
|
BUS_NAME = 'org.freedesktop.PolicyKit1'
|
||||||
|
MAIN_OBJ = '/org/freedesktop/PolicyKit1/Authority'
|
||||||
|
MAIN_IFACE = 'org.freedesktop.PolicyKit1.Authority'
|
||||||
|
SYSTEM_BUS = True
|
||||||
|
IS_OBJECT_MANAGER = False
|
||||||
|
|
||||||
|
def load(mock, parameters):
|
||||||
|
polkitd = mockobject.objects[MAIN_OBJ]
|
||||||
|
# default state
|
||||||
|
polkitd.allow_unknown = False
|
||||||
|
polkitd.allowed = []
|
||||||
|
polkitd.delay = 0
|
||||||
|
polkitd.simulate_hang = False
|
||||||
|
polkitd.hanging_actions = []
|
||||||
|
polkitd.hanging_calls = []
|
||||||
|
|
||||||
|
mock.AddProperties(MAIN_IFACE,
|
||||||
|
dbus.Dictionary({
|
||||||
|
'BackendName': 'local',
|
||||||
|
'BackendVersion': '0.8.15',
|
||||||
|
'BackendFeatures': dbus.UInt32(1, variant_level=1),
|
||||||
|
}, signature='sv'))
|
||||||
|
|
||||||
|
|
||||||
|
@dbus.service.method(MAIN_IFACE,
|
||||||
|
in_signature='(sa{sv})sa{ss}us', out_signature='(bba{ss})',
|
||||||
|
async_callbacks=('ok_cb', 'err_cb'))
|
||||||
|
def CheckAuthorization(self, subject, action_id, details, flags, cancellation_id,
|
||||||
|
ok_cb, err_cb):
|
||||||
|
time.sleep(self.delay)
|
||||||
|
allowed = action_id in self.allowed or self.allow_unknown
|
||||||
|
ret = (allowed, False, {'test': 'test'})
|
||||||
|
|
||||||
|
if self.simulate_hang or action_id in self.hanging_actions:
|
||||||
|
self.hanging_calls.append((ok_cb, ret))
|
||||||
|
else:
|
||||||
|
ok_cb(ret)
|
||||||
|
|
||||||
|
@dbus.service.method(MOCK_IFACE, in_signature='b', out_signature='')
|
||||||
|
def AllowUnknown(self, default):
|
||||||
|
'''Control whether unknown actions are allowed
|
||||||
|
|
||||||
|
This controls the return value of CheckAuthorization for actions which were
|
||||||
|
not explicitly allowed by SetAllowed().
|
||||||
|
'''
|
||||||
|
self.allow_unknown = default
|
||||||
|
|
||||||
|
@dbus.service.method(MOCK_IFACE, in_signature='d', out_signature='')
|
||||||
|
def SetDelay(self, delay):
|
||||||
|
'''Makes the CheckAuthorization() method to delay'''
|
||||||
|
self.delay = delay
|
||||||
|
|
||||||
|
@dbus.service.method(MOCK_IFACE, in_signature='b', out_signature='')
|
||||||
|
def SimulateHang(self, hang):
|
||||||
|
'''Makes the CheckAuthorization() method to hang'''
|
||||||
|
self.simulate_hang = hang
|
||||||
|
|
||||||
|
@dbus.service.method(MOCK_IFACE, in_signature='as', out_signature='')
|
||||||
|
def SimulateHangActions(self, actions):
|
||||||
|
'''Makes the CheckAuthorization() method to hang on such actions'''
|
||||||
|
self.hanging_actions = actions
|
||||||
|
|
||||||
|
@dbus.service.method(MOCK_IFACE, in_signature='', out_signature='')
|
||||||
|
def ReleaseHangingCalls(self):
|
||||||
|
'''Calls all the hanging callbacks'''
|
||||||
|
for (cb, ret) in self.hanging_calls:
|
||||||
|
cb(ret)
|
||||||
|
self.hanging_calls = []
|
||||||
|
|
||||||
|
@dbus.service.method(MOCK_IFACE, in_signature='', out_signature='b')
|
||||||
|
def HaveHangingCalls(self):
|
||||||
|
'''Check if we've hangling calls'''
|
||||||
|
return len(self.hanging_calls)
|
||||||
|
|
||||||
|
@dbus.service.method(MOCK_IFACE, in_signature='as', out_signature='')
|
||||||
|
def SetAllowed(self, actions):
|
||||||
|
'''Set allowed actions'''
|
||||||
|
|
||||||
|
self.allowed = actions
|
||||||
|
|
||||||
|
@dbus.service.method(MAIN_IFACE,
|
||||||
|
in_signature='', out_signature='o')
|
||||||
|
def GetDefaultDevice(self):
|
||||||
|
devices = self.GetDevices()
|
||||||
|
if len(devices) < 1:
|
||||||
|
raise dbus.exceptions.DBusException(
|
||||||
|
'No devices available',
|
||||||
|
name='net.reactivated.Fprint.Error.NoSuchDevice')
|
||||||
|
return devices[0]
|
||||||
132
tests/delete.c
@ -1,132 +0,0 @@
|
|||||||
/*
|
|
||||||
* fprintd example to delete fingerprints
|
|
||||||
* Copyright (C) 2008 Daniel Drake <dsd@gentoo.org>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along
|
|
||||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <dbus/dbus-glib-bindings.h>
|
|
||||||
#include "manager-dbus-glue.h"
|
|
||||||
#include "device-dbus-glue.h"
|
|
||||||
|
|
||||||
static DBusGProxy *manager = NULL;
|
|
||||||
static DBusGConnection *connection = NULL;
|
|
||||||
|
|
||||||
static void create_manager(void)
|
|
||||||
{
|
|
||||||
GError *error = NULL;
|
|
||||||
|
|
||||||
connection = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error);
|
|
||||||
if (connection == NULL) {
|
|
||||||
g_print("Failed to connect to session bus: %s\n", error->message);
|
|
||||||
exit (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
manager = dbus_g_proxy_new_for_name(connection,
|
|
||||||
"net.reactivated.Fprint", "/net/reactivated/Fprint/Manager",
|
|
||||||
"net.reactivated.Fprint.Manager");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void delete_fingerprints(DBusGProxy *dev, const char *username)
|
|
||||||
{
|
|
||||||
GError *error = NULL;
|
|
||||||
GHashTable *props;
|
|
||||||
DBusGProxy *p;
|
|
||||||
|
|
||||||
p = dbus_g_proxy_new_from_proxy(dev, "org.freedesktop.DBus.Properties", NULL);
|
|
||||||
if (!dbus_g_proxy_call (p, "GetAll", &error, G_TYPE_STRING, "net.reactivated.Fprint.Device", G_TYPE_INVALID,
|
|
||||||
dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE), &props, G_TYPE_INVALID)) {
|
|
||||||
g_print("GetAll on the Properties interface failed: %s\n", error->message);
|
|
||||||
exit (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!net_reactivated_Fprint_Device_delete_enrolled_fingers(dev, username, &error)) {
|
|
||||||
if (dbus_g_error_has_name (error, "net.reactivated.Fprint.Error.NoEnrolledPrints") == FALSE) {
|
|
||||||
g_print("ListEnrolledFingers failed: %s\n", error->message);
|
|
||||||
exit (1);
|
|
||||||
} else {
|
|
||||||
g_print ("No fingerprints to delete on %s\n", g_value_get_string (g_hash_table_lookup (props, "name")));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
g_print ("Fingerprints deleted on %s\n", g_value_get_string (g_hash_table_lookup (props, "name")));
|
|
||||||
}
|
|
||||||
g_hash_table_destroy (props);
|
|
||||||
g_object_unref (p);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void process_devices(char **argv)
|
|
||||||
{
|
|
||||||
GError *error = NULL;
|
|
||||||
GPtrArray *devices;
|
|
||||||
char *path;
|
|
||||||
guint i;
|
|
||||||
|
|
||||||
if (!net_reactivated_Fprint_Manager_get_devices(manager, &devices, &error)) {
|
|
||||||
g_print("list_devices failed: %s\n", error->message);
|
|
||||||
exit (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (devices->len == 0) {
|
|
||||||
g_print("No devices found\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_print("found %d devices\n", devices->len);
|
|
||||||
for (i = 0; i < devices->len; i++) {
|
|
||||||
path = g_ptr_array_index(devices, i);
|
|
||||||
g_print("Device at %s\n", path);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < devices->len; i++) {
|
|
||||||
guint j;
|
|
||||||
DBusGProxy *dev;
|
|
||||||
|
|
||||||
path = g_ptr_array_index(devices, i);
|
|
||||||
g_print("Using device %s\n", path);
|
|
||||||
|
|
||||||
/* FIXME use for_name_owner?? */
|
|
||||||
dev = dbus_g_proxy_new_for_name(connection, "net.reactivated.Fprint",
|
|
||||||
path, "net.reactivated.Fprint.Device");
|
|
||||||
|
|
||||||
for (j = 1; argv[j] != NULL; j++)
|
|
||||||
delete_fingerprints (dev, argv[j]);
|
|
||||||
|
|
||||||
g_object_unref (dev);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_ptr_array_foreach(devices, (GFunc) g_free, NULL);
|
|
||||||
g_ptr_array_free(devices, TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
#if !GLIB_CHECK_VERSION (2, 36, 0)
|
|
||||||
g_type_init();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
create_manager();
|
|
||||||
|
|
||||||
if (argc < 2) {
|
|
||||||
g_print ("Usage: %s <username> [usernames...]\n", argv[0]);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
process_devices (argv);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
185
tests/enroll.c
@ -1,185 +0,0 @@
|
|||||||
/*
|
|
||||||
* fprintd example to enroll right index finger
|
|
||||||
* Copyright (C) 2008 Daniel Drake <dsd@gentoo.org>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along
|
|
||||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <dbus/dbus-glib-bindings.h>
|
|
||||||
#include "manager-dbus-glue.h"
|
|
||||||
#include "device-dbus-glue.h"
|
|
||||||
#include "marshal.h"
|
|
||||||
|
|
||||||
#define N_(x) x
|
|
||||||
#define TR(x) x
|
|
||||||
#include "fingerprint-strings.h"
|
|
||||||
|
|
||||||
static DBusGProxy *manager = NULL;
|
|
||||||
static DBusGConnection *connection = NULL;
|
|
||||||
static char *finger_name = "right-index-finger";
|
|
||||||
static char **usernames = NULL;
|
|
||||||
|
|
||||||
static void create_manager(void)
|
|
||||||
{
|
|
||||||
GError *error = NULL;
|
|
||||||
|
|
||||||
connection = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error);
|
|
||||||
if (connection == NULL) {
|
|
||||||
g_print("Failed to connect to session bus: %s\n", error->message);
|
|
||||||
exit (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
manager = dbus_g_proxy_new_for_name(connection,
|
|
||||||
"net.reactivated.Fprint", "/net/reactivated/Fprint/Manager",
|
|
||||||
"net.reactivated.Fprint.Manager");
|
|
||||||
}
|
|
||||||
|
|
||||||
static DBusGProxy *open_device(const char *username)
|
|
||||||
{
|
|
||||||
GError *error = NULL;
|
|
||||||
gchar *path;
|
|
||||||
DBusGProxy *dev;
|
|
||||||
|
|
||||||
if (!net_reactivated_Fprint_Manager_get_default_device(manager, &path, &error)) {
|
|
||||||
g_print("list_devices failed: %s\n", error->message);
|
|
||||||
exit (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (path == NULL) {
|
|
||||||
g_print("No devices found\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_print("Using device %s\n", path);
|
|
||||||
|
|
||||||
/* FIXME use for_name_owner?? */
|
|
||||||
dev = dbus_g_proxy_new_for_name(connection, "net.reactivated.Fprint",
|
|
||||||
path, "net.reactivated.Fprint.Device");
|
|
||||||
|
|
||||||
g_free (path);
|
|
||||||
|
|
||||||
if (!net_reactivated_Fprint_Device_claim(dev, username, &error)) {
|
|
||||||
g_print("failed to claim device: %s\n", error->message);
|
|
||||||
exit (1);
|
|
||||||
}
|
|
||||||
return dev;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void enroll_result(GObject *object, const char *result, gboolean done, void *user_data)
|
|
||||||
{
|
|
||||||
gboolean *enroll_completed = user_data;
|
|
||||||
g_print("Enroll result: %s\n", result);
|
|
||||||
if (done != FALSE)
|
|
||||||
*enroll_completed = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void do_enroll(DBusGProxy *dev)
|
|
||||||
{
|
|
||||||
GError *error = NULL;
|
|
||||||
gboolean enroll_completed = FALSE;
|
|
||||||
gboolean found;
|
|
||||||
guint i;
|
|
||||||
|
|
||||||
dbus_g_proxy_add_signal(dev, "EnrollStatus", G_TYPE_STRING, G_TYPE_BOOLEAN, NULL);
|
|
||||||
dbus_g_proxy_connect_signal(dev, "EnrollStatus", G_CALLBACK(enroll_result),
|
|
||||||
&enroll_completed, NULL);
|
|
||||||
|
|
||||||
found = FALSE;
|
|
||||||
for (i = 0; fingers[i].dbus_name != NULL; i++) {
|
|
||||||
if (g_strcmp0 (fingers[i].dbus_name, finger_name) == 0) {
|
|
||||||
found = TRUE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!found) {
|
|
||||||
GString *s;
|
|
||||||
|
|
||||||
s = g_string_new (NULL);
|
|
||||||
g_string_append_printf (s, "Invalid finger name '%s'. Name must be one of ", finger_name);
|
|
||||||
for (i = 0; fingers[i].dbus_name != NULL; i++) {
|
|
||||||
g_string_append_printf (s, "%s", fingers[i].dbus_name);
|
|
||||||
if (fingers[i + 1].dbus_name != NULL)
|
|
||||||
g_string_append (s, ", ");
|
|
||||||
}
|
|
||||||
g_warning ("%s", s->str);
|
|
||||||
g_string_free (s, TRUE);
|
|
||||||
exit (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_print("Enrolling %s finger.\n", finger_name);
|
|
||||||
if (!net_reactivated_Fprint_Device_enroll_start(dev, finger_name, &error)) {
|
|
||||||
g_print("EnrollStart failed: %s\n", error->message);
|
|
||||||
exit (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
while (!enroll_completed)
|
|
||||||
g_main_context_iteration(NULL, TRUE);
|
|
||||||
|
|
||||||
dbus_g_proxy_disconnect_signal(dev, "EnrollStatus",
|
|
||||||
G_CALLBACK(enroll_result), &enroll_completed);
|
|
||||||
|
|
||||||
if (!net_reactivated_Fprint_Device_enroll_stop(dev, &error)) {
|
|
||||||
g_print("VerifyStop failed: %s\n", error->message);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void release_device(DBusGProxy *dev)
|
|
||||||
{
|
|
||||||
GError *error = NULL;
|
|
||||||
if (!net_reactivated_Fprint_Device_release(dev, &error)) {
|
|
||||||
g_print("ReleaseDevice failed: %s\n", error->message);
|
|
||||||
exit (1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static const GOptionEntry entries[] = {
|
|
||||||
{ "finger", 'f', 0, G_OPTION_ARG_STRING, &finger_name, "Finger selected to verify (default is automatic)", NULL },
|
|
||||||
{ G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_STRING_ARRAY, &usernames, NULL, "[username]" },
|
|
||||||
{ NULL }
|
|
||||||
};
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
GOptionContext *context;
|
|
||||||
GError *err = NULL;
|
|
||||||
DBusGProxy *dev;
|
|
||||||
|
|
||||||
#if !GLIB_CHECK_VERSION (2, 36, 0)
|
|
||||||
g_type_init();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
dbus_g_object_register_marshaller (fprintd_marshal_VOID__STRING_BOOLEAN,
|
|
||||||
G_TYPE_NONE, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_INVALID);
|
|
||||||
|
|
||||||
context = g_option_context_new ("Enroll a fingerprint");
|
|
||||||
g_option_context_add_main_entries (context, entries, NULL);
|
|
||||||
|
|
||||||
if (g_option_context_parse (context, &argc, &argv, &err) == FALSE) {
|
|
||||||
g_print ("couldn't parse command-line options: %s\n", err->message);
|
|
||||||
g_error_free (err);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
create_manager();
|
|
||||||
|
|
||||||
dev = open_device(usernames ? usernames[0] : NULL);
|
|
||||||
do_enroll(dev);
|
|
||||||
release_device(dev);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
1551
tests/fprintd.py
Normal file
148
tests/list.c
@ -1,148 +0,0 @@
|
|||||||
/*
|
|
||||||
* fprintd example to list enrolled fingerprints
|
|
||||||
* Copyright (C) 2008 Daniel Drake <dsd@gentoo.org>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along
|
|
||||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <dbus/dbus-glib-bindings.h>
|
|
||||||
#include "manager-dbus-glue.h"
|
|
||||||
#include "device-dbus-glue.h"
|
|
||||||
|
|
||||||
static DBusGProxy *manager = NULL;
|
|
||||||
static DBusGConnection *connection = NULL;
|
|
||||||
|
|
||||||
static void create_manager(void)
|
|
||||||
{
|
|
||||||
GError *error = NULL;
|
|
||||||
|
|
||||||
connection = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error);
|
|
||||||
if (connection == NULL) {
|
|
||||||
g_print("Failed to connect to session bus: %s\n", error->message);
|
|
||||||
exit (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
manager = dbus_g_proxy_new_for_name(connection,
|
|
||||||
"net.reactivated.Fprint", "/net/reactivated/Fprint/Manager",
|
|
||||||
"net.reactivated.Fprint.Manager");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void list_fingerprints(DBusGProxy *dev, const char *username)
|
|
||||||
{
|
|
||||||
GError *error = NULL;
|
|
||||||
char **fingers;
|
|
||||||
GHashTable *props;
|
|
||||||
DBusGProxy *p;
|
|
||||||
guint i;
|
|
||||||
|
|
||||||
if (!net_reactivated_Fprint_Device_list_enrolled_fingers(dev, username, &fingers, &error)) {
|
|
||||||
if (dbus_g_error_has_name (error, "net.reactivated.Fprint.Error.NoEnrolledPrints") == FALSE) {
|
|
||||||
g_print("ListEnrolledFingers failed: %s\n", error->message);
|
|
||||||
exit (1);
|
|
||||||
} else {
|
|
||||||
fingers = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
p = dbus_g_proxy_new_from_proxy(dev, "org.freedesktop.DBus.Properties", NULL);
|
|
||||||
if (!dbus_g_proxy_call (p, "GetAll", &error, G_TYPE_STRING, "net.reactivated.Fprint.Device", G_TYPE_INVALID,
|
|
||||||
dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE), &props, G_TYPE_INVALID)) {
|
|
||||||
g_print("GetAll on the Properties interface failed: %s\n", error->message);
|
|
||||||
exit (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fingers == NULL || g_strv_length (fingers) == 0) {
|
|
||||||
g_print("User %s has no fingers enrolled for %s.\n", username, g_value_get_string (g_hash_table_lookup (props, "name")));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_print("Fingerprints for user %s on %s (%s):\n",
|
|
||||||
username,
|
|
||||||
g_value_get_string (g_hash_table_lookup (props, "name")),
|
|
||||||
g_value_get_string (g_hash_table_lookup (props, "scan-type")));
|
|
||||||
g_hash_table_destroy (props);
|
|
||||||
g_object_unref (p);
|
|
||||||
|
|
||||||
for (i = 0; fingers[i] != NULL; i++) {
|
|
||||||
g_print(" - #%d: %s\n", i, fingers[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_strfreev (fingers);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void process_devices(char **argv)
|
|
||||||
{
|
|
||||||
GError *error = NULL;
|
|
||||||
GPtrArray *devices;
|
|
||||||
char *path;
|
|
||||||
guint i;
|
|
||||||
|
|
||||||
if (!net_reactivated_Fprint_Manager_get_devices(manager, &devices, &error)) {
|
|
||||||
g_print("list_devices failed: %s\n", error->message);
|
|
||||||
exit (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (devices->len == 0) {
|
|
||||||
g_print("No devices found\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_print("found %d devices\n", devices->len);
|
|
||||||
for (i = 0; i < devices->len; i++) {
|
|
||||||
path = g_ptr_array_index(devices, i);
|
|
||||||
g_print("Device at %s\n", path);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < devices->len; i++) {
|
|
||||||
guint j;
|
|
||||||
DBusGProxy *dev;
|
|
||||||
|
|
||||||
path = g_ptr_array_index(devices, i);
|
|
||||||
g_print("Using device %s\n", path);
|
|
||||||
|
|
||||||
/* FIXME use for_name_owner?? */
|
|
||||||
dev = dbus_g_proxy_new_for_name(connection, "net.reactivated.Fprint",
|
|
||||||
path, "net.reactivated.Fprint.Device");
|
|
||||||
|
|
||||||
for (j = 1; argv[j] != NULL; j++)
|
|
||||||
list_fingerprints (dev, argv[j]);
|
|
||||||
|
|
||||||
g_object_unref (dev);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_ptr_array_foreach(devices, (GFunc) g_free, NULL);
|
|
||||||
g_ptr_array_free(devices, TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
#if !GLIB_CHECK_VERSION (2, 36, 0)
|
|
||||||
g_type_init();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
create_manager();
|
|
||||||
|
|
||||||
if (argc < 2) {
|
|
||||||
g_print ("Usage: %s <username> [usernames...]\n", argv[0]);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
process_devices (argv);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
126
tests/meson.build
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
# Add a way to discover and run python unit tests separately
|
||||||
|
# https://github.com/mesonbuild/meson/issues/6851
|
||||||
|
python_tests = [
|
||||||
|
# List all the python tests, must be in the form:
|
||||||
|
# {
|
||||||
|
# 'name': 'test name',
|
||||||
|
# 'file': 'full test file path, use files('path')[0]',
|
||||||
|
# Fields below are optional:
|
||||||
|
# 'workdir': '',
|
||||||
|
# 'env': [],
|
||||||
|
# 'depends': [],
|
||||||
|
# 'suite': [],
|
||||||
|
# 'extra_args': [],
|
||||||
|
# 'timeout': 30,
|
||||||
|
# 'is_parallel': true,
|
||||||
|
# }
|
||||||
|
]
|
||||||
|
|
||||||
|
address_sanitizer = get_option('b_sanitize') == 'address'
|
||||||
|
|
||||||
|
tests = [
|
||||||
|
'fprintd',
|
||||||
|
'test_fprintd_utils',
|
||||||
|
]
|
||||||
|
|
||||||
|
foreach t: tests
|
||||||
|
python_tests += [
|
||||||
|
{
|
||||||
|
'name': t,
|
||||||
|
'file': files(meson.current_source_dir() / t + '.py')[0],
|
||||||
|
'env': [
|
||||||
|
'G_DEBUG=fatal-criticals',
|
||||||
|
'G_MESSAGES_DEBUG=all',
|
||||||
|
'FPRINT_BUILD_DIR=' + meson.build_root() / 'src',
|
||||||
|
'TOPSRCDIR=' + meson.source_root(),
|
||||||
|
],
|
||||||
|
'depends': [
|
||||||
|
fprintd,
|
||||||
|
fprintd_utils,
|
||||||
|
],
|
||||||
|
'suite': [t == 'fprintd' ? 'daemon' : ''],
|
||||||
|
}
|
||||||
|
]
|
||||||
|
endforeach
|
||||||
|
|
||||||
|
if get_option('pam')
|
||||||
|
subdir('pam')
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Add a way to discover and run python unit tests separately
|
||||||
|
# https://github.com/mesonbuild/meson/issues/6851
|
||||||
|
unittest_inspector = find_program('unittest_inspector.py')
|
||||||
|
|
||||||
|
foreach pt: python_tests
|
||||||
|
r = run_command(unittest_inspector, pt.get('file'))
|
||||||
|
unit_tests = r.stdout().strip().split('\n')
|
||||||
|
base_args = [ pt.get('file') ] + pt.get('extra_args', [])
|
||||||
|
suite = pt.get('suite', [])
|
||||||
|
|
||||||
|
if r.returncode() == 0 and unit_tests.length() > 0
|
||||||
|
suite += pt.get('name')
|
||||||
|
else
|
||||||
|
unit_tests = [pt.get('name')]
|
||||||
|
endif
|
||||||
|
|
||||||
|
foreach ut: unit_tests
|
||||||
|
ut_suite = suite
|
||||||
|
ut_args = base_args
|
||||||
|
if unit_tests.length() > 1
|
||||||
|
ut_args += ut
|
||||||
|
ut_suite += ut.split('.')[0]
|
||||||
|
endif
|
||||||
|
test(ut,
|
||||||
|
python3,
|
||||||
|
args: ut_args,
|
||||||
|
suite: ut_suite,
|
||||||
|
depends: pt.get('depends', []),
|
||||||
|
workdir: pt.get('workdir', meson.build_root()),
|
||||||
|
env: pt.get('env', []),
|
||||||
|
timeout: pt.get('timeout', 30),
|
||||||
|
is_parallel: pt.get('is_parallel', true),
|
||||||
|
)
|
||||||
|
endforeach
|
||||||
|
endforeach
|
||||||
|
|
||||||
|
timeout_multiplier = 1
|
||||||
|
test_envs = [
|
||||||
|
'G_SLICE=always-malloc',
|
||||||
|
'MALLOC_CHECK_=2',
|
||||||
|
]
|
||||||
|
|
||||||
|
if address_sanitizer
|
||||||
|
timeout_multiplier = 3
|
||||||
|
test_envs += [
|
||||||
|
'ADDRESS_SANITIZER=true',
|
||||||
|
'ASAN_OPTIONS=@0@'.format(':'.join([
|
||||||
|
'abort_on_error=true',
|
||||||
|
'symbolize=true',
|
||||||
|
])),
|
||||||
|
'LSAN_OPTIONS=@0@'.format(':'.join([
|
||||||
|
'exitcode=0',
|
||||||
|
'strict_string_checks=true',
|
||||||
|
'suppressions=@0@'.format(
|
||||||
|
files(meson.current_source_dir() / 'LSAN-leaks-suppress.txt')[0]),
|
||||||
|
])),
|
||||||
|
]
|
||||||
|
endif
|
||||||
|
|
||||||
|
add_test_setup('default_setup',
|
||||||
|
is_default: true,
|
||||||
|
env: test_envs,
|
||||||
|
timeout_multiplier: timeout_multiplier
|
||||||
|
)
|
||||||
|
|
||||||
|
if not address_sanitizer and find_program('valgrind', required: false).found()
|
||||||
|
glib_share = glib_dep.get_pkgconfig_variable('prefix') / 'share' / glib_dep.name()
|
||||||
|
glib_suppressions = glib_share + '/valgrind/glib.supp'
|
||||||
|
add_test_setup('valgrind',
|
||||||
|
env: [
|
||||||
|
'G_SLICE=always-malloc',
|
||||||
|
'VALGRIND=' + glib_suppressions,
|
||||||
|
],
|
||||||
|
timeout_multiplier: 5
|
||||||
|
)
|
||||||
|
endif
|
||||||
|
|
||||||
148
tests/output_checker.py
Normal file
@ -0,0 +1,148 @@
|
|||||||
|
#! /usr/bin/env python3
|
||||||
|
# Copyright © 2020, RedHat Inc.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU Lesser General Public
|
||||||
|
# License as published by the Free Software Foundation; either
|
||||||
|
# version 2.1 of the License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
# Lesser General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Lesser General Public
|
||||||
|
# License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
# Authors:
|
||||||
|
# Benjamin Berg <bberg@redhat.com>
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import fcntl
|
||||||
|
import io
|
||||||
|
import re
|
||||||
|
import time
|
||||||
|
import threading
|
||||||
|
|
||||||
|
class OutputChecker(object):
|
||||||
|
|
||||||
|
def __init__(self, out=sys.stdout):
|
||||||
|
self._output = out
|
||||||
|
self._pipe_fd_r, self._pipe_fd_w = os.pipe()
|
||||||
|
self._partial_buf = b''
|
||||||
|
self._lines_sem = threading.Semaphore()
|
||||||
|
self._lines = []
|
||||||
|
self._reader_io = io.StringIO()
|
||||||
|
|
||||||
|
# Just to be sure, shouldn't be a problem even if we didn't set it
|
||||||
|
fcntl.fcntl(self._pipe_fd_r, fcntl.F_SETFL,
|
||||||
|
fcntl.fcntl(self._pipe_fd_r, fcntl.F_GETFL) | os.O_CLOEXEC)
|
||||||
|
fcntl.fcntl(self._pipe_fd_w, fcntl.F_SETFL,
|
||||||
|
fcntl.fcntl(self._pipe_fd_w, fcntl.F_GETFL) | os.O_CLOEXEC)
|
||||||
|
|
||||||
|
# Start copier thread
|
||||||
|
self._thread = threading.Thread(target=self._copy)
|
||||||
|
self._thread.start()
|
||||||
|
|
||||||
|
def _copy(self):
|
||||||
|
while True:
|
||||||
|
r = os.read(self._pipe_fd_r, 1024)
|
||||||
|
if not r:
|
||||||
|
return
|
||||||
|
|
||||||
|
l = r.split(b'\n')
|
||||||
|
l[0] = self._partial_buf + l[0]
|
||||||
|
self._lines.extend(l[:-1])
|
||||||
|
self._partial_buf = l[-1]
|
||||||
|
|
||||||
|
self._lines_sem.release()
|
||||||
|
|
||||||
|
os.write(self._output.fileno(), r)
|
||||||
|
|
||||||
|
def check_line_re(self, needle_re, timeout=0, failmsg=None):
|
||||||
|
deadline = time.time() + timeout
|
||||||
|
|
||||||
|
if isinstance(needle_re, str):
|
||||||
|
needle_re = needle_re.encode('ascii')
|
||||||
|
|
||||||
|
r = re.compile(needle_re)
|
||||||
|
ret = []
|
||||||
|
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
|
l = self._lines.pop(0)
|
||||||
|
except IndexError:
|
||||||
|
# Check if should wake up
|
||||||
|
if not self._lines_sem.acquire(timeout = deadline - time.time()):
|
||||||
|
if failmsg:
|
||||||
|
raise AssertionError(failmsg)
|
||||||
|
else:
|
||||||
|
raise AssertionError('Timed out waiting for needle %s (timeout: %0.2f)' % (str(needle_re), timeout))
|
||||||
|
continue
|
||||||
|
|
||||||
|
ret.append(l)
|
||||||
|
if r.search(l):
|
||||||
|
return ret
|
||||||
|
|
||||||
|
def check_line(self, needle, timeout=0, failmsg=None):
|
||||||
|
if isinstance(needle, str):
|
||||||
|
needle = needle.encode('ascii')
|
||||||
|
|
||||||
|
needle_re = re.escape(needle)
|
||||||
|
|
||||||
|
return self.check_line_re(needle_re, timeout=timeout, failmsg=failmsg)
|
||||||
|
|
||||||
|
def check_no_line_re(self, needle_re, wait=0, failmsg=None):
|
||||||
|
deadline = time.time() + wait
|
||||||
|
|
||||||
|
if isinstance(needle_re, str):
|
||||||
|
needle_re = needle_re.encode('ascii')
|
||||||
|
|
||||||
|
r = re.compile(needle_re)
|
||||||
|
ret = []
|
||||||
|
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
|
l = self._lines.pop(0)
|
||||||
|
except IndexError:
|
||||||
|
# Check if should wake up
|
||||||
|
if not self._lines_sem.acquire(timeout = deadline - time.time()):
|
||||||
|
# Timed out, so everything is good
|
||||||
|
break
|
||||||
|
continue
|
||||||
|
|
||||||
|
ret.append(l)
|
||||||
|
if r.search(l):
|
||||||
|
if failmsg:
|
||||||
|
raise AssertionError(failmsg)
|
||||||
|
else:
|
||||||
|
raise AssertionError('Found needle %s but shouldn\'t have been there (timeout: %0.2f)' % (str(needle_re), timeout))
|
||||||
|
|
||||||
|
return ret
|
||||||
|
|
||||||
|
def check_no_line(self, needle, wait=0, failmsg=None):
|
||||||
|
if isinstance(needle, str):
|
||||||
|
needle = needle.encode('ascii')
|
||||||
|
|
||||||
|
needle_re = re.escape(needle)
|
||||||
|
|
||||||
|
return self.check_no_line_re(needle_re, wait=wait, failmsg=failmsg)
|
||||||
|
|
||||||
|
def clear(self):
|
||||||
|
ret = self._lines
|
||||||
|
self._lines = []
|
||||||
|
return ret
|
||||||
|
|
||||||
|
def assert_closed(self, timeout=1):
|
||||||
|
self._thread.join(timeout)
|
||||||
|
if self._thread.is_alive() != False:
|
||||||
|
raise AssertionError("OutputCheck: Write side has not been closed yet!")
|
||||||
|
|
||||||
|
@property
|
||||||
|
def fd(self):
|
||||||
|
return self._pipe_fd_w
|
||||||
|
|
||||||
|
def writer_attached(self):
|
||||||
|
os.close(self._pipe_fd_w)
|
||||||
|
self._pipe_fd_w = -1
|
||||||
|
|
||||||
59
tests/pam/meson.build
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
subdir('services')
|
||||||
|
|
||||||
|
tests = [
|
||||||
|
'test_pam_fprintd',
|
||||||
|
]
|
||||||
|
|
||||||
|
preloaded_libs = []
|
||||||
|
pam_tests_ld_preload = []
|
||||||
|
|
||||||
|
if address_sanitizer
|
||||||
|
# ASAN has to be the first in list
|
||||||
|
preloaded_libs += 'asan'
|
||||||
|
endif
|
||||||
|
|
||||||
|
preloaded_libs += 'pam_wrapper'
|
||||||
|
|
||||||
|
foreach libname: preloaded_libs
|
||||||
|
lib = run_command(meson.get_compiler('c'),
|
||||||
|
'-print-file-name=lib@0@.so'.format(libname)
|
||||||
|
).stdout().strip()
|
||||||
|
|
||||||
|
# Support linker script files
|
||||||
|
if run_command('grep', '-qI', '^INPUT', files(lib)).returncode() == 0
|
||||||
|
out = run_command('cat', lib).stdout()
|
||||||
|
lib = out.split('(')[1].split(')')[0].strip()
|
||||||
|
endif
|
||||||
|
|
||||||
|
if lib != '' and lib[0] == '/'
|
||||||
|
message('Found library @0@ as @1@'.format(libname, lib))
|
||||||
|
pam_tests_ld_preload += '@0@'.format(files(lib)[0])
|
||||||
|
else
|
||||||
|
tests = []
|
||||||
|
warning('No library found for ' + libname + ', skipping PAM tests')
|
||||||
|
endif
|
||||||
|
endforeach
|
||||||
|
|
||||||
|
foreach t: tests
|
||||||
|
python_tests += [
|
||||||
|
{
|
||||||
|
'name': t,
|
||||||
|
'file': files(meson.current_source_dir() / t + '.py')[0],
|
||||||
|
'is_parallel': false,
|
||||||
|
'env': [
|
||||||
|
'TOPBUILDDIR=' + meson.build_root(),
|
||||||
|
'TOPSRCDIR=' + meson.source_root(),
|
||||||
|
'LD_PRELOAD=' + ' '.join(pam_tests_ld_preload),
|
||||||
|
'PAM_WRAPPER=1',
|
||||||
|
'PAM_WRAPPER_DEBUGLEVEL=2',
|
||||||
|
'PAM_WRAPPER_SERVICE_DIR=' + meson.current_build_dir() / 'services',
|
||||||
|
'G_DEBUG=fatal-warnings',
|
||||||
|
],
|
||||||
|
'depends': [
|
||||||
|
pam_fprintd,
|
||||||
|
pam_service_file,
|
||||||
|
],
|
||||||
|
'suite': ['PAM'],
|
||||||
|
}
|
||||||
|
]
|
||||||
|
endforeach
|
||||||
1
tests/pam/services/fprintd-pam-test.in
Normal file
@ -0,0 +1 @@
|
|||||||
|
auth required @FPRINTDPAMPATH@ debug timeout=10
|
||||||
13
tests/pam/services/meson.build
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
# Meson doesn't allow to have configure_file's as targets we depend on... Meh!
|
||||||
|
pam_service_file = custom_target('pam_test_service_file',
|
||||||
|
output: 'null',
|
||||||
|
command: 'true',
|
||||||
|
depends: pam_fprintd,
|
||||||
|
depend_files: configure_file(
|
||||||
|
input: 'fprintd-pam-test.in',
|
||||||
|
output: 'fprintd-pam-test',
|
||||||
|
configuration: configuration_data({
|
||||||
|
'FPRINTDPAMPATH': pam_fprintd.full_path(),
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
)
|
||||||
298
tests/pam/test_pam_fprintd.py
Executable file
@ -0,0 +1,298 @@
|
|||||||
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU Lesser General Public License as published by the Free
|
||||||
|
# Software Foundation; either version 3 of the License, or (at your option) any
|
||||||
|
# later version. See http://www.gnu.org/copyleft/lgpl.html for the full text
|
||||||
|
# of the license.
|
||||||
|
|
||||||
|
__author__ = 'Bastien Nocera'
|
||||||
|
__email__ = 'hadess@hadess.net'
|
||||||
|
__copyright__ = '(c) 2020 Red Hat Inc.'
|
||||||
|
__license__ = 'LGPL 3+'
|
||||||
|
|
||||||
|
import tempfile
|
||||||
|
import unittest
|
||||||
|
import sys
|
||||||
|
import subprocess
|
||||||
|
import dbus
|
||||||
|
import dbusmock
|
||||||
|
import glob
|
||||||
|
import os
|
||||||
|
import shutil
|
||||||
|
import time
|
||||||
|
import pypamtest
|
||||||
|
|
||||||
|
PAM_SUCCESS = 0
|
||||||
|
PAM_AUTH_ERR = 7
|
||||||
|
PAM_AUTHINFO_UNAVAIL = 9
|
||||||
|
PAM_USER_UNKNOWN = 10
|
||||||
|
PAM_MAXTRIES = 11
|
||||||
|
|
||||||
|
class TestPamFprintd(dbusmock.DBusTestCase):
|
||||||
|
'''Test pam_fprintd'''
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def start_monitor(klass):
|
||||||
|
'''Start dbus-monitor'''
|
||||||
|
|
||||||
|
workdir = os.environ['TOPBUILDDIR'] + '/tests/pam/'
|
||||||
|
klass.monitor_log = open(os.path.join(workdir, 'dbus-monitor.log'), 'wb', buffering=0)
|
||||||
|
klass.monitor = subprocess.Popen(['dbus-monitor', '--monitor', '--system'],
|
||||||
|
stdout=klass.monitor_log,
|
||||||
|
stderr=subprocess.STDOUT)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def stop_monitor(klass):
|
||||||
|
'''Stop dbus-monitor'''
|
||||||
|
|
||||||
|
assert klass.monitor
|
||||||
|
klass.monitor.terminate()
|
||||||
|
klass.monitor.wait()
|
||||||
|
|
||||||
|
klass.monitor_log.flush()
|
||||||
|
klass.monitor_log.close()
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def setUpClass(klass):
|
||||||
|
klass.start_system_bus()
|
||||||
|
klass.start_monitor()
|
||||||
|
klass.dbus_con = klass.get_dbus(True)
|
||||||
|
|
||||||
|
template_path = './'
|
||||||
|
if 'TOPSRCDIR' in os.environ:
|
||||||
|
template_path = os.environ['TOPSRCDIR'] + '/tests/'
|
||||||
|
klass.template_name = template_path + 'dbusmock/fprintd.py'
|
||||||
|
print ('Using template from %s' % klass.template_name)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def tearDownClass(klass):
|
||||||
|
klass.stop_monitor()
|
||||||
|
|
||||||
|
# Remove pam wrapper files, as they may break other tests
|
||||||
|
[shutil.rmtree(i) for i in glob.glob('/tmp/pam.[0-9A-z]')]
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
(self.p_mock, self.obj_fprintd_manager) = self.spawn_server_template(
|
||||||
|
self.template_name, {})
|
||||||
|
self.obj_fprintd_mock = dbus.Interface(self.obj_fprintd_manager, 'net.reactivated.Fprint.Manager.Mock')
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
self.p_mock.terminate()
|
||||||
|
self.p_mock.wait()
|
||||||
|
|
||||||
|
def setup_device(self):
|
||||||
|
device_path = self.obj_fprintd_mock.AddDevice('FDO Trigger Finger Laser Reader', 3, 'swipe')
|
||||||
|
self.device_mock = self.dbus_con.get_object('net.reactivated.Fprint', device_path)
|
||||||
|
self.device_mock.SetEnrolledFingers('toto', ['left-little-finger', 'right-little-finger'])
|
||||||
|
|
||||||
|
def test_pam_no_device(self):
|
||||||
|
tc = pypamtest.TestCase(pypamtest.PAMTEST_AUTHENTICATE, expected_rv=PAM_AUTHINFO_UNAVAIL)
|
||||||
|
res = pypamtest.run_pamtest("toto", "fprintd-pam-test", [tc], [ 'unused' ])
|
||||||
|
|
||||||
|
def test_pam_fprintd_identify_error(self):
|
||||||
|
self.setup_device()
|
||||||
|
script = [
|
||||||
|
( 'verify-unknown-error', True, 2 )
|
||||||
|
]
|
||||||
|
self.device_mock.SetVerifyScript(script)
|
||||||
|
|
||||||
|
tc = pypamtest.TestCase(pypamtest.PAMTEST_AUTHENTICATE, expected_rv=PAM_AUTHINFO_UNAVAIL)
|
||||||
|
res = pypamtest.run_pamtest("toto", "fprintd-pam-test", [tc], [ 'unused' ])
|
||||||
|
|
||||||
|
self.assertRegex(res.info[0], r'Swipe your left little finger across the fingerprint reader')
|
||||||
|
self.assertEqual(len(res.errors), 0)
|
||||||
|
|
||||||
|
def test_pam_fprintd_identify_error2(self):
|
||||||
|
self.setup_device()
|
||||||
|
script = [
|
||||||
|
( 'verify-disconnected', True, 2 )
|
||||||
|
]
|
||||||
|
self.device_mock.SetVerifyScript(script)
|
||||||
|
|
||||||
|
tc = pypamtest.TestCase(pypamtest.PAMTEST_AUTHENTICATE, expected_rv=PAM_AUTHINFO_UNAVAIL)
|
||||||
|
res = pypamtest.run_pamtest("toto", "fprintd-pam-test", [tc], [ 'unused' ])
|
||||||
|
|
||||||
|
self.assertRegex(res.info[0], r'Swipe your left little finger across the fingerprint reader')
|
||||||
|
self.assertEqual(len(res.errors), 0)
|
||||||
|
|
||||||
|
def test_pam_fprintd_identify_error3(self):
|
||||||
|
self.setup_device()
|
||||||
|
script = [
|
||||||
|
( 'verify-INVALID', True, 2 )
|
||||||
|
]
|
||||||
|
self.device_mock.SetVerifyScript(script)
|
||||||
|
|
||||||
|
tc = pypamtest.TestCase(pypamtest.PAMTEST_AUTHENTICATE, expected_rv=PAM_AUTH_ERR)
|
||||||
|
res = pypamtest.run_pamtest("toto", "fprintd-pam-test", [tc], [ 'unused' ])
|
||||||
|
|
||||||
|
self.assertRegex(res.info[0], r'Swipe your left little finger across the fingerprint reader')
|
||||||
|
self.assertEqual(len(res.errors), 1)
|
||||||
|
self.assertRegex(res.errors[0], r'An unknown error occurred')
|
||||||
|
|
||||||
|
def test_pam_fprintd_auth(self):
|
||||||
|
self.setup_device()
|
||||||
|
script = [
|
||||||
|
( 'verify-match', True, 2 )
|
||||||
|
]
|
||||||
|
self.device_mock.SetVerifyScript(script)
|
||||||
|
|
||||||
|
tc = pypamtest.TestCase(pypamtest.PAMTEST_AUTHENTICATE, expected_rv=PAM_SUCCESS)
|
||||||
|
res = pypamtest.run_pamtest("toto", "fprintd-pam-test", [tc], [ 'unused' ])
|
||||||
|
|
||||||
|
self.assertRegex(res.info[0], r'Swipe your left little finger across the fingerprint reader')
|
||||||
|
self.assertEqual(len(res.errors), 0)
|
||||||
|
|
||||||
|
def test_pam_fprintd_no_fingers(self):
|
||||||
|
self.setup_device()
|
||||||
|
self.device_mock.SetEnrolledFingers('toto', dbus.Array(set([]), signature='s'))
|
||||||
|
script = [
|
||||||
|
( 'verify-match', True, 1 )
|
||||||
|
]
|
||||||
|
self.device_mock.SetVerifyScript(script)
|
||||||
|
|
||||||
|
tc = pypamtest.TestCase(pypamtest.PAMTEST_AUTHENTICATE, expected_rv=PAM_AUTHINFO_UNAVAIL)
|
||||||
|
res = pypamtest.run_pamtest("toto", "fprintd-pam-test", [tc], [ 'unused' ])
|
||||||
|
|
||||||
|
def test_pam_fprintd_no_fingers_while_verifying(self):
|
||||||
|
self.setup_device()
|
||||||
|
script = [
|
||||||
|
( 'MOCK: no-prints', True, 1),
|
||||||
|
( 'verify-match', True, 1 )
|
||||||
|
]
|
||||||
|
self.device_mock.SetVerifyScript(script)
|
||||||
|
|
||||||
|
tc = pypamtest.TestCase(pypamtest.PAMTEST_AUTHENTICATE, expected_rv=PAM_USER_UNKNOWN)
|
||||||
|
res = pypamtest.run_pamtest("toto", "fprintd-pam-test", [tc], [ 'unused' ])
|
||||||
|
|
||||||
|
def test_pam_fprintd_blocks_unexpected_auth(self):
|
||||||
|
self.setup_device()
|
||||||
|
script = [
|
||||||
|
( 'verify-match', True, -500 ), # This one is sent before VerifyStart has completed
|
||||||
|
( 'verify-no-match', True, 1 ),
|
||||||
|
( 'verify-no-match', True, 1 ),
|
||||||
|
( 'verify-no-match', True, 1 ),
|
||||||
|
]
|
||||||
|
self.device_mock.SetVerifyScript(script)
|
||||||
|
|
||||||
|
tc = pypamtest.TestCase(pypamtest.PAMTEST_AUTHENTICATE, expected_rv=PAM_MAXTRIES)
|
||||||
|
res = pypamtest.run_pamtest("toto", "fprintd-pam-test", [tc], [ 'unused' ])
|
||||||
|
|
||||||
|
self.assertRegex(res.info[0], r'Swipe your left little finger across the fingerprint reader')
|
||||||
|
self.assertEqual(len(res.errors), 3)
|
||||||
|
self.assertRegex(res.errors[0], r'Failed to match fingerprint')
|
||||||
|
self.assertRegex(res.errors[0], r'Failed to match fingerprint')
|
||||||
|
self.assertRegex(res.errors[0], r'Failed to match fingerprint')
|
||||||
|
|
||||||
|
def test_pam_fprintd_blocks_unexpected_auth2(self):
|
||||||
|
self.setup_device()
|
||||||
|
script = [
|
||||||
|
( 'verify-no-match', True, 1 ),
|
||||||
|
( 'verify-match', True, -500 ), # This one is sent before VerifyStart has completed
|
||||||
|
( 'verify-no-match', True, 1 ),
|
||||||
|
( 'verify-no-match', True, 1 ),
|
||||||
|
]
|
||||||
|
self.device_mock.SetVerifyScript(script)
|
||||||
|
|
||||||
|
tc = pypamtest.TestCase(pypamtest.PAMTEST_AUTHENTICATE, expected_rv=PAM_MAXTRIES)
|
||||||
|
res = pypamtest.run_pamtest("toto", "fprintd-pam-test", [tc], [ 'unused' ])
|
||||||
|
|
||||||
|
self.assertRegex(res.info[0], r'Swipe your left little finger across the fingerprint reader')
|
||||||
|
self.assertEqual(len(res.errors), 3)
|
||||||
|
self.assertRegex(res.errors[0], r'Failed to match fingerprint')
|
||||||
|
self.assertRegex(res.errors[0], r'Failed to match fingerprint')
|
||||||
|
self.assertRegex(res.errors[0], r'Failed to match fingerprint')
|
||||||
|
|
||||||
|
def test_pam_fprintd_dual_reader_auth(self):
|
||||||
|
device_path = self.obj_fprintd_mock.AddDevice('FDO Sandpaper Reader', 3, 'press')
|
||||||
|
sandpaper_device_mock = self.dbus_con.get_object('net.reactivated.Fprint', device_path)
|
||||||
|
sandpaper_device_mock.SetEnrolledFingers('toto', ['left-middle-finger', 'right-middle-finger'])
|
||||||
|
script = [
|
||||||
|
( 'verify-match', True, 2 )
|
||||||
|
]
|
||||||
|
sandpaper_device_mock.SetVerifyScript(script)
|
||||||
|
|
||||||
|
# Add a 2nd device
|
||||||
|
self.setup_device()
|
||||||
|
|
||||||
|
tc = pypamtest.TestCase(pypamtest.PAMTEST_AUTHENTICATE, expected_rv=PAM_SUCCESS)
|
||||||
|
res = pypamtest.run_pamtest("toto", "fprintd-pam-test", [tc], [ 'unused' ])
|
||||||
|
|
||||||
|
self.assertRegex(res.info[0], r'Place your left middle finger on FDO Sandpaper Reader')
|
||||||
|
self.assertEqual(len(res.errors), 0)
|
||||||
|
|
||||||
|
def test_pam_fprintd_last_try_auth(self):
|
||||||
|
self.setup_device()
|
||||||
|
script = [
|
||||||
|
( 'verify-no-match', True, 1 ),
|
||||||
|
( 'verify-no-match', True, 1 ),
|
||||||
|
( 'verify-match', True, 1 ),
|
||||||
|
]
|
||||||
|
self.device_mock.SetVerifyScript(script)
|
||||||
|
|
||||||
|
tc = pypamtest.TestCase(pypamtest.PAMTEST_AUTHENTICATE, expected_rv=PAM_SUCCESS)
|
||||||
|
res = pypamtest.run_pamtest("toto", "fprintd-pam-test", [tc], [ 'unused' ])
|
||||||
|
|
||||||
|
self.assertRegex(res.info[0], r'Swipe your left little finger across the fingerprint reader')
|
||||||
|
self.assertEqual(len(res.errors), 2)
|
||||||
|
self.assertRegex(res.errors[0], r'Failed to match fingerprint')
|
||||||
|
self.assertRegex(res.errors[1], r'Failed to match fingerprint')
|
||||||
|
|
||||||
|
def test_pam_fprintd_failed_auth(self):
|
||||||
|
self.setup_device()
|
||||||
|
script = [
|
||||||
|
( 'verify-no-match', True, 1 ),
|
||||||
|
( 'verify-no-match', True, 1 ),
|
||||||
|
( 'verify-no-match', True, 1 ),
|
||||||
|
]
|
||||||
|
self.device_mock.SetVerifyScript(script)
|
||||||
|
|
||||||
|
tc = pypamtest.TestCase(pypamtest.PAMTEST_AUTHENTICATE, expected_rv=PAM_MAXTRIES)
|
||||||
|
res = pypamtest.run_pamtest("toto", "fprintd-pam-test", [tc], [ 'unused' ])
|
||||||
|
|
||||||
|
self.assertRegex(res.info[0], r'Swipe your left little finger across the fingerprint reader')
|
||||||
|
self.assertEqual(len(res.errors), 3)
|
||||||
|
self.assertRegex(res.errors[0], r'Failed to match fingerprint')
|
||||||
|
self.assertRegex(res.errors[1], r'Failed to match fingerprint')
|
||||||
|
self.assertRegex(res.errors[2], r'Failed to match fingerprint')
|
||||||
|
|
||||||
|
def test_pam_already_claimed(self):
|
||||||
|
self.setup_device()
|
||||||
|
script = [
|
||||||
|
( 'verify-match', True, 2 )
|
||||||
|
]
|
||||||
|
self.device_mock.SetVerifyScript(script)
|
||||||
|
self.device_mock.SetClaimed('toto')
|
||||||
|
|
||||||
|
tc = pypamtest.TestCase(pypamtest.PAMTEST_AUTHENTICATE, expected_rv=PAM_AUTHINFO_UNAVAIL)
|
||||||
|
res = pypamtest.run_pamtest("toto", "fprintd-pam-test", [tc], [ 'unused' ])
|
||||||
|
|
||||||
|
self.assertEqual(len(res.info), 0)
|
||||||
|
self.assertEqual(len(res.errors), 0)
|
||||||
|
|
||||||
|
def test_pam_timeout(self):
|
||||||
|
self.setup_device()
|
||||||
|
|
||||||
|
tc = pypamtest.TestCase(pypamtest.PAMTEST_AUTHENTICATE, expected_rv=PAM_AUTHINFO_UNAVAIL)
|
||||||
|
res = pypamtest.run_pamtest("toto", "fprintd-pam-test", [tc], [ 'unused' ])
|
||||||
|
self.assertRegex(res.info[1], r'Verification timed out')
|
||||||
|
|
||||||
|
def test_pam_notices_fprintd_disappearing(self):
|
||||||
|
self.setup_device()
|
||||||
|
|
||||||
|
script = [
|
||||||
|
( 'MOCK: quit', True, 0 ),
|
||||||
|
]
|
||||||
|
self.device_mock.SetVerifyScript(script)
|
||||||
|
|
||||||
|
tc = pypamtest.TestCase(pypamtest.PAMTEST_AUTHENTICATE, expected_rv=PAM_AUTHINFO_UNAVAIL)
|
||||||
|
res = pypamtest.run_pamtest("toto", "fprintd-pam-test", [tc], [ 'unused' ])
|
||||||
|
self.assertEqual(len(res.errors), 0)
|
||||||
|
self.assertEqual(len(res.info), 0)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
if 'PAM_WRAPPER_SERVICE_DIR' not in os.environ:
|
||||||
|
print('Cannot run test without environment set correctly, run "meson test" instead')
|
||||||
|
sys.exit(1)
|
||||||
|
# set stream to sys.stderr to get debug output
|
||||||
|
unittest.main(testRunner=unittest.TextTestRunner(stream=sys.stdout, verbosity=2))
|
||||||
3
tests/prints/README
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
These are example images from NIST and are in the public domain.
|
||||||
|
|
||||||
|
The PNG files have been generated by using the greyscale data as a mask.
|
||||||
BIN
tests/prints/arch.jpg
Normal file
|
After Width: | Height: | Size: 18 KiB |
BIN
tests/prints/arch.png
Normal file
|
After Width: | Height: | Size: 120 KiB |
BIN
tests/prints/loop-right.jpg
Normal file
|
After Width: | Height: | Size: 18 KiB |
BIN
tests/prints/loop-right.png
Normal file
|
After Width: | Height: | Size: 120 KiB |
BIN
tests/prints/tented_arch.jpg
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
tests/prints/tented_arch.png
Normal file
|
After Width: | Height: | Size: 107 KiB |
BIN
tests/prints/whorl.jpg
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
tests/prints/whorl.png
Normal file
|
After Width: | Height: | Size: 102 KiB |
302
tests/test_fprintd_utils.py
Executable file
@ -0,0 +1,302 @@
|
|||||||
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU Lesser General Public License as published by the Free
|
||||||
|
# Software Foundation; either version 3 of the License, or (at your option) any
|
||||||
|
# later version. See http://www.gnu.org/copyleft/lgpl.html for the full text
|
||||||
|
# of the license.
|
||||||
|
|
||||||
|
__author__ = 'Bastien Nocera'
|
||||||
|
__email__ = 'hadess@hadess.net'
|
||||||
|
__copyright__ = '(c) 2020 Red Hat Inc.'
|
||||||
|
__license__ = 'LGPL 3+'
|
||||||
|
|
||||||
|
import tempfile
|
||||||
|
import unittest
|
||||||
|
import sys
|
||||||
|
import subprocess
|
||||||
|
import dbus
|
||||||
|
import dbus.mainloop.glib
|
||||||
|
import dbusmock
|
||||||
|
import os
|
||||||
|
import time
|
||||||
|
from output_checker import OutputChecker
|
||||||
|
|
||||||
|
|
||||||
|
VALID_FINGER_NAMES = [
|
||||||
|
'left-thumb',
|
||||||
|
'left-index-finger',
|
||||||
|
'left-middle-finger',
|
||||||
|
'left-ring-finger',
|
||||||
|
'left-little-finger',
|
||||||
|
'right-thumb',
|
||||||
|
'right-index-finger',
|
||||||
|
'right-middle-finger',
|
||||||
|
'right-ring-finger',
|
||||||
|
'right-little-finger'
|
||||||
|
]
|
||||||
|
|
||||||
|
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
|
||||||
|
|
||||||
|
class TestFprintdUtilsBase(dbusmock.DBusTestCase):
|
||||||
|
'''Test fprintd utilities'''
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def setUpClass(klass):
|
||||||
|
klass.start_system_bus()
|
||||||
|
klass.dbus_con = klass.get_dbus(True)
|
||||||
|
klass.sleep_time = 0.5
|
||||||
|
|
||||||
|
template_path = './'
|
||||||
|
if 'TOPSRCDIR' in os.environ:
|
||||||
|
template_path = os.environ['TOPSRCDIR'] + '/tests/'
|
||||||
|
klass.template_name = template_path + 'dbusmock/fprintd.py'
|
||||||
|
print ('Using template from %s' % klass.template_name)
|
||||||
|
|
||||||
|
klass.tools_prefix = ''
|
||||||
|
if 'FPRINT_BUILD_DIR' in os.environ:
|
||||||
|
klass.tools_prefix = os.environ['FPRINT_BUILD_DIR'] + '/../utils/'
|
||||||
|
print ('Using tools from %s' % klass.tools_prefix)
|
||||||
|
else:
|
||||||
|
print ('Using tools from $PATH')
|
||||||
|
|
||||||
|
klass.wrapper_args = []
|
||||||
|
klass.valgrind = False
|
||||||
|
if 'VALGRIND' in os.environ:
|
||||||
|
valgrind = os.environ['VALGRIND']
|
||||||
|
if valgrind is not None:
|
||||||
|
klass.valgrind = True
|
||||||
|
klass.sleep_time *= 4
|
||||||
|
klass.wrapper_args = ['valgrind', '--leak-check=full']
|
||||||
|
if os.path.exists(valgrind):
|
||||||
|
klass.wrapper_args += ['--suppressions={}'.format(valgrind)]
|
||||||
|
|
||||||
|
if 'ADDRESS_SANITIZER' in os.environ:
|
||||||
|
klass.sleep_time *= 2
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super().setUp()
|
||||||
|
(self.p_mock, self.obj_fprintd_manager) = self.spawn_server_template(
|
||||||
|
self.template_name, {})
|
||||||
|
# set log to nonblocking
|
||||||
|
self.obj_fprintd_mock = dbus.Interface(self.obj_fprintd_manager, 'net.reactivated.Fprint.Manager.Mock')
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
self.p_mock.terminate()
|
||||||
|
self.p_mock.wait()
|
||||||
|
super().tearDown()
|
||||||
|
|
||||||
|
def setup_device(self):
|
||||||
|
self.device_path = self.obj_fprintd_mock.AddDevice(
|
||||||
|
'FDO Trigger Finger Laser Reader', 3, 'swipe')
|
||||||
|
self.device_mock = self.dbus_con.get_object('net.reactivated.Fprint',
|
||||||
|
self.device_path)
|
||||||
|
self.set_enrolled_fingers(['left-little-finger', 'right-little-finger'])
|
||||||
|
|
||||||
|
def set_enrolled_fingers(self, fingers, user='toto'):
|
||||||
|
self.enrolled_fingers = fingers
|
||||||
|
self.device_mock.SetEnrolledFingers('toto', self.enrolled_fingers,
|
||||||
|
signature='sas')
|
||||||
|
|
||||||
|
def start_utility_process(self, utility_name, args=[], sleep=True):
|
||||||
|
utility = [ os.path.join(self.tools_prefix, 'fprintd-{}'.format(utility_name)) ]
|
||||||
|
output = OutputChecker()
|
||||||
|
process = subprocess.Popen(self.wrapper_args + utility + args,
|
||||||
|
stdout=output.fd,
|
||||||
|
stderr=subprocess.STDOUT)
|
||||||
|
output.writer_attached()
|
||||||
|
|
||||||
|
self.addCleanup(output.assert_closed)
|
||||||
|
self.addCleanup(self.try_stop_utility_process, process)
|
||||||
|
|
||||||
|
if sleep:
|
||||||
|
time.sleep(self.sleep_time)
|
||||||
|
|
||||||
|
return process, output
|
||||||
|
|
||||||
|
def stop_utility_process(self, process):
|
||||||
|
process.terminate()
|
||||||
|
process.wait()
|
||||||
|
|
||||||
|
def try_stop_utility_process(self, process):
|
||||||
|
try:
|
||||||
|
self.stop_utility_process(process)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
def run_utility_process(self, utility_name, args=[], sleep=True, timeout=None):
|
||||||
|
proc, output = self.start_utility_process(utility_name, args=args, sleep=sleep)
|
||||||
|
ret = proc.wait(timeout=timeout if timeout is not None else self.sleep_time * 4)
|
||||||
|
self.assertLessEqual(ret, 128)
|
||||||
|
|
||||||
|
return b''.join(output.clear()), ret
|
||||||
|
|
||||||
|
|
||||||
|
class TestFprintdUtils(TestFprintdUtilsBase):
|
||||||
|
def setUp(self):
|
||||||
|
super().setUp()
|
||||||
|
self.setup_device()
|
||||||
|
|
||||||
|
def test_fprintd_enroll(self):
|
||||||
|
process, out = self.start_utility_process('enroll', ['-f', 'right-index-finger', 'toto'])
|
||||||
|
|
||||||
|
out.check_line(rb'right-index-finger', 0)
|
||||||
|
|
||||||
|
self.device_mock.EmitEnrollStatus('enroll-completed', True)
|
||||||
|
|
||||||
|
out.check_line(rb'Enroll result: enroll-completed', self.sleep_time)
|
||||||
|
|
||||||
|
def test_fprintd_list(self):
|
||||||
|
# Rick has no fingerprints enrolled
|
||||||
|
out, ret = self.run_utility_process('list', ['rick'])
|
||||||
|
self.assertRegex(out, rb'has no fingers enrolled for')
|
||||||
|
self.assertEqual(ret, 0)
|
||||||
|
|
||||||
|
# Toto does
|
||||||
|
out, ret = self.run_utility_process('list', ['toto'])
|
||||||
|
self.assertRegex(out, rb'right-little-finger')
|
||||||
|
self.assertEqual(ret, 0)
|
||||||
|
|
||||||
|
def test_fprintd_delete(self):
|
||||||
|
# Has fingerprints enrolled
|
||||||
|
out, ret = self.run_utility_process('list', ['toto'])
|
||||||
|
self.assertRegex(out, rb'left-little-finger')
|
||||||
|
self.assertEqual(ret, 0)
|
||||||
|
self.assertRegex(out, rb'right-little-finger')
|
||||||
|
|
||||||
|
# Delete fingerprints
|
||||||
|
out, ret = self.run_utility_process('delete', ['toto'])
|
||||||
|
self.assertRegex(out, rb'Fingerprints deleted')
|
||||||
|
self.assertEqual(ret, 0)
|
||||||
|
|
||||||
|
# Doesn't have fingerprints
|
||||||
|
out, ret = self.run_utility_process('list', ['toto'])
|
||||||
|
self.assertRegex(out, rb'has no fingers enrolled for')
|
||||||
|
self.assertEqual(ret, 0)
|
||||||
|
|
||||||
|
|
||||||
|
class TestFprintdUtilsNoDeviceTests(TestFprintdUtilsBase):
|
||||||
|
def test_fprintd_enroll(self):
|
||||||
|
out, ret = self.run_utility_process('enroll', ['toto'])
|
||||||
|
self.assertIn(b'No devices available', out)
|
||||||
|
self.assertEqual(ret, 1)
|
||||||
|
|
||||||
|
def test_fprintd_list(self):
|
||||||
|
out, ret = self.run_utility_process('list', ['toto'])
|
||||||
|
self.assertIn(b'No devices available', out)
|
||||||
|
self.assertEqual(ret, 1)
|
||||||
|
|
||||||
|
def test_fprintd_delete(self):
|
||||||
|
out, ret = self.run_utility_process('delete', ['toto'])
|
||||||
|
self.assertIn(b'No devices available', out)
|
||||||
|
self.assertEqual(ret, 1)
|
||||||
|
|
||||||
|
def test_fprintd_verify(self):
|
||||||
|
out, ret = self.run_utility_process('verify', ['toto'])
|
||||||
|
self.assertIn(b'No devices available', out)
|
||||||
|
self.assertEqual(ret, 1)
|
||||||
|
|
||||||
|
|
||||||
|
class TestFprintdUtilsVerify(TestFprintdUtilsBase):
|
||||||
|
def setUp(self):
|
||||||
|
super().setUp()
|
||||||
|
self.setup_device()
|
||||||
|
|
||||||
|
def start_verify_process(self, user='toto', finger=None, nowait=False):
|
||||||
|
args = [user]
|
||||||
|
if finger:
|
||||||
|
args += ['-f', finger]
|
||||||
|
|
||||||
|
self.process, self.output = self.start_utility_process('verify', args)
|
||||||
|
if nowait:
|
||||||
|
return
|
||||||
|
|
||||||
|
preamble = self.output.check_line(b'Verify started!')
|
||||||
|
|
||||||
|
out = b''.join(preamble)
|
||||||
|
|
||||||
|
self.assertNotIn(b'Verify result:', out)
|
||||||
|
|
||||||
|
if finger:
|
||||||
|
expected_finger = finger
|
||||||
|
if finger == 'any' and not self.device_mock.HasIdentification():
|
||||||
|
expected_finger = self.enrolled_fingers[0]
|
||||||
|
self.assertEqual(self.device_mock.GetSelectedFinger(), expected_finger)
|
||||||
|
|
||||||
|
def assertVerifyMatch(self, match):
|
||||||
|
self.output.check_line(r'Verify result: {} (done)'.format(
|
||||||
|
'verify-match' if match else 'verify-no-match'))
|
||||||
|
|
||||||
|
def test_fprintd_verify(self):
|
||||||
|
self.start_verify_process()
|
||||||
|
|
||||||
|
self.device_mock.EmitVerifyStatus('verify-match', True)
|
||||||
|
time.sleep(self.sleep_time)
|
||||||
|
self.assertVerifyMatch(True)
|
||||||
|
|
||||||
|
def test_fprintd_verify_enrolled_fingers(self):
|
||||||
|
for finger in self.enrolled_fingers:
|
||||||
|
self.start_verify_process(finger=finger)
|
||||||
|
|
||||||
|
self.device_mock.EmitVerifyStatus('verify-match', True)
|
||||||
|
time.sleep(self.sleep_time)
|
||||||
|
self.assertVerifyMatch(True)
|
||||||
|
|
||||||
|
def test_fprintd_verify_any_finger_no_identification(self):
|
||||||
|
self.start_verify_process(finger='any')
|
||||||
|
|
||||||
|
self.device_mock.EmitVerifyStatus('verify-match', True)
|
||||||
|
time.sleep(self.sleep_time)
|
||||||
|
self.assertVerifyMatch(True)
|
||||||
|
|
||||||
|
def test_fprintd_verify_any_finger_identification(self):
|
||||||
|
self.obj_fprintd_mock.RemoveDevice(self.device_path)
|
||||||
|
self.device_path = self.obj_fprintd_mock.AddDevice('Full powered device',
|
||||||
|
3, 'press', True)
|
||||||
|
self.device_mock = self.dbus_con.get_object('net.reactivated.Fprint',
|
||||||
|
self.device_path)
|
||||||
|
self.set_enrolled_fingers(VALID_FINGER_NAMES)
|
||||||
|
self.start_verify_process(finger='any')
|
||||||
|
|
||||||
|
self.device_mock.EmitVerifyStatus('verify-match', True)
|
||||||
|
time.sleep(self.sleep_time)
|
||||||
|
self.assertVerifyMatch(True)
|
||||||
|
|
||||||
|
def test_fprintd_verify_not_enrolled_fingers(self):
|
||||||
|
for finger in [f for f in VALID_FINGER_NAMES if f not in self.enrolled_fingers]:
|
||||||
|
self.start_verify_process(finger=finger, nowait=True)
|
||||||
|
regex = r'Finger \'{}\' not enrolled'.format(finger)
|
||||||
|
self.output.check_line_re(regex, timeout=self.sleep_time)
|
||||||
|
|
||||||
|
self.device_mock.Release()
|
||||||
|
|
||||||
|
def test_fprintd_verify_no_enrolled_fingers(self):
|
||||||
|
self.set_enrolled_fingers([])
|
||||||
|
self.start_verify_process(nowait=True)
|
||||||
|
self.output.check_line(b'No fingers enrolled for this device.', timeout=self.sleep_time)
|
||||||
|
self.assertEqual(self.process.poll(), 1)
|
||||||
|
|
||||||
|
def test_fprintd_list_all_fingers(self):
|
||||||
|
self.set_enrolled_fingers(VALID_FINGER_NAMES)
|
||||||
|
self.start_verify_process()
|
||||||
|
|
||||||
|
def test_fprintd_verify_script(self):
|
||||||
|
script = [
|
||||||
|
( 'verify-match', True, 2 )
|
||||||
|
]
|
||||||
|
self.device_mock.SetVerifyScript(script)
|
||||||
|
time.sleep(2)
|
||||||
|
|
||||||
|
self.start_verify_process()
|
||||||
|
time.sleep(2 + self.sleep_time)
|
||||||
|
self.assertVerifyMatch(True)
|
||||||
|
|
||||||
|
def test_fprintd_multiple_verify_fails(self):
|
||||||
|
self.start_verify_process()
|
||||||
|
|
||||||
|
self.start_verify_process(nowait=True)
|
||||||
|
self.output.check_line_re(rb'Device already in use by [A-z]+', timeout=self.sleep_time)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
# avoid writing to stderr
|
||||||
|
unittest.main(testRunner=unittest.TextTestRunner(stream=sys.stdout, verbosity=2))
|
||||||
46
tests/unittest_inspector.py
Executable file
@ -0,0 +1,46 @@
|
|||||||
|
#! /usr/bin/env python3
|
||||||
|
# Copyright © 2020, Canonical Ltd
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU Lesser General Public
|
||||||
|
# License as published by the Free Software Foundation; either
|
||||||
|
# version 2.1 of the License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
# Lesser General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Lesser General Public
|
||||||
|
# License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
# Authors:
|
||||||
|
# Marco Trevisan <marco.trevisan@canonical.com>
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import importlib.util
|
||||||
|
import inspect
|
||||||
|
import os
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
def list_tests(module):
|
||||||
|
tests = []
|
||||||
|
for name, obj in inspect.getmembers(module):
|
||||||
|
if inspect.isclass(obj) and issubclass(obj, unittest.TestCase):
|
||||||
|
cases = unittest.defaultTestLoader.getTestCaseNames(obj)
|
||||||
|
tests += [ (obj, '{}.{}'.format(name, t)) for t in cases ]
|
||||||
|
return tests
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument('unittest_source', type=argparse.FileType('r'))
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
source_path = args.unittest_source.name
|
||||||
|
spec = importlib.util.spec_from_file_location(
|
||||||
|
os.path.basename(source_path), source_path)
|
||||||
|
module = importlib.util.module_from_spec(spec)
|
||||||
|
spec.loader.exec_module(module)
|
||||||
|
|
||||||
|
for machine, human in list_tests(module):
|
||||||
|
print(human)
|
||||||
213
tests/verify.c
@ -1,213 +0,0 @@
|
|||||||
/*
|
|
||||||
* fprintd example to verify a fingerprint
|
|
||||||
* Copyright (C) 2008 Daniel Drake <dsd@gentoo.org>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along
|
|
||||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <dbus/dbus-glib-bindings.h>
|
|
||||||
#include "manager-dbus-glue.h"
|
|
||||||
#include "device-dbus-glue.h"
|
|
||||||
#include "marshal.h"
|
|
||||||
|
|
||||||
static DBusGProxy *manager = NULL;
|
|
||||||
static DBusGConnection *connection = NULL;
|
|
||||||
static char *finger_name = NULL;
|
|
||||||
static gboolean g_fatal_warnings = FALSE;
|
|
||||||
static char **usernames = NULL;
|
|
||||||
|
|
||||||
static void create_manager(void)
|
|
||||||
{
|
|
||||||
GError *error = NULL;
|
|
||||||
|
|
||||||
connection = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error);
|
|
||||||
if (connection == NULL) {
|
|
||||||
g_print("Failed to connect to session bus: %s\n", error->message);
|
|
||||||
exit (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
manager = dbus_g_proxy_new_for_name(connection,
|
|
||||||
"net.reactivated.Fprint", "/net/reactivated/Fprint/Manager",
|
|
||||||
"net.reactivated.Fprint.Manager");
|
|
||||||
}
|
|
||||||
|
|
||||||
static DBusGProxy *open_device(const char *username)
|
|
||||||
{
|
|
||||||
GError *error = NULL;
|
|
||||||
gchar *path;
|
|
||||||
DBusGProxy *dev;
|
|
||||||
|
|
||||||
if (!net_reactivated_Fprint_Manager_get_default_device(manager, &path, &error)) {
|
|
||||||
g_print("list_devices failed: %s\n", error->message);
|
|
||||||
exit (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (path == NULL) {
|
|
||||||
g_print("No devices found\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_print("Using device %s\n", path);
|
|
||||||
|
|
||||||
/* FIXME use for_name_owner?? */
|
|
||||||
dev = dbus_g_proxy_new_for_name(connection, "net.reactivated.Fprint",
|
|
||||||
path, "net.reactivated.Fprint.Device");
|
|
||||||
|
|
||||||
g_free (path);
|
|
||||||
|
|
||||||
if (!net_reactivated_Fprint_Device_claim(dev, username, &error)) {
|
|
||||||
g_print("failed to claim device: %s\n", error->message);
|
|
||||||
exit (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
return dev;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void find_finger(DBusGProxy *dev, const char *username)
|
|
||||||
{
|
|
||||||
GError *error = NULL;
|
|
||||||
char **fingers;
|
|
||||||
guint i;
|
|
||||||
|
|
||||||
if (!net_reactivated_Fprint_Device_list_enrolled_fingers(dev, username, &fingers, &error)) {
|
|
||||||
g_print("ListEnrolledFingers failed: %s\n", error->message);
|
|
||||||
exit (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fingers == NULL || g_strv_length (fingers) == 0) {
|
|
||||||
g_print("No fingers enrolled for this device.\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_print("Listing enrolled fingers:\n");
|
|
||||||
for (i = 0; fingers[i] != NULL; i++) {
|
|
||||||
g_print(" - #%d: %s\n", i, fingers[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (finger_name == NULL || strcmp (finger_name, "any") == 0) {
|
|
||||||
g_free (finger_name);
|
|
||||||
finger_name = g_strdup (fingers[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_strfreev (fingers);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void verify_result(GObject *object, const char *result, gboolean done, void *user_data)
|
|
||||||
{
|
|
||||||
gboolean *verify_completed = user_data;
|
|
||||||
g_print("Verify result: %s (%s)\n", result, done ? "done" : "not done");
|
|
||||||
if (done != FALSE)
|
|
||||||
*verify_completed = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void verify_finger_selected(GObject *object, const char *name, void *user_data)
|
|
||||||
{
|
|
||||||
g_print("Verifying: %s\n", name);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void do_verify(DBusGProxy *dev)
|
|
||||||
{
|
|
||||||
GError *error = NULL;
|
|
||||||
gboolean verify_completed = FALSE;
|
|
||||||
|
|
||||||
dbus_g_proxy_add_signal(dev, "VerifyStatus", G_TYPE_STRING, G_TYPE_BOOLEAN, NULL);
|
|
||||||
dbus_g_proxy_add_signal(dev, "VerifyFingerSelected", G_TYPE_INT, NULL);
|
|
||||||
dbus_g_proxy_connect_signal(dev, "VerifyStatus", G_CALLBACK(verify_result),
|
|
||||||
&verify_completed, NULL);
|
|
||||||
dbus_g_proxy_connect_signal(dev, "VerifyFingerSelected", G_CALLBACK(verify_finger_selected),
|
|
||||||
NULL, NULL);
|
|
||||||
|
|
||||||
if (!net_reactivated_Fprint_Device_verify_start(dev, finger_name, &error)) {
|
|
||||||
g_print("VerifyStart failed: %s\n", error->message);
|
|
||||||
exit (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
while (!verify_completed)
|
|
||||||
g_main_context_iteration(NULL, TRUE);
|
|
||||||
|
|
||||||
dbus_g_proxy_disconnect_signal(dev, "VerifyStatus", G_CALLBACK(verify_result), &verify_completed);
|
|
||||||
dbus_g_proxy_disconnect_signal(dev, "VerifyFingerSelected", G_CALLBACK(verify_finger_selected), NULL);
|
|
||||||
|
|
||||||
if (!net_reactivated_Fprint_Device_verify_stop(dev, &error)) {
|
|
||||||
g_print("VerifyStop failed: %s\n", error->message);
|
|
||||||
exit (1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void release_device(DBusGProxy *dev)
|
|
||||||
{
|
|
||||||
GError *error = NULL;
|
|
||||||
if (!net_reactivated_Fprint_Device_release(dev, &error)) {
|
|
||||||
g_print("ReleaseDevice failed: %s\n", error->message);
|
|
||||||
exit (1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static const GOptionEntry entries[] = {
|
|
||||||
{ "finger", 'f', 0, G_OPTION_ARG_STRING, &finger_name, "Finger selected to verify (default is automatic)", NULL },
|
|
||||||
{"g-fatal-warnings", 0, 0, G_OPTION_ARG_NONE, &g_fatal_warnings, "Make all warnings fatal", NULL},
|
|
||||||
{ G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_STRING_ARRAY, &usernames, NULL, "[username]" },
|
|
||||||
{ NULL }
|
|
||||||
};
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
GOptionContext *context;
|
|
||||||
GError *err = NULL;
|
|
||||||
DBusGProxy *dev;
|
|
||||||
char *username;
|
|
||||||
|
|
||||||
#if !GLIB_CHECK_VERSION (2, 36, 0)
|
|
||||||
g_type_init();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
dbus_g_object_register_marshaller (fprintd_marshal_VOID__STRING_BOOLEAN,
|
|
||||||
G_TYPE_NONE, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_INVALID);
|
|
||||||
|
|
||||||
context = g_option_context_new ("Verify a fingerprint");
|
|
||||||
g_option_context_add_main_entries (context, entries, NULL);
|
|
||||||
|
|
||||||
if (g_option_context_parse (context, &argc, &argv, &err) == FALSE) {
|
|
||||||
g_print ("couldn't parse command-line options: %s\n", err->message);
|
|
||||||
g_error_free (err);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (usernames == NULL) {
|
|
||||||
username = "";
|
|
||||||
} else {
|
|
||||||
username = usernames[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (g_fatal_warnings) {
|
|
||||||
GLogLevelFlags fatal_mask;
|
|
||||||
|
|
||||||
fatal_mask = g_log_set_always_fatal (G_LOG_FATAL_MASK);
|
|
||||||
fatal_mask |= G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL;
|
|
||||||
g_log_set_always_fatal (fatal_mask);
|
|
||||||
}
|
|
||||||
|
|
||||||
create_manager();
|
|
||||||
|
|
||||||
dev = open_device(username);
|
|
||||||
find_finger(dev, username);
|
|
||||||
do_verify(dev);
|
|
||||||
release_device(dev);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
9
update-transifex.sh
Executable file
@ -0,0 +1,9 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
test -f .tx/config || exit 1
|
||||||
|
|
||||||
|
echo Pulling translations from Transifex
|
||||||
|
tx --root `dirname $0` pull --all --force --skip
|
||||||
|
|
||||||
|
echo Pushing strings to Transifex
|
||||||
|
tx push --source
|
||||||
171
utils/delete.c
Normal file
@ -0,0 +1,171 @@
|
|||||||
|
/*
|
||||||
|
* fprintd example to delete fingerprints
|
||||||
|
* Copyright (C) 2008 Daniel Drake <dsd@gentoo.org>
|
||||||
|
* Copyright (C) 2020 Marco Trevisan <marco.trevisan@canonical.com>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <locale.h>
|
||||||
|
#include "fprintd-dbus.h"
|
||||||
|
|
||||||
|
static FprintDBusManager *manager = NULL;
|
||||||
|
static GDBusConnection *connection = NULL;
|
||||||
|
|
||||||
|
static void
|
||||||
|
create_manager (void)
|
||||||
|
{
|
||||||
|
g_autoptr(GError) error = NULL;
|
||||||
|
|
||||||
|
connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
|
||||||
|
if (connection == NULL)
|
||||||
|
{
|
||||||
|
g_print ("Failed to connect to session bus: %s\n", error->message);
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
manager = fprint_dbus_manager_proxy_new_sync (connection,
|
||||||
|
G_DBUS_PROXY_FLAGS_NONE,
|
||||||
|
"net.reactivated.Fprint",
|
||||||
|
"/net/reactivated/Fprint/Manager",
|
||||||
|
NULL, &error);
|
||||||
|
if (manager == NULL)
|
||||||
|
{
|
||||||
|
g_print ("Failed to get Fprintd manager: %s\n", error->message);
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
delete_fingerprints (FprintDBusDevice *dev, const char *username)
|
||||||
|
{
|
||||||
|
g_autoptr(GError) error = NULL;
|
||||||
|
|
||||||
|
if (!fprint_dbus_device_call_claim_sync (dev, username, NULL, &error))
|
||||||
|
{
|
||||||
|
g_print ("failed to claim device: %s\n", error->message);
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!fprint_dbus_device_call_delete_enrolled_fingers2_sync (dev, NULL,
|
||||||
|
&error))
|
||||||
|
{
|
||||||
|
gboolean ignore_error = FALSE;
|
||||||
|
if (g_dbus_error_is_remote_error (error))
|
||||||
|
{
|
||||||
|
g_autofree char *dbus_error =
|
||||||
|
g_dbus_error_get_remote_error (error);
|
||||||
|
if (g_str_equal (dbus_error,
|
||||||
|
"net.reactivated.Fprint.Error.NoEnrolledPrints"))
|
||||||
|
{
|
||||||
|
g_print ("No fingerprints to delete on %s\n",
|
||||||
|
fprint_dbus_device_get_name (dev));
|
||||||
|
ignore_error = TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!ignore_error)
|
||||||
|
{
|
||||||
|
g_print ("ListEnrolledFingers failed: %s\n",
|
||||||
|
error->message);
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g_print ("No fingerprints to delete on %s\n",
|
||||||
|
fprint_dbus_device_get_name (dev));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g_print ("Fingerprints deleted on %s\n",
|
||||||
|
fprint_dbus_device_get_name (dev));
|
||||||
|
}
|
||||||
|
g_clear_error (&error);
|
||||||
|
|
||||||
|
if (!fprint_dbus_device_call_release_sync (dev, NULL, &error))
|
||||||
|
{
|
||||||
|
g_print ("ReleaseDevice failed: %s\n", error->message);
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
process_devices (char **argv)
|
||||||
|
{
|
||||||
|
g_autoptr(GError) error = NULL;
|
||||||
|
g_auto(GStrv) devices = NULL;
|
||||||
|
char *path;
|
||||||
|
guint num_devices;
|
||||||
|
guint i;
|
||||||
|
|
||||||
|
if (!fprint_dbus_manager_call_get_devices_sync (manager, &devices,
|
||||||
|
NULL, &error))
|
||||||
|
{
|
||||||
|
g_print ("Impossible to get devices: %s\n", error->message);
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
num_devices = g_strv_length (devices);
|
||||||
|
if (num_devices == 0)
|
||||||
|
{
|
||||||
|
g_print ("No devices available\n");
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_print ("found %u devices\n", num_devices);
|
||||||
|
for (i = 0; devices[i] != NULL; i++)
|
||||||
|
{
|
||||||
|
path = devices[i];
|
||||||
|
g_print ("Device at %s\n", path);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; devices[i] != NULL; i++)
|
||||||
|
{
|
||||||
|
g_autoptr(FprintDBusDevice) dev = NULL;
|
||||||
|
guint j;
|
||||||
|
|
||||||
|
path = devices[i];
|
||||||
|
g_print ("Using device %s\n", path);
|
||||||
|
|
||||||
|
/* NOTE: We should handle error cases! */
|
||||||
|
dev = fprint_dbus_device_proxy_new_sync (connection,
|
||||||
|
G_DBUS_PROXY_FLAGS_NONE,
|
||||||
|
"net.reactivated.Fprint",
|
||||||
|
path, NULL, NULL);
|
||||||
|
|
||||||
|
for (j = 1; argv[j] != NULL; j++)
|
||||||
|
delete_fingerprints (dev, argv[j]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main (int argc, char **argv)
|
||||||
|
{
|
||||||
|
setlocale (LC_ALL, "");
|
||||||
|
|
||||||
|
create_manager ();
|
||||||
|
|
||||||
|
if (argc < 2)
|
||||||
|
{
|
||||||
|
g_print ("Usage: %s <username> [usernames...]\n", argv[0]);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
process_devices (argv);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
225
utils/enroll.c
Normal file
@ -0,0 +1,225 @@
|
|||||||
|
/*
|
||||||
|
* fprintd example to enroll right index finger
|
||||||
|
* Copyright (C) 2008 Daniel Drake <dsd@gentoo.org>
|
||||||
|
* Copyright (C) 2020 Marco Trevisan <marco.trevisan@canonical.com>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define _GNU_SOURCE
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <locale.h>
|
||||||
|
#include "fprintd-dbus.h"
|
||||||
|
|
||||||
|
#define N_(x) x
|
||||||
|
#define TR(x) x
|
||||||
|
#include "fingerprint-strings.h"
|
||||||
|
|
||||||
|
static FprintDBusManager *manager = NULL;
|
||||||
|
static GDBusConnection *connection = NULL;
|
||||||
|
static char *finger_name = NULL;
|
||||||
|
static char **usernames = NULL;
|
||||||
|
|
||||||
|
static void
|
||||||
|
create_manager (void)
|
||||||
|
{
|
||||||
|
g_autoptr(GError) error = NULL;
|
||||||
|
|
||||||
|
connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
|
||||||
|
if (connection == NULL)
|
||||||
|
{
|
||||||
|
g_print ("Failed to connect to session bus: %s\n", error->message);
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
manager = fprint_dbus_manager_proxy_new_sync (connection,
|
||||||
|
G_DBUS_PROXY_FLAGS_NONE,
|
||||||
|
"net.reactivated.Fprint",
|
||||||
|
"/net/reactivated/Fprint/Manager",
|
||||||
|
NULL, &error);
|
||||||
|
if (manager == NULL)
|
||||||
|
{
|
||||||
|
g_print ("Failed to get Fprintd manager: %s\n", error->message);
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static FprintDBusDevice *
|
||||||
|
open_device (const char *username)
|
||||||
|
{
|
||||||
|
g_autoptr(FprintDBusDevice) dev = NULL;
|
||||||
|
g_autoptr(GError) error = NULL;
|
||||||
|
g_autofree char *path = NULL;
|
||||||
|
|
||||||
|
if (!fprint_dbus_manager_call_get_default_device_sync (manager, &path,
|
||||||
|
NULL, &error))
|
||||||
|
{
|
||||||
|
g_print ("Impossible to enroll: %s\n", error->message);
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_print ("Using device %s\n", path);
|
||||||
|
|
||||||
|
dev = fprint_dbus_device_proxy_new_sync (connection,
|
||||||
|
G_DBUS_PROXY_FLAGS_NONE,
|
||||||
|
"net.reactivated.Fprint",
|
||||||
|
path, NULL, &error);
|
||||||
|
|
||||||
|
if (error)
|
||||||
|
{
|
||||||
|
g_print ("failed to connect to device: %s\n", error->message);
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!fprint_dbus_device_call_claim_sync (dev, username, NULL, &error))
|
||||||
|
{
|
||||||
|
g_print ("failed to claim device: %s\n", error->message);
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
return g_steal_pointer (&dev);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
enroll_result (GObject *object, const char *result, gboolean done, void *user_data)
|
||||||
|
{
|
||||||
|
gboolean *enroll_completed = user_data;
|
||||||
|
|
||||||
|
g_print ("Enroll result: %s\n", result);
|
||||||
|
if (done != FALSE)
|
||||||
|
*enroll_completed = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
proxy_signal_cb (GDBusProxy *proxy,
|
||||||
|
const gchar *sender_name,
|
||||||
|
const gchar *signal_name,
|
||||||
|
GVariant *parameters,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
if (g_str_equal (signal_name, "EnrollStatus"))
|
||||||
|
{
|
||||||
|
const gchar *result;
|
||||||
|
gboolean done;
|
||||||
|
|
||||||
|
g_variant_get (parameters, "(&sb)", &result, &done);
|
||||||
|
enroll_result (G_OBJECT (proxy), result, done, user_data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
do_enroll (FprintDBusDevice *dev)
|
||||||
|
{
|
||||||
|
g_autoptr(GError) error = NULL;
|
||||||
|
gboolean enroll_completed = FALSE;
|
||||||
|
gboolean found;
|
||||||
|
guint i;
|
||||||
|
|
||||||
|
g_signal_connect (dev, "g-signal", G_CALLBACK (proxy_signal_cb),
|
||||||
|
&enroll_completed);
|
||||||
|
|
||||||
|
found = FALSE;
|
||||||
|
for (i = 0; fingers[i].dbus_name != NULL; i++)
|
||||||
|
{
|
||||||
|
if (g_strcmp0 (fingers[i].dbus_name, finger_name) == 0)
|
||||||
|
{
|
||||||
|
found = TRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!found)
|
||||||
|
{
|
||||||
|
g_autoptr(GString) s = NULL;
|
||||||
|
|
||||||
|
s = g_string_new (NULL);
|
||||||
|
g_string_append_printf (s, "Invalid finger name '%s'. Name must be one of ", finger_name);
|
||||||
|
for (i = 0; fingers[i].dbus_name != NULL; i++)
|
||||||
|
{
|
||||||
|
g_string_append_printf (s, "%s", fingers[i].dbus_name);
|
||||||
|
if (fingers[i + 1].dbus_name != NULL)
|
||||||
|
g_string_append (s, ", ");
|
||||||
|
}
|
||||||
|
g_warning ("%s", s->str);
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_print ("Enrolling %s finger.\n", finger_name);
|
||||||
|
if (!fprint_dbus_device_call_enroll_start_sync (dev, finger_name, NULL,
|
||||||
|
&error))
|
||||||
|
{
|
||||||
|
g_print ("EnrollStart failed: %s\n", error->message);
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
while (!enroll_completed)
|
||||||
|
g_main_context_iteration (NULL, TRUE);
|
||||||
|
|
||||||
|
g_signal_handlers_disconnect_by_func (dev, proxy_signal_cb, &enroll_result);
|
||||||
|
|
||||||
|
if (!fprint_dbus_device_call_enroll_stop_sync (dev, NULL, &error))
|
||||||
|
{
|
||||||
|
g_print ("VerifyStop failed: %s\n", error->message);
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
release_device (FprintDBusDevice *dev)
|
||||||
|
{
|
||||||
|
g_autoptr(GError) error = NULL;
|
||||||
|
if (!fprint_dbus_device_call_release_sync (dev, NULL, &error))
|
||||||
|
{
|
||||||
|
g_print ("ReleaseDevice failed: %s\n", error->message);
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static const GOptionEntry entries[] = {
|
||||||
|
{ "finger", 'f', 0, G_OPTION_ARG_STRING, &finger_name, "Finger selected to verify (default is automatic)", NULL },
|
||||||
|
{ G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_STRING_ARRAY, &usernames, NULL, "[username]" },
|
||||||
|
{ NULL }
|
||||||
|
};
|
||||||
|
|
||||||
|
int
|
||||||
|
main (int argc, char **argv)
|
||||||
|
{
|
||||||
|
g_autoptr(FprintDBusDevice) dev = NULL;
|
||||||
|
GOptionContext *context;
|
||||||
|
|
||||||
|
g_autoptr(GError) err = NULL;
|
||||||
|
|
||||||
|
setlocale (LC_ALL, "");
|
||||||
|
|
||||||
|
context = g_option_context_new ("Enroll a fingerprint");
|
||||||
|
g_option_context_add_main_entries (context, entries, NULL);
|
||||||
|
|
||||||
|
if (g_option_context_parse (context, &argc, &argv, &err) == FALSE)
|
||||||
|
{
|
||||||
|
g_print ("couldn't parse command-line options: %s\n", err->message);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (finger_name == NULL)
|
||||||
|
finger_name = g_strdup ("right-index-finger");
|
||||||
|
|
||||||
|
create_manager ();
|
||||||
|
|
||||||
|
dev = open_device (usernames ? usernames[0] : "");
|
||||||
|
do_enroll (dev);
|
||||||
|
release_device (dev);
|
||||||
|
g_free (finger_name);
|
||||||
|
g_strfreev (usernames);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
162
utils/list.c
Normal file
@ -0,0 +1,162 @@
|
|||||||
|
/*
|
||||||
|
* fprintd example to list enrolled fingerprints
|
||||||
|
* Copyright (C) 2008 Daniel Drake <dsd@gentoo.org>
|
||||||
|
* Copyright (C) 2020 Marco Trevisan <marco.trevisan@canonical.com>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <locale.h>
|
||||||
|
#include "fprintd-dbus.h"
|
||||||
|
|
||||||
|
static FprintDBusManager *manager = NULL;
|
||||||
|
static GDBusConnection *connection = NULL;
|
||||||
|
|
||||||
|
static void
|
||||||
|
create_manager (void)
|
||||||
|
{
|
||||||
|
g_autoptr(GError) error = NULL;
|
||||||
|
|
||||||
|
connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
|
||||||
|
if (connection == NULL)
|
||||||
|
{
|
||||||
|
g_print ("Failed to connect to session bus: %s\n", error->message);
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
manager = fprint_dbus_manager_proxy_new_sync (connection,
|
||||||
|
G_DBUS_PROXY_FLAGS_NONE,
|
||||||
|
"net.reactivated.Fprint",
|
||||||
|
"/net/reactivated/Fprint/Manager",
|
||||||
|
NULL, &error);
|
||||||
|
if (manager == NULL)
|
||||||
|
{
|
||||||
|
g_print ("Failed to get Fprintd manager: %s\n", error->message);
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
list_fingerprints (FprintDBusDevice *dev, const char *username)
|
||||||
|
{
|
||||||
|
g_autoptr(GError) error = NULL;
|
||||||
|
g_auto(GStrv) fingers = NULL;
|
||||||
|
guint i;
|
||||||
|
|
||||||
|
if (!fprint_dbus_device_call_list_enrolled_fingers_sync (dev, username,
|
||||||
|
&fingers, NULL,
|
||||||
|
&error))
|
||||||
|
{
|
||||||
|
gboolean ignore_error = FALSE;
|
||||||
|
if (g_dbus_error_is_remote_error (error))
|
||||||
|
{
|
||||||
|
g_autofree char *dbus_error =
|
||||||
|
g_dbus_error_get_remote_error (error);
|
||||||
|
if (g_str_equal (dbus_error,
|
||||||
|
"net.reactivated.Fprint.Error.NoEnrolledPrints"))
|
||||||
|
ignore_error = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ignore_error)
|
||||||
|
{
|
||||||
|
g_print ("ListEnrolledFingers failed: %s\n", error->message);
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fingers == NULL || g_strv_length (fingers) == 0)
|
||||||
|
{
|
||||||
|
g_print ("User %s has no fingers enrolled for %s.\n", username,
|
||||||
|
fprint_dbus_device_get_name (dev));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_print ("Fingerprints for user %s on %s (%s):\n",
|
||||||
|
username,
|
||||||
|
fprint_dbus_device_get_name (dev),
|
||||||
|
fprint_dbus_device_get_scan_type (dev));
|
||||||
|
|
||||||
|
for (i = 0; fingers[i] != NULL; i++)
|
||||||
|
g_print (" - #%d: %s\n", i, fingers[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
process_devices (char **argv)
|
||||||
|
{
|
||||||
|
g_auto(GStrv) devices = NULL;
|
||||||
|
g_autoptr(GError) error = NULL;
|
||||||
|
char *path;
|
||||||
|
guint num_devices;
|
||||||
|
guint i;
|
||||||
|
|
||||||
|
if (!fprint_dbus_manager_call_get_devices_sync (manager, &devices, NULL,
|
||||||
|
&error))
|
||||||
|
{
|
||||||
|
g_print ("Impossible to get devices: %s\n", error->message);
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
num_devices = g_strv_length (devices);
|
||||||
|
if (num_devices == 0)
|
||||||
|
{
|
||||||
|
g_print ("No devices available\n");
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_print ("found %u devices\n", num_devices);
|
||||||
|
for (i = 0; devices[i] != NULL; i++)
|
||||||
|
{
|
||||||
|
path = devices[i];
|
||||||
|
g_print ("Device at %s\n", path);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; devices[i] != NULL; i++)
|
||||||
|
{
|
||||||
|
g_autoptr(FprintDBusDevice) dev = NULL;
|
||||||
|
guint j;
|
||||||
|
|
||||||
|
path = devices[i];
|
||||||
|
g_print ("Using device %s\n", path);
|
||||||
|
|
||||||
|
/* NOTE: We should handle error cases! */
|
||||||
|
dev = fprint_dbus_device_proxy_new_sync (connection,
|
||||||
|
G_DBUS_PROXY_FLAGS_NONE,
|
||||||
|
"net.reactivated.Fprint",
|
||||||
|
path, NULL, NULL);
|
||||||
|
|
||||||
|
for (j = 1; argv[j] != NULL; j++)
|
||||||
|
list_fingerprints (dev, argv[j]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main (int argc, char **argv)
|
||||||
|
{
|
||||||
|
setlocale (LC_ALL, "");
|
||||||
|
|
||||||
|
create_manager ();
|
||||||
|
|
||||||
|
if (argc < 2)
|
||||||
|
{
|
||||||
|
g_print ("Usage: %s <username> [usernames...]\n", argv[0]);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
process_devices (argv);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
34
utils/meson.build
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
libfprintd_utils_dep = declare_dependency(
|
||||||
|
include_directories: [
|
||||||
|
include_directories('../src'),
|
||||||
|
include_directories('../pam'),
|
||||||
|
],
|
||||||
|
dependencies: [
|
||||||
|
glib_dep,
|
||||||
|
gio_dep,
|
||||||
|
gio_unix_dep,
|
||||||
|
],
|
||||||
|
sources: [
|
||||||
|
fprintd_dbus_sources,
|
||||||
|
],
|
||||||
|
link_with: [
|
||||||
|
libfprintd_private
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
utils = [
|
||||||
|
'delete',
|
||||||
|
'enroll',
|
||||||
|
'list',
|
||||||
|
'verify',
|
||||||
|
]
|
||||||
|
|
||||||
|
fprintd_utils = []
|
||||||
|
|
||||||
|
foreach util: utils
|
||||||
|
fprintd_utils += executable('fprintd-' + util,
|
||||||
|
sources: util + '.c',
|
||||||
|
dependencies: libfprintd_utils_dep,
|
||||||
|
install: true,
|
||||||
|
)
|
||||||
|
endforeach
|
||||||
304
utils/verify.c
Normal file
@ -0,0 +1,304 @@
|
|||||||
|
/*
|
||||||
|
* fprintd example to verify a fingerprint
|
||||||
|
* Copyright (C) 2008 Daniel Drake <dsd@gentoo.org>
|
||||||
|
* Copyright (C) 2020 Marco Trevisan <marco.trevisan@canonical.com>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <locale.h>
|
||||||
|
#include <gio/gio.h>
|
||||||
|
#include "fprintd-dbus.h"
|
||||||
|
|
||||||
|
static FprintDBusManager *manager = NULL;
|
||||||
|
static GDBusConnection *connection = NULL;
|
||||||
|
static char *finger_name = NULL;
|
||||||
|
static gboolean g_fatal_warnings = FALSE;
|
||||||
|
static char **usernames = NULL;
|
||||||
|
|
||||||
|
static void
|
||||||
|
create_manager (void)
|
||||||
|
{
|
||||||
|
g_autoptr(GError) error = NULL;
|
||||||
|
|
||||||
|
connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
|
||||||
|
if (connection == NULL)
|
||||||
|
{
|
||||||
|
g_print ("Failed to connect to session bus: %s\n", error->message);
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
manager = fprint_dbus_manager_proxy_new_sync (connection,
|
||||||
|
G_DBUS_PROXY_FLAGS_NONE,
|
||||||
|
"net.reactivated.Fprint",
|
||||||
|
"/net/reactivated/Fprint/Manager",
|
||||||
|
NULL, &error);
|
||||||
|
if (manager == NULL)
|
||||||
|
{
|
||||||
|
g_print ("Failed to get Fprintd manager: %s\n", error->message);
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static FprintDBusDevice *
|
||||||
|
open_device (const char *username)
|
||||||
|
{
|
||||||
|
g_autoptr(FprintDBusDevice) dev = NULL;
|
||||||
|
g_autoptr(GError) error = NULL;
|
||||||
|
g_autofree char *path = NULL;
|
||||||
|
|
||||||
|
if (!fprint_dbus_manager_call_get_default_device_sync (manager, &path,
|
||||||
|
NULL, &error))
|
||||||
|
{
|
||||||
|
g_print ("Impossible to verify: %s\n", error->message);
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_print ("Using device %s\n", path);
|
||||||
|
|
||||||
|
dev = fprint_dbus_device_proxy_new_sync (connection,
|
||||||
|
G_DBUS_PROXY_FLAGS_NONE,
|
||||||
|
"net.reactivated.Fprint",
|
||||||
|
path, NULL, &error);
|
||||||
|
|
||||||
|
if (error)
|
||||||
|
{
|
||||||
|
g_print ("failed to connect to device: %s\n", error->message);
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!fprint_dbus_device_call_claim_sync (dev, username, NULL, &error))
|
||||||
|
{
|
||||||
|
g_print ("failed to claim device: %s\n", error->message);
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return g_steal_pointer (&dev);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
find_finger (FprintDBusDevice *dev, const char *username)
|
||||||
|
{
|
||||||
|
g_autoptr(GError) error = NULL;
|
||||||
|
g_auto(GStrv) fingers = NULL;
|
||||||
|
guint i;
|
||||||
|
|
||||||
|
if (!fprint_dbus_device_call_list_enrolled_fingers_sync (dev, username,
|
||||||
|
&fingers,
|
||||||
|
NULL, &error))
|
||||||
|
{
|
||||||
|
g_print ("ListEnrolledFingers failed: %s\n", error->message);
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fingers == NULL || g_strv_length (fingers) == 0)
|
||||||
|
{
|
||||||
|
g_print ("No fingers enrolled for this device.\n");
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_print ("Listing enrolled fingers:\n");
|
||||||
|
for (i = 0; fingers[i] != NULL; i++)
|
||||||
|
g_print (" - #%d: %s\n", i, fingers[i]);
|
||||||
|
|
||||||
|
if (finger_name && !g_str_equal (finger_name, "any") &&
|
||||||
|
!g_strv_contains ((const char **) fingers, finger_name))
|
||||||
|
{
|
||||||
|
g_print ("Finger '%s' not enrolled for user %s.\n", finger_name,
|
||||||
|
username);
|
||||||
|
g_free (finger_name);
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (finger_name == NULL)
|
||||||
|
finger_name = g_strdup (fingers[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct VerifyState
|
||||||
|
{
|
||||||
|
GError *error;
|
||||||
|
gboolean started;
|
||||||
|
gboolean completed;
|
||||||
|
};
|
||||||
|
|
||||||
|
static void
|
||||||
|
verify_result (GObject *object, const char *result, gboolean done, void *user_data)
|
||||||
|
{
|
||||||
|
struct VerifyState *verify_state = user_data;
|
||||||
|
|
||||||
|
g_print ("Verify result: %s (%s)\n", result, done ? "done" : "not done");
|
||||||
|
if (done != FALSE)
|
||||||
|
verify_state->completed = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
verify_finger_selected (GObject *object, const char *name, void *user_data)
|
||||||
|
{
|
||||||
|
g_print ("Verifying: %s\n", name);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
verify_started_cb (GObject *obj,
|
||||||
|
GAsyncResult *res,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
struct VerifyState *verify_state = user_data;
|
||||||
|
|
||||||
|
if (fprint_dbus_device_call_verify_start_finish (FPRINT_DBUS_DEVICE (obj), res, &verify_state->error))
|
||||||
|
verify_state->started = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
proxy_signal_cb (GDBusProxy *proxy,
|
||||||
|
const gchar *sender_name,
|
||||||
|
const gchar *signal_name,
|
||||||
|
GVariant *parameters,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
struct VerifyState *verify_state = user_data;
|
||||||
|
|
||||||
|
if (!verify_state->started)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (g_str_equal (signal_name, "VerifyStatus"))
|
||||||
|
{
|
||||||
|
const gchar *result;
|
||||||
|
gboolean done;
|
||||||
|
|
||||||
|
g_variant_get (parameters, "(&sb)", &result, &done);
|
||||||
|
verify_result (G_OBJECT (proxy), result, done, user_data);
|
||||||
|
}
|
||||||
|
else if (g_str_equal (signal_name, "VerifyFingerSelected"))
|
||||||
|
{
|
||||||
|
const gchar *name;
|
||||||
|
|
||||||
|
g_variant_get (parameters, "(&s)", &name);
|
||||||
|
verify_finger_selected (G_OBJECT (proxy), name, user_data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
do_verify (FprintDBusDevice *dev)
|
||||||
|
{
|
||||||
|
g_autoptr(GError) error = NULL;
|
||||||
|
struct VerifyState verify_state = { 0 };
|
||||||
|
|
||||||
|
/* This one is funny. We connect to the signal immediately to avoid
|
||||||
|
* race conditions. However, we must ignore any authentication results
|
||||||
|
* that happen before our start call returns.
|
||||||
|
* This is because the verify call itself may internally try to verify
|
||||||
|
* against fprintd (possibly using a separate account).
|
||||||
|
*
|
||||||
|
* To do so, we *must* use the async version of the verify call, as the
|
||||||
|
* sync version would cause the signals to be queued and only processed
|
||||||
|
* after it returns.
|
||||||
|
*/
|
||||||
|
|
||||||
|
g_signal_connect (dev, "g-signal", G_CALLBACK (proxy_signal_cb),
|
||||||
|
&verify_state);
|
||||||
|
|
||||||
|
fprint_dbus_device_call_verify_start (dev, finger_name, NULL,
|
||||||
|
verify_started_cb,
|
||||||
|
&verify_state);
|
||||||
|
|
||||||
|
/* Wait for verify start while discarding any VerifyStatus signals */
|
||||||
|
while (!verify_state.started && !verify_state.error)
|
||||||
|
g_main_context_iteration (NULL, TRUE);
|
||||||
|
|
||||||
|
if (verify_state.error)
|
||||||
|
{
|
||||||
|
g_print ("VerifyStart failed: %s\n", verify_state.error->message);
|
||||||
|
g_clear_error (&verify_state.error);
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
g_print ("Verify started!\n");
|
||||||
|
|
||||||
|
/* VerifyStatus signals are processing, wait for completion. */
|
||||||
|
while (!verify_state.completed)
|
||||||
|
g_main_context_iteration (NULL, TRUE);
|
||||||
|
|
||||||
|
|
||||||
|
g_signal_handlers_disconnect_by_func (dev, proxy_signal_cb,
|
||||||
|
&verify_state);
|
||||||
|
|
||||||
|
if (!fprint_dbus_device_call_verify_stop_sync (dev, NULL, &error))
|
||||||
|
{
|
||||||
|
g_print ("VerifyStop failed: %s\n", error->message);
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
release_device (FprintDBusDevice *dev)
|
||||||
|
{
|
||||||
|
g_autoptr(GError) error = NULL;
|
||||||
|
if (!fprint_dbus_device_call_release_sync (dev, NULL, &error))
|
||||||
|
{
|
||||||
|
g_print ("ReleaseDevice failed: %s\n", error->message);
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static const GOptionEntry entries[] = {
|
||||||
|
{ "finger", 'f', 0, G_OPTION_ARG_STRING, &finger_name, "Finger selected to verify (default is automatic)", NULL },
|
||||||
|
{"g-fatal-warnings", 0, 0, G_OPTION_ARG_NONE, &g_fatal_warnings, "Make all warnings fatal", NULL},
|
||||||
|
{ G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_STRING_ARRAY, &usernames, NULL, "[username]" },
|
||||||
|
{ NULL }
|
||||||
|
};
|
||||||
|
|
||||||
|
int
|
||||||
|
main (int argc, char **argv)
|
||||||
|
{
|
||||||
|
g_autoptr(FprintDBusDevice) dev = NULL;
|
||||||
|
g_autoptr(GError) err = NULL;
|
||||||
|
GOptionContext *context;
|
||||||
|
const char *username = NULL;
|
||||||
|
|
||||||
|
setlocale (LC_ALL, "");
|
||||||
|
|
||||||
|
context = g_option_context_new ("Verify a fingerprint");
|
||||||
|
g_option_context_add_main_entries (context, entries, NULL);
|
||||||
|
|
||||||
|
if (g_option_context_parse (context, &argc, &argv, &err) == FALSE)
|
||||||
|
{
|
||||||
|
g_print ("couldn't parse command-line options: %s\n", err->message);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (usernames == NULL)
|
||||||
|
username = "";
|
||||||
|
else
|
||||||
|
username = usernames[0];
|
||||||
|
|
||||||
|
if (g_fatal_warnings)
|
||||||
|
{
|
||||||
|
GLogLevelFlags fatal_mask;
|
||||||
|
|
||||||
|
fatal_mask = g_log_set_always_fatal (G_LOG_FATAL_MASK);
|
||||||
|
fatal_mask |= G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL;
|
||||||
|
g_log_set_always_fatal (fatal_mask);
|
||||||
|
}
|
||||||
|
|
||||||
|
create_manager ();
|
||||||
|
|
||||||
|
dev = open_device (username);
|
||||||
|
find_finger (dev, username);
|
||||||
|
do_verify (dev);
|
||||||
|
release_device (dev);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||