Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

usbguard fails to start if rule line in rules.conf ends with space character. #571

Open
jk-10 opened this issue Dec 1, 2022 · 1 comment · May be fixed by #637
Open

usbguard fails to start if rule line in rules.conf ends with space character. #571

jk-10 opened this issue Dec 1, 2022 · 1 comment · May be fixed by #637
Labels

Comments

@jk-10
Copy link

jk-10 commented Dec 1, 2022

It seems that usbguard fails to start if rule line in rules.conf ends with space character. (Problem may also occur with other lines, i did not check that.)

I added a new rule and tried to stop and start usbguard again:

jk@ktt:~$ sudo service usbguard start
jk@ktt:~$ service usbguard status
● usbguard.service - USBGuard daemon
     Loaded: loaded (/lib/systemd/system/usbguard.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Thu 2022-12-01 15:27:44 EET; 4s ago
       Docs: man:usbguard-daemon(8)
    Process: 859369 ExecStart=/usr/sbin/usbguard-daemon -k -c /etc/usbguard/usbguard-daemon.conf (code=exited, status=1/FAILURE)
   Main PID: 859369 (code=exited, status=1/FAILURE)

joulu 01 15:27:44 ktt systemd[1]: usbguard.service: Scheduled restart job, restart counter is at 5.
joulu 01 15:27:44 ktt systemd[1]: Stopped USBGuard daemon.
joulu 01 15:27:44 ktt systemd[1]: usbguard.service: Start request repeated too quickly.
joulu 01 15:27:44 ktt systemd[1]: usbguard.service: Failed with result 'exit-code'.
joulu 01 15:27:44 ktt systemd[1]: Failed to start USBGuard daemon.

Then I removed the space at the end of the newly added rule line and tried again:

jk@ktt:~$ sudo service usbguard start
jk@ktt:~$ service usbguard status
● usbguard.service - USBGuard daemon
     Loaded: loaded (/lib/systemd/system/usbguard.service; enabled; vendor preset: enabled)
     Active: active (running) since Thu 2022-12-01 15:28:21 EET; 6s ago
       Docs: man:usbguard-daemon(8)
   Main PID: 859471 (usbguard-daemon)
      Tasks: 3 (limit: 9274)
     Memory: 1.4M
     CGroup: /system.slice/usbguard.service
             └─859471 /usr/sbin/usbguard-daemon -k -c /etc/usbguard/usbguard-daemon.conf

Please add support for having spaces or make usbguard to remove them automatically when reading the conf file.

I don't know the usbguard version, but it is the default version coming with the Ubuntu 22.04 which is my OS.

@hartwork
Copy link
Contributor

hartwork commented Dec 1, 2022

Hi @jk-10,

I confirm that single trailing spaces in rules.conf. Here is how to reproduce it easily and the precise error output I get:

# sudo /etc/init.d/usbguard stop  # or a systemd equivalent
# cd "$(mktemp -d)"
# sudo usbguard generate-policy > rules.conf
# echo "RuleFile=${PWD}/rules.conf" > usbguard-daemon.conf
# sed 's,$, ,' -i rules.conf  # inserts trailing whitespace
# sudo usbguard-daemon -d -k -P -c ./usbguard-daemon.conf -l ./usbguard-daemon.log
[..]
[1669913599.512] (E) Rules: SourceLOCAL::/tmp/tmp.B7cpfOgomY/rules.conf: :1:225: parse error matching sor<usbguard::RuleParser::comment, usbguard::RuleParser::rule>

This is with USBGuard version 1.1.2. I'm assuming you are running 1.1.1+ds-3 because of your mention of Ubuntu 22.04 (codenamed "jammy").

@Cropi Cropi added the bug label Dec 6, 2022
@kumavale kumavale linked a pull request Sep 29, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants