[CalendarServer-changes] [3270] CalendarServer/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Wed Oct 29 17:59:32 PDT 2008
Revision: 3270
http://trac.macosforge.org/projects/calendarserver/changeset/3270
Author: wsanchez at apple.com
Date: 2008-10-29 17:59:32 -0700 (Wed, 29 Oct 2008)
Log Message:
-----------
Clean up checkDirectory():
* chmod/chown failure isn't fatal if we still have enough access.
Log the error, but don't exit.
Modified Paths:
--------------
CalendarServer/trunk/conf/caldavd.plist
CalendarServer/trunk/twistedcaldav/tap.py
Modified: CalendarServer/trunk/conf/caldavd.plist
===================================================================
--- CalendarServer/trunk/conf/caldavd.plist 2008-10-30 00:57:35 UTC (rev 3269)
+++ CalendarServer/trunk/conf/caldavd.plist 2008-10-30 00:59:32 UTC (rev 3270)
@@ -74,11 +74,11 @@
<!-- Data root -->
<key>DataRoot</key>
- <string>/var/run/caldavd</string>
+ <string>/var/run/caldavd/</string>
<!-- Document root -->
<key>DocumentRoot</key>
- <string>/Library/CalendarServer/Documents</string>
+ <string>/Library/CalendarServer/Documents/</string>
<!-- User quota (in bytes) -->
<key>UserQuota</key>
Modified: CalendarServer/trunk/twistedcaldav/tap.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/tap.py 2008-10-30 00:57:35 UTC (rev 3269)
+++ CalendarServer/trunk/twistedcaldav/tap.py 2008-10-30 00:59:32 UTC (rev 3270)
@@ -16,7 +16,10 @@
import os
import stat
+
from subprocess import Popen, PIPE
+from pwd import getpwnam
+from grp import getgrnam
from zope.interface import implements
@@ -187,7 +190,9 @@
if gid and gid != os.getgid():
gottaBeRoot()
+ #
# Ignore the logfile parameter if not daemonized and log to stdout.
+ #
if self.parent["nodaemon"]:
self.parent["logfile"] = None
else:
@@ -195,24 +200,14 @@
self.parent["pidfile"] = config.PIDFile
- # Verify that document root actually exists
+ #
+ # Verify that document root, data root actually exist
+ #
+ self.checkDirectory(config.DocumentRoot, "Document root")
self.checkDirectory(
- config.DocumentRoot,
- "Document root",
- access=os.W_OK,
- #permissions=0750,
- #uname=config.UserName,
- #gname=config.GroupName,
- )
-
- # Verify that data root actually exists
- self.checkDirectory(
config.DataRoot,
"Data root",
access=os.W_OK,
- #permissions=0750,
- #uname=config.UserName,
- #gname=config.GroupName,
create=(0750, config.UserName, config.GroupName,),
)
@@ -226,8 +221,8 @@
# Check current umask and warn if changed
oldmask = os.umask(config.umask)
if oldmask != config.umask:
- log.msg("WARNING: changing umask from: 0%03o to 0%03o"
- % (oldmask, config.umask,))
+ log.info("WARNING: changing umask from: 0%03o to 0%03o"
+ % (oldmask, config.umask,))
def checkDirectory(
self, dirpath, description,
@@ -235,29 +230,39 @@
uname=None, gname=None, create=None
):
if not os.path.exists(dirpath):
- if create is not None:
- # create is a tuple of (mode, username, groupname)
- try:
- os.mkdir(dirpath)
- os.chmod(dirpath, create[0])
- if create[1] and create[2]:
- import pwd
- import grp
- uid = pwd.getpwnam(create[1])[2]
- gid = grp.getgrnam(create[2])[2]
- os.chown(dirpath, uid, gid)
- except:
- log.msg("Could not create %s" % (dirpath,))
- raise ConfigurationError(
- "%s does not exist and cannot be created: %s"
- % (description, dirpath,)
- )
-
- log.msg("Created %s" % (dirpath,))
- else:
+ try:
+ mode, username, groupname = create
+ except TypeError:
raise ConfigurationError("%s does not exist: %s"
% (description, dirpath,))
+ try:
+ os.mkdir(dirpath)
+ except (OSError, IOError), e:
+ log.error("Could not create %s: %s" % (dirpath, e))
+ raise ConfigurationError(
+ "%s does not exist and cannot be created: %s"
+ % (description, dirpath,)
+ )
+ if username:
+ uid = getpwnam(username)[2]
+ else:
+ uid = -1
+
+ if groupname:
+ gid = getgrnam(groupname)[2]
+ else:
+ gid = -1
+
+ try:
+ os.chmod(dirpath, mode)
+ os.chown(dirpath, uid, gid)
+ except (OSError, IOError), e:
+ log.error("Unable to change mode/owner of %s: %s"
+ % (dirpath, e))
+
+ log.info("Created directory: %s" % (dirpath,))
+
if not os.path.isdir(dirpath):
raise ConfigurationError("%s is not a directory: %s"
% (description, dirpath,))
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20081029/aadf5bfc/attachment-0001.html>
More information about the calendarserver-changes
mailing list