[SERVER-20075] Debian init script not setting correct permissions on PIDFILEPATH Created: 21/Aug/15  Updated: 14/Apr/16  Resolved: 21/Aug/15

Status: Closed
Project: Core Server
Component/s: Packaging
Affects Version/s: 3.0.2
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Petr Malik Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

> lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 7.8 (wheezy)
Release: 7.8
Codename: wheezy

> mongod --version
db version v3.0.2
git version: 6201872043ecbbc0a4cc169b5482dcf385fc464f
OpenSSL version: OpenSSL 1.0.1e 11 Feb 2013


Issue Links:
Duplicate
duplicates SERVER-18492 Setting pidFilePath to /var/run/mongo... Closed
Operating System: Linux
Steps To Reproduce:

1. Create a configuration file.

  1. /etc/mongod.conf
    processManagement.fork: false
    processManagement.pidFilePath: /var/run/mongod.pid
    systemLog.destination: file
    systemLog.path: /var/log/mongodb/mongod.log
    systemLog.logAppend: true
    storage.mmapv1.smallFiles: false
    storage.journal.enabled: true
    storage.dbPath: /var/lib/mongodb/
    net.bindIp: 127.0.0.1

2. Start mongod as a service.
> sudo service mongod start
[FAIL] Starting database: mongod failed!

3. Check the server log.
> tail -f /var/log/mongodb/mongod.log
2015-08-21T10:20:20.096-0400 I CONTROL ERROR: Cannot write pid file to /var/run/mongod.pid: Permission denied

4. Check the PID permissions.
> ls -l /run/mongod.pid
rw-rr- 1 root root 5 Aug 21 10:20 /run/mongod.pid

Participants:

 Description   

Debian init script does not ensure proper ownership/permissions on the PID file. The created PID file is not writable by the $DAEMONUSER (mongodb) causing the server to fail to start.

Is it possible to ensure the PID location is writable before starting the service - like you do in the Ubuntu upstart script at lines 23-24: https://github.com/mongodb/mongo/blob/f7675b0a306764d8a435a623b4af0b5bd63180d4/debian/mongod.upstart



 Comments   
Comment by Ramon Fernandez Marina [ 21/Aug/15 ]

This is a duplicate of SERVER-18492: /var/run is owned by the system, and setting pidFilePath to anything in that directory is incorrect – pidFilePath should point to a path that the mongodb user can write to.

We've opened DOCS-5696 to add clarification on this matter.

Regards,
Ramón.

Generated at Thu Feb 08 03:53:04 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.