sendmail with crontab using default from and to address - cron

When I run sendmail with crontab getting below logs in mail.log
2020-07-17T02:50:12.431886-07:00 localhost postfix/qmgr[1371]: 681EC1FFEF: from=<nramasurbramanian#localhost>, size=777, nrcpt=1 (queue active)
2020-07-17T02:50:12.435570-07:00 localhost postfix/local[26936]: 681EC1FFEF: to=<nramasurbramanian#localhost>, orig_to=<nramasurbramanian>, relay=local, delay=0.03, delays=0.02/0/0/0, dsn=2.0.0, status=sent (delivered to mailbox)
2020-07-17T02:50:12.435720-07:00 localhost postfix/qmgr[1371]: 681EC1FFEF: removed
Same when I run normally in command line it works fine, getting below
2020-07-17T02:51:17.838476-07:00 localhost postfix/qmgr[1371]: CC8291FFEF: from=<support#test.com>, size=2239, nrcpt=1 (queue active)
2020-07-17T02:51:19.016735-07:00 localhost postfix/smtp[27130]: CC8291FFEF: to=<in.support#test.com>, relay=aspmx.l.google.com[108.177.127.27]:25, delay=1.2, delays=0/0.02/0.76/0.4, dsn=2.0.0, status=sent (250 2.0.0 OK 1594979478 x17si5640395edq.338 - gsmtp)
2020-07-17T02:51:19.016905-07:00 localhost postfix/qmgr[1371]: CC8291FFEF: removed
Is there a default configuration which it is taking when running from crontab?

After providing the absolute path of sendmail /usr/sbin/sendmail and set in crontab this is working fine.

Related

How to send haproxy info log to rsyslog via unix sock?

Hi i'm trying to config haproxy/rsyslog so that ONLY haproxy info log is sent to ryslog via unix sock.
Here my config:
haproxy config
frontend MY_FRONT_END
log 127.0.0.1 /var/log/haproxy/dev/log info
bind *:12080
default_backend HTTP_BACKEND
rsyslog config
$ModLoad imuxsock
$InputUnixListenSocketCreatePath on
$InputUnixListenSocketHostName localhost
$AddUnixListenSocket /var/log/haproxy/dev/log
*.info /var/log/haproxy/access.log
However, what i see in the log is not just haproxy log, the log contain all the info that not relate to haproxy (the first three log lines)
Dec 28 20:28:12 localhost sudo: testaccount : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/bin/sh -c ip addr show
Dec 28 20:28:12 localhost sudo: testaccount : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/bin/sh -c ip route
Dec 28 20:28:13 localhost sudo: testaccount : TTY=pts/1 ; PWD=/var/log/haproxy ; USER=root ; COMMAND=/sbin/service haproxy restart
Dec 28 20:28:13 localhost polkitd[59350]: Registered Authentication Agent for unix-process:32995:43061437 (system bus name :1.28346 [/usr/bin/pkttyagent --notify-fd 5 --fallback], object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_CA.UTF-8)
Dec 28 20:28:13 localhost systemd: Stopping HAProxy Load Balancer...
Dec 28 20:28:13 localhost haproxy: [WARNING] 362/202813 (30706) : Exiting Master process...
Dec 28 20:28:13 localhost haproxy: [NOTICE] 362/202813 (30706) : haproxy version is 2.2.6
Dec 28 20:28:13 localhost haproxy: [NOTICE] 362/202813 (30706) : path to executable is /usr/local/sbin/haproxy
Dec 28 20:28:13 localhost haproxy: [ALERT] 362/202813 (30706) : Current worker #1 (30708) exited with code 143 (Terminated)
Dec 28 20:28:13 localhost haproxy: [WARNING] 362/202813 (30706) : All workers exited. Exiting... (0)
Dec 28 20:28:13 localhost systemd: Starting HAProxy Load Balancer...
Dec 28 20:28:13 localhost haproxy[33016]: Proxy MY_FRONT_END started.
Dec 28 20:28:13 localhost haproxy[33016]: Proxy HTTP_BACKEND started.
Dec 28 20:28:13 localhost haproxy: [NOTICE] 362/202813 (33016) : New worker #1 (33018) forked
Dec 28 20:28:13 localhost systemd: Started HAProxy Load Balancer.
Dec 28 20:28:13 localhost polkitd[59350]: Unregistered Authentication Agent for unix-process:32995:43061437 (system bus name :1.28346, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_CA.UTF-8) (disconnected from bus)
Dec 28 20:28:13 localhost sudo: testaccount : TTY=pts/1 ; PWD=/var/log/haproxy ; USER=root ; COMMAND=/sbin/service rsyslog restart
How do i config to achieve this (only send haproxy info log to rsyslog through unix sock) ?
The correct answer is probably to use a ruleset to embrace just the imuxsock part, but I don't know how to do that in legacy syntax.
A simpler solution that is less optimal is to check for the programname in the log item. To also match for severity levels 0 to 6 (emerg to info) gives the result:
if $programname=="haproxy" and $syslogseverity<=6 then /var/log/haproxy/access.log
I'm not sure, but you could alternatively try just moving your configuration earlier in the file, before the standard logging code, but then your haproxy logs would appear in the standard logs too unless you use something like
*.info /var/log/haproxy/access.log
*.* stop
where stop stops further processing of that input.

How to Debug Localhost - This Site Can't Be Reached

I setup LAMP on my MacOS computer using the https://getgrav.org/blog/macos-mojave-apache-upgrade-homebrew tutorial series.
It works for a month or two and then suddenly (without any changes made to config) it will stop working.
This site can’t be reached
localhost refused to connect.
ERR_CONNECTION_REFUSED
The last time this happened I gave up and re-installed from scratch. I don't want to have to do this each time it stops working.
Here is what I've tried so far this time:
jackrobson$ ps -aef | grep httpd
501 84635 459 0 5:03pm ttys000 0:00.00 grep httpd
jackrobson$ sudo apachectl -k restart
jackrobson$ tail -f /usr/local/var/log/httpd/error_log
[Sun Sep 16 14:43:22.548017 2018] [mpm_prefork:notice] [pid 74] AH00173: SIGHUP received. Attempting to restart
[Sun Sep 16 14:43:22.635379 2018] [mpm_prefork:notice] [pid 74] AH00163: Apache/2.4.34 (Unix) PHP/7.0.31 configured -- resuming normal operations
[Sun Sep 16 14:43:22.635437 2018] [core:notice] [pid 74] AH00094: Command line: '/usr/local/opt/httpd/bin/httpd -D FOREGROUND'
My /usr/local/etc/httpd/extra/httpd-vhosts.conf looks like:
<VirtualHost *:80>
DocumentRoot "/Users/jackrobson/Projects"
ServerName localhost
</VirtualHost>
As you can see, the last error was over two weeks ago. No errors today even though I'm getting the ERR_CONNECTION_REFUSED error.
Any suggestions will be greatly appreciated.
Got it working, these are the commands that I did before it worked:
jackrobson$ sudo apachectl stop
jackrobson$ sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist 2>/dev/null
jackrobson$ brew services restart httpd
==> Successfully started `httpd` (label: homebrew.mxcl.httpd)

DB2 instance creation failed while running db2icrt

I have installed DB2 10.5 server in my centos 7 VM.
I am trying to create a DB2 instance via running db2icrt
./db2icrt -u db2fenc1 db2inst1
But the command fails by issuing this :
Operating system information: Linux 3.10.0-229.el7.x86_64.#1 SMP Fri Mar 6 11:36:42 UTC 2015 x86_64
ERROR: The host name "vm65x148.acg.ips" is invalid. Specify a valid host name.
ERROR: The "db2icrt" command failed. Ensure the command parameters are valid,
that errors reported in the log file are fixed, then rerun the command.
The entry in my /etc/hosts file is this
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
I assume that vm65x148.acg.ips is the hostname of your machine. Make sure that this hostname can be resolved on the OS level, then try creating the instance again.
for more detail, see http://www-01.ibm.com/support/docview.wss?uid=swg21615752
As pointed out in the post by Peter Schuetze ,my /etc/hosts file was missing the entry of my VM id . So I tried to fix the issue by editing my /etc/hosts files
This is the initial entry in my /etc/hosts file
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
This is how it looked after editing
127.0.0.1 vm65x148.acg.ips localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
After that I restarted the daemon like this :
/etc/rc.d/init.d/network restart
Then I tried to create the DB2 instanceand this time it worked
Hope this helps someone else

cron selinux security context issue

my system is fedora 23.
trying to run a cronjob that is blocked by selinux in /etc/crontab.
* * * * sun,mon,tue,wed,thu,fri,sat root DISPLAY=:0 eog $HOME/Pictures/somepic.jpg
context for crontab:
-rw-r--r--. 1 root root unconfined_u:object_r:etc_t:s0 2664 Jan 23 18:12 /etc/crontab
if i run selinux in permissive mode, the job runs every time.
here's the journal entry for crond in 'enforce mode':
-- Logs begin at Wed 2016-01-20 10:40:21 PST. --
Jan 23 18:25:01 localhost.localdomain CROND[20342]: (root) CMDOUT (/bin/sh: root: command not found)
Jan 23 18:25:25 localhost.localdomain crond[938]: (CRON) INFO (Shutting down)
Jan 23 18:25:25 localhost.localdomain crond[18645]: (CRON) INFO (Syslog will be used instead of sendmail.)
Jan 23 18:25:25 localhost.localdomain crond[18645]: (CRON) INFO (RANDOM_DELAY will be scaled with factor 12% if used.)
Jan 23 18:25:25 localhost.localdomain crond[18645]: ((null)) Unauthorized SELinux context=system_u:system_r:system_cronjob_t:s0-s0:c0.c1023 file_context=unconfined_u:object_r:etc_t:s0 (/etc/crontab)
Jan 23 18:25:25 localhost.localdomain crond[18645]: (root) FAILED (loading cron table)
Jan 23 18:25:25 localhost.localdomain crond[18645]: (root) Unauthorized SELinux context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 file_context=unconfined_u:object_r:user_cron_spool_t:s0 (/var/spool/cron/root)
Jan 23 18:25:25 localhost.localdomain crond[18645]: (root) FAILED (loading cron table)
Jan 23 18:25:25 localhost.localdomain crond[18645]: (CRON) INFO (running with inotify support)
Jan 23 18:25:25 localhost.localdomain crond[18645]: (CRON) INFO (#reboot jobs will be run at computer's startup.)
sebool settings:
cron_can_relabel --> off
cron_system_cronjob_use_shares --> off
cron_userdomain_transition --> on
fcron_crond --> off
I'm having the same issue. Had a crontab that worked great for a long time. Made an edit with crontab -e, and it stopped working. Tried as both root and normal user. Some searching around, this is a currently known bug.
https://bugzilla.redhat.com/show_bug.cgi?id=1263328
I tried the workaround listed in comment #19. It's working fine.
Create file mycron.cil with content:
(allow unconfined_t user_cron_spool_t( file ( entrypoint)))
Then run:
semodule -i mycron.cil
Then restart cron:
systemctl restart crond.service
Comment 21 tells how to remove the workaround when a fix is issued.
Remove by running:
semodule -r mycron
and I assume restart cron again.
You need to change the type of the cron file under var/spool/cron
Try this to apply files triggerd 'Unauthorized SELinux context' messages
# semanage fcontext -a -t user_cron_spool_t "/var/spool/cron(/.*)?"
# restorecon -R -vv /var/spool/cron
I was trying this for shutting down my rhel 7.3 server automatically at 11:00 pm daily through cron job in /etc/crontab.
I faced the similar issue and selinux did not allowed to run the job.
However I got the solution by creating a new crontab file in /etc/cron.d/ and the cron job successfully executed and shutdown the system on defined time in /etc/cron.d/crontab file.
I got solution from below RHEL page on point 24.1.2 Scheduling a Cron Job""
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/system_administrators_guide/ch-automating_system_tasks

Stop spammers from relaying via sendmail?

For the life of me I cannot figure out how spammers are sendmail mail through my server with relaying off. I'm running Sendmail 8.14.7 on Slackware Linux 14.1. The spammers have not figured out a user's password and are therefore logging in first via SASL with AUTH LOGIN or I would see that in the log.
Heres an example from my logs, a spammer/bot from 182.234.55.47, off the top of someones head what would allow this? Any IP randomly in the world can do this, yet when I try it sendmail says "relaying denied...". I could not be more lost. I firewall them but it happens again an hour later from a different IP.
Feb 23 12:18:44 server sendmail[28315]: t1NHIIgY028315: <-- MAIL FROM: <re>
Feb 23 12:18:44 server sendmail[28315]: t1NHIIgY028315: --- 250 2.1.0 <re>... Sender ok
Feb 23 12:18:45 server sendmail[28315]: t1NHIIgY028315: <-- RCPT TO: <htucker566#gmail.com>
Feb 23 12:18:45 server sendmail[28315]: t1NHIIgY028315: --- 250 2.1.5 <htunhtunnaing.goldpot#gmail.com>... Recipient ok
Feb 23 12:18:47 server sendmail[28315]: t1NHIIgY028315: <-- DATA
Feb 23 12:18:47 server sendmail[28315]: t1NHIIgY028315: --- 354 Enter mail, end with "." on a line by itself
Feb 23 12:18:48 server sendmail[28315]: t1NHIIgY028315: from=<re>, size=496, class=0, nrcpts=5, msgid=<B3BE0AC12425C02A1FB8C9201EE5CB9E#jyvicegy>, proto=ESMTP, daemon=MTA, relay=host-47.55-234-182.cable.dynamic.kbtelecom.net [182.234.55.47]
Feb 23 12:18:48 central sendmail[28315]: t1NHIIgY028315: --- 250 2.0.0 t1NHIIgY028315 Message accepted for delivery

Resources