backend/common/rhnLib.py | 13 +++++++------
backend/server/importlib/importLib.py | 9 +++++----
backend/server/rhnPackageUpload.py | 3 ++-
3 files changed, 14 insertions(+), 11 deletions(-)
New commits:
commit 8b82c31351821e1099ea682553751efe6933f34f
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Wed Dec 9 15:09:49 2009 +0100
fixed logging in rhnLib.py
diff --git a/backend/common/rhnLib.py b/backend/common/rhnLib.py
index da3fa71..18a6260 100644
--- a/backend/common/rhnLib.py
+++ b/backend/common/rhnLib.py
@@ -24,6 +24,8 @@ import string
import popen2
import select
import urlparse
+from common import log_debug, log_error
+
try:
import hashlib
except ImportError:
@@ -512,7 +514,7 @@ def startswith(s, prefix):
def setPermsPath(path, user='apache', group='root', chmod=0750):
"""chown user.group and set permissions to chmod"""
if not os.path.exists(path):
- log(-1, "*** ERROR: Path doesn't exist (can't set permissions):
%s" % path, stream=sys.stderr)
+ log_error("*** ERROR: Path doesn't exist (can't set permissions):
%s" % path)
sys.exit(-1)
# If non-root, don't bother to change owners
@@ -522,18 +524,17 @@ def setPermsPath(path, user='apache', group='root',
chmod=0750):
gc = GecosCache()
uid = gc.getuid(user)
if uid is None:
- log(-1, messages.missing_user % user, stream=sys.stderr)
+ log_error(messages.missing_user % user)
sys.exit(-1)
gid = gc.getgid(group)
if gid is None:
- log(-1, messages.missing_group % group, stream=sys.stderr)
+ log_error(messages.missing_group % group)
sys.exit(-1)
uid_, gid_ = os.stat(path)[4:6]
if uid_ != uid or gid_ != gid:
- log(3, " Performing 'chown %s.%s %s'" % (user, group, path),
- stream=sys.stderr)
+ log_debug(3, " Performing 'chown %s.%s %s'" % (user, group,
path))
os.chown(path, uid, gid)
os.chmod(path, chmod)
@@ -645,7 +646,7 @@ def createPath(path, user='apache', group='root',
chmod=0755, logging=1):
path = cleanupAbsPath(path)
if not os.path.exists(path):
if logging:
- log(4, " Creating path: %s" % path, stream=sys.stderr)
+ log_debug(4, " Creating path: %s" % path)
makedirs(path, mode=chmod, user=user, group=group)
elif not os.path.isdir(path):
raise ValueError, "ERROR: createPath('%s'): path doesn't lead to
a directory" % str(path)
commit b802c0dc304ea75e871bfc2df6036af243d21ce7
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Tue Dec 8 14:18:26 2009 +0100
fixed two more rhn_mpm imports
diff --git a/backend/server/importlib/importLib.py
b/backend/server/importlib/importLib.py
index 6c9e2b4..b8ccdee 100644
--- a/backend/server/importlib/importLib.py
+++ b/backend/server/importlib/importLib.py
@@ -22,10 +22,11 @@ from types import IntType, StringType, InstanceType
from UserDict import UserDict
from UserList import UserList
-from common import log_debug, rhn_mpm
+from common import log_debug
from common.rhnLib import maketemp, getFileChecksum, createPath, setPermsPath
from server.rhnLib import get_package_path
+from spacewalk.common import rhn_mpm
# no-op class, used to define the type of an attribute
class DateType:
diff --git a/backend/server/rhnPackageUpload.py b/backend/server/rhnPackageUpload.py
index 547bbf4..a16671d 100644
--- a/backend/server/rhnPackageUpload.py
+++ b/backend/server/rhnPackageUpload.py
@@ -18,7 +18,8 @@
import os
import tempfile
-from common import CFG, log_debug, rhnFault, rhn_mpm, rhnLib, UserDictCase
+from common import CFG, log_debug, rhnFault, rhnLib, UserDictCase
+from spacewalk.common import rhn_mpm
from spacewalk.common.rhn_rpm import get_header_byte_range
from server import rhnSQL
commit c2b56b7e01c305277eb737b6338a3f88bb3946b3
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Wed Dec 9 14:39:47 2009 +0100
fixed syntax error
diff --git a/backend/common/rhnLib.py b/backend/common/rhnLib.py
index 82c4c1c..da3fa71 100644
--- a/backend/common/rhnLib.py
+++ b/backend/common/rhnLib.py
@@ -532,7 +532,7 @@ def setPermsPath(path, user='apache', group='root',
chmod=0750):
uid_, gid_ = os.stat(path)[4:6]
if uid_ != uid or gid_ != gid:
- log(3, " Performing 'chown %s.%s %s'" % (user, group, path))
+ log(3, " Performing 'chown %s.%s %s'" % (user, group, path),
stream=sys.stderr)
os.chown(path, uid, gid)
os.chmod(path, chmod)
commit fd48c14fa88f53c59ea117e235f93c7010fc79a3
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Wed Dec 9 14:35:35 2009 +0100
516767 - create files with default repository owner/group/permissions
rather than root.root
diff --git a/backend/server/importlib/importLib.py
b/backend/server/importlib/importLib.py
index 3d9f5f4..6c9e2b4 100644
--- a/backend/server/importlib/importLib.py
+++ b/backend/server/importlib/importLib.py
@@ -23,7 +23,7 @@ from UserDict import UserDict
from UserList import UserList
from common import log_debug, rhn_mpm
-from common.rhnLib import maketemp, getFileChecksum
+from common.rhnLib import maketemp, getFileChecksum, createPath, setPermsPath
from server.rhnLib import get_package_path
@@ -848,7 +848,7 @@ def copy_package(fd, basedir, relpath, checksum, force=None):
dir = os.path.dirname(packagePath)
# Create the directory where the file will reside
if not os.path.exists(dir):
- os.makedirs(dir)
+ createPath(dir)
pkgfd = os.open(packagePath, os.O_WRONLY | os.O_CREAT | os.O_TRUNC)
os.lseek(fd, 0, 0)
while 1:
@@ -862,7 +862,7 @@ def copy_package(fd, basedir, relpath, checksum, force=None):
n, len(buffer), packagePath)
os.close(pkgfd)
# set the path perms readable by all users
- os.chmod(packagePath, 0644)
+ setPermsPath(packagePath, chmod=0644)
# Assuming packageData is an RPM package, writes it on the disk