LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 08-06-2016, 06:02 PM   #1
Altiris
Member
 
Registered: Mar 2013
Posts: 556

Rep: Reputation: Disabled
Why is postgrey complaining about no pid file?


I just compiled postgrey for Slackware 14.1 on Slackbuilds.org using sbotools.

When I go to start the rc.postgrey, I get

Code:
etc/rc.d/rc.postgrey start
Starting postgrey milter:  /usr/bin/postgrey -d --inet=10025 --delay=60 --pidfile=/var/run/postgrey/postgrey.pid --user=%POSTGREYUSR% --group=%POSTGREYGRP% --dbdir=/var/lib/postgrey --hostname=MYHOSTNAMEHERE
This is the rc.postgrey file

Code:
#!/bin/bash

PORT=10025
PIDFILE=/var/run/postgrey/postgrey.pid
USER=%POSTGREYUSR%
GROUP=%POSTGREYGRP%
HOST=MYHOSTNAMEHERE

postgrey_start() {
  echo "Starting postgrey milter:  /usr/bin/postgrey -d --inet=$PORT --delay=60 --pidfile=$PIDFILE --user=$USER --group=$GROUP --dbdir=/var/lib/postgrey --hostname=$HOST"
  mkdir -p /var/run/postgrey
  /usr/bin/postgrey -d \
                    --inet=$PORT \
                    --delay=60
                    --pidfile=/var/run/postgrey/postgrey.pid \
                    --user=$USER --group=$GROUP \
                    --dbdir=/var/lib/postgrey \
                    --hostname=$HOST
}

postgrey_stop() {
  if [ -e $PIDFILE ]; then
    echo "Stopping postgrey milter..."
    kill $(cat $PIDFILE) 1>/dev/null
  fi
}

case "$1" in
'start')
  postgrey_start
  ;;
'stop')
  postgrey_stop
  ;;
'restart')
  postgrey_stop
  sleep 2
  postgrey_start
  ;;
*)
  echo "usage $0 start|stop|restart"
  ;;
esac
 
Old 08-06-2016, 06:10 PM   #2
Gerard Lally
Senior Member
 
Registered: Sep 2009
Location: Leinster, IE
Distribution: Slackware, NetBSD
Posts: 2,180

Rep: Reputation: 1763Reputation: 1763Reputation: 1763Reputation: 1763Reputation: 1763Reputation: 1763Reputation: 1763Reputation: 1763Reputation: 1763Reputation: 1763Reputation: 1763
Have you checked permissions on /var/run/postgrey and /var/lib/postgrey? What user and group did you create before building?
 
1 members found this post helpful.
Old 08-06-2016, 06:22 PM   #3
Altiris
Member
 
Registered: Mar 2013
Posts: 556

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by gezley View Post
Have you checked permissions on /var/run/postgrey and /var/lib/postgrey? What user and group did you create before building?
Ahhh this is what I forgot to mention that I was confused at when I looked at the .slackbuild. The slackbuild can be viewed here, https://slackbuilds.org/slackbuilds/...rey.SlackBuild and if you notice it says
Code:
# Need to run postgrey as anything other than root.  Use nobody account by
# default.  Change this to whatever user you want.
So I just left it as nogroup/nouser as I didn't want to mess with that as this is my first time running this software. Looking at /var/run/postgrey and /var/lib/postgrey, the permissions are that they are owned by "nobody" and "nogroup". Should I remove postgrey, make a group and user called postgrey, compile/install again? Or just leave it as default? If I do, what UID and group ID do I use?

Last edited by Altiris; 08-06-2016 at 06:25 PM.
 
Old 08-06-2016, 06:25 PM   #4
bassmadrigal
LQ Guru
 
Registered: Nov 2003
Location: West Jordan, UT, USA
Distribution: Slackware
Posts: 8,792

Rep: Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656
Are you supposed to add a USER and GROUP name? Because I'm not seeing where these would otherwise be set.

Code:
USER=%POSTGREYUSR%
GROUP=%POSTGREYGRP%


Looking more carefully at the SlackBuild, it seems it didn't finish properly (or you didn't use it), because there are sed lines to replace the user and group with the ones specified in the SlackBuild.

Where they're set:

Code:
# Need to run postgrey as anything other than root.  Use nobody account by
# default.  Change this to whatever user you want.
POSTGREYUSR=${POSTGREYUSR:-nobody}
POSTGREYGRP=${POSTGREYGRP:-nogroup}
POSTGREYUID=${POSTGREYUID:-98}
POSTGREYGID=${POSTGREYGID:-99}
And where the rc.postgrey is changed:

Code:
sed -e s/%POSTGREYUSR%/$POSTGREYUSR/g \
    -e s/%POSTGREYGRP%/$POSTGREYGRP/g \
    $CWD/rc.postgrey > $PKG/etc/rc.d/rc.postgrey.new
TL;DNR

Most likely, you can change the lines in your rc.postgrey to read:

Code:
USER=nobody
GROUP=nogroup
 
1 members found this post helpful.
Old 08-06-2016, 06:35 PM   #5
Gerard Lally
Senior Member
 
Registered: Sep 2009
Location: Leinster, IE
Distribution: Slackware, NetBSD
Posts: 2,180

Rep: Reputation: 1763Reputation: 1763Reputation: 1763Reputation: 1763Reputation: 1763Reputation: 1763Reputation: 1763Reputation: 1763Reputation: 1763Reputation: 1763Reputation: 1763
Quote:
Originally Posted by Altiris View Post
Ahhh this is what I forgot to mention that I was confused at when I looked at the .slackbuild. The slackbuild can be viewed here, https://slackbuilds.org/slackbuilds/...rey.SlackBuild and if you notice it says
Code:
# Need to run postgrey as anything other than root.  Use nobody account by
# default.  Change this to whatever user you want.
So I just left it as nogroup/nouser as I didn't want to mess with that as this is my first time running this software. Looking at /var/run/postgrey and /var/lib/postgrey, the permissions are that they are owned by "nobody" and "nogroup". Should I remove postgrey, make a group and user called postgrey, compile/install again? Or just leave it as default? If I do, what UID and group ID do I use?
No that's fine. The shell construct below tells you the slackbuild will use custom $POSTGREYUSR and $POSTGREYGRP values only if you defined them beforehand. If you did not do so then it will default to nobody and nogroup instead.

Code:
# Need to run postgrey as anything other than root.  Use nobody account by
# default.  Change this to whatever user you want.
POSTGREYUSR=${POSTGREYUSR:-nobody}
POSTGREYGRP=${POSTGREYGRP:-nogroup}
 
1 members found this post helpful.
Old 08-06-2016, 06:40 PM   #6
Altiris
Member
 
Registered: Mar 2013
Posts: 556

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by bassmadrigal View Post
Are you supposed to add a USER and GROUP name? Because I'm not seeing where these would otherwise be set.

Code:
USER=%POSTGREYUSR%
GROUP=%POSTGREYGRP%


Looking more carefully at the SlackBuild, it seems it didn't finish properly (or you didn't use it), because there are sed lines to replace the user and group with the ones specified in the SlackBuild.

Where they're set:

Code:
# Need to run postgrey as anything other than root.  Use nobody account by
# default.  Change this to whatever user you want.
POSTGREYUSR=${POSTGREYUSR:-nobody}
POSTGREYGRP=${POSTGREYGRP:-nogroup}
POSTGREYUID=${POSTGREYUID:-98}
POSTGREYGID=${POSTGREYGID:-99}
And where the rc.postgrey is changed:

Code:
sed -e s/%POSTGREYUSR%/$POSTGREYUSR/g \
    -e s/%POSTGREYGRP%/$POSTGREYGRP/g \
    $CWD/rc.postgrey > $PKG/etc/rc.d/rc.postgrey.new
TL;DNR

Most likely, you can change the lines in your rc.postgrey to read:

Code:
USER=nobody
GROUP=nogroup
Hmm I am not sure, the rc.postgrey is showing %POSTGREYUSR% ..I don't know a lot about bash or whatever language this is but to me that it appears its trying to call something
that was already defined, I am assuming when it was compiled? I am going to uninstall it and compile it with the changes you suggested making in the SlackBuild, though I have to ask one thing, what is
Code:
POSTGREYUID=${POSTGREYUID:-98}
POSTGREYGID=${POSTGREYGID:-99}
Do I leave that or change it?
 
Old 08-06-2016, 06:47 PM   #7
Gerard Lally
Senior Member
 
Registered: Sep 2009
Location: Leinster, IE
Distribution: Slackware, NetBSD
Posts: 2,180

Rep: Reputation: 1763Reputation: 1763Reputation: 1763Reputation: 1763Reputation: 1763Reputation: 1763Reputation: 1763Reputation: 1763Reputation: 1763Reputation: 1763Reputation: 1763
Quote:
Originally Posted by Altiris View Post
I have to ask one thing, what is
Code:
POSTGREYUID=${POSTGREYUID:-98}
POSTGREYGID=${POSTGREYGID:-99}
Do I leave that or change it?
Again, that's a shell construct: it means the UID and GID variables will fall back on these preset values of 98 and 99 if you haven't explicitly set them otherwise.
 
Old 08-06-2016, 10:00 PM   #8
bassmadrigal
LQ Guru
 
Registered: Nov 2003
Location: West Jordan, UT, USA
Distribution: Slackware
Posts: 8,792

Rep: Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656
@gezley, those variables are changed in the rc.postgrey file during the SlackBuild process. If they're still showing %POSTGREYUSR% and %POSTGREYGRP%, it means that the sed line wasn't processed in the SlackBuild to change it. According to the output from Altrius, those entries were never changed, which means he either didn't use the SlackBuild and just grabbed the files or the SlackBuild didn't execute properly.

@Altrius, you need to change them to the username/group, not the UID/GID. If you want them to be configurable by passing variables, you'd need them to be:

Code:
POSTGREYUID=${POSTGREYUID:-nobody}
POSTGREYGID=${POSTGREYGID:-nogroup}
Did you use the SlackBuild for this or build it manually?
 
Old 08-06-2016, 11:16 PM   #9
Altiris
Member
 
Registered: Mar 2013
Posts: 556

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by gezley View Post
Again, that's a shell construct: it means the UID and GID variables will fall back on these preset values of 98 and 99 if you haven't explicitly set them otherwise.
I think I understand. Late reply but, I removed postgrey, and made a postgrey user and group using the commands

Code:
groupadd -g 230 postgrey
useradd -u 230 -d /dev/null -s /bin/false -g postgrey postgrey
Then i edited the postgrey.Slackbuild and took out nobody and nogroup and put it in postgrey, as well as the GID and UID and then compiled/installed.

and then I also edited the rc.postgrey from

Code:
PORT=10025
PIDFILE=/var/run/postgrey/postgrey.pid
USER=%POSTGREYUSR%
GROUP=%POSTGREYGRP%
HOST=myhostnamehere
to

Code:
PORT=10025
PIDFILE=/var/run/postgrey/postgrey.pid
USER=postgrey
GROUP=postgrey
HOST=myhostnamehere
Not sure if I should have done that, either way I still get this error
Code:
Starting postgrey milter:  /usr/bin/postgrey -d --inet=10025 --delay=60 --pidfile=/var/run/postgrey/postgrey.pid --user=postgrey --group=postgrey --dbdir=/var/lib/postgrey --hostname=myhostnamehere
/etc/rc.d/rc.postgrey: line 16: --pidfile=/var/run/postgrey/postgrey.pid: No such file or directory
The files/folders you told me to look at before are both owned by the user and group postgrey btw.

EDIT: I just noticed this in the .SlackBuild

Code:
useradd -u ${POSTGREYUID} -d /var/lib/postgrey -s /bin/false -g ${POSTGREYGRP} ${POSTGREYUSR}"
I am going to re-do everything again as I did not have that -d /var/lib/postgrey ...see if that fixes it.
EDIT2: Nope, same problem sadly.

Last edited by Altiris; 08-06-2016 at 11:28 PM.
 
Old 08-06-2016, 11:54 PM   #10
bassmadrigal
LQ Guru
 
Registered: Nov 2003
Location: West Jordan, UT, USA
Distribution: Slackware
Posts: 8,792

Rep: Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656
You really should use the SlackBuild, as that sets everything up for this to run properly.

Your issue now is that the user doesn't have access to the directory to create the pid file. That directory is created in the SlackBuild and chown'd to the user specified further up in the SlackBuild.

There's also /var/lib/postgrey/ created and chown'd in the SlackBuild that will need to be done as well.

Since I'd recommend you using the SlackBuild, if you want to keep the postgrey user/group, just run the following.

Code:
POSTGREYUSR=postgrey POSTGREYGRP=postgrey POSTGREYUID=230 POSTGREYGID=230 postgrey.SlackBuild
However, it'd be fine to just keep using the default user "nobody" and the default group "nogroup" (which means you could just run the SlackBuild without all the extra options). I don't think this program warrants having it's own user (but that's solely up to you). You just shouldn't run the program as root, so they picked the nobody account, which is created by default on Slackware.

Last edited by bassmadrigal; 08-06-2016 at 11:55 PM.
 
Old 08-07-2016, 12:10 AM   #11
Altiris
Member
 
Registered: Mar 2013
Posts: 556

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by bassmadrigal View Post
You really should use the SlackBuild, as that sets everything up for this to run properly.

Your issue now is that the user doesn't have access to the directory to create the pid file. That directory is created in the SlackBuild and chown'd to the user specified further up in the SlackBuild.

There's also /var/lib/postgrey/ created and chown'd in the SlackBuild that will need to be done as well.

Since I'd recommend you using the SlackBuild, if you want to keep the postgrey user/group, just run the following.

Code:
POSTGREYUSR=postgrey POSTGREYGRP=postgrey POSTGREYUID=230 POSTGREYGID=230 postgrey.SlackBuild
However, it'd be fine to just keep using the default user "nobody" and the default group "nogroup" (which means you could just run the SlackBuild without all the extra options). I don't think this program warrants having it's own user (but that's solely up to you). You just shouldn't run the program as root, so they picked the nobody account, which is created by default on Slackware.
Okay I am completely confused now. I am using the slackbuild, I always was using the slackbuild. I first compiled postgrey with all of the default options in the postgrey.Slackbuild and I had the pid file error. That is when I then tried to create a specific user and group by editing the postgrey.Slackbuild to see if that would get rid of the pid error, but it didn't. So now I am sort of stuck with what I should do. What you are telling me to paste into the terminal is what I already did by manually editing the postgrey.SlackBuild ....it shouldn't be any different right or should I try it again? I am just wondering why it keeps complaining about the pid file, even if I use a custom user or nobody/nogroup. I am going to do as you say though and just use the default configuration from the Slackbuild, though I am still going to have that pid error I think.

Last edited by Altiris; 08-07-2016 at 12:14 AM.
 
Old 08-07-2016, 01:27 AM   #12
bassmadrigal
LQ Guru
 
Registered: Nov 2003
Location: West Jordan, UT, USA
Distribution: Slackware
Posts: 8,792

Rep: Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656
Well then something is really screwy. I'm not sure if it is with the SlackBuild or your computer, and I don't have time to test the SlackBuild right now. As a quick and dirty fix, change the rc.postgrey to USER=nobody and GROUP=nogroup and then make sure /var/lib/postgrey/ and /var/run/postgrey/ folders are created and owned by nobody:nogroup. That should allow you to start the daemon assuming nothing else is screwed up.

If you haven't cleared your package source and packaging directories, can you post the file /tmp/SBo/package-postgrey/etc/rc.d/rc.postgrey.new ?
 
1 members found this post helpful.
Old 08-07-2016, 11:35 AM   #13
Altiris
Member
 
Registered: Mar 2013
Posts: 556

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by bassmadrigal View Post
Well then something is really screwy. I'm not sure if it is with the SlackBuild or your computer, and I don't have time to test the SlackBuild right now. As a quick and dirty fix, change the rc.postgrey to USER=nobody and GROUP=nogroup and then make sure /var/lib/postgrey/ and /var/run/postgrey/ folders are created and owned by nobody:nogroup. That should allow you to start the daemon assuming nothing else is screwed up.

If you haven't cleared your package source and packaging directories, can you post the file /tmp/SBo/package-postgrey/etc/rc.d/rc.postgrey.new ?
I apologize again for the late reply, went to sleep. I have no clue either, I doubt it could be the SlackBuild as these things are normally tested, but who knows. I will do as you say for the quick and dirty fix, and sure I can send you the rc.postgrey.new file

..However, /tmp/SBo/package-postgrey/etc/rc.d/rc.postgrey.new does not exist. I have /tmp/SBo/postgrey and inside that I have
Code:
COPYING  README.exim   postgrey*
Changes  contrib/      postgrey_whitelist_clients
README   policy-test*  postgrey_whitelist_recipients
The rc.postgrey.new looks like this

Code:
#!/bin/bash

PORT=10025
PIDFILE=/var/run/postgrey/postgrey.pid
USER=%POSTGREYUSR%
GROUP=%POSTGREYGRP%
HOST=mail.example.com

postgrey_start() {
  echo "Starting postgrey milter:  /usr/bin/postgrey -d --inet=$PORT --pidfile=$PIDFILE --user=$USER --group=$GROUP --dbdir=/var/lib/postgrey --hostname=$HOST"
  mkdir -p /var/run/postgrey
  /usr/bin/postgrey -d \
                    --inet=$PORT \
                    --pidfile=/var/run/postgrey/postgrey.pid \
                    --user=$USER --group=$GROUP \
                    --dbdir=/var/lib/postgrey \
                    --hostname=$HOST
}

postgrey_stop() {
  if [ -e $PIDFILE ]; then
    echo "Stopping postgrey milter..."
    kill $(cat $PIDFILE) 1>/dev/null
  fi
}

case "$1" in
'start')
  postgrey_start
  ;;
'stop')
  postgrey_stop
  ;;
'restart')
  postgrey_stop
  sleep 2
  postgrey_start
  ;;
*)
  echo "usage $0 start|stop|restart"
  ;;
esac
 
Old 08-07-2016, 11:39 AM   #14
Altiris
Member
 
Registered: Mar 2013
Posts: 556

Original Poster
Rep: Reputation: Disabled
Uhhh so I think you might hate me for this. I had been working on this last night stopping and starting....I forgot that I had made an alteration to the rc.postgrey, which included this --delay=60 that I added I completely forgot that I had added it in.....I used the new rc.postgrey.new (renamed to rc.postgrey) which did not have the --delay=60 option set and now it starts perfectly fine...lol sorry. Now I need to figure out how to change that delay to 60 as I do not want 300 as it is too long.

Figured out how to add the delay, I need a \ sign ...guess that's what I get for using a transparent terminal emulator, things are hard to see.

Last edited by Altiris; 08-07-2016 at 11:42 AM.
 
Old 08-07-2016, 12:35 PM   #15
bassmadrigal
LQ Guru
 
Registered: Nov 2003
Location: West Jordan, UT, USA
Distribution: Slackware
Posts: 8,792

Rep: Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656
No worries, I'm glad you got it working.

As for the /tmp/SBo/package-postgrey/ directory, that should be created when the make install occurs with the SlackBuild. Unless you have something clear the tmp directories after a build, it should exist as that is the directory that makepkg is called from.
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to kill PID based from pid file contents apss_evaluator Linux - Newbie 4 07-30-2015 08:07 AM
postgrey in centos:warning: connect to /var/spool/postfix/postgrey/socket SarahGurung Linux - Security 4 09-10-2014 04:00 AM
Confluence PID issue. (Removing/clearing stale PID file) vignesh4sh Linux - Server 5 12-05-2012 07:14 AM
[SOLVED] squid - incorrect pid in pid file theIndividualist Linux - Software 2 05-31-2012 08:23 AM
ERROR: Couldn't write pid to pid file lawrencegoodman Linux - Newbie 2 02-13-2004 08:05 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 08:45 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration