Procmail Troubles - procmail

I've been trying to solve this for weeks...
My Goal is to search my inbox for the following messages:
Hello
Hi
Hey
Im using three files to do this for me. The first, a .forward file in my $HOME
"|IFS=' '&&exec usr/bin/procmail||exit 75 #username"
And these two are in my ~/.procmail directory
.procmailrc
VERBOSE=off
MAILDIR=$HOME/Mail
PMDIR=$HOME/.procmail
DEFAULT=/var/spool/mail/username
LOGFILE=$PMDIR/log
INCLUDERC=$PMDIR/general.rc
#end of .procmailrc
And lastly the rule file: general.rc
:0
* ^From:.*sumone#sumaddy.com
* ^Subject:.*hello
$HOME/Mail/Hello
What's supposed to happen is that all three of these files work together to copy and move mail that contain the hello pattern in its subject. And to be safe it will also look for a certain persons address. Then when those patterns are matched it will stick what it found and create the specified path; if it doesn't already exist.
But its not doing that.
After I'm done editing these files in emacs, vi, .. and then save it, will it work automatically? Or do I need to compile it?
If I do, the .procmailrc might require ( if not all ) the 'Shell=/bin/sh'
Not that I didn't try that...
No, my poorly developed design is to process incoming mail..
I've tested it, by sending emails to myself.
What i think, is that my General.RC file isnt coded write. Because, directly after i send myself an email, it SHOULD copy and move it to the specified directory.
Its no wonder that i've made those mistakes, i've edited all three of these files a milllllion times.
Nothing is displayed in my LOG file...
I've fixed everything else and i know my /usr/bin/procmail exists because i used whereis to see its path.
But my testing still fails. I keep sending myself emails and checking my Mail Folder to see if the bytes in my "Hello" file have increased..
How can i get the log to work?
Is the general.rc wrong?

Procmail processes mail as it comes in, not when it's just sitting there in your mailbox. If you want to process mail that's already in your mailbox, you've got to pass it through procmail again, either by "bouncing" it to yourself, or by piping it through procmail. In a command line email client like mutt, you'd do the former with the 'b' command, and the latter by typing |procmail

If you wish to process email you already have, you will need to:
Exit any mail clients
Move away your current Inbox (mv /var/spool/mail/username /tmp/mail.username )
formail +1 -ds procmail < /tmp/mail.username

Your ~.forward file has a missing '/' before usr. Also, you may keep it short like this;
"| **/**usr/bin/procmail"
put your .procmailrc under your HOME directory
After setting your MAILDIR, write only "Hello" as the mailbox name in general.rc. Also use ":0:" at the beginning of the recipe to enable locking, all deliveries must lock the mailbox file!
Make sure you have procmail installed at /usr/bin/procmail on the server.
Make sure "Hello" file exists in your MAILDIR.
Check the log file

If all you want is to find messages on your disk with one of those Subject lines, I would recommend fgrep on your inbox.

I think your primary concern before any other debugging is to verify that procmail is being run on your incoming e-mail messages.
My suggestion is to make your .procmailrc file look like this (with nothing else)
VERBOSE=on
LOGFILE=/tmp/procmail.log
:0 fhbw
| sed "s/^Subject:/& --procmail working--/"
Then send yourself an e-mail message.
You should get a logfile in /tmp/procmail.log and your e-mail message should arrive in your mailbox with the subject line modified to include "--procmail working--".
If that doesn't work, then procmail is not being called and you should edit your question to show the current contents of your .forward file.
If that works, then the problem is with the contents of your .procmailrc or your general.rc file. You should edit your question to show the current contents of those two files.

Related

Is there a way to override the content of notification email from a test case update in Kiwi TCMS?

Im trying to change the content of the notification email sent after a test case has been updated to better clarify what has been changed. As it is, the content is hard to read.
Went through the link below to configure the other notification content:
http://kiwitcms.org/blog/atodorov/2018/08/06/how-to-override-templates-for-kiwi-tcms/
The content of the notification email:
Updated on Tue Aug 20 15:47:18 2019
Updated by Admin
--- notes
+++ notes
## -1 +1 ##
-TestTest
+TestTest123123
--- text
+++ text
## -10,7 +10,7 ##
3. item
*Expected results*:
-
+Test
1. item
2. item
3. item
I managed to replicate the example (from the link) for post_case_delete, post_run_save, and user_registered but the dir(tcms/templates/email/) lacks one for test case updates.
EDIT: It seems that adding dir and txt files for the others will undo the changes made to confirm_registration.
Is there a way to amend how the content is shown in the notification email?
Im trying to change the content of the notification email sent after a test case has been updated to better clarify what has been changed.
The link you've posted shows how to override templates (HTML, email, any kind of templates). However what context (e.g. which variables) get passed down to the template is up to the backend functions rendering that particular template.
As it is, the content is hard to read.
We thought diff is a pretty universal format but if you have other suggestions the best way is to start with opening an issue with examples, maybe a POC pull request.
In this particular example change history is automatically generated so any change will likely affect everything which deals with history but we need to see examples to comment further.
EDIT: It seems that adding dir and txt files for the others will undo the changes made to confirm_registration.
This is unrelated to the original question. Again I will have to see what exactly you are doing to tell you if/where the mistake is. The template engine in Django is trying to use the first template with a given name it finds. The search directory path tells it where to look for these templates. If you are somehow obscuring the files from the blog post then the application will not be able to find them hence you are not seeing the overriden changes you expect to.
Also follow https://github.com/kiwitcms/Kiwi/issues/1076 (not directly related but in the same domain space).

Automatic procmail filter based on username

I use postfix and procmail for mail and folder filtering. I have a main address and a bunch of alias addresses that go to it, then I sort the username to a folder that matches. For example I have the main address of 'address#domain.com" and a alias of "customer1#domain.com" pointing to it, and I have a folder called 'customer1' under 'address#domain.com' and a script like the following in .procmailrc -
:0:
* ^(To|Cc).*customer1#domain.com
.customer1/
and it works fine, but every time I add a alias I have to also add a line in .procmailrc to filter to it. Would there be a way I can create the alias, the folder, and have one procmail recipe that would grab the 'customer1' from the address and store the message in a folder by that same name? Even having procmail create the folder if it does not exist would be great too. Thanks!
Ok I found another question that was similar that solved this,
Procmail to automatically make new folders to store emails from new senders
So the following code solved the quesiton -
Who=`formail -zxTo: | cut -d# -f1`
:0
* ? mkdir -p ".$Who"
.$Who/
I tested it and it worked wonderfully

How safe is createuuid in a clustered environment?

The title pretty much says it all. The scenario is a user uploads a file but they could be hitting 1 of 6 servers depending on the current load at the time. We have run into a situation where the users are trying to upload files with special characters in their names. We can write a function to sanitize the file name but then we have to check that the new sanitized file name doesn't exists. My thought was to just rename the file using createuuid(). I believe the createuuid() function uses the servername as part of the algorithm if I remember correctly so if anything, the uniqueness should be 6 fold due to the 6 servers. Am I correct in this thinking?
If I remember correctly, CF uses timestamp+clock+servername.
Did you consider sanitizing the uploaded filename and just append the UUID? This appears failproof to me.

How to undo move files from filezilla

I have one problem about filezilla. I accidentally move one folder to wrong directory, so it shows the errors when I view my website.
How can I solve it? Please help me.
Many thanks in advance for your answer.
You cannot undo, but you should understand why that happened and how to prevent that from happening again in the future.
This happened because Filezilla allows Drag-and-drop move functionality on both folders (directories) and files, very dangerous on production servers.
There is actually a feature-request for 11 years now, please add your vote to the list to get this done: https://trac.filezilla-project.org/ticket/2191
In the mean time, please consider using another software that allows the user to set this behavior as an option:
WinSCP: http://winscp.net/eng/docs/screenshots
WS-FTP Pro: https://trac.filezilla-project.org/attachment/ticket/2191/ws_ftp-professional-options.gif
EDIT: Filezilla team responded (sort of) to the feature request and you can block drag and drop in the xml config file. It's better than nothing.
You cannot undo ftp moves. The only way to rectify the problem is to manually move the folder to it's original location.
I suggest you be more careful from next time.
If you don't know where the folder belongs, download the x-cart script package and check where the directory belongs.
Sorry for late, but I am up to date. I get logs from filezilla of moved files.
Status: Renaming '/var/www/html/brb/abc.js' to '/var/www/html/brb/node_modules/abc.js'
Status: /var/www/html/brb/abc.js -> /var/www/html/brb/node_modules/abc.js
Status: Renaming '/var/www/html/brb/xyz.html' to '/var/www/html/brb/node_modules/xyz.html'
Status: /var/www/html/brb/xyz.html -> /var/www/html/brb/node_modules/xyz.html
I write script in js to build command
let x = ['/var/www/html/brb/abc.js -> /var/www/html/brb/node_modules/abc.js',
'/var/www/html/brb/xyz.html -> /var/www/html/brb/node_modules/xyz.html'];
let cmd = [];
x.forEach(p => {
let path = p.split('->');
cmd.push(`mv ${path[1]} ${path[0]}`);
})
console.log(cmd);
Output:
['mv /var/www/html/brb/node_modules/abc.js /var/www/html/brb/abc.js'
'mv /var/www/html/brb/node_modules/xyz.html /var/www/html/brb/xyz.html']
Use any editor like vscode etc and remove string quotes and execute command in server terminal etc
mv /var/www/html/brb/node_modules/abc.js /var/www/html/brb/abc.js
mv /var/www/html/brb/node_modules/xyz.html /var/www/html/brb/xyz.html
A simple answer is,
Copy the folder into the desired location and then delete from the current location where you moved it mistakenly.
Now, what if you overwrite a file.
I just edited a file in local, then downloaded the file from my server into the local, and my all the local updated data is gone. There seems no solution of this, but there may be one possibility, I may be the lucky enough that this is my case.
If you were working on that local file, so most probably it is opened in your browser. Do not refresh it. Copy the content one by one, and update the file again. You can also open developers tools of both old and new page. Compare them line by line and do the job.
I had the same issue and resolved it manually.
The log panel was helpful in this. It is the large panel below the connection form in the top menu.
From that log panel, I was able to figure out all the files which were moved with their current and previous location.
I copied those all log lines and paste them somewhere in notepad and then manually selected all files and move those all at once to their original directory.
Screenshot: The log panel showing last actions

File downloader suggestions

I need to provide non-techie user ability to reliable download a few large files (3Gb) from URL without revealing the source URL of the file. Ideally I need single exe (without dependencies) that will download file from URL, specified inside exe: when user click on exe it just need show prompt where to save the file, and(optionally) will provide the user with some progress bar, for instance. The target URL can be specified directly in
the resource section, so I can edit URL path with HEX editor when I need set another path.
Wget are not suitable in my case, as its command line utility and requires user to specify an URL.
You could use the URLDownloadToFile function. Implement the IBindStatusCallback interface to receive progress information.
You really can't hide the source URL. Why are you trying to do that? If an end user runs tcpdump while they are running your program, they'll see where packets are coming from and going to.
I'd just provide them with a small batch file which calls ftp.exe. Tell your end user to drop the .BAT file where the downloaded file should go, and click it.
That solves quite a few problems, e.g. you know that your end user will be able to find the directory.