Tag Archives: sendmail

I was receiving [email protected] as the sender of mails from my WordPress site hosted on Digital Ocean.

Check revealed:

/etc# grep -inr 'd1stkfactory'
mailname~:1:d1stkfactory
mail/sendmail.mc:107:MASQUERADE_AS(`d1stkfactory')dnl
mail/sendmail.cf:161:DMd1stkfactory
mail/sendmail.cf:1996:# MASQUERADE_AS(`d1stkfactory')dnl
exim4/update-exim4.conf.conf~:20:dc_other_hostnames='d1stkfactory'

Fix:

emacs mail/sendmail.cf
emacs mail/sendmail.mc

And changing:MASQUERADE_AS settings

I found the following errors after installing sendmail:

apt-get install sendmail:

Errors in generating sendmail.cf
*** ERROR: FEATURE() should be before MAILER()
*** MAILER(`local') must appear after FEATURE(`always_add_domain')*** ERROR: FEATURE() should be before MAILER()
*** MAILER(`local') must appear after FEATURE(`allmasquerade')*** ERROR: FEATURE() should be before MAILER()

Starting Mail Transport Agent (MTA): sendmail.
Setting up sensible-mda (8.14.3-9.4) ...
Setting up sendmail (8.14.3-9.4) ...

Apparently sendmail.cf located at /etc/mail/sendmail.cf is automatically generated. To fix the issue, edit /etc/mail/sendmail.mc

#grep -in FEATURE\(\`always_add_domain\'\) ./etc/mail/sendmail.mc
106:FEATURE(`always_add_domain')dnl

#grep -in MAILER ./etc/mail/sendmail.mc
100:dnl # Default Mailer setup
101:MAILER_DEFINITIONS
102:MAILER(`local')dnl
103:MAILER(`smtp')dnl

I edited the lines from #100, and switched the positions of the MAILER and FEATURE tags.

Once edited, sendmail.cf should be autoregenerated with:

sendmailconfig

 

I was using OpenSUSE at my workplace and needed to add myself to the sudoers group. I did that successfully, but the first time I tried to use sudo, I found that the system was asking for the root password instead of my password as happens in Ubuntu.

The reason was the following line in the sudoers file (/etc/sudoers):

Defaults rootpw

This means that all sudo functions require the root password, instead of the user password

You can set this only for one user, with:

Defaults:jim rootpw

Here, only jim will be asked for root password.

Note that the proper way of editing the sudoers file is by running the following command:

visudo

Sudo settings may be viewed by the following command:

sudo -V

 

#sudo -V
Sudo version 1.7.4p4

Configure args: --prefix=/usr -v --with-all-insults --with-devel --with-pam --with-fqdn --with-logging=syslog --with-logfac=authpriv --with-env-editor --with-editor=/usr/bin/editor --with-timeout=15 --with-password-timeout=0 --with-passprompt=[sudo] password for %p:  --with-timedir=/var/lib/sudo --disable-root-mailer --disable-setresuid --with-sendmail=/usr/sbin/sendmail --mandir=/usr/share/man --libexecdir=/usr/lib/sudo --with-secure-path=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin
Sudoers path: /etc/sudoers
Authentication methods: 'pam'
Syslog facility if syslog is being used for logging: authpriv
Syslog priority to use when user authenticates successfully: notice
Syslog priority to use when user authenticates unsuccessfully: alert
Send mail if the user is not in sudoers
Use a separate timestamp for each user/tty combo
Lecture user the first time they run sudo
Require users to authenticate by default
Root may run sudo
Allow some information gathering to give useful error messages
Require fully-qualified hostnames in the sudoers file
Visudo will honor the EDITOR environment variable
Set the LOGNAME and USER environment variables
Length at which to wrap log file lines (0 for no wrap): 80
Authentication timestamp timeout: 15.0 minutes
Password prompt timeout: 0.0 minutes
Number of tries to enter a password: 3
Umask to use or 0777 to use user's: 022
Path to mail program: /usr/sbin/sendmail
Flags for mail program: -t
Address to send mail to: root
Subject line for mail messages: *** SECURITY information for %h ***
Incorrect password message: Sorry, try again.
Path to authentication timestamp dir: /var/lib/sudo
Default password prompt: [sudo] password for %p:
Default user to run commands as: root
Value to override user's $PATH with: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin
Path to the editor for use by visudo: /usr/bin/editor
When to require a password for 'list' pseudocommand: any
When to require a password for 'verify' pseudocommand: all
File containing dummy exec functions: /usr/lib/sudo/sudo_noexec.so
File descriptors >= 3 will be closed before executing a command
Reset the environment to a default set of variables
Environment variables to check for sanity:
        TERM
        LINGUAS
        LC_*
        LANGUAGE
        LANG
        COLORTERM
Environment variables to remove:
        RUBYOPT
        RUBYLIB
        PYTHONUSERBASE
        PYTHONINSPECT
        PYTHONPATH
        PYTHONHOME
        TMPPREFIX
        ZDOTDIR
        READNULLCMD
        NULLCMD
        FPATH
        PERL5DB
        PERL5OPT
        PERL5LIB
        PERLLIB
        PERLIO_DEBUG
        JAVA_TOOL_OPTIONS
        SHELLOPTS
        GLOBIGNORE
        PS4
        BASH_ENV
        ENV
        TERMCAP
        TERMPATH
        TERMINFO_DIRS
        TERMINFO
        _RLD*
        LD_*
        PATH_LOCALE
        NLSPATH
        HOSTALIASES
        RES_OPTIONS
        LOCALDOMAIN
        PS4
        SHELLOPTS
        CDPATH
        IFS
Environment variables to preserve:
        XAUTHORIZATION
        XAUTHORITY
        TZ
        PS2
        PS1
        PATH
        LS_COLORS
        KRB5CCNAME
        HOSTNAME
        DISPLAY
        COLORS
Locale to use while parsing sudoers: C
Compress I/O logs using zlib

 

The following is a very useful beginner’s guide to sudoers:

http://www.developertutorials.com/tutorials/linux/using-sudo-050511-1194/

At times it was noted that sendmail on my Debian system was not getting completely removed.

Thing tried:

apt-get remove sendmail*

It worked at times, and didnt at others.

But I were to try:

netstat -tulpn | grep :25
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      27878/sendmail: MTA

I’d find it again.

To find where it came from, I did:

 ls -l /proc/27878/
total 0
-r-------- 1 root root 0 Mar  5 12:47 auxv
-r--r--r-- 1 root root 0 Mar  5 11:58 cmdline
-rw-r--r-- 1 root root 0 Mar  5 12:47 coredump_filter
-r--r--r-- 1 root root 0 Mar  5 12:47 cpusete
lrwxrwxrwx 1 root root 0 Mar  5 12:47 cwd -> (deleted) /var/spool/mqueue
-r-------- 1 root root 0 Mar  5 12:47 environ
lrwxrwxrwx 1 root root 0 Mar  5 11:58 exe -> (deleted) /usr/lib/sm.bin/sendmail

Note that it shows /usr/lib/sm.bin/sendmail

However there is no /usr/lib/sm.bin, but there sure is a /usr/lib/sendmail

So I deleted them, and restarted the apache2 server.

 service apache2 restart
[ ok ] Restarting web server: apache2 ... waiting .
[email protected]:~/imscp# netstat -tulpn | grep :25
[email protected]:~/imscp# netstat -tulpn | grep 'sendmail'

Another thing that worked once was doing this:

chmod ugo=rw /etc/init.d/sendmail

In other words, I prevented it from running. But in the earlier instance there was no entry for sendmail under init.d