usbauth-notifier/0000755000175200017530000000000014003045132015047 5ustar moonape1226moonape1226usbauth-notifier/usbauth-notifier.changelog0000644000175200017530000000020713425571254022227 0ustar moonape1226moonape1226* Sat Jan 12 2019 stefan.koch10@gmail.com - 1.0-1 - initial notifier package to use with desktop environments for usbauth USB Firewall usbauth-notifier/INSTALL0000644000175200017530000000033613425571267016126 0ustar moonape1226moonape1226To compile and install run: ./autogen.sh ./configure make make install Alternatively you can build a RPM or DEB package. To generate the .spec file that is necessary to build a RPM package call: ./autogen.sh ./configure usbauth-notifier/po/0000755000175200017530000000000013552627002015477 5ustar moonape1226moonape1226usbauth-notifier/po/de.po0000644000175200017530000000532013552627002016427 0ustar moonape1226moonape1226# usbauth-notifier language template # Copyright (C) 2015 SUSE LLC. All Rights Reserved. # This file is distributed under the same license as the usbauth-notifier package. # Stefan Koch , 2015. # msgid "" msgstr "" "Project-Id-Version: usbauth-notifier 1.0.2\n" "Report-Msgid-Bugs-To: stefan.koch10@gmail.com\n" "POT-Creation-Date: 2017-09-22 00:23+0200\n" "PO-Revision-Date: 2015-05-20 19:21+0200\n" "Last-Translator: Stefan Koch \n" "Language-Team: German\n" "Language: de\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=ASCII\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #: src/usbauth-notifier.c:58 msgid "Per Interface" msgstr "Interfacespezifisch" #: src/usbauth-notifier.c:62 msgid "Audio" msgstr "Audio" #: src/usbauth-notifier.c:66 msgid "Communication" msgstr "Kommunikation" #: src/usbauth-notifier.c:70 msgid "HID" msgstr "HID" #: src/usbauth-notifier.c:73 msgid "Keyboard" msgstr "Tastatur" #: src/usbauth-notifier.c:77 msgid "Mouse" msgstr "Maus" #: src/usbauth-notifier.c:82 msgid "Physical" msgstr "Physikal" #: src/usbauth-notifier.c:86 msgid "Image" msgstr "Bilder" #: src/usbauth-notifier.c:90 msgid "Printer" msgstr "Drucker" #: src/usbauth-notifier.c:94 msgid "Mass Storage" msgstr "Massenspeicher" #: src/usbauth-notifier.c:98 msgid "Hub" msgstr "Hub" #: src/usbauth-notifier.c:102 msgid "CDC data" msgstr "CDC Daten" #: src/usbauth-notifier.c:106 msgid "Smart Card" msgstr "Smartcard" #: src/usbauth-notifier.c:110 msgid "Content Security" msgstr "Inhaltssicherheit" #: src/usbauth-notifier.c:114 msgid "Video" msgstr "Video" #: src/usbauth-notifier.c:118 msgid "Personal Healthcare" msgstr "Gesundheit" #: src/usbauth-notifier.c:122 msgid "AV" msgstr "AV" #: src/usbauth-notifier.c:126 msgid "Billboard" msgstr "Billboard" #: src/usbauth-notifier.c:130 msgid "Diagnostic Device" msgstr "Diagnose" #: src/usbauth-notifier.c:134 msgid "Wireless Controller" msgstr "Funkcontroller" #: src/usbauth-notifier.c:138 msgid "Miscellaneous" msgstr "Verschiedenes" #: src/usbauth-notifier.c:142 msgid "Application Specific" msgstr "Anwendungsspezifisch" #: src/usbauth-notifier.c:146 msgid "Vendor Specific" msgstr "Herstellerspezifisch" #: src/usbauth-notifier.c:150 msgid "Unknown" msgstr "Unbekannt" #: src/usbauth-notifier.c:293 msgid "New USB interface" msgstr "Neues USB Interface" #: src/usbauth-notifier.c:305 msgid "Default" msgstr "Standard" #: src/usbauth-notifier.c:305 src/usbauth-notifier.c:311 msgid "Allow" msgstr "Erlauben" #: src/usbauth-notifier.c:305 src/usbauth-notifier.c:312 msgid "Deny" msgstr "Ablehnen" #: src/usbauth-notifier.c:305 msgid "Type" msgstr "Typ" #: src/usbauth-notifier.c:305 msgid "Name" msgstr "Name" usbauth-notifier/po/POTFILES.in0000644000175200017530000000012313425571263017256 0ustar moonape1226moonape1226# List of source files which contain translatable strings. src/usbauth-notifier.c usbauth-notifier/po/usbauth-notifier.pot0000644000175200017530000000460413552627002021517 0ustar moonape1226moonape1226# usbauth_notifier language template # Copyright (C) 2015 SUSE LLC. All Rights Reserved. # This file is distributed under the same license as the usbauth-notifier package. # Stefan Koch , 2015. # #, fuzzy msgid "" msgstr "" "Project-Id-Version: usbauth-notifier 1.0.2\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2015-05-20 19:20+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: Stefan Koch \n" "Language-Team: LANGUAGE \n" "Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" #: src/usbauth-notifier.c:56 msgid "Per Interface" msgstr "" #: src/usbauth-notifier.c:60 msgid "Audio" msgstr "" #: src/usbauth-notifier.c:64 msgid "Communication" msgstr "" #: src/usbauth-notifier.c:68 msgid "HID" msgstr "" #: src/usbauth-notifier.c:71 msgid "Keyboard" msgstr "" #: src/usbauth-notifier.c:75 msgid "Mouse" msgstr "" #: src/usbauth-notifier.c:80 msgid "Physical" msgstr "" #: src/usbauth-notifier.c:84 msgid "Image" msgstr "" #: src/usbauth-notifier.c:88 msgid "Printer" msgstr "" #: src/usbauth-notifier.c:92 msgid "Mass Storage" msgstr "" #: src/usbauth-notifier.c:96 msgid "Hub" msgstr "" #: src/usbauth-notifier.c:100 msgid "CDC data" msgstr "" #: src/usbauth-notifier.c:104 msgid "Smart Card" msgstr "" #: src/usbauth-notifier.c:108 msgid "Content Security" msgstr "" #: src/usbauth-notifier.c:112 msgid "Video" msgstr "" #: src/usbauth-notifier.c:116 msgid "Personal Healthcare" msgstr "" #: src/usbauth-notifier.c:120 msgid "AV" msgstr "" #: src/usbauth-notifier.c:124 msgid "Billboard" msgstr "" #: src/usbauth-notifier.c:128 msgid "Diagnostic Device" msgstr "" #: src/usbauth-notifier.c:132 msgid "Wireless Controller" msgstr "" #: src/usbauth-notifier.c:136 msgid "Miscellaneous" msgstr "" #: src/usbauth-notifier.c:140 msgid "Application Specific" msgstr "" #: src/usbauth-notifier.c:144 msgid "Vendor Specific" msgstr "" #: src/usbauth-notifier.c:148 msgid "Unknown" msgstr "" #: src/usbauth-notifier.c:287 msgid "New USB interface" msgstr "" #: src/usbauth-notifier.c:299 msgid "Default" msgstr "" #: src/usbauth-notifier.c:299 src/usbauth-notifier.c:305 msgid "Allow" msgstr "" #: src/usbauth-notifier.c:299 src/usbauth-notifier.c:306 msgid "Deny" msgstr "" #: src/usbauth-notifier.c:299 msgid "Type" msgstr "" #: src/usbauth-notifier.c:299 msgid "Name" msgstr "" usbauth-notifier/po/zh_TW.po0000644000175200017530000000533313552627002017076 0ustar moonape1226moonape1226# usbauth_notifier language template # This file is distributed under the same license as the usbauth-notifier package. # SZ Lin (林上智) , 2018. # msgid "" msgstr "" "Project-Id-Version: usbauth-notifier 1.0.2\n" "Report-Msgid-Bugs-To: szlin@debian.org\n" "POT-Creation-Date: 2015-05-20 19:20+0200\n" "PO-Revision-Date: 2018-02-21 21:37+0800\n" "Language-Team: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Last-Translator: SZ Lin (林上智) \n" "Plural-Forms: nplurals=1; plural=0;\n" "Language: zh_TW\n" #: src/usbauth-notifier.c:56 msgid "Per Interface" msgstr "每個介面" #: src/usbauth-notifier.c:60 msgid "Audio" msgstr "音訊裝置" #: src/usbauth-notifier.c:64 msgid "Communication" msgstr "通訊" #: src/usbauth-notifier.c:68 msgid "HID" msgstr "人機介面裝置" #: src/usbauth-notifier.c:71 msgid "Keyboard" msgstr "鍵盤" #: src/usbauth-notifier.c:75 msgid "Mouse" msgstr "滑鼠" #: src/usbauth-notifier.c:80 msgid "Physical" msgstr "物理介面裝置" #: src/usbauth-notifier.c:84 msgid "Image" msgstr "靜止圖像裝置" #: src/usbauth-notifier.c:88 msgid "Printer" msgstr "列印裝置" #: src/usbauth-notifier.c:92 msgid "Mass Storage" msgstr "大容量儲存裝置" #: src/usbauth-notifier.c:96 msgid "Hub" msgstr "集線器" #: src/usbauth-notifier.c:100 msgid "CDC data" msgstr "CDC 資料" #: src/usbauth-notifier.c:104 msgid "Smart Card" msgstr "智慧卡" #: src/usbauth-notifier.c:108 msgid "Content Security" msgstr "內容安全裝置" #: src/usbauth-notifier.c:112 msgid "Video" msgstr "影像" #: src/usbauth-notifier.c:116 msgid "Personal Healthcare" msgstr "個人保健" #: src/usbauth-notifier.c:120 msgid "AV" msgstr "影音裝置" #: src/usbauth-notifier.c:124 msgid "Billboard" msgstr "告示板" #: src/usbauth-notifier.c:128 msgid "Diagnostic Device" msgstr "診斷裝置" #: src/usbauth-notifier.c:132 msgid "Wireless Controller" msgstr "無線傳輸裝置" #: src/usbauth-notifier.c:136 msgid "Miscellaneous" msgstr "其他" #: src/usbauth-notifier.c:140 msgid "Application Specific" msgstr "特殊應用裝置" #: src/usbauth-notifier.c:144 msgid "Vendor Specific" msgstr "廠商自定裝置" #: src/usbauth-notifier.c:148 msgid "Unknown" msgstr "未知裝置" #: src/usbauth-notifier.c:287 msgid "New USB interface" msgstr "新的 USB 介面" #: src/usbauth-notifier.c:299 msgid "Default" msgstr "預設" #: src/usbauth-notifier.c:299 src/usbauth-notifier.c:305 msgid "Allow" msgstr "允許" #: src/usbauth-notifier.c:299 src/usbauth-notifier.c:306 msgid "Deny" msgstr "拒絕" #: src/usbauth-notifier.c:299 msgid "Type" msgstr "屬性" #: src/usbauth-notifier.c:299 msgid "Name" msgstr "名字" usbauth-notifier/po/LINGUAS0000644000175200017530000000003713425571265016534 0ustar moonape1226moonape1226# available languages de zh_TW usbauth-notifier/po/Makevars0000644000175200017530000000161013425571264017200 0ustar moonape1226moonape1226# Makefile variables for PO directory in any package using GNU gettext. # Usually the message domain is the same as the package name. DOMAIN = $(PACKAGE) # These two variables depend on the location of this directory. subdir = po top_builddir = .. # These options get passed to xgettext. XGETTEXT_OPTIONS = --keyword=_ --keyword=N_ # This is the copyright holder that gets inserted into the header of the # $(DOMAIN).pot file. Set this to the copyright holder of the surrounding # package. (Note that the msgstr strings, extracted from the package's # sources, belong to the copyright holder of the package.) Translators are # expected to transfer the copyright for their translations to this person # or entity, or to disclaim their copyright. The empty string stands for # the public domain; in this case the translators are expected to disclaim # their copyright. COPYRIGHT_HOLDER = SUSE LLC. usbauth-notifier/usbauth-notifier.spec.in0000644000175200017530000000653713767421335021656 0ustar moonape1226moonape1226# # spec file for package usbauth-notifier # # Copyright (c) 2020 SUSE LLC # Copyright (c) 2019 SUSE LLC # Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany. # Copyright (c) 2017-2018 Stefan Koch # Copyright (c) 2015 SUSE LLC. All Rights Reserved. # Author: Stefan Koch # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed # upon. The license for this file, and modifications and additions to the # file, is the same license as for the pristine package itself (unless the # license for the pristine package is not an Open Source License, in which # case the license is the MIT License). An "Open Source License" is a # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. # Please submit bugfixes or comments via https://bugs.opensuse.org/ # Name: @PACKAGE@ Version: @VERSION@ Summary: Notifier for USB Firewall to use with desktop environments URL: https://github.com/kochstefan/usbauth-all/tree/master/usbauth-notifier Source: https://github.com/kochstefan/usbauth-all/archive/v%{version}.tar.gz %if 0%{?suse_version} Release: 0 License: GPL-2.0-only Group: System/X11/Utilities %else Release: 1%{?dist} License: GPLv2 %endif %if 0%{?suse_version} Requires(pre): permissions %else Requires(pre): shadow-utils %endif Requires: usbauth BuildRequires: pkgconfig(dbus-1) BuildRequires: pkgconfig(libudev) BuildRequires: libusbauth-configparser-devel BuildRequires: gcc BuildRequires: libnotify-devel BuildRequires: libtool %if 0%{?suse_version} BuildRequires: permissions BuildRequires: gettext-runtime BuildRequires: pkg-config %else BuildRequires: gettext-devel BuildRequires: pkgconfig %endif %description A notifier for the usbauth firewall against BadUSB attacks. The user could manually allow or deny USB devices. %prep %autosetup -n usbauth-all-%{version} -p1 %build pushd %{name}/ autoreconf -f -i %configure %make_build popd %pre if ! getent group usbauth>/dev/null; then groupadd -r usbauth; fi if ! getent group usbauth-notifier>/dev/null; then groupadd -r usbauth-notifier; fi %install pushd %{name}/ %make_install %find_lang %name popd %files -f %name.lang %if 0%{?suse_version} %defattr(-,root,root) %endif %license %{name}/COPYING %doc %{name}/README doc %_mandir/man1/usbauth-notifier.1* doc %_mandir/man1/usbauth-npriv.1* %dir %_sysconfdir/xdg/autostart %_sysconfdir/xdg/autostart/usbauth-notifier.desktop %if 0%{?suse_version} %verify(not mode) %attr(04750,root,usbauth) %_libexecdir/usbauth-npriv %dir %verify(not mode) %attr(00750,root,usbauth-notifier) %_libexecdir/usbauth-notifier %verify(not mode) %attr(02755,root,usbauth) %_libexecdir/usbauth-notifier/usbauth-notifier %else %attr(04750,root,usbauth) %_libexecdir/usbauth-npriv %dir %attr(00750,root,usbauth-notifier) %_libexecdir/usbauth-notifier %attr(02755,root,usbauth) %_libexecdir/usbauth-notifier/usbauth-notifier %endif %if 0%{?suse_version} %post %set_permissions %_libexecdir/usbauth-npriv %_libexecdir/usbauth-notifier %_libexecdir/usbauth-notifier/usbauth-notifier %verifyscript %verify_permissions -e %_libexecdir/usbauth-npriv %_libexecdir/usbauth-notifier %_libexecdir/usbauth-notifier/usbauth-notifier %endif %changelog usbauth-notifier/autogen.sh0000755000175200017530000000101013430161060017042 0ustar moonape1226moonape1226#!/bin/sh # Copyright (C) 2017 Stefan Koch # # This program is free software; you can redistribute it and/or # modify it under the terms of version 2 of the GNU General # Public License as published by the Free Software Foundation. # # 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. autoreconf -f -i usbauth-notifier/COPYING0000644000175200017530000004366313425571273016137 0ustar moonape1226moonape1226This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. ############################################################################### GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 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. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. usbauth-notifier/configure.ac0000644000175200017530000000332314003045132017336 0ustar moonape1226moonape1226# Copyright (C) 2017 Stefan Koch # # This program is free software; you can redistribute it and/or # modify it under the terms of version 2 of the GNU General # Public License as published by the Free Software Foundation. # # 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. # -*- Autoconf -*- # Process this file with autoconf to produce a configure script. AC_PREREQ([2.69]) AC_INIT([usbauth-notifier], [1.0.2], [stefan.koch10@gmail.com]) AM_INIT_AUTOMAKE([-Wall foreign]) AC_CONFIG_SRCDIR([config.h.in]) AC_CONFIG_HEADERS([config.h]) AC_CONFIG_MACRO_DIRS([m4]) AC_SYS_LARGEFILE AM_PROG_AR LT_INIT # Checks for programs. AC_PROG_CXX AC_PROG_AWK AC_PROG_CC AC_PROG_CPP AC_PROG_INSTALL AC_PROG_LN_S AC_PROG_MAKE_SET # Checks for libraries. # Checks for header files. AC_CHECK_HEADERS([inttypes.h libintl.h locale.h stdint.h stdlib.h string.h unistd.h]) # Checks for typedefs, structures, and compiler characteristics. AC_CHECK_HEADER_STDBOOL AC_TYPE_INT32_T AC_TYPE_PID_T AC_TYPE_SIZE_T # Checks for library functions. AC_CHECK_FUNCS([setlocale]) AM_GNU_GETTEXT_VERSION([0.19.8]) AM_GNU_GETTEXT([external]) AC_CHECK_FUNCS([setlocale]) PKG_CHECK_MODULES([USBAUTH], [libusbauth-configparser]) PKG_CHECK_MODULES([NOTIFY], [libnotify]) PKG_CHECK_MODULES([UDEV], [libudev]) PKG_CHECK_MODULES([DBUS], [dbus-1]) AC_CONFIG_FILES([Makefile data/Makefile src/Makefile po/Makefile.in usbauth-notifier.spec]) AC_OUTPUT usbauth-notifier/usbauth-notifier-rpmlintrc0000644000175200017530000000005513425571255022313 0ustar moonape1226moonape1226setBadness('permissions-file-setuid-bit', 0) usbauth-notifier/CHANGELOG.md0000644000175200017530000000034614003045132016663 0ustar moonape1226moonape1226usbauth-notifier 1.0.4 (2021-01-21) * Fix libexecdir expansion for usbauth-notifier.desktop usbauth-notifier 1.0.2 (2019-09-30) * Move binaries from bindir to libexecdir usbauth-notifier 1.0 (2018-02-26) * Initial Release usbauth-notifier/usbauth-notifier.changes0000644000175200017530000000146213425571253021713 0ustar moonape1226moonape1226------------------------------------------------------------------- Mon Feb 26 05:23:04 UTC 2018 - stefan.koch10@gmail.com - fix formatting of notifications - fix group name in manpage/README - use XDG autostart instead of xinitrc.d ------------------------------------------------------------------- Tue Feb 13 22:30:00 UTC 2018 - stefan.koch10@gmail.com - buildrequires usbauth not needed, we create both groups here. - fix group creation within spec file ------------------------------------------------------------------- Thu Oct 12 14:37:00 UTC 2017 - meissner@suse.com - susefied spec file. correct permission handling added. ------------------------------------------------------------------- Thu Oct 12 06:58:07 UTC 2017 - meissner@suse.com - UI notifications for new USB devices to be authenticated usbauth-notifier/data/0000755000175200017530000000000014003045132015760 5ustar moonape1226moonape1226usbauth-notifier/data/usbauth-notifier.10000644000175200017530000000065513425571271021357 0ustar moonape1226moonape1226.TH USBAUTH 1 .SH NAME usbauth-notifier \- Notifier for USB Firewall to use with desktop environments .SH SYNOPSIS .B usbauth-notifier .SH DESCRIPTION A notifier for the usbauth firewall against BadUSB attacks. The user could manually allow or deny interfaces of USB devices. Every user that wants use the notifier must be added to the usbauth-notifier group. To get notifications, at least one usbauth rule must be specified. usbauth-notifier/data/usbauth-notifier.desktop.tmpl0000644000175200017530000000112614003045132023616 0ustar moonape1226moonape1226# Copyright (C) 2018 Stefan Koch # # This program is free software; you can redistribute it and/or modify # it under the terms of version 2 of the GNU General Public # License as published by the Free Software Foundation. # # 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. [Desktop Entry] Type=Application Name=usbauth-notifier Exec=LIBEXECDIR/usbauth-notifier/usbauth-notifier usbauth-notifier/data/usbauth-npriv.10000644000175200017530000000073113425571270020670 0ustar moonape1226moonape1226.TH USBAUTH 1 .SH NAME usbauth-notifier \- Notifier for USB Firewall to use with desktop environments .SH SYNOPSIS .B usbauth-notifier .SH DESCRIPTION This program is installed with SUID bit set. The usbauth-notifier will call it to call usbauth firewall with superuser rights. .LP Example call: .br usbauth-npriv allow/deny DEVNUM PATH .LP This program calls then: .br /usr/sbin/usbauth allow/deny DEVNUM PATH .br but only if the caller is .br /usr/bin/usbauth-notifier usbauth-notifier/data/Makefile.am0000644000175200017530000000132414003045132020014 0ustar moonape1226moonape1226# Copyright (C) 2017 Stefan Koch # # This program is free software; you can redistribute it and/or # modify it under the terms of version 2 of the GNU General # Public License as published by the Free Software Foundation. # # 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. man_MANS = usbauth-notifier.1 usbauth-npriv.1 xdgautostartdir = $(sysconfdir)/xdg/autostart dist_xdgautostart_DATA = usbauth-notifier.desktop $(dist_xdgautostart_DATA): $(SED) "s#LIBEXECDIR#$(libexecdir)#g" $(srcdir)/$@.tmpl > $@ usbauth-notifier/usbauth-notifier.rpmlintrc0000644000175200017530000000020713552627002022304 0ustar moonape1226moonape1226addFilter(r'setuid-binary') addFilter(r'setgid-binary') addFilter(r'non-standard-dir-perm') addFilter(r'non-standard-executable-perm') usbauth-notifier/src/0000755000175200017530000000000013552627002015650 5ustar moonape1226moonape1226usbauth-notifier/src/usbauth-notifier.c0000644000175200017530000002475213552627002021316 0ustar moonape1226moonape1226/* * Copyright (c) 2015 SUSE LLC. All Rights Reserved. * Author: Stefan Koch * * Copyright (c) 2017 Stefan Koch * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General * Public License as published by the Free Software Foundation. * * 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, contact SUSE LLC. * * To contact SUSE about this file by physical or electronic mail, * you may find current contact information at www.suse.com */ /* * Description : Notifier for USB Firewall to use with desktop environments */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "usbauth-notifier.h" #define NPRIV_PATH LIBEXECDIR "/usbauth-npriv" static bool work = true; static struct udev *udev = NULL; static DBusConnection *bus = NULL; static GMainLoop *loop = NULL; char *classArray[] = { "PER_INTERFACE", "AUDIO", "COMM", "HID", "", "PHYSICAL", "STILL_IMAGE", "PRINTER", "MASS_STORAGE", "HUB" }; const char* get_info_string(unsigned cl, unsigned subcl, unsigned iprot, bool returnIcon) { const char *ret = ""; const char *str = ""; const char *icon = ""; switch(cl) { case 0: str = gettext("Per Interface"); icon = "dialog-information"; break; case 1: str = gettext("Audio"); icon = "audio-card"; break; case 2: str = gettext("Communication"); icon = "modem"; break; case 3: str = gettext("HID"); icon = "input-keyboard"; if (subcl == 1 && iprot == 1) { str = gettext("Keyboard"); icon = "input-keyboard"; } else if (subcl == 1 && iprot == 2) { str = gettext("Mouse"); icon = "input-mouse"; } break; case 5: str = gettext("Physical"); icon = "dialog-information"; break; case 6: str = gettext("Image"); icon = "camera-photo"; break; case 7: str = gettext("Printer"); icon = "printer"; break; case 8: str = gettext("Mass Storage"); icon = "drive-removable-media-usb"; break; case 9: str = gettext("Hub"); icon = "dialog-information"; break; case 0x0a: str = gettext("CDC data"); icon = "modem"; break; case 0x0b: str = gettext("Smart Card"); icon = "secure-card"; break; case 0x0d: str = gettext("Content Security"); icon = "dialog-information"; break; case 0x0e: str = gettext("Video"); icon = "camera-video"; break; case 0x0f: str = gettext("Personal Healthcare"); icon = "dialog-information"; break; case 0x10: str = gettext("AV"); icon = "camera-video"; break; case 0x11: str = gettext("Billboard"); icon = "dialog-information"; break; case 0xdc: str = gettext("Diagnostic Device"); icon = "dialog-information"; break; case 0xe0: str = gettext("Wireless Controller"); icon = "network-wireless"; break; case 0xef: str = gettext("Miscellaneous"); icon = "dialog-information"; break; case 0xfe: str = gettext("Application Specific"); icon = "dialog-information"; break; case 0xff: str = gettext("Vendor Specific"); icon = "dialog-information"; break; default: str = gettext("Unknown"); icon = "dialog-information"; break; } if (returnIcon) ret = icon; else ret = str; return ret; } bool init_dbus() { bool ret = true; DBusError error; dbus_error_init(&error); bus = dbus_bus_get(DBUS_BUS_SYSTEM, &error); ret &= no_error_check_dbus(&error); dbus_bus_request_name(bus, "org.opensuse.usbauth.notifier", DBUS_NAME_FLAG_REPLACE_EXISTING, &error); ret &= no_error_check_dbus(&error); dbus_bus_add_match(bus, "type='signal',interface='org.opensuse.usbauth.Message'", &error); ret &= no_error_check_dbus(&error); return ret; } void deinit_dbus() { dbus_connection_unref(bus); bus=NULL; } bool no_error_check_dbus(DBusError *error) { bool ret = true; if (dbus_error_is_set(error)) { ret = false; syslog(LOG_ERR, "dbus_error: %s\n", error->message); dbus_error_free(error); } return ret; } struct Dev* receive_dbus(bool *authorize) { struct Dev *ret = NULL; struct udev_device *udevdev = NULL; int32_t authorize_int = 0; int32_t devn_int = 0; const char *path = NULL; DBusError error; DBusMessage *msg = NULL; dbus_error_init(&error); dbus_connection_flush(bus); while (work) { // receive dbus message dbus_connection_read_write(bus, 1); msg = dbus_connection_pop_message(bus); if (msg) { // get interface udev_device from message path and devnum if (dbus_message_is_signal(msg, "org.opensuse.usbauth.Message", "usbauth")) { dbus_message_get_args(msg, &error, DBUS_TYPE_INT32, &authorize_int, DBUS_TYPE_INT32, &devn_int, DBUS_TYPE_STRING, &path, DBUS_TYPE_INVALID); if (no_error_check_dbus(&error)) { syslog(LOG_NOTICE, "successful received dbus message\n"); udevdev = udev_device_new_from_syspath(udev, path); if (udevdev) ret = calloc(1, sizeof(struct Dev)); if (ret) { *authorize = authorize_int; ret->udevdev = udevdev; ret->devnum = devn_int; } } dbus_message_unref(msg); msg = NULL; break; } } usleep(100000); } return ret; } void notification_action_callback(NotifyNotification *callback, char* action, gpointer user_data) { const char *authstr = strcmp(action, "act_allow") ? "deny" : "allow"; struct Dev *dev = (struct Dev*) user_data; struct udev_device *udevdev = dev->udevdev; const char *syspath = NULL; int devn = -1; char sdevn[32]; if (!dev) return; if (!udevdev) { free(dev); return; } devn = dev->devnum; syspath = udev_device_get_syspath(udevdev); snprintf(sdevn, sizeof(sdevn), "%x", devn); // /usr/bin/usbauth-npriv allow/deny DEVNUM PATH syslog(LOG_NOTICE, "execute %s %s %s %s\n", NPRIV_PATH, authstr, sdevn, syspath); if (fork()) wait(NULL); else execl(NPRIV_PATH, NPRIV_PATH, authstr, sdevn, syspath, NULL); udev_device_unref(udevdev); free(dev); g_object_unref(G_OBJECT(callback)); } void notification_create(const struct Dev* dev, bool authorize) { struct udev_device *udevdev = dev->udevdev; int32_t devn = dev->devnum; char titleMsg[48]; char detailedMsg[128]; unsigned cl = 255; unsigned subcl = 255; unsigned iprot = 0; unsigned vId = 0; unsigned pId = 0; const char *busn = 0; const char *devp = 0; const char *conf = 0; const char *intf = 0; const char *titleStr = ""; struct Dev *dev_heap = NULL; NotifyNotification *notification = NULL; const char *type = udev_device_get_devtype(udevdev); dev_heap = calloc(1, sizeof(struct Dev)); if (!type || !dev_heap) { syslog(LOG_ERR, "error at creating notification\n"); return; } if (strcmp(type, "usb_interface") == 0) { // values from interface cl = usbauth_get_param_val(bInterfaceClass, udevdev); subcl = usbauth_get_param_val(bInterfaceSubClass, udevdev); iprot = usbauth_get_param_val(bInterfaceProtocol, udevdev); titleStr = gettext("New USB interface"); } // values from interfaces parent vId = usbauth_get_param_val(idVendor, udevdev); pId = usbauth_get_param_val(idProduct, udevdev); busn = usbauth_get_param_valStr(busnum, udevdev); devp = usbauth_get_param_valStr(devpath, udevdev); conf = usbauth_get_param_valStr(bConfigurationValue, udevdev); intf = usbauth_get_param_valStr(bInterfaceNumber, udevdev); snprintf(titleMsg, sizeof(titleMsg), "%s (%s-%s:%s.%s)", titleStr, busn, devp, conf, intf); snprintf(detailedMsg, sizeof(detailedMsg), "%s: %s\n%s: %s\n%s: %04x:%04x\n%s: %s-%s:%s.%s", gettext("Default"), authorize ? gettext("Allow") : gettext("Deny"), gettext("Type"), get_info_string(cl, subcl, iprot, false), "ID", vId, pId, gettext("Name"), busn, devp, conf, intf); // pointer of dev heap gets back at callback so stack would be then out of context dev_heap->udevdev = udevdev; dev_heap->devnum = devn; notification = notify_notification_new(titleMsg, detailedMsg, get_info_string(cl, subcl, iprot, true)); notify_notification_add_action(notification, "act_allow", gettext("Allow"), (NotifyActionCallback) notification_action_callback, dev_heap, NULL); notify_notification_add_action(notification, "act_deny", gettext("Deny"), (NotifyActionCallback) notification_action_callback, dev_heap, NULL); notify_notification_show(notification, NULL); syslog(LOG_INFO, "show notification for syspath %s\n", udev_device_get_syspath(udevdev)); } void* notification_thread_loop(void *arg) { loop = g_main_loop_new(NULL, FALSE); if (loop) g_main_loop_run(loop); g_thread_exit(NULL); return NULL; } void signal_handler(int sig) { work = false; } int main(int argc, char **argv) { struct group *gr = NULL; GThread *thread = NULL; // set signal handler for SIGINT and SIGTERM, the handler sets work to false signal(SIGINT, signal_handler); signal(SIGTERM, signal_handler); // connect to syslog openlog("usbauth-notifier", LOG_PERROR | LOG_PID, LOG_USER); // set GID to usbauth gr = getgrnam("usbauth"); if (!gr || !gr->gr_gid) { syslog(LOG_ERR, "getgrnam error"); return EXIT_FAILURE; } if (setgid(gr->gr_gid)) { syslog(LOG_ERR, "setgid error"); return EXIT_FAILURE; } setlocale(LC_ALL, ""); textdomain("usbauth-notifier"); udev = udev_new(); if (!udev) { syslog(LOG_ERR, "udev error\n"); return EXIT_FAILURE; } if (!init_dbus()) { syslog(LOG_ERR, "dbus init error\n"); return EXIT_FAILURE; } if (!notify_init("usbauth")) { syslog(LOG_ERR, "notify init error\n"); return EXIT_FAILURE; } thread = g_thread_new("thread", notification_thread_loop, NULL); // thread for g_main_loop syslog(LOG_NOTICE, "usbauth-notifier started\n"); // work until SIGINT or SIGTERM while(work) { bool authorize = false; struct Dev *dev = receive_dbus(&authorize); // receive dbus message from USB firewall if (dev) { notification_create(dev, authorize); // create notification according interface device from dbus message free(dev); } } g_main_loop_quit(loop); // exit g_main_loop g_thread_join(thread); // exit g_main_loop thread notify_uninit(); deinit_dbus(); udev_unref(udev); udev = NULL; syslog(LOG_NOTICE, "usbauth-notifier stopped\n"); // disconnect from syslog closelog(); return EXIT_SUCCESS; } usbauth-notifier/src/usbauth-notifier.h0000644000175200017530000000660513425571256021330 0ustar moonape1226moonape1226/* * Copyright (c) 2015 SUSE LLC. All Rights Reserved. * Author: Stefan Koch * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General * Public License as published by the Free Software Foundation. * * 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, contact SUSE LLC. * * To contact SUSE about this file by physical or electronic mail, * you may find current contact information at www.suse.com */ /* * Description : Notifier for USB Firewall to use with desktop environments */ #ifndef USBAUTH_NOTIFIER_H_ #define USBAUTH_NOTIFIER_H_ #include #include #include #include struct Dev { struct udev_device *udevdev; int32_t devnum; }; /** * get string representation of device class or icon name string * * @cl: interface class number * @subcl: interface sub class number * @iprot: interface protocol (for differ keyboard and mouse) * @returnIcon: false that device class string should returned, true if icon name string should returned * * Return: device class string (returnIcon == false) or icon name string (returnIcon == true) */ const char* get_info_string(unsigned cl, unsigned subcl, unsigned iprot, bool returnIcon); /** * initialize dbus related things */ bool init_dbus(); /** * deinitialize dbus related things */ void deinit_dbus(); /** * check dbus errors * * @error: dbus error structure * * Return: true if no error, false if error */ bool no_error_check_dbus(DBusError *error); /** * receive dbus message from USB firewall * will called when user clicked on allow or deny in notify pop up * * @authorize (output param): true if interface was authorized by the USB firewall, false if interface was not authorized by the USB firewall * * Return: Dev structure with udev_device from type "usb_interface" and devnum from sysfs tree */ struct Dev* receive_dbus(bool *authorize); /** * callback handler from after action from notification * will called when user clicked on allow or deny in notify pop up * * @callback: pointer to notify structure * @action: to differ from allow and deny actions * @user_data: pointer that is given to the notification message, and is returned back on callback; used to relate the interface from notification (struct Dev*) */ void notification_action_callback(NotifyNotification *callback, char* action, gpointer user_data); /** * create a notification that will showed as pop up * will called when user clicked on allow or deny in notify pop up * * @dev: Dev structure with udev_device from type "usb_interface" and devnum from sysfs tree * @authorize: true if interface was authorized by the USB firewall, false if interface was not authorized by the USB firewall */ void notification_create(const struct Dev* intf, bool authorize); /** * Thread for g_main_loop needed for action_callback handler */ void* notification_thread_loop(void *arg); /** * signal handler that catches SIGINT and SIGTERM to exit program * * @int: signal type */ void signal_handler(int sig); #endif /* USBAUTH_NOTIFIER_H_ */ usbauth-notifier/src/usbauth-npriv.c0000644000175200017530000000512613552626767020650 0ustar moonape1226moonape1226/* * Copyright (c) 2015 SUSE LLC. All Rights Reserved. * Author: Stefan Koch * * Copyright (c) 2017 Stefan Koch * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General * Public License as published by the Free Software Foundation. * * 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, contact SUSE LLC. * * To contact SUSE about this file by physical or electronic mail, * you may find current contact information at www.suse.com */ #include #include #include #include #include #include #define USBAUTH_PATH SBINDIR "/usbauth" #define NOTIFIER_PATH LIBEXECDIR "/usbauth-notifier/usbauth-notifier" #define BUFSIZE 128 /* * This program will installed with SUID bit set * The usbauth_notifier will call it to call usbauth firewall * with superuser rights * * Example call: * usbauth-npriv allow/deny DEVNUM PATH * * This program calls then: * /usr/sbin/usbauth allow/deny DEVNUM PATH * * but only if the caller is * /usr/lib/usbauth-notifier/usbauth-notifier * */ int main(int argc, char **argv) { int ret = EXIT_FAILURE; char str_proc[BUFSIZE] = {0}; char str_path[BUFSIZE] = {0}; size_t len_str_path = 0; pid_t ppid = 0; // connect to syslog openlog("usbauth-npriv", LOG_PERROR | LOG_PID, LOG_LOCAL0); ppid = getppid(); snprintf(str_proc, BUFSIZE, "/proc/%d/exe", (int) ppid); len_str_path = readlink(str_proc, str_path, BUFSIZE-1); if (len_str_path < 0 || len_str_path >= BUFSIZE) len_str_path = 0; str_path[len_str_path] = 0; // three params must be given and the caller must be the notifier if (argc >= 4 && strncmp(NOTIFIER_PATH, str_path, BUFSIZE) == 0) { ret = setuid(0); if (!ret) ret = clearenv(); if (!ret) { // /usr/sbin/usbauth allow/deny DEVNUM PATH syslog(LOG_NOTICE, "execute %s %s %s %s\n", USBAUTH_PATH, argv[1], argv[2], argv[3]); if (fork()) wait(NULL); else execl(USBAUTH_PATH, USBAUTH_PATH, argv[1], argv[2], argv[3], NULL); } else { syslog(LOG_ERR, "setuid failed\n"); } } else { syslog(LOG_ERR, "call of usbauth-npriv from ppid=%d with unauthorized installation path=%s\n", ppid, str_path); } // disconnect from syslog closelog(); return ret; } usbauth-notifier/src/Makefile.am0000644000175200017530000000201113552627002017676 0ustar moonape1226moonape1226# Copyright (C) 2017-2018 Stefan Koch # # This program is free software; you can redistribute it and/or # modify it under the terms of version 2 of the GNU General # Public License as published by the Free Software Foundation. # # 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. notifier_installdir = $(libexecdir)/$(PACKAGE) notifier_install_PROGRAMS = usbauth-notifier libexec_PROGRAMS = usbauth-npriv usbauth_notifier_CFLAGS = -include config.h -DLIBEXECDIR=\""$(libexecdir)"\" $(USBAUTH_CFLAGS) $(NOTIFY_CFLAGS) $(UDEV_CFLAGS) $(DBUS_CFLAGS) usbauth_notifier_SOURCES = usbauth-notifier.c usbauth_notifier_LDADD = $(USBAUTH_LIBS) $(NOTIFY_LIBS) $(UDEV_LIBS) $(DBUS_LIBS) usbauth_npriv_CFLAGS = -include config.h -DSBINDIR=\""$(sbindir)"\" -DLIBEXECDIR=\""$(libexecdir)"\" usbauth_npriv_SOURCES = usbauth-npriv.c usbauth-notifier/README0000644000175200017530000000054213425571261015746 0ustar moonape1226moonape1226usbauth-notifier: Notifier for USB Firewall to use with desktop environments A notifier for the usbauth firewall against BadUSB attacks. The user could manually allow or deny interfaces of USB devices. Every user that wants use the notifier must be added to the usbauth-notifier group. To get notifications, at least one usbauth rule must be specified. usbauth-notifier/Makefile.am0000644000175200017530000000110213425571266017120 0ustar moonape1226moonape1226# Copyright (C) 2017 Stefan Koch # # This program is free software; you can redistribute it and/or # modify it under the terms of version 2 of the GNU General # Public License as published by the Free Software Foundation. # # 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. SUBDIRS = src data po ACLOCAL_AMFLAGS = -I m4 EXTRA_DIST = config.rpath m4/ChangeLog