[GH-ISSUE #789] Backgrounding fetchmail in script #534

Closed
opened 2026-05-05 06:04:06 -06:00 by gitea-mirror · 2 comments
Owner

Originally created by @chiraag-nataraj on GitHub (Sep 17, 2016).
Original GitHub issue: https://github.com/netblue30/firejail/issues/789

I decided to use firejail to contain fetchmail to the files and directories it needs. I use it in daemon mode (as most people probably do). I also use gpg to encrypt the config file. So right now, the workflow is

  1. Decrypt the config file to a location on RAM (my /tmp is a tmpfs).
  2. Launch fetchmail with that config file.
  3. Delete the config file so that only the encrypted one ever exists on disk.
    Obviously, I can only delete the config file after fetchmail has launched. When it's just fetchmail, there's no problem - it launches daemon mode and then releases the foreground. When I launch it with firejail, though, firejail refuses to leave the foreground, which means the decrypted config file never gets deleted.
    Here's the script:
#!/bin/bash
gpg -o /tmp/.fetchmailrc ~/.fetchmailrc.gpg
chmod 600 /tmp/.fetchmailrc
firejail fetchmail -d 5 -f /tmp/.fetchmailrc
rm /tmp/.fetchmailrc

As you can tell, pretty simple. I tried putting & at the end (as I would normally do), but then fetchmail exited saying that no mail servers were specified. How would I go about fixing this? All I need is for firejail to background itself when fetchmail does.

Originally created by @chiraag-nataraj on GitHub (Sep 17, 2016). Original GitHub issue: https://github.com/netblue30/firejail/issues/789 I decided to use firejail to contain fetchmail to the files and directories it needs. I use it in daemon mode (as most people probably do). I also use gpg to encrypt the config file. So right now, the workflow is 1. Decrypt the config file to a location on RAM (my `/tmp` is a `tmpfs`). 2. Launch fetchmail with that config file. 3. Delete the config file so that only the encrypted one ever exists on disk. Obviously, I can only delete the config file after fetchmail has launched. When it's just fetchmail, there's no problem - it launches daemon mode and then releases the foreground. When I launch it with firejail, though, firejail refuses to leave the foreground, which means the decrypted config file never gets deleted. Here's the script: ``` #!/bin/bash gpg -o /tmp/.fetchmailrc ~/.fetchmailrc.gpg chmod 600 /tmp/.fetchmailrc firejail fetchmail -d 5 -f /tmp/.fetchmailrc rm /tmp/.fetchmailrc ``` As you can tell, pretty simple. I tried putting `&` at the end (as I would normally do), but then fetchmail exited saying that no mail servers were specified. How would I go about fixing this? All I need is for firejail to background itself when fetchmail does.
gitea-mirror 2026-05-05 06:04:06 -06:00
Author
Owner

@netblue30 commented on GitHub (Sep 18, 2016):

Try daemon command (sudo apt-get install daemon):

$ daemon firejail sleep 100
$ firejail --list
620:netblue:firejail sleep 100 
$
<!-- gh-comment-id:247850578 --> @netblue30 commented on GitHub (Sep 18, 2016): Try daemon command (sudo apt-get install daemon): ``` $ daemon firejail sleep 100 $ firejail --list 620:netblue:firejail sleep 100 $ ```
Author
Owner

@chiraag-nataraj commented on GitHub (Sep 18, 2016):

I fixed it by just running the whole script inside firejail. I was having trouble because of the fetchmail and daemon options conflicting or something - it was weird. If I run the script inside firejail, then backgrounding works and firejail properly doesn't close.

<!-- gh-comment-id:247855849 --> @chiraag-nataraj commented on GitHub (Sep 18, 2016): I fixed it by just running the whole script inside firejail. I was having trouble because of the fetchmail and daemon options conflicting or something - it was weird. If I run the script inside firejail, then backgrounding works and firejail properly **doesn't** close.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/firejail#534
No description provided.